From cfe-commits at lists.llvm.org Mon Jul 6 00:02:01 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 07:02:01 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically Message-ID: gamesh411 created this revision. Herald added subscribers: cfe-commits, ASDenysPetrov, martong, steakhal, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, whisperity. Herald added a reviewer: Szelethus. Herald added a project: clang. In case a pointer iterator is incremented in a binary plus expression (operator+), where the iterator is on the RHS, IteratorModeling should now detect, and track the resulting value. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83190 Files: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp clang/test/Analysis/iterator-modeling.cpp Index: clang/test/Analysis/iterator-modeling.cpp =================================================================== --- clang/test/Analysis/iterator-modeling.cpp +++ clang/test/Analysis/iterator-modeling.cpp @@ -1948,7 +1948,7 @@ clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.end() - 2}} } -void plus_ptr_iterator(const cont_with_ptr_iterator &c) { +void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) { auto i1 = c.begin(); clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()"); @@ -1960,6 +1960,18 @@ clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}} } +void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) { + auto i1 = c.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()"); + + auto i2 = 2 + i1; + + clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}} + clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}} + clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}} +} + void minus_ptr_iterator(const cont_with_ptr_iterator &c) { auto i1 = c.end(); Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -264,16 +264,23 @@ CheckerContext &C) const { ProgramStateRef State = C.getState(); BinaryOperatorKind OK = BO->getOpcode(); - SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext()); + Expr *LHS = BO->getLHS(); + Expr *RHS = BO->getRHS(); + SVal LVal = State->getSVal(LHS, C.getLocationContext()); + SVal RVal = State->getSVal(RHS, C.getLocationContext()); if (isSimpleComparisonOperator(BO->getOpcode())) { - SVal LVal = State->getSVal(BO->getLHS(), C.getLocationContext()); SVal Result = State->getSVal(BO, C.getLocationContext()); handleComparison(C, BO, Result, LVal, RVal, BinaryOperator::getOverloadedOperator(OK)); } else if (isRandomIncrOrDecrOperator(OK)) { - handlePtrIncrOrDecr(C, BO->getLHS(), - BinaryOperator::getOverloadedOperator(OK), RVal); + // In case of operator+ the iterator can be either on the LHS (eg.: it + 1), + // or on the RHS (eg.: 1 + it). Both cases are modeled. + bool IsItOnLHS = BO->getLHS()->getType()->isPointerType(); + Expr *&ItExpr = IsItOnLHS ? LHS : RHS; + SVal &OffsetVal = IsItOnLHS ? RVal : LVal; + handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK), + OffsetVal); } } @@ -563,7 +570,7 @@ const SVal &LHS, const SVal &RHS) const { // Increment or decrement the symbolic expressions which represents the - // position of the iterator + // position of the iterator. auto State = C.getState(); const auto *Pos = getIteratorPosition(State, LHS); -------------- next part -------------- A non-text attachment was scrubbed... Name: D83190.275594.patch Type: text/x-patch Size: 3237 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 00:06:53 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 07:06:53 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <846f0bd9ebdc8d7bfbfc5f2db8cad0bf@localhost.localdomain> gamesh411 updated this revision to Diff 275595. gamesh411 added a comment. remove unrelated comment formatting Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 Files: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp clang/test/Analysis/iterator-modeling.cpp Index: clang/test/Analysis/iterator-modeling.cpp =================================================================== --- clang/test/Analysis/iterator-modeling.cpp +++ clang/test/Analysis/iterator-modeling.cpp @@ -1948,7 +1948,7 @@ clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.end() - 2}} } -void plus_ptr_iterator(const cont_with_ptr_iterator &c) { +void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) { auto i1 = c.begin(); clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()"); @@ -1960,6 +1960,18 @@ clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}} } +void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) { + auto i1 = c.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()"); + + auto i2 = 2 + i1; + + clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}} + clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}} + clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}} +} + void minus_ptr_iterator(const cont_with_ptr_iterator &c) { auto i1 = c.end(); Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -264,16 +264,23 @@ CheckerContext &C) const { ProgramStateRef State = C.getState(); BinaryOperatorKind OK = BO->getOpcode(); - SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext()); + Expr *LHS = BO->getLHS(); + Expr *RHS = BO->getRHS(); + SVal LVal = State->getSVal(LHS, C.getLocationContext()); + SVal RVal = State->getSVal(RHS, C.getLocationContext()); if (isSimpleComparisonOperator(BO->getOpcode())) { - SVal LVal = State->getSVal(BO->getLHS(), C.getLocationContext()); SVal Result = State->getSVal(BO, C.getLocationContext()); handleComparison(C, BO, Result, LVal, RVal, BinaryOperator::getOverloadedOperator(OK)); } else if (isRandomIncrOrDecrOperator(OK)) { - handlePtrIncrOrDecr(C, BO->getLHS(), - BinaryOperator::getOverloadedOperator(OK), RVal); + // In case of operator+ the iterator can be either on the LHS (eg.: it + 1), + // or on the RHS (eg.: 1 + it). Both cases are modeled. + bool IsItOnLHS = BO->getLHS()->getType()->isPointerType(); + Expr *&ItExpr = IsItOnLHS ? LHS : RHS; + SVal &OffsetVal = IsItOnLHS ? RVal : LVal; + handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK), + OffsetVal); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83190.275595.patch Type: text/x-patch Size: 2857 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 01:25:44 2020 From: cfe-commits at lists.llvm.org (Kazushi Marukawa via cfe-commits) Date: Mon, 06 Jul 2020 01:25:44 -0700 (PDT) Subject: [clang] df3bda0 - [VE] Correct stack alignment Message-ID: <5f02e008.1c69fb81.d000c.0bec@mx.google.com> Author: Kazushi (Jam) Marukawa Date: 2020-07-06T17:25:29+09:00 New Revision: df3bda047d5abe9190bdd0422270328140556bd4 URL: https://github.com/llvm/llvm-project/commit/df3bda047d5abe9190bdd0422270328140556bd4 DIFF: https://github.com/llvm/llvm-project/commit/df3bda047d5abe9190bdd0422270328140556bd4.diff LOG: [VE] Correct stack alignment Summary: Change stack alignment from 64 bits to 128 bits to follow ABI correctly. And add a regression test for datalayout. Reviewers: simoll, k-ishizaka Reviewed By: simoll Subscribers: hiraditya, cfe-commits, llvm-commits Tags: #llvm, #ve, #clang Differential Revision: https://reviews.llvm.org/D83173 Added: Modified: clang/lib/Basic/Targets/VE.h clang/test/CodeGen/target-data.c llvm/lib/Target/VE/VETargetMachine.cpp Removed: ################################################################################ diff --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h index 7e50e7daeb90..f863a0af0acb 100644 --- a/clang/lib/Basic/Targets/VE.h +++ b/clang/lib/Basic/Targets/VE.h @@ -45,7 +45,7 @@ class LLVM_LIBRARY_VISIBILITY VETargetInfo : public TargetInfo { WCharType = UnsignedInt; WIntType = UnsignedInt; UseZeroLengthBitfieldAlignment = true; - resetDataLayout("e-m:e-i64:64-n32:64-S64"); + resetDataLayout("e-m:e-i64:64-n32:64-S128"); } void getTargetDefines(const LangOptions &Opts, diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c index e619843f4bdb..8c740119cd1b 100644 --- a/clang/test/CodeGen/target-data.c +++ b/clang/test/CodeGen/target-data.c @@ -250,3 +250,7 @@ // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=BPFEB // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128" + +// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=VE +// VE: target datalayout = "e-m:e-i64:64-n32:64-S128" diff --git a/llvm/lib/Target/VE/VETargetMachine.cpp b/llvm/lib/Target/VE/VETargetMachine.cpp index a0c8ae0c82d7..08b55eebbc98 100644 --- a/llvm/lib/Target/VE/VETargetMachine.cpp +++ b/llvm/lib/Target/VE/VETargetMachine.cpp @@ -41,8 +41,8 @@ static std::string computeDataLayout(const Triple &T) { // VE supports 32 bit and 64 bits integer on registers Ret += "-n32:64"; - // Stack alignment is 64 bits - Ret += "-S64"; + // Stack alignment is 128 bits + Ret += "-S128"; return Ret; } From cfe-commits at lists.llvm.org Mon Jul 6 01:58:20 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via cfe-commits) Date: Mon, 06 Jul 2020 01:58:20 -0700 (PDT) Subject: [clang] bd50cf9 - Fix indentation in FixedPoint.h. NFC. Message-ID: <5f02e7ac.1c69fb81.f3c05.fe64@mx.google.com> Author: Bevin Hansson Date: 2020-07-06T10:57:21+02:00 New Revision: bd50cf905fa7c0c7caa134301c6ca0658c81eeb1 URL: https://github.com/llvm/llvm-project/commit/bd50cf905fa7c0c7caa134301c6ca0658c81eeb1 DIFF: https://github.com/llvm/llvm-project/commit/bd50cf905fa7c0c7caa134301c6ca0658c81eeb1.diff LOG: Fix indentation in FixedPoint.h. NFC. Added: Modified: clang/include/clang/Basic/FixedPoint.h Removed: ################################################################################ diff --git a/clang/include/clang/Basic/FixedPoint.h b/clang/include/clang/Basic/FixedPoint.h index 8937bccb0edb..0d181f30907f 100644 --- a/clang/include/clang/Basic/FixedPoint.h +++ b/clang/include/clang/Basic/FixedPoint.h @@ -93,52 +93,52 @@ class FixedPointSemantics { /// point types and should eventually be moved to LLVM if fixed point types gain /// native IR support. class APFixedPoint { - public: - APFixedPoint(const llvm::APInt &Val, const FixedPointSemantics &Sema) - : Val(Val, !Sema.isSigned()), Sema(Sema) { - assert(Val.getBitWidth() == Sema.getWidth() && - "The value should have a bit width that matches the Sema width"); - } - - APFixedPoint(uint64_t Val, const FixedPointSemantics &Sema) - : APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()), - Sema) {} - - // Zero initialization. - APFixedPoint(const FixedPointSemantics &Sema) : APFixedPoint(0, Sema) {} - - llvm::APSInt getValue() const { return llvm::APSInt(Val, !Sema.isSigned()); } - inline unsigned getWidth() const { return Sema.getWidth(); } - inline unsigned getScale() const { return Sema.getScale(); } - inline bool isSaturated() const { return Sema.isSaturated(); } - inline bool isSigned() const { return Sema.isSigned(); } - inline bool hasPadding() const { return Sema.hasUnsignedPadding(); } - FixedPointSemantics getSemantics() const { return Sema; } - - bool getBoolValue() const { return Val.getBoolValue(); } - - // Convert this number to match the semantics provided. If the overflow - // parameter is provided, set this value to true or false to indicate if this - // operation results in an overflow. - APFixedPoint convert(const FixedPointSemantics &DstSema, - bool *Overflow = nullptr) const; - - // Perform binary operations on a fixed point type. The resulting fixed point - // value will be in the common, full precision semantics that can represent - // the precision and ranges of both input values. See convert() for an - // explanation of the Overflow parameter. - APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const; - APFixedPoint sub(const APFixedPoint &Other, bool *Overflow = nullptr) const; - APFixedPoint mul(const APFixedPoint &Other, bool *Overflow = nullptr) const; - APFixedPoint div(const APFixedPoint &Other, bool *Overflow = nullptr) const; - - /// Perform a unary negation (-X) on this fixed point type, taking into - /// account saturation if applicable. - APFixedPoint negate(bool *Overflow = nullptr) const; - - APFixedPoint shr(unsigned Amt) const { - return APFixedPoint(Val >> Amt, Sema); - } +public: + APFixedPoint(const llvm::APInt &Val, const FixedPointSemantics &Sema) + : Val(Val, !Sema.isSigned()), Sema(Sema) { + assert(Val.getBitWidth() == Sema.getWidth() && + "The value should have a bit width that matches the Sema width"); + } + + APFixedPoint(uint64_t Val, const FixedPointSemantics &Sema) + : APFixedPoint(llvm::APInt(Sema.getWidth(), Val, Sema.isSigned()), + Sema) {} + + // Zero initialization. + APFixedPoint(const FixedPointSemantics &Sema) : APFixedPoint(0, Sema) {} + + llvm::APSInt getValue() const { return llvm::APSInt(Val, !Sema.isSigned()); } + inline unsigned getWidth() const { return Sema.getWidth(); } + inline unsigned getScale() const { return Sema.getScale(); } + inline bool isSaturated() const { return Sema.isSaturated(); } + inline bool isSigned() const { return Sema.isSigned(); } + inline bool hasPadding() const { return Sema.hasUnsignedPadding(); } + FixedPointSemantics getSemantics() const { return Sema; } + + bool getBoolValue() const { return Val.getBoolValue(); } + + // Convert this number to match the semantics provided. If the overflow + // parameter is provided, set this value to true or false to indicate if this + // operation results in an overflow. + APFixedPoint convert(const FixedPointSemantics &DstSema, + bool *Overflow = nullptr) const; + + // Perform binary operations on a fixed point type. The resulting fixed point + // value will be in the common, full precision semantics that can represent + // the precision and ranges of both input values. See convert() for an + // explanation of the Overflow parameter. + APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const; + APFixedPoint sub(const APFixedPoint &Other, bool *Overflow = nullptr) const; + APFixedPoint mul(const APFixedPoint &Other, bool *Overflow = nullptr) const; + APFixedPoint div(const APFixedPoint &Other, bool *Overflow = nullptr) const; + + /// Perform a unary negation (-X) on this fixed point type, taking into + /// account saturation if applicable. + APFixedPoint negate(bool *Overflow = nullptr) const; + + APFixedPoint shr(unsigned Amt) const { + return APFixedPoint(Val >> Amt, Sema); + } APFixedPoint shl(unsigned Amt) const { return APFixedPoint(Val << Amt, Sema); From cfe-commits at lists.llvm.org Mon Jul 6 04:06:58 2020 From: cfe-commits at lists.llvm.org (=?UTF-8?Q?Kirst=C3=B3f_Umann?= via cfe-commits) Date: Mon, 06 Jul 2020 04:06:58 -0700 (PDT) Subject: [clang] 690ff37 - [analyzer] Force dependency checkers to be hidden Message-ID: <5f0305d2.1c69fb81.b9c0f.465e@mx.google.com> Author: Kirstóf Umann Date: 2020-07-06T13:05:45+02:00 New Revision: 690ff37a286991f142584f25842e50c6cb23aba6 URL: https://github.com/llvm/llvm-project/commit/690ff37a286991f142584f25842e50c6cb23aba6 DIFF: https://github.com/llvm/llvm-project/commit/690ff37a286991f142584f25842e50c6cb23aba6.diff LOG: [analyzer] Force dependency checkers to be hidden Since strong dependencies aren't user-facing (its hardly ever legal to disable them), lets enforce that they are hidden. Modeling checkers that aren't dependencies are of course not impacted, but there is only so much you can do against developers shooting themselves in the foot :^) I also made some changes to the test files, reversing the "test" package for, well, testing. Differential Revision: https://reviews.llvm.org/D81761 Added: Modified: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp Removed: ################################################################################ diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 0ceedfb8771b..c1baa52a69b6 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -130,7 +130,8 @@ def CallAndMessageModeling : Checker<"CallAndMessageModeling">, "function/method call. For instance, if we can't reason about the " "nullability of the implicit this parameter after a method call, " "this checker conservatively assumes it to be non-null">, - Documentation; + Documentation, + Hidden; def CallAndMessageChecker : Checker<"CallAndMessage">, HelpText<"Check for logical errors for function calls and Objective-C " @@ -220,7 +221,8 @@ def StackAddrEscapeChecker : Checker<"StackAddressEscape">, def DynamicTypePropagation : Checker<"DynamicTypePropagation">, HelpText<"Generate dynamic type information">, - Documentation; + Documentation, + Hidden; def NonnullGlobalConstantsChecker: Checker<"NonnilStringConstants">, HelpText<"Assume that const string-like globals are non-null">, @@ -363,7 +365,8 @@ def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">, "false", InAlpha> ]>, - Documentation; + Documentation, + Hidden; def TrustNonnullChecker : Checker<"TrustNonnull">, HelpText<"Trust that returns from framework methods annotated with _Nonnull " diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp index a68820523eaf..528284ca8985 100644 --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp @@ -310,6 +310,13 @@ template void CheckerRegistry::resolveDependencies() { DependencyIt->FullName == Entry.second && "Failed to find the dependency of a checker!"); + // We do allow diagnostics from unit test/example dependency checkers. + assert((DependencyIt->FullName.startswith("test") || + DependencyIt->FullName.startswith("example") || IsWeak || + DependencyIt->IsHidden) && + "Strong dependencies are modeling checkers, and as such " + "non-user facing! Mark them hidden in Checkers.td!"); + if (IsWeak) CheckerIt->WeakDependencies.emplace_back(&*DependencyIt); else diff --git a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp index c7c75955f97f..60b8aafa0d84 100644 --- a/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp +++ b/clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp @@ -42,17 +42,16 @@ class CustomChecker : public Checker { void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.CustomChecker", true}}; + AnOpts.CheckersAndPackages = {{"test.CustomChecker", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { - Registry.addChecker("custom.CustomChecker", "Description", - ""); + Registry.addChecker("test.CustomChecker", "Description", ""); }); } TEST(RegisterCustomCheckers, RegisterChecker) { std::string Diags; EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags)); - EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description\n"); + EXPECT_EQ(Diags, "test.CustomChecker:Custom diagnostic description\n"); } //===----------------------------------------------------------------------===// @@ -121,7 +120,7 @@ bool shouldRegisterCheckerRegistrationOrderPrinter(const CheckerManager &mgr) { void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) { Registry.addChecker(registerCheckerRegistrationOrderPrinter, shouldRegisterCheckerRegistrationOrderPrinter, - "custom.RegistrationOrder", "Description", "", false); + "test.RegistrationOrder", "Description", "", false); } #define UNITTEST_CHECKER(CHECKER_NAME, DIAG_MSG) \ @@ -142,7 +141,7 @@ void addCheckerRegistrationOrderPrinter(CheckerRegistry &Registry) { } \ void add##CHECKER_NAME(CheckerRegistry &Registry) { \ Registry.addChecker(register##CHECKER_NAME, shouldRegister##CHECKER_NAME, \ - "custom." #CHECKER_NAME, "Description", "", false); \ + "test." #CHECKER_NAME, "Description", "", false); \ } UNITTEST_CHECKER(StrongDep, "Strong") @@ -155,22 +154,22 @@ bool shouldRegisterStrongFALSE(const CheckerManager &mgr) { void addDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) { Registry.addChecker(registerStrongDep, shouldRegisterStrongFALSE, - "custom.Strong", "Description", "", false); + "test.Strong", "Description", "", false); addStrongDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.Dep", "custom.Strong"); + Registry.addDependency("test.Dep", "test.Strong"); }); } TEST(RegisterDeps, UnsatisfiedDependency) { std::string Diags; EXPECT_TRUE(runCheckerOnCode("void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.RegistrationOrder\n"); } //===----------------------------------------------------------------------===// @@ -181,52 +180,52 @@ UNITTEST_CHECKER(WeakDep, "Weak") void addWeakDepCheckerBothEnabled(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.WeakDep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.WeakDep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addWeakDepCheckerBothEnabledSwitched(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.WeakDep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.WeakDep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addWeakDependency("custom.WeakDep", "custom.Dep"); + Registry.addWeakDependency("test.WeakDep", "test.Dep"); }); } void addWeakDepCheckerDepDisabled(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.WeakDep", false}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.WeakDep", false}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addWeakDepCheckerDepUnspecified(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } @@ -235,10 +234,10 @@ UNITTEST_CHECKER(Dep2, "Dep2") void addWeakDepHasWeakDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.WeakDep", true}, - {"custom.WeakDep2", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.WeakDep", true}, + {"test.WeakDep2", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); @@ -246,17 +245,17 @@ void addWeakDepHasWeakDep(AnalysisASTConsumer &AnalysisConsumer, addDep(Registry); addDep2(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); - Registry.addWeakDependency("custom.WeakDep", "custom.WeakDep2"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); + Registry.addWeakDependency("test.WeakDep", "test.WeakDep2"); }); } void addWeakDepTransitivity(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.WeakDep", false}, - {"custom.WeakDep2", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.WeakDep", false}, + {"test.WeakDep2", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); @@ -264,8 +263,8 @@ void addWeakDepTransitivity(AnalysisASTConsumer &AnalysisConsumer, addDep(Registry); addDep2(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); - Registry.addWeakDependency("custom.WeakDep", "custom.WeakDep2"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); + Registry.addWeakDependency("test.WeakDep", "test.WeakDep2"); }); } @@ -273,42 +272,40 @@ TEST(RegisterDeps, SimpleWeakDependency) { std::string Diags; EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.WeakDep\ncustom." - "Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep\ntest." + "Dep\ntest.RegistrationOrder\n"); Diags.clear(); // Mind that AnalyzerOption listed the enabled checker list in the same order, // but the dependencies are switched. EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.Dep\ncustom." - "RegistrationOrder\ncustom.WeakDep\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest." + "RegistrationOrder\ntest.WeakDep\n"); Diags.clear(); // Weak dependencies dont prevent dependent checkers from being enabled. EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, - "custom.RegistrationOrder:custom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest.RegistrationOrder\n"); Diags.clear(); // Nor will they be enabled just because a dependent checker is. EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, - "custom.RegistrationOrder:custom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest.RegistrationOrder\n"); Diags.clear(); EXPECT_TRUE( runCheckerOnCode("void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.WeakDep2\ncustom." - "Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep2\ntest." + "Dep\ntest.RegistrationOrder\n"); Diags.clear(); EXPECT_TRUE( runCheckerOnCode("void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.WeakDep2\ncustom." - "WeakDep\ncustom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep2\ntest." + "WeakDep\ntest.Dep\ntest.RegistrationOrder\n"); Diags.clear(); } @@ -318,98 +315,98 @@ TEST(RegisterDeps, SimpleWeakDependency) { void addWeakDepHasStrongDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.StrongDep", true}, - {"custom.WeakDep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.StrongDep", true}, + {"test.WeakDep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.WeakDep", "custom.StrongDep"); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addDependency("test.WeakDep", "test.StrongDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addWeakDepAndStrongDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.StrongDep", true}, - {"custom.WeakDep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.StrongDep", true}, + {"test.WeakDep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.Dep", "custom.StrongDep"); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addDependency("test.Dep", "test.StrongDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addDisabledWeakDepHasStrongDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.StrongDep", true}, - {"custom.WeakDep", false}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.StrongDep", true}, + {"test.WeakDep", false}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.WeakDep", "custom.StrongDep"); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addDependency("test.WeakDep", "test.StrongDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addDisabledWeakDepHasUnspecifiedStrongDep( AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.WeakDep", false}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.WeakDep", false}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.WeakDep", "custom.StrongDep"); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addDependency("test.WeakDep", "test.StrongDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addWeakDepHasDisabledStrongDep(AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.StrongDep", false}, - {"custom.WeakDep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.StrongDep", false}, + {"test.WeakDep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); addDep(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.WeakDep", "custom.StrongDep"); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addDependency("test.WeakDep", "test.StrongDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } void addWeakDepHasUnspecifiedButLaterEnabledStrongDep( AnalysisASTConsumer &AnalysisConsumer, AnalyzerOptions &AnOpts) { - AnOpts.CheckersAndPackages = {{"custom.Dep", true}, - {"custom.Dep2", true}, - {"custom.WeakDep", true}, - {"custom.RegistrationOrder", true}}; + AnOpts.CheckersAndPackages = {{"test.Dep", true}, + {"test.Dep2", true}, + {"test.WeakDep", true}, + {"test.RegistrationOrder", true}}; AnalysisConsumer.AddCheckerRegistrationFn([=](CheckerRegistry &Registry) { addStrongDep(Registry); addWeakDep(Registry); addDep(Registry); addDep2(Registry); addCheckerRegistrationOrderPrinter(Registry); - Registry.addDependency("custom.WeakDep", "custom.StrongDep"); - Registry.addDependency("custom.Dep2", "custom.StrongDep"); - Registry.addWeakDependency("custom.Dep", "custom.WeakDep"); + Registry.addDependency("test.WeakDep", "test.StrongDep"); + Registry.addDependency("test.Dep2", "test.StrongDep"); + Registry.addWeakDependency("test.Dep", "test.WeakDep"); }); } @@ -417,8 +414,8 @@ TEST(RegisterDeps, DependencyInteraction) { std::string Diags; EXPECT_TRUE( runCheckerOnCode("void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.StrongDep\ncustom." - "WeakDep\ncustom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.StrongDep\ntest." + "WeakDep\ntest.Dep\ntest.RegistrationOrder\n"); Diags.clear(); // Weak dependencies are registered before strong dependencies. This is most @@ -427,39 +424,36 @@ TEST(RegisterDeps, DependencyInteraction) { // established in between the modeling portion and the weak dependency. EXPECT_TRUE( runCheckerOnCode("void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.WeakDep\ncustom." - "StrongDep\ncustom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.WeakDep\ntest." + "StrongDep\ntest.Dep\ntest.RegistrationOrder\n"); Diags.clear(); // If a weak dependency is disabled, the checker itself can still be enabled. EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, "custom.RegistrationOrder:custom.Dep\ncustom." - "RegistrationOrder\ncustom.StrongDep\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest." + "RegistrationOrder\ntest.StrongDep\n"); Diags.clear(); // If a weak dependency is disabled, the checker itself can still be enabled, // but it shouldn't enable a strong unspecified dependency. EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, - "custom.RegistrationOrder:custom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest.RegistrationOrder\n"); Diags.clear(); // A strong dependency of a weak dependency is disabled, so neither of them // should be enabled. EXPECT_TRUE(runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, - "custom.RegistrationOrder:custom.Dep\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.Dep\ntest.RegistrationOrder\n"); Diags.clear(); EXPECT_TRUE( runCheckerOnCode( "void f() {int i;}", Diags)); - EXPECT_EQ(Diags, - "custom.RegistrationOrder:custom.StrongDep\ncustom.WeakDep\ncustom." - "Dep\ncustom.Dep2\ncustom.RegistrationOrder\n"); + EXPECT_EQ(Diags, "test.RegistrationOrder:test.StrongDep\ntest.WeakDep\ntest." + "Dep\ntest.Dep2\ntest.RegistrationOrder\n"); Diags.clear(); } } // namespace From cfe-commits at lists.llvm.org Mon Jul 6 04:41:41 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via cfe-commits) Date: Mon, 06 Jul 2020 04:41:41 -0700 (PDT) Subject: [clang] 7349479 - RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal Message-ID: <5f030df5.1c69fb81.de1a5.0dd9@mx.google.com> Author: Dmitri Gribenko Date: 2020-07-06T13:38:01+02:00 New Revision: 7349479f2244c32c0184ca545af04adb171c8077 URL: https://github.com/llvm/llvm-project/commit/7349479f2244c32c0184ca545af04adb171c8077 DIFF: https://github.com/llvm/llvm-project/commit/7349479f2244c32c0184ca545af04adb171c8077.diff LOG: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal Summary: How does RecursiveASTVisitor call the WalkUp callback for expressions? * In pre-order traversal mode, RecursiveASTVisitor calls the WalkUp callback from the default implementation of Traverse callbacks. * In post-order traversal mode when we don't have a DataRecursionQueue, RecursiveASTVisitor also calls the WalkUp callback from the default implementation of Traverse callbacks. * However, in post-order traversal mode when we have a DataRecursionQueue, RecursiveASTVisitor calls the WalkUp callback from PostVisitStmt. As a result, when the user overrides the Traverse callback, in pre-order traversal mode they never get the corresponding WalkUp callback. However in the post-order traversal mode the WalkUp callback is invoked or not depending on whether the data recursion optimization could be applied. I had to adjust the implementation of TraverseCXXForRangeStmt in the syntax tree builder to call the WalkUp method directly, as it was relying on this behavior. There is an existing test for this functionality and it prompted me to make this extra fix. In addition, I had to fix the default implementation implementation of RecursiveASTVisitor::TraverseSynOrSemInitListExpr to call WalkUpFrom in the same manner as the implementation generated by the DEF_TRAVERSE_STMT macro. Without this fix, the InitListExprIsPostOrderNoQueueVisitedTwice test was failing because WalkUpFromInitListExpr was never called. Reviewers: eduucaldas, ymandel Reviewed By: eduucaldas, ymandel Subscribers: gribozavr2, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82486 Added: Modified: clang/include/clang/AST/RecursiveASTVisitor.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index b16c1ae1e483..464a80d15cef 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -83,6 +83,42 @@ namespace clang { return false; \ } while (false) +namespace detail { + +template +struct has_same_member_pointer_type : std::false_type {}; +template +struct has_same_member_pointer_type + : std::true_type {}; + +template struct is_same_method_impl { + template + static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr, + SecondMethodPtrTy SecondMethodPtr) { + return false; + } +}; + +template <> struct is_same_method_impl { + template + static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr, + SecondMethodPtrTy SecondMethodPtr) { + return FirstMethodPtr == SecondMethodPtr; + } +}; + +/// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr +/// are pointers to the same non-static member function. +template +bool isSameMethod(FirstMethodPtrTy FirstMethodPtr, + SecondMethodPtrTy SecondMethodPtr) { + return is_same_method_impl::value>::isSameMethod(FirstMethodPtr, SecondMethodPtr); +} + +} // end namespace detail + /// A class that does preorder or postorder /// depth-first traversal on the entire Clang AST and visits each node. /// @@ -325,23 +361,17 @@ template class RecursiveASTVisitor { Stmt::child_range getStmtChildren(Stmt *S) { return S->children(); } private: - template - struct has_same_member_pointer_type : std::false_type {}; - template - struct has_same_member_pointer_type - : std::true_type {}; - // Traverse the given statement. If the most-derived traverse function takes a // data recursion queue, pass it on; otherwise, discard it. Note that the // first branch of this conditional must compile whether or not the derived // class can take a queue, so if we're taking the second arm, make the first // arm call our function rather than the derived class version. #define TRAVERSE_STMT_BASE(NAME, CLASS, VAR, QUEUE) \ - (has_same_member_pointer_type::value \ + (::clang::detail::has_same_member_pointer_type< \ + decltype(&RecursiveASTVisitor::Traverse##NAME), \ + decltype(&Derived::Traverse##NAME)>::value \ ? static_cast::value, \ Derived &, RecursiveASTVisitor &>>(*this) \ @@ -609,17 +639,38 @@ bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { #define ABSTRACT_STMT(STMT) #define STMT(CLASS, PARENT) \ case Stmt::CLASS##Class: \ - TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break; + /* In pre-order traversal mode, each Traverse##STMT method is responsible \ + * for calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT \ + * and does not call the default implementation, the WalkUpFrom callback \ + * is not called. Post-order traversal mode should provide the same \ + * behavior regarding method overrides. \ + * \ + * In post-order traversal mode the Traverse##STMT method, when it \ + * receives a DataRecursionQueue, can't call WalkUpFrom after traversing \ + * children because it only enqueues the children and does not traverse \ + * them. TraverseStmt traverses the enqueued children, and we call \ + * WalkUpFrom here. \ + * \ + * However, to make pre-order and post-order modes identical with regards \ + * to whether they call WalkUpFrom at all, we call WalkUpFrom if and only \ + * if the user did not override the Traverse##STMT method. */ \ + if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \ + &Derived::Traverse##CLASS)) { \ + TRY_TO(WalkUpFrom##CLASS(static_cast(S))); \ + } \ + break; #define INITLISTEXPR(CLASS, PARENT) \ case Stmt::CLASS##Class: \ - { \ + /* See the comment above for the explanation of the isSameMethod check. */ \ + if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \ + &Derived::Traverse##CLASS)) { \ auto ILE = static_cast(S); \ if (auto Syn = ILE->isSemanticForm() ? ILE->getSyntacticForm() : ILE) \ TRY_TO(WalkUpFrom##CLASS(Syn)); \ if (auto Sem = ILE->isSemanticForm() ? ILE : ILE->getSemanticForm()) \ TRY_TO(WalkUpFrom##CLASS(Sem)); \ - break; \ - } + } \ + break; #include "clang/AST/StmtNodes.inc" } @@ -2216,8 +2267,13 @@ DEF_TRAVERSE_DECL(RequiresExprBodyDecl, {}) TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); \ } \ } \ - if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) \ + /* Call WalkUpFrom if TRY_TO_TRAVERSE_OR_ENQUEUE_STMT has traversed the \ + * children already. If TRY_TO_TRAVERSE_OR_ENQUEUE_STMT only enqueued the \ + * children, PostVisitStmt will call WalkUpFrom after we are done visiting \ + * children. */ \ + if (!Queue && ReturnValue && getDerived().shouldTraversePostOrder()) { \ TRY_TO(WalkUpFrom##STMT(S)); \ + } \ return ReturnValue; \ } @@ -2388,6 +2444,9 @@ bool RecursiveASTVisitor::TraverseSynOrSemInitListExpr( for (Stmt *SubStmt : S->children()) { TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(SubStmt); } + + if (!Queue && getDerived().shouldTraversePostOrder()) + TRY_TO(WalkUpFromInitListExpr(S)); } return true; } diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 8185af2a6cc7..4371a303bb9d 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -578,15 +578,19 @@ class BuildTreeVisitor : public RecursiveASTVisitor { // RAV traverses it as a statement, we produce invalid node kinds in that // case. // FIXME: should do this in RAV instead? - if (S->getInit() && !TraverseStmt(S->getInit())) - return false; - if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable())) - return false; - if (S->getRangeInit() && !TraverseStmt(S->getRangeInit())) - return false; - if (S->getBody() && !TraverseStmt(S->getBody())) - return false; - return true; + bool Result = [&, this]() { + if (S->getInit() && !TraverseStmt(S->getInit())) + return false; + if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable())) + return false; + if (S->getRangeInit() && !TraverseStmt(S->getRangeInit())) + return false; + if (S->getBody() && !TraverseStmt(S->getBody())) + return false; + return true; + }(); + WalkUpFromCXXForRangeStmt(S); + return Result; } bool TraverseStmt(Stmt *S) { diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp index 66aa1d763833..1ab843d437a8 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp @@ -154,22 +154,17 @@ TraverseIntegerLiteral IntegerLiteral(5) R"txt( TraverseIntegerLiteral IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt IntegerLiteral(1) TraverseIntegerLiteral IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt IntegerLiteral(2) TraverseIntegerLiteral IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt BinaryOperator(+) WalkUpFromStmt DeclRefExpr(add) WalkUpFromStmt ImplicitCastExpr TraverseIntegerLiteral IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) -WalkUpFromStmt IntegerLiteral(4) TraverseIntegerLiteral IntegerLiteral(5) WalkUpFromStmt IntegerLiteral(5) -WalkUpFromStmt IntegerLiteral(5) WalkUpFromStmt CallExpr(add) WalkUpFromStmt CompoundStmt )txt")); @@ -258,23 +253,14 @@ TraverseIntegerLiteral IntegerLiteral(1) WalkUpFromIntegerLiteral IntegerLiteral(1) WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromIntegerLiteral IntegerLiteral(1) - WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) TraverseIntegerLiteral IntegerLiteral(2) WalkUpFromIntegerLiteral IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromIntegerLiteral IntegerLiteral(2) - WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) TraverseIntegerLiteral IntegerLiteral(3) WalkUpFromIntegerLiteral IntegerLiteral(3) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromIntegerLiteral IntegerLiteral(3) - WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) WalkUpFromExpr BinaryOperator(+) WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr DeclRefExpr(add) @@ -285,16 +271,10 @@ TraverseIntegerLiteral IntegerLiteral(4) WalkUpFromIntegerLiteral IntegerLiteral(4) WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) -WalkUpFromIntegerLiteral IntegerLiteral(4) - WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) TraverseIntegerLiteral IntegerLiteral(5) WalkUpFromIntegerLiteral IntegerLiteral(5) WalkUpFromExpr IntegerLiteral(5) WalkUpFromStmt IntegerLiteral(5) -WalkUpFromIntegerLiteral IntegerLiteral(5) - WalkUpFromExpr IntegerLiteral(5) - WalkUpFromStmt IntegerLiteral(5) WalkUpFromExpr CallExpr(add) WalkUpFromStmt CallExpr(add) WalkUpFromStmt CompoundStmt @@ -436,12 +416,13 @@ WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) )txt")); + // FIXME: The following log should include a call to WalkUpFromStmt for + // UnaryOperator(-). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt UnaryOperator(-) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -507,6 +488,8 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); + // FIXME: The following log should include a call to WalkUpFromUnaryOperator + // for UnaryyOperator(-). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -514,9 +497,6 @@ WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromUnaryOperator UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -817,13 +797,14 @@ WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(4) )txt")); + // FIXME: The following log should include a call to WalkUpFromStmt for + // BinaryOperator(+). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt BinaryOperator(+) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); @@ -891,6 +872,7 @@ WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) )txt")); + // FIXME: The following log should include a call to WalkUpFromBinaryOperator. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -900,9 +882,6 @@ WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromBinaryOperator BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt @@ -1216,13 +1195,14 @@ WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) )txt")); + // FIXME: The following log should include a call to WalkUpFromStmt for + // CompoundAssignOperator(+=). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) WalkUpFromStmt DeclRefExpr(a) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -1291,6 +1271,8 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); + // FIXME: The following log should include a call to + // WalkUpFromCompoundAssignOperator. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1300,9 +1282,6 @@ WalkUpFromExpr DeclRefExpr(a) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) - WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -1636,7 +1615,6 @@ TraverseCallExpr CallExpr(add) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(5) WalkUpFromStmt CallExpr(add) -WalkUpFromStmt CallExpr(add) WalkUpFromStmt CompoundStmt )txt")); } @@ -1730,9 +1708,6 @@ TraverseCallExpr CallExpr(add) WalkUpFromCallExpr CallExpr(add) WalkUpFromExpr CallExpr(add) WalkUpFromStmt CallExpr(add) -WalkUpFromCallExpr CallExpr(add) - WalkUpFromExpr CallExpr(add) - WalkUpFromStmt CallExpr(add) WalkUpFromStmt CompoundStmt )txt")); } From cfe-commits at lists.llvm.org Mon Jul 6 04:41:43 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via cfe-commits) Date: Mon, 06 Jul 2020 04:41:43 -0700 (PDT) Subject: [clang] c19c6b1 - Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode Message-ID: <5f030df7.1c69fb81.8f6b5.8266@mx.google.com> Author: Dmitri Gribenko Date: 2020-07-06T13:38:01+02:00 New Revision: c19c6b1722e5f71200c09cdb096245b98f03dce0 URL: https://github.com/llvm/llvm-project/commit/c19c6b1722e5f71200c09cdb096245b98f03dce0 DIFF: https://github.com/llvm/llvm-project/commit/c19c6b1722e5f71200c09cdb096245b98f03dce0.diff LOG: Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode Reviewers: ymandel, eduucaldas, rsmith Reviewed By: eduucaldas, rsmith Subscribers: gribozavr2, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82787 Added: Modified: clang/include/clang/AST/RecursiveASTVisitor.h clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 464a80d15cef..9d93f1e99666 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -593,7 +593,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, BINOP_LIST() #undef OPERATOR -#undef BINOP_LIST #define OPERATOR(NAME) \ case BO_##NAME##Assign: \ @@ -601,7 +600,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, CAO_LIST() #undef OPERATOR -#undef CAO_LIST } } else if (UnaryOperator *UnOp = dyn_cast(S)) { switch (UnOp->getOpcode()) { @@ -611,7 +609,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, UNARYOP_LIST() #undef OPERATOR -#undef UNARYOP_LIST } } @@ -633,27 +630,70 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, template bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { + // In pre-order traversal mode, each Traverse##STMT method is responsible for + // calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT and + // does not call the default implementation, the WalkUpFrom callback is not + // called. Post-order traversal mode should provide the same behavior + // regarding method overrides. + // + // In post-order traversal mode the Traverse##STMT method, when it receives a + // DataRecursionQueue, can't call WalkUpFrom after traversing children because + // it only enqueues the children and does not traverse them. TraverseStmt + // traverses the enqueued children, and we call WalkUpFrom here. + // + // However, to make pre-order and post-order modes identical with regards to + // whether they call WalkUpFrom at all, we call WalkUpFrom if and only if the + // user did not override the Traverse##STMT method. We implement the override + // check with isSameMethod calls below. + + if (BinaryOperator *BinOp = dyn_cast(S)) { + switch (BinOp->getOpcode()) { +#define OPERATOR(NAME) \ + case BO_##NAME: \ + if (::clang::detail::isSameMethod(&RecursiveASTVisitor::TraverseBin##NAME, \ + &Derived::TraverseBin##NAME)) { \ + TRY_TO(WalkUpFromBin##NAME(static_cast(S))); \ + } \ + return true; + + BINOP_LIST() +#undef OPERATOR + +#define OPERATOR(NAME) \ + case BO_##NAME##Assign: \ + if (::clang::detail::isSameMethod( \ + &RecursiveASTVisitor::TraverseBin##NAME##Assign, \ + &Derived::TraverseBin##NAME##Assign)) { \ + TRY_TO(WalkUpFromBin##NAME##Assign( \ + static_cast(S))); \ + } \ + return true; + + CAO_LIST() +#undef OPERATOR + } + } else if (UnaryOperator *UnOp = dyn_cast(S)) { + switch (UnOp->getOpcode()) { +#define OPERATOR(NAME) \ + case UO_##NAME: \ + if (::clang::detail::isSameMethod( \ + &RecursiveASTVisitor::TraverseUnary##NAME, \ + &Derived::TraverseUnary##NAME)) { \ + TRY_TO(WalkUpFromUnary##NAME(static_cast(S))); \ + } \ + return true; + + UNARYOP_LIST() +#undef OPERATOR + } + } + switch (S->getStmtClass()) { case Stmt::NoStmtClass: break; #define ABSTRACT_STMT(STMT) #define STMT(CLASS, PARENT) \ case Stmt::CLASS##Class: \ - /* In pre-order traversal mode, each Traverse##STMT method is responsible \ - * for calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT \ - * and does not call the default implementation, the WalkUpFrom callback \ - * is not called. Post-order traversal mode should provide the same \ - * behavior regarding method overrides. \ - * \ - * In post-order traversal mode the Traverse##STMT method, when it \ - * receives a DataRecursionQueue, can't call WalkUpFrom after traversing \ - * children because it only enqueues the children and does not traverse \ - * them. TraverseStmt traverses the enqueued children, and we call \ - * WalkUpFrom here. \ - * \ - * However, to make pre-order and post-order modes identical with regards \ - * to whether they call WalkUpFrom at all, we call WalkUpFrom if and only \ - * if the user did not override the Traverse##STMT method. */ \ if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \ &Derived::Traverse##CLASS)) { \ TRY_TO(WalkUpFrom##CLASS(static_cast(S))); \ @@ -661,7 +701,6 @@ bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { break; #define INITLISTEXPR(CLASS, PARENT) \ case Stmt::CLASS##Class: \ - /* See the comment above for the explanation of the isSameMethod check. */ \ if (::clang::detail::isSameMethod(&RecursiveASTVisitor::Traverse##CLASS, \ &Derived::Traverse##CLASS)) { \ auto ILE = static_cast(S); \ @@ -3668,6 +3707,10 @@ bool RecursiveASTVisitor::VisitOMPAffinityClause( #undef TRY_TO +#undef UNARYOP_LIST +#undef BINOP_LIST +#undef CAO_LIST + } // end namespace clang #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp index 1ab843d437a8..0a4e9aa1e9e8 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp @@ -416,13 +416,12 @@ WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromStmt for - // UnaryOperator(-). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(2) +WalkUpFromStmt UnaryOperator(-) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -488,8 +487,6 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromUnaryOperator - // for UnaryyOperator(-). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -497,6 +494,9 @@ WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) +WalkUpFromUnaryOperator UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -606,13 +606,14 @@ TraverseUnaryMinus UnaryOperator(-) WalkUpFromStmt IntegerLiteral(3) )txt")); + // FIXME: The following log should include a call to WalkUpFromStmt for + // UnaryOperator(-). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) TraverseUnaryMinus UnaryOperator(-) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt UnaryOperator(-) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -683,8 +684,6 @@ WalkUpFromExpr IntegerLiteral(1) TraverseUnaryMinus UnaryOperator(-) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -739,7 +738,6 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromUnaryMinus. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -747,8 +745,9 @@ WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) +WalkUpFromUnaryMinus UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -797,14 +796,13 @@ WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(4) )txt")); - // FIXME: The following log should include a call to WalkUpFromStmt for - // BinaryOperator(+). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) +WalkUpFromStmt BinaryOperator(+) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); @@ -872,7 +870,6 @@ WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) )txt")); - // FIXME: The following log should include a call to WalkUpFromBinaryOperator. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -882,6 +879,9 @@ WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) +WalkUpFromBinaryOperator BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt @@ -996,6 +996,8 @@ TraverseBinAdd BinaryOperator(+) WalkUpFromStmt IntegerLiteral(4) )txt")); + // FIXME: The following log should include a call to WalkUpFromStmt for + // BinaryOperator(+). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1003,7 +1005,6 @@ WalkUpFromStmt IntegerLiteral(1) TraverseBinAdd BinaryOperator(+) WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt BinaryOperator(+) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); @@ -1077,8 +1078,6 @@ TraverseBinAdd BinaryOperator(+) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt @@ -1135,7 +1134,6 @@ WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) )txt")); - // FIXME: The following log should include a call to WalkUpFromBinAdd. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1145,8 +1143,9 @@ WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) +WalkUpFromBinAdd BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt @@ -1195,14 +1194,13 @@ WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromStmt for - // CompoundAssignOperator(+=). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) WalkUpFromStmt DeclRefExpr(a) WalkUpFromStmt IntegerLiteral(2) +WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -1271,8 +1269,6 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to - // WalkUpFromCompoundAssignOperator. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1282,6 +1278,9 @@ WalkUpFromExpr DeclRefExpr(a) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) +WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) + WalkUpFromExpr CompoundAssignOperator(+=) + WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -1397,6 +1396,8 @@ TraverseBinAddAssign CompoundAssignOperator(+=) WalkUpFromStmt IntegerLiteral(3) )txt")); + // FIXME: The following log should include a call to WalkUpFromStmt for + // CompoundAssignOperator(+=). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1404,7 +1405,6 @@ WalkUpFromStmt IntegerLiteral(1) TraverseBinAddAssign CompoundAssignOperator(+=) WalkUpFromStmt DeclRefExpr(a) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -1481,8 +1481,6 @@ TraverseBinAddAssign CompoundAssignOperator(+=) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -1540,7 +1538,6 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromBinAddAssign. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1550,8 +1547,9 @@ WalkUpFromExpr DeclRefExpr(a) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) +WalkUpFromBinAddAssign CompoundAssignOperator(+=) + WalkUpFromExpr CompoundAssignOperator(+=) + WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt From cfe-commits at lists.llvm.org Mon Jul 6 04:41:45 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via cfe-commits) Date: Mon, 06 Jul 2020 04:41:45 -0700 (PDT) Subject: [clang] 8e750b1 - Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent Message-ID: <5f030df9.1c69fb81.70bb1.5c94@mx.google.com> Author: Dmitri Gribenko Date: 2020-07-06T13:38:01+02:00 New Revision: 8e750b1f0a2b6b5174dc49adf20e6f863c28e3cd URL: https://github.com/llvm/llvm-project/commit/8e750b1f0a2b6b5174dc49adf20e6f863c28e3cd DIFF: https://github.com/llvm/llvm-project/commit/8e750b1f0a2b6b5174dc49adf20e6f863c28e3cd.diff LOG: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent Reviewers: eduucaldas, ymandel, rsmith Reviewed By: eduucaldas Subscribers: gribozavr2, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82889 Added: Modified: clang/include/clang/AST/RecursiveASTVisitor.h clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 9d93f1e99666..0d7c2b81512c 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -416,6 +416,8 @@ template class RecursiveASTVisitor { if (!getDerived().shouldTraversePostOrder()) \ TRY_TO(WalkUpFromUnary##NAME(S)); \ TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \ + if (!Queue && getDerived().shouldTraversePostOrder()) \ + TRY_TO(WalkUpFromUnary##NAME(S)); \ return true; \ } \ bool WalkUpFromUnary##NAME(UnaryOperator *S) { \ @@ -437,6 +439,8 @@ template class RecursiveASTVisitor { TRY_TO(WalkUpFromBin##NAME(S)); \ TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \ TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \ + if (!Queue && getDerived().shouldTraversePostOrder()) \ + TRY_TO(WalkUpFromBin##NAME(S)); \ return true; \ } \ bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \ diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp index 0a4e9aa1e9e8..70c7eb37ad4c 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp @@ -606,14 +606,13 @@ TraverseUnaryMinus UnaryOperator(-) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromStmt for - // UnaryOperator(-). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) TraverseUnaryMinus UnaryOperator(-) WalkUpFromStmt IntegerLiteral(2) + WalkUpFromStmt UnaryOperator(-) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -675,7 +674,6 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromUnaryMinus. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -684,6 +682,9 @@ WalkUpFromExpr IntegerLiteral(1) TraverseUnaryMinus UnaryOperator(-) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) + WalkUpFromUnaryMinus UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt @@ -996,8 +997,6 @@ TraverseBinAdd BinaryOperator(+) WalkUpFromStmt IntegerLiteral(4) )txt")); - // FIXME: The following log should include a call to WalkUpFromStmt for - // BinaryOperator(+). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1005,6 +1004,7 @@ WalkUpFromStmt IntegerLiteral(1) TraverseBinAdd BinaryOperator(+) WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(3) + WalkUpFromStmt BinaryOperator(+) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); @@ -1067,7 +1067,6 @@ WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) )txt")); - // FIXME: The following log should include a call to WalkUpFromBinAdd. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1078,6 +1077,9 @@ TraverseBinAdd BinaryOperator(+) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) + WalkUpFromBinAdd BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr IntegerLiteral(4) WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt @@ -1396,8 +1398,6 @@ TraverseBinAddAssign CompoundAssignOperator(+=) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromStmt for - // CompoundAssignOperator(+=). EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1405,6 +1405,7 @@ WalkUpFromStmt IntegerLiteral(1) TraverseBinAddAssign CompoundAssignOperator(+=) WalkUpFromStmt DeclRefExpr(a) WalkUpFromStmt IntegerLiteral(2) + WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); @@ -1470,7 +1471,6 @@ WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) )txt")); - // FIXME: The following log should include a call to WalkUpFromBinAddAssign. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( @@ -1481,6 +1481,9 @@ TraverseBinAddAssign CompoundAssignOperator(+=) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) + WalkUpFromBinAddAssign CompoundAssignOperator(+=) + WalkUpFromExpr CompoundAssignOperator(+=) + WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt From cfe-commits at lists.llvm.org Mon Jul 6 04:41:47 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via cfe-commits) Date: Mon, 06 Jul 2020 04:41:47 -0700 (PDT) Subject: [clang] 5689b38 - Removed a RecursiveASTVisitor feature to visit operator kinds with different methods Message-ID: <5f030dfb.1c69fb81.6d840.08cc@mx.google.com> Author: Dmitri Gribenko Date: 2020-07-06T13:38:01+02:00 New Revision: 5689b38c6a4220cc5f6ba68a56486229b10071bf URL: https://github.com/llvm/llvm-project/commit/5689b38c6a4220cc5f6ba68a56486229b10071bf DIFF: https://github.com/llvm/llvm-project/commit/5689b38c6a4220cc5f6ba68a56486229b10071bf.diff LOG: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods Summary: This feature was only used in two places, but contributed a non-trivial amount to the complexity of RecursiveASTVisitor, and was buggy (see my recent patches where I was fixing the bugs that I noticed). I don't think the convenience benefit of this feature is worth the complexity. Besides complexity, another issue with the current state of RecursiveASTVisitor is the non-uniformity in how it handles different AST nodes. All AST nodes follow a regular pattern, but operators are special -- and this special behavior not documented. Correct usage of RecursiveASTVisitor relies on shadowing member functions with specific names and signatures. Near misses don't cause any compile-time errors, incorrectly named or typed methods are just silently ignored. Therefore, predictability of RecursiveASTVisitor API is quite important. This change reduces the size of the `clang` binary by 38 KB (0.2%) in release mode, and by 7 MB (0.3%) in debug mode. The `clang-tidy` binary is reduced by 205 KB (0.3%) in release mode, and by 5 MB (0.4%) in debug mode. I don't think these code size improvements are significant enough to justify this change on its own (for me, the primary motivation is reducing code complexity), but they I think are a nice side-effect. Reviewers: rsmith, sammccall, ymandel, aaron.ballman Reviewed By: rsmith, sammccall, ymandel, aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82921 Added: Modified: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h clang/docs/ReleaseNotes.rst clang/include/clang/AST/RecursiveASTVisitor.h clang/lib/ARCMigrate/TransProperties.cpp clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp index 67f281b3ed1f..56d4cceb6002 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp @@ -500,7 +500,7 @@ void ForLoopIndexUseVisitor::addUsage(const Usage &U) { /// int k = *i + 2; /// } /// \endcode -bool ForLoopIndexUseVisitor::TraverseUnaryDeref(UnaryOperator *Uop) { +bool ForLoopIndexUseVisitor::TraverseUnaryOperator(UnaryOperator *Uop) { // If we dereference an iterator that's actually a pointer, count the // occurrence. if (isDereferenceOfUop(Uop, IndexVar)) { diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h index b2cba8c0172a..4f75c9c7522f 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h @@ -346,7 +346,7 @@ class ForLoopIndexUseVisitor bool TraverseLambdaCapture(LambdaExpr *LE, const LambdaCapture *C, Expr *Init); bool TraverseMemberExpr(MemberExpr *Member); - bool TraverseUnaryDeref(UnaryOperator *Uop); + bool TraverseUnaryOperator(UnaryOperator *Uop); bool VisitDeclRefExpr(DeclRefExpr *E); bool VisitDeclStmt(DeclStmt *S); bool TraverseStmt(Stmt *S); diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d0328b0ef54c..8a9a58aa01f8 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -243,6 +243,34 @@ These are major API changes that have happened since the 10.0.0 release of Clang. If upgrading an external codebase that uses Clang as a library, this section should help get you past the largest hurdles of upgrading. +- ``RecursiveASTVisitor`` no longer calls separate methods to visit specific + operator kinds. Previously, ``RecursiveASTVisitor`` treated unary, binary, + and compound assignment operators as if they were subclasses of the + corresponding AST node. For example, the binary operator plus was treated as + if it was a ``BinAdd`` subclass of the ``BinaryOperator`` class: during AST + traversal of a ``BinaryOperator`` AST node that had a ``BO_Add`` opcode, + ``RecursiveASTVisitor`` was calling the ``TraverseBinAdd`` method instead of + ``TraverseBinaryOperator``. This feature was contributing a non-trivial + amount of complexity to the implementation of ``RecursiveASTVisitor``, it was + used only in a minor way in Clang, was not tested, and as a result it was + buggy. Furthermore, this feature was creating a non-uniformity in the API. + Since this feature was not documented, it was quite diff icult to figure out + how to use ``RecursiveASTVisitor`` to visit operators. + + To update your code to the new uniform API, move the code from separate + visitation methods into methods that correspond to the actual AST node and + perform case analysis based on the operator opcode as needed: + + * ``TraverseUnary*() => TraverseUnaryOperator()`` + * ``WalkUpFromUnary*() => WalkUpFromUnaryOperator()`` + * ``VisitUnary*() => VisiUnaryOperator()`` + * ``TraverseBin*() => TraverseBinaryOperator()`` + * ``WalkUpFromBin*() => WalkUpFromBinaryOperator()`` + * ``VisitBin*() => VisiBinaryOperator()`` + * ``TraverseBin*Assign() => TraverseCompoundAssignOperator()`` + * ``WalkUpFromBin*Assign() => WalkUpFromCompoundAssignOperator()`` + * ``VisitBin*Assign() => VisiCompoundAssignOperator()`` + Build System Changes -------------------- diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index 0d7c2b81512c..3dcfc9fee629 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -48,29 +48,6 @@ #include #include -// The following three macros are used for meta programming. The code -// using them is responsible for defining macro OPERATOR(). - -// All unary operators. -#define UNARYOP_LIST() \ - OPERATOR(PostInc) OPERATOR(PostDec) OPERATOR(PreInc) OPERATOR(PreDec) \ - OPERATOR(AddrOf) OPERATOR(Deref) OPERATOR(Plus) OPERATOR(Minus) \ - OPERATOR(Not) OPERATOR(LNot) OPERATOR(Real) OPERATOR(Imag) \ - OPERATOR(Extension) OPERATOR(Coawait) - -// All binary operators (excluding compound assign operators). -#define BINOP_LIST() \ - OPERATOR(PtrMemD) OPERATOR(PtrMemI) OPERATOR(Mul) OPERATOR(Div) \ - OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) OPERATOR(Shl) OPERATOR(Shr) \ - OPERATOR(LT) OPERATOR(GT) OPERATOR(LE) OPERATOR(GE) OPERATOR(EQ) \ - OPERATOR(NE) OPERATOR(Cmp) OPERATOR(And) OPERATOR(Xor) OPERATOR(Or) \ - OPERATOR(LAnd) OPERATOR(LOr) OPERATOR(Assign) OPERATOR(Comma) - -// All compound assign operators. -#define CAO_LIST() \ - OPERATOR(Mul) OPERATOR(Div) OPERATOR(Rem) OPERATOR(Add) OPERATOR(Sub) \ - OPERATOR(Shl) OPERATOR(Shr) OPERATOR(And) OPERATOR(Or) OPERATOR(Xor) - namespace clang { // A helper macro to implement short-circuiting when recursing. It @@ -407,64 +384,6 @@ template class RecursiveASTVisitor { bool Visit##CLASS(CLASS *S) { return true; } #include "clang/AST/StmtNodes.inc" -// Define Traverse*(), WalkUpFrom*(), and Visit*() for unary -// operator methods. Unary operators are not classes in themselves -// (they're all opcodes in UnaryOperator) but do have visitors. -#define OPERATOR(NAME) \ - bool TraverseUnary##NAME(UnaryOperator *S, \ - DataRecursionQueue *Queue = nullptr) { \ - if (!getDerived().shouldTraversePostOrder()) \ - TRY_TO(WalkUpFromUnary##NAME(S)); \ - TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr()); \ - if (!Queue && getDerived().shouldTraversePostOrder()) \ - TRY_TO(WalkUpFromUnary##NAME(S)); \ - return true; \ - } \ - bool WalkUpFromUnary##NAME(UnaryOperator *S) { \ - TRY_TO(WalkUpFromUnaryOperator(S)); \ - TRY_TO(VisitUnary##NAME(S)); \ - return true; \ - } \ - bool VisitUnary##NAME(UnaryOperator *S) { return true; } - - UNARYOP_LIST() -#undef OPERATOR - -// Define Traverse*(), WalkUpFrom*(), and Visit*() for binary -// operator methods. Binary operators are not classes in themselves -// (they're all opcodes in BinaryOperator) but do have visitors. -#define GENERAL_BINOP_FALLBACK(NAME, BINOP_TYPE) \ - bool TraverseBin##NAME(BINOP_TYPE *S, DataRecursionQueue *Queue = nullptr) { \ - if (!getDerived().shouldTraversePostOrder()) \ - TRY_TO(WalkUpFromBin##NAME(S)); \ - TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS()); \ - TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS()); \ - if (!Queue && getDerived().shouldTraversePostOrder()) \ - TRY_TO(WalkUpFromBin##NAME(S)); \ - return true; \ - } \ - bool WalkUpFromBin##NAME(BINOP_TYPE *S) { \ - TRY_TO(WalkUpFrom##BINOP_TYPE(S)); \ - TRY_TO(VisitBin##NAME(S)); \ - return true; \ - } \ - bool VisitBin##NAME(BINOP_TYPE *S) { return true; } - -#define OPERATOR(NAME) GENERAL_BINOP_FALLBACK(NAME, BinaryOperator) - BINOP_LIST() -#undef OPERATOR - -// Define Traverse*(), WalkUpFrom*(), and Visit*() for compound -// assignment methods. Compound assignment operators are not -// classes in themselves (they're all opcodes in -// CompoundAssignOperator) but do have visitors. -#define OPERATOR(NAME) \ - GENERAL_BINOP_FALLBACK(NAME##Assign, CompoundAssignOperator) - - CAO_LIST() -#undef OPERATOR -#undef GENERAL_BINOP_FALLBACK - // ---- Methods on Types ---- // FIXME: revamp to take TypeLoc's rather than Types. @@ -583,39 +502,6 @@ template class RecursiveASTVisitor { template bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, DataRecursionQueue *Queue) { -#define DISPATCH_STMT(NAME, CLASS, VAR) \ - return TRAVERSE_STMT_BASE(NAME, CLASS, VAR, Queue); - - // If we have a binary expr, dispatch to the subcode of the binop. A smart - // optimizer (e.g. LLVM) will fold this comparison into the switch stmt - // below. - if (BinaryOperator *BinOp = dyn_cast(S)) { - switch (BinOp->getOpcode()) { -#define OPERATOR(NAME) \ - case BO_##NAME: \ - DISPATCH_STMT(Bin##NAME, BinaryOperator, S); - - BINOP_LIST() -#undef OPERATOR - -#define OPERATOR(NAME) \ - case BO_##NAME##Assign: \ - DISPATCH_STMT(Bin##NAME##Assign, CompoundAssignOperator, S); - - CAO_LIST() -#undef OPERATOR - } - } else if (UnaryOperator *UnOp = dyn_cast(S)) { - switch (UnOp->getOpcode()) { -#define OPERATOR(NAME) \ - case UO_##NAME: \ - DISPATCH_STMT(Unary##NAME, UnaryOperator, S); - - UNARYOP_LIST() -#undef OPERATOR - } - } - // Top switch stmt: dispatch to TraverseFooStmt for each concrete FooStmt. switch (S->getStmtClass()) { case Stmt::NoStmtClass: @@ -623,7 +509,7 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S, #define ABSTRACT_STMT(STMT) #define STMT(CLASS, PARENT) \ case Stmt::CLASS##Class: \ - DISPATCH_STMT(CLASS, CLASS, S); + return TRAVERSE_STMT_BASE(CLASS, CLASS, S, Queue); #include "clang/AST/StmtNodes.inc" } @@ -650,48 +536,6 @@ bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) { // user did not override the Traverse##STMT method. We implement the override // check with isSameMethod calls below. - if (BinaryOperator *BinOp = dyn_cast(S)) { - switch (BinOp->getOpcode()) { -#define OPERATOR(NAME) \ - case BO_##NAME: \ - if (::clang::detail::isSameMethod(&RecursiveASTVisitor::TraverseBin##NAME, \ - &Derived::TraverseBin##NAME)) { \ - TRY_TO(WalkUpFromBin##NAME(static_cast(S))); \ - } \ - return true; - - BINOP_LIST() -#undef OPERATOR - -#define OPERATOR(NAME) \ - case BO_##NAME##Assign: \ - if (::clang::detail::isSameMethod( \ - &RecursiveASTVisitor::TraverseBin##NAME##Assign, \ - &Derived::TraverseBin##NAME##Assign)) { \ - TRY_TO(WalkUpFromBin##NAME##Assign( \ - static_cast(S))); \ - } \ - return true; - - CAO_LIST() -#undef OPERATOR - } - } else if (UnaryOperator *UnOp = dyn_cast(S)) { - switch (UnOp->getOpcode()) { -#define OPERATOR(NAME) \ - case UO_##NAME: \ - if (::clang::detail::isSameMethod( \ - &RecursiveASTVisitor::TraverseUnary##NAME, \ - &Derived::TraverseUnary##NAME)) { \ - TRY_TO(WalkUpFromUnary##NAME(static_cast(S))); \ - } \ - return true; - - UNARYOP_LIST() -#undef OPERATOR - } - } - switch (S->getStmtClass()) { case Stmt::NoStmtClass: break; @@ -3711,10 +3555,6 @@ bool RecursiveASTVisitor::VisitOMPAffinityClause( #undef TRY_TO -#undef UNARYOP_LIST -#undef BINOP_LIST -#undef CAO_LIST - } // end namespace clang #endif // LLVM_CLANG_AST_RECURSIVEASTVISITOR_H diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp index adfb4bd77ac6..cba2256ef97b 100644 --- a/clang/lib/ARCMigrate/TransProperties.cpp +++ b/clang/lib/ARCMigrate/TransProperties.cpp @@ -287,7 +287,10 @@ class PropertiesRewriter { public: PlusOneAssign(ObjCIvarDecl *D) : Ivar(D) {} - bool VisitBinAssign(BinaryOperator *E) { + bool VisitBinaryOperator(BinaryOperator *E) { + if (E->getOpcode() != BO_Assign) + return true; + Expr *lhs = E->getLHS()->IgnoreParenImpCasts(); if (ObjCIvarRefExpr *RE = dyn_cast(lhs)) { if (RE->getDecl() != Ivar) diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp index 70c7eb37ad4c..71f2bf6be599 100644 --- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp +++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp @@ -403,622 +403,40 @@ void test() { } )cpp"; - // TraverseUnaryOperator is not called because RecursiveASTVisitor treats - // individual operators as subclasses, for which it calls their Traverse - // methods. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::No), Code, R"txt( WalkUpFromStmt CompoundStmt WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt UnaryOperator(-) -WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt IntegerLiteral(3) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt UnaryOperator(-) -WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, - StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool TraverseUnaryOperator(UnaryOperator *UO) { - recordCallback(__func__, UO, [&]() { - RecordingVisitorBase::TraverseUnaryOperator(UO); - }); - return true; - } - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - - bool WalkUpFromExpr(Expr *E) { - recordCallback(__func__, E, - [&]() { RecordingVisitorBase::WalkUpFromExpr(E); }); - return true; - } - - bool WalkUpFromUnaryOperator(UnaryOperator *UO) { - recordCallback(__func__, UO, [&]() { - RecordingVisitorBase::WalkUpFromUnaryOperator(UO); - }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - -2; - 3; -} -)cpp"; - - // TraverseUnaryOperator is not called because RecursiveASTVisitor treats - // individual operators as subclasses, for which it calls their Traverse - // methods. - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromUnaryOperator UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromUnaryOperator UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromUnaryOperator) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - - bool WalkUpFromExpr(Expr *E) { - recordCallback(__func__, E, - [&]() { RecordingVisitorBase::WalkUpFromExpr(E); }); - return true; - } - - bool WalkUpFromUnaryOperator(UnaryOperator *UO) { - recordCallback(__func__, UO, [&]() { - RecordingVisitorBase::WalkUpFromUnaryOperator(UO); - }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - -2; - 3; -} -)cpp"; - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromUnaryOperator UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromUnaryOperator UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, StmtCallbacks_TraverseUnaryMinus) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool TraverseUnaryMinus(UnaryOperator *UO) { - recordCallback(__func__, UO, - [&]() { RecordingVisitorBase::TraverseUnaryMinus(UO); }); - return true; - } - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - -2; - 3; -} -)cpp"; - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromStmt IntegerLiteral(1) -TraverseUnaryMinus UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt IntegerLiteral(3) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromStmt IntegerLiteral(1) -TraverseUnaryMinus UnaryOperator(-) - WalkUpFromStmt IntegerLiteral(2) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, - StmtCallbacks_TraverseUnaryMinus_WalkUpFromUnaryMinus) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool TraverseUnaryMinus(UnaryOperator *UO) { - recordCallback(__func__, UO, - [&]() { RecordingVisitorBase::TraverseUnaryMinus(UO); }); - return true; - } - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - - bool WalkUpFromExpr(Expr *E) { - recordCallback(__func__, E, - [&]() { RecordingVisitorBase::WalkUpFromExpr(E); }); - return true; - } - - bool WalkUpFromUnaryMinus(UnaryOperator *UO) { - recordCallback(__func__, UO, - [&]() { RecordingVisitorBase::WalkUpFromUnaryMinus(UO); }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - -2; - 3; -} -)cpp"; - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -TraverseUnaryMinus UnaryOperator(-) - WalkUpFromUnaryMinus UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) - WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -TraverseUnaryMinus UnaryOperator(-) - WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) - WalkUpFromUnaryMinus UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromUnaryMinus) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - - bool WalkUpFromExpr(Expr *E) { - recordCallback(__func__, E, - [&]() { RecordingVisitorBase::WalkUpFromExpr(E); }); - return true; - } - - bool WalkUpFromUnaryMinus(UnaryOperator *UO) { - recordCallback(__func__, UO, - [&]() { RecordingVisitorBase::WalkUpFromUnaryMinus(UO); }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - -2; - 3; -} -)cpp"; - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromUnaryMinus UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromUnaryMinus UnaryOperator(-) - WalkUpFromExpr UnaryOperator(-) - WalkUpFromStmt UnaryOperator(-) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinaryOperator) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool TraverseBinaryOperator(BinaryOperator *BO) { - recordCallback(__func__, BO, [&]() { - RecordingVisitorBase::TraverseBinaryOperator(BO); - }); - return true; - } - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - 2 + 3; - 4; -} -)cpp"; - - // TraverseBinaryOperator is not called because RecursiveASTVisitor treats - // individual operators as subclasses, for which it calls their Traverse - // methods. - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt BinaryOperator(+) -WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt IntegerLiteral(4) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt BinaryOperator(+) -WalkUpFromStmt IntegerLiteral(4) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, - StmtCallbacks_TraverseBinaryOperator_WalkUpFromBinaryOperator) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool TraverseBinaryOperator(BinaryOperator *BO) { - recordCallback(__func__, BO, [&]() { - RecordingVisitorBase::TraverseBinaryOperator(BO); - }); - return true; - } - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - - bool WalkUpFromExpr(Expr *E) { - recordCallback(__func__, E, - [&]() { RecordingVisitorBase::WalkUpFromExpr(E); }); - return true; - } - - bool WalkUpFromBinaryOperator(BinaryOperator *BO) { - recordCallback(__func__, BO, [&]() { - RecordingVisitorBase::WalkUpFromBinaryOperator(BO); - }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - 2 + 3; - 4; -} -)cpp"; - - // TraverseBinaryOperator is not called because RecursiveASTVisitor treats - // individual operators as subclasses, for which it calls their Traverse - // methods. - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromBinaryOperator BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromBinaryOperator BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinaryOperator) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - - bool WalkUpFromExpr(Expr *E) { - recordCallback(__func__, E, - [&]() { RecordingVisitorBase::WalkUpFromExpr(E); }); - return true; - } - - bool WalkUpFromBinaryOperator(BinaryOperator *BO) { - recordCallback(__func__, BO, [&]() { - RecordingVisitorBase::WalkUpFromBinaryOperator(BO); - }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - 2 + 3; - 4; -} -)cpp"; - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromBinaryOperator BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) -)txt")); - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::Yes), Code, - R"txt( -WalkUpFromExpr IntegerLiteral(1) - WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromBinaryOperator BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) -WalkUpFromStmt CompoundStmt -)txt")); -} - -TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinAdd) { - class RecordingVisitor : public RecordingVisitorBase { - public: - RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) - : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - - bool TraverseBinAdd(BinaryOperator *BO) { - recordCallback(__func__, BO, - [&]() { RecordingVisitorBase::TraverseBinAdd(BO); }); - return true; - } - - bool WalkUpFromStmt(Stmt *S) { - recordCallback(__func__, S, - [&]() { RecordingVisitorBase::WalkUpFromStmt(S); }); - return true; - } - }; - - StringRef Code = R"cpp( -void test() { - 1; - 2 + 3; - 4; -} -)cpp"; - - EXPECT_TRUE(visitorCallbackLogEqual( - RecordingVisitor(ShouldTraversePostOrder::No), Code, - R"txt( -WalkUpFromStmt CompoundStmt -WalkUpFromStmt IntegerLiteral(1) -TraverseBinAdd BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) +TraverseUnaryOperator UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromStmt IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromStmt IntegerLiteral(4) +WalkUpFromStmt IntegerLiteral(3) )txt")); EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) -TraverseBinAdd BinaryOperator(+) +TraverseUnaryOperator UnaryOperator(-) WalkUpFromStmt IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(3) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromStmt IntegerLiteral(4) + WalkUpFromStmt UnaryOperator(-) +WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinAdd_WalkUpFromBinAdd) { +TEST(RecursiveASTVisitor, + StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - bool TraverseBinAdd(BinaryOperator *BO) { - recordCallback(__func__, BO, - [&]() { RecordingVisitorBase::TraverseBinAdd(BO); }); + bool TraverseUnaryOperator(UnaryOperator *UO) { + recordCallback(__func__, UO, [&]() { + RecordingVisitorBase::TraverseUnaryOperator(UO); + }); return true; } @@ -1034,9 +452,10 @@ TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinAdd_WalkUpFromBinAdd) { return true; } - bool WalkUpFromBinAdd(BinaryOperator *BO) { - recordCallback(__func__, BO, - [&]() { RecordingVisitorBase::WalkUpFromBinAdd(BO); }); + bool WalkUpFromUnaryOperator(UnaryOperator *UO) { + recordCallback(__func__, UO, [&]() { + RecordingVisitorBase::WalkUpFromUnaryOperator(UO); + }); return true; } }; @@ -1044,8 +463,8 @@ TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinAdd_WalkUpFromBinAdd) { StringRef Code = R"cpp( void test() { 1; - 2 + 3; - 4; + -2; + 3; } )cpp"; @@ -1055,16 +474,14 @@ void test() { WalkUpFromStmt CompoundStmt WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -TraverseBinAdd BinaryOperator(+) - WalkUpFromBinAdd BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) +TraverseUnaryOperator UnaryOperator(-) + WalkUpFromUnaryOperator UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) - WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) +WalkUpFromExpr IntegerLiteral(3) + WalkUpFromStmt IntegerLiteral(3) )txt")); EXPECT_TRUE(visitorCallbackLogEqual( @@ -1072,21 +489,19 @@ WalkUpFromExpr IntegerLiteral(4) R"txt( WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -TraverseBinAdd BinaryOperator(+) +TraverseUnaryOperator UnaryOperator(-) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) - WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) - WalkUpFromBinAdd BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) + WalkUpFromUnaryOperator UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) +WalkUpFromExpr IntegerLiteral(3) + WalkUpFromStmt IntegerLiteral(3) WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinAdd) { +TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromUnaryOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) @@ -1104,9 +519,10 @@ TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinAdd) { return true; } - bool WalkUpFromBinAdd(BinaryOperator *BO) { - recordCallback(__func__, BO, - [&]() { RecordingVisitorBase::WalkUpFromBinAdd(BO); }); + bool WalkUpFromUnaryOperator(UnaryOperator *UO) { + recordCallback(__func__, UO, [&]() { + RecordingVisitorBase::WalkUpFromUnaryOperator(UO); + }); return true; } }; @@ -1114,8 +530,8 @@ TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinAdd) { StringRef Code = R"cpp( void test() { 1; - 2 + 3; - 4; + -2; + 3; } )cpp"; @@ -1125,15 +541,13 @@ void test() { WalkUpFromStmt CompoundStmt WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromBinAdd BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) +WalkUpFromUnaryOperator UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) )txt")); EXPECT_TRUE(visitorCallbackLogEqual( @@ -1143,26 +557,24 @@ WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) +WalkUpFromUnaryOperator UnaryOperator(-) + WalkUpFromExpr UnaryOperator(-) + WalkUpFromStmt UnaryOperator(-) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) -WalkUpFromBinAdd BinaryOperator(+) - WalkUpFromExpr BinaryOperator(+) - WalkUpFromStmt BinaryOperator(+) -WalkUpFromExpr IntegerLiteral(4) - WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, StmtCallbacks_TraverseCompoundAssignOperator) { +TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinaryOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - bool TraverseCompoundAssignOperator(CompoundAssignOperator *CAO) { - recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::TraverseCompoundAssignOperator(CAO); + bool TraverseBinaryOperator(BinaryOperator *BO) { + recordCallback(__func__, BO, [&]() { + RecordingVisitorBase::TraverseBinaryOperator(BO); }); return true; } @@ -1175,50 +587,48 @@ TEST(RecursiveASTVisitor, StmtCallbacks_TraverseCompoundAssignOperator) { }; StringRef Code = R"cpp( -void test(int a) { +void test() { 1; - a += 2; - 3; + 2 + 3; + 4; } )cpp"; - // TraverseCompoundAssignOperator is not called because RecursiveASTVisitor - // treats individual operators as subclasses, for which it calls their - // Traverse methods. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::No), Code, R"txt( WalkUpFromStmt CompoundStmt WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt CompoundAssignOperator(+=) -WalkUpFromStmt DeclRefExpr(a) -WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt IntegerLiteral(3) +TraverseBinaryOperator BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) + WalkUpFromStmt IntegerLiteral(2) + WalkUpFromStmt IntegerLiteral(3) +WalkUpFromStmt IntegerLiteral(4) )txt")); EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) -WalkUpFromStmt DeclRefExpr(a) -WalkUpFromStmt IntegerLiteral(2) -WalkUpFromStmt CompoundAssignOperator(+=) -WalkUpFromStmt IntegerLiteral(3) +TraverseBinaryOperator BinaryOperator(+) + WalkUpFromStmt IntegerLiteral(2) + WalkUpFromStmt IntegerLiteral(3) + WalkUpFromStmt BinaryOperator(+) +WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); } -TEST( - RecursiveASTVisitor, - StmtCallbacks_TraverseCompoundAssignOperator_WalkUpFromCompoundAssignOperator) { +TEST(RecursiveASTVisitor, + StmtCallbacks_TraverseBinaryOperator_WalkUpFromBinaryOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - bool TraverseCompoundAssignOperator(CompoundAssignOperator *CAO) { - recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::TraverseCompoundAssignOperator(CAO); + bool TraverseBinaryOperator(BinaryOperator *BO) { + recordCallback(__func__, BO, [&]() { + RecordingVisitorBase::TraverseBinaryOperator(BO); }); return true; } @@ -1235,40 +645,38 @@ TEST( return true; } - bool WalkUpFromCompoundAssignOperator(CompoundAssignOperator *CAO) { - recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::WalkUpFromCompoundAssignOperator(CAO); + bool WalkUpFromBinaryOperator(BinaryOperator *BO) { + recordCallback(__func__, BO, [&]() { + RecordingVisitorBase::WalkUpFromBinaryOperator(BO); }); return true; } }; StringRef Code = R"cpp( -void test(int a) { +void test() { 1; - a += 2; - 3; + 2 + 3; + 4; } )cpp"; - // TraverseCompoundAssignOperator is not called because RecursiveASTVisitor - // treats individual operators as subclasses, for which it calls their - // Traverse methods. EXPECT_TRUE(visitorCallbackLogEqual( RecordingVisitor(ShouldTraversePostOrder::No), Code, R"txt( WalkUpFromStmt CompoundStmt WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) - WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) -WalkUpFromExpr DeclRefExpr(a) - WalkUpFromStmt DeclRefExpr(a) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) +TraverseBinaryOperator BinaryOperator(+) + WalkUpFromBinaryOperator BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) + WalkUpFromExpr IntegerLiteral(2) + WalkUpFromStmt IntegerLiteral(2) + WalkUpFromExpr IntegerLiteral(3) + WalkUpFromStmt IntegerLiteral(3) +WalkUpFromExpr IntegerLiteral(4) + WalkUpFromStmt IntegerLiteral(4) )txt")); EXPECT_TRUE(visitorCallbackLogEqual( @@ -1276,20 +684,21 @@ WalkUpFromExpr IntegerLiteral(3) R"txt( WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr DeclRefExpr(a) - WalkUpFromStmt DeclRefExpr(a) -WalkUpFromExpr IntegerLiteral(2) - WalkUpFromStmt IntegerLiteral(2) -WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) - WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) -WalkUpFromExpr IntegerLiteral(3) - WalkUpFromStmt IntegerLiteral(3) +TraverseBinaryOperator BinaryOperator(+) + WalkUpFromExpr IntegerLiteral(2) + WalkUpFromStmt IntegerLiteral(2) + WalkUpFromExpr IntegerLiteral(3) + WalkUpFromStmt IntegerLiteral(3) + WalkUpFromBinaryOperator BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) +WalkUpFromExpr IntegerLiteral(4) + WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromCompoundAssignOperator) { +TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinaryOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) @@ -1307,19 +716,19 @@ TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromCompoundAssignOperator) { return true; } - bool WalkUpFromCompoundAssignOperator(CompoundAssignOperator *CAO) { - recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::WalkUpFromCompoundAssignOperator(CAO); + bool WalkUpFromBinaryOperator(BinaryOperator *BO) { + recordCallback(__func__, BO, [&]() { + RecordingVisitorBase::WalkUpFromBinaryOperator(BO); }); return true; } }; StringRef Code = R"cpp( -void test(int a) { +void test() { 1; - a += 2; - 3; + 2 + 3; + 4; } )cpp"; @@ -1329,15 +738,15 @@ void test(int a) { WalkUpFromStmt CompoundStmt WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) - WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) -WalkUpFromExpr DeclRefExpr(a) - WalkUpFromStmt DeclRefExpr(a) +WalkUpFromBinaryOperator BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) +WalkUpFromExpr IntegerLiteral(4) + WalkUpFromStmt IntegerLiteral(4) )txt")); EXPECT_TRUE(visitorCallbackLogEqual( @@ -1345,28 +754,28 @@ WalkUpFromExpr IntegerLiteral(3) R"txt( WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromExpr DeclRefExpr(a) - WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) - WalkUpFromExpr CompoundAssignOperator(+=) - WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) WalkUpFromStmt IntegerLiteral(3) +WalkUpFromBinaryOperator BinaryOperator(+) + WalkUpFromExpr BinaryOperator(+) + WalkUpFromStmt BinaryOperator(+) +WalkUpFromExpr IntegerLiteral(4) + WalkUpFromStmt IntegerLiteral(4) WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinAddAssign) { +TEST(RecursiveASTVisitor, StmtCallbacks_TraverseCompoundAssignOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - bool TraverseBinAddAssign(CompoundAssignOperator *CAO) { + bool TraverseCompoundAssignOperator(CompoundAssignOperator *CAO) { recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::TraverseBinAddAssign(CAO); + RecordingVisitorBase::TraverseCompoundAssignOperator(CAO); }); return true; } @@ -1391,7 +800,7 @@ void test(int a) { R"txt( WalkUpFromStmt CompoundStmt WalkUpFromStmt IntegerLiteral(1) -TraverseBinAddAssign CompoundAssignOperator(+=) +TraverseCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromStmt DeclRefExpr(a) WalkUpFromStmt IntegerLiteral(2) @@ -1402,7 +811,7 @@ WalkUpFromStmt IntegerLiteral(3) RecordingVisitor(ShouldTraversePostOrder::Yes), Code, R"txt( WalkUpFromStmt IntegerLiteral(1) -TraverseBinAddAssign CompoundAssignOperator(+=) +TraverseCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromStmt DeclRefExpr(a) WalkUpFromStmt IntegerLiteral(2) WalkUpFromStmt CompoundAssignOperator(+=) @@ -1411,16 +820,17 @@ WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, - StmtCallbacks_TraverseBinAddAssign_WalkUpFromBinAddAssign) { +TEST( + RecursiveASTVisitor, + StmtCallbacks_TraverseCompoundAssignOperator_WalkUpFromCompoundAssignOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) : RecordingVisitorBase(ShouldTraversePostOrderValue) {} - bool TraverseBinAddAssign(CompoundAssignOperator *CAO) { + bool TraverseCompoundAssignOperator(CompoundAssignOperator *CAO) { recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::TraverseBinAddAssign(CAO); + RecordingVisitorBase::TraverseCompoundAssignOperator(CAO); }); return true; } @@ -1437,9 +847,9 @@ TEST(RecursiveASTVisitor, return true; } - bool WalkUpFromBinAddAssign(CompoundAssignOperator *CAO) { + bool WalkUpFromCompoundAssignOperator(CompoundAssignOperator *CAO) { recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::WalkUpFromBinAddAssign(CAO); + RecordingVisitorBase::WalkUpFromCompoundAssignOperator(CAO); }); return true; } @@ -1459,8 +869,8 @@ void test(int a) { WalkUpFromStmt CompoundStmt WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -TraverseBinAddAssign CompoundAssignOperator(+=) - WalkUpFromBinAddAssign CompoundAssignOperator(+=) +TraverseCompoundAssignOperator CompoundAssignOperator(+=) + WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromExpr CompoundAssignOperator(+=) WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr DeclRefExpr(a) @@ -1476,12 +886,12 @@ WalkUpFromExpr IntegerLiteral(3) R"txt( WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -TraverseBinAddAssign CompoundAssignOperator(+=) +TraverseCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromExpr DeclRefExpr(a) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) - WalkUpFromBinAddAssign CompoundAssignOperator(+=) + WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromExpr CompoundAssignOperator(+=) WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) @@ -1490,7 +900,7 @@ WalkUpFromStmt CompoundStmt )txt")); } -TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinAddAssign) { +TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromCompoundAssignOperator) { class RecordingVisitor : public RecordingVisitorBase { public: RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue) @@ -1508,9 +918,9 @@ TEST(RecursiveASTVisitor, StmtCallbacks_WalkUpFromBinAddAssign) { return true; } - bool WalkUpFromBinAddAssign(CompoundAssignOperator *CAO) { + bool WalkUpFromCompoundAssignOperator(CompoundAssignOperator *CAO) { recordCallback(__func__, CAO, [&]() { - RecordingVisitorBase::WalkUpFromBinAddAssign(CAO); + RecordingVisitorBase::WalkUpFromCompoundAssignOperator(CAO); }); return true; } @@ -1530,7 +940,7 @@ void test(int a) { WalkUpFromStmt CompoundStmt WalkUpFromExpr IntegerLiteral(1) WalkUpFromStmt IntegerLiteral(1) -WalkUpFromBinAddAssign CompoundAssignOperator(+=) +WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromExpr CompoundAssignOperator(+=) WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr DeclRefExpr(a) @@ -1550,7 +960,7 @@ WalkUpFromExpr DeclRefExpr(a) WalkUpFromStmt DeclRefExpr(a) WalkUpFromExpr IntegerLiteral(2) WalkUpFromStmt IntegerLiteral(2) -WalkUpFromBinAddAssign CompoundAssignOperator(+=) +WalkUpFromCompoundAssignOperator CompoundAssignOperator(+=) WalkUpFromExpr CompoundAssignOperator(+=) WalkUpFromStmt CompoundAssignOperator(+=) WalkUpFromExpr IntegerLiteral(3) From cfe-commits at lists.llvm.org Mon Jul 6 05:52:05 2020 From: cfe-commits at lists.llvm.org (=?UTF-8?Q?Kirst=C3=B3f_Umann?= via cfe-commits) Date: Mon, 06 Jul 2020 05:52:05 -0700 (PDT) Subject: [clang] b295607 - [analyzer][NFC] Don't allow dependency checkers to emit diagnostics Message-ID: <5f031e75.1c69fb81.6f121.1d41@mx.google.com> Author: Kirstóf Umann Date: 2020-07-06T14:51:37+02:00 New Revision: b2956076976cd0f435c46257f7cf9a0e5376d0fa URL: https://github.com/llvm/llvm-project/commit/b2956076976cd0f435c46257f7cf9a0e5376d0fa DIFF: https://github.com/llvm/llvm-project/commit/b2956076976cd0f435c46257f7cf9a0e5376d0fa.diff LOG: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics The thrilling conclusion to the barrage of patches I uploaded lately! This is a big milestone towards the goal set out in http://lists.llvm.org/pipermail/cfe-dev/2019-August/063070.html. I hope to accompany this with a patch where the a coreModeling package is added, from which package diagnostics aren't allowed either, is an implicit dependency of all checkers, and the core package for the first time can be safely disabled. Differential Revision: https://reviews.llvm.org/D78126 Added: Modified: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h clang/lib/StaticAnalyzer/Core/BugReporter.cpp Removed: ################################################################################ diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 51565524db1e..27bc0dda1f1c 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -19,6 +19,7 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Lex/Preprocessor.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h" +#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h" @@ -135,7 +136,7 @@ class BugReport { SmallVector Fixits; BugReport(Kind kind, const BugType &bt, StringRef desc) - : K(kind), BT(bt), Description(desc) {} + : BugReport(kind, bt, "", desc) {} BugReport(Kind K, const BugType &BT, StringRef ShortDescription, StringRef Description) @@ -369,16 +370,13 @@ class PathSensitiveBugReport : public BugReport { public: PathSensitiveBugReport(const BugType &bt, StringRef desc, const ExplodedNode *errorNode) - : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode), - ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() - : SourceRange()) {} + : PathSensitiveBugReport(bt, desc, desc, errorNode) {} PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errorNode) - : BugReport(Kind::PathSensitive, bt, shortDesc, desc), - ErrorNode(errorNode), - ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() - : SourceRange()) {} + : PathSensitiveBugReport(bt, shortDesc, desc, errorNode, + /*LocationToUnique*/ {}, + /*DeclToUnique*/ nullptr) {} /// Create a PathSensitiveBugReport with a custom uniqueing location. /// @@ -391,11 +389,13 @@ class PathSensitiveBugReport : public BugReport { const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique, const Decl *DeclToUnique) - : BugReport(Kind::PathSensitive, bt, desc), ErrorNode(errorNode), - ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()), - UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) { - assert(errorNode); - } + : PathSensitiveBugReport(bt, desc, desc, errorNode, LocationToUnique, + DeclToUnique) {} + + PathSensitiveBugReport(const BugType &bt, StringRef shortDesc, StringRef desc, + const ExplodedNode *errorNode, + PathDiagnosticLocation LocationToUnique, + const Decl *DeclToUnique); static bool classof(const BugReport *R) { return R->getKind() == Kind::PathSensitive; diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index f4fd495956aa..a832b90ddf0e 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -34,6 +34,7 @@ #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/CheckerRegistryData.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h" #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h" @@ -2107,6 +2108,32 @@ void BuiltinBug::anchor() {} // Methods for BugReport and subclasses. //===----------------------------------------------------------------------===// +static bool isDependency(const CheckerRegistryData &Registry, + StringRef CheckerName) { + for (const std::pair &Pair : Registry.Dependencies) { + if (Pair.second == CheckerName) + return true; + } + return false; +} + +PathSensitiveBugReport::PathSensitiveBugReport( + const BugType &bt, StringRef shortDesc, StringRef desc, + const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique, + const Decl *DeclToUnique) + : BugReport(Kind::PathSensitive, bt, shortDesc, desc), ErrorNode(errorNode), + ErrorNodeRange(getStmt() ? getStmt()->getSourceRange() : SourceRange()), + UniqueingLocation(LocationToUnique), UniqueingDecl(DeclToUnique) { + assert(!isDependency(ErrorNode->getState() + ->getAnalysisManager() + .getCheckerManager() + ->getCheckerRegistryData(), + bt.getCheckerName()) && + "Some checkers depend on this one! We don't allow dependency " + "checkers to emit warnings, because checkers should depend on " + "*modeling*, not *diagnostics*."); +} + void PathSensitiveBugReport::addVisitor( std::unique_ptr visitor) { if (!visitor) @@ -2195,12 +2222,12 @@ static void insertToInterestingnessMap( return; case bugreporter::TrackingKind::Condition: return; - } + } - llvm_unreachable( - "BugReport::markInteresting currently can only handle 2 diff erent " - "tracking kinds! Please define what tracking kind should this entitiy" - "have, if it was already marked as interesting with a diff erent kind!"); + llvm_unreachable( + "BugReport::markInteresting currently can only handle 2 diff erent " + "tracking kinds! Please define what tracking kind should this entitiy" + "have, if it was already marked as interesting with a diff erent kind!"); } void PathSensitiveBugReport::markInteresting(SymbolRef sym, From cfe-commits at lists.llvm.org Mon Jul 6 06:35:40 2020 From: cfe-commits at lists.llvm.org (=?UTF-8?Q?Kirst=C3=B3f_Umann?= via cfe-commits) Date: Mon, 06 Jul 2020 06:35:40 -0700 (PDT) Subject: [clang] cfd6b4b - [analyzer] Don't allow hidden checkers to emit diagnostics Message-ID: <5f0328ac.1c69fb81.eaf2.115f@mx.google.com> Author: Kirstóf Umann Date: 2020-07-06T15:34:51+02:00 New Revision: cfd6b4b811aa8bb193f744264e36e83de4bb3650 URL: https://github.com/llvm/llvm-project/commit/cfd6b4b811aa8bb193f744264e36e83de4bb3650 DIFF: https://github.com/llvm/llvm-project/commit/cfd6b4b811aa8bb193f744264e36e83de4bb3650.diff LOG: [analyzer] Don't allow hidden checkers to emit diagnostics Hidden checkers (those marked with Hidden in Checkers.td) are meant for development purposes only, and are only displayed under -analyzer-checker-help-developer, so users shouldn't see reports from them. I moved StdLibraryFunctionsArg checker to the unix package from apiModeling as it violated this rule. I believe this change doesn't deserve a different revision because it is in alpha, and the name is so bad anyways I don't immediately care where it is, because we'll have to revisit it soon enough. Differential Revision: https://reviews.llvm.org/D81750 Added: Modified: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Core/BugReporter.cpp clang/test/Analysis/std-c-library-functions-arg-constraints.c clang/test/Analysis/std-c-library-functions-arg-constraints.cpp clang/test/Analysis/weak-dependencies.c Removed: ################################################################################ diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index c1baa52a69b6..dc1269890f93 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -375,18 +375,6 @@ def TrustNonnullChecker : Checker<"TrustNonnull">, } // end "apiModeling" -let ParentPackage = APIModelingAlpha in { - -def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">, - HelpText<"Check constraints of arguments of C standard library functions, " - "such as whether the parameter of isalpha is in the range [0, 255] " - "or is EOF.">, - Dependencies<[StdCLibraryFunctionsChecker]>, - WeakDependencies<[NonNullParamChecker]>, - Documentation; - -} // end "alpha.apiModeling" - //===----------------------------------------------------------------------===// // Evaluate "builtin" functions. //===----------------------------------------------------------------------===// @@ -545,6 +533,14 @@ def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">, HelpText<"Check for calls to blocking functions inside a critical section">, Documentation; +def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">, + HelpText<"Check constraints of arguments of C standard library functions, " + "such as whether the parameter of isalpha is in the range [0, 255] " + "or is EOF.">, + Dependencies<[StdCLibraryFunctionsChecker]>, + WeakDependencies<[NonNullParamChecker]>, + Documentation; + } // end "alpha.unix" //===----------------------------------------------------------------------===// diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index a832b90ddf0e..7df8dea56055 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2108,8 +2108,8 @@ void BuiltinBug::anchor() {} // Methods for BugReport and subclasses. //===----------------------------------------------------------------------===// -static bool isDependency(const CheckerRegistryData &Registry, - StringRef CheckerName) { +LLVM_ATTRIBUTE_USED static bool +isDependency(const CheckerRegistryData &Registry, StringRef CheckerName) { for (const std::pair &Pair : Registry.Dependencies) { if (Pair.second == CheckerName) return true; @@ -2117,6 +2117,17 @@ static bool isDependency(const CheckerRegistryData &Registry, return false; } +LLVM_ATTRIBUTE_USED static bool isHidden(const CheckerRegistryData &Registry, + StringRef CheckerName) { + for (const CheckerInfo &Checker : Registry.Checkers) { + if (Checker.FullName == CheckerName) + return Checker.IsHidden; + } + llvm_unreachable( + "Checker name not found in CheckerRegistry -- did you retrieve it " + "correctly from CheckerManager::getCurrentCheckerName?"); +} + PathSensitiveBugReport::PathSensitiveBugReport( const BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errorNode, PathDiagnosticLocation LocationToUnique, @@ -2132,6 +2143,16 @@ PathSensitiveBugReport::PathSensitiveBugReport( "Some checkers depend on this one! We don't allow dependency " "checkers to emit warnings, because checkers should depend on " "*modeling*, not *diagnostics*."); + + assert( + bt.getCheckerName().startswith("debug") || + !isHidden(ErrorNode->getState() + ->getAnalysisManager() + .getCheckerManager() + ->getCheckerRegistryData(), + bt.getCheckerName()) && + "Hidden checkers musn't emit diagnostics as they are by definition " + "non-user facing!"); } void PathSensitiveBugReport::addVisitor( diff --git a/clang/test/Analysis/std-c-library-functions-arg-constraints.c b/clang/test/Analysis/std-c-library-functions-arg-constraints.c index b99248d337b3..b23700a96f38 100644 --- a/clang/test/Analysis/std-c-library-functions-arg-constraints.c +++ b/clang/test/Analysis/std-c-library-functions-arg-constraints.c @@ -2,7 +2,7 @@ // RUN: %clang_analyze_cc1 %s \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \ // RUN: -analyzer-checker=debug.ExprInspection \ // RUN: -triple x86_64-unknown-linux-gnu \ @@ -12,7 +12,7 @@ // RUN: %clang_analyze_cc1 %s \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \ // RUN: -analyzer-checker=debug.ExprInspection \ // RUN: -triple x86_64-unknown-linux-gnu \ diff --git a/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp b/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp index ebc841a07fb7..ae26834402e6 100644 --- a/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp +++ b/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp @@ -1,7 +1,7 @@ // RUN: %clang_analyze_cc1 %s \ // RUN: -analyzer-checker=core \ // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=debug.StdCLibraryFunctionsTester \ // RUN: -analyzer-checker=debug.ExprInspection \ // RUN: -analyzer-config eagerly-assume=false \ diff --git a/clang/test/Analysis/weak-dependencies.c b/clang/test/Analysis/weak-dependencies.c index a2179ecaff57..62cb10b5b523 100644 --- a/clang/test/Analysis/weak-dependencies.c +++ b/clang/test/Analysis/weak-dependencies.c @@ -1,5 +1,5 @@ // RUN: %clang_analyze_cc1 %s -verify \ -// RUN: -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \ +// RUN: -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \ // RUN: -analyzer-checker=core typedef __typeof(sizeof(int)) size_t; From cfe-commits at lists.llvm.org Mon Jul 6 06:39:14 2020 From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits) Date: Mon, 06 Jul 2020 06:39:14 -0700 (PDT) Subject: [clang-tools-extra] fc3c693 - [clang-tidy] Added alias llvm-else-after-return. Message-ID: <5f032982.1c69fb81.301be.18ea@mx.google.com> Author: Nathan James Date: 2020-07-06T14:39:03+01:00 New Revision: fc3c693b617fc5fde8939a3aec7e7372ace07693 URL: https://github.com/llvm/llvm-project/commit/fc3c693b617fc5fde8939a3aec7e7372ace07693 DIFF: https://github.com/llvm/llvm-project/commit/fc3c693b617fc5fde8939a3aec7e7372ace07693.diff LOG: [clang-tidy] Added alias llvm-else-after-return. Added an alias llvm-else-after-return from readability-else-after-return to help enforce one of the llvm coding guidelines. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D82825 Added: clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst Modified: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp index 2aaf07639267..0310a8e07a2d 100644 --- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp @@ -9,6 +9,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "../readability/ElseAfterReturnCheck.h" #include "../readability/NamespaceCommentCheck.h" #include "../readability/QualifiedAutoCheck.h" #include "HeaderGuardCheck.h" @@ -24,6 +25,8 @@ namespace llvm_check { class LLVMModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + CheckFactories.registerCheck( + "llvm-else-after-return"); CheckFactories.registerCheck("llvm-header-guard"); CheckFactories.registerCheck("llvm-include-order"); CheckFactories.registerCheck( @@ -40,6 +43,9 @@ class LLVMModule : public ClangTidyModule { ClangTidyOptions getModuleOptions() override { ClangTidyOptions Options; Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0"; + Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0"; + Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] = + "0"; return Options; } }; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 7593554d896d..c66d5eb6069e 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -192,6 +192,11 @@ New check aliases :doc:`bugprone-signed-char-misuse ` was added. +- New alias :doc:`llvm-else-after-return + ` to + :doc:`readability-else-after-return + ` was added. + Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index baa142e28e7f..7356c585d20c 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -423,4 +423,5 @@ Clang-Tidy Checks `hicpp-use-nullptr `_, `modernize-use-nullptr `_, "Yes" `hicpp-use-override `_, `modernize-use-override `_, "Yes" `hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_, + `llvm-else-after-return `_, `readability-else-after-return `_, "Yes" `llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes" diff --git a/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst b/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst new file mode 100644 index 000000000000..f9af610fe50d --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst @@ -0,0 +1,11 @@ +.. title:: clang-tidy - llvm-else-after-return +.. meta:: + :http-equiv=refresh: 5;URL=readability-else-after-return.html + +llvm-else-after-return +====================== + +The llvm-else-after-return check is an alias, please see +`readability-else-after-return `_ +for more information. + diff --git a/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst b/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst index fccb01d0e6b2..4adcd7bbfa26 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst @@ -77,3 +77,13 @@ Options the ``if`` statement is the last statement in its parents scope. Default value is `true`. + +LLVM alias +---------- + +There is an alias of this check called llvm-else-after-return. +In that version the options :option:`WarnOnUnfixable` and +:option:`WarnOnConditionVariables` are both set to `false` by default. + +This check helps to enforce this `LLVM Coding Standards recommendation +`_. From cfe-commits at lists.llvm.org Mon Jul 6 06:44:12 2020 From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits) Date: Mon, 06 Jul 2020 06:44:12 -0700 (PDT) Subject: [clang-tools-extra] 0196600 - [clang-tidy] Fix incorrect default option in fc3c693b61 Message-ID: <5f032aac.1c69fb81.908da.d581@mx.google.com> Author: Nathan James Date: 2020-07-06T14:44:03+01:00 New Revision: 01966003674d49e06632495fec2a5a7b3fd58a80 URL: https://github.com/llvm/llvm-project/commit/01966003674d49e06632495fec2a5a7b3fd58a80 DIFF: https://github.com/llvm/llvm-project/commit/01966003674d49e06632495fec2a5a7b3fd58a80.diff LOG: [clang-tidy] Fix incorrect default option in fc3c693b61 Added: Modified: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp index 0310a8e07a2d..bf871e21f501 100644 --- a/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp @@ -44,7 +44,7 @@ class LLVMModule : public ClangTidyModule { ClangTidyOptions Options; Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0"; Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0"; - Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] = + Options.CheckOptions["llvm-else-after-return.WarnOnConditionVariables"] = "0"; return Options; } From cfe-commits at lists.llvm.org Mon Jul 6 07:43:13 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via cfe-commits) Date: Mon, 06 Jul 2020 07:43:13 -0700 (PDT) Subject: [clang] cd9a241 - [clang] Fix the incorrect dependence bits for DependentExtIntType. Message-ID: <5f033881.1c69fb81.880b0.eb00@mx.google.com> Author: Haojian Wu Date: 2020-07-06T16:42:56+02:00 New Revision: cd9a241f165013902fc060ace88c66e402c7767a URL: https://github.com/llvm/llvm-project/commit/cd9a241f165013902fc060ace88c66e402c7767a DIFF: https://github.com/llvm/llvm-project/commit/cd9a241f165013902fc060ace88c66e402c7767a.diff LOG: [clang] Fix the incorrect dependence bits for DependentExtIntType. The error-bit was missing, and the unexpandedpack bit seemed to be set incorrectly. Reviewed By: sammccall, erichkeane Differential Revision: https://reviews.llvm.org/D83114 Added: Modified: clang/lib/AST/Type.cpp clang/test/Sema/invalid-bitwidth-expr.mm Removed: ################################################################################ diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 05962f34bbf1..10a6a2610130 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -347,15 +347,7 @@ ExtIntType::ExtIntType(bool IsUnsigned, unsigned NumBits) DependentExtIntType::DependentExtIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) : Type(DependentExtInt, QualType{}, - ((NumBitsExpr->isValueDependent() || NumBitsExpr->isTypeDependent()) - ? TypeDependence::Dependent - : TypeDependence::None) | - (NumBitsExpr->isInstantiationDependent() - ? TypeDependence::Instantiation - : TypeDependence::None) | - (NumBitsExpr->containsUnexpandedParameterPack() - ? TypeDependence::VariablyModified - : TypeDependence::None)), + toTypeDependence(NumBitsExpr->getDependence())), Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {} bool DependentExtIntType::isUnsigned() const { diff --git a/clang/test/Sema/invalid-bitwidth-expr.mm b/clang/test/Sema/invalid-bitwidth-expr.mm index a38ebbbd6755..41ca9496de4f 100644 --- a/clang/test/Sema/invalid-bitwidth-expr.mm +++ b/clang/test/Sema/invalid-bitwidth-expr.mm @@ -32,3 +32,8 @@ auto func() { int X : func(); // expected-note {{in instantiation of function template}} }; constexpr int ssss = sizeof(Z); + +struct Z2 { + int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared identifier}} +}; +constexpr int sssss = sizeof(Z2); From cfe-commits at lists.llvm.org Mon Jul 6 08:13:38 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via cfe-commits) Date: Mon, 06 Jul 2020 08:13:38 -0700 (PDT) Subject: [clang-tools-extra] 254b016 - [clangd] More complete fix for hover crashes on invalid record. Message-ID: <5f033fa2.1c69fb81.3f249.aca5@mx.google.com> Author: Haojian Wu Date: 2020-07-06T17:12:39+02:00 New Revision: 254b016c6561e4ec4d145b81c4d0aaf3d2c7fca6 URL: https://github.com/llvm/llvm-project/commit/254b016c6561e4ec4d145b81c4d0aaf3d2c7fca6 DIFF: https://github.com/llvm/llvm-project/commit/254b016c6561e4ec4d145b81c4d0aaf3d2c7fca6.diff LOG: [clangd] More complete fix for hover crashes on invalid record. We should not call getFieldOffset on invalid record decls. Differential Revision: https://reviews.llvm.org/D83189 Added: Modified: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index f495052d2d30..cba933508fd5 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -659,8 +659,10 @@ bool isHardLineBreakAfter(llvm::StringRef Line, llvm::StringRef Rest) { } void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) { - const auto &Ctx = ND.getASTContext(); + if (ND.isInvalidDecl()) + return; + const auto &Ctx = ND.getASTContext(); if (auto *RD = llvm::dyn_cast(&ND)) { if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl())) HI.Size = Size->getQuantity(); @@ -671,11 +673,10 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) { const auto *Record = FD->getParent(); if (Record) Record = Record->getDefinition(); - if (Record && !Record->isDependentType()) { + if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) { + HI.Offset = Ctx.getFieldOffset(FD) / 8; if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) - HI.Offset = Ctx.getFieldOffset(FD) / 8; } return; } diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 3be796a6fb89..43f1e7142550 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -784,11 +784,24 @@ class Foo {})cpp"; HI.NamespaceScope = ""; HI.Definition = "int xx"; HI.LocalScope = "Foo::"; - HI.Size = 4; HI.Type = "int"; HI.AccessSpecifier = "public"; }}, - }; + {R"cpp( + // error-ok + struct Foo { + Bar xx; + int [[y^y]]; + };)cpp", + [](HoverInfo &HI) { + HI.Name = "yy"; + HI.Kind = index::SymbolKind::Field; + HI.NamespaceScope = ""; + HI.Definition = "int yy"; + HI.LocalScope = "Foo::"; + HI.Type = "int"; + HI.AccessSpecifier = "public"; + }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); From cfe-commits at lists.llvm.org Mon Jul 6 08:29:01 2020 From: cfe-commits at lists.llvm.org (Oliver Stannard via cfe-commits) Date: Mon, 06 Jul 2020 08:29:01 -0700 (PDT) Subject: [clang] e80b81d - [Support] Fix formatted_raw_ostream for UTF-8 Message-ID: <5f03433d.1c69fb81.880b0.ee2b@mx.google.com> Author: Oliver Stannard Date: 2020-07-06T16:18:15+01:00 New Revision: e80b81d1cbf85dcd427759369978afdb48f0998f URL: https://github.com/llvm/llvm-project/commit/e80b81d1cbf85dcd427759369978afdb48f0998f DIFF: https://github.com/llvm/llvm-project/commit/e80b81d1cbf85dcd427759369978afdb48f0998f.diff LOG: [Support] Fix formatted_raw_ostream for UTF-8 * The getLine and getColumn functions need to update the position, or they will return stale data for buffered streams. This fixes a bug in the clang -analyzer-checker-option-help option, which was not wrapping the help text correctly when stdout is not a TTY. * If the stream contains multi-byte UTF-8 sequences, then the whole sequence needs to be considered to be a single character. This has the edge case that the buffer might fill up and be flushed part way through a character. * If the stream contains East Asian wide characters, these will be rendered twice as wide as other characters, so we need to increase the column count to match. This doesn't attempt to handle everything unicode can do (combining characters, right-to-left markers, ...), but hopefully covers most things likely to be common in messages and source code we might want to print. Differential revision: https://reviews.llvm.org/D76291 Added: Modified: clang/test/Analysis/checker-plugins.c llvm/include/llvm/Support/FormattedStream.h llvm/lib/Support/FormattedStream.cpp llvm/test/MC/ARM/lsl-zero.s llvm/unittests/Support/formatted_raw_ostream_test.cpp Removed: ################################################################################ diff --git a/clang/test/Analysis/checker-plugins.c b/clang/test/Analysis/checker-plugins.c index fbc9c9bd1c22..69fab8fa6eed 100644 --- a/clang/test/Analysis/checker-plugins.c +++ b/clang/test/Analysis/checker-plugins.c @@ -116,4 +116,5 @@ void caller() { // RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-CHECKER-OPTION-HELP // CHECK-CHECKER-OPTION-HELP: example.MyChecker:ExampleOption (bool) This is an -// CHECK-CHECKER-OPTION-HELP-SAME: example checker opt. (default: false) +// CHECK-CHECKER-OPTION-HELP-SAME: example checker opt. (default: +// CHECK-CHECKER-OPTION-HELP-NEXT: false) diff --git a/llvm/include/llvm/Support/FormattedStream.h b/llvm/include/llvm/Support/FormattedStream.h index b49c8d86531d..5f937cfa7984 100644 --- a/llvm/include/llvm/Support/FormattedStream.h +++ b/llvm/include/llvm/Support/FormattedStream.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_FORMATTEDSTREAM_H #define LLVM_SUPPORT_FORMATTEDSTREAM_H +#include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" #include @@ -21,8 +22,11 @@ namespace llvm { /// formatted_raw_ostream - A raw_ostream that wraps another one and keeps track /// of line and column position, allowing padding out to specific column -/// boundaries and querying the number of lines written to the stream. -/// +/// boundaries and querying the number of lines written to the stream. This +/// assumes that the contents of the stream is valid UTF-8 encoded text. This +/// doesn't attempt to handle everything Unicode can do (combining characters, +/// right-to-left markers, etc), but should cover the cases likely to appear in +/// source code or diagnostic messages. class formatted_raw_ostream : public raw_ostream { /// TheStream - The real stream we output to. We set it to be /// unbuffered, since we're already doing our own buffering. @@ -40,6 +44,14 @@ class formatted_raw_ostream : public raw_ostream { /// const char *Scanned; + /// PartialUTF8Char - Either empty or a prefix of a UTF-8 code unit sequence + /// for a Unicode scalar value which should be prepended to the buffer for the + /// next call to ComputePosition. This is needed when the buffer is flushed + /// when it ends part-way through the UTF-8 encoding of a Unicode scalar + /// value, so that we can compute the display width of the character once we + /// have the rest of it. + SmallString<4> PartialUTF8Char; + void write_impl(const char *Ptr, size_t Size) override; /// current_pos - Return the current position within the stream, @@ -52,10 +64,16 @@ class formatted_raw_ostream : public raw_ostream { } /// ComputePosition - Examine the given output buffer and figure out the new - /// position after output. - /// + /// position after output. This is safe to call multiple times on the same + /// buffer, as it records the most recently scanned character and resumes from + /// there when the buffer has not been flushed. void ComputePosition(const char *Ptr, size_t size); + /// UpdatePosition - scan the characters in [Ptr, Ptr+Size), and update the + /// line and column numbers. Unlike ComputePosition, this must be called + /// exactly once on each region of the buffer. + void UpdatePosition(const char *Ptr, size_t Size); + void setStream(raw_ostream &Stream) { releaseStream(); @@ -105,11 +123,17 @@ class formatted_raw_ostream : public raw_ostream { /// \param NewCol - The column to move to. formatted_raw_ostream &PadToColumn(unsigned NewCol); - /// getColumn - Return the column number - unsigned getColumn() { return Position.first; } + unsigned getColumn() { + // Calculate current position, taking buffer contents into account. + ComputePosition(getBufferStart(), GetNumBytesInBuffer()); + return Position.first; + } - /// getLine - Return the line number - unsigned getLine() { return Position.second; } + unsigned getLine() { + // Calculate current position, taking buffer contents into account. + ComputePosition(getBufferStart(), GetNumBytesInBuffer()); + return Position.second; + } raw_ostream &resetColor() override { TheStream->resetColor(); diff --git a/llvm/lib/Support/FormattedStream.cpp b/llvm/lib/Support/FormattedStream.cpp index 4eb747038bb9..081b8bf2cc19 100644 --- a/llvm/lib/Support/FormattedStream.cpp +++ b/llvm/lib/Support/FormattedStream.cpp @@ -11,7 +11,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Unicode.h" #include "llvm/Support/raw_ostream.h" #include @@ -19,16 +21,22 @@ using namespace llvm; /// UpdatePosition - Examine the given char sequence and figure out which /// column we end up in after output, and how many line breaks are contained. -/// -static void UpdatePosition(std::pair &Position, const char *Ptr, size_t Size) { +/// This assumes that the input string is well-formed UTF-8, and takes into +/// account Unicode characters which render as multiple columns wide. +void formatted_raw_ostream::UpdatePosition(const char *Ptr, size_t Size) { unsigned &Column = Position.first; unsigned &Line = Position.second; - // Keep track of the current column and line by scanning the string for - // special characters - for (const char *End = Ptr + Size; Ptr != End; ++Ptr) { - ++Column; - switch (*Ptr) { + auto ProcessUTF8CodePoint = [&Line, &Column](StringRef CP) { + int Width = sys::unicode::columnWidthUTF8(CP); + if (Width != sys::unicode::ErrorNonPrintableCharacter) + Column += Width; + + // The only special whitespace characters we care about are single-byte. + if (CP.size() > 1) + return; + + switch (CP[0]) { case '\n': Line += 1; LLVM_FALLTHROUGH; @@ -40,6 +48,46 @@ static void UpdatePosition(std::pair &Position, const char * Column += (8 - (Column & 0x7)) & 0x7; break; } + }; + + // If we have a partial UTF-8 sequence from the previous buffer, check that + // first. + if (PartialUTF8Char.size()) { + size_t BytesFromBuffer = + getNumBytesForUTF8(PartialUTF8Char[0]) - PartialUTF8Char.size(); + if (Size < BytesFromBuffer) { + // If we still don't have enough bytes for a complete code point, just + // append what we have. + PartialUTF8Char.append(StringRef(Ptr, Size)); + return; + } else { + // The first few bytes from the buffer will complete the code point. + // Concatenate them and process their effect on the line and column + // numbers. + PartialUTF8Char.append(StringRef(Ptr, BytesFromBuffer)); + ProcessUTF8CodePoint(PartialUTF8Char); + PartialUTF8Char.clear(); + Ptr += BytesFromBuffer; + Size -= BytesFromBuffer; + } + } + + // Now scan the rest of the buffer. + unsigned NumBytes; + for (const char *End = Ptr + Size; Ptr < End; Ptr += NumBytes) { + NumBytes = getNumBytesForUTF8(*Ptr); + + // The buffer might end part way through a UTF-8 code unit sequence for a + // Unicode scalar value if it got flushed. If this happens, we can't know + // the display width until we see the rest of the code point. Stash the + // bytes we do have, so that we can reconstruct the whole code point later, + // even if the buffer is being flushed. + if ((End - Ptr) < NumBytes) { + PartialUTF8Char = StringRef(Ptr, End - Ptr); + return; + } + + ProcessUTF8CodePoint(StringRef(Ptr, NumBytes)); } } @@ -52,9 +100,9 @@ void formatted_raw_ostream::ComputePosition(const char *Ptr, size_t Size) { if (Ptr <= Scanned && Scanned <= Ptr + Size) // Scan all characters added since our last scan to determine the new // column. - UpdatePosition(Position, Scanned, Size - (Scanned - Ptr)); + UpdatePosition(Scanned, Size - (Scanned - Ptr)); else - UpdatePosition(Position, Ptr, Size); + UpdatePosition(Ptr, Size); // Update the scanning pointer. Scanned = Ptr + Size; diff --git a/llvm/test/MC/ARM/lsl-zero.s b/llvm/test/MC/ARM/lsl-zero.s index 5d097115448f..6e64e0012362 100644 --- a/llvm/test/MC/ARM/lsl-zero.s +++ b/llvm/test/MC/ARM/lsl-zero.s @@ -1,6 +1,6 @@ -// RUN: llvm-mc -triple=thumbv7 -show-encoding < %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONARM --check-prefix=CHECK-THUMBV7 %s -// RUN: llvm-mc -triple=thumbv8 -show-encoding < %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONARM --check-prefix=CHECK-THUMBV8 %s -// RUN: llvm-mc -triple=armv7 -show-encoding < %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARM %s +// RUN: llvm-mc -triple=thumbv7 -show-encoding < %s 2>/dev/null | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONARM --check-prefix=CHECK-THUMBV7 %s +// RUN: llvm-mc -triple=thumbv8 -show-encoding < %s 2>/dev/null | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NONARM --check-prefix=CHECK-THUMBV8 %s +// RUN: llvm-mc -triple=armv7 -show-encoding < %s 2>/dev/null | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ARM %s // lsl #0 is actually mov, so here we check that it behaves the same as // mov with regards to the permitted registers and how it behaves in an diff --git a/llvm/unittests/Support/formatted_raw_ostream_test.cpp b/llvm/unittests/Support/formatted_raw_ostream_test.cpp index 0fe0869922a1..5c57f1f18700 100644 --- a/llvm/unittests/Support/formatted_raw_ostream_test.cpp +++ b/llvm/unittests/Support/formatted_raw_ostream_test.cpp @@ -29,4 +29,143 @@ TEST(formatted_raw_ostreamTest, Test_Tell) { } } +TEST(formatted_raw_ostreamTest, Test_LineColumn) { + // Test tracking of line and column numbers in a stream. + SmallString<128> A; + raw_svector_ostream B(A); + formatted_raw_ostream C(B); + + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(0U, C.getColumn()); + + C << "a"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(1U, C.getColumn()); + + C << "bcdef"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(6U, C.getColumn()); + + // '\n' increments line number, sets column to zero. + C << "\n"; + EXPECT_EQ(1U, C.getLine()); + EXPECT_EQ(0U, C.getColumn()); + + // '\r sets column to zero without changing line number + C << "foo\r"; + EXPECT_EQ(1U, C.getLine()); + EXPECT_EQ(0U, C.getColumn()); + + // '\t' advances column to the next multiple of 8. + // FIXME: If the column number is already a multiple of 8 this will do + // nothing, is this behaviour correct? + C << "1\t"; + EXPECT_EQ(8U, C.getColumn()); + C << "\t"; + EXPECT_EQ(8U, C.getColumn()); + C << "1234567\t"; + EXPECT_EQ(16U, C.getColumn()); + EXPECT_EQ(1U, C.getLine()); +} + +TEST(formatted_raw_ostreamTest, Test_Flush) { + // Flushing the buffer causes the characters in the buffer to be scanned + // before the buffer is emptied, so line and column numbers will still be + // tracked properly. + SmallString<128> A; + raw_svector_ostream B(A); + B.SetBufferSize(32); + formatted_raw_ostream C(B); + + C << "\nabc"; + EXPECT_EQ(4U, C.GetNumBytesInBuffer()); + C.flush(); + EXPECT_EQ(1U, C.getLine()); + EXPECT_EQ(3U, C.getColumn()); + EXPECT_EQ(0U, C.GetNumBytesInBuffer()); +} + +TEST(formatted_raw_ostreamTest, Test_UTF8) { + SmallString<128> A; + raw_svector_ostream B(A); + B.SetBufferSize(32); + formatted_raw_ostream C(B); + + // U+00A0 Non-breaking space: encoded as two bytes, but only one column wide. + C << u8"\u00a0"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(1U, C.getColumn()); + EXPECT_EQ(2U, C.GetNumBytesInBuffer()); + + // U+2468 CIRCLED DIGIT NINE: encoded as three bytes, but only one column + // wide. + C << u8"\u2468"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(2U, C.getColumn()); + EXPECT_EQ(5U, C.GetNumBytesInBuffer()); + + // U+00010000 LINEAR B SYLLABLE B008 A: encoded as four bytes, but only one + // column wide. + C << u8"\U00010000"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(3U, C.getColumn()); + EXPECT_EQ(9U, C.GetNumBytesInBuffer()); + + // U+55B5, CJK character, encodes as three bytes, takes up two columns. + C << u8"\u55b5"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(5U, C.getColumn()); + EXPECT_EQ(12U, C.GetNumBytesInBuffer()); + + // U+200B, zero-width space, encoded as three bytes but has no effect on the + // column or line number. + C << u8"\u200b"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(5U, C.getColumn()); + EXPECT_EQ(15U, C.GetNumBytesInBuffer()); +} + +TEST(formatted_raw_ostreamTest, Test_UTF8Buffered) { + SmallString<128> A; + raw_svector_ostream B(A); + B.SetBufferSize(4); + formatted_raw_ostream C(B); + + // U+2468 encodes as three bytes, so will cause the buffer to be flushed after + // the first byte (4 byte buffer, 3 bytes already written). We need to save + // the first part of the UTF-8 encoding until after the buffer is cleared and + // the remaining two bytes are written, at which point we can check the + // display width. In this case the display width is 1, so we end at column 4, + // with 6 bytes written into total, 2 of which are in the buffer. + C << u8"123\u2468"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(4U, C.getColumn()); + EXPECT_EQ(2U, C.GetNumBytesInBuffer()); + C.flush(); + EXPECT_EQ(6U, A.size()); + + // Same as above, but with a CJK character which displays as two columns. + C << u8"123\u55b5"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(9U, C.getColumn()); + EXPECT_EQ(2U, C.GetNumBytesInBuffer()); + C.flush(); + EXPECT_EQ(12U, A.size()); +} + +TEST(formatted_raw_ostreamTest, Test_UTF8TinyBuffer) { + SmallString<128> A; + raw_svector_ostream B(A); + B.SetBufferSize(1); + formatted_raw_ostream C(B); + + // The stream has a one-byte buffer, so it gets flushed multiple times while + // printing a single Unicode character. + C << u8"\u2468"; + EXPECT_EQ(0U, C.getLine()); + EXPECT_EQ(1U, C.getColumn()); + EXPECT_EQ(0U, C.GetNumBytesInBuffer()); + C.flush(); + EXPECT_EQ(3U, A.size()); +} } From cfe-commits at lists.llvm.org Mon Jul 6 08:52:20 2020 From: cfe-commits at lists.llvm.org (Raphael Isemann via cfe-commits) Date: Mon, 06 Jul 2020 08:52:20 -0700 (PDT) Subject: [clang] 7308e14 - [clang] Fix modules build after D82585 Message-ID: <5f0348b4.1c69fb81.7eb02.1ecb@mx.google.com> Author: Raphael Isemann Date: 2020-07-06T17:51:53+02:00 New Revision: 7308e1432624f02d4e652ffa70e40d0eaa89fdb3 URL: https://github.com/llvm/llvm-project/commit/7308e1432624f02d4e652ffa70e40d0eaa89fdb3 DIFF: https://github.com/llvm/llvm-project/commit/7308e1432624f02d4e652ffa70e40d0eaa89fdb3.diff LOG: [clang] Fix modules build after D82585 Just getting the bots running again. See the D82585 for more info. Added: Modified: clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp Removed: ################################################################################ diff --git a/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h b/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h index e7a7671a7576..43248d8e6bb8 100644 --- a/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h +++ b/clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h @@ -76,7 +76,7 @@ struct CmdLineOption { "Invalid development status!"); } - LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dump() const; LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const; }; @@ -135,7 +135,7 @@ struct CheckerInfo { // Used for lower_bound. explicit CheckerInfo(StringRef FullName) : FullName(FullName) {} - LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dump() const; LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const; }; @@ -155,7 +155,7 @@ struct PackageInfo { explicit PackageInfo(StringRef FullName) : FullName(FullName) {} - LLVM_DUMP_METHOD void dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void dump() const; LLVM_DUMP_METHOD void dumpToStream(llvm::raw_ostream &Out) const; }; diff --git a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp index 7d5bfb2f9cdb..1b3e8b11549d 100644 --- a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp +++ b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp @@ -18,6 +18,10 @@ using namespace ento; // Methods of CmdLineOption, PackageInfo and CheckerInfo. //===----------------------------------------------------------------------===// +LLVM_DUMP_METHOD void CmdLineOption::dump() const { + dumpToStream(llvm::errs()); +} + LLVM_DUMP_METHOD void CmdLineOption::dumpToStream(llvm::raw_ostream &Out) const { // The description can be just checked in Checkers.inc, the point here is to @@ -39,6 +43,8 @@ static StringRef toString(StateFromCmdLine Kind) { llvm_unreachable("Unhandled StateFromCmdLine enum"); } +LLVM_DUMP_METHOD void CheckerInfo::dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const { // The description can be just checked in Checkers.inc, the point here is to // debug whether we succeeded in parsing it. Same with documentation uri. @@ -60,6 +66,8 @@ LLVM_DUMP_METHOD void CheckerInfo::dumpToStream(llvm::raw_ostream &Out) const { } } +LLVM_DUMP_METHOD void PackageInfo::dump() const { dumpToStream(llvm::errs()); } + LLVM_DUMP_METHOD void PackageInfo::dumpToStream(llvm::raw_ostream &Out) const { Out << FullName << "\n"; Out << " Options:\n"; From cfe-commits at lists.llvm.org Mon Jul 6 08:52:51 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via cfe-commits) Date: Mon, 06 Jul 2020 08:52:51 -0700 (PDT) Subject: [clang] cf0b3af - [clang][utils] make-ast-dump-check.sh: strip line and column numbers when generating serialization tests Message-ID: <5f0348d3.1c69fb81.17c50.31b6@mx.google.com> Author: Bruno Ricci Date: 2020-07-06T16:52:35+01:00 New Revision: cf0b3affed47811b02127383c7eec27285ac35a3 URL: https://github.com/llvm/llvm-project/commit/cf0b3affed47811b02127383c7eec27285ac35a3 DIFF: https://github.com/llvm/llvm-project/commit/cf0b3affed47811b02127383c7eec27285ac35a3.diff LOG: [clang][utils] make-ast-dump-check.sh: strip line and column numbers when generating serialization tests Added: Modified: clang/utils/make-ast-dump-check.sh Removed: ################################################################################ diff --git a/clang/utils/make-ast-dump-check.sh b/clang/utils/make-ast-dump-check.sh index f0c268c883e9..365f227cc1c6 100755 --- a/clang/utils/make-ast-dump-check.sh +++ b/clang/utils/make-ast-dump-check.sh @@ -70,6 +70,10 @@ BEGIN { if ($generate_serialization_test == 1) { gsub(" imported", "{{( imported)?}}", s) gsub(" ", "{{( )?}}", s) + gsub("line:[0-9]+:[0-9]+", "line:{{.*}}", s) + gsub("line:[0-9]+", "line:{{.*}}", s) + gsub("col:[0-9]+", "col:{{.*}}", s) + gsub(":[0-9]+:[0-9]+", "{{.*}}", s) } } From cfe-commits at lists.llvm.org Mon Jul 6 10:33:45 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via cfe-commits) Date: Mon, 06 Jul 2020 10:33:45 -0700 (PDT) Subject: [clang] 39d2ae0 - [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. Message-ID: <5f036079.1c69fb81.418d1.033d@mx.google.com> Author: Kevin P. Neal Date: 2020-07-06T13:32:49-04:00 New Revision: 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4 URL: https://github.com/llvm/llvm-project/commit/39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4 DIFF: https://github.com/llvm/llvm-project/commit/39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4.diff LOG: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. We currently have strict floating point/constrained floating point enabled for all targets. Constrained SDAG nodes get converted to the regular ones before reaching the target layer. In theory this should be fine. However, the changes are exposed to users through multiple clang options already in use in the field, and the changes are _completely_ _untested_ on almost all of our targets. Bugs have already been found, like "https://bugs.llvm.org/show_bug.cgi?id=45274". This patch disables constrained floating point options in clang everywhere except X86 and SystemZ. A warning will be printed when this happens. Differential Revision: https://reviews.llvm.org/D80952 Added: clang/test/CodeGen/fp-strictfp.cpp Modified: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/TargetInfo.h clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/SystemZ.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/CompilerInstance.cpp clang/test/CodeGen/aarch64-neon-misc-constrained.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c clang/test/CodeGen/arm-neon-directed-rounding-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/builtins-ppc-fpconstrained.c Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 83c13e0dbbe0..db334a7899c4 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -37,6 +37,12 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo; def warn_fe_override_module : Warning< "overriding the module target triple with %0">, InGroup>; +def warn_fe_backend_unsupported_fp_rounding : Warning< + "overriding currently unsupported rounding mode on this target">, + InGroup; +def warn_fe_backend_unsupported_fp_exceptions : Warning< + "overriding currently unsupported use of floating point exceptions " + "on this target">, InGroup; def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo, InGroup; diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 37e0b77e79ed..ff07608c81e4 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -107,6 +107,7 @@ def DoublePromotion : DiagGroup<"double-promotion">; def EnumTooLarge : DiagGroup<"enum-too-large">; def UnsupportedNan : DiagGroup<"unsupported-nan">; def UnsupportedAbs : DiagGroup<"unsupported-abs">; +def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">; def UnsupportedCB : DiagGroup<"unsupported-cb">; def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">; def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">; diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 140f55ff66b1..2ee3b1659630 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -192,6 +192,7 @@ class TargetInfo : public virtual TransferrableTargetInfo, bool HasFloat128; bool HasFloat16; bool HasBFloat16; + bool HasStrictFP; unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; unsigned short SimdDefaultAlign; @@ -577,6 +578,9 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Determine whether the _BFloat16 type is supported on this target. virtual bool hasBFloat16Type() const { return HasBFloat16; } + /// Determine whether constrained floating point is supported on this target. + virtual bool hasStrictFP() const { return HasStrictFP; } + /// Return the alignment that is suitable for storing any /// object with a fundamental alignment requirement. unsigned getSuitableAlign() const { return SuitableAlign; } diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 7f360b715da9..eccdc21d724a 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -37,6 +37,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { HasFloat128 = false; HasFloat16 = false; HasBFloat16 = false; + HasStrictFP = false; PointerWidth = PointerAlign = 32; BoolWidth = BoolAlign = 8; IntWidth = IntAlign = 32; diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 134b0313b86a..d7869e3754a8 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -48,6 +48,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { MinGlobalAlign = 16; resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"); MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; + HasStrictFP = true; } void getTargetDefines(const LangOptions &Opts, diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index c33c608e27c8..d6c9b3fd3fe9 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -138,6 +138,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { : TargetInfo(Triple) { LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); AddrSpaceMap = &X86AddrSpaceMap; + HasStrictFP = true; } const char *getLongDoubleMangling() const override { diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 9dc9c42297ed..189a030eb7f6 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -933,6 +933,19 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO)); } + if (!getTarget().hasStrictFP()) { + if (getLangOpts().getFPRoundingMode() != + llvm::RoundingMode::NearestTiesToEven) { + getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_rounding); + getLangOpts().setFPRoundingMode(llvm::RoundingMode::NearestTiesToEven); + } + if (getLangOpts().getFPExceptionMode() != LangOptions::FPE_Ignore) { + getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_exceptions); + getLangOpts().setFPExceptionMode(LangOptions::FPE_Ignore); + } + // FIXME: can we disable FEnvAccess? + } + // Inform the target of the language options. // // FIXME: We shouldn't need to do this, the target should be immutable once diff --git a/clang/test/CodeGen/aarch64-neon-misc-constrained.c b/clang/test/CodeGen/aarch64-neon-misc-constrained.c index 0385358291c9..db4474efd115 100644 --- a/clang/test/CodeGen/aarch64-neon-misc-constrained.c +++ b/clang/test/CodeGen/aarch64-neon-misc-constrained.c @@ -15,6 +15,9 @@ // REQUIRES: aarch64-registered-target +// Disabled until constrained floating point is implemented for arm64. +// XFAIL: * + // Test new aarch64 intrinsics and types but constrained #include diff --git a/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c b/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c index cbe5627337fd..c6fa81e894c8 100644 --- a/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c +++ b/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c @@ -15,6 +15,9 @@ // REQUIRES: aarch64-registered-target +// Disabled until constrained floating point is implemented for arm64. +// XFAIL: * + // Test new aarch64 intrinsics and types but constrained #include diff --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c index 6058e6f92832..dd3e92d0fde9 100644 --- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c +++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c @@ -19,6 +19,9 @@ // REQUIRES: aarch64-registered-target +// Disabled until constrained floating point is implemented for arm64. +// XFAIL: * + #include // COMMON-LABEL: test_vsqrt_f16 diff --git a/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c b/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c index 5246993173f8..493f7924ec14 100644 --- a/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c +++ b/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c @@ -32,6 +32,9 @@ // REQUIRES: arm-registered-target,aarch64-registered-target +// Disabled until constrained floating point is implemented for arm64. +// XFAIL: * + #include // COMMON-LABEL: test_vrndi_f32 diff --git a/clang/test/CodeGen/arm64-vrnd-constrained.c b/clang/test/CodeGen/arm64-vrnd-constrained.c index bbded8f2c7f6..f46b1abfa4e3 100644 --- a/clang/test/CodeGen/arm64-vrnd-constrained.c +++ b/clang/test/CodeGen/arm64-vrnd-constrained.c @@ -9,6 +9,9 @@ // REQUIRES: aarch64-registered-target +// Disabled until constrained floating point is implemented for arm64. +// XFAIL: * + #include float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); } diff --git a/clang/test/CodeGen/builtins-ppc-fpconstrained.c b/clang/test/CodeGen/builtins-ppc-fpconstrained.c index 38cdfb6aab38..1e6da685b3d2 100644 --- a/clang/test/CodeGen/builtins-ppc-fpconstrained.c +++ b/clang/test/CodeGen/builtins-ppc-fpconstrained.c @@ -12,6 +12,9 @@ // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \ // RUN: --check-prefix=FIXME-CHECK %s +// Disabled until constrained floating point is completed for PowerPC. +// XFAIL: * + typedef __attribute__((vector_size(4 * sizeof(float)))) float vec_float; typedef __attribute__((vector_size(2 * sizeof(double)))) double vec_double; diff --git a/clang/test/CodeGen/fp-strictfp.cpp b/clang/test/CodeGen/fp-strictfp.cpp new file mode 100644 index 000000000000..1a88a545fbd3 --- /dev/null +++ b/clang/test/CodeGen/fp-strictfp.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s +// +// Verify that constrained intrinsics are not used. +// As more targets gain support for constrained intrinsics the triple +// in this test will need to change. + +// rounding-warning@* {{overriding currently unsupported rounding mode on this target}} +// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}} +float fp_precise_1(float a, float b, float c) { +// CHECK: _Z12fp_precise_1fff +// CHECK: %[[M:.+]] = fmul float{{.*}} +// CHECK: fadd float %[[M]], %c + return a * b + c; +} + + From cfe-commits at lists.llvm.org Mon Jul 6 10:33:56 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 17:33:56 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <68fc7f2fa3dc58aa0d776da7ee121a60@localhost.localdomain> This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG39d2ae0afb23: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking… (authored by kpn). Changed prior to commit: https://reviews.llvm.org/D80952?vs=272530&id=275760#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 Files: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/TargetInfo.h clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/SystemZ.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/CompilerInstance.cpp clang/test/CodeGen/aarch64-neon-misc-constrained.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c clang/test/CodeGen/arm-neon-directed-rounding-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/builtins-ppc-fpconstrained.c clang/test/CodeGen/fp-strictfp.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D80952.275760.patch Type: text/x-patch Size: 8741 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 10:48:07 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 17:48:07 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <74856a1ce5b12936fcfef2b385dfdf84@localhost.localdomain> zequanwu updated this revision to Diff 275763. zequanwu added a comment. Delete `enable-npm-call-graph-profile` option for NPM, using `enable-call-graph-profile` for both LPM and NPM. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 Files: clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/new-pm-cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll llvm/tools/opt/NewPMDriver.cpp llvm/tools/opt/NewPMDriver.h llvm/tools/opt/opt.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83013.275763.patch Type: text/x-patch Size: 18513 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 10:52:14 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via cfe-commits) Date: Mon, 06 Jul 2020 10:52:14 -0700 (PDT) Subject: [clang] 0547040 - [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body. Message-ID: <5f0364ce.1c69fb81.ca2fa.c41f@mx.google.com> Author: Zequan Wu Date: 2020-07-06T10:52:05-07:00 New Revision: 054704082b461418d3dac3a379792cdaf52d40b3 URL: https://github.com/llvm/llvm-project/commit/054704082b461418d3dac3a379792cdaf52d40b3 DIFF: https://github.com/llvm/llvm-project/commit/054704082b461418d3dac3a379792cdaf52d40b3.diff LOG: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body. Summary: Some libraries use empty function to ignore unused variable warnings, which gets a new warning from `-Wuninitialized-const-reference`, discussed here https://reviews.llvm.org/D79895#2107604. This patch should fix that. Reviewers: hans, nick, aaron.ballman Reviewed By: aaron.ballman Subscribers: aaron.ballman, riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82425 Added: Modified: clang/lib/Analysis/UninitializedValues.cpp clang/test/SemaCXX/warn-uninitialized-const-reference.cpp Removed: ################################################################################ diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index 3d44d1c070fe..67cd39728c35 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -405,6 +405,15 @@ static bool isPointerToConst(const QualType &QT) { return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified(); } +static bool hasTrivialBody(CallExpr *CE) { + if (FunctionDecl *FD = CE->getDirectCallee()) { + if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate()) + return FTD->getTemplatedDecl()->hasTrivialBody(); + return FD->hasTrivialBody(); + } + return false; +} + void ClassifyRefs::VisitCallExpr(CallExpr *CE) { // Classify arguments to std::move as used. if (CE->isCallToStdMove()) { @@ -413,7 +422,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) { classify(CE->getArg(0), Use); return; } - + bool isTrivialBody = hasTrivialBody(CE); // If a value is passed by const pointer to a function, // we should not assume that it is initialized by the call, and we // conservatively do not assume that it is used. @@ -423,7 +432,7 @@ void ClassifyRefs::VisitCallExpr(CallExpr *CE) { I != E; ++I) { if ((*I)->isGLValue()) { if ((*I)->getType().isConstQualified()) - classify((*I), ConstRefUse); + classify((*I), isTrivialBody ? Ignore : ConstRefUse); } else if (isPointerToConst((*I)->getType())) { const Expr *Ex = stripCasts(DC->getParentASTContext(), *I); const auto *UO = dyn_cast(Ex); diff --git a/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp b/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp index 292793ba483a..d24b561441d8 100644 --- a/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp +++ b/clang/test/SemaCXX/warn-uninitialized-const-reference.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s +// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wuninitialized-const-reference -verify %s class A { public: @@ -9,6 +9,16 @@ class A { bool operator!=(const A &); }; +template +void ignore_template(const T &) {} +void ignore(const int &i) {} +void dont_ignore_non_empty(const int &i) { ; } // Calling this won't silence the warning for you +void dont_ignore_block(const int &i) { + {} +} // Calling this won't silence the warning for you +void ignore_function_try_block_maybe_who_knows(const int &) try { +} catch (...) { +} A const_ref_use_A(const A &a); int const_ref_use(const int &i); A const_use_A(const A a); @@ -33,4 +43,13 @@ void f(int a) { if (a < 42) m = 1; const_ref_use(m); + + int l; + ignore_template(l); // This is a pattern to avoid "unused variable" warnings (e.g. boost::ignore_unused). + ignore(l); + dont_ignore_non_empty(l); // expected-warning {{variable 'l' is uninitialized when passed as a const reference argument here}} + int l1; + dont_ignore_block(l1); // expected-warning {{variable 'l1' is uninitialized when passed as a const reference argument here}} + int l2; + ignore_function_try_block_maybe_who_knows(l2); // expected-warning {{variable 'l2' is uninitialized when passed as a const reference argument here}} } From cfe-commits at lists.llvm.org Mon Jul 6 10:52:27 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 17:52:27 +0000 (UTC) Subject: [PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body. In-Reply-To: References: Message-ID: <39b9b1829066d886275b99e2a8ddb148@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG054704082b46: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty… (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82425/new/ https://reviews.llvm.org/D82425 Files: clang/lib/Analysis/UninitializedValues.cpp clang/test/SemaCXX/warn-uninitialized-const-reference.cpp Index: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp =================================================================== --- clang/test/SemaCXX/warn-uninitialized-const-reference.cpp +++ clang/test/SemaCXX/warn-uninitialized-const-reference.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s +// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wuninitialized-const-reference -verify %s class A { public: @@ -9,6 +9,16 @@ bool operator!=(const A &); }; +template +void ignore_template(const T &) {} +void ignore(const int &i) {} +void dont_ignore_non_empty(const int &i) { ; } // Calling this won't silence the warning for you +void dont_ignore_block(const int &i) { + {} +} // Calling this won't silence the warning for you +void ignore_function_try_block_maybe_who_knows(const int &) try { +} catch (...) { +} A const_ref_use_A(const A &a); int const_ref_use(const int &i); A const_use_A(const A a); @@ -33,4 +43,13 @@ if (a < 42) m = 1; const_ref_use(m); + + int l; + ignore_template(l); // This is a pattern to avoid "unused variable" warnings (e.g. boost::ignore_unused). + ignore(l); + dont_ignore_non_empty(l); // expected-warning {{variable 'l' is uninitialized when passed as a const reference argument here}} + int l1; + dont_ignore_block(l1); // expected-warning {{variable 'l1' is uninitialized when passed as a const reference argument here}} + int l2; + ignore_function_try_block_maybe_who_knows(l2); // expected-warning {{variable 'l2' is uninitialized when passed as a const reference argument here}} } Index: clang/lib/Analysis/UninitializedValues.cpp =================================================================== --- clang/lib/Analysis/UninitializedValues.cpp +++ clang/lib/Analysis/UninitializedValues.cpp @@ -405,6 +405,15 @@ return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified(); } +static bool hasTrivialBody(CallExpr *CE) { + if (FunctionDecl *FD = CE->getDirectCallee()) { + if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate()) + return FTD->getTemplatedDecl()->hasTrivialBody(); + return FD->hasTrivialBody(); + } + return false; +} + void ClassifyRefs::VisitCallExpr(CallExpr *CE) { // Classify arguments to std::move as used. if (CE->isCallToStdMove()) { @@ -413,7 +422,7 @@ classify(CE->getArg(0), Use); return; } - + bool isTrivialBody = hasTrivialBody(CE); // If a value is passed by const pointer to a function, // we should not assume that it is initialized by the call, and we // conservatively do not assume that it is used. @@ -423,7 +432,7 @@ I != E; ++I) { if ((*I)->isGLValue()) { if ((*I)->getType().isConstQualified()) - classify((*I), ConstRefUse); + classify((*I), isTrivialBody ? Ignore : ConstRefUse); } else if (isPointerToConst((*I)->getType())) { const Expr *Ex = stripCasts(DC->getParentASTContext(), *I); const auto *UO = dyn_cast(Ex); -------------- next part -------------- A non-text attachment was scrubbed... Name: D82425.275765.patch Type: text/x-patch Size: 3049 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 11:09:00 2020 From: cfe-commits at lists.llvm.org (Alina Sbirlea via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:09:00 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: asbirlea added a comment. In D83013#2132088 , @aeubanks wrote: > In D83013#2132070 , @echristo wrote: > > > Adding Chandler and Alina here as well. > > > > In general, I don't think that this is such a great idea. Being able to have this sort of thing work more reliably is one of the reasons for the new pass manager. I think I'd like to see this split out into an old versus new pass manager pass to avoid the difficulty of cleaning this up after we finish migrating llvm to the new pass manager. This also seems to add some technical debt around options and other enablement which is also less than ideal. Is this compelling to add right now versus finishing work migrating llvm completely to the new pass manager and removing the old one? From speaking with Alina I think that work should be done in a short while. > > > > Thanks. > > > > -eric > > > I don't think we're that close yet, probably at least a couple months out, there are lots of loose ends to be tied up. I'll make a post soon in llvm-dev (maybe first we can sync up again) about what I think needs to be done before the NPM switch. +1 to sync up again and make progress towards the NPM switch. I don't want to block this patch, but I do agree with Eric's point. We *really* want to focus more on the switch then invest into more LPM infra. Short term resolutions to unblock folks, with the best split possible, sure, keeping in mind they'll need to be cleaned up. But I don't want us to lose focus on tying up the remaining loose ends for the switch. I think it's critical for LLVM's codebase health to focus on the NPM switch in the next couple of months. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Mon Jul 6 11:12:55 2020 From: cfe-commits at lists.llvm.org (Gui Andrade via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:12:55 +0000 (UTC) Subject: [PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary In-Reply-To: References: Message-ID: <519a029883efa6fafe2403e8aad80d14@localhost.localdomain> guiand updated this revision to Diff 275771. guiand added a comment. Another wave of test updates Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82317/new/ https://reviews.llvm.org/D82317 Files: clang/test/ARCMT/objcmt-instancetype.m clang/test/ARCMT/objcmt-instancetype.m.result clang/test/ARCMT/objcmt-numeric-literals.m clang/test/ARCMT/objcmt-numeric-literals.m.result clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c clang/test/AST/gen_ast_dump_json_test.py clang/test/ASTMerge/unnamed_fields/test.cpp clang/test/Analysis/casts.c clang/test/Analysis/inlining/DynDispatchBifurcate.m clang/test/Analysis/inlining/InlineObjCClassMethod.m clang/test/Analysis/misc-ps-region-store.m clang/test/Analysis/missing-bind-temporary.cpp clang/test/Analysis/silence-checkers-and-packages-core-all.cpp clang/test/CXX/class/class.compare/class.compare.default/p4.cpp clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp clang/test/CXX/drs/dr0xx.cpp clang/test/CXX/except/except.spec/p14-ir.cpp clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm clang/test/CXX/modules-ts/codegen-basics.cppm clang/test/CXX/special/class.copy/p3.cpp clang/test/CodeGen/2004-02-13-Memset.c clang/test/CodeGen/2004-06-17-UnorderedCompares.c clang/test/CodeGen/2006-05-19-SingleEltReturn.c clang/test/CodeGen/2007-02-25-C-DotDotDot.c clang/test/CodeGen/2007-06-18-SextAttrAggregate.c clang/test/CodeGen/2008-03-05-syncPtr.c clang/test/CodeGen/2008-07-29-override-alias-decl.c clang/test/CodeGen/2008-07-30-implicit-initialization.c clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c clang/test/CodeGen/2009-02-13-zerosize-union-field.c clang/test/CodeGen/2009-05-04-EnumInreg.c clang/test/CodeGen/2009-09-24-SqrtErrno.c clang/test/CodeGen/3dnow-builtins.c clang/test/CodeGen/64bit-swiftcall.c clang/test/CodeGen/PR3589-freestanding-libcalls.c clang/test/CodeGen/_Bool-conversion.c clang/test/CodeGen/aapcs-align.cpp clang/test/CodeGen/aapcs-bitfield.c clang/test/CodeGen/aapcs64-align.cpp clang/test/CodeGen/aarch64-args.cpp clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c clang/test/CodeGen/aarch64-byval-temp.c clang/test/CodeGen/aarch64-neon-3v.c clang/test/CodeGen/aarch64-neon-across.c clang/test/CodeGen/aarch64-neon-dot-product.c clang/test/CodeGen/aarch64-neon-extract.c clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c clang/test/CodeGen/aarch64-neon-fma.c clang/test/CodeGen/aarch64-neon-fp16fml.c clang/test/CodeGen/aarch64-neon-ldst-one.c clang/test/CodeGen/aarch64-neon-scalar-copy.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c clang/test/CodeGen/aarch64-neon-tbl.c clang/test/CodeGen/aarch64-neon-vcombine.c clang/test/CodeGen/aarch64-neon-vget-hilo.c clang/test/CodeGen/aarch64-neon-vget.c clang/test/CodeGen/aarch64-poly128.c clang/test/CodeGen/aarch64-poly64.c clang/test/CodeGen/aarch64-varargs-ms.c clang/test/CodeGen/aarch64-varargs.c clang/test/CodeGen/address-space-avr.c clang/test/CodeGen/address-space-field1.c clang/test/CodeGen/address-space.c clang/test/CodeGen/aggregate-assign-call.c clang/test/CodeGen/aix-return.c clang/test/CodeGen/aix-struct-arg.c clang/test/CodeGen/aix-vaargs.c clang/test/CodeGen/alias.c clang/test/CodeGen/align-param.c clang/test/CodeGen/align_value.cpp clang/test/CodeGen/alloc-align-attr.c clang/test/CodeGen/arc/arguments.c clang/test/CodeGen/arc/struct-align.c clang/test/CodeGen/arm-aapcs-vfp.c clang/test/CodeGen/arm-abi-vector.c clang/test/CodeGen/arm-arguments.c clang/test/CodeGen/arm-bf16-params-returns.c clang/test/CodeGen/arm-byval-align.c clang/test/CodeGen/arm-cmse-attr.c clang/test/CodeGen/arm-cmse-call.c clang/test/CodeGen/arm-float-helpers.c clang/test/CodeGen/arm-fp16-arguments.c clang/test/CodeGen/arm-homogenous.c clang/test/CodeGen/arm-mangle-bf16.cpp clang/test/CodeGen/arm-mve-intrinsics/vld24.c clang/test/CodeGen/arm-neon-directed-rounding.c clang/test/CodeGen/arm-neon-dot-product.c clang/test/CodeGen/arm-neon-fma.c clang/test/CodeGen/arm-neon-numeric-maxmin.c clang/test/CodeGen/arm-neon-vcvtX.c clang/test/CodeGen/arm-pcs.c clang/test/CodeGen/arm-swiftcall.c clang/test/CodeGen/arm-varargs.c clang/test/CodeGen/arm-vector-arguments.c clang/test/CodeGen/arm-vfp16-arguments.c clang/test/CodeGen/arm-vfp16-arguments2.cpp clang/test/CodeGen/arm64-aapcs-arguments.c clang/test/CodeGen/arm64-abi-vector.c clang/test/CodeGen/arm64-arguments.c clang/test/CodeGen/arm64-microsoft-arguments.cpp clang/test/CodeGen/arm64-microsoft-intrinsics.c clang/test/CodeGen/arm64-mte.c clang/test/CodeGen/arm64_32-vaarg.c clang/test/CodeGen/arm64_32.c clang/test/CodeGen/arm64_vcopy.c clang/test/CodeGen/arm64_vdupq_n_f64.c clang/test/CodeGen/arm_neon_intrinsics.c clang/test/CodeGen/armv7k-abi.c clang/test/CodeGen/asm-goto.c clang/test/CodeGen/asm-inout.c clang/test/CodeGen/asm-label.c clang/test/CodeGen/asm-reg-var-local.c clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c clang/test/CodeGen/atomic-arm64.c clang/test/CodeGen/atomic-ops-libcall.c clang/test/CodeGen/atomic-ops.c clang/test/CodeGen/atomic_ops.c clang/test/CodeGen/atomics-inlining.c clang/test/CodeGen/attr-cpuspecific.c clang/test/CodeGen/attr-disable-tail-calls.c clang/test/CodeGen/attr-func-def.c clang/test/CodeGen/attr-naked.c clang/test/CodeGen/attr-no-tail.c clang/test/CodeGen/attr-nomerge.cpp clang/test/CodeGen/attr-optnone.c clang/test/CodeGen/attr-target-mv-func-ptrs.c clang/test/CodeGen/attr-target-mv-va-args.c clang/test/CodeGen/attr-target-mv.c clang/test/CodeGen/attr-x86-interrupt.c clang/test/CodeGen/attributes.c clang/test/CodeGen/available-externally-hidden.cpp clang/test/CodeGen/available-externally-suppress.c clang/test/CodeGen/avr-builtins.c clang/test/CodeGen/avx2-builtins.c clang/test/CodeGen/avx512-reduceMinMaxIntrin.c clang/test/CodeGen/big-atomic-ops.c clang/test/CodeGen/bitfield-2.c clang/test/CodeGen/bittest-intrin.c clang/test/CodeGen/blocks-seq.c clang/test/CodeGen/blocks.c clang/test/CodeGen/bool-convert.c clang/test/CodeGen/bpf-attr-preserve-access-index-4.c clang/test/CodeGen/builtin-align-array.c clang/test/CodeGen/builtin-align.c clang/test/CodeGen/builtin-assume-aligned.c clang/test/CodeGen/builtin-assume.c clang/test/CodeGen/builtin-attributes.c clang/test/CodeGen/builtin-bpf-btf-type-id.c clang/test/CodeGen/builtin-constant-p.c clang/test/CodeGen/builtin-expect-with-probability.cpp clang/test/CodeGen/builtin-expect.c clang/test/CodeGen/builtin-memfns.c clang/test/CodeGen/builtin-ms-noop.cpp clang/test/CodeGen/builtin-preserve-access-index-array.c clang/test/CodeGen/builtin-preserve-access-index-nonptr.c clang/test/CodeGen/builtin-preserve-access-index-typedef.c clang/test/CodeGen/builtin-preserve-access-index.c clang/test/CodeGen/builtin-sponentry.c clang/test/CodeGen/builtin-sqrt.c clang/test/CodeGen/builtins-arm.c clang/test/CodeGen/builtins-bpf-preserve-field-info-1.c clang/test/CodeGen/builtins-bpf-preserve-field-info-2.c clang/test/CodeGen/builtins-memcpy-inline.c clang/test/CodeGen/builtins-ms.c clang/test/CodeGen/builtins-multiprecision.c clang/test/CodeGen/builtins-overflow.c clang/test/CodeGen/builtins-ppc-crypto.c clang/test/CodeGen/builtins-ppc-p7.c clang/test/CodeGen/builtins-ppc.c clang/test/CodeGen/builtins.c clang/test/CodeGen/c-strings.c clang/test/CodeGen/c11atomics-ios.c clang/test/CodeGen/c11atomics.c clang/test/CodeGen/callback_annotated.c clang/test/CodeGen/callback_openmp.c clang/test/CodeGen/callback_pthread_create.c clang/test/CodeGen/calling-conv-ignored.c clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp clang/test/CodeGen/catch-alignment-assumption-openmp.cpp clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c clang/test/CodeGen/catch-implicit-integer-sign-changes.c clang/test/CodeGen/catch-implicit-signed-integer-truncation-or-sign-change.c clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c clang/test/CodeGen/catch-pointer-overflow-volatile.c clang/test/CodeGen/catch-pointer-overflow.c clang/test/CodeGen/cfi-check-fail.c clang/test/CodeGen/cfi-check-fail2.c clang/test/CodeGen/cfi-icall-generalize.c clang/test/CodeGen/cleanup-destslot-simple.c clang/test/CodeGen/cmse-clear-arg.c clang/test/CodeGen/complex-builtins.c clang/test/CodeGen/complex-indirect.c clang/test/CodeGen/complex-init-list.c clang/test/CodeGen/complex-libcalls.c clang/test/CodeGen/complex-math.c clang/test/CodeGen/compound-literal.c clang/test/CodeGen/constructor-attribute.c clang/test/CodeGen/cxx-default-arg.cpp clang/test/CodeGen/debug-info-block-vars.c clang/test/CodeGen/debug-info-codeview-heapallocsite.c clang/test/CodeGen/debug-info-no-inline-line-tables.c clang/test/CodeGen/decl-in-prototype.c clang/test/CodeGen/decl.c clang/test/CodeGen/default-address-space.c clang/test/CodeGen/disable-tail-calls.c clang/test/CodeGen/dso-local-executable.c clang/test/CodeGen/enable_if.c clang/test/CodeGen/exceptions-seh-finally.c clang/test/CodeGen/exceptions-seh-leave.c clang/test/CodeGen/exceptions-seh-nested-finally.c clang/test/CodeGen/exceptions-seh.c clang/test/CodeGen/exceptions.c clang/test/CodeGen/exprs.c clang/test/CodeGen/ext-int-cc.c clang/test/CodeGen/extern-inline.c clang/test/CodeGen/fp-floatcontrol-pragma.cpp clang/test/CodeGen/fp-function-attrs.cpp clang/test/CodeGen/fp-options-to-fast-math-flags.c clang/test/CodeGen/fp128_complex.c clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c clang/test/CodeGen/function-attributes.c clang/test/CodeGen/functions.c clang/test/CodeGen/global-decls.c clang/test/CodeGen/hexagon-hvx-abi.c clang/test/CodeGen/ifunc.c clang/test/CodeGen/incomplete-function-type-2.c clang/test/CodeGen/inline-optim.c clang/test/CodeGen/inline.c clang/test/CodeGen/inline2.c clang/test/CodeGen/lanai-arguments.c clang/test/CodeGen/lanai-regparm.c clang/test/CodeGen/le32-arguments.c clang/test/CodeGen/le32-libcall-pow.c clang/test/CodeGen/le32-vaarg.c clang/test/CodeGen/libcall-declarations.c clang/test/CodeGen/libcalls-complex.c (1048 more files...) From cfe-commits at lists.llvm.org Mon Jul 6 11:23:46 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via cfe-commits) Date: Mon, 06 Jul 2020 11:23:46 -0700 (PDT) Subject: [clang] bfdafa3 - [FPEnv][Clang][Driver] Failing tests are now expected failures. Message-ID: <5f036c32.1c69fb81.d381f.0602@mx.google.com> Author: Kevin P. Neal Date: 2020-07-06T14:20:49-04:00 New Revision: bfdafa32a0fa4b2745627fe57dd253db10ac3fcf URL: https://github.com/llvm/llvm-project/commit/bfdafa32a0fa4b2745627fe57dd253db10ac3fcf DIFF: https://github.com/llvm/llvm-project/commit/bfdafa32a0fa4b2745627fe57dd253db10ac3fcf.diff LOG: [FPEnv][Clang][Driver] Failing tests are now expected failures. These are now expected failures on PowerPC. They can be reenabled when PowerPC is ready. Differential Revision: https://reviews.llvm.org/D80952 Added: Modified: clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c clang/test/CodeGen/fpconstrained.c clang/test/CodeGen/fpconstrained.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGen/fpconstrained-cmp-double.c b/clang/test/CodeGen/fpconstrained-cmp-double.c index 2819970a3fcf..d2744d283c84 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-double.c +++ b/clang/test/CodeGen/fpconstrained-cmp-double.c @@ -5,6 +5,9 @@ // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP +// Disabled until constrained floating point is completed for PowerPC. +// XFAIL: * + _Bool QuietEqual(double f1, double f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2) diff --git a/clang/test/CodeGen/fpconstrained-cmp-float.c b/clang/test/CodeGen/fpconstrained-cmp-float.c index 0265fc54c02b..2403e542b929 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-float.c +++ b/clang/test/CodeGen/fpconstrained-cmp-float.c @@ -5,6 +5,9 @@ // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP +// Disabled until constrained floating point is completed for PowerPC. +// XFAIL: * + _Bool QuietEqual(float f1, float f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2) diff --git a/clang/test/CodeGen/fpconstrained.c b/clang/test/CodeGen/fpconstrained.c index 902d6b5baf49..e268af46a2de 100644 --- a/clang/test/CodeGen/fpconstrained.c +++ b/clang/test/CodeGen/fpconstrained.c @@ -5,6 +5,10 @@ // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP + +// Disabled until constrained floating point is completed for PowerPC. +// XFAIL: * + float f0, f1, f2; void foo() { diff --git a/clang/test/CodeGen/fpconstrained.cpp b/clang/test/CodeGen/fpconstrained.cpp index e914abcc6926..8db68533d37c 100644 --- a/clang/test/CodeGen/fpconstrained.cpp +++ b/clang/test/CodeGen/fpconstrained.cpp @@ -5,6 +5,10 @@ // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP + +// Disabled until constrained floating point is completed for PowerPC. +// XFAIL: * + float f0, f1, f2; template From cfe-commits at lists.llvm.org Mon Jul 6 11:24:29 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:24:29 +0000 (UTC) Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot In-Reply-To: References: Message-ID: <01bfa2ee9e894875c98a3439a25e9389@localhost.localdomain> arsenm added a comment. ping CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82087/new/ https://reviews.llvm.org/D82087 From cfe-commits at lists.llvm.org Mon Jul 6 11:28:06 2020 From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:28:06 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: cchen marked an inline comment as done. cchen added inline comments. ================ Comment at: clang/lib/Parse/ParseExpr.cpp:1933 } + if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) { + // Consume ':' ---------------- cchen wrote: > ABataev wrote: > > Seems to me, it is too broad. According to the standard, it must be allowed only in to/from clauses. > I did the check in Sema, I'll move the check here. Thanks We didn't pass OpenMP clause information here. Do you think I should put the analysis in ParseOpenMPVarList or put the check in SemaOpenMP? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 From cfe-commits at lists.llvm.org Mon Jul 6 11:41:42 2020 From: cfe-commits at lists.llvm.org (Nico Weber via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:41:42 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <41aa18830cf71ec6a9e3414e5b5d14ce@localhost.localdomain> thakis added a comment. This seems to break tests everywhere, eg http://45.33.8.238/linux/22152/step_7.txt or http://lab.llvm.org:8011/builders/clang-x86_64-debian-new-pass-manager-fast/builds/11251 Please take a look and revert if the fix takes a while. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Mon Jul 6 11:44:17 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via cfe-commits) Date: Mon, 06 Jul 2020 11:44:17 -0700 (PDT) Subject: [clang] 2b35511 - [FPEnv][Clang][Driver] Failing tests are now expected failures only on PowerPC Message-ID: <5f037101.1c69fb81.77eeb.1d74@mx.google.com> Author: Kevin P. Neal Date: 2020-07-06T14:44:06-04:00 New Revision: 2b35511350454dd22997f129ee529e3fdb129ac2 URL: https://github.com/llvm/llvm-project/commit/2b35511350454dd22997f129ee529e3fdb129ac2 DIFF: https://github.com/llvm/llvm-project/commit/2b35511350454dd22997f129ee529e3fdb129ac2.diff LOG: [FPEnv][Clang][Driver] Failing tests are now expected failures only on PowerPC Mark these tests as only failing on PowerPC. Avoids unexpected passes on other bots. Fingers crossed. Differential Revision: https://reviews.llvm.org/D80952 Added: Modified: clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c clang/test/CodeGen/fpconstrained.c clang/test/CodeGen/fpconstrained.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGen/fpconstrained-cmp-double.c b/clang/test/CodeGen/fpconstrained-cmp-double.c index d2744d283c84..7c4d04677842 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-double.c +++ b/clang/test/CodeGen/fpconstrained-cmp-double.c @@ -6,7 +6,7 @@ // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP // Disabled until constrained floating point is completed for PowerPC. -// XFAIL: * +// XFAIL: powerpc, powerpc64, powerpc64le _Bool QuietEqual(double f1, double f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2) diff --git a/clang/test/CodeGen/fpconstrained-cmp-float.c b/clang/test/CodeGen/fpconstrained-cmp-float.c index 2403e542b929..964725080a7e 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-float.c +++ b/clang/test/CodeGen/fpconstrained-cmp-float.c @@ -6,7 +6,7 @@ // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP // Disabled until constrained floating point is completed for PowerPC. -// XFAIL: * +// XFAIL: powerpc, powerpc64, powerpc64le _Bool QuietEqual(float f1, float f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2) diff --git a/clang/test/CodeGen/fpconstrained.c b/clang/test/CodeGen/fpconstrained.c index e268af46a2de..3ce9b6fa1a55 100644 --- a/clang/test/CodeGen/fpconstrained.c +++ b/clang/test/CodeGen/fpconstrained.c @@ -7,7 +7,7 @@ // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP // Disabled until constrained floating point is completed for PowerPC. -// XFAIL: * +// XFAIL: powerpc, powerpc64, powerpc664le float f0, f1, f2; diff --git a/clang/test/CodeGen/fpconstrained.cpp b/clang/test/CodeGen/fpconstrained.cpp index 8db68533d37c..39634dd96994 100644 --- a/clang/test/CodeGen/fpconstrained.cpp +++ b/clang/test/CodeGen/fpconstrained.cpp @@ -7,7 +7,7 @@ // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP // Disabled until constrained floating point is completed for PowerPC. -// XFAIL: * +// XFAIL: powerpc, powerpc64, powerpc64le float f0, f1, f2; From cfe-commits at lists.llvm.org Mon Jul 6 11:45:16 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:45:16 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: kpn added a comment. Already on it. I hope I got it now. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Mon Jul 6 11:46:35 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:46:35 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <342ab789ccc1cbd7d2eb9afa0f829b86@localhost.localdomain> MaskRay added a comment. Note also that @arsenm is still a blocking reviewer. It is generally expected that all feedback is acknowledged. @kpn you should probably wait for @arsenm to explicitly clear the blocker. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Mon Jul 6 11:48:15 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:48:15 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: <89304fab4c8d8b8f3d4cf1b973db6e71@localhost.localdomain> njames93 added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121 "bugprone-narrowing-conversions"); + CheckFactories.registerCheck("bugprone-no-escape"); CheckFactories.registerCheck( ---------------- aaron.ballman wrote: > Given that this is limited to Objective-C, why register this under `bugprone` as opposed to the `objc` module? Alternatively, why limit to Objective-C when blocks can be used in other modes like C or C++ with `-fblocks`? Thats a good point, maybe restrict this to `LangOptions::ObjC || LangOptions::Blocks` Then it can be left in bugprone. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Mon Jul 6 11:49:39 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:49:39 +0000 (UTC) Subject: [PATCH] D83084: DomTree: Remove the releaseMemory() method In-Reply-To: References: Message-ID: <07ed16895943b4b98582cda732968fae@localhost.localdomain> dblaikie added a comment. @arsenm - if you can, please include some text whenever approving a patch via phabricator, otherwise no email indicating approval is sent to the mailing lists (which makes auditing reviews difficult) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83084/new/ https://reviews.llvm.org/D83084 From cfe-commits at lists.llvm.org Mon Jul 6 11:51:57 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 18:51:57 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: <24aad55f80463e5d8093241da42fdcff@localhost.localdomain> dblaikie added a comment. Generally Clang tries to avoid stylistic warnings like this (& they are left to be addressed by tools like clang-tidy), hence why -Winconsistent-missing-override was implemented that way (the presence of at least one "override" being a signal the user intended to use override and missed some, rather than that maybe the user hadn't intended to use it at all (because they were compiling their code with multiple versions, etc)). (but I wouldn't outright rule this out - just mentioning the general principle here, perhaps @rsmith or others have other ideas. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Mon Jul 6 12:00:11 2020 From: cfe-commits at lists.llvm.org (Julian Lettner via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:00:11 +0000 (UTC) Subject: [PATCH] D82791: [lit] Improve lit's output with default settings and --verbose. In-Reply-To: References: Message-ID: <9143896c53f9810308f40130c5aa0893@localhost.localdomain> yln added a comment. The changes here are for text printed for failing tests, right? And `showAllOutput` is orthogonal and just shows everything even for non-failing tests? ================ Comment at: llvm/utils/lit/lit/OutputSettings.py:34 +ONLY_FAILING_COMMAND = CommandOutputStyle("OnlyFailing") +UP_TO_AND_INCLUDING_FAILING_COMMAND = CommandOutputStyle("UpToAndIncluding") + ---------------- I really like the "communicating intent" part of this infrastructure. However, this is a lot of code and `if`s considering we really only have to distinguish two cases. From your commit message: - default (no flags): no script, show only failing line in command output - `-v`: full script, adds 'set +x', shows command output Am I missing something or could everything be keyed off a single verbose (reading from the code below `showAllOutput` implies verbose) flag. Do we anticipate other combinations being useful? (In general I would argue for striving for the simplest implementation that gives us what we currently want and not try to anticipate future extensions.) Have you considered (or started out with) just using a single verbose flag to base your decisions in the implementation functions? ================ Comment at: llvm/utils/lit/lit/TestRunner.py:1499 +def locate_last_run_line(output_str): + """ ---------------- I feel like this function is the most complex part of this patch. I don't fully follow it, but you experimented and believe this is the best approach and wrote a whole test suite so I am happy with it. ================ Comment at: llvm/utils/lit/lit/TestRunner.py:1503-1508 + Returns a pair of: + - The index in ``output_str`` pointing to immediately after the preceding + newline, i.e. the start of the RUN line, before any shell-specific + prefix. + - The matched substring itself, including the number at the end, + starting with 'RUN', skipping the shell-specific prefix. ---------------- Why use a complicated parser-like return value? Our only caller below could just receive the potentially found RUN line. ================ Comment at: llvm/utils/lit/lit/TestRunner.py:1593 + assert(lit_config.script_output_style == OutputSettings.FULL_SCRIPT) + return default_output() + ---------------- Why are we using two local functions here? The whole thing could be (already assuming just one verbose flag): ``` def make_script_output(lit_config, script_lines, exit_code): if not lit_config.verbose: return "" return ... ``` ================ Comment at: llvm/utils/lit/lit/TestRunner.py:1614-1617 + line_start, run_line_str = locate_last_run_line(cmd_output) + # maybe there was an error, or maybe we are not truncating anything + if run_line_str is None or line_start == 0: + return default_output() ---------------- This block should be pushed into the `lit_config.command_output_style == OutputSettings.ONLY_FAILING_COMMAND` case, otherwise we are always searching for the last line, even if we don't really use the result of the computation. Also: if we fail to find the RUN line, we might print the note to use `--verbose` even if the user already specified it. ================ Comment at: llvm/utils/lit/lit/TestRunner.py:1624 + == OutputSettings.UP_TO_AND_INCLUDING_FAILING_COMMAND) + return make_output(cmd_output, is_truncated=False) ---------------- Please try to simplify this a bit, maybe the following? ``` def make_command_output(): if not lit_config.quiet: return "" verbose = lit_config.verbose output = "header {} ...".format(", truncated" if verbose else "") if verbose: output += cmd_output else: run_line = locate_last_run_line() # then deal with "not found" case output += ... output += "Note: try to use --verbose" return output ``` ================ Comment at: llvm/utils/lit/lit/cl_arguments.py:56 action="store_true") + # TODO(python3): Use aliases kwarg for add_argument above. format_group.add_argument("-vv", "--echo-all-commands", ---------------- I think aliases kwarg is something else (seems to be related to subparsers). You could just add `"-vv", "--echo-all-commands"` after `"--verbose"` to allow for additional names for the flag, but I think I prefer to have it separate (makes it easer to remove it if we ever decide to drop the alias in the future). So long comment short: just drop this comment please. ================ Comment at: llvm/utils/lit/lit/cl_arguments.py:178 + opts.command_output_style = OutputSettings.ONLY_FAILING_COMMAND + opts.echo_all_commands = True + ---------------- Unconditionally overwritten below ================ Comment at: llvm/utils/lit/lit/cl_arguments.py:195 + cmd_output_style == OutputSettings.UP_TO_AND_INCLUDING_FAILING_COMMAND + or cmd_output_style == OutputSettings.ONLY_FAILING_COMMAND) ---------------- `opts.echo_all_commands = opts.command_output_style in {OutputSettings.UP_TO_AND_INCLUDING_FAILING_COMMAND, ...}` ================ Comment at: llvm/utils/lit/tests/shtest-run-at-line.py:70 + +################################################################################ +# Checking lines for verbose output ---------------- I really like the extension to this test. Thanks! ================ Comment at: llvm/utils/lit/tests/unittest-failing-locator.py:122 + +unittest.main() ---------------- Thanks for being diligent and adding these tests. This will also make it easy to add additional tests for corner cases if we need them in the future! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82791/new/ https://reviews.llvm.org/D82791 From cfe-commits at lists.llvm.org Mon Jul 6 12:00:30 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via cfe-commits) Date: Mon, 06 Jul 2020 12:00:30 -0700 (PDT) Subject: [clang] 916e2ca - Revert "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support." Message-ID: <5f0374ce.1c69fb81.85f01.2ba5@mx.google.com> Author: Kevin P. Neal Date: 2020-07-06T14:57:45-04:00 New Revision: 916e2ca99785d34db73945940923a487efad32ad URL: https://github.com/llvm/llvm-project/commit/916e2ca99785d34db73945940923a487efad32ad DIFF: https://github.com/llvm/llvm-project/commit/916e2ca99785d34db73945940923a487efad32ad.diff LOG: Revert "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support." My mistake, I had a blocking reviewer. This reverts commit 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4. This reverts commit bfdafa32a0fa4b2745627fe57dd253db10ac3fcf. This reverts commit 2b35511350454dd22997f129ee529e3fdb129ac2. Differential Revision: https://reviews.llvm.org/D80952 Added: Modified: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/TargetInfo.h clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/SystemZ.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/CompilerInstance.cpp clang/test/CodeGen/aarch64-neon-misc-constrained.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c clang/test/CodeGen/arm-neon-directed-rounding-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/builtins-ppc-fpconstrained.c clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c clang/test/CodeGen/fpconstrained.c clang/test/CodeGen/fpconstrained.cpp Removed: clang/test/CodeGen/fp-strictfp.cpp ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index db334a7899c4..83c13e0dbbe0 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -37,12 +37,6 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo; def warn_fe_override_module : Warning< "overriding the module target triple with %0">, InGroup>; -def warn_fe_backend_unsupported_fp_rounding : Warning< - "overriding currently unsupported rounding mode on this target">, - InGroup; -def warn_fe_backend_unsupported_fp_exceptions : Warning< - "overriding currently unsupported use of floating point exceptions " - "on this target">, InGroup; def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo, InGroup; diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index ff07608c81e4..37e0b77e79ed 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -107,7 +107,6 @@ def DoublePromotion : DiagGroup<"double-promotion">; def EnumTooLarge : DiagGroup<"enum-too-large">; def UnsupportedNan : DiagGroup<"unsupported-nan">; def UnsupportedAbs : DiagGroup<"unsupported-abs">; -def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">; def UnsupportedCB : DiagGroup<"unsupported-cb">; def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">; def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">; diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 2ee3b1659630..140f55ff66b1 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -192,7 +192,6 @@ class TargetInfo : public virtual TransferrableTargetInfo, bool HasFloat128; bool HasFloat16; bool HasBFloat16; - bool HasStrictFP; unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; unsigned short SimdDefaultAlign; @@ -578,9 +577,6 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Determine whether the _BFloat16 type is supported on this target. virtual bool hasBFloat16Type() const { return HasBFloat16; } - /// Determine whether constrained floating point is supported on this target. - virtual bool hasStrictFP() const { return HasStrictFP; } - /// Return the alignment that is suitable for storing any /// object with a fundamental alignment requirement. unsigned getSuitableAlign() const { return SuitableAlign; } diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index eccdc21d724a..7f360b715da9 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -37,7 +37,6 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { HasFloat128 = false; HasFloat16 = false; HasBFloat16 = false; - HasStrictFP = false; PointerWidth = PointerAlign = 32; BoolWidth = BoolAlign = 8; IntWidth = IntAlign = 32; diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index d7869e3754a8..134b0313b86a 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -48,7 +48,6 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { MinGlobalAlign = 16; resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"); MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; - HasStrictFP = true; } void getTargetDefines(const LangOptions &Opts, diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index d6c9b3fd3fe9..c33c608e27c8 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -138,7 +138,6 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { : TargetInfo(Triple) { LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); AddrSpaceMap = &X86AddrSpaceMap; - HasStrictFP = true; } const char *getLongDoubleMangling() const override { diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 189a030eb7f6..9dc9c42297ed 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -933,19 +933,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO)); } - if (!getTarget().hasStrictFP()) { - if (getLangOpts().getFPRoundingMode() != - llvm::RoundingMode::NearestTiesToEven) { - getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_rounding); - getLangOpts().setFPRoundingMode(llvm::RoundingMode::NearestTiesToEven); - } - if (getLangOpts().getFPExceptionMode() != LangOptions::FPE_Ignore) { - getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_exceptions); - getLangOpts().setFPExceptionMode(LangOptions::FPE_Ignore); - } - // FIXME: can we disable FEnvAccess? - } - // Inform the target of the language options. // // FIXME: We shouldn't need to do this, the target should be immutable once diff --git a/clang/test/CodeGen/aarch64-neon-misc-constrained.c b/clang/test/CodeGen/aarch64-neon-misc-constrained.c index db4474efd115..0385358291c9 100644 --- a/clang/test/CodeGen/aarch64-neon-misc-constrained.c +++ b/clang/test/CodeGen/aarch64-neon-misc-constrained.c @@ -15,9 +15,6 @@ // REQUIRES: aarch64-registered-target -// Disabled until constrained floating point is implemented for arm64. -// XFAIL: * - // Test new aarch64 intrinsics and types but constrained #include diff --git a/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c b/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c index c6fa81e894c8..cbe5627337fd 100644 --- a/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c +++ b/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c @@ -15,9 +15,6 @@ // REQUIRES: aarch64-registered-target -// Disabled until constrained floating point is implemented for arm64. -// XFAIL: * - // Test new aarch64 intrinsics and types but constrained #include diff --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c index dd3e92d0fde9..6058e6f92832 100644 --- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c +++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c @@ -19,9 +19,6 @@ // REQUIRES: aarch64-registered-target -// Disabled until constrained floating point is implemented for arm64. -// XFAIL: * - #include // COMMON-LABEL: test_vsqrt_f16 diff --git a/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c b/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c index 493f7924ec14..5246993173f8 100644 --- a/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c +++ b/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c @@ -32,9 +32,6 @@ // REQUIRES: arm-registered-target,aarch64-registered-target -// Disabled until constrained floating point is implemented for arm64. -// XFAIL: * - #include // COMMON-LABEL: test_vrndi_f32 diff --git a/clang/test/CodeGen/arm64-vrnd-constrained.c b/clang/test/CodeGen/arm64-vrnd-constrained.c index f46b1abfa4e3..bbded8f2c7f6 100644 --- a/clang/test/CodeGen/arm64-vrnd-constrained.c +++ b/clang/test/CodeGen/arm64-vrnd-constrained.c @@ -9,9 +9,6 @@ // REQUIRES: aarch64-registered-target -// Disabled until constrained floating point is implemented for arm64. -// XFAIL: * - #include float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); } diff --git a/clang/test/CodeGen/builtins-ppc-fpconstrained.c b/clang/test/CodeGen/builtins-ppc-fpconstrained.c index 1e6da685b3d2..38cdfb6aab38 100644 --- a/clang/test/CodeGen/builtins-ppc-fpconstrained.c +++ b/clang/test/CodeGen/builtins-ppc-fpconstrained.c @@ -12,9 +12,6 @@ // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \ // RUN: --check-prefix=FIXME-CHECK %s -// Disabled until constrained floating point is completed for PowerPC. -// XFAIL: * - typedef __attribute__((vector_size(4 * sizeof(float)))) float vec_float; typedef __attribute__((vector_size(2 * sizeof(double)))) double vec_double; diff --git a/clang/test/CodeGen/fp-strictfp.cpp b/clang/test/CodeGen/fp-strictfp.cpp deleted file mode 100644 index 1a88a545fbd3..000000000000 --- a/clang/test/CodeGen/fp-strictfp.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s -// -// Verify that constrained intrinsics are not used. -// As more targets gain support for constrained intrinsics the triple -// in this test will need to change. - -// rounding-warning@* {{overriding currently unsupported rounding mode on this target}} -// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}} -float fp_precise_1(float a, float b, float c) { -// CHECK: _Z12fp_precise_1fff -// CHECK: %[[M:.+]] = fmul float{{.*}} -// CHECK: fadd float %[[M]], %c - return a * b + c; -} - - diff --git a/clang/test/CodeGen/fpconstrained-cmp-double.c b/clang/test/CodeGen/fpconstrained-cmp-double.c index 7c4d04677842..2819970a3fcf 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-double.c +++ b/clang/test/CodeGen/fpconstrained-cmp-double.c @@ -5,9 +5,6 @@ // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP -// Disabled until constrained floating point is completed for PowerPC. -// XFAIL: powerpc, powerpc64, powerpc64le - _Bool QuietEqual(double f1, double f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2) diff --git a/clang/test/CodeGen/fpconstrained-cmp-float.c b/clang/test/CodeGen/fpconstrained-cmp-float.c index 964725080a7e..0265fc54c02b 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-float.c +++ b/clang/test/CodeGen/fpconstrained-cmp-float.c @@ -5,9 +5,6 @@ // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP -// Disabled until constrained floating point is completed for PowerPC. -// XFAIL: powerpc, powerpc64, powerpc64le - _Bool QuietEqual(float f1, float f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2) diff --git a/clang/test/CodeGen/fpconstrained.c b/clang/test/CodeGen/fpconstrained.c index 3ce9b6fa1a55..902d6b5baf49 100644 --- a/clang/test/CodeGen/fpconstrained.c +++ b/clang/test/CodeGen/fpconstrained.c @@ -5,10 +5,6 @@ // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP - -// Disabled until constrained floating point is completed for PowerPC. -// XFAIL: powerpc, powerpc64, powerpc664le - float f0, f1, f2; void foo() { diff --git a/clang/test/CodeGen/fpconstrained.cpp b/clang/test/CodeGen/fpconstrained.cpp index 39634dd96994..e914abcc6926 100644 --- a/clang/test/CodeGen/fpconstrained.cpp +++ b/clang/test/CodeGen/fpconstrained.cpp @@ -5,10 +5,6 @@ // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP - -// Disabled until constrained floating point is completed for PowerPC. -// XFAIL: powerpc, powerpc64, powerpc64le - float f0, f1, f2; template From cfe-commits at lists.llvm.org Mon Jul 6 12:03:03 2020 From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:03:03 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: <8dd35093969b31962d16e454005edb2b@localhost.localdomain> ellis marked an inline comment as done. ellis added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:82 "bugprone-bool-pointer-implicit-conversion"); - CheckFactories.registerCheck( - "bugprone-branch-clone"); + CheckFactories.registerCheck("bugprone-branch-clone"); CheckFactories.registerCheck( ---------------- aaron.ballman wrote: > It looks like unrelated formatting changes may have snuck in? The script `add_new_check.py` doesn't format the code that it generated so a few lines aren't linted. Would you like me to undo these extra formatted lines? ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121 "bugprone-narrowing-conversions"); + CheckFactories.registerCheck("bugprone-no-escape"); CheckFactories.registerCheck( ---------------- njames93 wrote: > aaron.ballman wrote: > > Given that this is limited to Objective-C, why register this under `bugprone` as opposed to the `objc` module? Alternatively, why limit to Objective-C when blocks can be used in other modes like C or C++ with `-fblocks`? > Thats a good point, maybe restrict this to `LangOptions::ObjC || LangOptions::Blocks` Then it can be left in bugprone. Ok, I'll include `LangOptions::Blocks`. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:37 + if (Var && Var->hasAttr()) { + diag(MatchedEscapingBlock->getBeginLoc(), + "pointer %0 with attribute 'noescape' is captured by an " ---------------- aaron.ballman wrote: > Given that the capture is the issue (not the block), why not point to the use of the captured variable? I actually agree that pointing to the use of the captured variable would be easier to read, but honestly I couldn't figure out how to grab the location of that use. All I could get was the definition of the variable. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Mon Jul 6 12:08:10 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:08:10 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: <70333820bebf2c23c634309e9a910d86@localhost.localdomain> ABataev added inline comments. ================ Comment at: clang/lib/Parse/ParseExpr.cpp:1933 } + if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) { + // Consume ':' ---------------- cchen wrote: > cchen wrote: > > ABataev wrote: > > > Seems to me, it is too broad. According to the standard, it must be allowed only in to/from clauses. > > I did the check in Sema, I'll move the check here. Thanks > We didn't pass OpenMP clause information here. Do you think I should put the analysis in ParseOpenMPVarList or put the check in SemaOpenMP? Try to pass it somehow. Maybe, create a parser data member with the current kind of the clause we trying to parse? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 From cfe-commits at lists.llvm.org Mon Jul 6 12:08:20 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:08:20 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: <3f5496b767e4b144d1418657bfaa0e59@localhost.localdomain> aaron.ballman added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:82 "bugprone-bool-pointer-implicit-conversion"); - CheckFactories.registerCheck( - "bugprone-branch-clone"); + CheckFactories.registerCheck("bugprone-branch-clone"); CheckFactories.registerCheck( ---------------- ellis wrote: > aaron.ballman wrote: > > It looks like unrelated formatting changes may have snuck in? > The script `add_new_check.py` doesn't format the code that it generated so a few lines aren't linted. Would you like me to undo these extra formatted lines? Yes, please. The way I usually do this, btw, is to run the patch through clang-format-diff so that only the lines I've touched get formatted: https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121 "bugprone-narrowing-conversions"); + CheckFactories.registerCheck("bugprone-no-escape"); CheckFactories.registerCheck( ---------------- ellis wrote: > njames93 wrote: > > aaron.ballman wrote: > > > Given that this is limited to Objective-C, why register this under `bugprone` as opposed to the `objc` module? Alternatively, why limit to Objective-C when blocks can be used in other modes like C or C++ with `-fblocks`? > > Thats a good point, maybe restrict this to `LangOptions::ObjC || LangOptions::Blocks` Then it can be left in bugprone. > Ok, I'll include `LangOptions::Blocks`. I think the only option you need is `LangOptions::Blocks` (it should be enabled automatically in ObjC language mode). ================ Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:37 + if (Var && Var->hasAttr()) { + diag(MatchedEscapingBlock->getBeginLoc(), + "pointer %0 with attribute 'noescape' is captured by an " ---------------- ellis wrote: > aaron.ballman wrote: > > Given that the capture is the issue (not the block), why not point to the use of the captured variable? > I actually agree that pointing to the use of the captured variable would be easier to read, but honestly I couldn't figure out how to grab the location of that use. All I could get was the definition of the variable. Ah, yeah, I just looked at the class and it looks like we don't track that information yet and it would be somewhat involved to get it. Can you add a FIXME comment above the call to `diag()` mentioning that we'd prefer to diagnose the use of the capture rather than the block? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Mon Jul 6 12:08:24 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:08:24 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: <0621a2c4e55db5052736c5a67e9361b1@localhost.localdomain> riccibruno updated this revision to Diff 275783. riccibruno added a comment. Make `dumpAPValueChildren` a private member function and remove `TextNodeDumper::getOS`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 Files: clang/include/clang/AST/APValue.h clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/JSONNodeDumper.h clang/include/clang/AST/TextNodeDumper.h clang/lib/AST/APValue.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/TextNodeDumper.cpp clang/test/AST/alignas_maybe_odr_cleanup.cpp clang/test/AST/ast-dump-APValue-anon-union.cpp clang/test/AST/ast-dump-APValue-arithmetic.cpp clang/test/AST/ast-dump-APValue-array.cpp clang/test/AST/ast-dump-APValue-struct.cpp clang/test/AST/ast-dump-APValue-todo.cpp clang/test/AST/ast-dump-APValue-union.cpp clang/test/AST/ast-dump-APValue-vector.cpp clang/test/AST/ast-dump-attr.cpp clang/test/AST/ast-dump-color.cpp clang/test/AST/ast-dump-constant-expr.cpp clang/test/AST/ast-dump-decl.cpp clang/test/AST/ast-dump-records.cpp clang/test/AST/ast-dump-stmt.cpp clang/test/AST/pr43983.cpp clang/test/Import/switch-stmt/test.cpp clang/test/Tooling/clang-check-ast-dump.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83183.275783.patch Type: text/x-patch Size: 48555 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:12:26 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:12:26 +0000 (UTC) Subject: [PATCH] D82937: Fix `isInfixBinaryOp` that returned true for postfix ++ In-Reply-To: References: Message-ID: <298c360220146cc74f28f16f47ef372c@localhost.localdomain> gribozavr2 added inline comments. ================ Comment at: clang/unittests/Tooling/CXXOperatorCallExprTest.cpp:21 + const std::string Code = R"cpp( + struct X{ + friend X operator+(X, X); ---------------- Please add a space before "{". ================ Comment at: clang/unittests/Tooling/CXXOperatorCallExprTest.cpp:24 + }; + void test(X x){ + x + x; ---------------- Please add a space before "{". (Throughout the patch.) ================ Comment at: clang/unittests/Tooling/CXXOperatorCallExprTest.cpp:1 +//===- unittests/Tooling/CXXOperatorCallExprTest.cpp ----------------------===// +// ---------------- eduucaldas wrote: > This file is in the `unittests/Tooling` instead in the `unittests/AST` directory because I wanted to have access to the `TestVisitor` infrastructure. I know the solution is not optimal and I am looking for suggestions Could you make a separate patch where you move `TestVisitor.h` under `clang/include/clang/Testing`? Then you can place this test into `unittests/AST`. OTOH, since the test is not testing the visitation, WDYT about changing the test to use AST matchers instead? It would seem to lead to more straightforward tests: get the AST node, act on it. See `clang/unittests/AST/MatchVerifier.h`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82937/new/ https://reviews.llvm.org/D82937 From cfe-commits at lists.llvm.org Mon Jul 6 12:16:05 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:16:05 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <178e37b3d566d5e1769f2a71b30eac42@localhost.localdomain> arsenm added a comment. In D80952#2133693 , @MaskRay wrote: > Note also that @arsenm is still a blocking reviewer. It is generally expected that all feedback is acknowledged. @kpn you should probably have waited for @arsenm to explicitly clear the blocker. I think this is one of the finer points of phabricator usage that are generally ignored. I'd still like to have a way to force this on unhandled targets, but I don't care that much about this Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Mon Jul 6 12:26:35 2020 From: cfe-commits at lists.llvm.org (Zixu Wang via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:26:35 +0000 (UTC) Subject: [PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver Message-ID: zixuw created this revision. zixuw added reviewers: arphaman, ributzka. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang. Add clang option `-Wundef-prefix=TARGET_OS_` and `-Werror=undef-prefix` to Darwin driver. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83250 Files: clang/lib/Driver/ToolChains/Darwin.cpp Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -954,6 +954,10 @@ : Darwin(D, Triple, Args) {} void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const { + // Always error about undefined 'TARGET_OS_*' macros. + CC1Args.push_back("-Wundef-prefix=TARGET_OS_"); + CC1Args.push_back("-Werror=undef-prefix"); + // For modern targets, promote certain warnings to errors. if (isTargetWatchOSBased() || getTriple().isArch64Bit()) { // Always enable -Wdeprecated-objc-isa-usage and promote it -------------- next part -------------- A non-text attachment was scrubbed... Name: D83250.275796.patch Type: text/x-patch Size: 676 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:29:58 2020 From: cfe-commits at lists.llvm.org (Varun Gandhi via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:29:58 +0000 (UTC) Subject: [PATCH] D82791: [lit] Improve lit's output with default settings and --verbose. In-Reply-To: References: Message-ID: varungandhi-apple marked 2 inline comments as done. varungandhi-apple added a comment. Thanks for the review, it's a big patch. 😅 I'm a bit busy at the moment, I will respond to the other comments later this week or sometime next week. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82791/new/ https://reviews.llvm.org/D82791 From cfe-commits at lists.llvm.org Mon Jul 6 12:31:49 2020 From: cfe-commits at lists.llvm.org (Steven Wan via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:31:49 +0000 (UTC) Subject: [PATCH] D79842: [clang][Driver] Correct tool search path priority In-Reply-To: References: Message-ID: <2ff89634ac605b5d192bbc9fb2b9e135@localhost.localdomain> stevewan added a comment. The test was failing on Linux if I set LLVM_DEFAULT_TARGET_TRIPLE. For example if I set it to`powerpc64le-linux-gnu` clang actually uses "powerpc64le-unknown-linux-gnu". Would you be able to provide a fix to this? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79842/new/ https://reviews.llvm.org/D79842 From cfe-commits at lists.llvm.org Mon Jul 6 12:45:12 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:45:12 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! ================ Comment at: clang/test/Import/switch-stmt/test.cpp:8 // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral ---------------- riccibruno wrote: > aaron.ballman wrote: > > I sort of wonder whether we want both the text and the JSON dumpers to dump these as: `value(type): `, as that seems like it produces results that are a bit more well-structured. WDYT? > I'm not sure I follow. The `value` is just a label for the child of the `VarDecl`. > If you look at a more complex example such as: > ``` > VarDecl {{.*}} col:{{.*}} s4 'const S4' > |-value: Struct > | |-base: Struct > | | `-fields: Int 0, Union .j Int 0 > | |-fields: Int 1, Int 2, Int 3 > | |-field: Struct > | `-fields: Int 4, Int 5, Int 6 > ``` > > There is no other `value` label. Ah, I was misunderstanding the ouput. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 From cfe-commits at lists.llvm.org Mon Jul 6 12:49:00 2020 From: cfe-commits at lists.llvm.org (Arthur O'Dwyer via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:49:00 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: <239a6794b97afad65f4f22e9d073c144@localhost.localdomain> Quuxplusone added a comment. In D82728#2133720 , @dblaikie wrote: > (the presence of at least one "override" being a signal the user intended to use override and missed some [...] I'm in favor of `-Wsuggest-override`, and would definitely use it if it existed. The problem I see with `-Wmissing-override`, as it's been implemented, is that it uses the wrong granularity for "intent": it looks only across the methods of a single class, rather than across all the classes of a single header, or across a single translation unit, or across my entire codebase. In real life, I //always// want to look across my entire codebase (excluding system headers). If //any// class in my project uses `override`, I want Clang to take that as a clear declaration of intent to use `override` throughout; I don't want Clang treating class A differently from class B. But of course Clang can't look at my whole codebase simultaneously. So the next best thing is to give the user a simple way to "preload the intent flag": to say "As soon as you start processing //any// class, please act as if intent has been declared for that class." Adding `-Wsuggest-override` to my build line seems like a perfect way to implement that "preload" facility. ================ Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3075 + : diag:: + warn_inconsistent_function_marked_not_override_overriding); + else ---------------- These linebreaks are super unfortunate. Could they be improved by doing it like this? ``` auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) { unsigned DiagID = isa(MD) ? DiagDtor : DiagFn; Diag(MD->getLocation(), DiagID) << MD->getDeclName(); const CXXMethodDecl *OMD = *MD->begin_overridden_methods(); Diag(OMD->getLocation(), diag::note_overridden_virtual_function); }; if (Inconsistent) EmitDiag(diag::warn_inconsistent_destructor_marked_not_override_overriding, diag::warn_inconsistent_function_marked_not_override_overriding); else EmitDiag(diag::warn_suggest_destructor_marked_not_override_overriding diag::warn_suggest_function_marked_not_override_overriding); ``` ================ Comment at: clang/lib/Sema/SemaDeclCXX.cpp:6764 + if (HasOverridingMethodWithoutOverrideControl) { + bool InconsistentOverrideControl = HasMethodWithOverrideControl; for (auto *M : Record->methods()) ---------------- Can you s/InconsistentOverrideControl/HasInconsistentOverrideControl/ without causing bad linebreaks? ================ Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:6 + ~A() {} + void virtual run() {} +}; ---------------- Surely this doesn't compile?! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Mon Jul 6 12:50:08 2020 From: cfe-commits at lists.llvm.org (Wouter van Oortmerssen via cfe-commits) Date: Mon, 06 Jul 2020 12:50:08 -0700 (PDT) Subject: [clang] 16d83c3 - [WebAssembly] Added 64-bit memory.grow/size/copy/fill Message-ID: <5f038070.1c69fb81.1ca09.3d7c@mx.google.com> Author: Wouter van Oortmerssen Date: 2020-07-06T12:49:50-07:00 New Revision: 16d83c395a1f8660fc583a66e1927a5c433fbbe1 URL: https://github.com/llvm/llvm-project/commit/16d83c395a1f8660fc583a66e1927a5c433fbbe1 DIFF: https://github.com/llvm/llvm-project/commit/16d83c395a1f8660fc583a66e1927a5c433fbbe1.diff LOG: [WebAssembly] Added 64-bit memory.grow/size/copy/fill This covers both the existing memory functions as well as the new bulk memory proposal. Added new test files since changes where also required in the inputs. Also removes unused init/drop intrinsics rather than trying to make them work for 64-bit. Differential Revision: https://reviews.llvm.org/D82821 Added: llvm/test/CodeGen/WebAssembly/bulk-memory64.ll llvm/test/CodeGen/WebAssembly/memory-addr64.ll Modified: clang/include/clang/Basic/BuiltinsWebAssembly.def clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/builtins-wasm.c llvm/include/llvm/IR/IntrinsicsWebAssembly.td llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp llvm/test/MC/WebAssembly/bulk-memory-encodings.s Removed: llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll ################################################################################ diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def b/clang/include/clang/Basic/BuiltinsWebAssembly.def index 5e6f0d90ab46..ecee7782920f 100644 --- a/clang/include/clang/Basic/BuiltinsWebAssembly.def +++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def @@ -25,10 +25,6 @@ BUILTIN(__builtin_wasm_memory_size, "zIi", "n") BUILTIN(__builtin_wasm_memory_grow, "zIiz", "n") -// Bulk memory builtins -TARGET_BUILTIN(__builtin_wasm_memory_init, "vIUiIUiv*UiUi", "", "bulk-memory") -TARGET_BUILTIN(__builtin_wasm_data_drop, "vIUi", "", "bulk-memory") - // Thread-local storage TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory") TARGET_BUILTIN(__builtin_wasm_tls_align, "z", "nc", "bulk-memory") diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 265fee392a82..91969267cdb9 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -16101,30 +16101,6 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_grow, ResultType); return Builder.CreateCall(Callee, Args); } - case WebAssembly::BI__builtin_wasm_memory_init: { - llvm::APSInt SegConst; - if (!E->getArg(0)->isIntegerConstantExpr(SegConst, getContext())) - llvm_unreachable("Constant arg isn't actually constant?"); - llvm::APSInt MemConst; - if (!E->getArg(1)->isIntegerConstantExpr(MemConst, getContext())) - llvm_unreachable("Constant arg isn't actually constant?"); - if (!MemConst.isNullValue()) - ErrorUnsupported(E, "non-zero memory index"); - Value *Args[] = {llvm::ConstantInt::get(getLLVMContext(), SegConst), - llvm::ConstantInt::get(getLLVMContext(), MemConst), - EmitScalarExpr(E->getArg(2)), EmitScalarExpr(E->getArg(3)), - EmitScalarExpr(E->getArg(4))}; - Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_memory_init); - return Builder.CreateCall(Callee, Args); - } - case WebAssembly::BI__builtin_wasm_data_drop: { - llvm::APSInt SegConst; - if (!E->getArg(0)->isIntegerConstantExpr(SegConst, getContext())) - llvm_unreachable("Constant arg isn't actually constant?"); - Value *Arg = llvm::ConstantInt::get(getLLVMContext(), SegConst); - Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_data_drop); - return Builder.CreateCall(Callee, {Arg}); - } case WebAssembly::BI__builtin_wasm_tls_size: { llvm::Type *ResultType = ConvertType(E->getType()); Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_size, ResultType); diff --git a/clang/test/CodeGen/builtins-wasm.c b/clang/test/CodeGen/builtins-wasm.c index 36d259f7405d..f7e3dc1ea5e7 100644 --- a/clang/test/CodeGen/builtins-wasm.c +++ b/clang/test/CodeGen/builtins-wasm.c @@ -26,18 +26,6 @@ __SIZE_TYPE__ memory_grow(__SIZE_TYPE__ delta) { // WEBASSEMBLY64: call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %{{.*}}) } -void memory_init(void *dest, int offset, int size) { - __builtin_wasm_memory_init(3, 0, dest, offset, size); - // WEBASSEMBLY32: call void @llvm.wasm.memory.init(i32 3, i32 0, i8* %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) - // WEBASSEMBLY64: call void @llvm.wasm.memory.init(i32 3, i32 0, i8* %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) -} - -void data_drop() { - __builtin_wasm_data_drop(3); - // WEBASSEMBLY32: call void @llvm.wasm.data.drop(i32 3) - // WEBASSEMBLY64: call void @llvm.wasm.data.drop(i32 3) -} - __SIZE_TYPE__ tls_size() { return __builtin_wasm_tls_size(); // WEBASSEMBLY32: call i32 @llvm.wasm.tls.size.i32() diff --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td index 0c08aad22362..7c9ceb148a47 100644 --- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td +++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td @@ -206,20 +206,6 @@ def int_wasm_nearest : [LLVMMatchType<0>], [IntrNoMem, IntrSpeculatable]>; -//===----------------------------------------------------------------------===// -// Bulk memory intrinsics -//===----------------------------------------------------------------------===// - -def int_wasm_memory_init : - Intrinsic<[], - [llvm_i32_ty, llvm_i32_ty, llvm_ptr_ty, llvm_i32_ty, llvm_i32_ty], - [IntrWriteMem, IntrInaccessibleMemOrArgMemOnly, WriteOnly>, - IntrHasSideEffects, ImmArg>, ImmArg>]>; -def int_wasm_data_drop : - Intrinsic<[], - [llvm_i32_ty], - [IntrNoDuplicate, IntrHasSideEffects, ImmArg>]>; - //===----------------------------------------------------------------------===// // Thread-local storage intrinsics //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td index 05735cf6d31f..3e9ef6fbc7ea 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td @@ -33,39 +33,43 @@ def wasm_memset_t : SDTypeProfile<0, 4, def wasm_memset : SDNode<"WebAssemblyISD::MEMORY_FILL", wasm_memset_t, [SDNPHasChain, SDNPMayStore]>; +multiclass BulkMemoryOps { + let mayStore = 1, hasSideEffects = 1 in -defm MEMORY_INIT : +defm MEMORY_INIT_A#B : BULK_I<(outs), - (ins i32imm_op:$seg, i32imm_op:$idx, I32:$dest, - I32:$offset, I32:$size), + (ins i32imm_op:$seg, i32imm_op:$idx, rc:$dest, + rc:$offset, rc:$size), (outs), (ins i32imm_op:$seg, i32imm_op:$idx), - [(int_wasm_memory_init (i32 timm:$seg), (i32 timm:$idx), I32:$dest, - I32:$offset, I32:$size - )], + [], "memory.init\t$seg, $idx, $dest, $offset, $size", "memory.init\t$seg, $idx", 0x08>; let hasSideEffects = 1 in defm DATA_DROP : BULK_I<(outs), (ins i32imm_op:$seg), (outs), (ins i32imm_op:$seg), - [(int_wasm_data_drop (i32 timm:$seg))], + [], "data.drop\t$seg", "data.drop\t$seg", 0x09>; let mayLoad = 1, mayStore = 1 in -defm MEMORY_COPY : +defm MEMORY_COPY_A#B : BULK_I<(outs), (ins i32imm_op:$src_idx, i32imm_op:$dst_idx, - I32:$dst, I32:$src, I32:$len), + rc:$dst, rc:$src, rc:$len), (outs), (ins i32imm_op:$src_idx, i32imm_op:$dst_idx), [(wasm_memcpy (i32 imm:$src_idx), (i32 imm:$dst_idx), - I32:$dst, I32:$src, I32:$len + rc:$dst, rc:$src, rc:$len )], "memory.copy\t$src_idx, $dst_idx, $dst, $src, $len", "memory.copy\t$src_idx, $dst_idx", 0x0a>; let mayStore = 1 in -defm MEMORY_FILL : - BULK_I<(outs), (ins i32imm_op:$idx, I32:$dst, I32:$value, I32:$size), +defm MEMORY_FILL_A#B : + BULK_I<(outs), (ins i32imm_op:$idx, rc:$dst, I32:$value, rc:$size), (outs), (ins i32imm_op:$idx), - [(wasm_memset (i32 imm:$idx), I32:$dst, I32:$value, I32:$size)], + [(wasm_memset (i32 imm:$idx), rc:$dst, I32:$value, rc:$size)], "memory.fill\t$idx, $dst, $value, $size", "memory.fill\t$idx", 0x0b>; +} + +defm : BulkMemoryOps; +defm : BulkMemoryOps; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td index 686c017593c8..b3c63cc1f884 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td @@ -365,19 +365,24 @@ defm : StorePatGlobalAddrOffOnly; defm : StorePatGlobalAddrOffOnly; defm : StorePatGlobalAddrOffOnly; +multiclass MemoryOps { // Current memory size. -defm MEMORY_SIZE_I32 : I<(outs I32:$dst), (ins i32imm:$flags), +defm MEMORY_SIZE_A#B : I<(outs rc:$dst), (ins i32imm:$flags), (outs), (ins i32imm:$flags), - [(set I32:$dst, + [(set rc:$dst, (int_wasm_memory_size (i32 imm:$flags)))], "memory.size\t$dst, $flags", "memory.size\t$flags", 0x3f>; // Grow memory. -defm MEMORY_GROW_I32 : I<(outs I32:$dst), (ins i32imm:$flags, I32:$delta), +defm MEMORY_GROW_A#B : I<(outs rc:$dst), (ins i32imm:$flags, rc:$delta), (outs), (ins i32imm:$flags), - [(set I32:$dst, + [(set rc:$dst, (int_wasm_memory_grow (i32 imm:$flags), - I32:$delta))], + rc:$delta))], "memory.grow\t$dst, $flags, $delta", "memory.grow\t$flags", 0x40>; +} + +defm : MemoryOps; +defm : MemoryOps; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp b/llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp index b2b2b7a9d705..16e05150c64e 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp @@ -22,15 +22,15 @@ SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemcpy( SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool IsVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const { - if (!DAG.getMachineFunction() - .getSubtarget() - .hasBulkMemory()) + auto &ST = DAG.getMachineFunction().getSubtarget(); + if (!ST.hasBulkMemory()) return SDValue(); SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32); + auto LenMVT = ST.hasAddr64() ? MVT::i64 : MVT::i32; return DAG.getNode(WebAssemblyISD::MEMORY_COPY, DL, MVT::Other, {Chain, MemIdx, MemIdx, Dst, Src, - DAG.getZExtOrTrunc(Size, DL, MVT::i32)}); + DAG.getZExtOrTrunc(Size, DL, LenMVT)}); } SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemmove( @@ -46,14 +46,14 @@ SDValue WebAssemblySelectionDAGInfo::EmitTargetCodeForMemset( SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Val, SDValue Size, Align Alignment, bool IsVolatile, MachinePointerInfo DstPtrInfo) const { - if (!DAG.getMachineFunction() - .getSubtarget() - .hasBulkMemory()) + auto &ST = DAG.getMachineFunction().getSubtarget(); + if (!ST.hasBulkMemory()) return SDValue(); SDValue MemIdx = DAG.getConstant(0, DL, MVT::i32); + auto LenMVT = ST.hasAddr64() ? MVT::i64 : MVT::i32; // Only low byte matters for val argument, so anyext the i8 return DAG.getNode(WebAssemblyISD::MEMORY_FILL, DL, MVT::Other, Chain, MemIdx, Dst, DAG.getAnyExtOrTrunc(Val, DL, MVT::i32), - DAG.getZExtOrTrunc(Size, DL, MVT::i32)); + DAG.getZExtOrTrunc(Size, DL, LenMVT)); } diff --git a/llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll b/llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll deleted file mode 100644 index dfb74b78f64f..000000000000 --- a/llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll +++ /dev/null @@ -1,28 +0,0 @@ -; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+bulk-memory | FileCheck %s - -; Test that bulk memory intrinsics lower correctly - -target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" -target triple = "wasm32-unknown-unknown" - -; CHECK-LABEL: memory_init: -; CHECK-NEXT: .functype memory_init (i32, i32, i32) -> () -; CHECK-NEXT: memory.init 3, 0, $0, $1, $2 -; CHECK-NEXT: return -declare void @llvm.wasm.memory.init(i32, i32, i8*, i32, i32) -define void @memory_init(i8* %dest, i32 %offset, i32 %size) { - call void @llvm.wasm.memory.init( - i32 3, i32 0, i8* %dest, i32 %offset, i32 %size - ) - ret void -} - -; CHECK-LABEL: data_drop: -; CHECK-NEXT: .functype data_drop () -> () -; CHECK-NEXT: data.drop 3 -; CHECK-NEXT: return -declare void @llvm.wasm.data.drop(i32) -define void @data_drop() { - call void @llvm.wasm.data.drop(i32 3) - ret void -} diff --git a/llvm/test/CodeGen/WebAssembly/bulk-memory64.ll b/llvm/test/CodeGen/WebAssembly/bulk-memory64.ll new file mode 100644 index 000000000000..6c450f5b5398 --- /dev/null +++ b/llvm/test/CodeGen/WebAssembly/bulk-memory64.ll @@ -0,0 +1,210 @@ +; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+bulk-memory | FileCheck %s --check-prefixes CHECK,BULK-MEM +; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=-bulk-memory | FileCheck %s --check-prefixes CHECK,NO-BULK-MEM + +; Test that basic bulk memory codegen works correctly + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm64-unknown-unknown" + +declare void @llvm.memcpy.p0i8.p0i8.i8(i8*, i8*, i8, i1) +declare void @llvm.memcpy.p0i8.p0i8.i64(i8*, i8*, i64, i1) +declare void @llvm.memcpy.p0i32.p0i32.i64(i32*, i32*, i64, i1) + +declare void @llvm.memmove.p0i8.p0i8.i8(i8*, i8*, i8, i1) +declare void @llvm.memmove.p0i8.p0i8.i64(i8*, i8*, i64, i1) +declare void @llvm.memmove.p0i32.p0i32.i64(i32*, i32*, i64, i1) + +declare void @llvm.memset.p0i8.i8(i8*, i8, i8, i1) +declare void @llvm.memset.p0i8.i64(i8*, i8, i64, i1) +declare void @llvm.memset.p0i32.i64(i32*, i8, i64, i1) + +; CHECK-LABEL: memcpy_i8: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memcpy_i8 (i64, i64, i32) -> () +; BULK-MEM-NEXT: i64.extend_i32_u $push0=, $2 +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $pop0 +; BULK-MEM-NEXT: return +define void @memcpy_i8(i8* %dest, i8* %src, i8 zeroext %len) { + call void @llvm.memcpy.p0i8.p0i8.i8(i8* %dest, i8* %src, i8 %len, i1 0) + ret void +} + +; CHECK-LABEL: memmove_i8: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memmove_i8 (i64, i64, i32) -> () +; BULK-MEM-NEXT: i64.extend_i32_u $push0=, $2 +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $pop0 +; BULK-MEM-NEXT: return +define void @memmove_i8(i8* %dest, i8* %src, i8 zeroext %len) { + call void @llvm.memmove.p0i8.p0i8.i8(i8* %dest, i8* %src, i8 %len, i1 0) + ret void +} + +; CHECK-LABEL: memset_i8: +; NO-BULK-MEM-NOT: memory.fill +; BULK-MEM-NEXT: .functype memset_i8 (i64, i32, i32) -> () +; BULK-MEM-NEXT: i64.extend_i32_u $push0=, $2 +; BULK-MEM-NEXT: memory.fill 0, $0, $1, $pop0 +; BULK-MEM-NEXT: return +define void @memset_i8(i8* %dest, i8 %val, i8 zeroext %len) { + call void @llvm.memset.p0i8.i8(i8* %dest, i8 %val, i8 %len, i1 0) + ret void +} + +; CHECK-LABEL: memcpy_i32: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memcpy_i32 (i64, i64, i64) -> () +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $2 +; BULK-MEM-NEXT: return +define void @memcpy_i32(i32* %dest, i32* %src, i64 %len) { + call void @llvm.memcpy.p0i32.p0i32.i64(i32* %dest, i32* %src, i64 %len, i1 0) + ret void +} + +; CHECK-LABEL: memmove_i32: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memmove_i32 (i64, i64, i64) -> () +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $2 +; BULK-MEM-NEXT: return +define void @memmove_i32(i32* %dest, i32* %src, i64 %len) { + call void @llvm.memmove.p0i32.p0i32.i64(i32* %dest, i32* %src, i64 %len, i1 0) + ret void +} + +; CHECK-LABEL: memset_i32: +; NO-BULK-MEM-NOT: memory.fill +; BULK-MEM-NEXT: .functype memset_i32 (i64, i32, i64) -> () +; BULK-MEM-NEXT: memory.fill 0, $0, $1, $2 +; BULK-MEM-NEXT: return +define void @memset_i32(i32* %dest, i8 %val, i64 %len) { + call void @llvm.memset.p0i32.i64(i32* %dest, i8 %val, i64 %len, i1 0) + ret void +} + +; CHECK-LABEL: memcpy_1: +; CHECK-NEXT: .functype memcpy_1 (i64, i64) -> () +; CHECK-NEXT: i32.load8_u $push[[L0:[0-9]+]]=, 0($1) +; CHECK-NEXT: i32.store8 0($0), $pop[[L0]] +; CHECK-NEXT: return +define void @memcpy_1(i8* %dest, i8* %src) { + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 1, i1 0) + ret void +} + +; CHECK-LABEL: memmove_1: +; CHECK-NEXT: .functype memmove_1 (i64, i64) -> () +; CHECK-NEXT: i32.load8_u $push[[L0:[0-9]+]]=, 0($1) +; CHECK-NEXT: i32.store8 0($0), $pop[[L0]] +; CHECK-NEXT: return +define void @memmove_1(i8* %dest, i8* %src) { + call void @llvm.memmove.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 1, i1 0) + ret void +} + +; CHECK-LABEL: memset_1: +; NO-BULK-MEM-NOT: memory.fill +; BULK-MEM-NEXT: .functype memset_1 (i64, i32) -> () +; BULK-MEM-NEXT: i32.store8 0($0), $1 +; BULK-MEM-NEXT: return +define void @memset_1(i8* %dest, i8 %val) { + call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 1, i1 0) + ret void +} + +; CHECK-LABEL: memcpy_1024: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memcpy_1024 (i64, i64) -> () +; BULK-MEM-NEXT: i64.const $push[[L0:[0-9]+]]=, 1024 +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $pop[[L0]] +; BULK-MEM-NEXT: return +define void @memcpy_1024(i8* %dest, i8* %src) { + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 1024, i1 0) + ret void +} + +; CHECK-LABEL: memmove_1024: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memmove_1024 (i64, i64) -> () +; BULK-MEM-NEXT: i64.const $push[[L0:[0-9]+]]=, 1024 +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $1, $pop[[L0]] +; BULK-MEM-NEXT: return +define void @memmove_1024(i8* %dest, i8* %src) { + call void @llvm.memmove.p0i8.p0i8.i64(i8* %dest, i8* %src, i64 1024, i1 0) + ret void +} + +; CHECK-LABEL: memset_1024: +; NO-BULK-MEM-NOT: memory.fill +; BULK-MEM-NEXT: .functype memset_1024 (i64, i32) -> () +; BULK-MEM-NEXT: i64.const $push[[L0:[0-9]+]]=, 1024 +; BULK-MEM-NEXT: memory.fill 0, $0, $1, $pop[[L0]] +; BULK-MEM-NEXT: return +define void @memset_1024(i8* %dest, i8 %val) { + call void @llvm.memset.p0i8.i64(i8* %dest, i8 %val, i64 1024, i1 0) + ret void +} + +; The following tests check that frame index elimination works for +; bulk memory instructions. The stack pointer is bumped by 112 instead +; of 100 because the stack pointer in WebAssembly is currently always +; 16-byte aligned, even in leaf functions, although it is not written +; back to the global in this case. + +; TODO: Change TransientStackAlignment to 1 to avoid this extra +; arithmetic. This will require forcing the use of StackAlignment in +; PrologEpilogEmitter.cpp when +; WebAssemblyFrameLowering::needsSPWriteback would be true. + +; CHECK-LABEL: memcpy_alloca_src: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memcpy_alloca_src (i64) -> () +; BULK-MEM-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer +; BULK-MEM-NEXT: i64.const $push[[L1:[0-9]+]]=, 112 +; BULK-MEM-NEXT: i64.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]] +; BULK-MEM-NEXT: i64.const $push[[L3:[0-9]+]]=, 12 +; BULK-MEM-NEXT: i64.add $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]] +; BULK-MEM-NEXT: i64.const $push[[L5:[0-9]+]]=, 100 +; BULK-MEM-NEXT: memory.copy 0, 0, $0, $pop[[L4]], $pop[[L5]] +; BULK-MEM-NEXT: return +define void @memcpy_alloca_src(i8* %dst) { + %a = alloca [100 x i8] + %p = bitcast [100 x i8]* %a to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %p, i64 100, i1 false) + ret void +} + +; CHECK-LABEL: memcpy_alloca_dst: +; NO-BULK-MEM-NOT: memory.copy +; BULK-MEM-NEXT: .functype memcpy_alloca_dst (i64) -> () +; BULK-MEM-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer +; BULK-MEM-NEXT: i64.const $push[[L1:[0-9]+]]=, 112 +; BULK-MEM-NEXT: i64.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]] +; BULK-MEM-NEXT: i64.const $push[[L3:[0-9]+]]=, 12 +; BULK-MEM-NEXT: i64.add $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]] +; BULK-MEM-NEXT: i64.const $push[[L5:[0-9]+]]=, 100 +; BULK-MEM-NEXT: memory.copy 0, 0, $pop[[L4]], $0, $pop[[L5]] +; BULK-MEM-NEXT: return +define void @memcpy_alloca_dst(i8* %src) { + %a = alloca [100 x i8] + %p = bitcast [100 x i8]* %a to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %p, i8* %src, i64 100, i1 false) + ret void +} + +; CHECK-LABEL: memset_alloca: +; NO-BULK-MEM-NOT: memory.fill +; BULK-MEM-NEXT: .functype memset_alloca (i32) -> () +; BULK-MEM-NEXT: global.get $push[[L0:[0-9]+]]=, __stack_pointer +; BULK-MEM-NEXT: i64.const $push[[L1:[0-9]+]]=, 112 +; BULK-MEM-NEXT: i64.sub $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]] +; BULK-MEM-NEXT: i64.const $push[[L3:[0-9]+]]=, 12 +; BULK-MEM-NEXT: i64.add $push[[L4:[0-9]+]]=, $pop[[L2]], $pop[[L3]] +; BULK-MEM-NEXT: i64.const $push[[L5:[0-9]+]]=, 100 +; BULK-MEM-NEXT: memory.fill 0, $pop[[L4]], $0, $pop[[L5]] +; BULK-MEM-NEXT: return +define void @memset_alloca(i8 %val) { + %a = alloca [100 x i8] + %p = bitcast [100 x i8]* %a to i8* + call void @llvm.memset.p0i8.i64(i8* %p, i8 %val, i64 100, i1 false) + ret void +} diff --git a/llvm/test/CodeGen/WebAssembly/memory-addr64.ll b/llvm/test/CodeGen/WebAssembly/memory-addr64.ll new file mode 100644 index 000000000000..7268d166783a --- /dev/null +++ b/llvm/test/CodeGen/WebAssembly/memory-addr64.ll @@ -0,0 +1,27 @@ +; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s + +; Test that basic memory operations assemble as expected with 64-bit addresses. + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm64-unknown-unknown" + +declare i64 @llvm.wasm.memory.size.i64(i32) nounwind readonly +declare i64 @llvm.wasm.memory.grow.i64(i32, i64) nounwind + +; CHECK-LABEL: memory_size: +; CHECK-NEXT: .functype memory_size () -> (i64){{$}} +; CHECK-NEXT: memory.size $push0=, 0{{$}} +; CHECK-NEXT: return $pop0{{$}} +define i64 @memory_size() { + %a = call i64 @llvm.wasm.memory.size.i64(i32 0) + ret i64 %a +} + +; CHECK-LABEL: memory_grow: +; CHECK-NEXT: .functype memory_grow (i64) -> (i64){{$}} +; CHECK: memory.grow $push0=, 0, $0{{$}} +; CHECK-NEXT: return $pop0{{$}} +define i64 @memory_grow(i64 %n) { + %a = call i64 @llvm.wasm.memory.grow.i64(i32 0, i64 %n) + ret i64 %a +} diff --git a/llvm/test/MC/WebAssembly/bulk-memory-encodings.s b/llvm/test/MC/WebAssembly/bulk-memory-encodings.s index d661932d2c8d..0863527c8b36 100644 --- a/llvm/test/MC/WebAssembly/bulk-memory-encodings.s +++ b/llvm/test/MC/WebAssembly/bulk-memory-encodings.s @@ -1,4 +1,5 @@ # RUN: llvm-mc -show-encoding -triple=wasm32-unknown-unknown -mattr=+bulk-memory < %s | FileCheck %s +# RUN: llvm-mc -show-encoding -triple=wasm64-unknown-unknown -mattr=+bulk-memory < %s | FileCheck %s main: .functype main () -> () From cfe-commits at lists.llvm.org Mon Jul 6 12:50:14 2020 From: cfe-commits at lists.llvm.org (Wouter van Oortmerssen via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:50:14 +0000 (UTC) Subject: [PATCH] D82821: [WebAssembly] Added 64-bit memory.grow/size/init/copy/fill In-Reply-To: References: Message-ID: <918ed8ed43290316ec9599625ba2f4e6@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG16d83c395a1f: [WebAssembly] Added 64-bit memory.grow/size/copy/fill (authored by aardappel). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D82821?vs=275785&id=275804#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82821/new/ https://reviews.llvm.org/D82821 Files: clang/include/clang/Basic/BuiltinsWebAssembly.def clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/builtins-wasm.c llvm/include/llvm/IR/IntrinsicsWebAssembly.td llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll llvm/test/CodeGen/WebAssembly/bulk-memory64.ll llvm/test/CodeGen/WebAssembly/memory-addr64.ll llvm/test/MC/WebAssembly/bulk-memory-encodings.s -------------- next part -------------- A non-text attachment was scrubbed... Name: D82821.275804.patch Type: text/x-patch Size: 22118 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:50:25 2020 From: cfe-commits at lists.llvm.org (Alex Lorenz via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:50:25 +0000 (UTC) Subject: [PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver In-Reply-To: References: Message-ID: <4ba74c416d0b282fa2bd92a10fa20621@localhost.localdomain> arphaman added a comment. Please add a test-case as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83250/new/ https://reviews.llvm.org/D83250 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:22 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_Benics_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:22 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <4102930c3aeab765765dfca63ddce7af@localhost.localdomain> steakhal added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:267 BinaryOperatorKind OK = BO->getOpcode(); - SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext()); + Expr *LHS = BO->getLHS(); + Expr *RHS = BO->getRHS(); ---------------- You should probably use const where applicable. Especially where the refs value depends on a condition operator (eg. few lines below) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:22 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:22 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <6da68308ca1ccf5aa3427de961b6ce6f@localhost.localdomain> gamesh411 marked 2 inline comments as done. gamesh411 added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:279 + // or on the RHS (eg.: 1 + it). Both cases are modeled. + bool IsItOnLHS = BO->getLHS()->getType()->isPointerType(); + Expr *&ItExpr = IsItOnLHS ? LHS : RHS; ---------------- What do you think about this detection strategy? This assumes that the Iterator being detected is a pointer (and not a used-defined type like STL iterators etc.). Would you say that this assumption holds every time because the pointer-iterators are only handled in this checkPostStmt callback and the traditional iterators in another callback? ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:282 + SVal &OffsetVal = IsItOnLHS ? RVal : LVal; + handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK), + OffsetVal); ---------------- During the development of this patch, I saw something related. At the beginning of handlePtrIncrOrDecr, there is a branch on whether the Expr (2nd argument) is a pointer. I think that branch could just be an assertion. What do you think? (or maybe I should create a patch to show what I mean?) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:22 2020 From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:22 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <1a168d902ff156f8f54d911b6be4d24f@localhost.localdomain> hans added a comment. In D83013#2132070 , @echristo wrote: > Adding Chandler and Alina here as well. > > In general, I don't think that this is such a great idea. Being able to have this sort of thing work more reliably is one of the reasons for the new pass manager. I think I'd like to see this split out into an old versus new pass manager pass to avoid the difficulty of cleaning this up after we finish migrating llvm to the new pass manager. This also seems to add some technical debt around options and other enablement which is also less than ideal. Is this compelling to add right now versus finishing work migrating llvm completely to the new pass manager and removing the old one? From speaking with Alina I think that work should be done in a short while. Given how long the new pass manager has been in progress, we definitely don't want to block on enabling it. So yes, porting this pass to the current pass manager is compelling to do right now. I also don't see why it should be a big deal. As for splitting it into separate passes, this patch technically does that, although it extracts and changes the core code a bit so it can be shared between the passes. I think that's how most passes have been adapted to work with both pass managers, no? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:22 2020 From: cfe-commits at lists.llvm.org (Kazushi Marukawa via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:22 +0000 (UTC) Subject: [PATCH] D83173: [VE] Correct stack alignment In-Reply-To: References: Message-ID: <9dc16acd156047fd51bdda8a4065e441@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGdf3bda047d5a: [VE] Correct stack alignment (authored by kaz7). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83173/new/ https://reviews.llvm.org/D83173 Files: clang/lib/Basic/Targets/VE.h clang/test/CodeGen/target-data.c llvm/lib/Target/VE/VETargetMachine.cpp Index: llvm/lib/Target/VE/VETargetMachine.cpp =================================================================== --- llvm/lib/Target/VE/VETargetMachine.cpp +++ llvm/lib/Target/VE/VETargetMachine.cpp @@ -41,8 +41,8 @@ // VE supports 32 bit and 64 bits integer on registers Ret += "-n32:64"; - // Stack alignment is 64 bits - Ret += "-S64"; + // Stack alignment is 128 bits + Ret += "-S128"; return Ret; } Index: clang/test/CodeGen/target-data.c =================================================================== --- clang/test/CodeGen/target-data.c +++ clang/test/CodeGen/target-data.c @@ -250,3 +250,7 @@ // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=BPFEB // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128" + +// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=VE +// VE: target datalayout = "e-m:e-i64:64-n32:64-S128" Index: clang/lib/Basic/Targets/VE.h =================================================================== --- clang/lib/Basic/Targets/VE.h +++ clang/lib/Basic/Targets/VE.h @@ -45,7 +45,7 @@ WCharType = UnsignedInt; WIntType = UnsignedInt; UseZeroLengthBitfieldAlignment = true; - resetDataLayout("e-m:e-i64:64-n32:64-S64"); + resetDataLayout("e-m:e-i64:64-n32:64-S128"); } void getTargetDefines(const LangOptions &Opts, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83173.275598.patch Type: text/x-patch Size: 1396 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:26 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:26 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <1bd10dc78886d846a44e6c51ceaf7578@localhost.localdomain> gamesh411 updated this revision to Diff 275605. gamesh411 added a comment. Herald added subscribers: ASDenysPetrov, martong. change license Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp clang/test/Analysis/sufficient-size-array-indexing-32bit.c clang/test/Analysis/sufficient-size-array-indexing-64bit.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D69318.275605.patch Type: text/x-patch Size: 24658 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:26 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:26 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: kadircet added a comment. thanks for doing this ! ================ Comment at: clang-tools-extra/clangd/Hover.cpp:665 if (auto *RD = llvm::dyn_cast(&ND)) { if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl())) HI.Size = Size->getQuantity(); ---------------- i think we should bail out for invalid decls in here too. it won't crash but will provide spurious results. so i think an early exit for `ND.isInvalidDecl()` at the beginning of the function would be nice. ================ Comment at: clang-tools-extra/clangd/Hover.cpp:677 HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) HI.Offset = Ctx.getFieldOffset(FD) / 8; + } ---------------- could you move this out of the if statement. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:27 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:27 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: vsavchenko updated this revision to Diff 275608. vsavchenko added a comment. Fix review remarks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 Files: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp clang/test/Analysis/equality_tracking.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D82445.275608.patch Type: text/x-patch Size: 43341 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:28 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:28 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <8cfd1e525ffcfdbd24ba61de6225b183@localhost.localdomain> gamesh411 updated this revision to Diff 275611. gamesh411 added a comment. move to core.alpha Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp clang/test/Analysis/sufficient-size-array-indexing-32bit.c clang/test/Analysis/sufficient-size-array-indexing-64bit.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D69318.275611.patch Type: text/x-patch Size: 24754 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:27 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:27 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: <96a521e4ac839ea43323ed791b4ae9de@localhost.localdomain> kbobyrev added inline comments. ================ Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:61 + if (IndexedProjectRoot.empty()) + return static_cast(Result); + llvm::sys::path::replace_path_prefix(Result, IndexedProjectRoot, ""); ---------------- sammccall wrote: > static_cast is a pretty surprising/uncommon way to write this conversion.... > I'd suggest either Result.str.str() or std::string(result) Okay, sure! I just thought `.str().str()` looks really weird, but `std::string` is probably a good choice. ================ Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:43 for (auto &Sym : Symbols) { - const auto ProtobufMeessage = toProtobuf(Sym); - const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings); + const auto ProtobufMessage = toProtobuf(Sym, ""); + const auto SymToProtobufAndBack = fromProtobuf( ---------------- sammccall wrote: > Is passing the empty string here actually valid? I think you probably want to pass testRoot() or some unixified equivalent Why testroot? That's what I'm stripping from URI body, the URI is `unittest:///TestTU.h`, hence I'm stripping from `/TestTU.h`, there is no `/clangd-test` there. Could you elaborate? ================ Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:45 + const auto SymToProtobufAndBack = fromProtobuf( + ProtobufMessage, &Strings, std::string(testRoot()) + '/', "unittest"); EXPECT_TRUE(SymToProtobufAndBack.hasValue()); ---------------- sammccall wrote: > this is `testPath("unittest")`, isn't it? > > I mean, forward vs backslashes are going to differ, but the current expression is going to produce `C:\test/unittest` which doesn't seem better. I don't understand: `std::string(testRoot()) + '/'` is `/clangd-test/` on unix and `testPath("unittest")` is `/clangd-test/unittest`. I understand the slashes argument, but could you please elaborate on the former? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:28 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:28 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: kbobyrev updated this revision to Diff 275613. kbobyrev marked 19 inline comments as done. kbobyrev added a comment. Store the progress so that I don't lose it. Still WIP. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.275613.patch Type: text/x-patch Size: 20540 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:28 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:28 +0000 (UTC) Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for recovery expr. Message-ID: hokein created this revision. hokein added a reviewer: sammccall. Herald added a project: clang. RecoveryExpr was always lvalue, but it is wrong if we use it to model broken function calls, function call expression has more compliated rules: - a call to a function whose return type is an lvalue reference yields an lvalue; - a call to a function whose return type is an rvalue reference yields an xvalue; - a call to a function whose return type is nonreference type yields a prvalue; This patch makes the recovery-expr align with the function call if it is modeled a broken call. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83201 Files: clang/include/clang/AST/Expr.h clang/include/clang/Sema/Sema.h clang/lib/AST/Expr.cpp clang/lib/AST/ExprClassification.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOverload.cpp clang/test/AST/ast-dump-recovery.cpp clang/test/SemaCXX/recovery-expr-type.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83201.275615.patch Type: text/x-patch Size: 8845 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:28 2020 From: cfe-commits at lists.llvm.org (Kristof Beyls via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:28 +0000 (UTC) Subject: [PATCH] D76291: [Support] Fix formatted_raw_ostream for UTF-8 In-Reply-To: References: Message-ID: <363fa3891d7d9c5a6912a394e58709f0@localhost.localdomain> kristof.beyls accepted this revision. kristof.beyls added a comment. This revision is now accepted and ready to land. LGTM, thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76291/new/ https://reviews.llvm.org/D76291 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:31 2020 From: cfe-commits at lists.llvm.org (Kristina Bessonova via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:31 +0000 (UTC) Subject: [PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v9.2.0 In-Reply-To: References: Message-ID: <893ade31e47eb782c07f5140a888fa19@localhost.localdomain> krisb added a comment. Thank you! LGTM, except some minor nits below. ================ Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:154 + SmallString<128> MultilibInclude(GCCInstallation.getInstallPath()); + llvm::sys::path::append(MultilibInclude, "include"); ---------------- I'd guard this by `if (GCCInstallation.isValid())` to avoid adding include directories with relative paths if `GCCInstallation.getInstallPath()` is empty. ================ Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:239 + Arg *SspFlag = Args.getLastArg( + options::OPT_fno_stack_protector, options::OPT_fstack_protector, + options::OPT_fstack_protector_all, options::OPT_fstack_protector_strong); ---------------- Is the check for `fno-stack-protector` necessary here? Looks as the checks for 'positive' options should be enough to do the trick. ================ Comment at: clang/test/Driver/msp430-toolchain.c:5 + +// Test for include paths (cannot use -###) + ---------------- This way looks okay to me, but I believe you should be able to check cc1 command (though -###) for `-internal-isystem`, right? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81676/new/ https://reviews.llvm.org/D81676 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:32 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:32 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <826e2b11895493c3a94579729ebe54ab@localhost.localdomain> gamesh411 updated this revision to Diff 275625. gamesh411 added a comment. make single bug-type fix checker registration Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp clang/test/Analysis/sufficient-size-array-indexing-32bit.c clang/test/Analysis/sufficient-size-array-indexing-64bit.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D69318.275625.patch Type: text/x-patch Size: 23096 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:32 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:32 +0000 (UTC) Subject: [PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer In-Reply-To: References: Message-ID: <8a0a8d71c8404a183979b638024f27c2@localhost.localdomain> kadircet updated this revision to Diff 275627. kadircet added a comment. - Add unittest to DiagnosticsTest via llvm-include-order Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83178/new/ https://reviews.llvm.org/D83178 Files: clang-tools-extra/clangd/ParsedAST.cpp clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp +++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp @@ -29,6 +29,8 @@ namespace { using ::testing::_; +using ::testing::AllOf; +using ::testing::Contains; using ::testing::ElementsAre; using ::testing::Field; using ::testing::IsEmpty; @@ -278,6 +280,23 @@ "use a trailing return type for this function"))))); } +TEST(DiagnosticsTest, ClangTidyEOF) { + // clang-format off + Annotations Test(R"cpp( + [[#]]include + #include "a.h")cpp"); + // clang-format on + auto TU = TestTU::withCode(Test.code()); + TU.ExtraArgs = {"-isystem."}; + TU.AdditionalFiles["a.h"] = TU.AdditionalFiles["b.h"] = ""; + TU.ClangTidyChecks = "-*, llvm-include-order"; + EXPECT_THAT( + TU.build().getDiagnostics(), + Contains(AllOf(Diag(Test.range(), "#includes are not sorted properly"), + DiagSource(Diag::ClangTidy), + DiagName("llvm-include-order")))); +} + TEST(DiagnosticTest, TemplatesInHeaders) { // Diagnostics from templates defined in headers are placed at the expansion. Annotations Main(R"cpp( Index: clang-tools-extra/clangd/ParsedAST.cpp =================================================================== --- clang-tools-extra/clangd/ParsedAST.cpp +++ clang-tools-extra/clangd/ParsedAST.cpp @@ -428,15 +428,15 @@ CTFinder.matchAST(Clang->getASTContext()); } + // XXX: This is messy: clang-tidy checks flush some diagnostics at EOF. + // However Action->EndSourceFile() would destroy the ASTContext! + // So just inform the preprocessor of EOF, while keeping everything alive. + Clang->getPreprocessor().EndSourceFile(); // UnitDiagsConsumer is local, we can not store it in CompilerInstance that // has a longer lifetime. Clang->getDiagnostics().setClient(new IgnoreDiagnostics); // CompilerInstance won't run this callback, do it directly. ASTDiags.EndSourceFile(); - // XXX: This is messy: clang-tidy checks flush some diagnostics at EOF. - // However Action->EndSourceFile() would destroy the ASTContext! - // So just inform the preprocessor of EOF, while keeping everything alive. - Clang->getPreprocessor().EndSourceFile(); std::vector Diags = CompilerInvocationDiags; // Add diagnostics from the preamble, if any. -------------- next part -------------- A non-text attachment was scrubbed... Name: D83178.275627.patch Type: text/x-patch Size: 2459 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:33 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:33 +0000 (UTC) Subject: [PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer In-Reply-To: References: Message-ID: <235526090744aa32f5c1c9a5b2936314@localhost.localdomain> kadircet added a comment. Yeah concerns around header-guard checks are real (and likely to be annoying), so will wait for D78038 . I suppose we can split that into multiple patches, and at least land the bit around preserving conditional stack at the end of preamble, WDYT? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83178/new/ https://reviews.llvm.org/D83178 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:35 2020 From: cfe-commits at lists.llvm.org (MyDeveloperDay via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:35 +0000 (UTC) Subject: [PATCH] D79773: [clang-format] Improve clang-formats handling of concepts In-Reply-To: References: Message-ID: <31f144dc6a6fe5ce9e6ffa51e844d587@localhost.localdomain> MyDeveloperDay added a comment. Thank you @JohelEGP please keep them coming, I'll try and update the patch as soon as I have some fixes, I kind of feel like we are addressing what would have just been downstream bugs anyway. (some are quite bizarre!) so lets squish as many of them as we can before we land this. My assumption is you are giving me valid c++ code, if so that is great I'll try and address them, but your examples are probably beyond my own concepts knowledge. (This is actually why I started to add this to clang-format, I wanted a way to learn about concepts) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79773/new/ https://reviews.llvm.org/D79773 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:35 2020 From: cfe-commits at lists.llvm.org (Dmitry Polukhin via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:35 +0000 (UTC) Subject: [PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization In-Reply-To: References: Message-ID: <443d16fe00f9a4eac3a789d70d9f70b2@localhost.localdomain> DmitryPolukhin added a comment. @njames93 and @aaron.ballman - please take a look to this diff. Multiline replacements in YAML are broken and cannot be applied correctly. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80301/new/ https://reviews.llvm.org/D80301 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:37 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:37 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM Message-ID: LukeGeeson created this revision. LukeGeeson added a reviewer: t.p.northover. Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, kristof.beyls. Herald added projects: clang, LLVM. This patch adds support for the Arm-v8 Cortex-A78 and Cortex-X1 processors for AArch64 and ARM. In detail: - Adding cortex-a78 and cortex-x1 as cpu options for aarch64 and arm targets in clang - Adding Cortex-A78 and Cortex-X1 CPU names and ProcessorModels in llvm details of the CPU can be found here: https://www.arm.com/products/cortex-x https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78 The following people contributed to this patch: - Luke Geeson - Mikhail Maltsev Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.275633.patch Type: text/x-patch Size: 14081 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:38 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Lubo=C5=A1_Lu=C5=88=C3=A1k_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:38 +0000 (UTC) Subject: [PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work also with precompiled headers In-Reply-To: References: Message-ID: <4c13fb51a0669ea281d69338134a02a5@localhost.localdomain> llunak added a comment. Ping ... Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69778/new/ https://reviews.llvm.org/D69778 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:38 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:38 +0000 (UTC) Subject: [PATCH] D83157: [clangd] Extract BackgroundIndex::Options struct. NFC In-Reply-To: References: Message-ID: kadircet marked an inline comment as done. kadircet added inline comments. ================ Comment at: clang-tools-extra/clangd/ClangdServer.cpp:184 + TFS, CDB, BackgroundIndexStorage::createDiskBackedStorageFactory( [&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }), ---------------- sammccall wrote: > kadircet wrote: > > I think we should move storage factory into options too ? > The storage factory isn't optional, nor does it have a good default. So it seems mechanically awkward to put it in the struct, and I'm not sure there's much benefit... > > How would you see this being initialized? I thought we were exposing `NullStorage` so I was planning for it to be the default for ignorant call sites. But seeing it is not exposed, and this only being used by ClangdServer (and tests), I suppose it is not that important. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83157/new/ https://reviews.llvm.org/D83157 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:38 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:38 +0000 (UTC) Subject: [PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences In-Reply-To: References: Message-ID: <455066780058bbd80ee1168310e56d22@localhost.localdomain> Szelethus accepted this revision. Szelethus added a comment. This revision is now accepted and ready to land. LGTM! You packed a lot of punch into this patch, and I like it very much. I read the code and everything looks great. I nitpicked on one thing, the `updateTrackedRegion` function is a bit awkward, but if you place a `TODO` there, I'm happy to have that addressed in a later patch. I don't think this is reason to postpone the landing on this patch any further. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:202-219 +ProgramStateRef +SmartPtrModeling::updateTrackedRegion(const CallEvent &Call, CheckerContext &C, + const MemRegion *ThisValRegion) const { + ProgramStateRef State = C.getState(); + auto NumArgs = Call.getNumArgs(); + + if (NumArgs == 0) { ---------------- Hmm, this function feels clunky. So, if the call has no arguments, we set the smart pointer to null, otherwise if its a single-argument then we set it to whatever the argument is? How about `operator[]`, that also takes a single argument, but isn't a memory region? `get`, `get_deleter` don't take any arguments, but they don't set the internal pointee to null either. The name `updateTrackedRegion` however suggests that whatever operation was done, this is the one-tool-to-solve-it-all function to take care of it. I think this function handles too many things as once, and the name and lack of documentation obfuscates its purpose. How about we put the relevant code to `handleRelease`, and repurpose the rest of the function like this: `updateOwnedRegion(CallEvent, CheckerContext, MemRegion of the smart pointer, MemRegion to take ownership of)` What do you think? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81315/new/ https://reviews.llvm.org/D81315 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:39 2020 From: cfe-commits at lists.llvm.org (Kerry McLaughlin via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:39 +0000 (UTC) Subject: [PATCH] D82943: [SVE] Add more warnings checks to clang and LLVM SVE tests In-Reply-To: References: Message-ID: <901dd0d50031b96c16d7e213f0a20df9@localhost.localdomain> kmclaughlin accepted this revision. kmclaughlin added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82943/new/ https://reviews.llvm.org/D82943 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:39 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:39 +0000 (UTC) Subject: [PATCH] D83099: Revert "[clangd] Store index in '.clangd/index' instead of '.clangd-index'" In-Reply-To: References: Message-ID: <3acd294d313ab3a6d841c6345e8ff7b0@localhost.localdomain> sammccall updated this revision to Diff 275643. sammccall added a comment. Slightly different layout after getting input on discourse and elsewhere Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 Files: .gitignore clang-tools-extra/clangd/index/Background.h clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp clang-tools-extra/clangd/test/background-index.test llvm/.gitignore Index: llvm/.gitignore =================================================================== --- llvm/.gitignore +++ llvm/.gitignore @@ -59,8 +59,6 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd #==============================================================================# # Files created in tree by the Go bindings. Index: clang-tools-extra/clangd/test/background-index.test =================================================================== --- clang-tools-extra/clangd/test/background-index.test +++ clang-tools-extra/clangd/test/background-index.test @@ -15,8 +15,8 @@ # RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD # Test that the index is writing files in the expected location. -# RUN: ls %t/.clangd/index/foo.cpp.*.idx -# RUN: ls %t/sub_dir/.clangd/index/foo.h.*.idx +# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx +# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx # Test the index is read from disk: delete code and restart clangd. # RUN: rm %t/foo.cpp Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp =================================================================== --- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp +++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp @@ -95,8 +95,8 @@ }; // Creates and owns IndexStorages for multiple CDBs. -// When a CDB root is found, shards are stored in $ROOT/.clangd/index. -// When no root is found, the fallback path is ~/.cache/clangd/index. +// When a CDB root is found, shards are stored in $ROOT/.cache/clangd/index/. +// When no root is found, the fallback path is ~/.cache/clangd/index/. class DiskBackedIndexStorageManager { public: DiskBackedIndexStorageManager( @@ -115,7 +115,7 @@ llvm::SmallString<128> StorageDir(FallbackDir); if (auto PI = GetProjectInfo(File)) { StorageDir = PI->SourceRoot; - llvm::sys::path::append(StorageDir, ".clangd", "index"); + llvm::sys::path::append(StorageDir, ".cache", "clangd", "index"); } auto &IndexStorage = IndexStorageMap[StorageDir]; if (!IndexStorage) Index: clang-tools-extra/clangd/index/Background.h =================================================================== --- clang-tools-extra/clangd/index/Background.h +++ clang-tools-extra/clangd/index/Background.h @@ -56,9 +56,9 @@ using Factory = llvm::unique_function; // Creates an Index Storage that saves shards into disk. Index storage uses - // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory - // is the first directory containing a CDB in parent directories of a file, or - // user's home directory if none was found, e.g. standard library headers. + // CDBDirectory + ".cache/clangd/index/" as the folder to save shards. + // CDBDirectory is the first directory containing a CDB in parent directories + // of a file, or user's home directory if none was found, e.g. stdlib headers. static Factory createDiskBackedStorageFactory( std::function(PathRef)> GetProjectInfo); }; Index: .gitignore =================================================================== --- .gitignore +++ .gitignore @@ -53,10 +53,11 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd +# clangd index. (".clangd" is a config file now, thus trailing slash) +.clangd/ +.cache # static analyzer regression testing project files /clang/utils/analyzer/projects/*/CachedSource /clang/utils/analyzer/projects/*/PatchedSource /clang/utils/analyzer/projects/*/ScanBuildResults -/clang/utils/analyzer/projects/*/RefScanBuildResults \ No newline at end of file +/clang/utils/analyzer/projects/*/RefScanBuildResults -------------- next part -------------- A non-text attachment was scrubbed... Name: D83099.275643.patch Type: text/x-patch Size: 3810 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:40 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:40 +0000 (UTC) Subject: [PATCH] D83209: Factor out call to EXTRACTOR in generateCC1CommandLine Message-ID: dang created this revision. dang added a reviewer: Bigcheese. Herald added subscribers: llvm-commits, cfe-commits, dexonsmith. Herald added projects: clang, LLVM. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83209 Files: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/Option/OptParser.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D83209.275646.patch Type: text/x-patch Size: 8323 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:40 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:40 +0000 (UTC) Subject: [PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' In-Reply-To: References: Message-ID: <7a779ee224c6b80b70177e82e1221715@localhost.localdomain> sammccall updated this revision to Diff 275645. sammccall retitled this revision from "Revert "[clangd] Store index in '.clangd/index' instead of '.clangd-index'"" to "[clangd] Store index in '.cache/clangd/index' instead of '.clangd/index'". sammccall edited the summary of this revision. sammccall added a comment. Updating description Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 Files: .gitignore clang-tools-extra/clangd/index/Background.h clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp clang-tools-extra/clangd/test/background-index.test llvm/.gitignore Index: llvm/.gitignore =================================================================== --- llvm/.gitignore +++ llvm/.gitignore @@ -59,8 +59,6 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd #==============================================================================# # Files created in tree by the Go bindings. Index: clang-tools-extra/clangd/test/background-index.test =================================================================== --- clang-tools-extra/clangd/test/background-index.test +++ clang-tools-extra/clangd/test/background-index.test @@ -15,8 +15,8 @@ # RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD # Test that the index is writing files in the expected location. -# RUN: ls %t/.clangd/index/foo.cpp.*.idx -# RUN: ls %t/sub_dir/.clangd/index/foo.h.*.idx +# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx +# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx # Test the index is read from disk: delete code and restart clangd. # RUN: rm %t/foo.cpp Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp =================================================================== --- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp +++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp @@ -95,8 +95,8 @@ }; // Creates and owns IndexStorages for multiple CDBs. -// When a CDB root is found, shards are stored in $ROOT/.clangd/index. -// When no root is found, the fallback path is ~/.cache/clangd/index. +// When a CDB root is found, shards are stored in $ROOT/.cache/clangd/index/. +// When no root is found, the fallback path is ~/.cache/clangd/index/. class DiskBackedIndexStorageManager { public: DiskBackedIndexStorageManager( @@ -115,7 +115,7 @@ llvm::SmallString<128> StorageDir(FallbackDir); if (auto PI = GetProjectInfo(File)) { StorageDir = PI->SourceRoot; - llvm::sys::path::append(StorageDir, ".clangd", "index"); + llvm::sys::path::append(StorageDir, ".cache", "clangd", "index"); } auto &IndexStorage = IndexStorageMap[StorageDir]; if (!IndexStorage) Index: clang-tools-extra/clangd/index/Background.h =================================================================== --- clang-tools-extra/clangd/index/Background.h +++ clang-tools-extra/clangd/index/Background.h @@ -56,9 +56,9 @@ using Factory = llvm::unique_function; // Creates an Index Storage that saves shards into disk. Index storage uses - // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory - // is the first directory containing a CDB in parent directories of a file, or - // user's home directory if none was found, e.g. standard library headers. + // CDBDirectory + ".cache/clangd/index/" as the folder to save shards. + // CDBDirectory is the first directory containing a CDB in parent directories + // of a file, or user's home directory if none was found, e.g. stdlib headers. static Factory createDiskBackedStorageFactory( std::function(PathRef)> GetProjectInfo); }; Index: .gitignore =================================================================== --- .gitignore +++ .gitignore @@ -53,10 +53,11 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd +# clangd index. (".clangd" is a config file now, thus trailing slash) +.clangd/ +.cache # static analyzer regression testing project files /clang/utils/analyzer/projects/*/CachedSource /clang/utils/analyzer/projects/*/PatchedSource /clang/utils/analyzer/projects/*/ScanBuildResults -/clang/utils/analyzer/projects/*/RefScanBuildResults \ No newline at end of file +/clang/utils/analyzer/projects/*/RefScanBuildResults -------------- next part -------------- A non-text attachment was scrubbed... Name: D83099.275645.patch Type: text/x-patch Size: 3810 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:42 2020 From: cfe-commits at lists.llvm.org (Mikhail Maltsev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:42 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <0bb2cccc86a8348e7c373f67c7c751c9@localhost.localdomain> miyuki added inline comments. ================ Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.h:72 + ThunderX3T110, + CortexX1, + CortexA78 ---------------- I think the new CPUs should be grouped with other Cortex-A CPUs. ================ Comment at: llvm/lib/Target/ARM/ARMSubtarget.h:78 + Swift, + CortexX1, + CortexA78 ---------------- Please keep the list sorted in alphabetical order. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:44 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:44 +0000 (UTC) Subject: [PATCH] D81761: [analyzer] Force dependency checkers to be hidden In-Reply-To: References: Message-ID: <11b7ab0480a83af9644d3d91778bd566@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG690ff37a2869: [analyzer] Force dependency checkers to be hidden (authored by Szelethus). Changed prior to commit: https://reviews.llvm.org/D81761?vs=274466&id=275651#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81761/new/ https://reviews.llvm.org/D81761 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D81761.275651.patch Type: text/x-patch Size: 22892 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:44 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:44 +0000 (UTC) Subject: [PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine Message-ID: dang created this revision. dang added a reviewer: Bigcheese. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83211 Files: clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -3927,9 +3927,10 @@ PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, \ TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX) \ - if (((FLAGS)&options::CC1Option) && \ - (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) { \ - DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH)); \ + if ((FLAGS)&options::CC1Option) { \ + const auto &Extracted = EXTRACTOR(this->KEYPATH); \ + if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) \ + DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted); \ } #include "clang/Driver/Options.inc" -------------- next part -------------- A non-text attachment was scrubbed... Name: D83211.275655.patch Type: text/x-patch Size: 1096 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:45 2020 From: cfe-commits at lists.llvm.org (=?utf-8?b?QmFsb2doLCDDgWTDoW0gdmlhIFBoYWJyaWNhdG9y?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:45 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <1a9ae3629fdc34df0b37775172428a77@localhost.localdomain> baloghadamsoftware added a comment. Nice work, but please implement this feature also for non-pointer iterators for the matter of consistence. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:279 + // or on the RHS (eg.: 1 + it). Both cases are modeled. + bool IsItOnLHS = BO->getLHS()->getType()->isPointerType(); + Expr *&ItExpr = IsItOnLHS ? LHS : RHS; ---------------- gamesh411 wrote: > What do you think about this detection strategy? This assumes that the Iterator being detected is a pointer (and not a used-defined type like STL iterators etc.). Would you say that this assumption holds every time because the pointer-iterators are only handled in this checkPostStmt callback and the traditional iterators in another callback? Instead of `It` please use `Iter`, beacause `It` can be understood as the English //it// pronoun: "Is //it// on the left-hand side?" ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:282 + SVal &OffsetVal = IsItOnLHS ? RVal : LVal; + handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK), + OffsetVal); ---------------- gamesh411 wrote: > During the development of this patch, I saw something related. At the beginning of handlePtrIncrOrDecr, there is a branch on whether the Expr (2nd argument) is a pointer. I think that branch could just be an assertion. What do you think? (or maybe I should create a patch to show what I mean?) I wonder whether this should be implemented here in `checkPostStmt()` ot in `handlePtrIncrOrDecr()`. Your current implementation is in `checkPostStmt()`, in this case we can assert in `handlePtrIncrOrDecl()`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:45 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:45 +0000 (UTC) Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations. In-Reply-To: References: Message-ID: <3f34e4147c7719c64c470fafe6c6a7d0@localhost.localdomain> ebevhan updated this revision to Diff 275657. ebevhan added a comment. Rebased. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82663/new/ https://reviews.llvm.org/D82663 Files: clang/include/clang/Basic/FixedPoint.h clang/lib/Basic/FixedPoint.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/test/Frontend/fixed_point_add.c clang/test/Frontend/fixed_point_comparisons.c clang/test/Frontend/fixed_point_compound.c clang/test/Frontend/fixed_point_div.c clang/test/Frontend/fixed_point_mul.c clang/test/Frontend/fixed_point_sub.c clang/test/Frontend/fixed_point_unary.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D82663.275657.patch Type: text/x-patch Size: 44683 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:46 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:46 +0000 (UTC) Subject: [PATCH] D83212: [Fixed Point] Add fixed-point shift operations and consteval. Message-ID: ebevhan created this revision. ebevhan added reviewers: rjmccall, leonardchan, bjope. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83212 Files: clang/include/clang/Basic/FixedPoint.h clang/lib/AST/ExprConstant.cpp clang/lib/Basic/FixedPoint.cpp clang/lib/Sema/SemaExpr.cpp clang/test/Frontend/fixed_point_errors.c clang/test/Frontend/fixed_point_shift.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83212.275660.patch Type: text/x-patch Size: 11147 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:46 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:46 +0000 (UTC) Subject: [PATCH] D82442: [Coroutines] Warning if the return type of coroutine_handle::address is not void* In-Reply-To: References: Message-ID: riccibruno added inline comments. ================ Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10531 +def warn_coroutine_handle_address_invalid_return_type : Warning < + "return type of 'coroutine_handle<>::address should be 'void*' (have %0) in order to get capability with existing async C API.">, + InGroup; ---------------- Should this be something like `[...] for compatibility with existing async C APIs` instead? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82442/new/ https://reviews.llvm.org/D82442 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:46 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:46 +0000 (UTC) Subject: [PATCH] D82921: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods In-Reply-To: References: Message-ID: <787828159b9074cb13f0e0d8b05f768f@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG5689b38c6a42: Removed a RecursiveASTVisitor feature to visit operator kinds with different… (authored by gribozavr). Changed prior to commit: https://reviews.llvm.org/D82921?vs=275064&id=275663#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82921/new/ https://reviews.llvm.org/D82921 Files: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h clang/docs/ReleaseNotes.rst clang/include/clang/AST/RecursiveASTVisitor.h clang/lib/ARCMigrate/TransProperties.cpp clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82921.275663.patch Type: text/x-patch Size: 50175 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:47 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:47 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: <5f506bf554a070821c30c3c0e431f565@localhost.localdomain> hokein updated this revision to Diff 275664. hokein marked 2 inline comments as done. hokein added a comment. address comment. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -784,11 +784,24 @@ HI.NamespaceScope = ""; HI.Definition = "int xx"; HI.LocalScope = "Foo::"; - HI.Size = 4; HI.Type = "int"; HI.AccessSpecifier = "public"; }}, - }; + {R"cpp( + // error-ok + struct Foo { + Bar xx; + int [[y^y]]; + };)cpp", + [](HoverInfo &HI) { + HI.Name = "yy"; + HI.Kind = index::SymbolKind::Field; + HI.NamespaceScope = ""; + HI.Definition = "int yy"; + HI.LocalScope = "Foo::"; + HI.Type = "int"; + HI.AccessSpecifier = "public"; + }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -659,8 +659,10 @@ } void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) { - const auto &Ctx = ND.getASTContext(); + if (ND.isInvalidDecl()) + return; + const auto &Ctx = ND.getASTContext(); if (auto *RD = llvm::dyn_cast(&ND)) { if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl())) HI.Size = Size->getQuantity(); @@ -671,11 +673,11 @@ const auto *Record = FD->getParent(); if (Record) Record = Record->getDefinition(); - if (Record && !Record->isDependentType()) { - if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) + if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) { + if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) { HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) HI.Offset = Ctx.getFieldOffset(FD) / 8; + } } return; } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83189.275664.patch Type: text/x-patch Size: 2048 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:47 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:47 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: <2e19c2017cdf3e2346e20c4c4e1b1167@localhost.localdomain> hokein added inline comments. ================ Comment at: clang-tools-extra/clangd/Hover.cpp:677 HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) HI.Offset = Ctx.getFieldOffset(FD) / 8; + } ---------------- kadircet wrote: > could you move this out of the if statement. I'm not sure whether Size and Offset should be be independent, IIUC your fix seems to change it as a side effect, this just preserves the old behavior. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:48 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:48 +0000 (UTC) Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit. Message-ID: hokein created this revision. hokein added a reviewer: sammccall. Herald added a project: clang. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83213 Files: clang/lib/AST/ComputeDependence.cpp clang/lib/AST/Expr.cpp Index: clang/lib/AST/Expr.cpp =================================================================== --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -3397,7 +3397,7 @@ if (!IncludePossibleEffects && getExprLoc().isMacroID()) return false; - if (isInstantiationDependent()) + if (isInstantiationDependent() || containsErrors()) return IncludePossibleEffects; switch (getStmtClass()) { Index: clang/lib/AST/ComputeDependence.cpp =================================================================== --- clang/lib/AST/ComputeDependence.cpp +++ clang/lib/AST/ComputeDependence.cpp @@ -501,7 +501,7 @@ // FIXME: drop type+value+instantiation once Error is sufficient to suppress // bogus dianostics. auto D = toExprDependence(E->getType()->getDependence()) | - ExprDependence::ValueInstantiation | ExprDependence::Error; + ExprDependence::Value | ExprDependence::Error; for (auto *S : E->subExpressions()) D |= S->getDependence(); return D; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83213.275671.patch Type: text/x-patch Size: 1002 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:48 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:48 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: kbobyrev updated this revision to Diff 275667. kbobyrev marked 12 inline comments as done. kbobyrev added a comment. Resolve the rest of patch comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.275667.patch Type: text/x-patch Size: 26095 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:48 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:48 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: kbobyrev updated this revision to Diff 275670. kbobyrev added a comment. Remove IndexRoot conversion to UNIX slashes from the Marshalling hot path. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.275670.patch Type: text/x-patch Size: 26029 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:48 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:48 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: <063bd89073266335062d2df1cc4fc4a6@localhost.localdomain> kbobyrev updated this revision to Diff 275672. kbobyrev added a comment. Use std::string() instead of static_cast() Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.275672.patch Type: text/x-patch Size: 26016 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:48 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:48 +0000 (UTC) Subject: [PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of RecoveryExpr. Message-ID: hokein created this revision. hokein added a reviewer: sammccall. Herald added a project: clang. Fix some out-of-date doc/FIXMEs, and be clear about our plan. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83215 Files: clang/include/clang/AST/Expr.h clang/lib/AST/ComputeDependence.cpp clang/lib/Sema/SemaExpr.cpp Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -19211,9 +19211,6 @@ ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef SubExprs, QualType T, ExprValueKind VK) { - // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress - // bogus diagnostics and this trick does not work in C. - // FIXME: use containsErrors() to suppress unwanted diags in C. if (!Context.getLangOpts().RecoveryAST) return ExprError(); Index: clang/lib/AST/ComputeDependence.cpp =================================================================== --- clang/lib/AST/ComputeDependence.cpp +++ clang/lib/AST/ComputeDependence.cpp @@ -495,11 +495,19 @@ } ExprDependence clang::computeDependence(RecoveryExpr *E) { - // Mark the expression as value- and instantiation- dependent to reuse - // existing suppressions for dependent code, e.g. avoiding - // constant-evaluation. - // FIXME: drop type+value+instantiation once Error is sufficient to suppress - // bogus dianostics. + // RecoveryExpr dependence-bits setting: + // - type-dep is set if we don't know about the type (fallback to an opaque + // dependent type); + // - value-dep is always set to avoid constant-evaluation; + // - instantiation-dep bit is not set to disinguish with regular template + // dependent expressions; + // + // Explanations: + // - "type-dependent" + "contains-errors": depends on an error and we don't + // know the type + // - "contains-errors": depends on an error and we know the type + // - "type-depdendent" + "instantiation-dependent": a regular dependent + // expression which involves template parameters (not a recovery expr) auto D = toExprDependence(E->getType()->getDependence()) | ExprDependence::Value | ExprDependence::Error; for (auto *S : E->subExpressions()) Index: clang/include/clang/AST/Expr.h =================================================================== --- clang/include/clang/AST/Expr.h +++ clang/include/clang/AST/Expr.h @@ -6212,19 +6212,22 @@ /// subexpressions of some expression that we could not construct and source /// range covered by the expression. /// -/// By default, RecoveryExpr is type-, value- and instantiation-dependent to -/// take advantage of existing machinery to deal with dependent code in C++, -/// e.g. RecoveryExpr is preserved in `decltype()` as part of the -/// `DependentDecltypeType`. In addition to that, clang does not report most -/// errors on dependent expressions, so we get rid of bogus errors for free. -/// However, note that unlike other dependent expressions, RecoveryExpr can be -/// produced in non-template contexts. +/// By default, RecoveryExpr uses dependence-bits to take advantage of existing +/// machinery to deal with dependent code in C++, e.g. RecoveryExpr is preserved +/// in `decltype()` as part of the `DependentDecltypeType`. In +/// addition to that, clang does not report most errors on dependent +/// expressions, so we get rid of bogus errors for free. However, note that +/// unlike other dependent expressions, RecoveryExpr can be produced in +/// non-template contexts. /// In addition, we will preserve the type in RecoveryExpr when the type is /// known, e.g. preserving the return type for a broken non-overloaded function /// call, a overloaded call where all candidates have the same return type. /// /// One can also reliably suppress all bogus errors on expressions containing /// recovery expressions by examining results of Expr::containsErrors(). +/// +/// FIXME: RecoveryExpr is C++ only, make it work for C by supporting dependence +/// mechanism for C language in clang. class RecoveryExpr final : public Expr, private llvm::TrailingObjects { public: -------------- next part -------------- A non-text attachment was scrubbed... Name: D83215.275673.patch Type: text/x-patch Size: 4036 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:50 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:50 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <350975bc706b6fe7435c375006821d39@localhost.localdomain> gamesh411 updated this revision to Diff 275678. gamesh411 added a comment. modernize the memory modeling code, still WIP Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp clang/test/Analysis/sufficient-size-array-indexing-32bit.c clang/test/Analysis/sufficient-size-array-indexing-64bit.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D69318.275678.patch Type: text/x-patch Size: 21996 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:52 2020 From: cfe-commits at lists.llvm.org (Manuel Klimek via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:52 +0000 (UTC) Subject: [PATCH] D83218: Hand Allocator and IdentifierTable into FormatTokenLexer. Message-ID: klimek created this revision. klimek added a reviewer: sammccall. Herald added a project: clang. Herald added a subscriber: cfe-commits. This allows us to share the allocator in the future so we can create tokens while parsing. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83218 Files: clang/lib/Format/FormatTokenLexer.cpp clang/lib/Format/FormatTokenLexer.h clang/lib/Format/TokenAnalyzer.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83218.275686.patch Type: text/x-patch Size: 4837 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:52 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:52 +0000 (UTC) Subject: [PATCH] D80858: [HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: <753fc2c7fdad2d48849140170d186231@localhost.localdomain> yaxunl marked 10 inline comments as done. yaxunl added inline comments. ================ Comment at: clang/include/clang/Driver/Action.h:216 const llvm::opt::Arg &Input; - + unsigned Id; virtual void anchor(); ---------------- rjmccall wrote: > Allowing an arbitrary string might be more adaptable. done ================ Comment at: clang/lib/AST/ASTContext.cpp:10064 return GVA_StrongODR; + // Externalize device side static file-scope variable for HIP. + if (Context.getLangOpts().HIP && Context.getLangOpts().HIPCUID && ---------------- rjmccall wrote: > This needs to be a clearer statement of why this is necessary. added comments to explain why ================ Comment at: clang/lib/AST/ASTContext.cpp:10068 + isa(D) && cast(D)->isFileVarDecl() && + cast(D)->getStorageClass() == SC_Static) { + return GVA_StrongExternal; ---------------- rjmccall wrote: > Are you sure this doesn't apply to e.g. local statics? Can't you have kernel lambdas, or am I confusing HIP with another language? function-scope static var in a device function is only visible to the device function. Host code cannot access it, therefore no need to externalize it. ================ Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1094 + if ((VD->hasAttr() || VD->hasAttr()) && + VD->isFileVarDecl() && VD->getStorageClass() == SC_Static) { + Out << ".hip.static." << CGM.getLangOpts().HIPCUID; ---------------- rjmccall wrote: > Please extract this "(device || constant) && file && static" predicate instead of repeating it in three different places. extracted as ASTContext::shouldExternalizeStaticVar ================ Comment at: clang/lib/Driver/Action.cpp:170 + if (!Id) + Id = llvm::sys::Process::GetRandomNumber(); +} ---------------- rjmccall wrote: > I'm sure GetRandomNumber can return 0, so this logic is faulty. > > This also seems like an unfortunate intrusion of HIP-specific semantics on the rest of the driver. Maybe HIP can generate the shared id when it's setting up and cloning the job. Changed type of ID to string. Now empty ID means disabled. 0 is now allowed as a usual ID. Moved initialization of ID to HIP action builder. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:52 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:52 +0000 (UTC) Subject: [PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer In-Reply-To: References: Message-ID: njames93 added a comment. In D83178#2132490 , @kadircet wrote: > Yeah concerns around header-guard checks are real (and likely to be annoying), so will wait for D78038 . > > I suppose we can split that into multiple patches, and at least land the bit around preserving conditional stack at the end of preamble, WDYT? If there are issues with D78038 then I'd say this could be landed so long as header-guard (and other) checks were manually disabled til that can be sorted. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83178/new/ https://reviews.llvm.org/D83178 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:53 2020 From: cfe-commits at lists.llvm.org (Erich Keane via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:53 +0000 (UTC) Subject: [PATCH] D83114: [clang] Fix the incorrect dependence bits for DependentExtIntType. In-Reply-To: References: Message-ID: erichkeane accepted this revision. erichkeane added inline comments. ================ Comment at: clang/lib/AST/Type.cpp:356 - : TypeDependence::None) | - (NumBitsExpr->containsUnexpandedParameterPack() - ? TypeDependence::VariablyModified ---------------- sammccall wrote: > @erichkeane was there any intent behind translating "num bits contains unexpanded pack" into "extint is variably modified", or was this an oversight? (My guess is the latter, just want to double check) Ah, I think this was a result of a messy/not completely understood rebase. The 'toTypeDependence' parts appeared in the middle of my review, so I must have just merged the change incorrectly. This patch seems like the right thing. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83114/new/ https://reviews.llvm.org/D83114 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:53 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:53 +0000 (UTC) Subject: [PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics In-Reply-To: References: Message-ID: <50a209112166c34907072b68fb2f7e42@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGb2956076976c: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics (authored by Szelethus). Changed prior to commit: https://reviews.llvm.org/D78126?vs=270372&id=275687#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78126/new/ https://reviews.llvm.org/D78126 Files: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h clang/lib/StaticAnalyzer/Core/BugReporter.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D78126.275687.patch Type: text/x-patch Size: 5766 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:54 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:54 +0000 (UTC) Subject: [PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: yaxunl updated this revision to Diff 275685. yaxunl marked 5 inline comments as done. yaxunl retitled this revision from "[HIP] Support accessing static device variable in host code" to "[CUDA][HIP] Support accessing static device variable in host code". yaxunl edited the summary of this revision. yaxunl added a comment. revised by John's comments. Also added generating compilation unit ID by hashing input file path and options. added option -fuse-cuid=random|hash|none for controlling the method to generate compilation unit ID. Allows -cuid=X to override -fuse-cuid. Enabled this feature for both CUDA and HIP. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 Files: clang/include/clang/AST/ASTContext.h clang/include/clang/Basic/LangOptions.h clang/include/clang/Driver/Action.h clang/include/clang/Driver/Compilation.h clang/include/clang/Driver/Options.td clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/Driver/Action.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCUDA/static-device-var.cu clang/test/Driver/hip-cuid.hip clang/test/SemaCUDA/static-device-var.cu -------------- next part -------------- A non-text attachment was scrubbed... Name: D80858.275685.patch Type: text/x-patch Size: 22582 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:55 2020 From: cfe-commits at lists.llvm.org (MyDeveloperDay via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:55 +0000 (UTC) Subject: [PATCH] D82767: clang-format: Explicitly use python3 In-Reply-To: References: Message-ID: MyDeveloperDay added a comment. We may not be consistent across all of LLVM $ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort | uniq -c 6 #! /usr/bin/env python 2 #! /usr/bin/env python3 2 #! /usr/bin/python 1 #!/bin/env python 133 #!/usr/bin/env python 13 #!/usr/bin/env python3 49 #!/usr/bin/python CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82767/new/ https://reviews.llvm.org/D82767 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:56 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:56 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <52634816f581eb7053b32875304d4f67@localhost.localdomain> gamesh411 updated this revision to Diff 275693. gamesh411 marked 2 inline comments as done. gamesh411 added a comment. rename misleading variables apply local consts Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 Files: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp clang/test/Analysis/iterator-modeling.cpp Index: clang/test/Analysis/iterator-modeling.cpp =================================================================== --- clang/test/Analysis/iterator-modeling.cpp +++ clang/test/Analysis/iterator-modeling.cpp @@ -1948,7 +1948,7 @@ clang_analyzer_express(clang_analyzer_iterator_position(i)); // expected-warning{{$c.end() - 2}} } -void plus_ptr_iterator(const cont_with_ptr_iterator &c) { +void lhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) { auto i1 = c.begin(); clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()"); @@ -1960,6 +1960,18 @@ clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}} } +void rhs_plus_ptr_iterator(const cont_with_ptr_iterator &c) { + auto i1 = c.begin(); + + clang_analyzer_denote(clang_analyzer_container_begin(c), "$c.begin()"); + + auto i2 = 2 + i1; + + clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &c); // expected-warning{{TRUE}} + clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$c.begin()}} + clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.begin() + 2}} +} + void minus_ptr_iterator(const cont_with_ptr_iterator &c) { auto i1 = c.end(); Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -262,18 +262,25 @@ void IteratorModeling::checkPostStmt(const BinaryOperator *BO, CheckerContext &C) const { - ProgramStateRef State = C.getState(); - BinaryOperatorKind OK = BO->getOpcode(); - SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext()); + const ProgramStateRef State = C.getState(); + const BinaryOperatorKind OK = BO->getOpcode(); + const Expr *const LHS = BO->getLHS(); + const Expr *const RHS = BO->getRHS(); + const SVal LVal = State->getSVal(LHS, C.getLocationContext()); + const SVal RVal = State->getSVal(RHS, C.getLocationContext()); if (isSimpleComparisonOperator(BO->getOpcode())) { - SVal LVal = State->getSVal(BO->getLHS(), C.getLocationContext()); SVal Result = State->getSVal(BO, C.getLocationContext()); handleComparison(C, BO, Result, LVal, RVal, BinaryOperator::getOverloadedOperator(OK)); } else if (isRandomIncrOrDecrOperator(OK)) { - handlePtrIncrOrDecr(C, BO->getLHS(), - BinaryOperator::getOverloadedOperator(OK), RVal); + // In case of operator+ the iterator can be either on the LHS (eg.: it + 1), + // or on the RHS (eg.: 1 + it). Both cases are modeled. + const bool IsIterOnLHS = BO->getLHS()->getType()->isPointerType(); + const Expr *const &IterExpr = IsIterOnLHS ? LHS : RHS; + const SVal &OffsetVal = IsIterOnLHS ? RVal : LVal; + handlePtrIncrOrDecr(C, IterExpr, BinaryOperator::getOverloadedOperator(OK), + OffsetVal); } } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83190.275693.patch Type: text/x-patch Size: 3090 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:58 2020 From: cfe-commits at lists.llvm.org (Raphael Isemann via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:58 +0000 (UTC) Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source In-Reply-To: References: Message-ID: teemperor added a comment. In D83008#2131796 , @tschuett wrote: > You could try: > > clangxx_host -Xclang -fdump-record-layouts %p/Inputs/layout.cpp -emit-llvm -o /dev/null > > > You could commit the record layouts without your fix to show the differences that you patch makes. Yeah that's I think the proper way to check the results, but IIRC the problem with testing this in Clang is that `foverride-record-layout=` (the testing approach for this code) doesn't support specifying base class offset), so we can't even *trigger* the bug itself in Clang itself. That what I was referring to with "layout overwrite JSON file" in my comment above. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83008/new/ https://reviews.llvm.org/D83008 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:58 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:58 +0000 (UTC) Subject: [PATCH] D83223: [clang-tidy] Header guard check can skip past license comment Message-ID: njames93 created this revision. njames93 added reviewers: aaron.ballman, alexfh, bkramer, gribozavr2. Herald added subscribers: cfe-commits, xazax.hun. Herald added a project: clang. Add an option for header guard derived checks to control whether to skip past a license comment when adding a guard to file currently missing one. Whats identified as a license comment is a block of comments right at the start of a file that is followed by an empty line. All these examples are being interpreted as the first tokens in a file. // This is identified as a license comment. // It can span multiple lines too. // This is not part of the license comment as its detached. // This is not identified as a license comment as the // block is followed by code. void foo(); // This is identified as a license comment as its followed by // an empty line void foo(); Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83223 Files: clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp clang-tools-extra/clang-tidy/utils/HeaderGuard.h clang-tools-extra/unittests/clang-tidy/LLVMModuleTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83223.275696.patch Type: text/x-patch Size: 9509 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:59 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:53:59 +0000 (UTC) Subject: [PATCH] D81750: [analyzer] Don't allow hidden checkers to emit diagnostics In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGcfd6b4b811aa: [analyzer] Don't allow hidden checkers to emit diagnostics (authored by Szelethus). Changed prior to commit: https://reviews.llvm.org/D81750?vs=270447&id=275697#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81750/new/ https://reviews.llvm.org/D81750 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Core/BugReporter.cpp clang/test/Analysis/std-c-library-functions-arg-constraints.c clang/test/Analysis/std-c-library-functions-arg-constraints.cpp clang/test/Analysis/weak-dependencies.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D81750.275697.patch Type: text/x-patch Size: 6038 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:59 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:59 +0000 (UTC) Subject: [PATCH] D82825: [clang-tidy] Added alias llvm-else-after-return. In-Reply-To: References: Message-ID: <78b62d5c9c2f27eb479d403dfb97b800@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGfc3c693b617f: [clang-tidy] Added alias llvm-else-after-return. (authored by njames93). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82825/new/ https://reviews.llvm.org/D82825 Files: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst Index: clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst +++ clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst @@ -77,3 +77,13 @@ the ``if`` statement is the last statement in its parents scope. Default value is `true`. + +LLVM alias +---------- + +There is an alias of this check called llvm-else-after-return. +In that version the options :option:`WarnOnUnfixable` and +:option:`WarnOnConditionVariables` are both set to `false` by default. + +This check helps to enforce this `LLVM Coding Standards recommendation +`_. Index: clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst =================================================================== --- /dev/null +++ clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst @@ -0,0 +1,11 @@ +.. title:: clang-tidy - llvm-else-after-return +.. meta:: + :http-equiv=refresh: 5;URL=readability-else-after-return.html + +llvm-else-after-return +====================== + +The llvm-else-after-return check is an alias, please see +`readability-else-after-return `_ +for more information. + Index: clang-tools-extra/docs/clang-tidy/checks/list.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/list.rst +++ clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -423,4 +423,5 @@ `hicpp-use-nullptr `_, `modernize-use-nullptr `_, "Yes" `hicpp-use-override `_, `modernize-use-override `_, "Yes" `hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_, + `llvm-else-after-return `_, `readability-else-after-return `_, "Yes" `llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes" Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -192,6 +192,11 @@ :doc:`bugprone-signed-char-misuse ` was added. +- New alias :doc:`llvm-else-after-return + ` to + :doc:`readability-else-after-return + ` was added. + Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ Index: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp =================================================================== --- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp +++ clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp @@ -9,6 +9,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "../readability/ElseAfterReturnCheck.h" #include "../readability/NamespaceCommentCheck.h" #include "../readability/QualifiedAutoCheck.h" #include "HeaderGuardCheck.h" @@ -24,6 +25,8 @@ class LLVMModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + CheckFactories.registerCheck( + "llvm-else-after-return"); CheckFactories.registerCheck("llvm-header-guard"); CheckFactories.registerCheck("llvm-include-order"); CheckFactories.registerCheck( @@ -40,6 +43,9 @@ ClangTidyOptions getModuleOptions() override { ClangTidyOptions Options; Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0"; + Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0"; + Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] = + "0"; return Options; } }; -------------- next part -------------- A non-text attachment was scrubbed... Name: D82825.275698.patch Type: text/x-patch Size: 4223 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:00 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:00 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: <69317a34672d0132669d94030e46df16@localhost.localdomain> aaron.ballman added a comment. Do none of the JSON tests break from this change? ================ Comment at: clang/include/clang/AST/TextNodeDumper.h:163 + raw_ostream &getOS() { return OS; } + ---------------- This is a pretty strange public method; any way to limit its visibility? ================ Comment at: clang/test/Import/switch-stmt/test.cpp:8 // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral ---------------- I sort of wonder whether we want both the text and the JSON dumpers to dump these as: `value(type): `, as that seems like it produces results that are a bit more well-structured. WDYT? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 From cfe-commits at lists.llvm.org Mon Jul 6 12:53:59 2020 From: cfe-commits at lists.llvm.org (Djordje Todorovic via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:59 +0000 (UTC) Subject: [PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1 option In-Reply-To: References: Message-ID: <6ef427e063b1c6fe04d7922af3858fa7@localhost.localdomain> djtodoro marked 2 inline comments as done. djtodoro added inline comments. ================ Comment at: clang/lib/CodeGen/BackendUtil.cpp:855 +class ClangCustomPassManager : public legacy::PassManager { +public: ---------------- vsk wrote: > Please factor out OptCustomPassManager from opt and generalize it so it can be used by both opt and clang. That should help ensure that extensions and bug fixes are only made to one custom 'debugify' pass manager. I'll try that with the latest code. I remember I've tried it once, but I ended up moving it into the IR library (since we need to link it within legacy pass manager). ================ Comment at: clang/lib/CodeGen/BackendUtil.cpp:893 + + void enableDebugifyEachOriginal() { DebugifyEachOriginalEnabled = true; } + ---------------- vsk wrote: > I don't think the discussion from 'RFC: Introduce LLVM DI Checker utility' is complete, and I'd ask that you split off changes for 'original mode' from this patch until there's some consensus about what that mode should look like. > > There are open questions about to what extent a new mode is needed (e.g., it may be that the interesting questions compiler developers need to answer about debug info loss are simpler to determine some other way (which is not to say that that's true -- just that we haven't explored the space much yet)). Or what its output should look like. OK, I'll split off this and notify you/resend a message on the RFC. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82547/new/ https://reviews.llvm.org/D82547 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:01 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:01 +0000 (UTC) Subject: [PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer Message-ID: kadircet created this revision. kadircet added a reviewer: sammccall. Herald added subscribers: cfe-commits, aaron.ballman, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. This enables sharing the logic between standalone clangd and embedders of it. The new approach should be same performance-wise, as it is only called once per addDocument call. This patch also introduces a blacklisting code path for disabling crashy or high-noise tests, until we figure out a way to make them work with clangd-setup. The biggest difference is the way we make use of preambles, hence those checks can't see directives coming from the preamble section of the file. The second thing is the fact that code might-not be compiling while clangd is trying to build an AST, hence some checks might choke on those incomplete ASTs. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83224 Files: clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/tool/ClangdMain.cpp Index: clang-tools-extra/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/clangd/tool/ClangdMain.cpp +++ clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -729,23 +729,6 @@ // FIXME: use the FS provided to the function. Opts = ClangTidyOptProvider->getOptions(File); } - if (!Opts.Checks) { - // If the user hasn't configured clang-tidy checks at all, including - // via .clang-tidy, give them a nice set of checks. - // (This should be what the "default" options does, but it isn't...) - // - // These default checks are chosen for: - // - low false-positive rate - // - providing a lot of value - // - being reasonably efficient - Opts.Checks = llvm::join_items( - ",", "readability-misleading-indentation", - "readability-deleted-default", "bugprone-integer-division", - "bugprone-sizeof-expression", "bugprone-suspicious-missing-comma", - "bugprone-unused-raii", "bugprone-unused-return-value", - "misc-unused-using-decls", "misc-unused-alias-decls", - "misc-definitions-in-headers"); - } return Opts; }; } Index: clang-tools-extra/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdServer.cpp +++ clang-tools-extra/clangd/ClangdServer.cpp @@ -107,6 +107,17 @@ ClangdServer::Callbacks *ServerCallbacks; bool TheiaSemanticHighlighting; }; + +// Set of clang-tidy checks that are not suitable to be run through clangd, +// either due to crashes or false positives. +std::string getClangTidyBlacklist() { + std::string FalsePositives = + llvm::join_items(", ", + // Check relies on seeing ifndef/define/endif directives, + // clangd doesn't replay those when using a preamble. + "-llvm-header-guard"); + return llvm::join_items(", ", FalsePositives); +} } // namespace ClangdServer::Options ClangdServer::optsForTest() { @@ -186,6 +197,28 @@ if (GetClangTidyOptions) Opts.ClangTidyOpts = GetClangTidyOptions(*TFS.view(/*CWD=*/llvm::None), File); + if (!Opts.ClangTidyOpts.Checks) { + // If the user hasn't configured clang-tidy checks at all, including + // via .clang-tidy, give them a nice set of checks. + // (This should be what the "default" options does, but it isn't...) + // + // These default checks are chosen for: + // - low false-positive rate + // - providing a lot of value + // - being reasonably efficient + Opts.ClangTidyOpts.Checks = llvm::join_items( + ",", "readability-misleading-indentation", + "readability-deleted-default", "bugprone-integer-division", + "bugprone-sizeof-expression", "bugprone-suspicious-missing-comma", + "bugprone-unused-raii", "bugprone-unused-return-value", + "misc-unused-using-decls", "misc-unused-alias-decls", + "misc-definitions-in-headers"); + } else { + // If user has enabled some checks, make sure clangd incompatible ones are + // disabled. + Opts.ClangTidyOpts.Checks = llvm::join_items( + ", ", *Opts.ClangTidyOpts.Checks, getClangTidyBlacklist()); + } Opts.SuggestMissingIncludes = SuggestMissingIncludes; // Compile command is set asynchronously during update, as it can be slow. -------------- next part -------------- A non-text attachment was scrubbed... Name: D83224.275699.patch Type: text/x-patch Size: 3465 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:02 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:02 +0000 (UTC) Subject: [PATCH] D82365: [Power10] Implement Vector Insert Builtins in LLVM/Clang In-Reply-To: References: Message-ID: <2d9fefb10b1931b7c5d17a8164b71ddc@localhost.localdomain> lei added inline comments. ================ Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:12 +// RUN: -target-cpu pwr10 -triple powerpc64le-unknown-unknown -emit-llvm %s \ +// RUN: -o - | FileCheck %s -check-prefix=CHECK-LE + ---------------- biplmish wrote: > lei wrote: > > I just noticed this. There is no need to add this RUN line since it's the same as the one on line 2. Please post a patch to remove this and update tests to use the default `CHECK`. > Sure. However there are also tests in Line 125,133 etc which would need modification. > > Can we also do "RUN: -o - | FileCheck %s -check-prefixes=CHECK,CHECK-LE" in the test1 and remove the test3 so that the tests work in the current format. Please make all the necessary modification all affected testcases to use `CHECK` instead of `CHECK-LE`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82365/new/ https://reviews.llvm.org/D82365 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:03 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:03 +0000 (UTC) Subject: [PATCH] D83223: [clang-tidy] Header guard check can skip past license comment In-Reply-To: References: Message-ID: njames93 marked an inline comment as done. njames93 added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp:313 continue; - + StringRef Opening = AddNewLine == NewLineInsertions::None ? "#ifndef " + : AddNewLine == NewLineInsertions::One ---------------- clang-format(trunk) says what I submitted was correct, clang-format-10 is suggesting the change. Which do I trust?? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83223/new/ https://reviews.llvm.org/D83223 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:03 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:03 +0000 (UTC) Subject: [PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body. In-Reply-To: References: Message-ID: aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM despite my enduring sadness that Boost elected to use this totally bizarre approach to silencing unused variable diagnostics when far better-supported options have existed for so long. ================ Comment at: clang/lib/Analysis/UninitializedValues.cpp:435 if ((*I)->getType().isConstQualified()) - classify((*I), ConstRefUse); + if (!hasTrivialBody(CE)) + classify((*I), ConstRefUse); ---------------- zequanwu wrote: > nick wrote: > > zequanwu wrote: > > > aaron.ballman wrote: > > > > This can be hoisted out of the loop so that we don't have to check the same thing on every argument. > > > The `DeclRefExpr` needs to be set to `Ignore` like `VisitCastExpr` does. Otherwise, it maybe classified to `Init` by `isTrackedVar` in `ClassifyRefs::get`. > > Could not the empty body check be done in `reportConstRefUse`, after `isUninitialized`? > No, `reportConstRefUse` doesn't know if the called function has trivial body or not. You made the change I was looking for -- I just needed the `hasTrivialBody()` call hoisted since that was invariant within the loop body. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82425/new/ https://reviews.llvm.org/D82425 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:04 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:54:04 +0000 (UTC) Subject: [PATCH] D83226: [analyzer] Add system header simulator a symmetric random access iterator operator+ Message-ID: gamesh411 created this revision. Herald added subscribers: cfe-commits, ASDenysPetrov, martong, steakhal, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun, whisperity. Herald added a reviewer: Szelethus. Herald added a project: clang. Random access iterators must handle operator+, where the iterator is on the RHS. The system header simulator library is extended with these operators. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83226 Files: clang/test/Analysis/Inputs/system-header-simulator-cxx.h clang/test/Analysis/diagnostics/explicit-suppression.cpp Index: clang/test/Analysis/diagnostics/explicit-suppression.cpp =================================================================== --- clang/test/Analysis/diagnostics/explicit-suppression.cpp +++ clang/test/Analysis/diagnostics/explicit-suppression.cpp @@ -19,6 +19,6 @@ void testCopyNull(C *I, C *E) { std::copy(I, E, (C *)0); #ifndef SUPPRESSED - // expected-warning at ../Inputs/system-header-simulator-cxx.h:699 {{Called C++ object pointer is null}} + // expected-warning at ../Inputs/system-header-simulator-cxx.h:709 {{Called C++ object pointer is null}} #endif } Index: clang/test/Analysis/Inputs/system-header-simulator-cxx.h =================================================================== --- clang/test/Analysis/Inputs/system-header-simulator-cxx.h +++ clang/test/Analysis/Inputs/system-header-simulator-cxx.h @@ -60,6 +60,11 @@ __vector_iterator operator+(difference_type n) { return ptr + n; } + friend __vector_iterator operator+( + difference_type n, + const __vector_iterator &iter) { + return n + iter.ptr; + } __vector_iterator operator-(difference_type n) { return ptr - n; } @@ -118,6 +123,11 @@ __deque_iterator operator+(difference_type n) { return ptr + n; } + friend __deque_iterator operator+( + difference_type n, + const __deque_iterator &iter) { + return n + iter.ptr; + } __deque_iterator operator-(difference_type n) { return ptr - n; } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83226.275703.patch Type: text/x-patch Size: 1552 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:07 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:07 +0000 (UTC) Subject: [PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer In-Reply-To: References: Message-ID: <80901f59d373e54ae4a2870a83147783@localhost.localdomain> kadircet updated this revision to Diff 275709. kadircet added a comment. - Add tests and also disable bugprone-use-after-move Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83224/new/ https://reviews.llvm.org/D83224 Files: clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/tool/ClangdMain.cpp clang-tools-extra/clangd/unittests/ClangdTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83224.275709.patch Type: text/x-patch Size: 6212 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:07 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:54:07 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <48d803e4de3ed51e8409ac101410f6ad@localhost.localdomain> gamesh411 added a comment. In order to test the non-pointer iterators, an extension has to be made to the system header simulator. Please check the related patch (parent of this one in the stack) https://reviews.llvm.org/D83226. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:267 BinaryOperatorKind OK = BO->getOpcode(); - SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext()); + Expr *LHS = BO->getLHS(); + Expr *RHS = BO->getRHS(); ---------------- steakhal wrote: > You should probably use const where applicable. > Especially where the refs value depends on a condition operator (eg. few lines below) Definitely should have done that, thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:07 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:07 +0000 (UTC) Subject: [PATCH] D83114: [clang] Fix the incorrect dependence bits for DependentExtIntType. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGcd9a241f1650: [clang] Fix the incorrect dependence bits for DependentExtIntType. (authored by hokein). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83114/new/ https://reviews.llvm.org/D83114 Files: clang/lib/AST/Type.cpp clang/test/Sema/invalid-bitwidth-expr.mm Index: clang/test/Sema/invalid-bitwidth-expr.mm =================================================================== --- clang/test/Sema/invalid-bitwidth-expr.mm +++ clang/test/Sema/invalid-bitwidth-expr.mm @@ -32,3 +32,8 @@ int X : func(); // expected-note {{in instantiation of function template}} }; constexpr int ssss = sizeof(Z); + +struct Z2 { + int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared identifier}} +}; +constexpr int sssss = sizeof(Z2); Index: clang/lib/AST/Type.cpp =================================================================== --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -347,15 +347,7 @@ DependentExtIntType::DependentExtIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) : Type(DependentExtInt, QualType{}, - ((NumBitsExpr->isValueDependent() || NumBitsExpr->isTypeDependent()) - ? TypeDependence::Dependent - : TypeDependence::None) | - (NumBitsExpr->isInstantiationDependent() - ? TypeDependence::Instantiation - : TypeDependence::None) | - (NumBitsExpr->containsUnexpandedParameterPack() - ? TypeDependence::VariablyModified - : TypeDependence::None)), + toTypeDependence(NumBitsExpr->getDependence())), Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {} bool DependentExtIntType::isUnsigned() const { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83114.275711.patch Type: text/x-patch Size: 1522 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:08 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:08 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: riccibruno updated this revision to Diff 275713. riccibruno added a comment. Format the tests and make them more relevant. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 Files: clang/include/clang/AST/APValue.h clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/JSONNodeDumper.h clang/include/clang/AST/TextNodeDumper.h clang/lib/AST/APValue.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/TextNodeDumper.cpp clang/test/AST/alignas_maybe_odr_cleanup.cpp clang/test/AST/ast-dump-APValue-anon-union.cpp clang/test/AST/ast-dump-APValue-arithmetic.cpp clang/test/AST/ast-dump-APValue-array.cpp clang/test/AST/ast-dump-APValue-struct.cpp clang/test/AST/ast-dump-APValue-todo.cpp clang/test/AST/ast-dump-APValue-union.cpp clang/test/AST/ast-dump-APValue-vector.cpp clang/test/AST/ast-dump-attr.cpp clang/test/AST/ast-dump-color.cpp clang/test/AST/ast-dump-constant-expr.cpp clang/test/AST/ast-dump-decl.cpp clang/test/AST/ast-dump-records.cpp clang/test/AST/ast-dump-stmt.cpp clang/test/AST/pr43983.cpp clang/test/Import/switch-stmt/test.cpp clang/test/Tooling/clang-check-ast-dump.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83183.275713.patch Type: text/x-patch Size: 48479 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:08 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:08 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: <772892df631bfa497669b3e2b9c3e6f0@localhost.localdomain> kadircet added inline comments. ================ Comment at: clang-tools-extra/clangd/Hover.cpp:677 HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) HI.Offset = Ctx.getFieldOffset(FD) / 8; + } ---------------- hokein wrote: > kadircet wrote: > > could you move this out of the if statement. > I'm not sure whether Size and Offset should be be independent, IIUC your fix seems to change it as a side effect, this just preserves the old behavior. it wasn't a side effect, it was intentional and stamped (and explicitly spelled out in the description) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:10 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:10 +0000 (UTC) Subject: [PATCH] D82739: Improve heuristic resolution of dependent types in TargetFinder In-Reply-To: References: Message-ID: hokein added a comment. looks like we use this heuristic for go-to-def, I think we might want to use it in more places, e.g. libindex (for xrefs), sema code completion (so that `this->a.^` can suggest something). ================ Comment at: clang-tools-extra/clangd/FindTarget.cpp:198 + // analyzing it. + if (E && BT->getKind() == BuiltinType::Dependent) { + T = resolveDependentExprToType(E); ---------------- I think this is the key point of the fix? It would be nice if you could find a way to split it into two (one for refactoring, one for the fix). The diff of this patch contains large chunk of refactoring changes which make the fix less obvious. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82739/new/ https://reviews.llvm.org/D82739 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:10 2020 From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:10 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <9d9fc9c84b700c55641e31e9d6955cd6@localhost.localdomain> Xiangling_L marked 27 inline comments as done. Xiangling_L added inline comments. ================ Comment at: clang/lib/AST/ASTContext.cpp:2424 + (T->isSpecificBuiltinType(BuiltinType::LongDouble) && + Target->supportsAIXPowerAlignment())) // Don't increase the alignment if an alignment attribute was specified on a ---------------- hubert.reinterpretcast wrote: > hubert.reinterpretcast wrote: > > Xiangling_L wrote: > > > hubert.reinterpretcast wrote: > > > > Does `supportsAIXPowerAlignment` express the condition we want to check here? That might be true for an implementation operating with `mac68k` alignment rules. > > > Yeah, `supportsAIXPowerAlignment` cannot separate the preferred alignment of double, long double between `power/natural` and `mac68k` alignment rules. But I noticed that currently, AIX target on wyvern or XL don't support `mac68k` , so maybe we should leave further changes to the patch which is gonna implement `mac68k` alignment rules? The possible solution I am thinking is we can add checking if the decl has `AlignMac68kAttr` into query to separate things out. > > > > > > Another thing is that once we start supporting mac68k alignment rule(if we will), should we also change the ABI align values as well? (e.g. for double, it should be 2 instead) > > If the "base state" is AIX `power` alignment for a platform, I suggest that the name be `defaultsToAIXPowerAlignment`. > This last question about the ABI align values is relevant to considerations for `natural` alignment support as well. More generally, the question is whether the "minimum alignment" of the type in a context subject to alternative alignment rules is altered to match said alignment rule. This is observable via the diagnostic associated with C++11 alignment specifiers. > > The existing behaviour of `mac68k` alignment suggests that the "minimum alignment" is context-free. > > ``` > #pragma options align=mac68k > struct Q { > double x alignas(2); // expected-error {{less than minimum alignment}} > }; > #pragma options align=reset > ``` > > Compiler Explorer link: https://godbolt.org/z/9NM5_- Thank you for your explanation. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1885 + Context.getBaseElementType(CTy->getElementType()) + ->getAs()) + if (BTy->getKind() == BuiltinType::Double || ---------------- hubert.reinterpretcast wrote: > I believe `castAs` should be expected to succeed here. `castAs` is not declared in current context, do we really want to use it by introducing one more header? ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1898 + } else if (const RecordType *RT = D->getType() + ->getBaseElementTypeUnsafe() + ->getAs()) { ---------------- hubert.reinterpretcast wrote: > Is there a reason to use `getBaseElementTypeUnsafe` for this case and `Context.getBaseElementType` for the other ones? Also, it would make sense to factor out the array-type considerations once at the top of the if-else chain instead of doing so in each alternative. Sorry, I didn't pay attention to the different versions of `getBaseElementType` functions here and I believe this part of code came from our old compiler's changesets. My understanding would be since type qualifiers are not very meaningful in our case and `getBaseElementTypeUnsafe()` is more efficient than `getBaseElementType()`, we can use `getBaseElementTypeUnsafe()` all over the place instead. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:11 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:11 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: hokein marked an inline comment as done. hokein added inline comments. ================ Comment at: clang-tools-extra/clangd/Hover.cpp:677 HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) HI.Offset = Ctx.getFieldOffset(FD) / 8; + } ---------------- kadircet wrote: > hokein wrote: > > kadircet wrote: > > > could you move this out of the if statement. > > I'm not sure whether Size and Offset should be be independent, IIUC your fix seems to change it as a side effect, this just preserves the old behavior. > it wasn't a side effect, it was intentional and stamped (and explicitly spelled out in the description) ah, OK, changed it back. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:11 2020 From: cfe-commits at lists.llvm.org (Danila Malyutin via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:11 +0000 (UTC) Subject: [PATCH] D62574: Initial draft of target-configurable address spaces. In-Reply-To: References: Message-ID: danilaml added a comment. What are the remaining roadblocks left before this patch can be merged? I'm interested in having a target-specific way to define the allowed explicit/implicit address space conversions. Also, it appears that currently whether implicit casts between pointers of different AS are allowed is determined by the superset relations only, however https://reviews.llvm.org/D73360 introduced another (openCL-specific) variable into the mix: whether the conversion is a top level or not. IMHO, this should also be configured by the target, although I'm not sure whether it needs a separate hook (isBitcastNoop or similar?) or it needs to check the legality of the implicit casts differently. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62574/new/ https://reviews.llvm.org/D62574 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:11 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:11 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: hokein updated this revision to Diff 275718. hokein added a comment. address comment. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -784,11 +784,24 @@ HI.NamespaceScope = ""; HI.Definition = "int xx"; HI.LocalScope = "Foo::"; - HI.Size = 4; HI.Type = "int"; HI.AccessSpecifier = "public"; }}, - }; + {R"cpp( + // error-ok + struct Foo { + Bar xx; + int [[y^y]]; + };)cpp", + [](HoverInfo &HI) { + HI.Name = "yy"; + HI.Kind = index::SymbolKind::Field; + HI.NamespaceScope = ""; + HI.Definition = "int yy"; + HI.LocalScope = "Foo::"; + HI.Type = "int"; + HI.AccessSpecifier = "public"; + }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -659,8 +659,10 @@ } void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) { - const auto &Ctx = ND.getASTContext(); + if (ND.isInvalidDecl()) + return; + const auto &Ctx = ND.getASTContext(); if (auto *RD = llvm::dyn_cast(&ND)) { if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl())) HI.Size = Size->getQuantity(); @@ -671,11 +673,10 @@ const auto *Record = FD->getParent(); if (Record) Record = Record->getDefinition(); - if (Record && !Record->isDependentType()) { + if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) { + HI.Offset = Ctx.getFieldOffset(FD) / 8; if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) - HI.Offset = Ctx.getFieldOffset(FD) / 8; } return; } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83189.275718.patch Type: text/x-patch Size: 2015 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:53:31 2020 From: cfe-commits at lists.llvm.org (Sebastian Neubauer via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:53:31 +0000 (UTC) Subject: [PATCH] D81728: [InstCombine] Add target-specific inst combining In-Reply-To: References: Message-ID: <7c091cc74958be98f1e773d9ca49725e@localhost.localdomain> Flakebi updated this revision to Diff 275617. Flakebi added a comment. Rebased and removed a few includes as suggested. Make the TargetTransformInfo a private member of InstCombiner because it should not be used in general inst combines. Move CreateOverflowTuple out of InstCombiner and make CreateNonTerminatorUnreachable static. > I would really rather not make this be a public class - this is a very thick interface. Can this be cut down to something much smaller than the implementation details of InstCombine? I agrees that keeping the public interface small is desirable and I tried to do that by splitting the class into `InstCombiner` – the internal, public interface – and `InstCombinerImpl` – the actual implementation of the pass. As far as I understand it, `LLVM_LIBRARY_VISIBILITY` hides this class so it is not visible outside LLVM? With this change, inst combining is split across several places, the general InstCombine and all the targets. They do similar things with the difference that the inst combining part inside the targets does only have access to the public `InstCombiner` interface. As the target specific parts want to use the same helper methods, these helpers need to be in a public interface (public to the targets, not to LLVM users). The most prominent of these helpers is `peekThroughBitcast`. Some of these helper functions are currently not used by targets, so they can be moved to a utils header if desired. In general, I think we want them to be shared, so that not every target has its own set of helpers. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81728/new/ https://reviews.llvm.org/D81728 Files: clang/test/CodeGen/thinlto-distributed-newpm.ll llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/include/llvm/IR/Function.h llvm/include/llvm/Transforms/InstCombine/InstCombiner.h llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/IR/Function.cpp llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h llvm/lib/Target/AMDGPU/CMakeLists.txt llvm/lib/Target/AMDGPU/InstCombineTables.td llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp llvm/lib/Target/ARM/ARMTargetTransformInfo.h llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h llvm/lib/Target/X86/CMakeLists.txt llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp llvm/lib/Target/X86/X86TargetTransformInfo.h llvm/lib/Transforms/InstCombine/CMakeLists.txt llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/lib/Transforms/InstCombine/InstCombineInternal.h llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/lib/Transforms/InstCombine/InstCombineTables.td llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp llvm/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/test/CodeGen/Thumb2/mve-intrinsics/predicates.ll llvm/test/CodeGen/Thumb2/mve-intrinsics/vadc-multiple.ll llvm/test/CodeGen/Thumb2/mve-vpt-from-intrinsics.ll llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts.ll llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll llvm/test/Transforms/InstCombine/AMDGPU/ldexp.ll llvm/test/Transforms/InstCombine/ARM/mve-v2i2v.ll llvm/test/Transforms/InstCombine/ARM/neon-intrinsics.ll llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll llvm/test/Transforms/InstCombine/X86/addcarry.ll llvm/test/Transforms/InstCombine/X86/clmulqdq.ll llvm/test/Transforms/InstCombine/X86/x86-avx2.ll llvm/test/Transforms/InstCombine/X86/x86-avx512.ll llvm/test/Transforms/InstCombine/X86/x86-bmi-tbm.ll llvm/test/Transforms/InstCombine/X86/x86-insertps.ll llvm/test/Transforms/InstCombine/X86/x86-masked-memops.ll llvm/test/Transforms/InstCombine/X86/x86-movmsk.ll llvm/test/Transforms/InstCombine/X86/x86-pack.ll llvm/test/Transforms/InstCombine/X86/x86-pshufb.ll llvm/test/Transforms/InstCombine/X86/x86-sse.ll llvm/test/Transforms/InstCombine/X86/x86-sse2.ll llvm/test/Transforms/InstCombine/X86/x86-sse41.ll llvm/test/Transforms/InstCombine/X86/x86-sse4a.ll llvm/test/Transforms/InstCombine/X86/x86-vec_demanded_elts.ll llvm/test/Transforms/InstCombine/X86/x86-vector-shifts.ll llvm/test/Transforms/InstCombine/X86/x86-vpermil.ll llvm/test/Transforms/InstCombine/X86/x86-xop.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D81728.275617.patch Type: text/x-patch Size: 484375 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:12 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:12 +0000 (UTC) Subject: [PATCH] D83189: [clangd] More complete fix for hover crashes on invalid record. In-Reply-To: References: Message-ID: <04c797a3a7153ebadf764e49abb8168a@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG254b016c6561: [clangd] More complete fix for hover crashes on invalid record. (authored by hokein). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83189/new/ https://reviews.llvm.org/D83189 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -784,11 +784,24 @@ HI.NamespaceScope = ""; HI.Definition = "int xx"; HI.LocalScope = "Foo::"; - HI.Size = 4; HI.Type = "int"; HI.AccessSpecifier = "public"; }}, - }; + {R"cpp( + // error-ok + struct Foo { + Bar xx; + int [[y^y]]; + };)cpp", + [](HoverInfo &HI) { + HI.Name = "yy"; + HI.Kind = index::SymbolKind::Field; + HI.NamespaceScope = ""; + HI.Definition = "int yy"; + HI.LocalScope = "Foo::"; + HI.Type = "int"; + HI.AccessSpecifier = "public"; + }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -659,8 +659,10 @@ } void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) { - const auto &Ctx = ND.getASTContext(); + if (ND.isInvalidDecl()) + return; + const auto &Ctx = ND.getASTContext(); if (auto *RD = llvm::dyn_cast(&ND)) { if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl())) HI.Size = Size->getQuantity(); @@ -671,11 +673,10 @@ const auto *Record = FD->getParent(); if (Record) Record = Record->getDefinition(); - if (Record && !Record->isDependentType()) { + if (Record && !Record->isInvalidDecl() && !Record->isDependentType()) { + HI.Offset = Ctx.getFieldOffset(FD) / 8; if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) HI.Size = Size->getQuantity(); - if (!FD->isInvalidDecl()) - HI.Offset = Ctx.getFieldOffset(FD) / 8; } return; } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83189.275721.patch Type: text/x-patch Size: 2015 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:12 2020 From: cfe-commits at lists.llvm.org (Raphael Isemann via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:12 +0000 (UTC) Subject: [PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library In-Reply-To: References: Message-ID: <839b73b86e2636cacfef877bc25d5654@localhost.localdomain> teemperor added a comment. This broke the Green Dragon build for Clang: http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/ FAILED: bin/diagtool : && /Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/clang++ -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -fmodules -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/module.cache -fcxx-modules -Xclang -fmodules-local-submodule-visibility -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/diagtool_main.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagTool.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/FindDiagnosticID.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ListWarnings.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ShowEnabledWarnings.cpp.o tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/TreeView.cpp.o -o bin/diagtool -Wl,-rpath, at loader_path/../lib lib/libLLVMSupport.a lib/libclangBasic.a lib/libclangFrontend.a lib/libclangDriver.a lib/libclangParse.a lib/libclangSerialization.a lib/libclangSema.a lib/libclangEdit.a lib/libclangAnalysis.a lib/libclangASTMatchers.a lib/libclangAST.a lib/libclangLex.a lib/libclangBasic.a lib/libLLVMFrontendOpenMP.a lib/libLLVMTransformUtils.a lib/libLLVMAnalysis.a lib/libLLVMObject.a lib/libLLVMMCParser.a lib/libLLVMMC.a lib/libLLVMDebugInfoCodeView.a lib/libLLVMDebugInfoMSF.a lib/libLLVMTextAPI.a lib/libLLVMBitReader.a lib/libLLVMOption.a lib/libLLVMProfileData.a lib/libLLVMCore.a lib/libLLVMBinaryFormat.a lib/libLLVMRemarks.a lib/libLLVMBitstreamReader.a lib/libLLVMSupport.a -lz -lcurses -lm lib/libLLVMDemangle.a && : Undefined symbols for architecture x86_64: "clang::ento::PackageInfo::dumpToStream(llvm::raw_ostream&) const", referenced from: clang::ento::PackageInfo::dump() const in ShowEnabledWarnings.cpp.o clang::ento::PackageInfo::dump() const in libclangFrontend.a(CompilerInstance.cpp.o) clang::ento::PackageInfo::dump() const in libclangFrontend.a(CompilerInvocation.cpp.o) clang::ento::PackageInfo::dump() const in libclangFrontend.a(CreateInvocationFromCommandLine.cpp.o) clang::ento::PackageInfo::dump() const in libclangFrontend.a(TextDiagnosticBuffer.cpp.o) clang::ento::PackageInfo::dump() const in libclangFrontend.a(FrontendAction.cpp.o) clang::ento::PackageInfo::dump() const in libclangFrontend.a(FrontendOptions.cpp.o) ... "clang::ento::CmdLineOption::dumpToStream(llvm::raw_ostream&) const", referenced from: clang::ento::CmdLineOption::dump() const in ShowEnabledWarnings.cpp.o clang::ento::CmdLineOption::dump() const in libclangFrontend.a(CompilerInstance.cpp.o) clang::ento::CmdLineOption::dump() const in libclangFrontend.a(CompilerInvocation.cpp.o) clang::ento::CmdLineOption::dump() const in libclangFrontend.a(CreateInvocationFromCommandLine.cpp.o) clang::ento::CmdLineOption::dump() const in libclangFrontend.a(TextDiagnosticBuffer.cpp.o) clang::ento::CmdLineOption::dump() const in libclangFrontend.a(FrontendAction.cpp.o) clang::ento::CmdLineOption::dump() const in libclangFrontend.a(FrontendOptions.cpp.o) ... "clang::ento::CheckerInfo::dumpToStream(llvm::raw_ostream&) const", referenced from: clang::ento::CheckerInfo::dump() const in ShowEnabledWarnings.cpp.o clang::ento::CheckerInfo::dump() const in libclangFrontend.a(CompilerInstance.cpp.o) clang::ento::CheckerInfo::dump() const in libclangFrontend.a(CompilerInvocation.cpp.o) clang::ento::CheckerInfo::dump() const in libclangFrontend.a(CreateInvocationFromCommandLine.cpp.o) clang::ento::CheckerInfo::dump() const in libclangFrontend.a(TextDiagnosticBuffer.cpp.o) clang::ento::CheckerInfo::dump() const in libclangFrontend.a(FrontendAction.cpp.o) clang::ento::CheckerInfo::dump() const in libclangFrontend.a(FrontendOptions.cpp.o) ... ld: symbol(s) not found for architecture x86_64 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82585/new/ https://reviews.llvm.org/D82585 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:13 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:13 +0000 (UTC) Subject: [PATCH] D83233: [clangd] Enable reading config from files by default. Message-ID: sammccall created this revision. sammccall added reviewers: kadircet, hokein. Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83233 Files: clang-tools-extra/clangd/tool/ClangdMain.cpp Index: clang-tools-extra/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/clangd/tool/ClangdMain.cpp +++ clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -320,7 +320,7 @@ "lit-test", cat(Misc), desc("Abbreviation for -input-style=delimited -pretty -sync " - "-enable-test-scheme -log=verbose. " + "-enable-test-scheme -enable-config=0 -log=verbose. " "Intended to simplify lit tests"), init(false), Hidden, @@ -427,6 +427,19 @@ Hidden, }; +opt EnableConfig{ + "enable-config", + cat(Misc), + desc( + "Read user and project configuration from YAML files.\n" + "Project config is from a .clangd file in the project directory.\n" + "User config is from clangd/config.yaml in the following directories:\n" + "\tWindows: %USERPROFILE%\\AppData\\Local\n" + "\tMac OS: ~/Library/Preferences/\n" + "\tOthers: $XDG_CONFIG_HOME, usually ~/.config"), + init(true), +}; + /// Supports a test URI scheme with relaxed constraints for lit tests. /// The path in a test URI will be combined with a platform-specific fake /// directory to form an absolute path. For example, test:///a.cpp is resolved @@ -510,6 +523,9 @@ InputStyle = JSONStreamStyle::Delimited; LogLevel = Logger::Verbose; PrettyPrint = true; + // Disable config system by default to avoid external reads. + if (!EnableConfig.getNumOccurrences()) + EnableConfig = false; // Disable background index on lit tests by default to prevent disk writes. if (!EnableBackgroundIndex.getNumOccurrences()) EnableBackgroundIndex = false; @@ -677,6 +693,23 @@ CCOpts.RunParser = CodeCompletionParse; RealThreadsafeFS TFS; + std::unique_ptr Config; + if (EnableConfig) { + std::vector> ProviderStack; + ProviderStack.push_back( + config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS)); + llvm::SmallString<256> UserConfig; + if (llvm::sys::path::user_config_directory(UserConfig)) { + llvm::sys::path::append(UserConfig, "clangd", "config.yaml"); + vlog("User config file is {0}", UserConfig); + ProviderStack.push_back(config::Provider::fromYAMLFile(UserConfig, TFS)); + } else { + elog("Couldn't determine user config file, not loading"); + } + Config = config::Provider::combine(std::move(ProviderStack)); + Opts.ConfigProvider = Config.get(); + } + // Initialize and run ClangdLSPServer. // Change stdin to binary to not lose \r\n on windows. llvm::sys::ChangeStdinToBinary(); -------------- next part -------------- A non-text attachment was scrubbed... Name: D83233.275724.patch Type: text/x-patch Size: 2682 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:14 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:14 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: riccibruno marked 2 inline comments as done. riccibruno added a comment. Thanks for your comments! In D83183#2132975 , @aaron.ballman wrote: > Do none of the JSON tests break from this change? No, but only because I am not modifying the JSON output at all (the JSON output is still from `APValue::printPretty`). ================ Comment at: clang/include/clang/AST/TextNodeDumper.h:163 + raw_ostream &getOS() { return OS; } + ---------------- aaron.ballman wrote: > This is a pretty strange public method; any way to limit its visibility? I just need it for `dumpAPValueChildren`, but I can make `dumpAPValueChildren` a private method of `TextNodeDumper` instead. ================ Comment at: clang/test/Import/switch-stmt/test.cpp:8 // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral ---------------- aaron.ballman wrote: > I sort of wonder whether we want both the text and the JSON dumpers to dump these as: `value(type): `, as that seems like it produces results that are a bit more well-structured. WDYT? I'm not sure I follow. The `value` is just a label for the child of the `VarDecl`. If you look at a more complex example such as: ``` VarDecl {{.*}} col:{{.*}} s4 'const S4' |-value: Struct | |-base: Struct | | `-fields: Int 0, Union .j Int 0 | |-fields: Int 1, Int 2, Int 3 | |-field: Struct | `-fields: Int 4, Int 5, Int 6 ``` There is no other `value` label. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:14 2020 From: cfe-commits at lists.llvm.org (Oliver Stannard (Linaro) via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:14 +0000 (UTC) Subject: [PATCH] D76291: [Support] Fix formatted_raw_ostream for UTF-8 In-Reply-To: References: Message-ID: <570a5b2ceba6aa935ef11ec7c6a5ce7b@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGe80b81d1cbf8: [Support] Fix formatted_raw_ostream for UTF-8 (authored by ostannard). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76291/new/ https://reviews.llvm.org/D76291 Files: clang/test/Analysis/checker-plugins.c llvm/include/llvm/Support/FormattedStream.h llvm/lib/Support/FormattedStream.cpp llvm/test/MC/ARM/lsl-zero.s llvm/unittests/Support/formatted_raw_ostream_test.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D76291.275726.patch Type: text/x-patch Size: 13508 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:14 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:14 +0000 (UTC) Subject: [PATCH] D83178: [clangd] Send EOF before resetting diagnostics consumer In-Reply-To: References: Message-ID: <9038b4132b9e92c6a2223f9871bf46ae@localhost.localdomain> kadircet added a comment. As discussed offline D78038 is not going to fix header-guard-check issue, as it relies on not only the PP state, but receiving appropriate callbacks for all of the ifndef/define/endif macros, which is something we don't do in current state. So sent out D83224 to discuss our options around disabling tidy checks. As for checks affected by this change; there seems to be 3 of them, llvm-include-order-check, llvm-header-guard-check and portability-restrict-system-includes, out of these 3 only the llvm-header-guard requires access to non-include directives, the rest seems to be fine. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83178/new/ https://reviews.llvm.org/D83178 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:15 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:54:15 +0000 (UTC) Subject: [PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library In-Reply-To: References: Message-ID: Szelethus added a comment. I'm on it! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82585/new/ https://reviews.llvm.org/D82585 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:16 2020 From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:16 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <686ea3c8aa1596c31a2da576ee503acf@localhost.localdomain> Xiangling_L updated this revision to Diff 275728. Xiangling_L marked 3 inline comments as done. Xiangling_L added a comment. Fixed -Wpacked warning issue; Fixed EmptySubobjects related offset issue; Fixed zero-extent array in a base class related issue; Addressed other comments; CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 Files: clang/include/clang/AST/RecordLayout.h clang/include/clang/Basic/TargetInfo.h clang/lib/AST/ASTContext.cpp clang/lib/AST/RecordLayout.cpp clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Basic/Targets/PPC.h clang/test/Layout/aix-Wpacked.cpp clang/test/Layout/aix-double-struct-member.cpp clang/test/Layout/aix-no-unique-address-with-double.cpp clang/test/Layout/aix-virtual-function-and-base-with-double.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D79719.275728.patch Type: text/x-patch Size: 60899 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:17 2020 From: cfe-commits at lists.llvm.org (Raphael Isemann via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:17 +0000 (UTC) Subject: [PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library In-Reply-To: References: Message-ID: <6525cda72c8de03dc195752c9740044e@localhost.localdomain> teemperor added a comment. Fixed here to get the bot running again: https://github.com/llvm/llvm-project/commit/7308e1432624f02d4e652ffa70e40d0eaa89fdb3 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82585/new/ https://reviews.llvm.org/D82585 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:17 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:54:17 +0000 (UTC) Subject: [PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library In-Reply-To: References: Message-ID: <7fd784257e71e8577797498b81c7af51@localhost.localdomain> Szelethus added a comment. In D82585#2133260 , @teemperor wrote: > Fixed here to get the bot running again: https://github.com/llvm/llvm-project/commit/7308e1432624f02d4e652ffa70e40d0eaa89fdb3 Thank you so much! Kind of ironic considering that this entire patch was all about fixing them in the first place :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82585/new/ https://reviews.llvm.org/D82585 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:23 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:23 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <6a1bfcb4ef3b0319041944b7c922acdc@localhost.localdomain> hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/ASTContext.cpp:2409 + const RecordDecl *RD = RT->getDecl(); + return std::max(ABIAlign, static_cast(toBits( + getASTRecordLayout(RD).PreferredAlignment))); ---------------- Please add a comment regarding the situations where the `ABIAlign` value is greater than the `PreferredAlignment` value. It may be appropriate to assert that, absent those cases, the `PreferredAlignment` value is at least that of `ABIAlign`. ================ Comment at: clang/lib/AST/ASTContext.cpp:2409 + const RecordDecl *RD = RT->getDecl(); + return std::max(ABIAlign, static_cast(toBits( + getASTRecordLayout(RD).PreferredAlignment))); ---------------- hubert.reinterpretcast wrote: > Please add a comment regarding the situations where the `ABIAlign` value is greater than the `PreferredAlignment` value. It may be appropriate to assert that, absent those cases, the `PreferredAlignment` value is at least that of `ABIAlign`. It does not appear that the maximum of the two values is the correct answer: ``` struct C { double x; } c; typedef struct C __attribute__((__aligned__(2))) CC; CC cc; extern char x[__alignof__(cc)]; extern char x[2]; // this is okay with IBM XL C/C++ ``` ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1888 + BTy->getKind() == BuiltinType::LongDouble) { + PreferredAlign = CharUnits::fromQuantity(8); + } ---------------- hubert.reinterpretcast wrote: > I believe an assertion that `PreferredAlign` was 4 would be appropriate. It seems that overriding the value should only be done after additional checks: ``` typedef double __attribute__((__aligned__(2))) Dbl; struct A { Dbl x; } a; extern char x[__alignof__(a)]; extern char x[2]; // this is okay with IBM XL C/C++ ``` I am getting concerned that the logic here overlaps quite a bit with `getPreferredTypeAlign` and refactoring to make the code here more common with `getPreferredTypeAlign` is necessary. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:24 2020 From: cfe-commits at lists.llvm.org (Yonghong Song via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:24 +0000 (UTC) Subject: [PATCH] D83242: [RFC][BPF] support expr with typedef type for FIELD_EXISTENCE reloc Message-ID: yonghong-song created this revision. yonghong-song added reviewers: anakryiko, ast. Herald added subscribers: llvm-commits, cfe-commits, hiraditya. Herald added projects: clang, LLVM. [The patch needs more work e.g. to create proper test, to be agreed on interface, etc.] This patch added support of expression with typedef type for FIELD_EXISTENCE relocation. This tries to address the following use case: enum { FIELD_EXISTENCE = 2, }; typedef unsigned long u64; typedef unsigned int u32; struct bpf_perf_event_data_kern; typedef u64 (*btf_bpf_read_branch_records)(struct bpf_perf_event_data_kern *, void *, u32, u64); int test() { btf_bpf_read_branch_records a; return __builtin_preserve_field_info(a, FIELD_EXISTENCE); } A relocation with a type of typedef 'btf_bpf_read_branch_records' will be recorded. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83242 Files: clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp Index: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp =================================================================== --- llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp +++ llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp @@ -277,7 +277,7 @@ } if (GV->getName().startswith("llvm.bpf.preserve.field.info")) { CInfo.Kind = BPFPreserveFieldInfoAI; - CInfo.Metadata = nullptr; + CInfo.Metadata = Call->getMetadata(LLVMContext::MD_preserve_access_index); // Check validity of info_kind as clang did not check this. uint64_t InfoKind = getConstant(Call->getArgOperand(1)); if (InfoKind >= BPFCoreSharedInfo::MAX_FIELD_RELOC_KIND) @@ -742,6 +742,13 @@ break; } + if (CInfo.Kind == BPFPreserveFieldInfoAI) { + // typedef type. + TypeName = std::string(PossibleTypeDef->getName()); + TypeMeta = PossibleTypeDef; + break; + } + assert(CInfo.Kind == BPFPreserveArrayAI); // Array entries will always be consumed for accumulative initial index. Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2582,6 +2582,15 @@ return false; } + // The second argument needs to be a constant int + Arg = TheCall->getArg(1); + llvm::APSInt Value; + if (!Arg->isIntegerConstantExpr(Value, Context)) { + Diag(Arg->getBeginLoc(), diag::err_preserve_field_info_not_const) + << 2 << Arg->getSourceRange(); + return true; + } + // The first argument needs to be a record field access. // If it is an array element access, we delay decision // to BPF backend to check whether the access is a @@ -2590,21 +2599,14 @@ if (Arg->getType()->getAsPlaceholderType() || (Arg->IgnoreParens()->getObjectKind() != OK_BitField && !dyn_cast(Arg->IgnoreParens()) && - !dyn_cast(Arg->IgnoreParens()))) { + !dyn_cast(Arg->IgnoreParens()) && + // Value 2 here represents reloc kind FIELD_EXISTENCE. + (Value != 2 || !Arg->getType()->getAs()))) { Diag(Arg->getBeginLoc(), diag::err_preserve_field_info_not_field) << 1 << Arg->getSourceRange(); return true; } - // The second argument needs to be a constant int - Arg = TheCall->getArg(1); - llvm::APSInt Value; - if (!Arg->isIntegerConstantExpr(Value, Context)) { - Diag(Arg->getBeginLoc(), diag::err_preserve_field_info_not_const) - << 2 << Arg->getSourceRange(); - return true; - } - TheCall->setType(Context.UnsignedIntTy); return false; } Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -10966,11 +10966,17 @@ ConstantInt *C = cast(EmitScalarExpr(E->getArg(1))); Value *InfoKind = ConstantInt::get(Int64Ty, C->getSExtValue()); + llvm::DIType *DbgInfo = + getDebugInfo()->getOrCreateStandaloneType(E->getArg(0)->getType(), + E->getArg(0)->getExprLoc()); + // Built the IR for the preserve_field_info intrinsic. llvm::Function *FnGetFieldInfo = llvm::Intrinsic::getDeclaration( &CGM.getModule(), llvm::Intrinsic::bpf_preserve_field_info, {FieldAddr->getType()}); - return Builder.CreateCall(FnGetFieldInfo, {FieldAddr, InfoKind}); + CallInst *Fn = Builder.CreateCall(FnGetFieldInfo, {FieldAddr, InfoKind}); + Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo); + return Fn; } case BPF::BI__builtin_btf_type_id: { Value *FieldVal = nullptr; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83242.275744.patch Type: text/x-patch Size: 3737 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:25 2020 From: cfe-commits at lists.llvm.org (Nick Desaulniers via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:25 +0000 (UTC) Subject: [PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types In-Reply-To: References: Message-ID: <479ddbd9162f25e62c4099261a827615@localhost.localdomain> nickdesaulniers added a comment. Bumping for review Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80242/new/ https://reviews.llvm.org/D80242 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:25 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:25 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <77af2eba8725bd3252373c3eebd33399@localhost.localdomain> hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1885 + Context.getBaseElementType(CTy->getElementType()) + ->getAs()) + if (BTy->getKind() == BuiltinType::Double || ---------------- Xiangling_L wrote: > hubert.reinterpretcast wrote: > > I believe `castAs` should be expected to succeed here. > `castAs` is not declared in current context, do we really want to use it by introducing one more header? `castAs` should be declared: https://clang.llvm.org/doxygen/classclang_1_1Type.html#a436b8b08ae7f2404b4712d37986194ce Also, the additional point is that the `if` here should be unnecessary. `BTy` should not be null. We should use `castAs` to gain the guarantee (with assertions) that `BTy` is not null. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:26 2020 From: cfe-commits at lists.llvm.org (Zixu Wang via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:26 +0000 (UTC) Subject: [PATCH] D82118: [clang][module] Improve incomplete-umbrella warning In-Reply-To: References: Message-ID: zixuw added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82118/new/ https://reviews.llvm.org/D82118 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:27 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:27 +0000 (UTC) Subject: [PATCH] D83224: [clangd] Move clang-tidy check modifications into ClangdServer In-Reply-To: References: Message-ID: <49c4cc29ed4f2ecbc9c2252a9f52ab3b@localhost.localdomain> njames93 added a comment. Do you think there should be a hidden command line option to disable disabling blacklisted checks, purely to prevent hindering attempts to fix these problematic checks. ================ Comment at: clang-tools-extra/clangd/ClangdServer.cpp:115 +// either due to crashes or false positives. +const char *getClangTidyBlacklist() { + static const std::string FalsePositives = ---------------- Return by StringRef? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83224/new/ https://reviews.llvm.org/D83224 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:27 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:27 +0000 (UTC) Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid SourceLocation In-Reply-To: References: Message-ID: gribozavr2 added inline comments. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:118 +syntax::NodeKind getOperatorNodeKind(const CXXOperatorCallExpr &E) { + switch (E.getOperator()) { ---------------- eduucaldas wrote: > # Where to put this logic? > The pro of having this function inside `BuildTree.cpp` is that it is closer to it's *only* usage. And also for now `BuildTree.cpp` agglomerates everything that takes a semantic AST as an input, so it would be coherent. > > Another option is to put it in `Nodes`, as it might serve as documentation for `*OperatorExpression`s. > For example, it would document that the semantic node `CXXOperatorCallExpr` can also generate the syntax node `BinaryOperatorExpression`, which was previously only generated by a semantic `BinaryOperator` > > Another option is to add put this function as a lambda inside `WalkUpFromCXXOperatorCallExpr` as probably it will only be used there. Placing this helper here makes sense to me. However, please mark it static. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:178 + return syntax::NodeKind::BinaryOperatorExpression; + // Not supported by SyntaxTree + case OO_New: ---------------- "Not supported by syntax tree *yet*" ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:741 bool WalkUpFromIntegerLiteral(IntegerLiteral *S) { + if (S->getLocation().isInvalid()) + return true; ---------------- WDYT about overriding `TraverseCXXOperatorCallExpr`, so that we don't even visit the synthetic argument of the postfix unary `++`? I would prefer to not introduce blanket "if invalid then ignore" checks in the code. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:852 + default: + llvm_unreachable("getKind does not implement that"); } ---------------- "getOperatorNodeKind() does not return this value" ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2333 +struct X { + X operator++(int); +}; ---------------- Could you also add tests for a prefix unary operator? ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2376 + | | | `-x + | | `-IdExpression + | | `-UnqualifiedId ---------------- I'm not sure about this part where `++` is wrapped in IdExpression -- shouldn't the syntax tree look identical to a builtin postfix `++` (see another test in this file)? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82954/new/ https://reviews.llvm.org/D82954 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:28 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:28 +0000 (UTC) Subject: [PATCH] D83071: Add support for options with two flags for controlling the same field. In-Reply-To: References: Message-ID: <380a4d6ead9d3f7d4fede9dc4bee38b4@localhost.localdomain> dang marked an inline comment as done. dang added inline comments. ================ Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3931-3932 if (((FLAGS)&options::CC1Option) && \ (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) { \ - if (Option::KIND##Class == Option::FlagClass) { \ - Args.push_back(SPELLING); \ - } \ - if (Option::KIND##Class == Option::SeparateClass) { \ - Args.push_back(SPELLING); \ - DENORMALIZER(Args, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH)); \ - } \ + DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH)); \ } ---------------- dang wrote: > dexonsmith wrote: > > I realize this commit doesn't introduce it, but it seems unfortunate to call `EXTRACTOR` twice. Maybe in a follow-up or prep commit you can fix that... maybe something like this? > > ``` > > if ((FLAGS)&options::CC1Option) { > > const auto &Extracted = EXTRACTOR(this->KEYPATH); > > if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) > > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH)); > > } > > ``` > Yes I can do that of course. Although EXTRACTOR is meant to be very cheap and in most cases it expands to just `this->KEYPATH` See D83211 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83071/new/ https://reviews.llvm.org/D83071 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:29 2020 From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:29 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: <80ad44b7b19e337e3ed396fa309c3ea8@localhost.localdomain> cchen marked 8 inline comments as done. cchen added inline comments. ================ Comment at: clang/lib/Parse/ParseExpr.cpp:1933 } + if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) { + // Consume ':' ---------------- ABataev wrote: > Seems to me, it is too broad. According to the standard, it must be allowed only in to/from clauses. I did the check in Sema, I'll move the check here. Thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:29 2020 From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:29 +0000 (UTC) Subject: [PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods In-Reply-To: References: Message-ID: erik.pilkington updated this revision to Diff 275759. erik.pilkington marked 3 inline comments as done. erik.pilkington added a comment. Add an off-by-default variant of this warning. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82611/new/ https://reviews.llvm.org/D82611 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaExprObjC.cpp clang/test/SemaObjC/potentially-direct-selector.m -------------- next part -------------- A non-text attachment was scrubbed... Name: D82611.275759.patch Type: text/x-patch Size: 15290 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 12:54:30 2020 From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:30 +0000 (UTC) Subject: [PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods In-Reply-To: References: Message-ID: erik.pilkington added a comment. In D82611#2125868 , @MadCoder wrote: > So the risk with that one is that if someone had say the `-didSomething` direct selector and that some UIKit/Apple SDK API now adds this as a thing that you use with CFNotification center for example, where you _need_ dynamism, then the uses of the API would warn all the time when the internal to the client project `-didSomething` is in scope. > > So we ideally need a way to silence this warning, so at the very least this needs to be a new `-W` flag (on by default (?)) so that callers that have an issue can use a `_Pragma` at the call site to ignore the error for when it's legal. The `DiagGroup<"potentially-direct-selector">` creates a command line flag, so the pragma thing works. I couldn't think of a decent way of suppressing this without pragmas, but ISTM that this will have a low enough false-positive rate that it won't be a big problem. > I would suggest something like `-Wstrict-direct-dispatch` or something. I kinda prefer `-Wpotentially-direct-selector`, since that seems to more closely correspond to what the compiler is complaining about. WDYT? ================ Comment at: clang/test/SemaObjC/potentially-direct-selector.m:84 + (void)@selector(inBaseCat); + (void)@selector(inBaseCatImpl); + (void)@selector(inDerived); ---------------- MadCoder wrote: > I think this might be too weak, if we add a warning then maybe what we want is a tri-state: > > `-Wstrict-direct-dispatch=none|self|all` > > because I can see cases where the heuristic here would be too weak Sure - new patch adds an off-by-default "strict" variant, since I think that's a bit more common in clang then the `-Wx=y` approach. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82611/new/ https://reviews.llvm.org/D82611 From cfe-commits at lists.llvm.org Mon Jul 6 12:54:30 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:54:30 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: <813ec217f50645afbabc707c524e5ef1@localhost.localdomain> aaron.ballman added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:82 "bugprone-bool-pointer-implicit-conversion"); - CheckFactories.registerCheck( - "bugprone-branch-clone"); + CheckFactories.registerCheck("bugprone-branch-clone"); CheckFactories.registerCheck( ---------------- It looks like unrelated formatting changes may have snuck in? ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:121 "bugprone-narrowing-conversions"); + CheckFactories.registerCheck("bugprone-no-escape"); CheckFactories.registerCheck( ---------------- Given that this is limited to Objective-C, why register this under `bugprone` as opposed to the `objc` module? Alternatively, why limit to Objective-C when blocks can be used in other modes like C or C++ with `-fblocks`? ================ Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:34 + const BlockDecl *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl(); + for (const BlockDecl::Capture &CapturedVar : EscapingBlockDecl->captures()) { + const VarDecl *Var = CapturedVar.getVariable(); ---------------- This makes me think we should extend the `hasAnyCaptures()` AST matcher so it works with blocks as well as lambdas. It would be nice to do all of this from the matcher interface. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:37 + if (Var && Var->hasAttr()) { + diag(MatchedEscapingBlock->getBeginLoc(), + "pointer %0 with attribute 'noescape' is captured by an " ---------------- Given that the capture is the issue (not the block), why not point to the use of the captured variable? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Mon Jul 6 12:57:56 2020 From: cfe-commits at lists.llvm.org (George Burgess IV via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 19:57:56 +0000 (UTC) Subject: [PATCH] D83144: Allow to specify macro names for android-comparison-in-temp-failure-retry. In-Reply-To: References: Message-ID: <348dde67164b5e5150c71bf13a0fc811@localhost.localdomain> george.burgess.iv added a reviewer: alexfh. george.burgess.iv added a comment. Concept and implementation LGTM. Please wait for comment from +alexfh before landing, since I think they have more ownership over clang-tidy in general than I do :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83144/new/ https://reviews.llvm.org/D83144 From cfe-commits at lists.llvm.org Mon Jul 6 12:58:25 2020 From: cfe-commits at lists.llvm.org (=?UTF-8?Q?Nicolai_H=C3=A4hnle?= via cfe-commits) Date: Mon, 06 Jul 2020 12:58:25 -0700 (PDT) Subject: [clang] 723a44c - DomTree: Remove the releaseMemory() method Message-ID: <5f038261.1c69fb81.eaf2.2ca8@mx.google.com> Author: Nicolai Hähnle Date: 2020-07-06T21:58:11+02:00 New Revision: 723a44c9b5d654ec791720fc450757ae00f9e631 URL: https://github.com/llvm/llvm-project/commit/723a44c9b5d654ec791720fc450757ae00f9e631 DIFF: https://github.com/llvm/llvm-project/commit/723a44c9b5d654ec791720fc450757ae00f9e631.diff LOG: DomTree: Remove the releaseMemory() method Summary: It is fully redundant with reset(). Change-Id: I25850b9f08eace757cf03cbb8780e970aca7f51a Reviewers: arsenm, RKSimon, mehdi_amini, courbet Subscribers: wdng, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D83084 Added: Modified: clang/include/clang/Analysis/Analyses/Dominators.h llvm/include/llvm/Analysis/PostDominators.h llvm/include/llvm/IR/Dominators.h llvm/include/llvm/Support/GenericDomTree.h Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/Analyses/Dominators.h b/clang/include/clang/Analysis/Analyses/Dominators.h index 061c98137da2..51d86f6e4540 100644 --- a/clang/include/clang/Analysis/Analyses/Dominators.h +++ b/clang/include/clang/Analysis/Analyses/Dominators.h @@ -167,9 +167,7 @@ class CFGDominatorTreeImpl : public ManagedAnalysis { } /// Releases the memory held by the dominator tree. - virtual void releaseMemory() { - DT.releaseMemory(); - } + virtual void releaseMemory() { DT.reset(); } /// Converts the dominator tree to human readable form. virtual void print(raw_ostream &OS, const llvm::Module* M= nullptr) const { diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h index 801eb3d59673..296110d8d03b 100644 --- a/llvm/include/llvm/Analysis/PostDominators.h +++ b/llvm/include/llvm/Analysis/PostDominators.h @@ -88,9 +88,7 @@ struct PostDominatorTreeWrapperPass : public FunctionPass { AU.setPreservesAll(); } - void releaseMemory() override { - DT.releaseMemory(); - } + void releaseMemory() override { DT.reset(); } void print(raw_ostream &OS, const Module*) const override; }; diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h index a79be8779b7e..0084ac0b655a 100644 --- a/llvm/include/llvm/IR/Dominators.h +++ b/llvm/include/llvm/IR/Dominators.h @@ -277,7 +277,7 @@ class DominatorTreeWrapperPass : public FunctionPass { AU.setPreservesAll(); } - void releaseMemory() override { DT.releaseMemory(); } + void releaseMemory() override { DT.reset(); } void print(raw_ostream &OS, const Module *M = nullptr) const override; }; diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index d93293864a65..e83e7aa39e7a 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -325,8 +325,6 @@ class DominatorTreeBase { return false; } - void releaseMemory() { reset(); } - /// getNode - return the (Post)DominatorTree node for the specified basic /// block. This is the same as using operator[] on this class. The result /// may (but is not required to) be null for a forward (backwards) @@ -760,9 +758,6 @@ class DominatorTreeBase { return DomTreeBuilder::Verify(*this, VL); } -protected: - void addRoot(NodeT *BB) { this->Roots.push_back(BB); } - void reset() { DomTreeNodes.clear(); Roots.clear(); @@ -772,6 +767,9 @@ class DominatorTreeBase { SlowQueries = 0; } +protected: + void addRoot(NodeT *BB) { this->Roots.push_back(BB); } + // NewBB is split and now it has one successor. Update dominator tree to // reflect this change. template From cfe-commits at lists.llvm.org Mon Jul 6 12:58:27 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 19:58:27 +0000 (UTC) Subject: [PATCH] D83084: DomTree: Remove the releaseMemory() method In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG723a44c9b5d6: DomTree: Remove the releaseMemory() method (authored by nhaehnle). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83084/new/ https://reviews.llvm.org/D83084 Files: clang/include/clang/Analysis/Analyses/Dominators.h llvm/include/llvm/Analysis/PostDominators.h llvm/include/llvm/IR/Dominators.h llvm/include/llvm/Support/GenericDomTree.h Index: llvm/include/llvm/Support/GenericDomTree.h =================================================================== --- llvm/include/llvm/Support/GenericDomTree.h +++ llvm/include/llvm/Support/GenericDomTree.h @@ -325,8 +325,6 @@ return false; } - void releaseMemory() { reset(); } - /// getNode - return the (Post)DominatorTree node for the specified basic /// block. This is the same as using operator[] on this class. The result /// may (but is not required to) be null for a forward (backwards) @@ -760,9 +758,6 @@ return DomTreeBuilder::Verify(*this, VL); } -protected: - void addRoot(NodeT *BB) { this->Roots.push_back(BB); } - void reset() { DomTreeNodes.clear(); Roots.clear(); @@ -772,6 +767,9 @@ SlowQueries = 0; } +protected: + void addRoot(NodeT *BB) { this->Roots.push_back(BB); } + // NewBB is split and now it has one successor. Update dominator tree to // reflect this change. template Index: llvm/include/llvm/IR/Dominators.h =================================================================== --- llvm/include/llvm/IR/Dominators.h +++ llvm/include/llvm/IR/Dominators.h @@ -277,7 +277,7 @@ AU.setPreservesAll(); } - void releaseMemory() override { DT.releaseMemory(); } + void releaseMemory() override { DT.reset(); } void print(raw_ostream &OS, const Module *M = nullptr) const override; }; Index: llvm/include/llvm/Analysis/PostDominators.h =================================================================== --- llvm/include/llvm/Analysis/PostDominators.h +++ llvm/include/llvm/Analysis/PostDominators.h @@ -88,9 +88,7 @@ AU.setPreservesAll(); } - void releaseMemory() override { - DT.releaseMemory(); - } + void releaseMemory() override { DT.reset(); } void print(raw_ostream &OS, const Module*) const override; }; Index: clang/include/clang/Analysis/Analyses/Dominators.h =================================================================== --- clang/include/clang/Analysis/Analyses/Dominators.h +++ clang/include/clang/Analysis/Analyses/Dominators.h @@ -167,9 +167,7 @@ } /// Releases the memory held by the dominator tree. - virtual void releaseMemory() { - DT.releaseMemory(); - } + virtual void releaseMemory() { DT.reset(); } /// Converts the dominator tree to human readable form. virtual void print(raw_ostream &OS, const llvm::Module* M= nullptr) const { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83084.275805.patch Type: text/x-patch Size: 2424 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 13:02:46 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 20:02:46 +0000 (UTC) Subject: [PATCH] D83088: Introduce CfgTraits abstraction In-Reply-To: References: Message-ID: <65bacd0bc0f6fb64125cc2fe2e029694@localhost.localdomain> nhaehnle updated this revision to Diff 275811. nhaehnle marked 4 inline comments as done. nhaehnle added a comment. - fix MachineCfgTraits::blockdef_iterator and allow it to iterate over the instructions in a bundle - use MachineBasicBlock::printName Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83088/new/ https://reviews.llvm.org/D83088 Files: clang/include/clang/Analysis/Analyses/Dominators.h llvm/include/llvm/CodeGen/MachineCfgTraits.h llvm/include/llvm/IR/CFG.h llvm/include/llvm/Support/CfgTraits.h llvm/lib/CodeGen/CMakeLists.txt llvm/lib/CodeGen/MachineCfgTraits.cpp llvm/lib/IR/CFG.cpp llvm/lib/IR/CMakeLists.txt llvm/lib/Support/CMakeLists.txt llvm/lib/Support/CfgTraits.cpp llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h mlir/include/mlir/IR/Dominance.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D83088.275811.patch Type: text/x-patch Size: 34804 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 13:04:06 2020 From: cfe-commits at lists.llvm.org (James Y Knight via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:04:06 +0000 (UTC) Subject: [PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path In-Reply-To: References: Message-ID: <291e1154f4055e2cb38eb1562830f7db@localhost.localdomain> jyknight added a comment. BTW, I just noticed recently that we have a -mlinker-version= flag, too, which is only used on darwin at the moment. That's another instance of "we need to condition behavior based on what linker we're invoking", but in this case, between multiple versions of apple's linker, rather than which brand of linker. That doesn't impact this directly, but just thought I'd mention it as it's in the same area of concern. ================ Comment at: clang/lib/Driver/ToolChain.cpp:556-557 + // -fld-path= takes precedence over -fuse-ld= and specifies the executable + // name. PATH is consulted if the value does not contain /. -B is + // intentionally ignored. + if (const Arg *A = Args.getLastArg(options::OPT_fld_path_EQ)) { ---------------- Shouldn't this use -B paths? Why do we want to ignore them? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83015/new/ https://reviews.llvm.org/D83015 From cfe-commits at lists.llvm.org Mon Jul 6 13:05:53 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 20:05:53 +0000 (UTC) Subject: [PATCH] D83088: Introduce CfgTraits abstraction In-Reply-To: References: Message-ID: <0c5020d437ce50bbdbe58b13d108c85e@localhost.localdomain> nhaehnle added inline comments. ================ Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:133 + ++m_def; + if (m_def == m_instr->defs().end()) { + ++m_instr; ---------------- arsenm wrote: > != return early? The logic is actually subtly broken in the presence of instructions without defs, I just didn't notice it because it currently affects only debug printing logic. Going to fix it. ================ Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:136-138 + // Prefer to avoid support for bundled instructions as long as we + // don't really need it. + assert(!m_instr->isBundle()); ---------------- arsenm wrote: > I've been thinking about more aggressively using bundles around call sites to handle waterfall looping around divergent calls with SGPR arguments Hmm, so what's the correct iteration behavior in the presence of bundles? Iterate over all instructions in the bundle (which is that MachineBasicBlock::instr_iterator does) and only iterate over explicit defs? I think that's what makes the most sense, and what I'm going with for now... ================ Comment at: llvm/lib/CodeGen/MachineCfgTraits.cpp:27-29 +void MachineCfgTraits::Printer::printBlockName(raw_ostream &out, + MachineBasicBlock *block) const { + out << "bb." << block->getNumber(); ---------------- arsenm wrote: > I think this should be added to MachineBasicBlock. The same logic is already repeated in MIRPrinter (and the MBB dump function uses a different prefix) D83253 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83088/new/ https://reviews.llvm.org/D83088 From cfe-commits at lists.llvm.org Mon Jul 6 13:11:31 2020 From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:11:31 +0000 (UTC) Subject: [PATCH] D83254: [X86] Enabled a bunch of 64-bit Interlocked* functions intrinsics on 32-bit Windows to match recent MSVC Message-ID: craig.topper created this revision. craig.topper added reviewers: RKSimon, spatel, rnk, erichkeane. Herald added a subscriber: jfb. This enables _InterlockedAnd64/_InterlockedOr64/_InterlockedXor64/_InterlockedDecrement64/_InterlockedIncrement64/_InterlockedExchange64/_InterlockedExchangeAdd64/_InterlockedExchangeSub64 on 32-bit Windows The backend already knows how to expand these to a loop using cmpxchg8b on 32-bit targets. Fixes PR46595 https://reviews.llvm.org/D83254 Files: clang/include/clang/Basic/BuiltinsX86.def clang/include/clang/Basic/BuiltinsX86_64.def clang/lib/Headers/intrin.h clang/test/CodeGen/ms-intrinsics.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83254.275816.patch Type: text/x-patch Size: 8795 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 13:12:22 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:12:22 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: <588eccc8ae73df9206722b2a082955a2@localhost.localdomain> dblaikie added a comment. In D82728#2133951 , @Quuxplusone wrote: > In D82728#2133720 , @dblaikie wrote: > > > (the presence of at least one "override" being a signal the user intended to use override and missed some [...] > > > I'm in favor of `-Wsuggest-override`, and would definitely use it if it existed. I've no doubt a non-trivial number of folks would - we'd probably enable it in LLVM itself. > The problem I see with `-Wmissing-override`, as it's been implemented, is that it uses the wrong granularity for "intent": it looks only across the methods of a single class, rather than across all the classes of a single header, or across a single translation unit, or across my entire codebase. In real life, I //always// want to look across my entire codebase (excluding system headers). If //any// class in my project uses `override`, I want Clang to take that as a clear declaration of intent to use `override` throughout; I don't want Clang treating class A differently from class B. But of course Clang can't look at my whole codebase simultaneously. Right - Clang's doing its best (well, debatable - that's what we're debating) with what it's got. > So the next best thing is to give the user a simple way to "preload the intent flag": to say "As soon as you start processing //any// class, please act as if intent has been declared for that class." Adding `-Wsuggest-override` to my build line seems like a perfect way to implement that "preload" facility. The issue is that such a warning then needs to be off by default, because we can't assume the user's intent. And Clang's historically been fairly averse to off-by-default warnings due to low user-penetration (not zero, like I said, I imagine LLVM itself would use such a warning, were it implemented) & so concerns about the cost/benefit tradeoff of the added complexity (source code and runtime) of the feature. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Mon Jul 6 13:19:47 2020 From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:19:47 +0000 (UTC) Subject: [PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional operator In-Reply-To: References: Message-ID: <8351849f43a2892391d56b5e055a4f49@localhost.localdomain> erik.pilkington added a reviewer: ahatanak. erik.pilkington added a comment. Ping! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81751/new/ https://reviews.llvm.org/D81751 From cfe-commits at lists.llvm.org Mon Jul 6 13:27:54 2020 From: cfe-commits at lists.llvm.org (Zixu Wang via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:27:54 +0000 (UTC) Subject: [PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver In-Reply-To: References: Message-ID: <331cec0f05a9ba2875e87a5175b969df@localhost.localdomain> zixuw updated this revision to Diff 275821. zixuw added a comment. Add a test case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83250/new/ https://reviews.llvm.org/D83250 Files: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/darwin-warning-options.c Index: clang/test/Driver/darwin-warning-options.c =================================================================== --- /dev/null +++ clang/test/Driver/darwin-warning-options.c @@ -0,0 +1,7 @@ +// REQUIRES: system-darwin + +// Always error about undefined 'TARGET_OS_*' macros on Darwin. +// RUN: %clang -### %s 2>&1 | FileCheck %s + +// CHECK-DAG: "-Wundef-prefix=TARGET_OS_" +// CHECK-DAG: "-Werror=undef-prefix" Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -954,6 +954,10 @@ : Darwin(D, Triple, Args) {} void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const { + // Always error about undefined 'TARGET_OS_*' macros. + CC1Args.push_back("-Wundef-prefix=TARGET_OS_"); + CC1Args.push_back("-Werror=undef-prefix"); + // For modern targets, promote certain warnings to errors. if (isTargetWatchOSBased() || getTriple().isArch64Bit()) { // Always enable -Wdeprecated-objc-isa-usage and promote it -------------- next part -------------- A non-text attachment was scrubbed... Name: D83250.275821.patch Type: text/x-patch Size: 1093 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 13:33:18 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:33:18 +0000 (UTC) Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default In-Reply-To: References: Message-ID: <9db1d39bbce26431db4fe92bb6ab8565@localhost.localdomain> tra added inline comments. ================ Comment at: clang/lib/Sema/SemaLambda.cpp:1783 + + if (LangOpts.CUDA && LangOpts.CUDAIsDevice) + CUDACheckLambdaCapture(CallOperator, From); ---------------- yaxunl wrote: > tra wrote: > > I would expect Sema-level diags to be produced during both host and device compilation. Some of the diags for HD may need to be postponed until after things have been CodeGen'ed, but the checks should happen nevertheless. > > > > > A host device function could be emitted in both host and device compilation. The way the deferred diags works is that they are only emitted when the function is sure to be emitted in a specific compilation. In host compilation, when a host device function is sure to be emitted, it is emitted as host function, therefore diags for host compilation and only diags for host compilation should be emitted. The same with device compilation. > > This makes sense since we do not know if a host device function will be emitted in device compilation when we are doing host compilation, since to do that we have to go through the whole device compilation whereas currently device compilation and host compilation are separate process. > > That said, when we emit diags for captures by reference, we should only emit them when the lambdas are emitted as device functions. When they are emitted as host functions in host compilation, these captures are valid and should not be diagnosed. HD lambda capturing something that's side-specific is similar to HD function calling side-specific function. I still think that the general principle applies to both sides of the compilation. We may be saved by the fact that functions seem to be the only things that are truly side-specific and wrong-side access will already produce postponed diagnostics. For variables we'll end up capturing shadows, which is in the gray area -- we're allowed to use pointers & sizeof(), but not the non-const values. Perhaps this condition check should be folded into the `CUDACheckLambdaCapture` and add few comments about the reasons for particular OK/not-OK choices we make there. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78655/new/ https://reviews.llvm.org/D78655 From cfe-commits at lists.llvm.org Mon Jul 6 13:36:57 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:36:57 +0000 (UTC) Subject: [PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types In-Reply-To: References: Message-ID: <95eeb395a50c10c0bae2dda6788fcef3@localhost.localdomain> dblaikie added inline comments. ================ Comment at: clang/lib/CodeGen/CGDecl.cpp:103-118 + case Decl::CXXRecord: // struct/union/class X; [C++] + if (CGDebugInfo *DI = getDebugInfo()) + if (CGM.getCodeGenOpts().hasMaybeUnusedDebugInfo() && + cast(D).hasDefinition()) + DI->completeUnusedClass(cast(D)); + return; case Decl::Record: // struct/union/class X; ---------------- nickdesaulniers wrote: > nickdesaulniers wrote: > > dblaikie wrote: > > > All of these might be able to be collapsed together - using "cast(D).hasDefinition()" ... to have a common implementation. > > `TagDecl` doesn't have a method `hasDefinition`. Only `CXXRecordDecl` does. > Also, how to get the `QualType` differs between `Decl::Enum` an `Decl::Record`; `getEnumType` vs `getRecordType` respectively. Looks like ASTContext::getTypeDeclType could be used, if it makes things especially tidier. But perhaps the TagDecl/hasDefinition difference is enough for it not to be especially significant. ================ Comment at: clang/lib/CodeGen/CGDecl.cpp:116 + if (CGDebugInfo *DI = getDebugInfo()) + if (cast(&D)->getDefinition()) + DI->EmitAndRetainType(getContext().getEnumType(cast(&D))); ---------------- nickdesaulniers wrote: > dblaikie wrote: > > I think the right thing to call here (& the other places in this patch) is "hasDefinition" rather than "getDefinition" (this will avoid the definition being deserialized when it's not needed yet (then if we don't end up emitting the type because the flag hasn't been given, it won't be deserialized unnecessarily)) > `TagDecl` doesn't have a method `hasDefinition`. Only `CXXRecordDecl` does. Ah, fair enough! ================ Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5385 + if (getCodeGenOpts().hasMaybeUnusedDebugInfo() && CRD->hasDefinition()) + DI->completeUnusedClass(*CRD); + else if (auto *ES = D->getASTContext().getExternalSource()) ---------------- nickdesaulniers wrote: > dblaikie wrote: > > I think this might not work as intended if the type trips over the other class deduplication optimizations (try manually testing with a type that has an external VTable?) - and perhaps this codepath should use the EmitAndRetain functionality. > completeUnusedClass eventually calls into CGDebugInfo::completeClass which makes use of the TypeCache. What does it mean for a class to have "an external vtable?" Can you give me an example? Here's some sample code that uses a type in the DWARF but due to the vtable being external (an external vtable is one that's guaranteed to be emitted in some other object file - due to the key function optimization in the Itanium ABI - since all virtual functions must be defined if a type is ODR used, the compiler can make a shared assumption that the vtable will only be emitted with a single consistently chosen virtual function (ideally: the first non-inline one) and emit the vtable only in that object and nowhere else) the type is emitted as a declaration (when using "-fno-standalone-debug"): ``` struct t1 { virtual void f1(); }; t1 v1; ``` ================ Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3825-3828 + if (EmitDwarf && + Args.hasFlag(options::OPT_fno_eliminate_unused_debug_types, + options::OPT_feliminate_unused_debug_types, false)) + DebugInfoKind = codegenoptions::UnusedTypeInfo; ---------------- How does GCC compose this with -gmlt, for instance? I'd suspect that the desired behavior might be for -gmlt to override this -f flag? So maybe this should be predicated on "if (EmitDwarf && DebugInfoKind >= codegenoptions::LimitedDebugInfo && ... "? (so if someone wants to use only -gmlt in certain parts of their build that doesn't get upgraded by the presence of this -f flag) ================ Comment at: clang/test/CodeGen/debug-info-unused-types.c:46-60 +struct aaaaaaaaaaaa; +enum bbbbbbbbbbbb; +union cccccccccccc; +void b0(void) { + struct dddddddddddd; + enum eeeeeeeeeeee; + union ffffffffffff; ---------------- Maybe give these more specific names (similarly in the other test) - and/or you could use a pattern in the naming that might make the -NOT lines easier? eg: ``` struct decl_struct; enum decl_enum; ... // NODBG-NOT: name: "decl_ ``` (also best to include a bit more context in the -NOT checks, otherwise there's risk that a users build directory (even with these longer names) or other paths might accidentally fail the checks) ================ Comment at: clang/test/CodeGen/debug-info-unused-types.cpp:15-21 +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz" +// CHECK: !DIEnumerator(name: "BAZ" +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z" +// CHECK: !DIEnumerator(name: "Z" +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo" +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar" +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y" ---------------- Probably good to check these end up in the retained types list ================ Comment at: clang/test/CodeGen/debug-info-unused-types.cpp:23-29 +// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz" +// NODBG-NOT: !DIEnumerator(name: "BAZ" +// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z" +// NODBG-NOT: !DIEnumerator(name: "Z" +// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo" +// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar" +// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y" ---------------- With a uniform naming scheme, perhaps this could be `// NODBG-NOT: name: "unused_` ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80242/new/ https://reviews.llvm.org/D80242 From cfe-commits at lists.llvm.org Mon Jul 6 13:37:28 2020 From: cfe-commits at lists.llvm.org (Andrii Nakryiko via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:37:28 +0000 (UTC) Subject: [PATCH] D83242: [RFC][BPF] support expr with typedef type for FIELD_EXISTENCE reloc In-Reply-To: References: Message-ID: anakryiko added a comment. Awesome, that's exactly what we need for BPF helper availability checks! Can you please also add test that this pattern works: return __builtin_preserve_field_info((btf_bpf_read_branch_records)0, FIELD_EXISTENCE); Also for non-func pointer typedefs, something like this would work as well, right? return __builtin_preserve_field_info(*(T *)0, FIELD_EXISTENCE); Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83242/new/ https://reviews.llvm.org/D83242 From cfe-commits at lists.llvm.org Mon Jul 6 13:38:03 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:38:03 +0000 (UTC) Subject: [PATCH] D83188: [clang-tidy] bugprone-bool-pointer-implicit-conversion doesn't handle members In-Reply-To: References: Message-ID: <67d748d1b0a0f2628e91b4a6f798887b@localhost.localdomain> njames93 added a comment. Thanks for working on this. There seems to be many places in this check where names are confusing, `Var` referring to a `MemberExpr`, `DeclRef` refering to a `MemberExpr`. I'd prefer if the names that you have added were renamed to something more in line with what they represent. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp:82 + + if (const auto *Var = Result.Nodes.getNodeAs("expr")) { + const Decl *D = Var->getMemberDecl(); ---------------- This should be an `else if` or the previous `if` should return. Saves redundant checking for `MemberExpr` when `DeclRefExpr` already matched. ================ Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-bool-pointer-implicit-conversion.cpp:108-126 + if (d.b) { + *d.b = true; // no-warning + } + + if (d.b) { + d.b[0] = false; // no-warning + } ---------------- nit: You don't need to recycle all the test cases, the logic for that is already checked above, just a few showing member expr being detected properly will suffice. Don't have huge preference on this so feel free to ignore. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83188/new/ https://reviews.llvm.org/D83188 From cfe-commits at lists.llvm.org Mon Jul 6 13:49:51 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:49:51 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <6050b228f4af924cbbaeede91b4b397b@localhost.localdomain> arsenm added inline comments. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167 + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile) ---------------- yaxunl wrote: > arsenm wrote: > > arsenm wrote: > > > yaxunl wrote: > > > > arsenm wrote: > > > > > I don't think the detection should fail if this is missing > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken. > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > what is the directory structure of your most modern layout? /opt/rocm/amdgcn/bitcode/foo.bc The plan is to remove this and rely on symlinks in the resource directory though CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Mon Jul 6 13:51:30 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:51:30 +0000 (UTC) Subject: [PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path In-Reply-To: References: Message-ID: <3be7345701f08ae619090787647b47f9@localhost.localdomain> MaskRay marked an inline comment as done. MaskRay added inline comments. ================ Comment at: clang/lib/Driver/ToolChain.cpp:556-557 + // -fld-path= takes precedence over -fuse-ld= and specifies the executable + // name. PATH is consulted if the value does not contain /. -B is + // intentionally ignored. + if (const Arg *A = Args.getLastArg(options::OPT_fld_path_EQ)) { ---------------- jyknight wrote: > Shouldn't this use -B paths? Why do we want to ignore them? If the value is relative, respect -Bprefix and COMPILER_PATH? (COMPILER is currently not well supported in clang IIUC) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83015/new/ https://reviews.llvm.org/D83015 From cfe-commits at lists.llvm.org Mon Jul 6 13:51:41 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:51:41 +0000 (UTC) Subject: [PATCH] D83088: Introduce CfgTraits abstraction In-Reply-To: References: Message-ID: <677855f6a5f690f56731b38971d4d80c@localhost.localdomain> arsenm added inline comments. ================ Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:136-138 + // Prefer to avoid support for bundled instructions as long as we + // don't really need it. + assert(!m_instr->isBundle()); ---------------- nhaehnle wrote: > arsenm wrote: > > I've been thinking about more aggressively using bundles around call sites to handle waterfall looping around divergent calls with SGPR arguments > Hmm, so what's the correct iteration behavior in the presence of bundles? Iterate over all instructions in the bundle (which is that MachineBasicBlock::instr_iterator does) and only iterate over explicit defs? I think that's what makes the most sense, and what I'm going with for now... I don't think this actually needs to specially consider bundles. The BUNDLE itself is supposed to have the uses/defs that cover all the uses/defs inside the bundle. You shouldn't need to worry about the individual instructions Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83088/new/ https://reviews.llvm.org/D83088 From cfe-commits at lists.llvm.org Mon Jul 6 13:57:46 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 20:57:46 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <1913ef2e5c3ec46499af2b5025794ea7@localhost.localdomain> tra added inline comments. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167 + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile) ---------------- arsenm wrote: > yaxunl wrote: > > arsenm wrote: > > > arsenm wrote: > > > > yaxunl wrote: > > > > > arsenm wrote: > > > > > > I don't think the detection should fail if this is missing > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken. > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > what is the directory structure of your most modern layout? > /opt/rocm/amdgcn/bitcode/foo.bc > > The plan is to remove this and rely on symlinks in the resource directory though > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code. It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Mon Jul 6 14:00:32 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:00:32 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <290aa15b9f42bf5513de3fd8d3795cdd@localhost.localdomain> yaxunl marked 4 inline comments as done. yaxunl added inline comments. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167 + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile) ---------------- tra wrote: > arsenm wrote: > > yaxunl wrote: > > > arsenm wrote: > > > > arsenm wrote: > > > > > yaxunl wrote: > > > > > > arsenm wrote: > > > > > > > I don't think the detection should fail if this is missing > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken. > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > what is the directory structure of your most modern layout? > > /opt/rocm/amdgcn/bitcode/foo.bc > > > > The plan is to remove this and rely on symlinks in the resource directory though > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code. > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version. > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary. Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Mon Jul 6 14:02:46 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:02:46 +0000 (UTC) Subject: [PATCH] D83015: [Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path In-Reply-To: References: Message-ID: <5efacda5fdba79b32d97409ea7dea479@localhost.localdomain> MaskRay marked an inline comment as done. MaskRay added inline comments. ================ Comment at: clang/lib/Driver/ToolChain.cpp:556-557 + // -fld-path= takes precedence over -fuse-ld= and specifies the executable + // name. PATH is consulted if the value does not contain /. -B is + // intentionally ignored. + if (const Arg *A = Args.getLastArg(options::OPT_fld_path_EQ)) { ---------------- MaskRay wrote: > jyknight wrote: > > Shouldn't this use -B paths? Why do we want to ignore them? > If the value is relative, respect -Bprefix and COMPILER_PATH? (COMPILER is currently not well supported in clang IIUC) D80660's need is an option relative to the current working directory... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83015/new/ https://reviews.llvm.org/D83015 From cfe-commits at lists.llvm.org Mon Jul 6 14:02:48 2020 From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:02:48 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: <095e27438cea3df1bac1dc82fe1058e3@localhost.localdomain> ellis updated this revision to Diff 275826. ellis marked 9 inline comments as done. ellis added a comment. Use `LangOpts.Blocks` instead of `LangOpts.ObjC` and add FIXME about grabbing the use location of a `CapturedVar`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 Files: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m -------------- next part -------------- A non-text attachment was scrubbed... Name: D82904.275826.patch Type: text/x-patch Size: 9958 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:03:50 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via cfe-commits) Date: Mon, 06 Jul 2020 14:03:50 -0700 (PDT) Subject: [clang] f63e3ea - [clang] Rework how and when APValues are dumped Message-ID: <5f0391b6.1c69fb81.517d9.1105@mx.google.com> Author: Bruno Ricci Date: 2020-07-06T22:03:08+01:00 New Revision: f63e3ea558bbe14826b5b775367eac617b35e041 URL: https://github.com/llvm/llvm-project/commit/f63e3ea558bbe14826b5b775367eac617b35e041 DIFF: https://github.com/llvm/llvm-project/commit/f63e3ea558bbe14826b5b775367eac617b35e041.diff LOG: [clang] Rework how and when APValues are dumped Currently APValues are dumped as a single string. This becomes quickly completely unreadable since APValue is a tree-like structure. Even a simple example is not pretty: struct S { int arr[4]; float f; }; constexpr S s = { .arr = {1,2}, .f = 3.1415f }; // Struct fields: Array: Int: 1, Int: 2, 2 x Int: 0, Float: 3.141500e+00 With this patch this becomes: -Struct |-field: Array size=4 | |-elements: Int 1, Int 2 | `-filler: 2 x Int 0 `-field: Float 3.141500e+00 Additionally APValues are currently only dumped as part of visiting a ConstantExpr. This patch also dump the value of the initializer of constexpr variable declarations: constexpr int foo(int a, int b) { return a + b - 42; } constexpr int a = 1, b = 2; constexpr int c = foo(a, b) > 0 ? foo(a, b) : foo(b, a); // VarDecl 0x62100008aec8 col:17 c 'const int' constexpr cinit // |-value: Int -39 // `-ConditionalOperator 0x62100008b4d0 'int' // Do the above by moving the dump functions to TextNodeDumper which already has the machinery to display trees. The cases APValue::LValue, APValue::MemberPointer and APValue::AddrLabelDiff are left as they were before (unimplemented). We try to display multiple elements on the same line if they are considered to be "simple". This is to avoid wasting large amounts of vertical space in an example like: constexpr int arr[8] = {0,1,2,3,4,5,6,7}; // VarDecl 0x62100008bb78 col:17 arr 'int const[8]' constexpr cinit // |-value: Array size=8 // | |-elements: Int 0, Int 1, Int 2, Int 3 // | `-elements: Int 4, Int 5, Int 6, Int 7 Differential Revision: https://reviews.llvm.org/D83183 Reviewed By: aaron.ballman Added: clang/test/AST/ast-dump-APValue-anon-union.cpp clang/test/AST/ast-dump-APValue-arithmetic.cpp clang/test/AST/ast-dump-APValue-array.cpp clang/test/AST/ast-dump-APValue-struct.cpp clang/test/AST/ast-dump-APValue-todo.cpp clang/test/AST/ast-dump-APValue-union.cpp clang/test/AST/ast-dump-APValue-vector.cpp Modified: clang/include/clang/AST/APValue.h clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/JSONNodeDumper.h clang/include/clang/AST/TextNodeDumper.h clang/lib/AST/APValue.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/TextNodeDumper.cpp clang/test/AST/alignas_maybe_odr_cleanup.cpp clang/test/AST/ast-dump-attr.cpp clang/test/AST/ast-dump-color.cpp clang/test/AST/ast-dump-constant-expr.cpp clang/test/AST/ast-dump-decl.cpp clang/test/AST/ast-dump-records.cpp clang/test/AST/ast-dump-stmt.cpp clang/test/AST/pr43983.cpp clang/test/Import/switch-stmt/test.cpp clang/test/Tooling/clang-check-ast-dump.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h index c69974c63c71..cca92b5f8235 100644 --- a/clang/include/clang/AST/APValue.h +++ b/clang/include/clang/AST/APValue.h @@ -372,7 +372,7 @@ class APValue { bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; } void dump() const; - void dump(raw_ostream &OS, const ASTContext *Context) const; + void dump(raw_ostream &OS, const ASTContext &Context) const; void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const; std::string getAsString(const ASTContext &Ctx, QualType Ty) const; diff --git a/clang/include/clang/AST/ASTNodeTraverser.h b/clang/include/clang/AST/ASTNodeTraverser.h index f1c98193df6c..26656b7162b6 100644 --- a/clang/include/clang/AST/ASTNodeTraverser.h +++ b/clang/include/clang/AST/ASTNodeTraverser.h @@ -22,10 +22,13 @@ #include "clang/AST/LocInfoType.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/TemplateArgumentVisitor.h" +#include "clang/AST/Type.h" #include "clang/AST/TypeVisitor.h" namespace clang { +class APValue; + /** ASTNodeTraverser traverses the Clang AST for dumping purposes. @@ -50,6 +53,7 @@ struct { void Visit(const OMPClause *C); void Visit(const BlockDecl::Capture &C); void Visit(const GenericSelectionExpr::ConstAssociation &A); + void Visit(const APValue &Value, QualType Ty); }; */ template @@ -211,6 +215,10 @@ class ASTNodeTraverser }); } + void Visit(const APValue &Value, QualType Ty) { + getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(Value, Ty); }); + } + void Visit(const comments::Comment *C, const comments::FullComment *FC) { getNodeDelegate().AddChild([=] { getNodeDelegate().Visit(C, FC); diff --git a/clang/include/clang/AST/JSONNodeDumper.h b/clang/include/clang/AST/JSONNodeDumper.h index ae7b4c9a17ea..4e7162992418 100644 --- a/clang/include/clang/AST/JSONNodeDumper.h +++ b/clang/include/clang/AST/JSONNodeDumper.h @@ -23,10 +23,13 @@ #include "clang/AST/CommentVisitor.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/Mangle.h" +#include "clang/AST/Type.h" #include "llvm/Support/JSON.h" namespace clang { +class APValue; + class NodeStreamer { bool FirstChild = true; bool TopLevel = true; @@ -201,6 +204,7 @@ class JSONNodeDumper void Visit(const OMPClause *C); void Visit(const BlockDecl::Capture &C); void Visit(const GenericSelectionExpr::ConstAssociation &A); + void Visit(const APValue &Value, QualType Ty); void VisitTypedefType(const TypedefType *TT); void VisitFunctionType(const FunctionType *T); diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index d2ec153ce67c..b4cfb5a380d1 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -22,10 +22,13 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtVisitor.h" #include "clang/AST/TemplateArgumentVisitor.h" +#include "clang/AST/Type.h" #include "clang/AST/TypeVisitor.h" namespace clang { +class APValue; + class TextTreeStructure { raw_ostream &OS; const bool ShowColors; @@ -153,6 +156,12 @@ class TextNodeDumper const char *getCommandName(unsigned CommandID); + void dumpAPValueChildren(const APValue &Value, QualType Ty, + const APValue &(*IdxToChildFun)(const APValue &, + unsigned), + unsigned NumChildren, StringRef LabelSingular, + StringRef LabelPlurial); + public: TextNodeDumper(raw_ostream &OS, const ASTContext &Context, bool ShowColors); TextNodeDumper(raw_ostream &OS, bool ShowColors); @@ -180,6 +189,8 @@ class TextNodeDumper void Visit(const GenericSelectionExpr::ConstAssociation &A); + void Visit(const APValue &Value, QualType Ty); + void dumpPointer(const void *Ptr); void dumpLocation(SourceLocation Loc); void dumpSourceRange(SourceRange R); diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp index 417916241d79..f3828bb54c1d 100644 --- a/clang/lib/AST/APValue.cpp +++ b/clang/lib/AST/APValue.cpp @@ -386,92 +386,6 @@ static double GetApproxValue(const llvm::APFloat &F) { return V.convertToDouble(); } -LLVM_DUMP_METHOD void APValue::dump() const { - dump(llvm::errs(), /*Context=*/nullptr); - llvm::errs() << '\n'; -} - -LLVM_DUMP_METHOD void APValue::dump(raw_ostream &OS, - const ASTContext *Context) const { - switch (getKind()) { - case None: - OS << "None"; - return; - case Indeterminate: - OS << "Indeterminate"; - return; - case Int: - OS << "Int: " << getInt(); - return; - case Float: - OS << "Float: " << GetApproxValue(getFloat()); - return; - case FixedPoint: - OS << "FixedPoint : " << getFixedPoint(); - return; - case Vector: - OS << "Vector: "; - getVectorElt(0).dump(OS, Context); - for (unsigned i = 1; i != getVectorLength(); ++i) { - OS << ", "; - getVectorElt(i).dump(OS, Context); - } - return; - case ComplexInt: - OS << "ComplexInt: " << getComplexIntReal() << ", " << getComplexIntImag(); - return; - case ComplexFloat: - OS << "ComplexFloat: " << GetApproxValue(getComplexFloatReal()) - << ", " << GetApproxValue(getComplexFloatImag()); - return; - case LValue: - OS << "LValue: "; - return; - case Array: - OS << "Array: "; - for (unsigned I = 0, N = getArrayInitializedElts(); I != N; ++I) { - getArrayInitializedElt(I).dump(OS, Context); - if (I != getArraySize() - 1) - OS << ", "; - } - if (hasArrayFiller()) { - OS << getArraySize() - getArrayInitializedElts() << " x "; - getArrayFiller().dump(OS, Context); - } - return; - case Struct: - OS << "Struct "; - if (unsigned N = getStructNumBases()) { - OS << " bases: "; - getStructBase(0).dump(OS, Context); - for (unsigned I = 1; I != N; ++I) { - OS << ", "; - getStructBase(I).dump(OS, Context); - } - } - if (unsigned N = getStructNumFields()) { - OS << " fields: "; - getStructField(0).dump(OS, Context); - for (unsigned I = 1; I != N; ++I) { - OS << ", "; - getStructField(I).dump(OS, Context); - } - } - return; - case Union: - OS << "Union: "; - getUnionValue().dump(OS, Context); - return; - case MemberPointer: - OS << "MemberPointer: "; - return; - case AddrLabelDiff: - OS << "AddrLabelDiff: "; - return; - } - llvm_unreachable("Unknown APValue kind!"); -} - void APValue::printPretty(raw_ostream &Out, const ASTContext &Ctx, QualType Ty) const { switch (getKind()) { diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp index 08a6d0cbd261..284e5bdbc6b0 100644 --- a/clang/lib/AST/ASTDumper.cpp +++ b/clang/lib/AST/ASTDumper.cpp @@ -270,3 +270,19 @@ LLVM_DUMP_METHOD void Comment::dumpColor() const { ASTDumper Dumper(llvm::errs(), /*ShowColors=*/true); Dumper.Visit(FC, FC); } + +//===----------------------------------------------------------------------===// +// APValue method implementations +//===----------------------------------------------------------------------===// + +LLVM_DUMP_METHOD void APValue::dump() const { + ASTDumper Dumper(llvm::errs(), /*ShowColors=*/false); + Dumper.Visit(*this, /*Ty=*/QualType()); +} + +LLVM_DUMP_METHOD void APValue::dump(raw_ostream &OS, + const ASTContext &Context) const { + ASTDumper Dumper(llvm::errs(), Context, + Context.getDiagnostics().getShowColors()); + Dumper.Visit(*this, /*Ty=*/Context.getPointerType(Context.CharTy)); +} diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp index c9a84a2b7d57..4bd00ece86ab 100644 --- a/clang/lib/AST/JSONNodeDumper.cpp +++ b/clang/lib/AST/JSONNodeDumper.cpp @@ -183,6 +183,13 @@ void JSONNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) { attributeOnlyIfTrue("selected", A.isSelected()); } +void JSONNodeDumper::Visit(const APValue &Value, QualType Ty) { + std::string Str; + llvm::raw_string_ostream OS(Str); + Value.printPretty(OS, Ctx, Ty); + JOS.attribute("value", OS.str()); +} + void JSONNodeDumper::writeIncludeStack(PresumedLoc Loc, bool JustFirst) { if (Loc.isInvalid()) return; @@ -1272,12 +1279,8 @@ void JSONNodeDumper::VisitCXXTypeidExpr(const CXXTypeidExpr *CTE) { } void JSONNodeDumper::VisitConstantExpr(const ConstantExpr *CE) { - if (CE->getResultAPValueKind() != APValue::None) { - std::string Str; - llvm::raw_string_ostream OS(Str); - CE->getAPValueResult().printPretty(OS, Ctx, CE->getType()); - JOS.attribute("value", OS.str()); - } + if (CE->getResultAPValueKind() != APValue::None) + Visit(CE->getAPValueResult(), CE->getType()); } void JSONNodeDumper::VisitInitListExpr(const InitListExpr *ILE) { diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 74966f804fe3..5b0a0ac392c0 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -11,15 +11,20 @@ //===----------------------------------------------------------------------===// #include "clang/AST/TextNodeDumper.h" +#include "clang/AST/APValue.h" #include "clang/AST/DeclFriend.h" #include "clang/AST/DeclOpenMP.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/LocInfoType.h" +#include "clang/AST/Type.h" #include "clang/Basic/Module.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/Specifiers.h" #include "clang/Basic/TypeTraits.h" +#include +#include + using namespace clang; static void dumpPreviousDeclImpl(raw_ostream &OS, ...) {} @@ -350,6 +355,218 @@ void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) { OS << " selected"; } +static double GetApproxValue(const llvm::APFloat &F) { + llvm::APFloat V = F; + bool ignored; + V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven, + &ignored); + return V.convertToDouble(); +} + +/// True if the \p APValue \p Value can be folded onto the current line. +static bool isSimpleAPValue(const APValue &Value) { + switch (Value.getKind()) { + case APValue::None: + case APValue::Indeterminate: + case APValue::Int: + case APValue::Float: + case APValue::FixedPoint: + case APValue::ComplexInt: + case APValue::ComplexFloat: + case APValue::LValue: + case APValue::MemberPointer: + case APValue::AddrLabelDiff: + return true; + case APValue::Vector: + case APValue::Array: + case APValue::Struct: + return false; + case APValue::Union: + return isSimpleAPValue(Value.getUnionValue()); + } + llvm_unreachable("unexpected APValue kind!"); +} + +/// Dump the children of the \p APValue \p Value. +/// +/// \param[in] Value The \p APValue to visit +/// \param[in] Ty The \p QualType passed to \p Visit +/// +/// \param[in] IdxToChildFun A function mapping an \p APValue and an index +/// to one of the child of the \p APValue +/// +/// \param[in] NumChildren \p IdxToChildFun will be called on \p Value with +/// the indices in the range \p [0,NumChildren( +/// +/// \param[in] LabelSingular The label to use on a line with a single child +/// \param[in] LabelPlurial The label to use on a line with multiple children +void TextNodeDumper::dumpAPValueChildren( + const APValue &Value, QualType Ty, + const APValue &(*IdxToChildFun)(const APValue &, unsigned), + unsigned NumChildren, StringRef LabelSingular, StringRef LabelPlurial) { + // To save some vertical space we print up to MaxChildrenPerLine APValues + // considered to be simple (by isSimpleAPValue) on a single line. + constexpr unsigned MaxChildrenPerLine = 4; + unsigned I = 0; + while (I < NumChildren) { + unsigned J = I; + while (J < NumChildren) { + if (isSimpleAPValue(IdxToChildFun(Value, J)) && + (J - I < MaxChildrenPerLine)) { + ++J; + continue; + } + break; + } + + J = std::max(I + 1, J); + + // Print [I,J) on a single line. + AddChild(J - I > 1 ? LabelPlurial : LabelSingular, [=]() { + for (unsigned X = I; X < J; ++X) { + Visit(IdxToChildFun(Value, X), Ty); + if (X + 1 != J) + OS << ", "; + } + }); + I = J; + } +} + +void TextNodeDumper::Visit(const APValue &Value, QualType Ty) { + ColorScope Color(OS, ShowColors, ValueKindColor); + switch (Value.getKind()) { + case APValue::None: + OS << "None"; + return; + case APValue::Indeterminate: + OS << "Indeterminate"; + return; + case APValue::Int: + OS << "Int "; + { + ColorScope Color(OS, ShowColors, ValueColor); + OS << Value.getInt(); + } + return; + case APValue::Float: + OS << "Float "; + { + ColorScope Color(OS, ShowColors, ValueColor); + OS << GetApproxValue(Value.getFloat()); + } + return; + case APValue::FixedPoint: + OS << "FixedPoint "; + { + ColorScope Color(OS, ShowColors, ValueColor); + OS << Value.getFixedPoint(); + } + return; + case APValue::Vector: { + unsigned VectorLength = Value.getVectorLength(); + OS << "Vector length=" << VectorLength; + + dumpAPValueChildren( + Value, Ty, + [](const APValue &Value, unsigned Index) -> const APValue & { + return Value.getVectorElt(Index); + }, + VectorLength, "element", "elements"); + return; + } + case APValue::ComplexInt: + OS << "ComplexInt "; + { + ColorScope Color(OS, ShowColors, ValueColor); + OS << Value.getComplexIntReal() << " + " << Value.getComplexIntImag() + << 'i'; + } + return; + case APValue::ComplexFloat: + OS << "ComplexFloat "; + { + ColorScope Color(OS, ShowColors, ValueColor); + OS << GetApproxValue(Value.getComplexFloatReal()) << " + " + << GetApproxValue(Value.getComplexFloatImag()) << 'i'; + } + return; + case APValue::LValue: + (void)Context; + OS << "LValue "; + return; + case APValue::Array: { + unsigned ArraySize = Value.getArraySize(); + unsigned NumInitializedElements = Value.getArrayInitializedElts(); + OS << "Array size=" << ArraySize; + + dumpAPValueChildren( + Value, Ty, + [](const APValue &Value, unsigned Index) -> const APValue & { + return Value.getArrayInitializedElt(Index); + }, + NumInitializedElements, "element", "elements"); + + if (Value.hasArrayFiller()) { + AddChild("filler", [=] { + { + ColorScope Color(OS, ShowColors, ValueColor); + OS << ArraySize - NumInitializedElements << " x "; + } + Visit(Value.getArrayFiller(), Ty); + }); + } + + return; + } + case APValue::Struct: { + OS << "Struct"; + + dumpAPValueChildren( + Value, Ty, + [](const APValue &Value, unsigned Index) -> const APValue & { + return Value.getStructBase(Index); + }, + Value.getStructNumBases(), "base", "bases"); + + dumpAPValueChildren( + Value, Ty, + [](const APValue &Value, unsigned Index) -> const APValue & { + return Value.getStructField(Index); + }, + Value.getStructNumFields(), "field", "fields"); + + return; + } + case APValue::Union: { + OS << "Union"; + { + ColorScope Color(OS, ShowColors, ValueColor); + if (const FieldDecl *FD = Value.getUnionField()) + OS << " ." << *cast(FD); + } + // If the union value is considered to be simple, fold it into the + // current line to save some vertical space. + const APValue &UnionValue = Value.getUnionValue(); + if (isSimpleAPValue(UnionValue)) { + OS << ' '; + Visit(UnionValue, Ty); + } else { + AddChild([=] { Visit(UnionValue, Ty); }); + } + + return; + } + case APValue::MemberPointer: + OS << "MemberPointer "; + return; + case APValue::AddrLabelDiff: + OS << "AddrLabelDiff "; + return; + } + llvm_unreachable("Unknown APValue kind!"); +} + void TextNodeDumper::dumpPointer(const void *Ptr) { ColorScope Color(OS, ShowColors, AddressColor); OS << ' ' << Ptr; @@ -712,11 +929,9 @@ void TextNodeDumper::VisitCaseStmt(const CaseStmt *Node) { } void TextNodeDumper::VisitConstantExpr(const ConstantExpr *Node) { - if (Node->getResultAPValueKind() != APValue::None) { - ColorScope Color(OS, ShowColors, ValueColor); - OS << " "; - Node->getAPValueResult().dump(OS, Context); - } + if (Node->hasAPValueResult()) + AddChild("value", + [=] { Visit(Node->getAPValueResult(), Node->getType()); }); } void TextNodeDumper::VisitCallExpr(const CallExpr *Node) { @@ -1454,6 +1669,16 @@ void TextNodeDumper::VisitVarDecl(const VarDecl *D) { OS << " destroyed"; if (D->isParameterPack()) OS << " pack"; + + if (D->hasInit()) { + const Expr *E = D->getInit(); + // Only dump the value of constexpr VarDecls for now. + if (E && !E->isValueDependent() && D->isConstexpr()) { + const APValue *Value = D->evaluateValue(); + if (Value) + AddChild("value", [=] { Visit(*Value, E->getType()); }); + } + } } void TextNodeDumper::VisitBindingDecl(const BindingDecl *D) { diff --git a/clang/test/AST/alignas_maybe_odr_cleanup.cpp b/clang/test/AST/alignas_maybe_odr_cleanup.cpp index cdff1bfe8b80..3adef4cba144 100644 --- a/clang/test/AST/alignas_maybe_odr_cleanup.cpp +++ b/clang/test/AST/alignas_maybe_odr_cleanup.cpp @@ -15,8 +15,9 @@ struct FOO { } }; -// CHECK: AlignedAttr {{.*}} alignas -// CHECK: ConstantExpr {{.+}} 'int' Int: 32 -// CHECK: ImplicitCastExpr {{.*}} 'int' -// CHECK: DeclRefExpr {{.*}} 'const int' lvalue Var {{.*}} 'vec_align_bytes' 'const int' non_odr_use_constant -// CHECK: NullStmt +// CHECK: | `-AlignedAttr {{.*}} alignas +// CHECK-NEXT: | `-ConstantExpr {{.*}} 'int' +// CHECK-NEXT: | |-value: Int 32 +// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'int' +// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const int' lvalue Var {{.*}} 'vec_align_bytes' 'const int' non_odr_use_constant +// CHECK-NEXT: `-NullStmt {{.*}} diff --git a/clang/test/AST/ast-dump-APValue-anon-union.cpp b/clang/test/AST/ast-dump-APValue-anon-union.cpp new file mode 100644 index 000000000000..c50fe70be911 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-anon-union.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +struct S0 { + union { + int i = 42; + }; +}; + +union U0 { + union { + float f = 3.1415f; + }; +}; + +union U1 { + union { + float f; + }; +}; + +void Test() { + constexpr S0 s0{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s0 'const S0' constexpr listinit + // CHECK-NEXT: | |-value: Struct + // CHECK-NEXT: | | `-field: Union .i Int 42 + + constexpr U0 u0a{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0a 'const U0' constexpr listinit + // CHECK-NEXT: | |-value: Union None + + constexpr U0 u0b{3.1415f}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0b 'const U0' constexpr listinit + // CHECK-NEXT: | |-value: Union . Union .f Float 3.141500e+00 + + constexpr U1 u1a{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u1a 'const U1' constexpr listinit + // CHECK-NEXT: | |-value: Union . Union .f Float 0.000000e+00 + + constexpr U1 u1b{3.1415f}; + // CHECK: `-VarDecl {{.*}} col:{{.*}} u1b 'const U1' constexpr listinit + // CHECK-NEXT: |-value: Union . Union .f Float 3.141500e+00 +} diff --git a/clang/test/AST/ast-dump-APValue-arithmetic.cpp b/clang/test/AST/ast-dump-APValue-arithmetic.cpp new file mode 100644 index 000000000000..a4e1d82eeb37 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-arithmetic.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +void Test() { + constexpr int Int = 42; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} Int 'const int' constexpr cinit + // CHECK-NEXT: | |-value: Int 42 + + constexpr __int128 Int128 = (__int128)0xFFFFFFFFFFFFFFFF + (__int128)1; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} Int128 'const __int128' constexpr cinit + // CHECK-NEXT: | |-value: Int 18446744073709551616 + + constexpr float Float = 3.1415f; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} Float 'const float' constexpr cinit + // CHECK-NEXT: | |-value: Float 3.141500e+00 + + constexpr double Double = 3.1415f; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} Double 'const double' constexpr cinit + // CHECK-NEXT: | |-value: Float 3.141500e+00 + + constexpr _Complex int ComplexInt = 42 + 24i; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} referenced ComplexInt 'const _Complex int' constexpr cinit + // CHECK-NEXT: | |-value: ComplexInt 42 + 24i + + constexpr _Complex float ComplexFloat = 3.1415f + 42i; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} referenced ComplexFloat 'const _Complex float' constexpr cinit + // CHECK-NEXT: | |-value: ComplexFloat 3.141500e+00 + 4.200000e+01i + + constexpr _Complex int ArrayOfComplexInt[10] = {ComplexInt, ComplexInt, ComplexInt, ComplexInt}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} ArrayOfComplexInt '_Complex int const[10]' constexpr cinit + // CHECK-NEXT: | |-value: Array size=10 + // CHECK-NEXT: | | |-elements: ComplexInt 42 + 24i, ComplexInt 42 + 24i, ComplexInt 42 + 24i, ComplexInt 42 + 24i + // CHECK-NEXT: | | `-filler: 6 x ComplexInt 0 + 0i + + constexpr _Complex float ArrayOfComplexFloat[10] = {ComplexFloat, ComplexFloat, ComplexInt, ComplexInt}; + // CHECK: `-VarDecl {{.*}} col:{{.*}} ArrayOfComplexFloat '_Complex float const[10]' constexpr cinit + // CHECK-NEXT: |-value: Array size=10 + // CHECK-NEXT: | |-elements: ComplexFloat 3.141500e+00 + 4.200000e+01i, ComplexFloat 3.141500e+00 + 4.200000e+01i, ComplexFloat 4.200000e+01 + 2.400000e+01i, ComplexFloat 4.200000e+01 + 2.400000e+01i + // CHECK-NEXT: | `-filler: 6 x ComplexFloat 0.000000e+00 + 0.000000e+00i +} diff --git a/clang/test/AST/ast-dump-APValue-array.cpp b/clang/test/AST/ast-dump-APValue-array.cpp new file mode 100644 index 000000000000..4b7dfab09eaf --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-array.cpp @@ -0,0 +1,74 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +struct S0 { + int arr[2]; +}; +union U0 { + int i; + float f; +}; + +struct S1 { + S0 s0 = {1, 2}; + U0 u0 = {.i = 42}; +}; + +void Test() { + constexpr int __attribute__((vector_size(sizeof(int) * 5))) arr_v5i[5] = { + {1, 2, 3, 4, 5}, + {1, 2, 3, 4}, + }; + // CHECK: | `-VarDecl {{.*}} line:{{.*}} arr_v5i '__attribute__((__vector_size__(5 * sizeof(int)))) int const[5]' constexpr cinit + // CHECK-NEXT: | |-value: Array size=5 + // CHECK-NEXT: | | |-element: Vector length=5 + // CHECK-NEXT: | | | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | | | `-element: Int 5 + // CHECK-NEXT: | | |-element: Vector length=5 + // CHECK-NEXT: | | | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | | | `-element: Int 0 + // CHECK-NEXT: | | `-filler: 3 x Vector length=5 + // CHECK-NEXT: | | |-elements: Int 0, Int 0, Int 0, Int 0 + // CHECK-NEXT: | | `-element: Int 0 + + constexpr float arr_f[3][5] = { + {1, 2, 3, 4, 5}, + }; + // CHECK: | `-VarDecl {{.*}} line:{{.*}} arr_f 'float const[3][5]' constexpr cinit + // CHECK-NEXT: | |-value: Array size=3 + // CHECK-NEXT: | | |-element: Array size=5 + // CHECK-NEXT: | | | |-elements: Float 1.000000e+00, Float 2.000000e+00, Float 3.000000e+00, Float 4.000000e+00 + // CHECK-NEXT: | | | `-element: Float 5.000000e+00 + // CHECK-NEXT: | | `-filler: 2 x Array size=5 + // CHECK-NEXT: | | `-filler: 5 x Float 0.000000e+00 + + constexpr S0 arr_s0[2] = {{1, 2}, {3, 4}}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} arr_s0 'S0 const[2]' constexpr cinit + // CHECK-NEXT: | |-value: Array size=2 + // CHECK-NEXT: | | |-element: Struct + // CHECK-NEXT: | | | `-field: Array size=2 + // CHECK-NEXT: | | | `-elements: Int 1, Int 2 + // CHECK-NEXT: | | `-element: Struct + // CHECK-NEXT: | | `-field: Array size=2 + // CHECK-NEXT: | | `-elements: Int 3, Int 4 + + constexpr U0 arr_u0[2] = {{.i = 42}, {.f = 3.1415f}}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} arr_u0 'U0 const[2]' constexpr cinit + // CHECK-NEXT: | |-value: Array size=2 + // CHECK-NEXT: | | `-elements: Union .i Int 42, Union .f Float 3.141500e+00 + + constexpr S1 arr_s1[2] = {}; + // CHECK: `-VarDecl {{.*}} col:{{.*}} arr_s1 'S1 const[2]' constexpr cinit + // CHECK-NEXT: |-value: Array size=2 + // CHECK-NEXT: | |-element: Struct + // CHECK-NEXT: | | |-field: Struct + // CHECK-NEXT: | | | `-field: Array size=2 + // CHECK-NEXT: | | | `-elements: Int 1, Int 2 + // CHECK-NEXT: | | `-field: Union .i Int 42 + // CHECK-NEXT: | `-element: Struct + // CHECK-NEXT: | |-field: Struct + // CHECK-NEXT: | | `-field: Array size=2 + // CHECK-NEXT: | | `-elements: Int 1, Int 2 + // CHECK-NEXT: | `-field: Union .i Int 42 +} diff --git a/clang/test/AST/ast-dump-APValue-struct.cpp b/clang/test/AST/ast-dump-APValue-struct.cpp new file mode 100644 index 000000000000..d69ddffda031 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-struct.cpp @@ -0,0 +1,105 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +struct S0 { + int i = 0; + union { + int j = 0; + } u0; +}; + +struct S1 { + int i = 0; + union { + struct { + int j = 0; + } s; + } u1; +}; + +struct S2 { + int i = 0; + union { + union { + int j = 0; + } u; + } u2; +}; + +struct S3 { + int i = 0; + union { + union { + struct { + int j = 0; + } j; + } u; + } u3; +}; + +struct S4 : S0 { + int i = 1, j = 2, k = 3; + struct { + } s; + int a = 4, b = 5, c = 6; +}; + +struct S5 : S4 { + int arr0[8] = {1, 2, 3, 4}; + int arr1[8] = {1, 2, 3, 4, 0, 0, 0, 0}; +}; + +void Test() { + constexpr S0 s0{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s0 'const S0' constexpr listinit + // CHECK-NEXT: | |-value: Struct + // CHECK-NEXT: | | `-fields: Int 0, Union .j Int 0 + + constexpr S1 s1{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s1 'const S1' constexpr listinit + // CHECK-NEXT: | |-value: Struct + // CHECK-NEXT: | | |-field: Int 0 + // CHECK-NEXT: | | `-field: Union .s + // CHECK-NEXT: | | `-Struct + // CHECK-NEXT: | | `-field: Int 0 + + constexpr S2 s2{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s2 'const S2' constexpr listinit + // CHECK-NEXT: | |-value: Struct + // CHECK-NEXT: | | `-fields: Int 0, Union .u Union .j Int 0 + + constexpr S3 s3{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s3 'const S3' constexpr listinit + // CHECK-NEXT: | |-value: Struct + // CHECK-NEXT: | | |-field: Int 0 + // CHECK-NEXT: | | `-field: Union .u + // CHECK-NEXT: | | `-Union .j + // CHECK-NEXT: | | `-Struct + // CHECK-NEXT: | | `-field: Int 0 + + constexpr S4 s4{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s4 'const S4' constexpr listinit + // CHECK-NEXT: | |-value: Struct + // CHECK-NEXT: | | |-base: Struct + // CHECK-NEXT: | | | `-fields: Int 0, Union .j Int 0 + // CHECK-NEXT: | | |-fields: Int 1, Int 2, Int 3 + // CHECK-NEXT: | | |-field: Struct + // CHECK-NEXT: | | `-fields: Int 4, Int 5, Int 6 + + constexpr S5 s5{}; + // CHECK: `-VarDecl {{.*}} col:{{.*}} s5 'const S5' constexpr listinit + // CHECK-NEXT: |-value: Struct + // CHECK-NEXT: | |-base: Struct + // CHECK-NEXT: | | |-base: Struct + // CHECK-NEXT: | | | `-fields: Int 0, Union .j Int 0 + // CHECK-NEXT: | | |-fields: Int 1, Int 2, Int 3 + // CHECK-NEXT: | | |-field: Struct + // CHECK-NEXT: | | `-fields: Int 4, Int 5, Int 6 + // CHECK-NEXT: | |-field: Array size=8 + // CHECK-NEXT: | | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | | `-filler: 4 x Int 0 + // CHECK-NEXT: | `-field: Array size=8 + // CHECK-NEXT: | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | `-elements: Int 0, Int 0, Int 0, Int 0 +} diff --git a/clang/test/AST/ast-dump-APValue-todo.cpp b/clang/test/AST/ast-dump-APValue-todo.cpp new file mode 100644 index 000000000000..5de8146910f7 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-todo.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +int i; +struct S { + int i; +}; + +void Test() { + constexpr int *pi = &i; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} pi 'int *const' constexpr cinit + // CHECK-NEXT: | |-value: LValue + + constexpr int(S::*pmi) = &S::i; + // CHECK: `-VarDecl {{.*}} col:{{.*}} pmi 'int (S::*const)' constexpr cinit + // CHECK-NEXT: |-value: MemberPointer +} diff --git a/clang/test/AST/ast-dump-APValue-union.cpp b/clang/test/AST/ast-dump-APValue-union.cpp new file mode 100644 index 000000000000..afb69de9f587 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-union.cpp @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +union U0 { + int i = 42; + float f; +}; + +union U1 { + union Uinner { + int i; + float f = 3.1415f; + } uinner; +}; + +union U2 { + union Uinner { + double d; + int arr[2] = {1, 2}; + } uinner; +}; + +union U3 { + union Uinner { + double d = 3.1415; + int arr[2]; + } uinner; + float f; +}; + +void Test() { + constexpr U0 u0{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0 'const U0' constexpr listinit + // CHECK-NEXT: | |-value: Union .i Int 42 + + constexpr U1 u1{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u1 'const U1' constexpr listinit + // CHECK-NEXT: | |-value: Union .uinner Union .f Float 3.141500e+00 + + constexpr U2 u2{}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u2 'const U2' constexpr listinit + // CHECK-NEXT: | |-value: Union .uinner + // CHECK-NEXT: | | `-Union .arr + // CHECK-NEXT: | | `-Array size=2 + // CHECK-NEXT: | | `-elements: Int 1, Int 2 + + constexpr U3 u3a = {.f = 3.1415}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u3a 'const U3' constexpr cinit + // CHECK-NEXT: | |-value: Union .f Float 3.141500e+00 + + constexpr U3 u3b = {.uinner = {}}; + // CHECK: `-VarDecl {{.*}} col:{{.*}} u3b 'const U3' constexpr cinit + // CHECK-NEXT: |-value: Union .uinner Union .d Float 3.141500e+00 +} diff --git a/clang/test/AST/ast-dump-APValue-vector.cpp b/clang/test/AST/ast-dump-APValue-vector.cpp new file mode 100644 index 000000000000..fe2dcd934056 --- /dev/null +++ b/clang/test/AST/ast-dump-APValue-vector.cpp @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \ +// RUN: -ast-dump %s -ast-dump-filter Test \ +// RUN: | FileCheck --strict-whitespace --match-full-lines %s + +void Test() { + constexpr int __attribute__((vector_size(sizeof(int) * 1))) v1i = {1}; + // CHECK: |-DeclStmt {{.*}} + // CHECK-NEXT: | `-VarDecl {{.*}} col:{{.*}} v1i '__attribute__((__vector_size__(1 * sizeof(int)))) int const' constexpr cinit + // CHECK-NEXT: | |-value: Vector length=1 + // CHECK-NEXT: | | `-element: Int 1 + + constexpr int __attribute__((vector_size(sizeof(int) * 4))) v4i = {1, 2, 3, 4}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} v4i '__attribute__((__vector_size__(4 * sizeof(int)))) int const' constexpr cinit + // CHECK-NEXT: | |-value: Vector length=4 + // CHECK-NEXT: | | `-elements: Int 1, Int 2, Int 3, Int 4 + + constexpr int __attribute__((vector_size(sizeof(int) * 5))) v5i = {1, 2, 3, 4}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} v5i '__attribute__((__vector_size__(5 * sizeof(int)))) int const' constexpr cinit + // CHECK-NEXT: | |-value: Vector length=5 + // CHECK-NEXT: | | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | | `-element: Int 0 + + constexpr int __attribute__((vector_size(sizeof(int) * 8))) v8i = {1, 2, 3, 4}; + // CHECK: | `-VarDecl {{.*}} col:{{.*}} v8i '__attribute__((__vector_size__(8 * sizeof(int)))) int const' constexpr cinit + // CHECK-NEXT: | |-value: Vector length=8 + // CHECK-NEXT: | | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | | `-elements: Int 0, Int 0, Int 0, Int 0 + + constexpr int __attribute__((vector_size(sizeof(int) * 9))) v9i = {1, 2, 3, 4}; + // CHECK: `-VarDecl {{.*}} col:{{.*}} v9i '__attribute__((__vector_size__(9 * sizeof(int)))) int const' constexpr cinit + // CHECK-NEXT: |-value: Vector length=9 + // CHECK-NEXT: | |-elements: Int 1, Int 2, Int 3, Int 4 + // CHECK-NEXT: | |-elements: Int 0, Int 0, Int 0, Int 0 + // CHECK-NEXT: | `-element: Int 0 +} diff --git a/clang/test/AST/ast-dump-attr.cpp b/clang/test/AST/ast-dump-attr.cpp index 50eef3e0d97a..95491a02f8b2 100644 --- a/clang/test/AST/ast-dump-attr.cpp +++ b/clang/test/AST/ast-dump-attr.cpp @@ -45,6 +45,7 @@ int TestAlignedExpr __attribute__((aligned(4))); // CHECK: VarDecl{{.*}}TestAlignedExpr // CHECK-NEXT: AlignedAttr {{.*}} aligned // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 4 // CHECK-NEXT: IntegerLiteral int TestEnum __attribute__((visibility("default"))); diff --git a/clang/test/AST/ast-dump-color.cpp b/clang/test/AST/ast-dump-color.cpp index 6651ef2652e0..baaf9729c7ce 100644 --- a/clang/test/AST/ast-dump-color.cpp +++ b/clang/test/AST/ast-dump-color.cpp @@ -49,13 +49,15 @@ struct Invalid { //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:11[[RESET]]> [[Green]]'int'[[RESET]][[Cyan:.\[0;36m]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}} //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:14[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}} //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:3[[RESET]], [[Yellow]]line:12:27[[RESET]]>{{$}} -//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[MAGENTA]]ConstantExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] Int: 1[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[MAGENTA]]ConstantExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | | | |-value: [[RESET]][[Cyan]]Int [[CYAN]]1[[RESET]][[RESET]]{{$}} //CHECK: {{^}}[[Blue]]| | | | `-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}} //CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]AttributedStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:12:5[[RESET]], [[Yellow]]col:27[[RESET]]>{{$}} //CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[BLUE]]FallThroughAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:7[[RESET]], [[Yellow]]col:14[[RESET]]>{{$}} //CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:27[[RESET]]>{{$}} //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:3[[RESET]], [[Yellow]]line:14:5[[RESET]]>{{$}} -//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]ConstantExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] Int: 2[[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]ConstantExpr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]]{{$}} +//CHECK: {{^}}[[Blue]]| | | |-value: [[RESET]][[Cyan]]Int [[CYAN]]2[[RESET]][[RESET]]{{$}} //CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 2[[RESET]]{{$}} //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:14:5[[RESET]]>{{$}} //CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:8:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}} diff --git a/clang/test/AST/ast-dump-constant-expr.cpp b/clang/test/AST/ast-dump-constant-expr.cpp index c9ddb245ef64..43f68cac7206 100644 --- a/clang/test/AST/ast-dump-constant-expr.cpp +++ b/clang/test/AST/ast-dump-constant-expr.cpp @@ -54,27 +54,32 @@ void Test() { // CHECK-NEXT:FunctionDecl {{.*}} <{{.*}}ast-dump-constant-expr.cpp:42:1, line:52:1> line:42:6{{( imported)?}} Test 'void ()' // CHECK-NEXT:`-CompoundStmt {{.*}} // CHECK-NEXT: |-CStyleCastExpr {{.*}} 'void' -// CHECK-NEXT: | `-ConstantExpr {{.*}} 'int' Int: 42 +// CHECK-NEXT: | `-ConstantExpr {{.*}} 'int' +// CHECK-NEXT: | |-value: Int 42 // CHECK-NEXT: | `-CallExpr {{.*}} 'int' // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'int (*)()' // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'int ()' lvalue Function {{.*}} 'test_Int' 'int ()' // CHECK-NEXT: |-CStyleCastExpr {{.*}} 'void' -// CHECK-NEXT: | `-ConstantExpr {{.*}} 'float' Float: 1.000000e+00 +// CHECK-NEXT: | `-ConstantExpr {{.*}} 'float' +// CHECK-NEXT: | |-value: Float 1.000000e+00 // CHECK-NEXT: | `-CallExpr {{.*}} 'float' // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'float (*)()' // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'float ()' lvalue Function {{.*}} 'test_Float' 'float ()' // CHECK-NEXT: |-CStyleCastExpr {{.*}} 'void' -// CHECK-NEXT: | `-ConstantExpr {{.*}} '_Complex int' ComplexInt: 1, 2 +// CHECK-NEXT: | `-ConstantExpr {{.*}} '_Complex int' +// CHECK-NEXT: | |-value: ComplexInt 1 + 2i // CHECK-NEXT: | `-CallExpr {{.*}} '_Complex int' // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Complex int (*)()' // CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Complex int ()' lvalue Function {{.*}} 'test_ComplexInt' '_Complex int ()' // CHECK-NEXT: |-CStyleCastExpr {{.*}} 'void' -// CHECK-NEXT: | `-ConstantExpr {{.*}} '_Complex float' ComplexFloat: 1.200000e+00, 3.400000e+00 +// CHECK-NEXT: | `-ConstantExpr {{.*}} '_Complex float' +// CHECK-NEXT: | |-value: ComplexFloat 1.200000e+00 + 3.400000e+00i // CHECK-NEXT: | `-CallExpr {{.*}} '_Complex float' // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '_Complex float (*)()' // CHECK-NEXT: | `-DeclRefExpr {{.*}} '_Complex float ()' lvalue Function {{.*}} 'test_ComplexFloat' '_Complex float ()' // CHECK-NEXT: `-CStyleCastExpr {{.*}} 'void' -// CHECK-NEXT: `-ConstantExpr {{.*}} '__int128' Int: 18446744073709551616 +// CHECK-NEXT: `-ConstantExpr {{.*}} '__int128' +// CHECK-NEXT: |-value: Int 18446744073709551616 // CHECK-NEXT: `-CallExpr {{.*}} '__int128' // CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__int128 (*)()' // CHECK-NEXT: `-DeclRefExpr {{.*}} '__int128 ()' lvalue Function {{.*}} 'test_Int128' '__int128 ()' diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp index b9b7cba394f5..97bb7964c47b 100644 --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -439,6 +439,7 @@ namespace testClassTemplateDecl { // CHECK-NEXT: |-NonTypeTemplateParmDecl 0x{{.+}} col:16 'int' depth 0 index 0 I // CHECK-NEXT: | `-TemplateArgument expr // CHECK-NEXT: | `-ConstantExpr 0x{{.+}} 'int' +// CHECK-NEXT: | |-value: Int 42 // CHECK-NEXT: | `-IntegerLiteral 0x{{.+}} 'int' 42 // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} col:31 struct TestTemplateDefaultNonType @@ -644,6 +645,7 @@ namespace TestNonTypeTemplateParmDecl { // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 0 I // CHECK-NEXT: TemplateArgument expr // CHECK-NEXT: ConstantExpr{{.*}} 'int' +// CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral{{.*}} 'int' 1 // CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} 'int' depth 0 index 1 ... J diff --git a/clang/test/AST/ast-dump-records.cpp b/clang/test/AST/ast-dump-records.cpp index f379b2dba529..cb7ac8320431 100644 --- a/clang/test/AST/ast-dump-records.cpp +++ b/clang/test/AST/ast-dump-records.cpp @@ -15,7 +15,7 @@ struct B; // CHECK: CXXRecordDecl 0x{{[^ ]*}} col:8 referenced struct B struct A { - // CHECK: CXXRecordDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} line:[[@LINE-1]]:8 struct A definition + // CHECK: CXXRecordDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} line:[[@LINE-1]]:8 struct A definition // CHECK-NEXT: DefinitionData pass_in_registers aggregate standard_layout trivially_copyable pod trivial literal // CHECK-NEXT: DefaultConstructor exists trivial needs_implicit // CHECK-NEXT: CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -33,14 +33,17 @@ struct A { int d : 12; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:7 d 'int' // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: value: Int 12 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 int : 0; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:7 'int' // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: value: Int 0 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 0 int e : 10; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:7 e 'int' // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: value: Int 10 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 10 B *f; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:6 f 'B *' @@ -141,7 +144,7 @@ union F; // CHECK: CXXRecordDecl 0x{{[^ ]*}} col:7 union F union E { - // CHECK: CXXRecordDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} line:[[@LINE-1]]:7 union E definition + // CHECK: CXXRecordDecl 0x{{[^ ]*}} prev 0x{{[^ ]*}} line:[[@LINE-1]]:7 union E definition // CHECK-NEXT: DefinitionData pass_in_registers aggregate standard_layout trivially_copyable pod trivial literal // CHECK-NEXT: DefaultConstructor exists trivial needs_implicit // CHECK-NEXT: CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param @@ -159,14 +162,17 @@ union E { int d : 12; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:7 d 'int' // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: value: Int 12 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 int : 0; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:7 'int' // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: value: Int 0 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 0 int e : 10; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:7 e 'int' // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'int' + // CHECK-NEXT: value: Int 10 // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 10 B *f; // CHECK-NEXT: FieldDecl 0x{{[^ ]*}} col:6 f 'B *' diff --git a/clang/test/AST/ast-dump-stmt.cpp b/clang/test/AST/ast-dump-stmt.cpp index e4d8d8218b4e..585a94bd1920 100644 --- a/clang/test/AST/ast-dump-stmt.cpp +++ b/clang/test/AST/ast-dump-stmt.cpp @@ -130,6 +130,7 @@ void TestIf(bool b) { ; // CHECK: IfStmt 0x{{[^ ]*}} // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'bool' + // CHECK-NEXT: value: Int 1 // CHECK-NEXT: BinaryOperator // CHECK-NEXT: UnaryExprOrTypeTraitExpr // CHECK-NEXT: ParenExpr @@ -144,6 +145,7 @@ void TestIf(bool b) { ; // CHECK: IfStmt 0x{{[^ ]*}} has_else // CHECK-NEXT: ConstantExpr 0x{{[^ ]*}} 'bool' + // CHECK-NEXT: value: Int 1 // CHECK-NEXT: BinaryOperator // CHECK-NEXT: UnaryExprOrTypeTraitExpr // CHECK-NEXT: ParenExpr diff --git a/clang/test/AST/pr43983.cpp b/clang/test/AST/pr43983.cpp index dd7ce76a38bc..c27d825dbb1b 100644 --- a/clang/test/AST/pr43983.cpp +++ b/clang/test/AST/pr43983.cpp @@ -9,6 +9,7 @@ struct B { _Alignas(64) struct { int b; }; }; -// CHECK: AlignedAttr {{.*}} _Alignas -// CHECK: ConstantExpr {{.*}} 64 -// CHECK: IntegerLiteral {{.*}} 64 +// CHECK: | `-AlignedAttr {{.*}} _Alignas +// CHECK-NEXT: | `-ConstantExpr {{.*}} 'int' +// CHECK-NEXT: | |-value: Int 64 +// CHECK-NEXT: | `-IntegerLiteral {{.*}} 'int' 64 diff --git a/clang/test/Import/switch-stmt/test.cpp b/clang/test/Import/switch-stmt/test.cpp index e274e895c444..fcd8263727ea 100644 --- a/clang/test/Import/switch-stmt/test.cpp +++ b/clang/test/Import/switch-stmt/test.cpp @@ -5,20 +5,26 @@ // CHECK-NEXT: CompoundStmt // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 2 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: BreakStmt // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 3 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 4 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 5 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 5 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: BreakStmt @@ -30,16 +36,20 @@ // CHECK-NEXT: CompoundStmt // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: BreakStmt // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 2 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: BreakStmt // CHECK-NEXT: CaseStmt // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 3 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: ConstantExpr +// CHECK-NEXT: value: Int 5 // CHECK-NEXT: IntegerLiteral // CHECK-NEXT: BreakStmt diff --git a/clang/test/Tooling/clang-check-ast-dump.cpp b/clang/test/Tooling/clang-check-ast-dump.cpp index 496d489fd609..bd9ae5fcc2a5 100644 --- a/clang/test/Tooling/clang-check-ast-dump.cpp +++ b/clang/test/Tooling/clang-check-ast-dump.cpp @@ -33,6 +33,7 @@ // CHECK-ATTR-NEXT: FieldDecl{{.*}}n // CHECK-ATTR-NEXT: AlignedAttr // CHECK-ATTR-NEXT: ConstantExpr +// CHECK-ATTR-NEXT: value: Int 2 // CHECK-ATTR-NEXT: BinaryOperator // // RUN: clang-check -ast-dump -ast-dump-filter test_namespace::AfterNullNode "%s" -- 2>&1 | FileCheck -check-prefix CHECK-AFTER-NULL %s From cfe-commits at lists.llvm.org Mon Jul 6 14:03:55 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:03:55 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: <94f1344f2ff972684287068ae3f06790@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGf63e3ea558bb: [clang] Rework how and when APValues are dumped (authored by riccibruno). Changed prior to commit: https://reviews.llvm.org/D83183?vs=275783&id=275828#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 Files: clang/include/clang/AST/APValue.h clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/JSONNodeDumper.h clang/include/clang/AST/TextNodeDumper.h clang/lib/AST/APValue.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/TextNodeDumper.cpp clang/test/AST/alignas_maybe_odr_cleanup.cpp clang/test/AST/ast-dump-APValue-anon-union.cpp clang/test/AST/ast-dump-APValue-arithmetic.cpp clang/test/AST/ast-dump-APValue-array.cpp clang/test/AST/ast-dump-APValue-struct.cpp clang/test/AST/ast-dump-APValue-todo.cpp clang/test/AST/ast-dump-APValue-union.cpp clang/test/AST/ast-dump-APValue-vector.cpp clang/test/AST/ast-dump-attr.cpp clang/test/AST/ast-dump-color.cpp clang/test/AST/ast-dump-constant-expr.cpp clang/test/AST/ast-dump-decl.cpp clang/test/AST/ast-dump-records.cpp clang/test/AST/ast-dump-stmt.cpp clang/test/AST/pr43983.cpp clang/test/Import/switch-stmt/test.cpp clang/test/Tooling/clang-check-ast-dump.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83183.275828.patch Type: text/x-patch Size: 48723 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:06:03 2020 From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:06:03 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: ellis added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:34 + const BlockDecl *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl(); + for (const BlockDecl::Capture &CapturedVar : EscapingBlockDecl->captures()) { + const VarDecl *Var = CapturedVar.getVariable(); ---------------- aaron.ballman wrote: > This makes me think we should extend the `hasAnyCaptures()` AST matcher so it works with blocks as well as lambdas. It would be nice to do all of this from the matcher interface. Should I add a TODO for this? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Mon Jul 6 14:24:20 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:24:20 +0000 (UTC) Subject: [PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: tra added inline comments. ================ Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6069 + llvm::raw_ostream &OS) const { + OS << ".static." << getLangOpts().CUID; +} ---------------- I suspect that will have interesting issues if CUID is an arbitrary user-supplied string. We may want to impose some sort of sanity check or filtering on the cuid value. Considering that it's a CC1 flag, it's not a critical problem, but some safeguards would be useful there, too. Should we limit allowed character set? ================ Comment at: clang/test/Driver/hip-cuid.hip:35 +// RUN: --offload-arch=gfx906 \ +// RUN: -c -nogpulib -cuid=abcd \ +// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ ---------------- Nit: `abcd` could potentially match the value generated by hash. I'd change it to contain characters other than hex. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 From cfe-commits at lists.llvm.org Mon Jul 6 14:30:45 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:30:45 +0000 (UTC) Subject: [PATCH] D83015: [Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path In-Reply-To: References: Message-ID: MaskRay updated this revision to Diff 275830. MaskRay retitled this revision from "[Driver] Add -fld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path" to "[Driver] Add --ld-path= and deprecate -fuse-ld=/abs/path and -fuse-ld=rel/path". MaskRay edited the summary of this revision. MaskRay added a reviewer: phosek. MaskRay added a comment. Rename -fld-path= to --ld-path= Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83015/new/ https://reviews.llvm.org/D83015 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChain.cpp clang/test/Driver/fuse-ld.c clang/test/Driver/ld-path.c clang/test/Misc/warning-flags.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83015.275830.patch Type: text/x-patch Size: 8462 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:33:47 2020 From: cfe-commits at lists.llvm.org (Atmn Patel via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:33:47 +0000 (UTC) Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang In-Reply-To: References: Message-ID: atmnpatel added a comment. Herald added a subscriber: aaron.ballman. Ping @ABataev. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75591/new/ https://reviews.llvm.org/D75591 From cfe-commits at lists.llvm.org Mon Jul 6 14:34:28 2020 From: cfe-commits at lists.llvm.org (David Greene via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:34:28 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: <06a046e1b31833e12a467f082760e9f0@localhost.localdomain> greened updated this revision to Diff 275831. greened added a comment. Herald added a project: clang. Herald added a subscriber: cfe-commits. Fixed various bugs, added tests. This now has two modes because generated function output can't be ordered with respect to source file functions. When clang generates functions it can sometimes output original source functions in a different (non-source) order so checks can't be placed next to their definitions in the source file. I don't particularly like this mode dichotomy but unifying it would necessitate updating a whole lot of clang tests. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 Files: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected clang/test/utils/update_cc_test_checks/generated-funcs.test llvm/utils/UpdateTestChecks/asm.py llvm/utils/UpdateTestChecks/common.py llvm/utils/update_cc_test_checks.py llvm/utils/update_llc_test_checks.py llvm/utils/update_test_checks.py -------------- next part -------------- A non-text attachment was scrubbed... Name: D83004.275831.patch Type: text/x-patch Size: 29805 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:35:52 2020 From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:35:52 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: cchen updated this revision to Diff 275834. cchen added a comment. Move analysis of stride from Sema to Parse Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 Files: clang/include/clang-c/Index.h clang/include/clang/AST/ExprOpenMP.h clang/include/clang/Basic/DiagnosticParseKinds.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/StmtPrinter.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/OpenMP/target_data_messages.c clang/test/OpenMP/target_depend_messages.cpp clang/test/OpenMP/target_enter_data_depend_messages.cpp clang/test/OpenMP/target_exit_data_depend_messages.cpp clang/test/OpenMP/target_map_messages.cpp clang/test/OpenMP/target_parallel_depend_messages.cpp clang/test/OpenMP/target_parallel_for_depend_messages.cpp clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_simd_depend_messages.cpp clang/test/OpenMP/target_teams_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp clang/test/OpenMP/target_update_ast_print.cpp clang/test/OpenMP/target_update_depend_messages.cpp clang/test/OpenMP/target_update_messages.cpp clang/test/OpenMP/task_affinity_messages.cpp clang/test/OpenMP/task_depend_messages.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82800.275834.patch Type: text/x-patch Size: 49297 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:38:24 2020 From: cfe-commits at lists.llvm.org (David Greene via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:38:24 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: greened marked an inline comment as done. greened added inline comments. ================ Comment at: llvm/utils/update_cc_test_checks.py:133 + parser.add_argument('--include-generated-funcs', action='store_true', + help='Output checks for functions not in source') parser.add_argument('tests', nargs='+') ---------------- jdoerfert wrote: > I think this should go into common.py (after D78618). I would also make this the default but OK. Yes I suppose it should in case `opt` and friends generate functions. I hadn't considered that use-case. While I would like to make it default unfortunately it would require updating a bunch of the existing clang tests which doesn't seem too friendly. See the patch update comment for details. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 From cfe-commits at lists.llvm.org Mon Jul 6 14:39:15 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 21:39:15 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: <8520aaa8daced91ddd0c5a94457e7317@localhost.localdomain> gamesh411 updated this revision to Diff 275835. gamesh411 added a comment. implement traditional iterator support as well Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 Files: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp clang/test/Analysis/iterator-modeling.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83190.275835.patch Type: text/x-patch Size: 9067 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:39:16 2020 From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:39:16 +0000 (UTC) Subject: [PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: <9049de4a6f0734649ef5a97485d03b43@localhost.localdomain> JonChesterfield added inline comments. ================ Comment at: clang/lib/AST/ASTContext.cpp:10068 + isa(D) && cast(D)->isFileVarDecl() && + cast(D)->getStorageClass() == SC_Static) { + return GVA_StrongExternal; ---------------- yaxunl wrote: > rjmccall wrote: > > Are you sure this doesn't apply to e.g. local statics? Can't you have kernel lambdas, or am I confusing HIP with another language? > function-scope static var in a device function is only visible to the device function. Host code cannot access it, therefore no need to externalize it. This doesn't sound right. An inline function can return a pointer to a function scope static variable, e.g. to implement a singleton in a header file. I think host code can then access said variable. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 From cfe-commits at lists.llvm.org Mon Jul 6 14:39:24 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:39:24 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <19842e124db7edff46c83ddc8d647519@localhost.localdomain> yaxunl marked 4 inline comments as done. yaxunl added inline comments. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167 + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile) ---------------- yaxunl wrote: > tra wrote: > > arsenm wrote: > > > yaxunl wrote: > > > > arsenm wrote: > > > > > arsenm wrote: > > > > > > yaxunl wrote: > > > > > > > arsenm wrote: > > > > > > > > I don't think the detection should fail if this is missing > > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken. > > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > > what is the directory structure of your most modern layout? > > > /opt/rocm/amdgcn/bitcode/foo.bc > > > > > > The plan is to remove this and rely on symlinks in the resource directory though > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code. > > > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version. > > > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary. > > Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version. > > Currently clang includes some wrapper headers by default, which does not work with ROCm 3.5 since those device functions are defined in HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable including those wrapper headers. This is one example why we need detect HIP version. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167 + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile) ---------------- yaxunl wrote: > yaxunl wrote: > > tra wrote: > > > arsenm wrote: > > > > yaxunl wrote: > > > > > arsenm wrote: > > > > > > arsenm wrote: > > > > > > > yaxunl wrote: > > > > > > > > arsenm wrote: > > > > > > > > > I don't think the detection should fail if this is missing > > > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken. > > > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > > > what is the directory structure of your most modern layout? > > > > /opt/rocm/amdgcn/bitcode/foo.bc > > > > > > > > The plan is to remove this and rely on symlinks in the resource directory though > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > > > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code. > > > > > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version. > > > > > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary. > > > > Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version. > > > > > Currently clang includes some wrapper headers by default, which does not work with ROCm 3.5 since those device functions are defined in HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable including those wrapper headers. This is one example why we need detect HIP version. I think we need to separate HIP runtime detection and device library detection and also separate hasValidHIPRuntime and hasValidDeviceLibrary. ROCm toolchain only need to make sure hasValidDeviceLibrary but HIP toolchain need both hasValidDeviceLibrary and hasValidHIPRuntime. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Mon Jul 6 14:42:48 2020 From: cfe-commits at lists.llvm.org (David Greene via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:42:48 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: <6b82c598f4c7f79a2646d2aa3eb04af6@localhost.localdomain> greened added a comment. In D83004#2129362 , @jdoerfert wrote: > This is great! Just a few days ago I added a TODO in one of the tests I created asking for this: D82722 :) Glad to help! > Will this work for all test scripts? Obviously right now it's only enabled for clang but it should be straightforward to add to the other test scripts. Al the infrastructure is there, the various drivers just have to use it. > Will this make the `prefix_exclusions` logic obsolete? Yeah, I think it might. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 From cfe-commits at lists.llvm.org Mon Jul 6 14:47:16 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 21:47:16 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: gamesh411 marked 5 inline comments as done. gamesh411 added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:282 + SVal &OffsetVal = IsItOnLHS ? RVal : LVal; + handlePtrIncrOrDecr(C, ItExpr, BinaryOperator::getOverloadedOperator(OK), + OffsetVal); ---------------- baloghadamsoftware wrote: > gamesh411 wrote: > > During the development of this patch, I saw something related. At the beginning of handlePtrIncrOrDecr, there is a branch on whether the Expr (2nd argument) is a pointer. I think that branch could just be an assertion. What do you think? (or maybe I should create a patch to show what I mean?) > I wonder whether this should be implemented here in `checkPostStmt()` ot in `handlePtrIncrOrDecr()`. Your current implementation is in `checkPostStmt()`, in this case we can assert in `handlePtrIncrOrDecl()`. I checked and decided it not really worth it to move the logic inside the `handlePtrIncrOrDecr()` function, as that would require us to pass both the left and right-hand side as `Expr`-s. This would be fine when we handle a binary operator, but if we handle a unary operator, we manually pass the SVal of RHS (namely a manually created ConcreteInt with value 1). All this could be abstracted with a function wrapping the original `handlePtrIncrOrDecr()`, but for now, I don't think it is worth it. ================ Comment at: clang/test/Analysis/iterator-modeling.cpp:169 + + auto i2 = 2 + i1; + ---------------- Note that this line requires the parent patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 From cfe-commits at lists.llvm.org Mon Jul 6 14:48:40 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:48:40 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: <3ffebc023c3abb9e54c11ac6c395a759@localhost.localdomain> ABataev added inline comments. ================ Comment at: clang/lib/Parse/ParseExpr.cpp:1944-1951 + if (StrideExpr && !StrideExpr->isValueDependent() && + (!StrideExpr->isEvaluatable(Actions.getASTContext()) || + (StrideExpr->EvaluateAsInt(Result, Actions.getASTContext()) && + !Result.Val.getInt().isOneValue()))) { + Diag(Tok, diag::err_omp_array_section_stride_only_zero_or_one) + << getOpenMPClauseName(OMPClauseKind) + << StrideExpr->getSourceRange(); ---------------- No, for non-to/from clauses the stride expression should not be allowed at all if I read the standard correctly. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 From cfe-commits at lists.llvm.org Mon Jul 6 14:49:23 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:49:23 +0000 (UTC) Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang In-Reply-To: References: Message-ID: <988bbfae255c59ffdb023ca080ab8838@localhost.localdomain> ABataev added a comment. In D75591#2134301 , @atmnpatel wrote: > Ping @ABataev. Rebase, please Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75591/new/ https://reviews.llvm.org/D75591 From cfe-commits at lists.llvm.org Mon Jul 6 14:50:15 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:50:15 +0000 (UTC) Subject: [PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation. Message-ID: ABataev created this revision. ABataev added a reviewer: jdoerfert. Herald added subscribers: aaron.ballman, sstefan1, jfb, guansong, yaxunl. Herald added a project: clang. Introduced OMPChildren class to handle all associated clauses, statement and child expressions/statements. It allows to represent some directives more correctly (like flush, depobj etc. with pseudo clauses, ordered depend directives, which are standalone, and target data directives). ALso, it will make easier to avoid using of CapturedStmt in directives, if required (atomic, tile etc. directives). Also, it simplifies serialization/deserialization of the executable directives. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83261 Files: clang/include/clang/AST/StmtOpenMP.h clang/lib/AST/StmtOpenMP.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/AST/ast-dump-openmp-ordered.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83261.275838.patch Type: text/x-patch Size: 289219 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:52:33 2020 From: cfe-commits at lists.llvm.org (Zixu Wang via cfe-commits) Date: Mon, 06 Jul 2020 14:52:33 -0700 (PDT) Subject: [clang] f47b885 - [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver Message-ID: <5f039d21.1c69fb81.c0e9c.f4c4@mx.google.com> Author: Zixu Wang Date: 2020-07-06T14:52:12-07:00 New Revision: f47b8851318d5ec2fa1e7867f3fdb86101cdc1da URL: https://github.com/llvm/llvm-project/commit/f47b8851318d5ec2fa1e7867f3fdb86101cdc1da DIFF: https://github.com/llvm/llvm-project/commit/f47b8851318d5ec2fa1e7867f3fdb86101cdc1da.diff LOG: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver Add clang option `-Wundef-prefix=TARGET_OS_` and `-Werror=undef-prefix` to Darwin driver. Differential Revision: https://reviews.llvm.org/D83250 Added: clang/test/Driver/darwin-warning-options.c Modified: clang/lib/Driver/ToolChains/Darwin.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index ad3b3a955d42..6bf42e6029eb 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -954,6 +954,10 @@ DarwinClang::DarwinClang(const Driver &D, const llvm::Triple &Triple, : Darwin(D, Triple, Args) {} void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const { + // Always error about undefined 'TARGET_OS_*' macros. + CC1Args.push_back("-Wundef-prefix=TARGET_OS_"); + CC1Args.push_back("-Werror=undef-prefix"); + // For modern targets, promote certain warnings to errors. if (isTargetWatchOSBased() || getTriple().isArch64Bit()) { // Always enable -Wdeprecated-objc-isa-usage and promote it diff --git a/clang/test/Driver/darwin-warning-options.c b/clang/test/Driver/darwin-warning-options.c new file mode 100644 index 000000000000..b0a591eac820 --- /dev/null +++ b/clang/test/Driver/darwin-warning-options.c @@ -0,0 +1,7 @@ +// REQUIRES: system-darwin + +// Always error about undefined 'TARGET_OS_*' macros on Darwin. +// RUN: %clang -### %s 2>&1 | FileCheck %s + +// CHECK-DAG: "-Wundef-prefix=TARGET_OS_" +// CHECK-DAG: "-Werror=undef-prefix" From cfe-commits at lists.llvm.org Mon Jul 6 14:52:37 2020 From: cfe-commits at lists.llvm.org (Zixu Wang via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:52:37 +0000 (UTC) Subject: [PATCH] D83250: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver In-Reply-To: References: Message-ID: <76c5688b16943c58686ddc8d326ca11d@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGf47b8851318d: [clang] Enable errors for undefined TARGET_OS_ macros in Darwin driver (authored by zixuw). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83250/new/ https://reviews.llvm.org/D83250 Files: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/darwin-warning-options.c Index: clang/test/Driver/darwin-warning-options.c =================================================================== --- /dev/null +++ clang/test/Driver/darwin-warning-options.c @@ -0,0 +1,7 @@ +// REQUIRES: system-darwin + +// Always error about undefined 'TARGET_OS_*' macros on Darwin. +// RUN: %clang -### %s 2>&1 | FileCheck %s + +// CHECK-DAG: "-Wundef-prefix=TARGET_OS_" +// CHECK-DAG: "-Werror=undef-prefix" Index: clang/lib/Driver/ToolChains/Darwin.cpp =================================================================== --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -954,6 +954,10 @@ : Darwin(D, Triple, Args) {} void DarwinClang::addClangWarningOptions(ArgStringList &CC1Args) const { + // Always error about undefined 'TARGET_OS_*' macros. + CC1Args.push_back("-Wundef-prefix=TARGET_OS_"); + CC1Args.push_back("-Werror=undef-prefix"); + // For modern targets, promote certain warnings to errors. if (isTargetWatchOSBased() || getTriple().isArch64Bit()) { // Always enable -Wdeprecated-objc-isa-usage and promote it -------------- next part -------------- A non-text attachment was scrubbed... Name: D83250.275839.patch Type: text/x-patch Size: 1093 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:56:49 2020 From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:56:49 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: Xiangling_L updated this revision to Diff 275840. Xiangling_L marked 6 inline comments as done. Xiangling_L added a comment. Fixed the `typedef` related issues; Added more testcases; CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 Files: clang/include/clang/AST/RecordLayout.h clang/include/clang/Basic/TargetInfo.h clang/lib/AST/ASTContext.cpp clang/lib/AST/RecordLayout.cpp clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Basic/Targets/PPC.h clang/test/Layout/aix-Wpacked.cpp clang/test/Layout/aix-double-struct-member.cpp clang/test/Layout/aix-no-unique-address-with-double.cpp clang/test/Layout/aix-power-alignment-typedef.cpp clang/test/Layout/aix-virtual-function-and-base-with-double.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D79719.275840.patch Type: text/x-patch Size: 64062 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:57:07 2020 From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:57:07 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: Xiangling_L added inline comments. ================ Comment at: clang/lib/AST/ASTContext.cpp:2409 + const RecordDecl *RD = RT->getDecl(); + return std::max(ABIAlign, static_cast(toBits( + getASTRecordLayout(RD).PreferredAlignment))); ---------------- hubert.reinterpretcast wrote: > hubert.reinterpretcast wrote: > > Please add a comment regarding the situations where the `ABIAlign` value is greater than the `PreferredAlignment` value. It may be appropriate to assert that, absent those cases, the `PreferredAlignment` value is at least that of `ABIAlign`. > It does not appear that the maximum of the two values is the correct answer: > ``` > struct C { > double x; > } c; > typedef struct C __attribute__((__aligned__(2))) CC; > > CC cc; > extern char x[__alignof__(cc)]; > extern char x[2]; // this is okay with IBM XL C/C++ > ``` > Please add a comment regarding the situations where the ABIAlign value is greater than the PreferredAlignment value. I added a `if` condition to guard the situation where `ABIAlign` should be returned instead of adding a comment. Please let me know if that is sufficient. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1888 + BTy->getKind() == BuiltinType::LongDouble) { + PreferredAlign = CharUnits::fromQuantity(8); + } ---------------- hubert.reinterpretcast wrote: > hubert.reinterpretcast wrote: > > I believe an assertion that `PreferredAlign` was 4 would be appropriate. > It seems that overriding the value should only be done after additional checks: > ``` > typedef double __attribute__((__aligned__(2))) Dbl; > struct A { > Dbl x; > } a; > extern char x[__alignof__(a)]; > extern char x[2]; // this is okay with IBM XL C/C++ > ``` > > I am getting concerned that the logic here overlaps quite a bit with `getPreferredTypeAlign` and refactoring to make the code here more common with `getPreferredTypeAlign` is necessary. Fixed the typedef related cases with my new changes, and the overlaps were not a lot as I expected. So I didn't do any refactoring yet. Please let me know if you still think it's necessary to refactor the code somehow. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 14:57:51 2020 From: cfe-commits at lists.llvm.org (Atmn Patel via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:57:51 +0000 (UTC) Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang In-Reply-To: References: Message-ID: <2099c64073e7902ff53b23de924e7f1f@localhost.localdomain> atmnpatel updated this revision to Diff 275841. atmnpatel added a comment. Herald added a subscriber: jfb. Rebased Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75591/new/ https://reviews.llvm.org/D75591 Files: clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp clang/docs/LibASTMatchersReference.html clang/include/clang/ASTMatchers/ASTMatchers.h clang/include/clang/Basic/DiagnosticParseKinds.td clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/distribute_parallel_for_default_messages.cpp clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/driver.c clang/test/OpenMP/parallel_default_messages.cpp clang/test/OpenMP/parallel_for_default_messages.cpp clang/test/OpenMP/parallel_for_simd_default_messages.cpp clang/test/OpenMP/parallel_master_codegen.cpp clang/test/OpenMP/parallel_master_default_messages.cpp clang/test/OpenMP/parallel_sections_default_messages.cpp clang/test/OpenMP/target_parallel_default_messages.cpp clang/test/OpenMP/target_parallel_for_default_messages.cpp clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp clang/test/OpenMP/target_teams_default_messages.cpp clang/test/OpenMP/target_teams_distribute_default_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/task_default_messages.cpp clang/test/OpenMP/task_messages.cpp clang/test/OpenMP/teams_default_messages.cpp clang/test/OpenMP/teams_distribute_default_messages.cpp clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/teams_distribute_simd_default_messages.cpp clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp clang/unittests/ASTMatchers/ASTMatchersTest.h llvm/include/llvm/Frontend/OpenMP/OMPKinds.def -------------- next part -------------- A non-text attachment was scrubbed... Name: D75591.275841.patch Type: text/x-patch Size: 283711 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 14:58:58 2020 From: cfe-commits at lists.llvm.org (Saleem Abdulrasool via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 21:58:58 +0000 (UTC) Subject: [PATCH] D82767: clang-format: Explicitly use python3 In-Reply-To: References: Message-ID: <8119dd75bc7f683d2edc39a864d2250f@localhost.localdomain> compnerd added a subscriber: arsen. compnerd added a comment. Thinking a bit more about this, using `/usr/bin/env python` ensures that we actually honour the python version that the user specifies because that allows the user control over the python symlink pointing to either python2 or python3. @arsen what do you think of just unifying on `/usr/bin/env python` across all the scripts? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82767/new/ https://reviews.llvm.org/D82767 From cfe-commits at lists.llvm.org Mon Jul 6 15:00:11 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 22:00:11 +0000 (UTC) Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failure In-Reply-To: References: Message-ID: MaskRay added a comment. The description appears to be wrapped at a very small column number. Can you please fix it? ================ Comment at: clang/test/Driver/program-path-priority.c:34 +/// isolated as we expected. +// NO_NOTREAL_GCC-NOT: {{\/gcc[^\/]*"}} ---------------- `\` can be removed. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83055/new/ https://reviews.llvm.org/D83055 From cfe-commits at lists.llvm.org Mon Jul 6 15:01:01 2020 From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits) Date: Mon, 06 Jul 2020 15:01:01 -0700 (PDT) Subject: [clang] c359c5d - [X86] Centalize the 'sse4' hack to a single place in X86TargetInfo::setFeatureEnabledImpl. NFCI Message-ID: <5f039f1d.1c69fb81.d3d8b.4092@mx.google.com> Author: Craig Topper Date: 2020-07-06T15:00:32-07:00 New Revision: c359c5d534429c96f1cebdf8d845b8120e9c2ef0 URL: https://github.com/llvm/llvm-project/commit/c359c5d534429c96f1cebdf8d845b8120e9c2ef0 DIFF: https://github.com/llvm/llvm-project/commit/c359c5d534429c96f1cebdf8d845b8120e9c2ef0.diff LOG: [X86] Centalize the 'sse4' hack to a single place in X86TargetInfo::setFeatureEnabledImpl. NFCI Instead of detecting the string in 2 places. Just swap the string to 'sse4.1' or 'sse4.2' at the top of the function. Prep work for a patch to switch the rest of this function to a table based system. And I don't want to include 'sse4a' in the table. Added: Modified: clang/lib/Basic/Targets/X86.cpp Removed: ################################################################################ diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 30f4570ecc02..2c6742b9042a 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -295,11 +295,18 @@ void X86TargetInfo::setXOPLevel(llvm::StringMap &Features, XOPEnum Level, void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, StringRef Name, bool Enabled) { - // This is a bit of a hack to deal with the sse4 target feature when used - // as part of the target attribute. We handle sse4 correctly everywhere - // else. See below for more information on how we handle the sse4 options. - if (Name != "sse4") - Features[Name] = Enabled; + if (Name == "sse4") { + // We can get here via the __target__ attribute since that's not controlled + // via the -msse4/-mno-sse4 command line alias. Handle this the same way + // here - turn on the sse4.2 if enabled, turn off the sse4.1 level if + // disabled. + if (Enabled) + Name = "sse4.2"; + else + Name = "sse4.1"; + } + + Features[Name] = Enabled; if (Name == "mmx") { setMMXLevel(Features, MMX, Enabled); @@ -381,15 +388,6 @@ void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, } else if (Name == "sha") { if (Enabled) setSSELevel(Features, SSE2, Enabled); - } else if (Name == "sse4") { - // We can get here via the __target__ attribute since that's not controlled - // via the -msse4/-mno-sse4 command line alias. Handle this the same way - // here - turn on the sse4.2 if enabled, turn off the sse4.1 level if - // disabled. - if (Enabled) - setSSELevel(Features, SSE42, Enabled); - else - setSSELevel(Features, SSE41, Enabled); } else if (Name == "xsave") { if (!Enabled) Features["xsaveopt"] = Features["xsavec"] = Features["xsaves"] = false; From cfe-commits at lists.llvm.org Mon Jul 6 15:19:08 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 22:19:08 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors Message-ID: oontvoo created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repro: - Annotate the unique_ptr class with trivial_abi (eg., https://godbolt.org/z/-rprsc) - ./build/bin/clang++ -stdlib=libc++ -I../libcxx/memory Crash: @ 0x559d129463fc clang::CXXRecordDecl::defaultedCopyConstructorIsDeleted() @ 0x559d1288d3e5 clang::Sema::checkIllFormedTrivialABIStruct()::$_7::operator()() @ 0x559d12884c34 clang::Sema::checkIllFormedTrivialABIStruct() @ 0x559d1288412e clang::Sema::CheckCompletedCXXClass() @ 0x559d1288d843 clang::Sema::ActOnFinishCXXMemberSpecification() @ 0x559d12020109 clang::Parser::ParseCXXMemberSpecification() @ 0x559d1201e80c clang::Parser::ParseClassSpecifier() @ 0x559d1204e807 clang::Parser::ParseDeclarationSpecifiers() @ 0x559d120e9aa9 clang::Parser::ParseSingleDeclarationAfterTemplate() @ 0x559d120e8f21 clang::Parser::ParseTemplateDeclarationOrSpecialization() @ 0x559d120e8886 clang::Parser::ParseDeclarationStartingWithTemplate() @ 0x559d1204a1d4 clang::Parser::ParseDeclaration() @ 0x559d12004b1d clang::Parser::ParseExternalDeclaration() @ 0x559d12017689 clang::Parser::ParseInnerNamespace() @ 0x559d12017024 clang::Parser::ParseNamespace() @ 0x559d1204a29b clang::Parser::ParseDeclaration() @ 0x559d12004c74 clang::Parser::ParseExternalDeclaration() Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83263 Files: clang/lib/Sema/SemaDeclCXX.cpp Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -9719,6 +9719,11 @@ // Ill-formed if the copy and move constructors are deleted. auto HasNonDeletedCopyOrMoveConstructor = [&]() { + // If we know there exist users-defined move/copy ctors, don't try to infer + // the deletion of implicit ones becausee Sema may not have the info yet. + if (RD.hasUserDeclaredMoveConstructor() || + RD.hasUserDeclaredCopyConstructor()) + return true; if (RD.needsImplicitCopyConstructor() && !RD.defaultedCopyConstructorIsDeleted()) return true; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83263.275849.patch Type: text/x-patch Size: 708 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 15:56:53 2020 From: cfe-commits at lists.llvm.org (Atmn Patel via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 22:56:53 +0000 (UTC) Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang In-Reply-To: References: Message-ID: <826d1e0b02aa6e18b4ec8fa704b54f3d@localhost.localdomain> atmnpatel updated this revision to Diff 275855. atmnpatel added a comment. Fixed tests. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75591/new/ https://reviews.llvm.org/D75591 Files: clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp clang/docs/LibASTMatchersReference.html clang/include/clang/ASTMatchers/ASTMatchers.h clang/include/clang/Basic/DiagnosticParseKinds.td clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/distribute_parallel_for_default_messages.cpp clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/driver.c clang/test/OpenMP/parallel_default_messages.cpp clang/test/OpenMP/parallel_for_default_messages.cpp clang/test/OpenMP/parallel_for_simd_default_messages.cpp clang/test/OpenMP/parallel_master_codegen.cpp clang/test/OpenMP/parallel_master_default_messages.cpp clang/test/OpenMP/parallel_sections_default_messages.cpp clang/test/OpenMP/target_parallel_default_messages.cpp clang/test/OpenMP/target_parallel_for_default_messages.cpp clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp clang/test/OpenMP/target_teams_default_messages.cpp clang/test/OpenMP/target_teams_distribute_default_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/task_default_messages.cpp clang/test/OpenMP/task_messages.cpp clang/test/OpenMP/teams_default_messages.cpp clang/test/OpenMP/teams_distribute_default_messages.cpp clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/teams_distribute_simd_default_messages.cpp clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp clang/unittests/ASTMatchers/ASTMatchersTest.h llvm/include/llvm/Frontend/OpenMP/OMPKinds.def -------------- next part -------------- A non-text attachment was scrubbed... Name: D75591.275855.patch Type: text/x-patch Size: 274251 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 16:00:18 2020 From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 23:00:18 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: cchen updated this revision to Diff 275856. cchen added a comment. Fix based on comment Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 Files: clang/include/clang-c/Index.h clang/include/clang/AST/ExprOpenMP.h clang/include/clang/Basic/DiagnosticParseKinds.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/StmtPrinter.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/OpenMP/target_data_messages.c clang/test/OpenMP/target_depend_messages.cpp clang/test/OpenMP/target_enter_data_depend_messages.cpp clang/test/OpenMP/target_exit_data_depend_messages.cpp clang/test/OpenMP/target_map_messages.cpp clang/test/OpenMP/target_parallel_depend_messages.cpp clang/test/OpenMP/target_parallel_for_depend_messages.cpp clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_simd_depend_messages.cpp clang/test/OpenMP/target_teams_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp clang/test/OpenMP/target_update_ast_print.cpp clang/test/OpenMP/target_update_depend_messages.cpp clang/test/OpenMP/target_update_messages.cpp clang/test/OpenMP/task_affinity_messages.cpp clang/test/OpenMP/task_depend_messages.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82800.275856.patch Type: text/x-patch Size: 50133 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 16:11:02 2020 From: cfe-commits at lists.llvm.org (Jan Korous via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 23:11:02 +0000 (UTC) Subject: [PATCH] D82629: [libclang] Fix crash when visiting a captured VLA. In-Reply-To: References: Message-ID: <540973722061ecd114671123e0f7a930@localhost.localdomain> jkorous accepted this revision. jkorous added a comment. This revision is now accepted and ready to land. LGTM! Thanks for fixing this! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82629/new/ https://reviews.llvm.org/D82629 From cfe-commits at lists.llvm.org Mon Jul 6 16:11:09 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Johel_Ernesto_Guerrero_Pe=C3=B1a_via_Phabricator?= via cfe-commits) Date: Mon, 06 Jul 2020 23:11:09 +0000 (UTC) Subject: [PATCH] D79773: [clang-format] Improve clang-formats handling of concepts In-Reply-To: References: Message-ID: <6800a878fda9b5551e59733d94c50a74@localhost.localdomain> JohelEGP added a comment. Yes, it's valid C++ (is my hope). It's from WIP code, which I made available to show you: https://github.com/johelegp/jge. Here it is building, running and passing the tests: https://travis-ci.com/github/johelegp/jge/jobs/358137355#L559. Here are links to the above linked snippets: - Now looking good: - https://github.com/johelegp/jge/blob/master/include/jge/cartesian.hpp#L84-L90 - https://github.com/johelegp/jge/blob/master/include/jge/plane.hpp#L54-L59 - https://github.com/johelegp/jge/blob/master/tests/jge/cartesian.cpp#L18-L20. - Just reported: - Inheritance: https://github.com/johelegp/jge/blob/master/tests/jge/cartesian.cpp#L11-L21 (https://reviews.llvm.org/D79773#2131680) - Non list-initialization: https://github.com/johelegp/jge/blob/master/tests/jge/cartesian.cpp#L11-L16 (https://reviews.llvm.org/D79773#2132086) - For the `EqualityComparable` case (https://reviews.llvm.org/D79773#2131680), I use this macro: https://github.com/johelegp/jge/blob/master/include/jge/detail/quantity_wrappers.hpp#L4-L5. Example: https://github.com/johelegp/jge/blob/master/include/jge/detail/quantity_wrappers.hpp#L59. I also used it before the previous fixes besides `//` comments. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79773/new/ https://reviews.llvm.org/D79773 From cfe-commits at lists.llvm.org Mon Jul 6 16:12:35 2020 From: cfe-commits at lists.llvm.org (Jan Korous via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 23:12:35 +0000 (UTC) Subject: [PATCH] D82740: [libclang]: check validity before visiting Stmt node In-Reply-To: References: Message-ID: <98bd587d02826464510279964e168642@localhost.localdomain> jkorous added a comment. @milianw I just approved https://reviews.llvm.org/D82629 - I feel like that patch is addressing the core issue. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82740/new/ https://reviews.llvm.org/D82740 From cfe-commits at lists.llvm.org Mon Jul 6 16:13:23 2020 From: cfe-commits at lists.llvm.org (Jan Korous via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 23:13:23 +0000 (UTC) Subject: [PATCH] D82629: [libclang] Fix crash when visiting a captured VLA. In-Reply-To: References: Message-ID: <0bccea46219c0649a02372ec9027baa7@localhost.localdomain> jkorous added a comment. @ckandeler do you have commit access or do you want me to land the patch? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82629/new/ https://reviews.llvm.org/D82629 From cfe-commits at lists.llvm.org Mon Jul 6 16:43:25 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Mon, 06 Jul 2020 23:43:25 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:666 + /// HasNonEmptyBaseClass - Whether the class has any non-empty class (in the + /// sense of (C++11 [meta.unary.prop])) as base. + bool HasNonEmptyBaseClass; ---------------- Minor nit: s/as base/as a base/; ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:707 + HandledFirstNonOverlappingEmptyField(false), + HasNonEmptyBaseClass(false), + FirstNearlyEmptyVBase(nullptr) {} ---------------- Minor nit: Please fix the formatting. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1225 + Context.getTargetInfo().getTriple().isPS4() || + Context.getTargetInfo().getTriple().isOSAIX())) + ? CharUnits::One() ---------------- Thanks; verified that this is correct with `xlclang++` from IBM XL C/C++ for AIX with: ``` struct A { char x; }; struct B { int x; }; struct __attribute__((__packed__)) C : A, B {} c; ``` Length is 5: ``` [10] m 0x00000004 .bss 1 extern c [11] a4 0x00000005 0 0 CM RW 0 0 ``` @Xiangling_L, I suggest adding a case for this to the tests. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1256 + // space or zero-extent array. + if (DefaultsToAIXPowerAlignment && !(getDataSize().isZero() || IsUnion)) { + PreferredBaseAlign = BaseAlign; ---------------- Unions cannot have base classes. Please assert `!IsUnion`. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1260 + + // The maximum field alignment overrides base align/preferred base align(AIX + // only). ---------------- Suggestion: ``` // The maximum field alignment overrides the base align/(AIX-only) preferred // base align. ``` ================ Comment at: clang/test/Layout/aix-power-alignment-typedef.cpp:18 + +// CHECK-DAG: @_ZN5test11aE = global i32 2, align 4 + ---------------- Instead of checking the value of `a`, the alignment can be checked more directly from the IR for `cc`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 16:53:42 2020 From: cfe-commits at lists.llvm.org (Amara Emerson via cfe-commits) Date: Mon, 06 Jul 2020 16:53:42 -0700 (PDT) Subject: [clang] 3c7e8d6 - Fix sdk version test to use 99.99.99 as a max dummy version instead of 10.99.99. Message-ID: <5f03b986.1c69fb81.ee2ed.55ea@mx.google.com> Author: Amara Emerson Date: 2020-07-06T16:53:12-07:00 New Revision: 3c7e8d6d0eb0660fb8fbae98c3e49ca059943416 URL: https://github.com/llvm/llvm-project/commit/3c7e8d6d0eb0660fb8fbae98c3e49ca059943416 DIFF: https://github.com/llvm/llvm-project/commit/3c7e8d6d0eb0660fb8fbae98c3e49ca059943416.diff LOG: Fix sdk version test to use 99.99.99 as a max dummy version instead of 10.99.99. Was failing on macOS 11 hosts which is > 10.99.99 Added: Modified: clang/test/Driver/darwin-sdk-vs-os-version.c Removed: ################################################################################ diff --git a/clang/test/Driver/darwin-sdk-vs-os-version.c b/clang/test/Driver/darwin-sdk-vs-os-version.c index 391f4d5a7305..94e52a9036ed 100644 --- a/clang/test/Driver/darwin-sdk-vs-os-version.c +++ b/clang/test/Driver/darwin-sdk-vs-os-version.c @@ -2,9 +2,9 @@ // Ensure that we never pick a version that's based on the SDK that's newer than // the system version: -// RUN: rm -rf %t/SDKs/MacOSX10.99.99.sdk -// RUN: mkdir -p %t/SDKs/MacOSX10.99.99.sdk -// RUN: %clang -target x86_64-apple-darwin -isysroot %t/SDKs/MacOSX10.99.99.sdk %s -### 2>&1 \ +// RUN: rm -rf %t/SDKs/MacOSX99.99.99.sdk +// RUN: mkdir -p %t/SDKs/MacOSX99.99.99.sdk +// RUN: %clang -target x86_64-apple-darwin -isysroot %t/SDKs/MacOSX99.99.99.sdk %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MACOSX-SYSTEM-VERSION %s -// CHECK-MACOSX-SYSTEM-VERSION-NOT: 10.99.99" +// CHECK-MACOSX-SYSTEM-VERSION-NOT: 99.99.99" From cfe-commits at lists.llvm.org Mon Jul 6 17:04:42 2020 From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 00:04:42 +0000 (UTC) Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source In-Reply-To: References: Message-ID: shafik updated this revision to Diff 275865. shafik added a comment. Adding a second test that is not arm64 specific. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83008/new/ https://reviews.llvm.org/D83008 Files: clang/lib/AST/RecordLayoutBuilder.cpp lldb/test/Shell/Expr/Inputs/layout.cpp lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test =================================================================== --- /dev/null +++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test @@ -0,0 +1,11 @@ +# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t + +# RUN: %lldb %t -b -s %s | FileCheck %s + +expr (intptr_t)&d2g.ID - (intptr_t)&d2g +# CHECK: (lldb) expr (intptr_t)&d2g.ID - (intptr_t)&d2g +# CHECK: (long) $0 = 12 + +expr (intptr_t)&d3g.f2 - (intptr_t)&d3g +# CHECK: (lldb) expr (intptr_t)&d3g.f2 - (intptr_t)&d3g +# CHECK: (long) $1 = 8 Index: lldb/test/Shell/Expr/Inputs/layout.cpp =================================================================== --- /dev/null +++ lldb/test/Shell/Expr/Inputs/layout.cpp @@ -0,0 +1,43 @@ +#include + +struct B1 { + uint8_t a; +}; + +struct D1 : public B1 { + uint8_t a; + uint32_t ID; + uint8_t b; +}; + +struct Mixin : public D1 { + uint8_t a; + uint32_t *arr[3]; +}; + +struct B2 { + uint32_t a; +}; + +class D2 : public B2, public Mixin {}; + +struct B3 { + char f1; +}; + +struct alignas(8) B4 { + char f2; +}; + +struct D3 : B3, B4 { +}; + +D2 d2g; +D3 d3g; + +int main() { + D2 d2; + D3 d3; + + return d2.ID + d3.f2; +} Index: clang/lib/AST/RecordLayoutBuilder.cpp =================================================================== --- clang/lib/AST/RecordLayoutBuilder.cpp +++ clang/lib/AST/RecordLayoutBuilder.cpp @@ -1187,11 +1187,10 @@ // Query the external layout to see if it provides an offset. bool HasExternalLayout = false; if (UseExternalLayout) { - // FIXME: This appears to be reversed. if (Base->IsVirtual) - HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset); - else HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset); + else + HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset); } // Clang <= 6 incorrectly applied the 'packed' attribute to base classes. -------------- next part -------------- A non-text attachment was scrubbed... Name: D83008.275865.patch Type: text/x-patch Size: 1986 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 17:07:38 2020 From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 00:07:38 +0000 (UTC) Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source In-Reply-To: References: Message-ID: <71a4e75cb2e7781a653fbe3d2e4ec7af@localhost.localdomain> shafik added a comment. In D83008#2131776 , @teemperor wrote: > Thanks for tracking this down, this is a really nasty bug... > > The fix itself is obviously fine, but I think I'm out of the loop regarding the testing strategy. We talked about adding a Clang test for this with the help of this layout overwrite JSON file. I assume that extending this to cover virtual bases turned out to be more complicated than expected? FWIW, I'm not necessarily the biggest fan of this Clang test option so I would be fine if we leave it as-is. > > I think having an LLDB test is a good idea, but it's not clear why it's a Shell test. If I understand correctly this test requires running on arm64 (so, a remote test target), but from what I remember all the remote platform support is only in dotest.py? Also pretty much all other expression evaluation tests and the utilities for that are in the Python/API test infrastructure, so it's a bit out of place. > > Also I think the test can be in general much simpler than an arm64-specific test. We get all base class offsets wrong in LLDB, so we can just write a simple test where you change the layout of some structs in a way that it doesn't fit the default layout. E.g., just putting `alignas` on a base class and then reading fields should be enough to trigger the same bug. Good idea using `alignas` that actually did the trick, I was having trouble getting this to reproduce otherwise. I added a second test which should also reproduce on non-arm64 cases but I will keep the original test as well since they are hitting the bug from slightly different paths. The goal of using a shell test was to avoid writing a device specific test and even though the first case should also pass on all other platforms. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83008/new/ https://reviews.llvm.org/D83008 From cfe-commits at lists.llvm.org Mon Jul 6 17:11:56 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 00:11:56 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors In-Reply-To: References: Message-ID: oontvoo updated this revision to Diff 275866. oontvoo added a comment. add test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83263/new/ https://reviews.llvm.org/D83263 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/trivial-abi-templated-type.cpp Index: clang/test/SemaCXX/trivial-abi-templated-type.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/trivial-abi-templated-type.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 +// expected-no-diagnostics + +template +class __attribute__((trivial_abi)) a { a(a &&); }; Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -6591,7 +6591,7 @@ } // See if trivial_abi has to be dropped. - if (Record->hasAttr()) + if (!Record->isDependentType() && Record->hasAttr()) checkIllFormedTrivialABIStruct(*Record); // Set HasTrivialSpecialMemberForCall if the record has attribute -------------- next part -------------- A non-text attachment was scrubbed... Name: D83263.275866.patch Type: text/x-patch Size: 845 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 18:04:18 2020 From: cfe-commits at lists.llvm.org (Pierre Habouzit via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:04:18 +0000 (UTC) Subject: [PATCH] D82611: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods In-Reply-To: References: Message-ID: MadCoder added a comment. In D82611#2133521 , @erik.pilkington wrote: > In D82611#2125868 , @MadCoder wrote: > > > > >> I would suggest something like `-Wstrict-direct-dispatch` or something. > > I kinda prefer `-Wpotentially-direct-selector`, since that seems to more closely correspond to what the compiler is complaining about. WDYT? Yes, that is better, I wasn't dead-set on the name. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82611/new/ https://reviews.llvm.org/D82611 From cfe-commits at lists.llvm.org Mon Jul 6 18:05:49 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:05:49 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments Message-ID: jdoerfert created this revision. jdoerfert added reviewers: jhuber6, fghanim, JonChesterfield, grokos, AndreyChurbanov, ye-luo, tianshilei1992, ggeorgakoudis. Herald added subscribers: llvm-commits, cfe-commits, sstefan1, guansong, bollu, yaxunl, jholewinski. Herald added projects: clang, OpenMP, LLVM. There are various runtime calls in the device runtime with unused, or always fixed, arguments. This is bad for all sorts of reasons. Clean up two before as we match them in OpenMPOpt now. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83268 Files: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp clang/test/OpenMP/nvptx_data_sharing.cpp clang/test/OpenMP/nvptx_parallel_codegen.cpp clang/test/OpenMP/nvptx_target_codegen.cpp clang/test/OpenMP/nvptx_target_teams_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp llvm/include/llvm/Frontend/OpenMP/OMPKinds.def openmp/libomptarget/deviceRTLs/common/src/parallel.cu openmp/libomptarget/deviceRTLs/interface.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D83268.275871.patch Type: text/x-patch Size: 12960 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 18:12:41 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:12:41 +0000 (UTC) Subject: [PATCH] D83154: clang: Add -fcoverage-prefix-map In-Reply-To: References: Message-ID: <7fcc2d2cbbedd23b2e2094e3fc8e1eb9@localhost.localdomain> MaskRay added a comment. GCC obtained -fdebug-prefix-map first, then r256847 added both -fmacro-prefix-map and -ffile-prefix-map. GCC doesn't have -fcoverage-prefix-map and I saw your https://github.com/apple/swift/pull/32416 However, do we really need one new -f*-prefix-map for every feature? If you think `-fcoverage-prefix-map=` is really necessary, you can probably ask whether GCC can adopt a -fcoverage-prefix-map for their gcov (.gcno files). If they do, reviewers may have more have more confidence to say that we should have the option as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83154/new/ https://reviews.llvm.org/D83154 From cfe-commits at lists.llvm.org Mon Jul 6 18:15:05 2020 From: cfe-commits at lists.llvm.org (Keith Smiley via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:15:05 +0000 (UTC) Subject: [PATCH] D83154: clang: Add -fcoverage-prefix-map In-Reply-To: References: Message-ID: keith added a comment. I originally implemented this behavior behind `-fdebug-prefix-map` but there was some pushback, more context: https://lists.llvm.org/pipermail/cfe-dev/2020-June/065668.html Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83154/new/ https://reviews.llvm.org/D83154 From cfe-commits at lists.llvm.org Mon Jul 6 18:18:25 2020 From: cfe-commits at lists.llvm.org (David Greene via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:18:25 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: <34ac37d3d1fba20ba3d31b60492aac0e@localhost.localdomain> greened added a comment. In D83004#2134303 , @greened wrote: > > I don't particularly like this mode dichotomy but unifying it would necessitate updating a whole lot of clang tests. Axtually that's not strictly true, It would just change the tests singificantly when they are updated for some other reason. Whether that is reasonable is something we should discuss. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 From cfe-commits at lists.llvm.org Mon Jul 6 18:21:54 2020 From: cfe-commits at lists.llvm.org (David Greene via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:21:54 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: greened marked an inline comment as done. greened added inline comments. ================ Comment at: llvm/utils/update_cc_test_checks.py:133 + parser.add_argument('--include-generated-funcs', action='store_true', + help='Output checks for functions not in source') parser.add_argument('tests', nargs='+') ---------------- greened wrote: > jdoerfert wrote: > > I think this should go into common.py (after D78618). I would also make this the default but OK. > Yes I suppose it should in case `opt` and friends generate functions. I hadn't considered that use-case. > > While I would like to make it default unfortunately it would require updating a bunch of the existing clang tests which doesn't seem too friendly. See the patch update comment for details. > Just realized it wouldn't necessarily require regeneration of tests, it would just cause regenerated tests to change a lot when they are eventually regenerated. We should discuss as to whether that's acceptable. I think for now this should be non-default to at least get the functionality in without disturbing existing users and then we can discuss a separate change to make it default. It's also possible we could change how clang orders functions. I discovered there's a difference in clang 10 vs. 11 in the order functions are output when OpenMP outlining happens. clang 10 seems to preserve the source order of functions and clang 11 does not. Perhaps that needs to be fixed as I don't know whether that change was intentional or not. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 From cfe-commits at lists.llvm.org Mon Jul 6 18:31:13 2020 From: cfe-commits at lists.llvm.org (Lei Huang via cfe-commits) Date: Mon, 06 Jul 2020 18:31:13 -0700 (PDT) Subject: [clang] 0c6b6e2 - [PowerPC] Implement Vector Splat Immediate Builtins in Clang Message-ID: <5f03d061.1c69fb81.37039.4cd5@mx.google.com> Author: Biplob Mishra Date: 2020-07-06T20:29:33-05:00 New Revision: 0c6b6e28e70c06a3cb4704d2d8f90829a689e230 URL: https://github.com/llvm/llvm-project/commit/0c6b6e28e70c06a3cb4704d2d8f90829a689e230 DIFF: https://github.com/llvm/llvm-project/commit/0c6b6e28e70c06a3cb4704d2d8f90829a689e230.diff LOG: [PowerPC] Implement Vector Splat Immediate Builtins in Clang Implements builtins for the following prototypes: vector signed int vec_splati (const signed int); vector float vec_splati (const float); vector double vec_splatid (const float); vector signed int vec_splati_ins (vector signed int, const unsigned int, const signed int); vector unsigned int vec_splati_ins (vector unsigned int, const unsigned int, const unsigned int); vector float vec_splati_ins (vector float, const unsigned int, const float); Differential Revision: https://reviews.llvm.org/D82520 Added: Modified: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c llvm/test/CodeGen/PowerPC/p10-splatImm.ll Removed: ################################################################################ diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index a63f2ee359fd..9a4009216930 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -17094,6 +17094,58 @@ vec_blendv(vector double __a, vector double __b, vector unsigned long long __c) { return __builtin_vsx_xxblendvd(__a, __b, __c); } + +/* vec_splati */ + +#define vec_splati(__a) \ + _Generic((__a), signed int \ + : ((vector signed int)__a), unsigned int \ + : ((vector unsigned int)__a), float \ + : ((vector float)__a)) + +/* vec_spatid */ + +static __inline__ vector double __ATTRS_o_ai vec_splatid(const float __a) { + return ((vector double)((double)__a)); +} + +/* vec_splati_ins */ + +static __inline__ vector signed int __ATTRS_o_ai vec_splati_ins( + vector signed int __a, const unsigned int __b, const signed int __c) { +#ifdef __LITTLE_ENDIAN__ + __a[1 - __b] = __c; + __a[3 - __b] = __c; +#else + __a[__b] = __c; + __a[2 + __b] = __c; +#endif + return __a; +} + +static __inline__ vector unsigned int __ATTRS_o_ai vec_splati_ins( + vector unsigned int __a, const unsigned int __b, const unsigned int __c) { +#ifdef __LITTLE_ENDIAN__ + __a[1 - __b] = __c; + __a[3 - __b] = __c; +#else + __a[__b] = __c; + __a[2 + __b] = __c; +#endif + return __a; +} + +static __inline__ vector float __ATTRS_o_ai +vec_splati_ins(vector float __a, const unsigned int __b, const float __c) { +#ifdef __LITTLE_ENDIAN__ + __a[1 - __b] = __c; + __a[3 - __b] = __c; +#else + __a[__b] = __c; + __a[2 + __b] = __c; +#endif + return __a; +} #endif /* __VSX__ */ #endif /* __POWER10_VECTOR__ */ diff --git a/clang/test/CodeGen/builtins-ppc-p10vector.c b/clang/test/CodeGen/builtins-ppc-p10vector.c index b0602dd66f53..22b4e7a6f3ec 100644 --- a/clang/test/CodeGen/builtins-ppc-p10vector.c +++ b/clang/test/CodeGen/builtins-ppc-p10vector.c @@ -512,3 +512,72 @@ vector unsigned int test_vec_inserth_uiv(void) { // CHECK-LE-NEXT: ret <4 x i32> return vec_inserth(vuia, vuib, uia); } + +vector signed int test_vec_vec_splati_si(void) { + // CHECK-BE: ret <4 x i32> + // CHECK: ret <4 x i32> + return vec_splati(-17); +} + +vector unsigned int test_vec_vec_splati_ui(void) { + // CHECK-BE: ret <4 x i32> + // CHECK: ret <4 x i32> + return vec_splati(16U); +} + +vector float test_vec_vec_splati_f(void) { + // CHECK-BE: ret <4 x float> + // CHECK: ret <4 x float> + return vec_splati(1.0f); +} + +vector double test_vec_vec_splatid(void) { + // CHECK-BE: [[T1:%.+]] = fpext float %{{.+}} to double + // CHECK-BE-NEXT: [[T2:%.+]] = insertelement <2 x double> undef, double [[T1:%.+]], i32 0 + // CHECK-BE-NEXT: [[T3:%.+]] = shufflevector <2 x double> [[T2:%.+]], <2 x double> undef, <2 x i32> zeroinitialize + // CHECK-BE-NEXT: ret <2 x double> [[T3:%.+]] + // CHECK: [[T1:%.+]] = fpext float %{{.+}} to double + // CHECK-NEXT: [[T2:%.+]] = insertelement <2 x double> undef, double [[T1:%.+]], i32 0 + // CHECK-NEXT: [[T3:%.+]] = shufflevector <2 x double> [[T2:%.+]], <2 x double> undef, <2 x i32> zeroinitialize + // CHECK-NEXT: ret <2 x double> [[T3:%.+]] + return vec_splatid(1.0); +} + +vector signed int test_vec_vec_splati_ins_si(void) { + // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 %{{.+}} + // CHECK-BE: [[T1:%.+]] = add i32 2, %{{.+}} + // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]] + // CHECK-BE: ret <4 x i32> + // CHECK: [[T1:%.+]] = sub i32 1, %{{.+}} + // CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]] + // CHECK: [[T2:%.+]] = sub i32 3, %{{.+}} + // CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T2]] + // CHECK: ret <4 x i32> + return vec_splati_ins(vsia, 0, -17); +} + +vector unsigned int test_vec_vec_splati_ins_ui(void) { + // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 %{{.+}} + // CHECK-BE: [[T1:%.+]] = add i32 2, %{{.+}} + // CHECK-BE: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]] + // CHECK-BE: ret <4 x i32> + // CHECK: [[T1:%.+]] = sub i32 1, %{{.+}} + // CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T1]] + // CHECK: [[T2:%.+]] = sub i32 3, %{{.+}} + // CHECK: insertelement <4 x i32> %{{.+}}, i32 %{{.+}}, i32 [[T2]] + // CHECK: ret <4 x i32> + return vec_splati_ins(vuia, 1, 16U); +} + +vector float test_vec_vec_splati_ins_f(void) { + // CHECK-BE: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 %{{.+}} + // CHECK-BE: [[T1:%.+]] = add i32 2, %{{.+}} + // CHECK-BE: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 [[T1]] + // CHECK-BE: ret <4 x float> + // CHECK: [[T1:%.+]] = sub i32 1, %{{.+}} + // CHECK: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 [[T1]] + // CHECK: [[T2:%.+]] = sub i32 3, %{{.+}} + // CHECK: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 [[T2]] + // CHECK: ret <4 x float> + return vec_splati_ins(vfa, 0, 1.0f); +} diff --git a/llvm/test/CodeGen/PowerPC/p10-splatImm.ll b/llvm/test/CodeGen/PowerPC/p10-splatImm.ll index b468f6d00451..8bb83c22be58 100644 --- a/llvm/test/CodeGen/PowerPC/p10-splatImm.ll +++ b/llvm/test/CodeGen/PowerPC/p10-splatImm.ll @@ -286,3 +286,21 @@ define dso_local double @testDoubleZeroScalar() local_unnamed_addr { entry: ret double 0.000000e+00 } + +define dso_local <4 x i32> @vec_splati() local_unnamed_addr { +; CHECK-LABEL: vec_splati: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltiw vs34, -17 +; CHECK-NEXT: blr +entry: + ret <4 x i32> +} + +define dso_local <2 x double> @vec_splatid() local_unnamed_addr { +; CHECK-LABEL: vec_splatid: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: xxspltidp vs34, 1065353216 +; CHECK-NEXT: blr +entry: + ret <2 x double> +} From cfe-commits at lists.llvm.org Mon Jul 6 18:31:29 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:31:29 +0000 (UTC) Subject: [PATCH] D82520: [Power10] Implement Vector Splat Immediate Builtins in LLVM/Clang In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG0c6b6e28e70c: [PowerPC] Implement Vector Splat Immediate Builtins in Clang (authored by biplmish, committed by lei). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D82520?vs=275790&id=275881#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82520/new/ https://reviews.llvm.org/D82520 Files: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c llvm/test/CodeGen/PowerPC/p10-splatImm.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82520.275881.patch Type: text/x-patch Size: 6056 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 18:38:03 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:38:03 +0000 (UTC) Subject: [PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives. In-Reply-To: References: Message-ID: dblaikie added a comment. In D82617#2119394 , @sammccall wrote: > Abandoning, we'll do this in clangd or find an acceptable way to silence it (see D82736 ). > > In D82617#2119144 , @dblaikie wrote: > > > In D82617#2119138 , @sammccall wrote: > > > > > > Guess perhaps a different question: Why don't you want this for clangd? Does it make the codebase better by not adhering to this particular warning? > > > > > > Yes, exactly. (Sorry if this wasn't explicit). > > > > > > Sorry - poor phrasing on my part. Seems we disagree on this - I think it's probably a good thing to adhere to, you don't. > > > Yeah, I think we disagree, and that's OK! We need to stop emitting a warning, and apart from that, this doesn't seem like a terribly important question that needs an LLVM-wide policy. > > On stylistic questions like this, I think code owners generally decide, right? So my intent was to drop this proposed change for clang (no consensus) and take these opinions under advisement for clangd. > > I didn't re-engage here on the substance as I think all the arguments are played out and nobody's mind is being changed, and I figured it was time to move on. > > > I'd like to better understand the difference of opinions. > > Sure, and apologies I didn't read it that way. I can summarize the counterargument as: > > 1. I agree that this warning flags cases with confusing code, though in some cases (like ThreadsafeFS::view) I think the potential for confusion *due to the name-hiding + overloading pattern* is very low. Fair - I'd be willing to classify this particular case as pretty close to a false positive. But for me it'd be under the bucket of false positive's like GCC's -Wparetheses which warns on assert("message" && x || y) (GCC warns about the user probably meaning (x || y), Clang doesn't because it notices you get the same answer with or without the parens) - a bit annoying, but probably harmless enough to add the parens to let GCC users keep getting the warnings (& in that case - just means they'll be less likely to break LLVM self-hosting buildbots than if we disabled the GCC warning entirely) > 2. Marking one method of an overload set virtual and implementing others in terms of it is the most direct way to express what we're trying to do here. (e.g. in Java which has no equivalent name-hiding pattern, nobody really takes issue with this). Therefore if the name-hiding is harmless or close-to-it, it's the clearest expression of this pattern. If there wasn't any name hiding, I wouldn't have a problem with the code as-is. For me it's about the call-sites rather than the implementation. Looking at a derived class never gives you the whole picture of the class's API anyway. > 3. The question of whether people like the concrete names or the overload set chosen in ThreadsafeFS is irrelevant here. Yep - agreed. That's a conversation for other reviews/threads. > I think there's a fair amount of disagreement about (1), nobody really presented a counterargument to (2), and for some reason we spent a lot of time on (3) which seems to be a total bikeshed on a tangentially related topic that had been settled in the usual way. Appreciate the summary/thoughts! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82617/new/ https://reviews.llvm.org/D82617 From cfe-commits at lists.llvm.org Mon Jul 6 18:45:19 2020 From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:45:19 +0000 (UTC) Subject: [PATCH] D83273: [X86] Remove the feature dependency handling in X86TargetInfo::setFeatureEnabledImpl to a table based lookup in X86TargetParser.cpp Message-ID: craig.topper created this revision. craig.topper added reviewers: RKSimon, spatel, echristo, erichkeane, LuoYuanke, LiuChen3, FreddyYe, xiangzhangllvm. Herald added subscribers: jfb, hiraditya. Herald added a project: LLVM. Previously we had to specify the forward and backwards feature dependencies separately which was error prone. And as dependencies have gotten more complex it was hard to be sure the transitive dependencies were handled correctly. The way it was written was also not super readable. This patch replaces everything with a table that lists what features a feature is dependent on directly. Then we just have to recursively walk through the table to find the transitive dependencies. This is largely based on how we handle subtarget features in the MC layer from the tablegen descriptions. https://reviews.llvm.org/D83273 Files: clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h llvm/include/llvm/Support/X86TargetParser.def llvm/include/llvm/Support/X86TargetParser.h llvm/lib/Support/X86TargetParser.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83273.275882.patch Type: text/x-patch Size: 23210 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 18:47:25 2020 From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:47:25 +0000 (UTC) Subject: [PATCH] D83273: [X86] Remove the feature dependency handling in X86TargetInfo::setFeatureEnabledImpl to a table based lookup in X86TargetParser.cpp In-Reply-To: References: Message-ID: <7672db721630b2e1664ead7e04b9ec89@localhost.localdomain> craig.topper updated this revision to Diff 275883. craig.topper added a comment. Drop two header includes I was using for debugging CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83273/new/ https://reviews.llvm.org/D83273 Files: clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h llvm/include/llvm/Support/X86TargetParser.def llvm/include/llvm/Support/X86TargetParser.h llvm/lib/Support/X86TargetParser.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83273.275883.patch Type: text/x-patch Size: 22958 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 18:48:14 2020 From: cfe-commits at lists.llvm.org (Eric Christopher via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:48:14 +0000 (UTC) Subject: [PATCH] D83273: [X86] Remove the feature dependency handling in X86TargetInfo::setFeatureEnabledImpl to a table based lookup in X86TargetParser.cpp In-Reply-To: References: Message-ID: echristo accepted this revision. echristo added a comment. This revision is now accepted and ready to land. Works for me :) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83273/new/ https://reviews.llvm.org/D83273 From cfe-commits at lists.llvm.org Mon Jul 6 18:51:57 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 01:51:57 +0000 (UTC) Subject: [PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional operator In-Reply-To: References: Message-ID: <737ffd5b17dea2b083da2f3fa9090a68@localhost.localdomain> ahatanak added a comment. This looks good to me. ================ Comment at: clang/lib/Sema/SemaChecking.cpp:11825 + Expr *TrueExpr = E->getTrueExpr(); + if (isa(E)) ---------------- Can you use `BinaryConditionalOperator::getCommon` here? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81751/new/ https://reviews.llvm.org/D81751 From cfe-commits at lists.llvm.org Mon Jul 6 19:02:52 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 02:02:52 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors In-Reply-To: References: Message-ID: oontvoo updated this revision to Diff 275885. oontvoo added a comment. Dont skip checking even for templated type Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83263/new/ https://reviews.llvm.org/D83263 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/trivial-abi-templated-type.cpp Index: clang/test/SemaCXX/trivial-abi-templated-type.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/trivial-abi-templated-type.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 +// expected-no-diagnostics + +template +class __attribute__((trivial_abi)) a { a(a &&); }; Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -9719,6 +9719,11 @@ // Ill-formed if the copy and move constructors are deleted. auto HasNonDeletedCopyOrMoveConstructor = [&]() { + // If we know there exist users-defined move/copy ctors, don't try to infer + // the deletion of implicit ones becausee Sema may not have the info yet. + if (RD.hasUserDeclaredMoveConstructor() || + RD.hasUserDeclaredCopyConstructor()) + return true; if (RD.needsImplicitCopyConstructor() && !RD.defaultedCopyConstructorIsDeleted()) return true; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83263.275885.patch Type: text/x-patch Size: 1073 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 19:06:08 2020 From: cfe-commits at lists.llvm.org (River Riddle via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 02:06:08 +0000 (UTC) Subject: [PATCH] D83087: DomTree: remove explicit use of DomTreeNodeBase::iterator In-Reply-To: References: Message-ID: <9132a28cf90e12a706ce59503329eb2d@localhost.localdomain> rriddle accepted this revision. rriddle added a comment. Approval for anything MLIR related. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83087/new/ https://reviews.llvm.org/D83087 From cfe-commits at lists.llvm.org Mon Jul 6 19:14:25 2020 From: cfe-commits at lists.llvm.org (Xiang1 Zhang via cfe-commits) Date: Mon, 06 Jul 2020 19:14:25 -0700 (PDT) Subject: [clang] 939d830 - [X86-64] Support Intel AMX Intrinsic Message-ID: <5f03da81.1c69fb81.29470.0120@mx.google.com> Author: Xiang1 Zhang Date: 2020-07-07T10:13:40+08:00 New Revision: 939d8309dbd4ee6cf6e9ef3e8ea26df008b006b4 URL: https://github.com/llvm/llvm-project/commit/939d8309dbd4ee6cf6e9ef3e8ea26df008b006b4 DIFF: https://github.com/llvm/llvm-project/commit/939d8309dbd4ee6cf6e9ef3e8ea26df008b006b4.diff LOG: [X86-64] Support Intel AMX Intrinsic INTEL ADVANCED MATRIX EXTENSIONS (AMX). AMX is a new programming paradigm, it has a set of 2-dimensional registers (TILES) representing sub-arrays from a larger 2-dimensional memory image and operate on TILES. These intrinsics use direct TMM register number as its params. Spec can be found in Chapter 3 here https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D83111 Added: clang/lib/Headers/amxintrin.h clang/test/CodeGen/AMX/amx.c clang/test/CodeGen/AMX/amx_errors.c clang/test/CodeGen/AMX/amx_inline_asm.c clang/test/Preprocessor/x86_amx_target_features.c llvm/test/CodeGen/X86/AMX/amx-bf16-intrinsics.ll llvm/test/CodeGen/X86/AMX/amx-int8-intrinsics.ll llvm/test/CodeGen/X86/AMX/amx-tile-intrinsics.ll Modified: clang/docs/ClangCommandLineReference.rst clang/include/clang/Basic/BuiltinsX86_64.def clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Driver/Options.td clang/include/clang/Sema/Sema.h clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h clang/lib/Headers/CMakeLists.txt clang/lib/Headers/cpuid.h clang/lib/Headers/immintrin.h clang/lib/Sema/SemaChecking.cpp clang/test/Driver/x86-target-features.c llvm/include/llvm/IR/IntrinsicsX86.td llvm/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86InstrAMX.td Removed: ################################################################################ diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 67c341feffbb..672c4ae80e73 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -3127,6 +3127,12 @@ X86 .. option:: -maes, -mno-aes +.. option:: -mamx-bf16, -mno-amx-bf16 + +.. option:: -mamx-int8, -mno-amx-int8 + +.. option:: -mamx-tile, -mno-amx-tile + .. option:: -mavx, -mno-avx .. option:: -mavx2, -mno-avx2 diff --git a/clang/include/clang/Basic/BuiltinsX86_64.def b/clang/include/clang/Basic/BuiltinsX86_64.def index c535f43203e5..7feccd2a81a0 100644 --- a/clang/include/clang/Basic/BuiltinsX86_64.def +++ b/clang/include/clang/Basic/BuiltinsX86_64.def @@ -101,6 +101,22 @@ TARGET_BUILTIN(__builtin_ia32_cvtsi2ss64, "V4fV4fOiIi", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvtusi2sd64, "V2dV2dUOiIi", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_cvtusi2ss64, "V4fV4fUOiIi", "ncV:128:", "avx512f") TARGET_BUILTIN(__builtin_ia32_directstore_u64, "vULi*ULi", "n", "movdiri") + +// AMX +TARGET_BUILTIN(__builtin_ia32_tile_loadconfig, "vvC*", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tile_storeconfig, "vvC*", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tilerelease, "v", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tilezero, "vUc", "n", "amx-tile") + +TARGET_BUILTIN(__builtin_ia32_tileloadd64, "vIUcvC*z", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tileloaddt164, "vIUcvC*z", "n", "amx-tile") +TARGET_BUILTIN(__builtin_ia32_tilestored64, "vIUcv*z", "n", "amx-tile") + +TARGET_BUILTIN(__builtin_ia32_tdpbssd, "vIUcIUcIUc", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbsud, "vIUcIUcIUc", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbusd, "vIUcIUcIUc", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbuud, "vIUcIUcIUc", "n", "amx-int8") +TARGET_BUILTIN(__builtin_ia32_tdpbf16ps, "vIUcIUcIUc", "n", "amx-bf16") TARGET_BUILTIN(__builtin_ia32_ptwrite64, "vUOi", "n", "ptwrite") #undef BUILTIN diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 5b94aa8c4325..c935545610e0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -9342,6 +9342,8 @@ def err_x86_builtin_invalid_rounding : Error< "invalid rounding argument">; def err_x86_builtin_invalid_scale : Error< "scale argument must be 1, 2, 4, or 8">; +def err_x86_builtin_tile_arg_duplicate : Error< + "tile arguments must refer to diff erent tiles">; def err_builtin_target_unsupported : Error< "builtin is not supported on this target">; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 50d18343f7d4..745c696bcaa3 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3065,6 +3065,12 @@ def m3dnow : Flag<["-"], "m3dnow">, Group; def mno_3dnow : Flag<["-"], "mno-3dnow">, Group; def m3dnowa : Flag<["-"], "m3dnowa">, Group; def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group; +def mamx_bf16 : Flag<["-"], "mamx-bf16">, Group; +def mno_amx_bf16 : Flag<["-"], "mno-amx-bf16">, Group; +def mtamx_int8 : Flag<["-"], "mamx-int8">, Group; +def mno_amx_int8 : Flag<["-"], "mno-amx-int8">, Group; +def mamx_tile : Flag<["-"], "mamx-tile">, Group; +def mno_amx_tile : Flag<["-"], "mno-amx-tile">, Group; def msse : Flag<["-"], "msse">, Group; def mno_sse : Flag<["-"], "mno-sse">, Group; def msse2 : Flag<["-"], "msse2">, Group; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 9b82d2c984be..8ee7dd74712d 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -12142,6 +12142,13 @@ class Sema final { bool CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool CheckX86BuiltinRoundingOrSAE(unsigned BuiltinID, CallExpr *TheCall); bool CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, CallExpr *TheCall); + bool CheckX86BuiltinTileArguments(unsigned BuiltinID, CallExpr *TheCall); + bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, + ArrayRef ArgNums); + bool CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, int ArgNum); + bool CheckX86BuiltinTileDuplicate(CallExpr *TheCall, ArrayRef ArgNums); + bool CheckX86BuiltinTileRangeAndDuplicate(CallExpr *TheCall, + ArrayRef ArgNums); bool CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, CallExpr *TheCall); bool CheckPPCBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 2c6742b9042a..ed62848d8070 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -62,6 +62,7 @@ static const char *const GCCRegNames[] = { "cr0", "cr2", "cr3", "cr4", "cr8", "dr0", "dr1", "dr2", "dr3", "dr6", "dr7", "bnd0", "bnd1", "bnd2", "bnd3", + "tmm0", "tmm1", "tmm2", "tmm3", "tmm4", "tmm5", "tmm6", "tmm7", }; const TargetInfo::AddlRegName AddlRegNames[] = { @@ -394,7 +395,10 @@ void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, } else if (Name == "xsaveopt" || Name == "xsavec" || Name == "xsaves") { if (Enabled) Features["xsave"] = true; - } + } else if (Name == "amx-tile" && !Enabled) { + Features["amx-bf16"] = Features["amx-int8"] = false; + } else if ((Name == "amx-bf16" || Name == "amx-int8") && Enabled) + Features["amx-tile"] = true; } /// handleTargetFeatures - Perform initialization based on the user @@ -529,6 +533,12 @@ bool X86TargetInfo::handleTargetFeatures(std::vector &Features, HasINVPCID = true; } else if (Feature == "+enqcmd") { HasENQCMD = true; + } else if (Feature == "+amx-bf16") { + HasAMXBF16 = true; + } else if (Feature == "+amx-int8") { + HasAMXINT8 = true; + } else if (Feature == "+amx-tile") { + HasAMXTILE = true; } else if (Feature == "+serialize") { HasSERIALIZE = true; } else if (Feature == "+tsxldtrk") { @@ -924,6 +934,12 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__INVPCID__"); if (HasENQCMD) Builder.defineMacro("__ENQCMD__"); + if (HasAMXTILE) + Builder.defineMacro("__AMXTILE__"); + if (HasAMXINT8) + Builder.defineMacro("__AMXINT8__"); + if (HasAMXBF16) + Builder.defineMacro("__AMXBF16__"); if (HasSERIALIZE) Builder.defineMacro("__SERIALIZE__"); if (HasTSXLDTRK) @@ -1020,6 +1036,9 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const { .Case("3dnowa", true) .Case("adx", true) .Case("aes", true) + .Case("amx-bf16", true) + .Case("amx-int8", true) + .Case("amx-tile", true) .Case("avx", true) .Case("avx2", true) .Case("avx512f", true) @@ -1102,6 +1121,9 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch(Feature) .Case("adx", HasADX) .Case("aes", HasAES) + .Case("amx-bf16", HasAMXBF16) + .Case("amx-int8", HasAMXINT8) + .Case("amx-tile", HasAMXTILE) .Case("avx", SSELevel >= AVX) .Case("avx2", SSELevel >= AVX2) .Case("avx512f", SSELevel >= AVX512F) diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index c33c608e27c8..623ac9474b5c 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -125,6 +125,9 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool HasPTWRITE = false; bool HasINVPCID = false; bool HasENQCMD = false; + bool HasAMXTILE = false; + bool HasAMXINT8 = false; + bool HasAMXBF16 = false; bool HasSERIALIZE = false; bool HasTSXLDTRK = false; diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index fd9e3a0d672f..e7bee192d918 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -2,6 +2,7 @@ set(files adxintrin.h altivec.h ammintrin.h + amxintrin.h arm_acle.h arm_cmse.h armintr.h diff --git a/clang/lib/Headers/amxintrin.h b/clang/lib/Headers/amxintrin.h new file mode 100644 index 000000000000..58254e21c81a --- /dev/null +++ b/clang/lib/Headers/amxintrin.h @@ -0,0 +1,225 @@ +/*===--------------- amxintrin.h - AMX intrinsics -*- C/C++ -*---------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===------------------------------------------------------------------------=== + */ + +#ifndef __IMMINTRIN_H +#error "Never use directly; include instead." +#endif /* __IMMINTRIN_H */ + +#ifndef __AMXINTRIN_H +#define __AMXINTRIN_H +#ifdef __x86_64__ + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("amx-tile"))) + +/// Load tile configuration from a 64-byte memory location specified by +/// "mem_addr". The tile configuration includes the tile type palette, the +/// number of bytes per row, and the number of rows. If the specified +/// palette_id is zero, that signifies the init state for both the tile +/// config and the tile data, and the tiles are zeroed. Any invalid +/// configurations will result in #GP fault. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the LDTILECFG instruction. +/// +/// \param __config +/// A pointer to 512-bits configuration +static __inline__ void __DEFAULT_FN_ATTRS +_tile_loadconfig(const void *__config) +{ + __builtin_ia32_tile_loadconfig(__config); +} + +/// Stores the current tile configuration to a 64-byte memory location +/// specified by "mem_addr". The tile configuration includes the tile type +/// palette, the number of bytes per row, and the number of rows. If tiles +/// are not configured, all zeroes will be stored to memory. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the STTILECFG instruction. +/// +/// \param __config +/// A pointer to 512-bits configuration +static __inline__ void __DEFAULT_FN_ATTRS +_tile_storeconfig(void *__config) +{ + __builtin_ia32_tile_storeconfig(__config); +} + +/// Release the tile configuration to return to the init state, which +/// releases all storage it currently holds. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILERELEASE instruction. +static __inline__ void __DEFAULT_FN_ATTRS +_tile_release(void) +{ + __builtin_ia32_tilerelease(); +} + +/// Load tile rows from memory specifieid by "base" address and "stride" into +/// destination tile "dst" using the tile configuration previously configured +/// via "_tile_loadconfig". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILELOADD instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +#define _tile_loadd(dst, base, stride) \ + __builtin_ia32_tileloadd64((dst), ((const void *)(base)), (__SIZE_TYPE__)(stride)) + +/// Load tile rows from memory specifieid by "base" address and "stride" into +/// destination tile "dst" using the tile configuration previously configured +/// via "_tile_loadconfig". This intrinsic provides a hint to the implementation +/// that the data will likely not be reused in the near future and the data +/// caching can be optimized accordingly. +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILELOADDT1 instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be loaded in memory. +#define _tile_stream_loadd(dst, base, stride) \ + __builtin_ia32_tileloaddt164((dst), ((const void *)(base)), (__SIZE_TYPE__)(stride)) + +/// Store the tile specified by "src" to memory specifieid by "base" address and +/// "stride" using the tile configuration previously configured via +/// "_tile_loadconfig". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILESTORED instruction. +/// +/// \param dst +/// A destination tile. Max size is 1024 Bytes. +/// \param base +/// A pointer to base address. +/// \param stride +/// The stride between the rows' data to be stored in memory. +#define _tile_stored(dst, base, stride) \ + __builtin_ia32_tilestored64((dst), ((void *)(base)), (__SIZE_TYPE__)(stride)) + +/// Zero the tile specified by "tdest". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TILEZERO instruction. +/// +/// \param tile +/// The destination tile to be zero. Max size is 1024 Bytes. +#define _tile_zero(tile) __builtin_ia32_tilezero((tile)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in src0 with +/// corresponding signed 8-bit integers in src1, producing 4 intermediate 32-bit +/// results. Sum these 4 results with the corresponding 32-bit integer in "dst", +/// and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBSSD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbssd(dst, src0, src1) __builtin_ia32_tdpbssd((dst), (src0), (src1)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of signed 8-bit integers in src0 with +/// corresponding unsigned 8-bit integers in src1, producing 4 intermediate +/// 32-bit results. Sum these 4 results with the corresponding 32-bit integer +/// in "dst", and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBSUD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbsud(dst, src0, src1) __builtin_ia32_tdpbsud((dst), (src0), (src1)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in src0 with +/// corresponding signed 8-bit integers in src1, producing 4 intermediate 32-bit +/// results. Sum these 4 results with the corresponding 32-bit integer in "dst", +/// and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBUSD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbusd(dst, src0, src1) __builtin_ia32_tdpbusd((dst), (src0), (src1)) + +/// Compute dot-product of bytes in tiles with a source/destination accumulator. +/// Multiply groups of 4 adjacent pairs of unsigned 8-bit integers in src0 with +/// corresponding unsigned 8-bit integers in src1, producing 4 intermediate +/// 32-bit results. Sum these 4 results with the corresponding 32-bit integer in +/// "dst", and store the 32-bit result back to tile "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBUUD instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbuud(dst, src0, src1) __builtin_ia32_tdpbuud((dst), (src0), (src1)) + +/// Compute dot-product of BF16 (16-bit) floating-point pairs in tiles src0 and +/// src1, accumulating the intermediate single-precision (32-bit) floating-point +/// elements with elements in "dst", and store the 32-bit result back to tile +/// "dst". +/// +/// \headerfile +/// +/// This intrinsic corresponds to the TDPBF16PS instruction. +/// +/// \param dst +/// The destination tile. Max size is 1024 Bytes. +/// \param src0 +/// The 1st source tile. Max size is 1024 Bytes. +/// \param src1 +/// The 2nd source tile. Max size is 1024 Bytes. +#define _tile_dpbf16ps(dst, src0, src1) \ + __builtin_ia32_tdpbf16ps((dst), (src0), (src1)) + +#undef __DEFAULT_FN_ATTRS + +#endif /* __x86_64__ */ +#endif /* __AMXINTRIN_H */ diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h index 6c38b578b30e..2a88c042d046 100644 --- a/clang/lib/Headers/cpuid.h +++ b/clang/lib/Headers/cpuid.h @@ -190,6 +190,9 @@ #define bit_TSXLDTRK 0x00010000 #define bit_PCONFIG 0x00040000 #define bit_IBT 0x00100000 +#define bit_AMXBF16 0x00400000 +#define bit_AMXTILE 0x01000000 +#define bit_AMXINT8 0x02000000 /* Features in %eax for leaf 7 sub-leaf 1 */ #define bit_AVX512BF16 0x00000020 diff --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h index dd27ca2f6605..e9dff2310fdf 100644 --- a/clang/lib/Headers/immintrin.h +++ b/clang/lib/Headers/immintrin.h @@ -471,6 +471,11 @@ _storebe_i64(void * __P, long long __D) { #include #endif +#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \ + defined(__AMXTILE__) || defined(__AMXINT8__) || defined(__AMXBF16__) +#include +#endif + #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \ defined(__AVX512VP2INTERSECT__) #include diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 0ce84ea382b5..2b52415b2800 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -88,6 +88,7 @@ #include "llvm/Support/SaveAndRestore.h" #include "llvm/Support/raw_ostream.h" #include +#include #include #include #include @@ -3607,6 +3608,64 @@ bool Sema::CheckX86BuiltinGatherScatterScale(unsigned BuiltinID, << Arg->getSourceRange(); } +enum { TileRegLow = 0, TileRegHigh = 7 }; + +bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, + ArrayRef ArgNums) { + for (int ArgNum : ArgNums) { + if (SemaBuiltinConstantArgRange(TheCall, ArgNum, TileRegLow, TileRegHigh)) + return true; + } + return false; +} + +bool Sema::CheckX86BuiltinTileArgumentsRange(CallExpr *TheCall, int ArgNum) { + return SemaBuiltinConstantArgRange(TheCall, ArgNum, TileRegLow, TileRegHigh); +} + +bool Sema::CheckX86BuiltinTileDuplicate(CallExpr *TheCall, + ArrayRef ArgNums) { + // Because the max number of tile register is TileRegHigh + 1, so here we use + // each bit to represent the usage of them in bitset. + std::bitset ArgValues; + for (int ArgNum : ArgNums) { + llvm::APSInt Arg; + SemaBuiltinConstantArg(TheCall, ArgNum, Arg); + int ArgExtValue = Arg.getExtValue(); + assert((ArgExtValue >= TileRegLow || ArgExtValue <= TileRegHigh) && + "Incorrect tile register num."); + if (ArgValues.test(ArgExtValue)) + return Diag(TheCall->getBeginLoc(), + diag::err_x86_builtin_tile_arg_duplicate) + << TheCall->getArg(ArgNum)->getSourceRange(); + ArgValues.set(ArgExtValue); + } + return false; +} + +bool Sema::CheckX86BuiltinTileRangeAndDuplicate(CallExpr *TheCall, + ArrayRef ArgNums) { + return CheckX86BuiltinTileArgumentsRange(TheCall, ArgNums) || + CheckX86BuiltinTileDuplicate(TheCall, ArgNums); +} + +bool Sema::CheckX86BuiltinTileArguments(unsigned BuiltinID, CallExpr *TheCall) { + switch (BuiltinID) { + default: + return false; + case X86::BI__builtin_ia32_tileloadd64: + case X86::BI__builtin_ia32_tileloaddt164: + case X86::BI__builtin_ia32_tilestored64: + case X86::BI__builtin_ia32_tilezero: + return CheckX86BuiltinTileArgumentsRange(TheCall, 0); + case X86::BI__builtin_ia32_tdpbssd: + case X86::BI__builtin_ia32_tdpbsud: + case X86::BI__builtin_ia32_tdpbusd: + case X86::BI__builtin_ia32_tdpbuud: + case X86::BI__builtin_ia32_tdpbf16ps: + return CheckX86BuiltinTileRangeAndDuplicate(TheCall, {0, 1, 2}); + } +} static bool isX86_32Builtin(unsigned BuiltinID) { // These builtins only work on x86-32 targets. switch (BuiltinID) { @@ -3640,6 +3699,10 @@ bool Sema::CheckX86BuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID, if (CheckX86BuiltinGatherScatterScale(BuiltinID, TheCall)) return true; + // If the intrinsic has a tile arguments, make sure they are valid. + if (CheckX86BuiltinTileArguments(BuiltinID, TheCall)) + return true; + // For intrinsics which take an immediate value as part of the instruction, // range check them here. int i = 0, l = 0, u = 0; diff --git a/clang/test/CodeGen/AMX/amx.c b/clang/test/CodeGen/AMX/amx.c new file mode 100644 index 000000000000..89b486f7a601 --- /dev/null +++ b/clang/test/CodeGen/AMX/amx.c @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +amx-int8 \ +// RUN: -target-feature +amx-bf16 -emit-llvm -o - -Werror -pedantic | FileCheck %s --check-prefixes=CHECK + +#include + +void test_amx(void *data) { + //CHECK-LABEL: @test_amx + //CHECK: call void @llvm.x86.ldtilecfg(i8* %{{.*}}) + //CHECK: call void @llvm.x86.sttilecfg(i8* %{{.*}}) + //CHECK: call void @llvm.x86.tilerelease() + //CHECK: call void @llvm.x86.tilezero(i8 3) + //CHECK: call void @llvm.x86.tileloadd64(i8 4, i8* %{{.*}}, i64 8) + //CHECK: call void @llvm.x86.tileloaddt164(i8 0, i8* %{{.*}}, i64 1) + //CHECK: call void @llvm.x86.tilestored64(i8 0, i8* %{{.*}}, i64 1) + //CHECK: call void @llvm.x86.tdpbssd(i8 1, i8 2, i8 3) + //CHECK: call void @llvm.x86.tdpbsud(i8 1, i8 2, i8 3) + //CHECK: call void @llvm.x86.tdpbusd(i8 1, i8 2, i8 3) + //CHECK: call void @llvm.x86.tdpbuud(i8 1, i8 2, i8 3) + //CHECK: call void @llvm.x86.tdpbf16ps(i8 1, i8 2, i8 3) + _tile_loadconfig(data); + _tile_storeconfig(data); + _tile_release(); + _tile_zero(3); + _tile_loadd(4, data, 8); + _tile_stream_loadd(0, data, 1); + _tile_stored(0, data, 1); + _tile_dpbssd(1, 2, 3); + _tile_dpbsud(1, 2, 3); + _tile_dpbusd(1, 2, 3); + _tile_dpbuud(1, 2, 3); + _tile_dpbf16ps(1, 2, 3); +} diff --git a/clang/test/CodeGen/AMX/amx_errors.c b/clang/test/CodeGen/AMX/amx_errors.c new file mode 100644 index 000000000000..13a2b33b5a0a --- /dev/null +++ b/clang/test/CodeGen/AMX/amx_errors.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +amx-tile -target-feature +amx-int8 -target-feature +amx-bf16 -emit-llvm -fsyntax-only -verify + +#include + +void test_amx(void *data) { + _tile_zero(16); // expected-error {{argument value 16 is outside the valid range [0, 7]}} + _tile_loadd(19, data, 16); // expected-error {{argument value 19 is outside the valid range [0, 7]}} + _tile_stream_loadd(23, data, 1); // expected-error {{argument value 23 is outside the valid range [0, 7]}} + _tile_stored(88, data, 1); // expected-error {{argument value 88 is outside the valid range [0, 7]}} + _tile_dpbssd(16, 2, 3); // expected-error {{argument value 16 is outside the valid range [0, 7]}} + _tile_dpbssd(0, 16, 3); // expected-error {{argument value 16 is outside the valid range [0, 7]}} + _tile_dpbuud(0, 2, 16); // expected-error {{argument value 16 is outside the valid range [0, 7]}} + _tile_dpbsud(1, 1, 3); // expected-error {{tile arguments must refer to diff erent tiles}} + _tile_dpbsud(7, 1, 7); // expected-error {{tile arguments must refer to diff erent tiles}} + _tile_dpbsud(4, 3, 3); // expected-error {{tile arguments must refer to diff erent tiles}} + _tile_dpbf16ps(4, 3, 3); // expected-error {{tile arguments must refer to diff erent tiles}} +} diff --git a/clang/test/CodeGen/AMX/amx_inline_asm.c b/clang/test/CodeGen/AMX/amx_inline_asm.c new file mode 100644 index 000000000000..9d828f8ac94e --- /dev/null +++ b/clang/test/CodeGen/AMX/amx_inline_asm.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +amx-int8 -target-feature +amx-bf16 -emit-llvm -o - -Wall -Werror -pedantic | FileCheck %s --check-prefixes=CHECK,X86_64 + +void f_tilemul(short a) +{ + //CHECK: call void asm sideeffect "tileloadd 0(%rsi,%r13,4), %tmm0 \0A\09tileloadd 0(%rdx,%r14,4), %tmm6 \0A\09tdpbf16ps %tmm6, %tmm0, %tmm7 \0A\09tilestored %tmm7, 0(%r12,%r15,4) \0A\09", "~{memory},~{tmm0},~{tmm6},~{tmm7},~{dirflag},~{fpsr},~{flags}"() + __asm__ volatile ("tileloadd 0(%%rsi,%%r13,4), %%tmm0 \n\t" + "tileloadd 0(%%rdx,%%r14,4), %%tmm6 \n\t" + "tdpbf16ps %%tmm6, %%tmm0, %%tmm7 \n\t" + "tilestored %%tmm7, 0(%%r12,%%r15,4) \n\t" + ::: "memory", "tmm0", "tmm6", "tmm7"); +} diff --git a/clang/test/Driver/x86-target-features.c b/clang/test/Driver/x86-target-features.c index b96eed287bd9..817caeecd71e 100644 --- a/clang/test/Driver/x86-target-features.c +++ b/clang/test/Driver/x86-target-features.c @@ -232,3 +232,18 @@ // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-tsxldtrk %s -### -o %t.o 2>&1 | FileCheck --check-prefix=NO-TSXLDTRK %s // TSXLDTRK: "-target-feature" "+tsxldtrk" // NO-TSXLDTRK: "-target-feature" "-tsxldtrk" + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile %s -### -o %t.o 2>&1 | FileCheck --check-prefix=AMX-TILE %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile %s -### -o %t.o 2>&1 | FileCheck --check-prefix=NO-AMX-TILE %s +// AMX-TILE: "-target-feature" "+amx-tile" +// NO-AMX-TILE: "-target-feature" "-amx-tile" + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 %s -### -o %t.o 2>&1 | FileCheck --check-prefix=AMX-BF16 %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-AMX-BF16 %s +// AMX-BF16: "-target-feature" "+amx-bf16" +// NO-AMX-BF16: "-target-feature" "-amx-bf16" + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 %s -### -o %t.o 2>&1 | FileCheck --check-prefix=AMX-INT8 %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 %s -### -o %t.o 2>&1 | FileCheck --check-prefix=NO-AMX-INT8 %s +// AMX-INT8: "-target-feature" "+amx-int8" +// NO-AMX-INT8: "-target-feature" "-amx-int8" diff --git a/clang/test/Preprocessor/x86_amx_target_features.c b/clang/test/Preprocessor/x86_amx_target_features.c new file mode 100644 index 000000000000..68a3d7f950b1 --- /dev/null +++ b/clang/test/Preprocessor/x86_amx_target_features.c @@ -0,0 +1,35 @@ +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-TILE %s + +// AMX-TILE: #define __AMXTILE__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s + +// AMX-BF16: #define __AMXBF16__ 1 +// AMX-BF16: #define __AMXTILE__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s + +// AMX-INT8: #define __AMXINT8__ 1 +// AMX-INT8: #define __AMXTILE__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile -x c -E -dM -o - %s | FileCheck -check-prefix=NOAMX-TILE %s + +// NOAMX-TILE-NOT: #define __AMXTILE__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=NOAMX-BF16 %s + +// NOAMX-BF16-NOT: #define __AMXBF16__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -amx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck -check-prefix=NOAMX-BF16 %s + +// NOAMX-BF16-NOT: #define __AMXTILE__ 1 +// NOAMX-BF16-NOT: #define __AMXBF16__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=NOAMX-INT8 %s + +// NOAMX-INT8-NOT: #define __AMXINT8__ 1 + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -amx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck -check-prefix=NOAMX-INT8 %s + +// NOAMX-INT8-NOT: #define __AMXTILE__ 1 +// NOAMX-INT8-NOT: #define __AMXINT8__ 1 diff --git a/llvm/include/llvm/IR/IntrinsicsX86.td b/llvm/include/llvm/IR/IntrinsicsX86.td index b3bf18720595..3f86fd075d3a 100644 --- a/llvm/include/llvm/IR/IntrinsicsX86.td +++ b/llvm/include/llvm/IR/IntrinsicsX86.td @@ -4948,3 +4948,32 @@ let TargetPrefix = "x86" in { def int_x86_xresldtrk : GCCBuiltin<"__builtin_ia32_xresldtrk">, Intrinsic<[], [], []>; } +//===----------------------------------------------------------------------===// +// AMX - Intel AMX extensions + +let TargetPrefix = "x86" in { + def int_x86_ldtilecfg : GCCBuiltin<"__builtin_ia32_tile_loadconfig">, + Intrinsic<[], [llvm_ptr_ty], []>; + def int_x86_sttilecfg : GCCBuiltin<"__builtin_ia32_tile_storeconfig">, + Intrinsic<[], [llvm_ptr_ty], []>; + def int_x86_tilerelease : GCCBuiltin<"__builtin_ia32_tilerelease">, + Intrinsic<[], [], []>; + def int_x86_tilezero : GCCBuiltin<"__builtin_ia32_tilezero">, + Intrinsic<[], [llvm_i8_ty], []>; + def int_x86_tileloadd64 : GCCBuiltin<"__builtin_ia32_tileloadd64">, + Intrinsic<[], [llvm_i8_ty, llvm_ptr_ty, llvm_i64_ty], []>; + def int_x86_tileloaddt164 : GCCBuiltin<"__builtin_ia32_tileloaddt164">, + Intrinsic<[], [llvm_i8_ty, llvm_ptr_ty, llvm_i64_ty], []>; + def int_x86_tilestored64 : GCCBuiltin<"__builtin_ia32_tilestored64">, + Intrinsic<[], [llvm_i8_ty, llvm_ptr_ty, llvm_i64_ty], []>; + def int_x86_tdpbssd : GCCBuiltin<"__builtin_ia32_tdpbssd">, + Intrinsic<[], [llvm_i8_ty, llvm_i8_ty, llvm_i8_ty], []>; + def int_x86_tdpbsud : GCCBuiltin<"__builtin_ia32_tdpbsud">, + Intrinsic<[], [llvm_i8_ty, llvm_i8_ty, llvm_i8_ty], []>; + def int_x86_tdpbusd : GCCBuiltin<"__builtin_ia32_tdpbusd">, + Intrinsic<[], [llvm_i8_ty, llvm_i8_ty, llvm_i8_ty], []>; + def int_x86_tdpbuud : GCCBuiltin<"__builtin_ia32_tdpbuud">, + Intrinsic<[], [llvm_i8_ty, llvm_i8_ty, llvm_i8_ty], []>; + def int_x86_tdpbf16ps : GCCBuiltin<"__builtin_ia32_tdpbf16ps">, + Intrinsic<[], [llvm_i8_ty, llvm_i8_ty, llvm_i8_ty], []>; +} diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index 5a57ca7646ff..fb285376c580 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -4435,8 +4435,39 @@ void X86DAGToDAGISel::Select(SDNode *Node) { break; } + case Intrinsic::x86_tileloadd64: + case Intrinsic::x86_tileloaddt164: + case Intrinsic::x86_tilestored64: { + if (!Subtarget->hasAMXTILE()) + break; + unsigned Opc; + switch (IntNo) { + default: llvm_unreachable("Unexpected intrinsic!"); + case Intrinsic::x86_tileloadd64: Opc = X86::PTILELOADD; break; + case Intrinsic::x86_tileloaddt164: Opc = X86::PTILELOADDT1; break; + case Intrinsic::x86_tilestored64: Opc = X86::PTILESTORED; break; + } + // FIXME: Match displacement and scale. + unsigned TIndex = Node->getConstantOperandVal(2); + SDValue TReg = getI8Imm(TIndex, dl); + SDValue Base = Node->getOperand(3); + SDValue Scale = getI8Imm(1, dl); + SDValue Index = Node->getOperand(4); + SDValue Disp = CurDAG->getTargetConstant(0, dl, MVT::i32); + SDValue Segment = CurDAG->getRegister(0, MVT::i16); + SDValue Chain = Node->getOperand(0); + MachineSDNode *CNode; + if (Opc == X86::PTILESTORED) { + SDValue Ops[] = { Base, Scale, Index, Disp, Segment, TReg, Chain }; + CNode = CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops); + } else { + SDValue Ops[] = { TReg, Base, Scale, Index, Disp, Segment, Chain }; + CNode = CurDAG->getMachineNode(Opc, dl, MVT::Other, Ops); + } + ReplaceNode(Node, CNode); + return; + } } - break; } case ISD::BRIND: { diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 88a563720c2a..d7a45f6fb7c4 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -33044,6 +33044,10 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, const TargetInstrInfo *TII = Subtarget.getInstrInfo(); DebugLoc DL = MI.getDebugLoc(); + auto TMMImmToTMMReg = [](unsigned Imm) { + assert (Imm < 8 && "Illegal tmm index"); + return X86::TMM0 + Imm; + }; switch (MI.getOpcode()) { default: llvm_unreachable("Unexpected instr type to insert"); case X86::TLS_addr32: @@ -33326,6 +33330,67 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, MI.eraseFromParent(); return BB; } + case X86::PTDPBSSD: + case X86::PTDPBSUD: + case X86::PTDPBUSD: + case X86::PTDPBUUD: + case X86::PTDPBF16PS: { + const DebugLoc &DL = MI.getDebugLoc(); + unsigned Opc; + switch (MI.getOpcode()) { + case X86::PTDPBSSD: Opc = X86::TDPBSSD; break; + case X86::PTDPBSUD: Opc = X86::TDPBSUD; break; + case X86::PTDPBUSD: Opc = X86::TDPBUSD; break; + case X86::PTDPBUUD: Opc = X86::TDPBUUD; break; + case X86::PTDPBF16PS: Opc = X86::TDPBF16PS; break; + } + + MachineInstrBuilder MIB = BuildMI(*BB, MI, DL, TII->get(Opc)); + MIB.addReg(TMMImmToTMMReg(MI.getOperand(0).getImm()), RegState::Define); + MIB.addReg(TMMImmToTMMReg(MI.getOperand(0).getImm()), RegState::Undef); + MIB.addReg(TMMImmToTMMReg(MI.getOperand(1).getImm()), RegState::Undef); + MIB.addReg(TMMImmToTMMReg(MI.getOperand(2).getImm()), RegState::Undef); + + MI.eraseFromParent(); // The pseudo is gone now. + return BB; + } + case X86::PTILEZERO: { + const DebugLoc &DL = MI.getDebugLoc(); + unsigned Imm = MI.getOperand(0).getImm(); + BuildMI(*BB, MI, DL, TII->get(X86::TILEZERO), TMMImmToTMMReg(Imm)); + MI.eraseFromParent(); // The pseudo is gone now. + return BB; + } + case X86::PTILELOADD: + case X86::PTILELOADDT1: + case X86::PTILESTORED: { + const DebugLoc &DL = MI.getDebugLoc(); + unsigned Opc; + switch (MI.getOpcode()) { + case X86::PTILELOADD: Opc = X86::TILELOADD; break; + case X86::PTILELOADDT1: Opc = X86::TILELOADDT1; break; + case X86::PTILESTORED: Opc = X86::TILESTORED; break; + } + + MachineInstrBuilder MIB = BuildMI(*BB, MI, DL, TII->get(Opc)); + unsigned CurOp = 0; + if (Opc != X86::TILESTORED) + MIB.addReg(TMMImmToTMMReg(MI.getOperand(CurOp++).getImm()), + RegState::Define); + + MIB.add(MI.getOperand(CurOp++)); // base + MIB.add(MI.getOperand(CurOp++)); // scale + MIB.add(MI.getOperand(CurOp++)); // index -- stride + MIB.add(MI.getOperand(CurOp++)); // displacement + MIB.add(MI.getOperand(CurOp++)); // segment + + if (Opc == X86::TILESTORED) + MIB.addReg(TMMImmToTMMReg(MI.getOperand(CurOp++).getImm()), + RegState::Undef); + + MI.eraseFromParent(); // The pseudo is gone now. + return BB; + } } } diff --git a/llvm/lib/Target/X86/X86InstrAMX.td b/llvm/lib/Target/X86/X86InstrAMX.td index deefb3eecf39..e26dd5050a23 100644 --- a/llvm/lib/Target/X86/X86InstrAMX.td +++ b/llvm/lib/Target/X86/X86InstrAMX.td @@ -18,9 +18,11 @@ let Predicates = [HasAMXTILE, In64BitMode] in { let SchedRW = [WriteSystem] in { let Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in def LDTILECFG : I <0x49, MRM0m, (outs), (ins opaquemem:$src), - "ldtilecfg\t$src", []>, VEX, T8PS; + "ldtilecfg\t$src", + [(int_x86_ldtilecfg addr:$src)]>, VEX, T8PS; def STTILECFG : I <0x49, MRM0m, (outs), (ins opaquemem:$src), - "sttilecfg\t$src", []>, VEX, T8PD; + "sttilecfg\t$src", + [(int_x86_sttilecfg addr:$src)]>, VEX, T8PD; def TILELOADD : I<0x4b, MRMSrcMemFSIB, (outs TILE:$dst), (ins sibmem:$src), "tileloadd\t{$src, $dst|$dst, $src}", []>, @@ -31,7 +33,7 @@ let Predicates = [HasAMXTILE, In64BitMode] in { VEX, T8PD; let Defs = [TMM0,TMM1,TMM2,TMM3,TMM4,TMM5,TMM6,TMM7] in def TILERELEASE : I<0x49, MRM_C0, (outs), (ins), - "tilerelease", []>, VEX, T8PS; + "tilerelease", [(int_x86_tilerelease)]>, VEX, T8PS; def TILESTORED : I<0x4b, MRMDestMemFSIB, (outs), (ins sibmem:$dst, TILE:$src), "tilestored\t{$src, $dst|$dst, $src}", []>, @@ -39,6 +41,17 @@ let Predicates = [HasAMXTILE, In64BitMode] in { def TILEZERO : I<0x49, MRMr0, (outs TILE:$dst), (ins), "tilezero\t$dst", []>, VEX, T8XD; + + let usesCustomInserter = 1 in { + // Pseudo instructions, using immediates instead of tile registers. + // To be translated to the actual instructions in X86ISelLowering.cpp + def PTILELOADD : PseudoI<(outs), (ins u8imm:$src1, sibmem:$src2), []>; + def PTILELOADDT1 : PseudoI<(outs), (ins u8imm:$src1, + sibmem:$src2), []>; + def PTILESTORED : PseudoI<(outs), (ins i8mem:$dst, u8imm:$src), []>; + def PTILEZERO : PseudoI<(outs), (ins u8imm:$src), + [(int_x86_tilezero imm:$src)]>; + } } // SchedRW } // HasAMXTILE @@ -62,6 +75,27 @@ let Predicates = [HasAMXINT8, In64BitMode] in { "tdpbuud\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, VEX_4V, T8PS; } + + let usesCustomInserter = 1 in { + // Pseudo instructions, using immediates instead of tile registers. + // To be translated to the actual instructions in X86ISelLowering.cpp + def PTDPBSSD : PseudoI<(outs), (ins u8imm:$src1, + u8imm:$src2, u8imm:$src3), + [(int_x86_tdpbssd imm:$src1, + imm:$src2, imm:$src3)]>; + def PTDPBSUD : PseudoI<(outs), (ins u8imm:$src1, + u8imm:$src2, u8imm:$src3), + [(int_x86_tdpbsud imm:$src1, + imm:$src2, imm:$src3)]>; + def PTDPBUSD : PseudoI<(outs), (ins u8imm:$src1, + u8imm:$src2, u8imm:$src3), + [(int_x86_tdpbusd imm:$src1, + imm:$src2, imm:$src3)]>; + def PTDPBUUD : PseudoI<(outs), (ins u8imm:$src1, + u8imm:$src2, u8imm:$src3), + [(int_x86_tdpbuud imm:$src1, + imm:$src2, imm:$src3)]>; + } } } // HasAMXTILE @@ -72,5 +106,14 @@ let Predicates = [HasAMXBF16, In64BitMode] in { (ins TILE:$src1, TILE:$src2, TILE:$src3), "tdpbf16ps\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, VEX_4V, T8XS; + + let usesCustomInserter = 1 in { + // Pseudo instructions, using immediates instead of tile registers. + // To be translated to the actual instructions in X86ISelLowering.cpp + def PTDPBF16PS : PseudoI<(outs), (ins u8imm:$src1, + u8imm:$src2, u8imm:$src3), + [(int_x86_tdpbf16ps imm:$src1, + imm:$src2, imm:$src3)]>; + } } } // HasAMXTILE, HasAMXBF16 diff --git a/llvm/test/CodeGen/X86/AMX/amx-bf16-intrinsics.ll b/llvm/test/CodeGen/X86/AMX/amx-bf16-intrinsics.ll new file mode 100644 index 000000000000..a415d9c15242 --- /dev/null +++ b/llvm/test/CodeGen/X86/AMX/amx-bf16-intrinsics.ll @@ -0,0 +1,13 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+amx-tile -mattr=+amx-bf16 -verify-machineinstrs | FileCheck %s + +define void @test_amx() { +; CHECK-LABEL: test_amx: +; CHECK: # %bb.0: +; CHECK-NEXT: tdpbf16ps %tmm7, %tmm4, %tmm3 +; CHECK-NEXT: retq + call void @llvm.x86.tdpbf16ps(i8 3, i8 4, i8 7) + ret void +} + +declare void @llvm.x86.tdpbf16ps(i8 %tile0, i8 %tile1, i8 %tile2) diff --git a/llvm/test/CodeGen/X86/AMX/amx-int8-intrinsics.ll b/llvm/test/CodeGen/X86/AMX/amx-int8-intrinsics.ll new file mode 100644 index 000000000000..49e69aeab510 --- /dev/null +++ b/llvm/test/CodeGen/X86/AMX/amx-int8-intrinsics.ll @@ -0,0 +1,24 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+amx-int8 -verify-machineinstrs | FileCheck %s + +define void @test_amx() { +; CHECK-LABEL: test_amx: +; CHECK: # %bb.0: + call void @llvm.x86.tdpbssd(i8 3, i8 4, i8 7) +; CHECK-NEXT: tdpbssd %tmm7, %tmm4, %tmm3 + + call void @llvm.x86.tdpbsud(i8 3, i8 4, i8 7) +; CHECK-NEXT: tdpbsud %tmm7, %tmm4, %tmm3 + + call void @llvm.x86.tdpbusd(i8 3, i8 0, i8 7) +; CHECK-NEXT: tdpbusd %tmm7, %tmm0, %tmm3 + + call void @llvm.x86.tdpbuud(i8 3, i8 4, i8 1) +; CHECK-NEXT: tdpbuud %tmm1, %tmm4, %tmm3 + ret void +} + +declare void @llvm.x86.tdpbssd(i8 %tile0, i8 %tile1, i8 %tile2) +declare void @llvm.x86.tdpbsud(i8 %tile0, i8 %tile1, i8 %tile2) +declare void @llvm.x86.tdpbusd(i8 %tile0, i8 %tile1, i8 %tile2) +declare void @llvm.x86.tdpbuud(i8 %tile0, i8 %tile1, i8 %tile2) diff --git a/llvm/test/CodeGen/X86/AMX/amx-tile-intrinsics.ll b/llvm/test/CodeGen/X86/AMX/amx-tile-intrinsics.ll new file mode 100644 index 000000000000..6b8e040abb9a --- /dev/null +++ b/llvm/test/CodeGen/X86/AMX/amx-tile-intrinsics.ll @@ -0,0 +1,36 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+amx-tile -verify-machineinstrs | FileCheck %s + +define void @test_amx(i8* %pointer, i8* %base, i64 %stride) { +; CHECK-LABEL: test_amx: +; CHECK: # %bb.0: + call void @llvm.x86.ldtilecfg(i8* %pointer) +; CHECK-NEXT: ldtilecfg (%rdi) + + call void @llvm.x86.sttilecfg(i8* %pointer) +; CHECK-NEXT: sttilecfg (%rdi) + + call void @llvm.x86.tilerelease() +; CHECK-NEXT: tilerelease + + call void @llvm.x86.tilezero(i8 3) +; CHECK-NEXT: tilezero %tmm3 + + call void @llvm.x86.tileloadd64(i8 3, i8* %base, i64 %stride) +; CHECK-NEXT: tileloadd (%rsi,%rdx), %tmm3 + + call void @llvm.x86.tileloaddt164(i8 3, i8* %base, i64 %stride) +; CHECK-NEXT: tileloaddt1 (%rsi,%rdx), %tmm3 + + call void @llvm.x86.tilestored64(i8 3, i8* %base, i64 %stride) +; CHECK-NEXT: tilestored %tmm3, (%rsi,%rdx) + ret void +} + +declare void @llvm.x86.tileloadd64(i8 %tile, i8* %base, i64 %stride) +declare void @llvm.x86.tileloaddt164(i8 %tile, i8* %base, i64 %stride) +declare void @llvm.x86.tilestored64(i8 %tile, i8* %base, i64 %stride) +declare void @llvm.x86.ldtilecfg(i8* %pointer) +declare void @llvm.x86.sttilecfg(i8* %pointer) +declare void @llvm.x86.tilerelease() +declare void @llvm.x86.tilezero(i8 %tile) From cfe-commits at lists.llvm.org Mon Jul 6 19:14:33 2020 From: cfe-commits at lists.llvm.org (Xiang Zhang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 02:14:33 +0000 (UTC) Subject: [PATCH] D83111: [X86-64] Support Intel AMX Intrinsic In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG939d8309dbd4: [X86-64] Support Intel AMX Intrinsic (authored by xiangzhangllvm). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D83111?vs=275878&id=275888#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83111/new/ https://reviews.llvm.org/D83111 Files: clang/docs/ClangCommandLineReference.rst clang/include/clang/Basic/BuiltinsX86_64.def clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Driver/Options.td clang/include/clang/Sema/Sema.h clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h clang/lib/Headers/CMakeLists.txt clang/lib/Headers/amxintrin.h clang/lib/Headers/cpuid.h clang/lib/Headers/immintrin.h clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/AMX/amx.c clang/test/CodeGen/AMX/amx_errors.c clang/test/CodeGen/AMX/amx_inline_asm.c clang/test/Driver/x86-target-features.c clang/test/Preprocessor/x86_amx_target_features.c llvm/include/llvm/IR/IntrinsicsX86.td llvm/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86InstrAMX.td llvm/test/CodeGen/X86/AMX/amx-bf16-intrinsics.ll llvm/test/CodeGen/X86/AMX/amx-int8-intrinsics.ll llvm/test/CodeGen/X86/AMX/amx-tile-intrinsics.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83111.275888.patch Type: text/x-patch Size: 42404 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 19:15:30 2020 From: cfe-commits at lists.llvm.org (Xiang Zhang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 02:15:30 +0000 (UTC) Subject: [PATCH] D83111: [X86-64] Support Intel AMX Intrinsic In-Reply-To: References: Message-ID: xiangzhangllvm added a comment. In D83111#2134747 , @craig.topper wrote: > LGTM with all instances of "pointer point" replace with just "pointer" Done it in commit. Thank you! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83111/new/ https://reviews.llvm.org/D83111 From cfe-commits at lists.llvm.org Mon Jul 6 19:15:57 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 02:15:57 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: <02260bb11ff42e6009de8beb9b3e1cd1@localhost.localdomain> jdoerfert added inline comments. ================ Comment at: llvm/utils/update_cc_test_checks.py:133 + parser.add_argument('--include-generated-funcs', action='store_true', + help='Output checks for functions not in source') parser.add_argument('tests', nargs='+') ---------------- greened wrote: > greened wrote: > > jdoerfert wrote: > > > I think this should go into common.py (after D78618). I would also make this the default but OK. > > Yes I suppose it should in case `opt` and friends generate functions. I hadn't considered that use-case. > > > > While I would like to make it default unfortunately it would require updating a bunch of the existing clang tests which doesn't seem too friendly. See the patch update comment for details. > > > Just realized it wouldn't necessarily require regeneration of tests, it would just cause regenerated tests to change a lot when they are eventually regenerated. We should discuss as to whether that's acceptable. I think for now this should be non-default to at least get the functionality in without disturbing existing users and then we can discuss a separate change to make it default. > > It's also possible we could change how clang orders functions. I discovered there's a difference in clang 10 vs. 11 in the order functions are output when OpenMP outlining happens. clang 10 seems to preserve the source order of functions and clang 11 does not. Perhaps that needs to be fixed as I don't know whether that change was intentional or not. Best case, without the option the original behavior is preserved. Is that not the case? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 From cfe-commits at lists.llvm.org Mon Jul 6 19:46:28 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 02:46:28 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <966c49350f0b021c82de2b32bb3b9585@localhost.localdomain> hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/ASTContext.cpp:2414 + assert(PreferredAlign >= ABIAlign && + "PreferredAlign is at least as large as ABIAlign."); + return PreferredAlign; ---------------- Minor nit: s/is/should be/; ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1207 + if (!Base->Class->isEmpty()) + HasNonEmptyBaseClass = true; + ---------------- Just set `HandledFirstNonOverlappingEmptyField` to `true` with a comment before the `if`: By handling a base class that is not empty, we're handling the "first (inherited) member". ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1799 if (D->isBitField()) { + if (FoundNonOverlappingEmptyFieldToHandle) + // For a union, the current field does not represent all "firsts". ---------------- Add a comment before the `if`: ``` // We're going to handle the "first member" based on // `FoundNonOverlappingEmptyFieldToHandle` during the current invocation of // this function; record it as handled for future invocations. ``` Given the rationale from the comment, move the subject `if` to immediately after the determination of `FoundNonOverlappingEmptyFieldToHandle`. That way, the setting of `HandledFirstNonOverlappingEmptyField` becomes less complicated to track. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1832 const ArrayType* ATy = Context.getAsArrayType(D->getType()); FieldAlign = Context.getTypeAlignInChars(ATy->getElementType()); } else if (const ReferenceType *RT = D->getType()->getAs()) { ---------------- It seems that the code to set `AlignIsRequired` is missing from this path. ``` typedef double Dbl __attribute__((__aligned__(2))); typedef Dbl DblArr[]; union U { DblArr fam; char x; }; U u[2]; extern char x[sizeof(u)]; extern char x[4]; ``` ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1908 + FoundNonOverlappingEmptyFieldToHandle))) { + HandledFirstNonOverlappingEmptyField = !IsUnion; + ---------------- I think the `if` condition above is too complicated as a filter for setting `HandledFirstNonOverlappingEmptyField`. I would prefer if we don't need to set `HandledFirstNonOverlappingEmptyField` here. Please see my other comment about `HandledFirstNonOverlappingEmptyField`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 20:11:49 2020 From: cfe-commits at lists.llvm.org (Jakub Kuderski via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 03:11:49 +0000 (UTC) Subject: [PATCH] D83087: DomTree: remove explicit use of DomTreeNodeBase::iterator In-Reply-To: References: Message-ID: <5dcc5253fd173402f6aad63a3ea956a8@localhost.localdomain> kuhar accepted this revision. kuhar added a comment. LGTM modulo accidental formatting changes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83087/new/ https://reviews.llvm.org/D83087 From cfe-commits at lists.llvm.org Mon Jul 6 20:16:07 2020 From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 03:16:07 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: <234281e4cbab0d0e4729d8a335b1ccde@localhost.localdomain> NoQ accepted this revision. NoQ added a comment. This revision is now accepted and ready to land. 🎉! I vaguely remember that we talked offline about a few nasty test cases that with casts and overflows, would it make sense to add them? Like, even if they don't pass yet, they may prove valuable. ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1472 + // path compression when dealing with immutability. That means that we + // compress paths every time we do merges. It also means that we loose + // the main amortized complexity benefit from the original data structure. ---------------- "lose"! ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1487 + // we shouldn't generate ranges incompatible with equivalence classes. + // However, at the moment, due to imperfections in the solver, it is + // possible and the merge function can also return infeasible states ---------------- "I am the solver!!!" I guess what you're trying to say is that every time there's an infeasible state here, technically one of the `infer()` functions had a chance to prevent it (not necessarily easily). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 From cfe-commits at lists.llvm.org Mon Jul 6 20:19:06 2020 From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 03:19:06 +0000 (UTC) Subject: [PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences In-Reply-To: References: Message-ID: <48ff417672ffa6d4b7f7e8261b0578d3@localhost.localdomain> NoQ added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:202-219 +ProgramStateRef +SmartPtrModeling::updateTrackedRegion(const CallEvent &Call, CheckerContext &C, + const MemRegion *ThisValRegion) const { + ProgramStateRef State = C.getState(); + auto NumArgs = Call.getNumArgs(); + + if (NumArgs == 0) { ---------------- Szelethus wrote: > Hmm, this function feels clunky. So, if the call has no arguments, we set the smart pointer to null, otherwise if its a single-argument then we set it to whatever the argument is? > > How about `operator[]`, that also takes a single argument, but isn't a memory region? `get`, `get_deleter` don't take any arguments, but they don't set the internal pointee to null either. The name `updateTrackedRegion` however suggests that whatever operation was done, this is the one-tool-to-solve-it-all function to take care of it. > > I think this function handles too many things as once, and the name and lack of documentation obfuscates its purpose. How about we put the relevant code to `handleRelease`, and repurpose the rest of the function like this: > > `updateOwnedRegion(CallEvent, CheckerContext, MemRegion of the smart pointer, MemRegion to take ownership of)` > > What do you think? Yup, I completely agree. I think this structure will naturally evolve into something cleaner once more modeling gets added. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81315/new/ https://reviews.llvm.org/D81315 From cfe-commits at lists.llvm.org Mon Jul 6 20:24:10 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 03:24:10 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors In-Reply-To: References: Message-ID: <7e78a7ffcf4bbf58d4b5ec48d0014dc7@localhost.localdomain> oontvoo updated this revision to Diff 275895. oontvoo added a comment. Add more tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83263/new/ https://reviews.llvm.org/D83263 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/attr-trivial-abi.cpp clang/test/SemaObjCXX/attr-trivial-abi.mm -------------- next part -------------- A non-text attachment was scrubbed... Name: D83263.275895.patch Type: text/x-patch Size: 6285 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 20:48:41 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 03:48:41 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors In-Reply-To: References: Message-ID: <408abb38d5ae437403e0b24c7a113deb@localhost.localdomain> oontvoo updated this revision to Diff 275898. oontvoo added a comment. updated diff Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83263/new/ https://reviews.llvm.org/D83263 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/attr-trivial-abi.cpp clang/test/SemaObjCXX/attr-trivial-abi.mm -------------- next part -------------- A non-text attachment was scrubbed... Name: D83263.275898.patch Type: text/x-patch Size: 6417 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 20:55:54 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 03:55:54 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors In-Reply-To: References: Message-ID: <03b9974cb25ff140331dc93a9d67e26d@localhost.localdomain> oontvoo updated this revision to Diff 275899. oontvoo added a comment. updated diff Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83263/new/ https://reviews.llvm.org/D83263 Files: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/attr-trivial-abi.cpp clang/test/SemaObjCXX/attr-trivial-abi.mm -------------- next part -------------- A non-text attachment was scrubbed... Name: D83263.275899.patch Type: text/x-patch Size: 6271 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 21:16:41 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 04:16:41 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <1611a9672945eedd788d4f9a2e1c225e@localhost.localdomain> hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1910 + + auto upgradeAlignmentIfQualified = [&](const BuiltinType *BTy) { + if (BTy->getKind() == BuiltinType::Double || ---------------- "Qualified" is a term of art in the context of C/C++ types. Please remove "IfQualified" from the name. The lambda just needs to be named for what it does. When naming it for the conditions where it should be called, "if" (as opposed to "assuming") implies that the function checks the condition itself. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1927 + assert(RD && "Expected non-null RecordDecl."); + if (RD) { + const ASTRecordLayout &FieldRecord = Context.getASTRecordLayout(RD); ---------------- Please don't write a check on a variable right after making an assertion on what its value should be. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Mon Jul 6 22:28:15 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 05:28:15 +0000 (UTC) Subject: [PATCH] D83154: clang: Add -fcoverage-prefix-map In-Reply-To: References: Message-ID: <784ad864c601a145f1ce1b53a2491657@localhost.localdomain> MaskRay added a comment. -fdebug-prefix-map does not make sense to me because coverage is not debug info. I am on the fence whether we need -fcoverage-prefix-map. I created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96092 (Should --coverage respect -ffile-prefix-map?) ================ Comment at: clang/include/clang/Driver/Options.td:2066 + : Joined<["-"], "fcoverage-prefix-map=">, Group, + Flags<[CC1Option,CC1AsOption]>, + HelpText<"remap file source paths in coverage info">; ---------------- Drop CC1AsOption The option does not affect -cc1as (assembly input) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83154/new/ https://reviews.llvm.org/D83154 From cfe-commits at lists.llvm.org Mon Jul 6 22:33:29 2020 From: cfe-commits at lists.llvm.org (Richard Smith - zygoloid via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 05:33:29 +0000 (UTC) Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of copy and move ctors In-Reply-To: References: Message-ID: <9a75ba7f7449ef731daab24a802aa7b3@localhost.localdomain> rsmith added inline comments. ================ Comment at: clang/lib/Sema/SemaDeclCXX.cpp:9733 return true; return false; }; ---------------- This is not the right fallback answer if the class is a dependent type -- we don't yet know if there's a non-deleted copy or move constructor if one might be implicitly declared, so we should conservatively assume that there might be one. It'd probably be easiest to return `true` from this function at the very start if the type is dependent (because we don't know if there's a non-deleted copy or move constructor). ================ Comment at: clang/test/SemaObjCXX/attr-trivial-abi.mm:59-62 +template +struct __attribute__((trivial_abi)) S10 { // expected-warning {{'trivial_abi' cannot be applied to 'S10}}' expected-note {{copy constructors and move constructors are all deleted}} T p; }; ---------------- We should not diagnose this, because instantiations of this template might have non-deleted copy or move constructors. (We don't know yet when parsing the template definition.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83263/new/ https://reviews.llvm.org/D83263 From cfe-commits at lists.llvm.org Mon Jul 6 23:14:39 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 06:14:39 +0000 (UTC) Subject: [PATCH] D83281: [OpenMP] Allow traits for the OpenMP context selector `isa` Message-ID: jdoerfert created this revision. jdoerfert added reviewers: jhuber6, fghanim, JonChesterfield, grokos, ggeorgakoudis, ABataev. Herald added subscribers: llvm-commits, sstefan1, guansong, bollu, hiraditya, yaxunl. Herald added projects: clang, LLVM. NOTE: The changes are fairly mechanical overall but this patch currently lacks proper testing. An updated version with more test coverage will be provided. It was unclear what `isa` was supposed to mean so we did not provide any traits for this context selector. With this patch we will allow *any* string or identifier. We use the target attribute and target info to determine if the trait matches. In other words, we will check if the provided value is a target feature that is available (at the call site). Fixes PR46338 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83281 Files: clang/include/clang/AST/OpenMPClause.h clang/lib/AST/OpenMPClause.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/declare_variant_device_isa_codegen_1.c llvm/include/llvm/Frontend/OpenMP/OMPContext.h llvm/include/llvm/Frontend/OpenMP/OMPKinds.def llvm/lib/Frontend/OpenMP/OMPContext.cpp llvm/unittests/Frontend/OpenMPContextTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83281.275912.patch Type: text/x-patch Size: 21680 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 23:15:00 2020 From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits) Date: Mon, 06 Jul 2020 23:15:00 -0700 (PDT) Subject: [clang] 16f3d69 - [X86] Move the feature dependency handling in X86TargetInfo::setFeatureEnabledImpl to a table based lookup in X86TargetParser.cpp Message-ID: <5f0412e4.1c69fb81.a9431.89ec@mx.google.com> Author: Craig Topper Date: 2020-07-06T23:14:02-07:00 New Revision: 16f3d698f2afbbea43e0c3df81df6f2a640ce806 URL: https://github.com/llvm/llvm-project/commit/16f3d698f2afbbea43e0c3df81df6f2a640ce806 DIFF: https://github.com/llvm/llvm-project/commit/16f3d698f2afbbea43e0c3df81df6f2a640ce806.diff LOG: [X86] Move the feature dependency handling in X86TargetInfo::setFeatureEnabledImpl to a table based lookup in X86TargetParser.cpp Previously we had to specify the forward and backwards feature dependencies separately which was error prone. And as dependencies have gotten more complex it was hard to be sure the transitive dependencies were handled correctly. The way it was written was also not super readable. This patch replaces everything with a table that lists what features a feature is dependent on directly. Then we can recursively walk through the table to find the transitive dependencies. This is largely based on how we handle subtarget features in the MC layer from the tablegen descriptions. Differential Revision: https://reviews.llvm.org/D83273 Added: Modified: clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h llvm/include/llvm/Support/X86TargetParser.def llvm/include/llvm/Support/X86TargetParser.h llvm/lib/Support/X86TargetParser.cpp Removed: ################################################################################ diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index ed62848d8070..9ea0925cb535 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -145,155 +145,6 @@ bool X86TargetInfo::initFeatureMap( return true; } -void X86TargetInfo::setSSELevel(llvm::StringMap &Features, - X86SSEEnum Level, bool Enabled) { - if (Enabled) { - switch (Level) { - case AVX512F: - Features["avx512f"] = true; - Features["fma"] = true; - Features["f16c"] = true; - LLVM_FALLTHROUGH; - case AVX2: - Features["avx2"] = true; - LLVM_FALLTHROUGH; - case AVX: - Features["avx"] = true; - LLVM_FALLTHROUGH; - case SSE42: - Features["sse4.2"] = true; - LLVM_FALLTHROUGH; - case SSE41: - Features["sse4.1"] = true; - LLVM_FALLTHROUGH; - case SSSE3: - Features["ssse3"] = true; - LLVM_FALLTHROUGH; - case SSE3: - Features["sse3"] = true; - LLVM_FALLTHROUGH; - case SSE2: - Features["sse2"] = true; - LLVM_FALLTHROUGH; - case SSE1: - Features["sse"] = true; - LLVM_FALLTHROUGH; - case NoSSE: - break; - } - return; - } - - switch (Level) { - case NoSSE: - case SSE1: - Features["sse"] = false; - LLVM_FALLTHROUGH; - case SSE2: - Features["sse2"] = Features["pclmul"] = Features["aes"] = false; - Features["sha"] = Features["gfni"] = false; - LLVM_FALLTHROUGH; - case SSE3: - Features["sse3"] = false; - setXOPLevel(Features, NoXOP, false); - LLVM_FALLTHROUGH; - case SSSE3: - Features["ssse3"] = false; - LLVM_FALLTHROUGH; - case SSE41: - Features["sse4.1"] = false; - LLVM_FALLTHROUGH; - case SSE42: - Features["sse4.2"] = false; - LLVM_FALLTHROUGH; - case AVX: - Features["fma"] = Features["avx"] = Features["f16c"] = false; - Features["vaes"] = Features["vpclmulqdq"] = false; - setXOPLevel(Features, FMA4, false); - LLVM_FALLTHROUGH; - case AVX2: - Features["avx2"] = false; - LLVM_FALLTHROUGH; - case AVX512F: - Features["avx512f"] = Features["avx512cd"] = Features["avx512er"] = false; - Features["avx512pf"] = Features["avx512dq"] = Features["avx512bw"] = false; - Features["avx512vl"] = Features["avx512vbmi"] = false; - Features["avx512ifma"] = Features["avx512vpopcntdq"] = false; - Features["avx512bitalg"] = Features["avx512vnni"] = false; - Features["avx512vbmi2"] = Features["avx512bf16"] = false; - Features["avx512vp2intersect"] = false; - break; - } -} - -void X86TargetInfo::setMMXLevel(llvm::StringMap &Features, - MMX3DNowEnum Level, bool Enabled) { - if (Enabled) { - switch (Level) { - case AMD3DNowAthlon: - Features["3dnowa"] = true; - LLVM_FALLTHROUGH; - case AMD3DNow: - Features["3dnow"] = true; - LLVM_FALLTHROUGH; - case MMX: - Features["mmx"] = true; - LLVM_FALLTHROUGH; - case NoMMX3DNow: - break; - } - return; - } - - switch (Level) { - case NoMMX3DNow: - case MMX: - Features["mmx"] = false; - LLVM_FALLTHROUGH; - case AMD3DNow: - Features["3dnow"] = false; - LLVM_FALLTHROUGH; - case AMD3DNowAthlon: - Features["3dnowa"] = false; - break; - } -} - -void X86TargetInfo::setXOPLevel(llvm::StringMap &Features, XOPEnum Level, - bool Enabled) { - if (Enabled) { - switch (Level) { - case XOP: - Features["xop"] = true; - LLVM_FALLTHROUGH; - case FMA4: - Features["fma4"] = true; - setSSELevel(Features, AVX, true); - LLVM_FALLTHROUGH; - case SSE4A: - Features["sse4a"] = true; - setSSELevel(Features, SSE3, true); - LLVM_FALLTHROUGH; - case NoXOP: - break; - } - return; - } - - switch (Level) { - case NoXOP: - case SSE4A: - Features["sse4a"] = false; - LLVM_FALLTHROUGH; - case FMA4: - Features["fma4"] = false; - LLVM_FALLTHROUGH; - case XOP: - Features["xop"] = false; - break; - } -} - void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, StringRef Name, bool Enabled) { if (Name == "sse4") { @@ -309,96 +160,10 @@ void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, Features[Name] = Enabled; - if (Name == "mmx") { - setMMXLevel(Features, MMX, Enabled); - } else if (Name == "sse") { - setSSELevel(Features, SSE1, Enabled); - } else if (Name == "sse2") { - setSSELevel(Features, SSE2, Enabled); - } else if (Name == "sse3") { - setSSELevel(Features, SSE3, Enabled); - } else if (Name == "ssse3") { - setSSELevel(Features, SSSE3, Enabled); - } else if (Name == "sse4.2") { - setSSELevel(Features, SSE42, Enabled); - } else if (Name == "sse4.1") { - setSSELevel(Features, SSE41, Enabled); - } else if (Name == "3dnow") { - setMMXLevel(Features, AMD3DNow, Enabled); - } else if (Name == "3dnowa") { - setMMXLevel(Features, AMD3DNowAthlon, Enabled); - } else if (Name == "aes") { - if (Enabled) - setSSELevel(Features, SSE2, Enabled); - else - Features["vaes"] = false; - } else if (Name == "vaes") { - if (Enabled) { - setSSELevel(Features, AVX, Enabled); - Features["aes"] = true; - } - } else if (Name == "pclmul") { - if (Enabled) - setSSELevel(Features, SSE2, Enabled); - else - Features["vpclmulqdq"] = false; - } else if (Name == "vpclmulqdq") { - if (Enabled) { - setSSELevel(Features, AVX, Enabled); - Features["pclmul"] = true; - } - } else if (Name == "gfni") { - if (Enabled) - setSSELevel(Features, SSE2, Enabled); - } else if (Name == "avx") { - setSSELevel(Features, AVX, Enabled); - } else if (Name == "avx2") { - setSSELevel(Features, AVX2, Enabled); - } else if (Name == "avx512f") { - setSSELevel(Features, AVX512F, Enabled); - } else if (Name.startswith("avx512")) { - if (Enabled) - setSSELevel(Features, AVX512F, Enabled); - // Enable BWI instruction if certain features are being enabled. - if ((Name == "avx512vbmi" || Name == "avx512vbmi2" || - Name == "avx512bitalg" || Name == "avx512bf16") && Enabled) - Features["avx512bw"] = true; - // Also disable some features if BWI is being disabled. - if (Name == "avx512bw" && !Enabled) { - Features["avx512vbmi"] = false; - Features["avx512vbmi2"] = false; - Features["avx512bitalg"] = false; - Features["avx512bf16"] = false; - } - } else if (Name == "fma") { - if (Enabled) - setSSELevel(Features, AVX, Enabled); - else - setSSELevel(Features, AVX512F, Enabled); - } else if (Name == "fma4") { - setXOPLevel(Features, FMA4, Enabled); - } else if (Name == "xop") { - setXOPLevel(Features, XOP, Enabled); - } else if (Name == "sse4a") { - setXOPLevel(Features, SSE4A, Enabled); - } else if (Name == "f16c") { - if (Enabled) - setSSELevel(Features, AVX, Enabled); - else - setSSELevel(Features, AVX512F, Enabled); - } else if (Name == "sha") { - if (Enabled) - setSSELevel(Features, SSE2, Enabled); - } else if (Name == "xsave") { - if (!Enabled) - Features["xsaveopt"] = Features["xsavec"] = Features["xsaves"] = false; - } else if (Name == "xsaveopt" || Name == "xsavec" || Name == "xsaves") { - if (Enabled) - Features["xsave"] = true; - } else if (Name == "amx-tile" && !Enabled) { - Features["amx-bf16"] = Features["amx-int8"] = false; - } else if ((Name == "amx-bf16" || Name == "amx-int8") && Enabled) - Features["amx-tile"] = true; + SmallVector ImpliedFeatures; + llvm::X86::getImpliedFeatures(Name, Enabled, ImpliedFeatures); + for (const auto &F : ImpliedFeatures) + Features[F] = Enabled; } /// handleTargetFeatures - Perform initialization based on the user diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 623ac9474b5c..b783decd72be 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -262,15 +262,6 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - static void setSSELevel(llvm::StringMap &Features, X86SSEEnum Level, - bool Enabled); - - static void setMMXLevel(llvm::StringMap &Features, MMX3DNowEnum Level, - bool Enabled); - - static void setXOPLevel(llvm::StringMap &Features, XOPEnum Level, - bool Enabled); - void setFeatureEnabled(llvm::StringMap &Features, StringRef Name, bool Enabled) const override { setFeatureEnabledImpl(Features, Name, Enabled); diff --git a/llvm/include/llvm/Support/X86TargetParser.def b/llvm/include/llvm/Support/X86TargetParser.def index a395ee86961d..e53ef20f939e 100644 --- a/llvm/include/llvm/Support/X86TargetParser.def +++ b/llvm/include/llvm/Support/X86TargetParser.def @@ -174,13 +174,16 @@ X86_FEATURE_COMPAT(AVX512VP2INTERSECT, "avx512vp2intersect") X86_FEATURE (3DNOW, "3dnow") X86_FEATURE (3DNOWA, "3dnowa") X86_FEATURE (ADX, "adx") +X86_FEATURE (AMX_BF16, "amx-bf16") +X86_FEATURE (AMX_INT8, "amx-int8") +X86_FEATURE (AMX_TILE, "amx-tile") X86_FEATURE (CLDEMOTE, "cldemote") X86_FEATURE (CLFLUSHOPT, "clflushopt") X86_FEATURE (CLWB, "clwb") X86_FEATURE (CLZERO, "clzero") X86_FEATURE (CMPXCHG16B, "cx16") X86_FEATURE (CMPXCHG8B, "cx8") -X86_FEATURE (EM64T, nullptr) +X86_FEATURE (EM64T, "") X86_FEATURE (ENQCMD, "enqcmd") X86_FEATURE (F16C, "f16c") X86_FEATURE (FSGSBASE, "fsgsbase") @@ -209,6 +212,7 @@ X86_FEATURE (SHSTK, "shstk") X86_FEATURE (TBM, "tbm") X86_FEATURE (TSXLDTRK, "tsxldtrk") X86_FEATURE (VAES, "vaes") +X86_FEATURE (VZEROUPPER, "vzeroupper") X86_FEATURE (WAITPKG, "waitpkg") X86_FEATURE (WBNOINVD, "wbnoinvd") X86_FEATURE (X87, "x87") @@ -216,5 +220,10 @@ X86_FEATURE (XSAVE, "xsave") X86_FEATURE (XSAVEC, "xsavec") X86_FEATURE (XSAVEOPT, "xsaveopt") X86_FEATURE (XSAVES, "xsaves") +// These features aren't really CPU features, but the frontend can set them. +X86_FEATURE (RETPOLINE_INDIRECT_BRANCHES, "retpoline-indirect-branches") +X86_FEATURE (RETPOLINE_INDIRECT_CALLS, "retpoline-indirect-calls") +X86_FEATURE (LVI_CFI, "lvi-cfi") +X86_FEATURE (LVI_LOAD_HARDENING, "lvi-load-hardening") #undef X86_FEATURE_COMPAT #undef X86_FEATURE diff --git a/llvm/include/llvm/Support/X86TargetParser.h b/llvm/include/llvm/Support/X86TargetParser.h index 5897e79eb287..4a4fb8ccc4cc 100644 --- a/llvm/include/llvm/Support/X86TargetParser.h +++ b/llvm/include/llvm/Support/X86TargetParser.h @@ -137,6 +137,11 @@ ProcessorFeatures getKeyFeature(CPUKind Kind); /// Fill in the features that \p CPU supports into \p Features. void getFeaturesForCPU(StringRef CPU, SmallVectorImpl &Features); +/// Fill \p Features with the features that are implied to be enabled/disabled +/// by the provided \p Feature. +void getImpliedFeatures(StringRef Feature, bool Enabled, + SmallVectorImpl &Features); + } // namespace X86 } // namespace llvm diff --git a/llvm/lib/Support/X86TargetParser.cpp b/llvm/lib/Support/X86TargetParser.cpp index 452d0934f29b..5e4f62d8a1d6 100644 --- a/llvm/lib/Support/X86TargetParser.cpp +++ b/llvm/lib/Support/X86TargetParser.cpp @@ -48,6 +48,14 @@ class FeatureBitset { return (Bits[I / 32] & Mask) != 0; } + constexpr FeatureBitset &operator|=(const FeatureBitset &RHS) { + for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) { + uint32_t NewBits = Bits[I] | RHS.Bits[I]; + Bits[I] = NewBits; + } + return *this; + } + constexpr FeatureBitset operator&(const FeatureBitset &RHS) const { FeatureBitset Result; for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) @@ -77,6 +85,11 @@ struct ProcInfo { FeatureBitset Features; }; +struct FeatureInfo { + StringLiteral Name; + FeatureBitset ImpliedFeatures; +}; + } // end anonymous namespace #define X86_FEATURE(ENUM, STRING) \ @@ -376,19 +389,187 @@ ProcessorFeatures llvm::X86::getKeyFeature(X86::CPUKind Kind) { llvm_unreachable("Unable to find CPU kind!"); } -static const char *FeatureStrings[X86::CPU_FEATURE_MAX] = { -#define X86_FEATURE(ENUM, STR) STR, +// Features with no dependencies. +static constexpr FeatureBitset ImpliedFeaturesADX = {}; +static constexpr FeatureBitset ImpliedFeaturesBMI = {}; +static constexpr FeatureBitset ImpliedFeaturesBMI2 = {}; +static constexpr FeatureBitset ImpliedFeaturesCLDEMOTE = {}; +static constexpr FeatureBitset ImpliedFeaturesCLFLUSHOPT = {}; +static constexpr FeatureBitset ImpliedFeaturesCLWB = {}; +static constexpr FeatureBitset ImpliedFeaturesCLZERO = {}; +static constexpr FeatureBitset ImpliedFeaturesCMOV = {}; +static constexpr FeatureBitset ImpliedFeaturesCMPXCHG16B = {}; +static constexpr FeatureBitset ImpliedFeaturesCMPXCHG8B = {}; +static constexpr FeatureBitset ImpliedFeaturesEM64T = {}; +static constexpr FeatureBitset ImpliedFeaturesENQCMD = {}; +static constexpr FeatureBitset ImpliedFeaturesFSGSBASE = {}; +static constexpr FeatureBitset ImpliedFeaturesFXSR = {}; +static constexpr FeatureBitset ImpliedFeaturesINVPCID = {}; +static constexpr FeatureBitset ImpliedFeaturesLWP = {}; +static constexpr FeatureBitset ImpliedFeaturesLZCNT = {}; +static constexpr FeatureBitset ImpliedFeaturesMWAITX = {}; +static constexpr FeatureBitset ImpliedFeaturesMOVBE = {}; +static constexpr FeatureBitset ImpliedFeaturesMOVDIR64B = {}; +static constexpr FeatureBitset ImpliedFeaturesMOVDIRI = {}; +static constexpr FeatureBitset ImpliedFeaturesPCONFIG = {}; +static constexpr FeatureBitset ImpliedFeaturesPOPCNT = {}; +static constexpr FeatureBitset ImpliedFeaturesPKU = {}; +static constexpr FeatureBitset ImpliedFeaturesPREFETCHWT1 = {}; +static constexpr FeatureBitset ImpliedFeaturesPRFCHW = {}; +static constexpr FeatureBitset ImpliedFeaturesPTWRITE = {}; +static constexpr FeatureBitset ImpliedFeaturesRDPID = {}; +static constexpr FeatureBitset ImpliedFeaturesRDRND = {}; +static constexpr FeatureBitset ImpliedFeaturesRDSEED = {}; +static constexpr FeatureBitset ImpliedFeaturesRTM = {}; +static constexpr FeatureBitset ImpliedFeaturesSAHF = {}; +static constexpr FeatureBitset ImpliedFeaturesSERIALIZE = {}; +static constexpr FeatureBitset ImpliedFeaturesSGX = {}; +static constexpr FeatureBitset ImpliedFeaturesSHSTK = {}; +static constexpr FeatureBitset ImpliedFeaturesTBM = {}; +static constexpr FeatureBitset ImpliedFeaturesTSXLDTRK = {}; +static constexpr FeatureBitset ImpliedFeaturesWAITPKG = {}; +static constexpr FeatureBitset ImpliedFeaturesWBNOINVD = {}; +static constexpr FeatureBitset ImpliedFeaturesVZEROUPPER = {}; +static constexpr FeatureBitset ImpliedFeaturesX87 = {}; +static constexpr FeatureBitset ImpliedFeaturesXSAVE = {}; + +// Not really CPU features, but need to be in the table because clang uses +// target features to communicate them to the backend. +static constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_BRANCHES = {}; +static constexpr FeatureBitset ImpliedFeaturesRETPOLINE_INDIRECT_CALLS = {}; +static constexpr FeatureBitset ImpliedFeaturesLVI_CFI = {}; +static constexpr FeatureBitset ImpliedFeaturesLVI_LOAD_HARDENING = {}; + +// XSAVE features are dependent on basic XSAVE. +static constexpr FeatureBitset ImpliedFeaturesXSAVEC = FeatureXSAVE; +static constexpr FeatureBitset ImpliedFeaturesXSAVEOPT = FeatureXSAVE; +static constexpr FeatureBitset ImpliedFeaturesXSAVES = FeatureXSAVE; + +// MMX->3DNOW->3DNOWA chain. +static constexpr FeatureBitset ImpliedFeaturesMMX = {}; +static constexpr FeatureBitset ImpliedFeatures3DNOW = FeatureMMX; +static constexpr FeatureBitset ImpliedFeatures3DNOWA = Feature3DNOW; + +// SSE/AVX/AVX512F chain. +static constexpr FeatureBitset ImpliedFeaturesSSE = {}; +static constexpr FeatureBitset ImpliedFeaturesSSE2 = FeatureSSE; +static constexpr FeatureBitset ImpliedFeaturesSSE3 = FeatureSSE2; +static constexpr FeatureBitset ImpliedFeaturesSSSE3 = FeatureSSE3; +static constexpr FeatureBitset ImpliedFeaturesSSE4_1 = FeatureSSSE3; +static constexpr FeatureBitset ImpliedFeaturesSSE4_2 = FeatureSSE4_1; +static constexpr FeatureBitset ImpliedFeaturesAVX = FeatureSSE4_2; +static constexpr FeatureBitset ImpliedFeaturesAVX2 = FeatureAVX; +static constexpr FeatureBitset ImpliedFeaturesAVX512F = + FeatureAVX2 | FeatureF16C | FeatureFMA; + +// Vector extensions that build on SSE or AVX. +static constexpr FeatureBitset ImpliedFeaturesAES = FeatureSSE2; +static constexpr FeatureBitset ImpliedFeaturesF16C = FeatureAVX; +static constexpr FeatureBitset ImpliedFeaturesFMA = FeatureAVX; +static constexpr FeatureBitset ImpliedFeaturesGFNI = FeatureSSE2; +static constexpr FeatureBitset ImpliedFeaturesPCLMUL = FeatureSSE2; +static constexpr FeatureBitset ImpliedFeaturesSHA = FeatureSSE2; +static constexpr FeatureBitset ImpliedFeaturesVAES = FeatureAES | FeatureAVX; +static constexpr FeatureBitset ImpliedFeaturesVPCLMULQDQ = + FeatureAVX | FeaturePCLMUL; + +// AVX512 features. +static constexpr FeatureBitset ImpliedFeaturesAVX512CD = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512BW = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512DQ = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512ER = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512PF = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512VL = FeatureAVX512F; + +static constexpr FeatureBitset ImpliedFeaturesAVX512BF16 = FeatureAVX512BW; +static constexpr FeatureBitset ImpliedFeaturesAVX512BITALG = FeatureAVX512BW; +static constexpr FeatureBitset ImpliedFeaturesAVX512IFMA = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512VNNI = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512VPOPCNTDQ = FeatureAVX512F; +static constexpr FeatureBitset ImpliedFeaturesAVX512VBMI = FeatureAVX512BW; +static constexpr FeatureBitset ImpliedFeaturesAVX512VBMI2 = FeatureAVX512BW; +static constexpr FeatureBitset ImpliedFeaturesAVX512VP2INTERSECT = + FeatureAVX512F; + +// FIXME: These two aren't really implemented and just exist in the feature +// list for __builtin_cpu_supports. So omit their dependencies. +static constexpr FeatureBitset ImpliedFeaturesAVX5124FMAPS = {}; +static constexpr FeatureBitset ImpliedFeaturesAVX5124VNNIW = {}; + +// SSE4_A->FMA4->XOP chain. +static constexpr FeatureBitset ImpliedFeaturesSSE4_A = FeatureSSSE3; +static constexpr FeatureBitset ImpliedFeaturesFMA4 = FeatureAVX | FeatureSSE4_A; +static constexpr FeatureBitset ImpliedFeaturesXOP = FeatureFMA4; + +// AMX Features +static constexpr FeatureBitset ImpliedFeaturesAMX_TILE = {}; +static constexpr FeatureBitset ImpliedFeaturesAMX_BF16 = FeatureAMX_TILE; +static constexpr FeatureBitset ImpliedFeaturesAMX_INT8 = FeatureAMX_TILE; + +static constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = { +#define X86_FEATURE(ENUM, STR) {{STR}, ImpliedFeatures##ENUM}, #include "llvm/Support/X86TargetParser.def" }; +// Convert the set bits in FeatureBitset to a list of strings. +static void getFeatureBitsAsStrings(const FeatureBitset &Bits, + SmallVectorImpl &Features) { + for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i) + if (Bits[i] && !FeatureInfos[i].Name.empty()) + Features.push_back(FeatureInfos[i].Name); +} + void llvm::X86::getFeaturesForCPU(StringRef CPU, - SmallVectorImpl &Features) { + SmallVectorImpl &EnabledFeatures) { auto I = llvm::find_if(Processors, [&](const ProcInfo &P) { return P.Name == CPU; }); assert(I != std::end(Processors) && "Processor not found!"); // Add the string version of all set bits. - for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i) - if (FeatureStrings[i] && I->Features[i]) - Features.push_back(FeatureStrings[i]); + getFeatureBitsAsStrings(I->Features, EnabledFeatures); +} + +// For each feature that is (transitively) implied by this feature, set it. +static void getImpliedEnabledFeatures(FeatureBitset &Bits, + const FeatureBitset &Implies) { + Bits |= Implies; + for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i) { + if (Implies[i]) + getImpliedEnabledFeatures(Bits, FeatureInfos[i].ImpliedFeatures); + } +} + +/// Create bit vector of features that are implied disabled if the feature +/// passed in Value is disabled. +static void getImpliedDisabledFeatures(FeatureBitset &Bits, unsigned Value) { + // Check all features looking for any dependent on this feature. If we find + // one, mark it and recursively find any feature that depend on it. + for (unsigned i = 0; i != CPU_FEATURE_MAX; ++i) { + if (FeatureInfos[i].ImpliedFeatures[Value]) { + Bits.set(i); + getImpliedDisabledFeatures(Bits, i); + } + } +} + +void llvm::X86::getImpliedFeatures( + StringRef Feature, bool Enabled, + SmallVectorImpl &ImpliedFeatures) { + auto I = llvm::find_if( + FeatureInfos, [&](const FeatureInfo &FI) { return FI.Name == Feature; }); + if (I == std::end(FeatureInfos)) { + // This shouldn't happen, but handle it gracefully for release builds. + assert(false && "Feature not in table!"); + return; + } + + FeatureBitset ImpliedBits; + if (Enabled) + getImpliedEnabledFeatures(ImpliedBits, I->ImpliedFeatures); + else + getImpliedDisabledFeatures(ImpliedBits, + std::distance(std::begin(FeatureInfos), I)); + + // Convert all the found bits into strings. + getFeatureBitsAsStrings(ImpliedBits, ImpliedFeatures); } From cfe-commits at lists.llvm.org Mon Jul 6 23:15:04 2020 From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 06:15:04 +0000 (UTC) Subject: [PATCH] D83273: [X86] Remove the feature dependency handling in X86TargetInfo::setFeatureEnabledImpl to a table based lookup in X86TargetParser.cpp In-Reply-To: References: Message-ID: <7159e778ba97c1f8ba5eaf902f22b704@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG16f3d698f2af: [X86] Move the feature dependency handling in X86TargetInfo… (authored by craig.topper). Herald added a project: clang. Changed prior to commit: https://reviews.llvm.org/D83273?vs=275883&id=275913#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83273/new/ https://reviews.llvm.org/D83273 Files: clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h llvm/include/llvm/Support/X86TargetParser.def llvm/include/llvm/Support/X86TargetParser.h llvm/lib/Support/X86TargetParser.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83273.275913.patch Type: text/x-patch Size: 21842 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Mon Jul 6 23:37:20 2020 From: cfe-commits at lists.llvm.org (Saiyedul Islam via cfe-commits) Date: Mon, 06 Jul 2020 23:37:20 -0700 (PDT) Subject: [clang] 0882c9d - [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values Message-ID: <5f041820.1c69fb81.7c16d.5d10@mx.google.com> Author: Saiyedul Islam Date: 2020-07-07T06:36:25Z New Revision: 0882c9d4fc49858338c9655154f1ad8357a8e516 URL: https://github.com/llvm/llvm-project/commit/0882c9d4fc49858338c9655154f1ad8357a8e516 DIFF: https://github.com/llvm/llvm-project/commit/0882c9d4fc49858338c9655154f1ad8357a8e516.diff LOG: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values builtin_amdgcn_atomic_inc32(uint *Ptr, uint Val, unsigned MemoryOrdering, const char *SyncScope) builtin_amdgcn_atomic_inc64(uint64_t *Ptr, uint64_t Val, unsigned MemoryOrdering, const char *SyncScope) builtin_amdgcn_atomic_dec32(uint *Ptr, uint Val, unsigned MemoryOrdering, const char *SyncScope) builtin_amdgcn_atomic_dec64(uint64_t *Ptr, uint64_t Val, unsigned MemoryOrdering, const char *SyncScope) As AMDGCN IR instrinsic for atomic inc/dec does unsigned comparison, these clang builtins should also take unsigned types instead of signed int types. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D83121 Added: Modified: clang/include/clang/Basic/BuiltinsAMDGPU.def clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp clang/test/SemaOpenCL/builtins-amdgcn-error.cl Removed: ################################################################################ diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def b/clang/include/clang/Basic/BuiltinsAMDGPU.def index 60be0525fabc..042a86368559 100644 --- a/clang/include/clang/Basic/BuiltinsAMDGPU.def +++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def @@ -60,11 +60,11 @@ BUILTIN(__builtin_amdgcn_ds_gws_sema_br, "vUiUi", "n") BUILTIN(__builtin_amdgcn_ds_gws_sema_p, "vUi", "n") BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n") -BUILTIN(__builtin_amdgcn_atomic_inc32, "ZiZiD*ZiUicC*", "n") -BUILTIN(__builtin_amdgcn_atomic_inc64, "WiWiD*WiUicC*", "n") +BUILTIN(__builtin_amdgcn_atomic_inc32, "UZiUZiD*UZiUicC*", "n") +BUILTIN(__builtin_amdgcn_atomic_inc64, "UWiUWiD*UWiUicC*", "n") -BUILTIN(__builtin_amdgcn_atomic_dec32, "ZiZiD*ZiUicC*", "n") -BUILTIN(__builtin_amdgcn_atomic_dec64, "WiWiD*WiUicC*", "n") +BUILTIN(__builtin_amdgcn_atomic_dec32, "UZiUZiD*UZiUicC*", "n") +BUILTIN(__builtin_amdgcn_atomic_dec64, "UWiUWiD*UWiUicC*", "n") // FIXME: Need to disallow constant address space. BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n") diff --git a/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp b/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp index 535c3d754954..77ea3d485c8a 100644 --- a/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp +++ b/clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp @@ -2,9 +2,9 @@ // RUN: %clang_cc1 %s -x hip -fcuda-is-device -emit-llvm -O0 -o - \ // RUN: -triple=amdgcn-amd-amdhsa | opt -S | FileCheck %s -__attribute__((device)) void test_non_volatile_parameter32(int *ptr) { +__attribute__((device)) void test_non_volatile_parameter32(__UINT32_TYPE__ *ptr) { // CHECK-LABEL: test_non_volatile_parameter32 - int res; + __UINT32_TYPE__ res; // CHECK: %ptr.addr = alloca i32*, align 8, addrspace(5) // CHECK-NEXT: %ptr.addr.ascast = addrspacecast i32* addrspace(5)* %ptr.addr to i32** // CHECK-NEXT: %res = alloca i32, align 4, addrspace(5) @@ -25,9 +25,9 @@ __attribute__((device)) void test_non_volatile_parameter32(int *ptr) { res = __builtin_amdgcn_atomic_dec32(ptr, *ptr, __ATOMIC_SEQ_CST, "workgroup"); } -__attribute__((device)) void test_non_volatile_parameter64(__INT64_TYPE__ *ptr) { +__attribute__((device)) void test_non_volatile_parameter64(__UINT64_TYPE__ *ptr) { // CHECK-LABEL: test_non_volatile_parameter64 - __INT64_TYPE__ res; + __UINT64_TYPE__ res; // CHECK: %ptr.addr = alloca i64*, align 8, addrspace(5) // CHECK-NEXT: %ptr.addr.ascast = addrspacecast i64* addrspace(5)* %ptr.addr to i64** // CHECK-NEXT: %res = alloca i64, align 8, addrspace(5) @@ -48,9 +48,9 @@ __attribute__((device)) void test_non_volatile_parameter64(__INT64_TYPE__ *ptr) res = __builtin_amdgcn_atomic_dec64(ptr, *ptr, __ATOMIC_SEQ_CST, "workgroup"); } -__attribute__((device)) void test_volatile_parameter32(volatile int *ptr) { +__attribute__((device)) void test_volatile_parameter32(volatile __UINT32_TYPE__ *ptr) { // CHECK-LABEL: test_volatile_parameter32 - int res; + __UINT32_TYPE__ res; // CHECK: %ptr.addr = alloca i32*, align 8, addrspace(5) // CHECK-NEXT: %ptr.addr.ascast = addrspacecast i32* addrspace(5)* %ptr.addr to i32** // CHECK-NEXT: %res = alloca i32, align 4, addrspace(5) @@ -71,9 +71,9 @@ __attribute__((device)) void test_volatile_parameter32(volatile int *ptr) { res = __builtin_amdgcn_atomic_dec32(ptr, *ptr, __ATOMIC_SEQ_CST, "workgroup"); } -__attribute__((device)) void test_volatile_parameter64(volatile __INT64_TYPE__ *ptr) { +__attribute__((device)) void test_volatile_parameter64(volatile __UINT64_TYPE__ *ptr) { // CHECK-LABEL: test_volatile_parameter64 - __INT64_TYPE__ res; + __UINT64_TYPE__ res; // CHECK: %ptr.addr = alloca i64*, align 8, addrspace(5) // CHECK-NEXT: %ptr.addr.ascast = addrspacecast i64* addrspace(5)* %ptr.addr to i64** // CHECK-NEXT: %res = alloca i64, align 8, addrspace(5) @@ -96,7 +96,7 @@ __attribute__((device)) void test_volatile_parameter64(volatile __INT64_TYPE__ * __attribute__((device)) void test_shared32() { // CHECK-LABEL: test_shared32 - __attribute__((shared)) int val; + __attribute__((shared)) __UINT32_TYPE__ val; // CHECK: %0 = load i32, i32* addrspacecast (i32 addrspace(3)* @_ZZ13test_shared32vE3val to i32*), align 4 // CHECK-NEXT: %1 = call i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* addrspacecast (i32 addrspace(3)* @_ZZ13test_shared32vE3val to i32*), i32 %0, i32 7, i32 2, i1 false) @@ -111,7 +111,7 @@ __attribute__((device)) void test_shared32() { __attribute__((device)) void test_shared64() { // CHECK-LABEL: test_shared64 - __attribute__((shared)) __INT64_TYPE__ val; + __attribute__((shared)) __UINT64_TYPE__ val; // CHECK: %0 = load i64, i64* addrspacecast (i64 addrspace(3)* @_ZZ13test_shared64vE3val to i64*), align 8 // CHECK-NEXT: %1 = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* addrspacecast (i64 addrspace(3)* @_ZZ13test_shared64vE3val to i64*), i64 %0, i32 7, i32 2, i1 false) @@ -124,7 +124,7 @@ __attribute__((device)) void test_shared64() { val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_SEQ_CST, "workgroup"); } -int global_val32; +__UINT32_TYPE__ global_val32; __attribute__((device)) void test_global32() { // CHECK-LABEL: test_global32 // CHECK: %0 = load i32, i32* addrspacecast (i32 addrspace(1)* @global_val32 to i32*), align 4 @@ -138,7 +138,7 @@ __attribute__((device)) void test_global32() { global_val32 = __builtin_amdgcn_atomic_dec32(&global_val32, global_val32, __ATOMIC_SEQ_CST, "workgroup"); } -__INT64_TYPE__ global_val64; +__UINT64_TYPE__ global_val64; __attribute__((device)) void test_global64() { // CHECK-LABEL: test_global64 // CHECK: %0 = load i64, i64* addrspacecast (i64 addrspace(1)* @global_val64 to i64*), align 8 @@ -152,10 +152,10 @@ __attribute__((device)) void test_global64() { global_val64 = __builtin_amdgcn_atomic_dec64(&global_val64, global_val64, __ATOMIC_SEQ_CST, "workgroup"); } -__attribute__((constant)) int cval32; +__attribute__((constant)) __UINT32_TYPE__ cval32; __attribute__((device)) void test_constant32() { // CHECK-LABEL: test_constant32 - int local_val; + __UINT32_TYPE__ local_val; // CHECK: %0 = load i32, i32* addrspacecast (i32 addrspace(4)* @cval32 to i32*), align 4 // CHECK-NEXT: %1 = call i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* addrspacecast (i32 addrspace(4)* @cval32 to i32*), i32 %0, i32 7, i32 2, i1 false) @@ -168,10 +168,10 @@ __attribute__((device)) void test_constant32() { local_val = __builtin_amdgcn_atomic_dec32(&cval32, cval32, __ATOMIC_SEQ_CST, "workgroup"); } -__attribute__((constant)) __INT64_TYPE__ cval64; +__attribute__((constant)) __UINT64_TYPE__ cval64; __attribute__((device)) void test_constant64() { // CHECK-LABEL: test_constant64 - __INT64_TYPE__ local_val; + __UINT64_TYPE__ local_val; // CHECK: %0 = load i64, i64* addrspacecast (i64 addrspace(4)* @cval64 to i64*), align 8 // CHECK-NEXT: %1 = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* addrspacecast (i64 addrspace(4)* @cval64 to i64*), i64 %0, i32 7, i32 2, i1 false) @@ -186,7 +186,7 @@ __attribute__((device)) void test_constant64() { __attribute__((device)) void test_order32() { // CHECK-LABEL: test_order32 - __attribute__((shared)) int val; + __attribute__((shared)) __UINT32_TYPE__ val; // CHECK: %1 = call i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* addrspacecast (i32 addrspace(3)* @_ZZ12test_order32vE3val to i32*), i32 %0, i32 4, i32 2, i1 false) val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, "workgroup"); @@ -203,7 +203,7 @@ __attribute__((device)) void test_order32() { __attribute__((device)) void test_order64() { // CHECK-LABEL: test_order64 - __attribute__((shared)) __INT64_TYPE__ val; + __attribute__((shared)) __UINT64_TYPE__ val; // CHECK: %1 = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* addrspacecast (i64 addrspace(3)* @_ZZ12test_order64vE3val to i64*), i64 %0, i32 4, i32 2, i1 false) val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, "workgroup"); @@ -220,7 +220,7 @@ __attribute__((device)) void test_order64() { __attribute__((device)) void test_scope32() { // CHECK-LABEL: test_scope32 - __attribute__((shared)) int val; + __attribute__((shared)) __UINT32_TYPE__ val; // CHECK: %1 = call i32 @llvm.amdgcn.atomic.inc.i32.p0i32(i32* addrspacecast (i32 addrspace(3)* @_ZZ12test_scope32vE3val to i32*), i32 %0, i32 7, i32 1, i1 false) val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_SEQ_CST, ""); @@ -237,7 +237,7 @@ __attribute__((device)) void test_scope32() { __attribute__((device)) void test_scope64() { // CHECK-LABEL: test_scope64 - __attribute__((shared)) __INT64_TYPE__ val; + __attribute__((shared)) __UINT64_TYPE__ val; // CHECK: %1 = call i64 @llvm.amdgcn.atomic.inc.i64.p0i64(i64* addrspacecast (i64 addrspace(3)* @_ZZ12test_scope64vE3val to i64*), i64 %0, i32 7, i32 1, i1 false) val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_SEQ_CST, ""); diff --git a/clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp b/clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp index c08b00bac0cf..9351b4ecb032 100644 --- a/clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp +++ b/clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp @@ -2,17 +2,18 @@ // RUN: not %clang_cc1 %s -x hip -fcuda-is-device -o - -emit-llvm -triple=amdgcn-amd-amdhsa 2>&1 | FileCheck %s void test_host() { - int val; + __UINT32_TYPE__ val32; + __UINT64_TYPE__ val64; // CHECK: error: reference to __device__ function '__builtin_amdgcn_atomic_inc32' in __host__ function - val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_SEQ_CST, ""); + val32 = __builtin_amdgcn_atomic_inc32(&val32, val32, __ATOMIC_SEQ_CST, ""); // CHECK: error: reference to __device__ function '__builtin_amdgcn_atomic_inc64' in __host__ function - val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_SEQ_CST, ""); + val64 = __builtin_amdgcn_atomic_inc64(&val64, val64, __ATOMIC_SEQ_CST, ""); // CHECK: error: reference to __device__ function '__builtin_amdgcn_atomic_dec32' in __host__ function - val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_SEQ_CST, ""); + val32 = __builtin_amdgcn_atomic_dec32(&val32, val32, __ATOMIC_SEQ_CST, ""); // CHECK: error: reference to __device__ function '__builtin_amdgcn_atomic_dec64' in __host__ function - val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_SEQ_CST, ""); + val64 = __builtin_amdgcn_atomic_dec64(&val64, val64, __ATOMIC_SEQ_CST, ""); } diff --git a/clang/test/SemaOpenCL/builtins-amdgcn-error.cl b/clang/test/SemaOpenCL/builtins-amdgcn-error.cl index e2d9082f8f72..8001cf3b59e0 100644 --- a/clang/test/SemaOpenCL/builtins-amdgcn-error.cl +++ b/clang/test/SemaOpenCL/builtins-amdgcn-error.cl @@ -146,7 +146,7 @@ void test_s_setreg(int x, int y) { } void test_atomic_inc32() { - int val = 17; + uint val = 17; val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_inc32(4); // expected-error {{too few arguments to function call, expected 4}} @@ -155,10 +155,12 @@ void test_atomic_inc32() { val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}} const char ptr[] = "workgroup"; val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}} + int signedVal = 15; + signedVal = __builtin_amdgcn_atomic_inc32(&signedVal, signedVal, __ATOMIC_ACQUIRE, ""); // expected-warning {{passing '__private int *' to parameter of type 'volatile __private unsigned int *' converts between pointers to integer types with diff erent sign}} } void test_atomic_inc64() { - __INT64_TYPE__ val = 17; + __UINT64_TYPE__ val = 17; val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_inc64(4); // expected-error {{too few arguments to function call, expected 4}} @@ -167,10 +169,12 @@ void test_atomic_inc64() { val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}} const char ptr[] = "workgroup"; val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}} + __INT64_TYPE__ signedVal = 15; + signedVal = __builtin_amdgcn_atomic_inc64(&signedVal, signedVal, __ATOMIC_ACQUIRE, ""); // expected-warning {{passing '__private long *' to parameter of type 'volatile __private unsigned long *' converts between pointers to integer types with diff erent sign}} } void test_atomic_dec32() { - int val = 17; + uint val = 17; val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_dec32(4); // expected-error {{too few arguments to function call, expected 4}} @@ -179,10 +183,12 @@ void test_atomic_dec32() { val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}} const char ptr[] = "workgroup"; val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}} + int signedVal = 15; + signedVal = __builtin_amdgcn_atomic_dec32(&signedVal, signedVal, __ATOMIC_ACQUIRE, ""); // expected-warning {{passing '__private int *' to parameter of type 'volatile __private unsigned int *' converts between pointers to integer types with diff erent sign}} } void test_atomic_dec64() { - __INT64_TYPE__ val = 17; + __UINT64_TYPE__ val = 17; val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}} val = __builtin_amdgcn_atomic_dec64(4); // expected-error {{too few arguments to function call, expected 4}} @@ -191,4 +197,6 @@ void test_atomic_dec64() { val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}} const char ptr[] = "workgroup"; val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}} + __INT64_TYPE__ signedVal = 15; + signedVal = __builtin_amdgcn_atomic_dec64(&signedVal, signedVal, __ATOMIC_ACQUIRE, ""); // expected-warning {{passing '__private long *' to parameter of type 'volatile __private unsigned long *' converts between pointers to integer types with diff erent sign}} } From cfe-commits at lists.llvm.org Mon Jul 6 23:37:35 2020 From: cfe-commits at lists.llvm.org (Saiyedul Islam via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 06:37:35 +0000 (UTC) Subject: [PATCH] D83121: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values In-Reply-To: References: Message-ID: <5e04ef04a3bd4d53fdce2db925c85217@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG0882c9d4fc49: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values (authored by saiislam). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83121/new/ https://reviews.llvm.org/D83121 Files: clang/include/clang/Basic/BuiltinsAMDGPU.def clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp clang/test/SemaOpenCL/builtins-amdgcn-error.cl -------------- next part -------------- A non-text attachment was scrubbed... Name: D83121.275916.patch Type: text/x-patch Size: 14878 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:01:19 2020 From: cfe-commits at lists.llvm.org (Sander de Smalen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:01:19 +0000 (UTC) Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for -march=armv8.6a+sve. In-Reply-To: References: Message-ID: <79b21d6fcd1f6454047acb85afd9e479@localhost.localdomain> sdesmalen accepted this revision. sdesmalen added a comment. This revision is now accepted and ready to land. LGTM ================ Comment at: clang/test/Preprocessor/aarch64-target-features.c:415 // CHECK-BFLOAT: __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1 - ---------------- nit: unrelated change. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83079/new/ https://reviews.llvm.org/D83079 From cfe-commits at lists.llvm.org Tue Jul 7 00:10:01 2020 From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits) Date: Tue, 07 Jul 2020 00:10:01 -0700 (PDT) Subject: [clang] 3cbfe98 - [X86] Merge X86TargetInfo::setFeatureEnabled and X86TargetInfo::setFeatureEnabledImpl. NFC Message-ID: <5f041fc9.1c69fb81.365e7.6075@mx.google.com> Author: Craig Topper Date: 2020-07-06T23:54:56-07:00 New Revision: 3cbfe988bc5cd366fb0f62e597f899b489c3834d URL: https://github.com/llvm/llvm-project/commit/3cbfe988bc5cd366fb0f62e597f899b489c3834d DIFF: https://github.com/llvm/llvm-project/commit/3cbfe988bc5cd366fb0f62e597f899b489c3834d.diff LOG: [X86] Merge X86TargetInfo::setFeatureEnabled and X86TargetInfo::setFeatureEnabledImpl. NFC setFeatureEnabled is a virtual function. setFeatureEnabledImpl was its implementation. This split was to avoid virtual calls when we need to call setFeatureEnabled in initFeatureMap. With C++11 we can use 'final' on setFeatureEnabled to enable the compiler to perform de-virtualization for the initFeatureMap calls. Added: Modified: clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h Removed: ################################################################################ diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 9ea0925cb535..e280a7216645 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -108,14 +108,14 @@ bool X86TargetInfo::initFeatureMap( // FIXME: This *really* should not be here. // X86_64 always has SSE2. if (getTriple().getArch() == llvm::Triple::x86_64) - setFeatureEnabledImpl(Features, "sse2", true); + setFeatureEnabled(Features, "sse2", true); using namespace llvm::X86; SmallVector CPUFeatures; getFeaturesForCPU(CPU, CPUFeatures); for (auto &F : CPUFeatures) - setFeatureEnabledImpl(Features, F, true); + setFeatureEnabled(Features, F, true); if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec)) return false; @@ -145,8 +145,8 @@ bool X86TargetInfo::initFeatureMap( return true; } -void X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features, - StringRef Name, bool Enabled) { +void X86TargetInfo::setFeatureEnabled(llvm::StringMap &Features, + StringRef Name, bool Enabled) const { if (Name == "sse4") { // We can get here via the __target__ attribute since that's not controlled // via the -msse4/-mno-sse4 command line alias. Handle this the same way diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index b783decd72be..4d76193e7e95 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -263,14 +263,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { MacroBuilder &Builder) const override; void setFeatureEnabled(llvm::StringMap &Features, StringRef Name, - bool Enabled) const override { - setFeatureEnabledImpl(Features, Name, Enabled); - } - - // This exists purely to cut down on the number of virtual calls in - // initFeatureMap which calls this repeatedly. - static void setFeatureEnabledImpl(llvm::StringMap &Features, - StringRef Name, bool Enabled); + bool Enabled) const final; bool initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags, @@ -279,7 +272,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { bool isValidFeatureName(StringRef Name) const override; - bool hasFeature(StringRef Feature) const override; + bool hasFeature(StringRef Feature) const final; bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override; From cfe-commits at lists.llvm.org Tue Jul 7 00:10:21 2020 From: cfe-commits at lists.llvm.org (Jonas Hahnfeld via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:10:21 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <71f9285de61d63872f412f624a0c7ec9@localhost.localdomain> Hahnfeld added a comment. This is definitely not NFC and breaks ABI compatibility (but apparently nobody cares anymore). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 00:20:19 2020 From: cfe-commits at lists.llvm.org (JunMa via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:20:19 +0000 (UTC) Subject: [PATCH] D82442: [Coroutines] Warning if the return type of coroutine_handle::address is not void* In-Reply-To: References: Message-ID: <04b9f157fb4277633d26f456fe274b9d@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG8849831d55a2: [Coroutines] Warning if return type of coroutine_handle::address is not void* (authored by ChuanqiXu, committed by junparser). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D82442?vs=273926&id=275587#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82442/new/ https://reviews.llvm.org/D82442 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/CodeGen/CodeGenFunction.h clang/lib/Sema/SemaCoroutine.cpp clang/test/SemaCXX/coroutine_handle-addres-return-type.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82442.275587.patch Type: text/x-patch Size: 4135 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:20:19 2020 From: cfe-commits at lists.llvm.org (Kazushi Marukawa via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:20:19 +0000 (UTC) Subject: [PATCH] D83173: [VE] Correct stack alignment In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rGdf3bda047d5a: [VE] Correct stack alignment (authored by kaz7). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83173/new/ https://reviews.llvm.org/D83173 Files: clang/lib/Basic/Targets/VE.h clang/test/CodeGen/target-data.c llvm/lib/Target/VE/VETargetMachine.cpp Index: llvm/lib/Target/VE/VETargetMachine.cpp =================================================================== --- llvm/lib/Target/VE/VETargetMachine.cpp +++ llvm/lib/Target/VE/VETargetMachine.cpp @@ -41,8 +41,8 @@ // VE supports 32 bit and 64 bits integer on registers Ret += "-n32:64"; - // Stack alignment is 64 bits - Ret += "-S64"; + // Stack alignment is 128 bits + Ret += "-S128"; return Ret; } Index: clang/test/CodeGen/target-data.c =================================================================== --- clang/test/CodeGen/target-data.c +++ clang/test/CodeGen/target-data.c @@ -250,3 +250,7 @@ // RUN: %clang_cc1 -triple bpfeb -o - -emit-llvm %s | \ // RUN: FileCheck %s -check-prefix=BPFEB // BPFEB: target datalayout = "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128" + +// RUN: %clang_cc1 -triple ve -o - -emit-llvm %s | \ +// RUN: FileCheck %s -check-prefix=VE +// VE: target datalayout = "e-m:e-i64:64-n32:64-S128" Index: clang/lib/Basic/Targets/VE.h =================================================================== --- clang/lib/Basic/Targets/VE.h +++ clang/lib/Basic/Targets/VE.h @@ -45,7 +45,7 @@ WCharType = UnsignedInt; WIntType = UnsignedInt; UseZeroLengthBitfieldAlignment = true; - resetDataLayout("e-m:e-i64:64-n32:64-S64"); + resetDataLayout("e-m:e-i64:64-n32:64-S128"); } void getTargetDefines(const LangOptions &Opts, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83173.275586.patch Type: text/x-patch Size: 1396 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:21:51 2020 From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:21:51 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: logan-5 updated this revision to Diff 275928. logan-5 marked 6 inline comments as done. logan-5 added a comment. Addressed some feedback. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/warn-suggest-destructor-override clang/test/SemaCXX/warn-suggest-override -------------- next part -------------- A non-text attachment was scrubbed... Name: D82728.275928.patch Type: text/x-patch Size: 7681 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:25:12 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 07:25:12 +0000 (UTC) Subject: [PATCH] D81761: [analyzer] Force dependency checkers to be hidden In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG690ff37a2869: [analyzer] Force dependency checkers to be hidden (authored by Szelethus). Changed prior to commit: https://reviews.llvm.org/D81761?vs=274466&id=275598#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81761/new/ https://reviews.llvm.org/D81761 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D81761.275598.patch Type: text/x-patch Size: 22892 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:25:38 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:25:38 +0000 (UTC) Subject: [PATCH] D82921: Removed a RecursiveASTVisitor feature to visit operator kinds with different methods In-Reply-To: References: Message-ID: <37bb18b811e9e1da7c482be5e88cc669@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG5689b38c6a42: Removed a RecursiveASTVisitor feature to visit operator kinds with different… (authored by gribozavr). Changed prior to commit: https://reviews.llvm.org/D82921?vs=275064&id=275601#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82921/new/ https://reviews.llvm.org/D82921 Files: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h clang/docs/ReleaseNotes.rst clang/include/clang/AST/RecursiveASTVisitor.h clang/lib/ARCMigrate/TransProperties.cpp clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82921.275601.patch Type: text/x-patch Size: 50175 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:25:56 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 07:25:56 +0000 (UTC) Subject: [PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGb2956076976c: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics (authored by Szelethus). Changed prior to commit: https://reviews.llvm.org/D78126?vs=270372&id=275605#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78126/new/ https://reviews.llvm.org/D78126 Files: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h clang/lib/StaticAnalyzer/Core/BugReporter.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D78126.275605.patch Type: text/x-patch Size: 5766 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:26:33 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 07:26:33 +0000 (UTC) Subject: [PATCH] D81750: [analyzer] Don't allow hidden checkers to emit diagnostics In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGcfd6b4b811aa: [analyzer] Don't allow hidden checkers to emit diagnostics (authored by Szelethus). Changed prior to commit: https://reviews.llvm.org/D81750?vs=270447&id=275607#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81750/new/ https://reviews.llvm.org/D81750 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Core/BugReporter.cpp clang/test/Analysis/std-c-library-functions-arg-constraints.c clang/test/Analysis/std-c-library-functions-arg-constraints.cpp clang/test/Analysis/weak-dependencies.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D81750.275607.patch Type: text/x-patch Size: 6038 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:26:39 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:26:39 +0000 (UTC) Subject: [PATCH] D82825: [clang-tidy] Added alias llvm-else-after-return. In-Reply-To: References: Message-ID: <0f4be1115b222f3e3aa3851c3407905a@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGfc3c693b617f: [clang-tidy] Added alias llvm-else-after-return. (authored by njames93). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82825/new/ https://reviews.llvm.org/D82825 Files: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst Index: clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst +++ clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst @@ -77,3 +77,13 @@ the ``if`` statement is the last statement in its parents scope. Default value is `true`. + +LLVM alias +---------- + +There is an alias of this check called llvm-else-after-return. +In that version the options :option:`WarnOnUnfixable` and +:option:`WarnOnConditionVariables` are both set to `false` by default. + +This check helps to enforce this `LLVM Coding Standards recommendation +`_. Index: clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst =================================================================== --- /dev/null +++ clang-tools-extra/docs/clang-tidy/checks/llvm-else-after-return.rst @@ -0,0 +1,11 @@ +.. title:: clang-tidy - llvm-else-after-return +.. meta:: + :http-equiv=refresh: 5;URL=readability-else-after-return.html + +llvm-else-after-return +====================== + +The llvm-else-after-return check is an alias, please see +`readability-else-after-return `_ +for more information. + Index: clang-tools-extra/docs/clang-tidy/checks/list.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/list.rst +++ clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -423,4 +423,5 @@ `hicpp-use-nullptr `_, `modernize-use-nullptr `_, "Yes" `hicpp-use-override `_, `modernize-use-override `_, "Yes" `hicpp-vararg `_, `cppcoreguidelines-pro-type-vararg `_, + `llvm-else-after-return `_, `readability-else-after-return `_, "Yes" `llvm-qualified-auto `_, `readability-qualified-auto `_, "Yes" Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -192,6 +192,11 @@ :doc:`bugprone-signed-char-misuse ` was added. +- New alias :doc:`llvm-else-after-return + ` to + :doc:`readability-else-after-return + ` was added. + Changes in existing checks ^^^^^^^^^^^^^^^^^^^^^^^^^^ Index: clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp =================================================================== --- clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp +++ clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp @@ -9,6 +9,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "../readability/ElseAfterReturnCheck.h" #include "../readability/NamespaceCommentCheck.h" #include "../readability/QualifiedAutoCheck.h" #include "HeaderGuardCheck.h" @@ -24,6 +25,8 @@ class LLVMModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + CheckFactories.registerCheck( + "llvm-else-after-return"); CheckFactories.registerCheck("llvm-header-guard"); CheckFactories.registerCheck("llvm-include-order"); CheckFactories.registerCheck( @@ -40,6 +43,9 @@ ClangTidyOptions getModuleOptions() override { ClangTidyOptions Options; Options.CheckOptions["llvm-qualified-auto.AddConstToQualified"] = "0"; + Options.CheckOptions["llvm-else-after-return.WarnOnUnfixable"] = "0"; + Options.CheckOptions["llvm-else-after-return.RefactorConditionVariables"] = + "0"; return Options; } }; -------------- next part -------------- A non-text attachment was scrubbed... Name: D82825.275608.patch Type: text/x-patch Size: 4223 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:26:59 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:26:59 +0000 (UTC) Subject: [PATCH] D83114: [clang] Fix the incorrect dependence bits for DependentExtIntType. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGcd9a241f1650: [clang] Fix the incorrect dependence bits for DependentExtIntType. (authored by hokein). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83114/new/ https://reviews.llvm.org/D83114 Files: clang/lib/AST/Type.cpp clang/test/Sema/invalid-bitwidth-expr.mm Index: clang/test/Sema/invalid-bitwidth-expr.mm =================================================================== --- clang/test/Sema/invalid-bitwidth-expr.mm +++ clang/test/Sema/invalid-bitwidth-expr.mm @@ -32,3 +32,8 @@ int X : func(); // expected-note {{in instantiation of function template}} }; constexpr int ssss = sizeof(Z); + +struct Z2 { + int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared identifier}} +}; +constexpr int sssss = sizeof(Z2); Index: clang/lib/AST/Type.cpp =================================================================== --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -347,15 +347,7 @@ DependentExtIntType::DependentExtIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) : Type(DependentExtInt, QualType{}, - ((NumBitsExpr->isValueDependent() || NumBitsExpr->isTypeDependent()) - ? TypeDependence::Dependent - : TypeDependence::None) | - (NumBitsExpr->isInstantiationDependent() - ? TypeDependence::Instantiation - : TypeDependence::None) | - (NumBitsExpr->containsUnexpandedParameterPack() - ? TypeDependence::VariablyModified - : TypeDependence::None)), + toTypeDependence(NumBitsExpr->getDependence())), Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {} bool DependentExtIntType::isUnsigned() const { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83114.275610.patch Type: text/x-patch Size: 1522 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:27:26 2020 From: cfe-commits at lists.llvm.org (Oliver Stannard (Linaro) via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:27:26 +0000 (UTC) Subject: [PATCH] D76291: [Support] Fix formatted_raw_ostream for UTF-8 In-Reply-To: References: Message-ID: <26095c9c697d5374bf02cbf8445a452f@localhost.localdomain> This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rGe80b81d1cbf8: [Support] Fix formatted_raw_ostream for UTF-8 (authored by ostannard). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76291/new/ https://reviews.llvm.org/D76291 Files: clang/test/Analysis/checker-plugins.c llvm/include/llvm/Support/FormattedStream.h llvm/lib/Support/FormattedStream.cpp llvm/test/MC/ARM/lsl-zero.s llvm/unittests/Support/formatted_raw_ostream_test.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D76291.275612.patch Type: text/x-patch Size: 13508 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:28:06 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:28:06 +0000 (UTC) Subject: [PATCH] D82425: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty function body. In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG054704082b46: [SemaCXX] Fix false positive of -Wuninitialized-const-reference in empty… (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82425/new/ https://reviews.llvm.org/D82425 Files: clang/lib/Analysis/UninitializedValues.cpp clang/test/SemaCXX/warn-uninitialized-const-reference.cpp Index: clang/test/SemaCXX/warn-uninitialized-const-reference.cpp =================================================================== --- clang/test/SemaCXX/warn-uninitialized-const-reference.cpp +++ clang/test/SemaCXX/warn-uninitialized-const-reference.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s +// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wuninitialized-const-reference -verify %s class A { public: @@ -9,6 +9,16 @@ bool operator!=(const A &); }; +template +void ignore_template(const T &) {} +void ignore(const int &i) {} +void dont_ignore_non_empty(const int &i) { ; } // Calling this won't silence the warning for you +void dont_ignore_block(const int &i) { + {} +} // Calling this won't silence the warning for you +void ignore_function_try_block_maybe_who_knows(const int &) try { +} catch (...) { +} A const_ref_use_A(const A &a); int const_ref_use(const int &i); A const_use_A(const A a); @@ -33,4 +43,13 @@ if (a < 42) m = 1; const_ref_use(m); + + int l; + ignore_template(l); // This is a pattern to avoid "unused variable" warnings (e.g. boost::ignore_unused). + ignore(l); + dont_ignore_non_empty(l); // expected-warning {{variable 'l' is uninitialized when passed as a const reference argument here}} + int l1; + dont_ignore_block(l1); // expected-warning {{variable 'l1' is uninitialized when passed as a const reference argument here}} + int l2; + ignore_function_try_block_maybe_who_knows(l2); // expected-warning {{variable 'l2' is uninitialized when passed as a const reference argument here}} } Index: clang/lib/Analysis/UninitializedValues.cpp =================================================================== --- clang/lib/Analysis/UninitializedValues.cpp +++ clang/lib/Analysis/UninitializedValues.cpp @@ -405,6 +405,15 @@ return QT->isAnyPointerType() && QT->getPointeeType().isConstQualified(); } +static bool hasTrivialBody(CallExpr *CE) { + if (FunctionDecl *FD = CE->getDirectCallee()) { + if (FunctionTemplateDecl *FTD = FD->getPrimaryTemplate()) + return FTD->getTemplatedDecl()->hasTrivialBody(); + return FD->hasTrivialBody(); + } + return false; +} + void ClassifyRefs::VisitCallExpr(CallExpr *CE) { // Classify arguments to std::move as used. if (CE->isCallToStdMove()) { @@ -413,7 +422,7 @@ classify(CE->getArg(0), Use); return; } - + bool isTrivialBody = hasTrivialBody(CE); // If a value is passed by const pointer to a function, // we should not assume that it is initialized by the call, and we // conservatively do not assume that it is used. @@ -423,7 +432,7 @@ I != E; ++I) { if ((*I)->isGLValue()) { if ((*I)->getType().isConstQualified()) - classify((*I), ConstRefUse); + classify((*I), isTrivialBody ? Ignore : ConstRefUse); } else if (isPointerToConst((*I)->getType())) { const Expr *Ex = stripCasts(DC->getParentASTContext(), *I); const auto *UO = dyn_cast(Ex); -------------- next part -------------- A non-text attachment was scrubbed... Name: D82425.275619.patch Type: text/x-patch Size: 3049 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:28:07 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:28:07 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG39d2ae0afb23: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking… (authored by kpn). Changed prior to commit: https://reviews.llvm.org/D80952?vs=272530&id=275620#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 Files: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/TargetInfo.h clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/SystemZ.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/CompilerInstance.cpp clang/test/CodeGen/aarch64-neon-misc-constrained.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c clang/test/CodeGen/arm-neon-directed-rounding-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/builtins-ppc-fpconstrained.c clang/test/CodeGen/fp-strictfp.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D80952.275620.patch Type: text/x-patch Size: 8741 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:29:07 2020 From: cfe-commits at lists.llvm.org (Wouter van Oortmerssen via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:29:07 +0000 (UTC) Subject: [PATCH] D82821: [WebAssembly] Added 64-bit memory.grow/size/init/copy/fill In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG16d83c395a1f: [WebAssembly] Added 64-bit memory.grow/size/copy/fill (authored by aardappel). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D82821?vs=275258&id=275627#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82821/new/ https://reviews.llvm.org/D82821 Files: clang/include/clang/Basic/BuiltinsWebAssembly.def clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/builtins-wasm.c llvm/include/llvm/IR/IntrinsicsWebAssembly.td llvm/lib/Target/WebAssembly/WebAssemblyInstrBulkMemory.td llvm/lib/Target/WebAssembly/WebAssemblyInstrMemory.td llvm/lib/Target/WebAssembly/WebAssemblySelectionDAGInfo.cpp llvm/test/CodeGen/WebAssembly/bulk-memory-intrinsics.ll llvm/test/CodeGen/WebAssembly/bulk-memory64.ll llvm/test/CodeGen/WebAssembly/memory-addr64.ll llvm/test/MC/WebAssembly/bulk-memory-encodings.s -------------- next part -------------- A non-text attachment was scrubbed... Name: D82821.275627.patch Type: text/x-patch Size: 22087 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:29:10 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 07:29:10 +0000 (UTC) Subject: [PATCH] D83084: DomTree: Remove the releaseMemory() method In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG723a44c9b5d6: DomTree: Remove the releaseMemory() method (authored by nhaehnle). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83084/new/ https://reviews.llvm.org/D83084 Files: clang/include/clang/Analysis/Analyses/Dominators.h llvm/include/llvm/Analysis/PostDominators.h llvm/include/llvm/IR/Dominators.h llvm/include/llvm/Support/GenericDomTree.h Index: llvm/include/llvm/Support/GenericDomTree.h =================================================================== --- llvm/include/llvm/Support/GenericDomTree.h +++ llvm/include/llvm/Support/GenericDomTree.h @@ -325,8 +325,6 @@ return false; } - void releaseMemory() { reset(); } - /// getNode - return the (Post)DominatorTree node for the specified basic /// block. This is the same as using operator[] on this class. The result /// may (but is not required to) be null for a forward (backwards) @@ -760,9 +758,6 @@ return DomTreeBuilder::Verify(*this, VL); } -protected: - void addRoot(NodeT *BB) { this->Roots.push_back(BB); } - void reset() { DomTreeNodes.clear(); Roots.clear(); @@ -772,6 +767,9 @@ SlowQueries = 0; } +protected: + void addRoot(NodeT *BB) { this->Roots.push_back(BB); } + // NewBB is split and now it has one successor. Update dominator tree to // reflect this change. template Index: llvm/include/llvm/IR/Dominators.h =================================================================== --- llvm/include/llvm/IR/Dominators.h +++ llvm/include/llvm/IR/Dominators.h @@ -277,7 +277,7 @@ AU.setPreservesAll(); } - void releaseMemory() override { DT.releaseMemory(); } + void releaseMemory() override { DT.reset(); } void print(raw_ostream &OS, const Module *M = nullptr) const override; }; Index: llvm/include/llvm/Analysis/PostDominators.h =================================================================== --- llvm/include/llvm/Analysis/PostDominators.h +++ llvm/include/llvm/Analysis/PostDominators.h @@ -88,9 +88,7 @@ AU.setPreservesAll(); } - void releaseMemory() override { - DT.releaseMemory(); - } + void releaseMemory() override { DT.reset(); } void print(raw_ostream &OS, const Module*) const override; }; Index: clang/include/clang/Analysis/Analyses/Dominators.h =================================================================== --- clang/include/clang/Analysis/Analyses/Dominators.h +++ clang/include/clang/Analysis/Analyses/Dominators.h @@ -167,9 +167,7 @@ } /// Releases the memory held by the dominator tree. - virtual void releaseMemory() { - DT.releaseMemory(); - } + virtual void releaseMemory() { DT.reset(); } /// Converts the dominator tree to human readable form. virtual void print(raw_ostream &OS, const llvm::Module* M= nullptr) const { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83084.275628.patch Type: text/x-patch Size: 2424 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:29:40 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:29:40 +0000 (UTC) Subject: [PATCH] D83183: [clang] Rework how and when APValues are dumped In-Reply-To: References: Message-ID: <91c5921237f1a6c8c66b4e1dd82e7898@localhost.localdomain> This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rGf63e3ea558bb: [clang] Rework how and when APValues are dumped (authored by riccibruno). Changed prior to commit: https://reviews.llvm.org/D83183?vs=275575&id=275633#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83183/new/ https://reviews.llvm.org/D83183 Files: clang/include/clang/AST/APValue.h clang/include/clang/AST/ASTNodeTraverser.h clang/include/clang/AST/JSONNodeDumper.h clang/include/clang/AST/TextNodeDumper.h clang/lib/AST/APValue.cpp clang/lib/AST/ASTDumper.cpp clang/lib/AST/JSONNodeDumper.cpp clang/lib/AST/TextNodeDumper.cpp clang/test/AST/alignas_maybe_odr_cleanup.cpp clang/test/AST/ast-dump-APValue-anon-union.cpp clang/test/AST/ast-dump-APValue-arithmetic.cpp clang/test/AST/ast-dump-APValue-array.cpp clang/test/AST/ast-dump-APValue-struct.cpp clang/test/AST/ast-dump-APValue-todo.cpp clang/test/AST/ast-dump-APValue-union.cpp clang/test/AST/ast-dump-APValue-vector.cpp clang/test/AST/ast-dump-attr.cpp clang/test/AST/ast-dump-color.cpp clang/test/AST/ast-dump-constant-expr.cpp clang/test/AST/ast-dump-decl.cpp clang/test/AST/ast-dump-records.cpp clang/test/AST/ast-dump-stmt.cpp clang/test/AST/pr43983.cpp clang/test/Import/switch-stmt/test.cpp clang/test/Tooling/clang-check-ast-dump.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83183.275633.patch Type: text/x-patch Size: 48723 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:31:03 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:31:03 +0000 (UTC) Subject: [PATCH] D83233: [clangd] Enable reading config from files by default. In-Reply-To: References: Message-ID: <181ccd8c4da456da24b140bb72faefd8@localhost.localdomain> hokein added inline comments. ================ Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:436 + "Project config is from a .clangd file in the project directory.\n" + "User config is from clangd/config.yaml in the following directories:\n" + "\tWindows: %USERPROFILE%\\AppData\\Local\n" ---------------- nit: maybe worth mentioning that the user config has higher privilege. ================ Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:440 + "\tOthers: $XDG_CONFIG_HOME, usually ~/.config"), + init(true), +}; ---------------- nit: I'd keep this flag off in this patch, and flip it in a new patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83233/new/ https://reviews.llvm.org/D83233 From cfe-commits at lists.llvm.org Tue Jul 7 00:31:19 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:31:19 +0000 (UTC) Subject: [PATCH] D82520: [Power10] Implement Vector Splat Immediate Builtins in LLVM/Clang In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Revision". This revision was automatically updated to reflect the committed changes. Closed by commit rG0c6b6e28e70c: [PowerPC] Implement Vector Splat Immediate Builtins in Clang (authored by biplmish, committed by lei). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D82520?vs=274748&id=275642#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82520/new/ https://reviews.llvm.org/D82520 Files: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c llvm/test/CodeGen/PowerPC/p10-splatImm.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82520.275642.patch Type: text/x-patch Size: 6056 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:31:39 2020 From: cfe-commits at lists.llvm.org (Xiang Zhang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:31:39 +0000 (UTC) Subject: [PATCH] D83111: [X86-64] Support Intel AMX Intrinsic In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG939d8309dbd4: [X86-64] Support Intel AMX Intrinsic (authored by xiangzhangllvm). Herald added a project: clang. Herald added a subscriber: cfe-commits. Changed prior to commit: https://reviews.llvm.org/D83111?vs=275537&id=275644#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83111/new/ https://reviews.llvm.org/D83111 Files: clang/docs/ClangCommandLineReference.rst clang/include/clang/Basic/BuiltinsX86_64.def clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Driver/Options.td clang/include/clang/Sema/Sema.h clang/lib/Basic/Targets/X86.cpp clang/lib/Basic/Targets/X86.h clang/lib/Headers/CMakeLists.txt clang/lib/Headers/amxintrin.h clang/lib/Headers/cpuid.h clang/lib/Headers/immintrin.h clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/AMX/amx.c clang/test/CodeGen/AMX/amx_errors.c clang/test/CodeGen/AMX/amx_inline_asm.c clang/test/Driver/x86-target-features.c clang/test/Preprocessor/x86_amx_target_features.c llvm/include/llvm/IR/IntrinsicsX86.td llvm/lib/Target/X86/X86ISelDAGToDAG.cpp llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86InstrAMX.td llvm/test/CodeGen/X86/AMX/amx-bf16-intrinsics.ll llvm/test/CodeGen/X86/AMX/amx-int8-intrinsics.ll llvm/test/CodeGen/X86/AMX/amx-tile-intrinsics.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83111.275644.patch Type: text/x-patch Size: 42384 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:32:01 2020 From: cfe-commits at lists.llvm.org (Saiyedul Islam via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:32:01 +0000 (UTC) Subject: [PATCH] D83121: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG0882c9d4fc49: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values (authored by saiislam). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83121/new/ https://reviews.llvm.org/D83121 Files: clang/include/clang/Basic/BuiltinsAMDGPU.def clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp clang/test/SemaOpenCL/builtins-amdgcn-error.cl -------------- next part -------------- A non-text attachment was scrubbed... Name: D83121.275646.patch Type: text/x-patch Size: 14878 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:40:14 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:40:14 +0000 (UTC) Subject: [PATCH] D82436: [clangd] Implement textDocument/foldingRange In-Reply-To: References: Message-ID: <1a9342b7ad61541262d33ad2b2678015@localhost.localdomain> kbobyrev updated this revision to Diff 275929. kbobyrev marked 7 inline comments as done. kbobyrev added a comment. Hide FoldingRanges feature behind the flag. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82436/new/ https://reviews.llvm.org/D82436 Files: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/ClangdServer.h clang-tools-extra/clangd/Protocol.cpp clang-tools-extra/clangd/Protocol.h clang-tools-extra/clangd/SemanticSelection.cpp clang-tools-extra/clangd/SemanticSelection.h clang-tools-extra/clangd/tool/ClangdMain.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82436.275929.patch Type: text/x-patch Size: 9868 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:45:01 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:45:01 +0000 (UTC) Subject: [PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' In-Reply-To: References: Message-ID: <6ead4440031722382c83b7c1aacf7ff1@localhost.localdomain> hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. looks good from my side. ================ Comment at: .gitignore:58 +.clangd/ +.cache # static analyzer regression testing project files ---------------- I'm afraid that many projects have to update their `.gitignore`, but this is a tradeoff... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 From cfe-commits at lists.llvm.org Tue Jul 7 00:45:17 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:45:17 +0000 (UTC) Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid SourceLocation In-Reply-To: References: Message-ID: <32320fa3c45e93245a29c7541f96e8d7@localhost.localdomain> eduucaldas updated this revision to Diff 275930. eduucaldas added a comment. `->*` and `,` are binary operators. Unit tests covering most of the operator kinds Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82954/new/ https://reviews.llvm.org/D82954 Files: clang/lib/Tooling/Syntax/BuildTree.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82954.275930.patch Type: text/x-patch Size: 10857 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 00:47:12 2020 From: cfe-commits at lists.llvm.org (Christian Kandeler via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:47:12 +0000 (UTC) Subject: [PATCH] D82629: [libclang] Fix crash when visiting a captured VLA. In-Reply-To: References: Message-ID: <32f183c1cb3b537523c1c4cb0792944c@localhost.localdomain> ckandeler added a comment. In D82629#2134521 , @jkorous wrote: > @ckandeler do you have commit access or do you want me to land the patch? I do not, so it'd be great if you could do it. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82629/new/ https://reviews.llvm.org/D82629 From cfe-commits at lists.llvm.org Tue Jul 7 00:48:46 2020 From: cfe-commits at lists.llvm.org (MyDeveloperDay via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:48:46 +0000 (UTC) Subject: [PATCH] D79773: [clang-format] Improve clang-formats handling of concepts In-Reply-To: References: Message-ID: <962ea3fe3a1c0833c140e91934cd1c33@localhost.localdomain> MyDeveloperDay added a comment. https://reviews.llvm.org/D79773#2131680 has something to do with your .clang-format file, the base LLVM style seems fine. template concept bool EqualityComparable = requires(T a, T b) { { a == b } -> bool; }; vs template concept bool EqualityComparable = requires(T a, T b) { { a == b } -> bool; }; >From what I can tell its because of the "BreakBeforeBraces: Allman or GNU" styles. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79773/new/ https://reviews.llvm.org/D79773 From cfe-commits at lists.llvm.org Tue Jul 7 00:49:24 2020 From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:49:24 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: <06e65079971aa9575df08e635ae2f57c@localhost.localdomain> logan-5 added a comment. Glad this is generating some discussion. For my $0.02, I would also (obviously) love to be able to enable this warning on all the codebases I work on, and this patch was born out of a discussion on the C++ Slack with another user who had found this warning very useful in GCC and was wondering why Clang didn't have it yet. In D82728#2134072 , @dblaikie wrote: > The issue is that such a warning then needs to be off by default, because we can't assume the user's intent. And Clang's historically been fairly averse to off-by-default warnings due to low user-penetration (not zero, like I said, I imagine LLVM itself would use such a warning, were it implemented) & so concerns about the cost/benefit tradeoff of the added complexity (source code and runtime) of the feature. I agree `-Wsuggest-override` should be off by default, yet I suspect its user-penetration will be much higher than other off-by-default warnings, due to numerous instances of people on the Internet asking for this feature , as well as the precedent for it set by GCC. Moreover, since this implementation of this warning lies along the exact same code paths as the already existing `-Winconsistent-missing-override`, the added complexity from this patch is absolutely minimal. ================ Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3075 + : diag:: + warn_inconsistent_function_marked_not_override_overriding); + else ---------------- Quuxplusone wrote: > These linebreaks are super unfortunate. Could they be improved by doing it like this? > ``` > auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) { > unsigned DiagID = isa(MD) ? DiagDtor : DiagFn; > Diag(MD->getLocation(), DiagID) << MD->getDeclName(); > const CXXMethodDecl *OMD = *MD->begin_overridden_methods(); > Diag(OMD->getLocation(), diag::note_overridden_virtual_function); > }; > if (Inconsistent) > EmitDiag(diag::warn_inconsistent_destructor_marked_not_override_overriding, > diag::warn_inconsistent_function_marked_not_override_overriding); > else > EmitDiag(diag::warn_suggest_destructor_marked_not_override_overriding > diag::warn_suggest_function_marked_not_override_overriding); > ``` Agreed. Good idea on the fix--needed one more line break (the first one still hit column 81), but it looks much better now. ================ Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:6 + ~A() {} + void virtual run() {} +}; ---------------- Quuxplusone wrote: > Surely this doesn't compile?! Because of `void virtual`? It does, surprisingly, as it does in the test for warn-inconsistent-missing-destructor-override, where I pilfered this from. Nevertheless, changed to `virtual void` for sanity's sake. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Tue Jul 7 00:56:15 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 07:56:15 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: <9c60e8e046218f3173574a9fd4e1278e@localhost.localdomain> dblaikie added a comment. In D82728#2135142 , @logan-5 wrote: > Glad this is generating some discussion. For my $0.02, I would also (obviously) love to be able to enable this warning on all the codebases I work on, and this patch was born out of a discussion on the C++ Slack with another user who had found this warning very useful in GCC and was wondering why Clang didn't have it yet. > > In D82728#2134072 , @dblaikie wrote: > > > The issue is that such a warning then needs to be off by default, because we can't assume the user's intent. And Clang's historically been fairly averse to off-by-default warnings due to low user-penetration (not zero, like I said, I imagine LLVM itself would use such a warning, were it implemented) & so concerns about the cost/benefit tradeoff of the added complexity (source code and runtime) of the feature. > > > I agree `-Wsuggest-override` should be off by default, yet I suspect its user-penetration will be much higher than other off-by-default warnings, due to numerous instances of people on the Internet asking for this feature , as well as the precedent for it set by GCC. Ah, I hadn't checked/wasn't mentioned whether GCC has this warning. If GCC already has it, there's usually an easy enough argument to be made for GCC compatibility being worthwhile that overcomes most of the objections unless the GCC warning is particularly problematic in some way that I doubt this is. Is the implementation you're proposing fairly consistent with GCC's? Run it over any big codebases to check it warns in the same places GCC does? > Moreover, since this implementation of this warning lies along the exact same code paths as the already existing `-Winconsistent-missing-override`, the added complexity from this patch is absolutely minimal. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Tue Jul 7 01:17:41 2020 From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:17:41 +0000 (UTC) Subject: [PATCH] D79842: [clang][Driver] Correct tool search path priority In-Reply-To: References: Message-ID: <4bf964c2fe2592616d4ca45518c7e438@localhost.localdomain> DavidSpickett added a comment. I saw similar behaviour on Mac OSX and fixed that in the reland. (https://reviews.llvm.org/rGd6efc9811646edbfe13f06c2676fb469f1c155b1) Are you still seeing a failure with that applied? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79842/new/ https://reviews.llvm.org/D79842 From cfe-commits at lists.llvm.org Tue Jul 7 01:19:00 2020 From: cfe-commits at lists.llvm.org (Milian Wolff via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:19:00 +0000 (UTC) Subject: [PATCH] D82740: [libclang]: check validity before visiting Stmt node In-Reply-To: References: Message-ID: <256e83273d6c4fbc49edbfafc26723b5@localhost.localdomain> milianw abandoned this revision. milianw added a comment. great, thanks for the help - please land the other change then Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82740/new/ https://reviews.llvm.org/D82740 From cfe-commits at lists.llvm.org Tue Jul 7 01:31:08 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 08:31:08 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <72f36fb77cb97d50337797fb69a86317@localhost.localdomain> gamesh411 updated this revision to Diff 275938. gamesh411 added a comment. fix detection logic fix license header add missing warning to test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 Files: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp clang/test/Analysis/sufficient-size-array-indexing-32bit.c clang/test/Analysis/sufficient-size-array-indexing-64bit.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D69318.275938.patch Type: text/x-patch Size: 21637 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 01:34:01 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:34:01 +0000 (UTC) Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid SourceLocation In-Reply-To: References: Message-ID: <724728fff0483a13a09d58c2c3810d6c@localhost.localdomain> eduucaldas updated this revision to Diff 275940. eduucaldas marked 9 inline comments as done. eduucaldas added a comment. Answering comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82954/new/ https://reviews.llvm.org/D82954 Files: clang/lib/Tooling/Syntax/BuildTree.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82954.275940.patch Type: text/x-patch Size: 10881 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 01:34:17 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:34:17 +0000 (UTC) Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid SourceLocation In-Reply-To: References: Message-ID: <77a63cbfe2deae92cf7f867acb566432@localhost.localdomain> eduucaldas added a comment. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:741 bool WalkUpFromIntegerLiteral(IntegerLiteral *S) { + if (S->getLocation().isInvalid()) + return true; ---------------- gribozavr2 wrote: > WDYT about overriding `TraverseCXXOperatorCallExpr`, so that we don't even visit the synthetic argument of the postfix unary `++`? I would prefer to not introduce blanket "if invalid then ignore" checks in the code. >>! In D82954#2125300, @eduucaldas wrote: > [[ https://godbolt.org/z/CWVEJ2 | Code that reproduces the crash ]] > Notice that when using a postfix unary operator ++ one argument is introduced to differ it from its prefix counterpart, but that argument is not used. This phantom argument shows up in the ClangAST in the form of an `IntegerLiteral` with `invalid sloc`. This invalid sloc in a valid AST node was causing the SyntaxTree generation to crash. > We can address this problems at two different levels: > 1. At the `TraverseCXXOperatorCallExpr`, by overriding it and replacing the children iteration to not iterate over this phantom argument. > 2. At the `WalkUpFromIntegerLiteral`, by skipping the visitation of the phantom node. > We preferred the latter. > 1. Cons: We would have to duplicate the implementation of RecursiveASTVisitor in BuildTree, to handle this subtle change in traversal. That would add code complexity. > 2. Cons: We are handling a problem of `CXXOperatorCallExpr` in `IntegerLiteral`. > > We chose the latter as, anyways, if an AST node has an invalid sloc, it was either a problem with parsing or the node is supposed to be ignored I've explained my reasoning in my first comment for this patch. But as it was a long time ago, I guess it got lost, even by me. I'll sketch how the Traverse solution would look like, to be able to give more concrete arguments. ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2376 + | | | `-x + | | `-IdExpression + | | `-UnqualifiedId ---------------- gribozavr2 wrote: > I'm not sure about this part where `++` is wrapped in IdExpression -- shouldn't the syntax tree look identical to a builtin postfix `++` (see another test in this file)? This comes back to a discussion we had a month ago about operators ( `+`, `!`, etc) **Question**: Should we represent operators (built-in or overloaded) in the syntax tree uniformly? If so in which way? **Context**: The ClangAST stores built-in operators as mere tokens, whereas overloaded operators are represented as a `DeclRefExpr`. That makes a lot of sense for the ClangAST, as we might refer back to the declaration of the overloaded operator, but the declaration of built-in operator doesn't exist. **Conclusion**: Have the same representation for both types of operators. I have implemented the "unboxed" representation of overloaded operators, i.e. just storing their token in the syntax tree. I have not committed that, but I can do it just after this patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82954/new/ https://reviews.llvm.org/D82954 From cfe-commits at lists.llvm.org Tue Jul 7 01:35:24 2020 From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:35:24 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <39f95cc6ae3f7926b2ffb1b2667d16d3@localhost.localdomain> hans added a comment. > I don't want to block this patch, but I do agree with Eric's point. We *really* want to focus more on the switch then invest into more LPM infra. Short term resolutions to unblock folks, with the best split possible, sure, keeping in mind they'll need to be cleaned up. Sounds good to me. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Tue Jul 7 01:35:40 2020 From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:35:40 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: hans accepted this revision. hans added a comment. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Tue Jul 7 01:35:46 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 08:35:46 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <18a0d9319de2977797edb685ad16f893@localhost.localdomain> gamesh411 marked 8 inline comments as done. gamesh411 added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:42 +BugType & +SufficientSizeArrayIndexingChecker::GetBugTypeForType(const QualType T) const { + auto BT = BugTypeCache.find(T); ---------------- NoQ wrote: > The whole point of bug types is to remain the same regardless of the specific message. They're more like a category. Please use only one bug type for the whole checker (unless you really find different categories of bugs). I have removed the whole BugType factory think, that was really stupid in retrospect. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:103 + const auto *SuperSubRegion = dyn_cast(SuperMemRegion); + // The checker has to access the extent of both the sub and the superregion. + if (!SuperSubRegion) ---------------- NoQ wrote: > This deserves comments on what kinds of regions do you expect to see here. Do i understand correctly that you expect `BaseMemRegion` to be an `ElementRegion` and its superregion to be the whole array? 'Cause the former is super unobvious and most likely //shouldn't// be that way. I feel a bit more familiar now with the infrastructure now, and I used getDynamicElementCount as it now an available utility. Thanks for the comments, they were helpful for discovering how things work! :D Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 From cfe-commits at lists.llvm.org Tue Jul 7 01:36:33 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 08:36:33 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <777e6f259bbb8fb00c123454a787dc61@localhost.localdomain> gamesh411 marked 4 inline comments as done. gamesh411 added inline comments. ================ Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:622 + } // end: "alpha.cplusplus" ---------------- NoQ wrote: > What makes this checker C++-specific? All your tests are in plain C. Very true, I have moved to `core.alpha`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 From cfe-commits at lists.llvm.org Tue Jul 7 01:36:44 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:36:44 +0000 (UTC) Subject: [PATCH] D83233: [clangd] Enable reading config from files by default. In-Reply-To: References: Message-ID: kadircet added inline comments. ================ Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:700 + ProviderStack.push_back( + config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS)); + llvm::SmallString<256> UserConfig; ---------------- should we first update the background index storage location? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83233/new/ https://reviews.llvm.org/D83233 From cfe-commits at lists.llvm.org Tue Jul 7 01:37:07 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:37:07 +0000 (UTC) Subject: [PATCH] D83233: [clangd] Enable reading config from files by default. In-Reply-To: References: Message-ID: <384c55fe57fc244ec2f425a97675351b@localhost.localdomain> kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. LG from my side Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83233/new/ https://reviews.llvm.org/D83233 From cfe-commits at lists.llvm.org Tue Jul 7 01:39:17 2020 From: cfe-commits at lists.llvm.org (David Sherwood via cfe-commits) Date: Tue, 07 Jul 2020 01:39:17 -0700 (PDT) Subject: [clang] 9a1a7d8 - [SVE] Add more warnings checks to clang and LLVM SVE tests Message-ID: <5f0434b5.1c69fb81.22fc9.7318@mx.google.com> Author: David Sherwood Date: 2020-07-07T09:33:20+01:00 New Revision: 9a1a7d888b53ebe5a934a8193de37da86e276f1e URL: https://github.com/llvm/llvm-project/commit/9a1a7d888b53ebe5a934a8193de37da86e276f1e DIFF: https://github.com/llvm/llvm-project/commit/9a1a7d888b53ebe5a934a8193de37da86e276f1e.diff LOG: [SVE] Add more warnings checks to clang and LLVM SVE tests There are now more SVE tests in LLVM and Clang that do not emit warnings related to invalid use of EVT::getVectorNumElements() and VectorType::getNumElements(). For these tests I have added additional checks that there are no warnings in order to prevent any future regressions. Differential Revision: https://reviews.llvm.org/D82943 Added: Modified: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll llvm/test/CodeGen/AArch64/sve-fcmp.ll llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll llvm/test/CodeGen/AArch64/sve-gep.ll llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll Removed: ################################################################################ diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c index 7db98086d286..d1752815bcee 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c index 89d16d955f8d..0377105a1ff0 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c index a45bf6b01710..f411cd2cf627 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c index ed6750ab2910..cbbd6ed94753 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c index e6b7b65513b3..269801c71fdc 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c index 19695759167f..56c761c77318 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c index 7512c05856a1..f49520b3e360 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c index 4fa8e656f964..cb93f1ece5fb 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c index 37cbd818de76..b19d51555956 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c index b8cbaea05de0..272af486f895 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c index 4727cb1177a7..bc9d506b5033 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c index a3b8f3c91600..5475d55564a6 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c index 5412915dcc32..d604d13356e5 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c index d174e5ee79d0..f4d8478ec83e 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint8_t test_svindex_s8(int8_t base, int8_t step) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c index c6729546606e..7a108331c940 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c index 758295fe554d..6475b19ab653 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c index 749b3d0dcd0d..3f4db7aec244 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c index 4f2d97d6a0e6..e3209fa8d924 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c index 6aa806063dd9..9219b687bd2c 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c index 0e7d62480805..1c2b48becbb9 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c index b02f28958f0b..0915a8ae4959 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c index c5841824bfc2..5c1fd27c3bbb 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c index 4595867811b2..b7892b96d0bb 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c index cffc1080d036..108980c19043 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c index 83c20e4ac510..2a267e8301c8 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c index a92ba68d9a72..6865c3ee6258 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c index ebde19c625ef..841da37bc12f 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint16_t test_svldnf1sb_s16(svbool_t pg, const int8_t *base) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c index d862954855cf..e5a1666abd60 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint32_t test_svldnf1sh_s32(svbool_t pg, const int16_t *base) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c index eac86a59a42b..addb6825aa37 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint64_t test_svldnf1sw_s64(svbool_t pg, const int32_t *base) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c index fb0abc4ed6e2..63ea57c43c55 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint16_t test_svldnf1ub_s16(svbool_t pg, const uint8_t *base) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c index 624aefd6ff27..3d70bba7f7d4 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint32_t test_svldnf1uh_s32(svbool_t pg, const uint16_t *base) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c index b1f9e5398fa0..685a563c99ff 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint64_t test_svldnf1uw_s64(svbool_t pg, const uint32_t *base) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c index eeaae1e104f7..4d023fa34b8f 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svbool_t test_svpnext_b8(svbool_t pg, svbool_t op) diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c index 496fea8a2051..98ea771ddf54 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svbool_t test_svptrue_b8() diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c index 336e00bc2ab9..f48c6c71f496 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c index 773eda97a7f9..3a9dcf0c739f 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c @@ -1,7 +1,11 @@ // REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t // CHECK-NOT: warning +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include void test_svsetffr() diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c index 0e9b61cb3c32..7e2e8e133bda 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c index 51bf31c6c744..704b8d10f715 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c index b60e083c24f3..581ea7a050d3 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c @@ -1,5 +1,10 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include svint8_t test_svundef_s8() diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c index 72c40dc9f82c..cae68a3e0a85 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c index 44598c0a84b1..a73419779a28 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c index fb35121df82c..6eea3bc17d98 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c index 204e94e3dc48..645e96c4e55f 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c index a322612653c1..6aa30f2ef59b 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c index a689c8921048..6904dbc079b7 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c index e438a6ac4d09..218f63764bec 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c index bab6ea8ed532..099d78958697 100644 --- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c +++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c @@ -1,6 +1,11 @@ +// REQUIRES: aarch64-registered-target // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -o - %s >/dev/null 2>%t +// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t +// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it. +// ASM-NOT: warning #include #ifdef SVE_OVERLOADED_FORMS diff --git a/llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll b/llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll index ca29e15697fe..caa8d32186f4 100644 --- a/llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll +++ b/llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll @@ -1,6 +1,9 @@ ; Because some arguments are passed by reference (through stack), ; the compiler should not do tail-call optimization. -; RUN: llc -mtriple=aarch64 -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64 -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; CHECK-LABEL: caller: ; CHECK: addvl sp, sp, #-[[STACKSIZE:[0-9]+]] diff --git a/llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll b/llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll index bbb8209941b0..d579ba08b59b 100644 --- a/llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll +++ b/llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -stop-after=finalize-isel < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -stop-after=finalize-isel < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; Test that z8 and z9, passed in by reference, are correctly loaded from x0 and x1. ; i.e. z0 = %z0 diff --git a/llvm/test/CodeGen/AArch64/sve-fcmp.ll b/llvm/test/CodeGen/AArch64/sve-fcmp.ll index cbafae608262..703e86d9f453 100644 --- a/llvm/test/CodeGen/AArch64/sve-fcmp.ll +++ b/llvm/test/CodeGen/AArch64/sve-fcmp.ll @@ -1,5 +1,8 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning define @oeq( %x, %x2) { ; CHECK-LABEL: oeq: diff --git a/llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll b/llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll index dffeee2df570..e9e34ada83d1 100644 --- a/llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll +++ b/llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; Verify that DAG combine rules for LD1 + sext/zext don't apply when the ; result of LD1 has multiple uses diff --git a/llvm/test/CodeGen/AArch64/sve-gep.ll b/llvm/test/CodeGen/AArch64/sve-gep.ll index 1b558a833f3b..48fc3ccb48bb 100644 --- a/llvm/test/CodeGen/AArch64/sve-gep.ll +++ b/llvm/test/CodeGen/AArch64/sve-gep.ll @@ -1,5 +1,8 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning define * @scalar_of_scalable_1(* %base) { ; CHECK-LABEL: scalar_of_scalable_1: diff --git a/llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll b/llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll index d8d44a8f5611..b721cc7b00c5 100644 --- a/llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll +++ b/llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; SMAX diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll index a86da9594a21..5637a6982c2a 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1H, LDFF1W, LDFF1D: base + 32-bit scaled offset, sign (sxtw) or zero (uxtw) diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll index 012812fb22b0..27aa5622160d 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1B, LDFF1W, LDFF1H, LDFF1D: base + 32-bit unscaled offset, sign (sxtw) or zero diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll index 4d5267356081..6cfbddf031da 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1H, LDFF1W, LDFF1D: base + 64-bit scaled offset diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll index 570bac58cc9a..9e17b470037a 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1B, LDFF1W, LDFF1H, LDFF1D: base + 64-bit unscaled offset diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll index 5cb887932eff..d591614b964c 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1B, LDFF1W, LDFF1H, LDFF1D: vector base + immediate offset (index) diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll index 4b9fba9dc275..6534f32cfbb1 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1B, LDFF1W, LDFF1H, LDFF1D: vector base + scalar offset (index) diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll index db593413f7af..b03e1a25f5bf 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1H, LD1W, LD1D: base + 32-bit scaled offset, sign (sxtw) or zero (uxtw) diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll index ba8806986d69..cf3847323734 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B, LD1W, LD1H, LD1D: base + 32-bit unscaled offset, sign (sxtw) or zero diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll index 10de34975fa0..3818c6178faa 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1H, LD1W, LD1D: base + 64-bit scaled offset diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll index fddbc24e911a..87580c92e710 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B, LD1W, LD1H, LD1D: base + 64-bit unscaled offset diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll index c7798e7f52d2..856d29aec7a4 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B, LD1W, LD1H, LD1D: vector base + immediate offset (index) diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll index 3d84c0bbfc71..f877d24111da 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B, LD1W, LD1H, LD1D: vector base + scalar offset (index) diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll index 60a9dd88da6e..18d7f3515756 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; SMAX diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll index e3fccea179e6..2aaf222504a7 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll index a47da1c004ca..e66b84a74103 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll index 69f20fa5c13e..e5d200945098 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll @@ -1,5 +1,8 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s ; RUN: llc -O0 -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1B diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll index b4ac587c0b79..1a4a25c83b34 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+f64mm,+bf16 -asm-verbose=0 < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+f64mm,+bf16 -asm-verbose=0 < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LD1ROB diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll index 96de8cc67802..e56ebcbde8e6 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; ; LDFF1B diff --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll b/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll index 27394bbbf944..31f5c6797bbc 100644 --- a/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll +++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll @@ -1,4 +1,7 @@ -; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s +; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t + +; WARN-NOT: warning ; Range testing for the immediate in the reg+imm(mulvl) addressing ; mode is done only for one instruction. The rest of the instrucions From cfe-commits at lists.llvm.org Tue Jul 7 01:39:21 2020 From: cfe-commits at lists.llvm.org (David Sherwood via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:39:21 +0000 (UTC) Subject: [PATCH] D82943: [SVE] Add more warnings checks to clang and LLVM SVE tests In-Reply-To: References: Message-ID: <73065efd3bd258576bc6b300816b4c78@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG9a1a7d888b53: [SVE] Add more warnings checks to clang and LLVM SVE tests (authored by david-arm). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82943/new/ https://reviews.llvm.org/D82943 Files: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll llvm/test/CodeGen/AArch64/sve-fcmp.ll llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll llvm/test/CodeGen/AArch64/sve-gep.ll llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82943.275941.patch Type: text/x-patch Size: 63544 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 01:40:56 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:40:56 +0000 (UTC) Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid SourceLocation In-Reply-To: References: Message-ID: eduucaldas updated this revision to Diff 275942. eduucaldas added a comment. Unifying user defined binary operator tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82954/new/ https://reviews.llvm.org/D82954 Files: clang/lib/Tooling/Syntax/BuildTree.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82954.275942.patch Type: text/x-patch Size: 10228 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 01:41:06 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 08:41:06 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <2dd658ff06f215495c8f028fe35cace1@localhost.localdomain> gamesh411 added a comment. The checker has been updated, the comments and the logic polished. I would still take a stab at this being a ClangSa checker (as opposed to being a Tidy check). What do you think? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 From cfe-commits at lists.llvm.org Tue Jul 7 01:42:29 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:42:29 +0000 (UTC) Subject: [PATCH] D83218: Hand Allocator and IdentifierTable into FormatTokenLexer. In-Reply-To: References: Message-ID: <609cb4d25baefb381adcd120281c3cb1@localhost.localdomain> sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang/lib/Format/FormatTokenLexer.h:121 llvm::Regex MacroBlockEndRegex; + llvm::SpecificBumpPtrAllocator &Allocator; ---------------- this seems a little odd, like it fit better where it was, up to you. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83218/new/ https://reviews.llvm.org/D83218 From cfe-commits at lists.llvm.org Tue Jul 7 01:42:58 2020 From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:42:58 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <53ed24925af01a010eae2af70f770ab9@localhost.localdomain> nikic requested changes to this revision. nikic added inline comments. This revision now requires changes to proceed. ================ Comment at: llvm/test/Other/opt-O2-pipeline.ll:289 +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ---------------- Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use? PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Tue Jul 7 01:53:53 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:53:53 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: <189a73d1e1425d7dba1070c8a6a6d78b@localhost.localdomain> kbobyrev updated this revision to Diff 275945. kbobyrev added a comment. Don't convert test paths to system native, UNIX native is good enough. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.275945.patch Type: text/x-patch Size: 25535 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 01:59:03 2020 From: cfe-commits at lists.llvm.org (David Sherwood via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 08:59:03 +0000 (UTC) Subject: [PATCH] D82943: [SVE] Add more warnings checks to clang and LLVM SVE tests In-Reply-To: References: Message-ID: This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG9a1a7d888b53: [SVE] Add more warnings checks to clang and LLVM SVE tests (authored by david-arm). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82943/new/ https://reviews.llvm.org/D82943 Files: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpeq.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpge.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpgt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmple.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmplt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpne.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmpuo.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_index.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldff1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sb.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1sw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1ub.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uh.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ldnf1uw.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pnext.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ptrue.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rev.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_setffr.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_trn2.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_undef.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpkhi.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_unpklo.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_uzp2.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilele.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_whilelt.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip1.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_zip2.c llvm/test/CodeGen/AArch64/sve-callbyref-notailcall.ll llvm/test/CodeGen/AArch64/sve-calling-convention-byref.ll llvm/test/CodeGen/AArch64/sve-fcmp.ll llvm/test/CodeGen/AArch64/sve-gather-scatter-dag-combine.ll llvm/test/CodeGen/AArch64/sve-gep.ll llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-scaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-32bit-unscaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-scaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-64bit-unscaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-imm-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ff-gather-loads-vector-base-scalar-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-scaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-32bit-unscaled-offsets.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-scaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-64bit-unscaled-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-imm-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-gather-loads-vector-base-scalar-offset.ll llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-imm.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1-addressing-mode-reg-reg.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll llvm/test/CodeGen/AArch64/sve-intrinsics-ld1ro-addressing-mode-reg-reg.ll llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82943.275650.patch Type: text/x-patch Size: 63544 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:07:56 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:07:56 +0000 (UTC) Subject: [PATCH] D82436: [clangd] Implement textDocument/foldingRange In-Reply-To: References: Message-ID: <49942de4e445afa7ddc7e990c26d32e6@localhost.localdomain> kbobyrev added inline comments. ================ Comment at: clang-tools-extra/clangd/FindSymbols.cpp:281 + Range.startCharacter = Symbol.range.start.character; + Range.endLine = Symbol.range.end.line; + Range.endCharacter = Symbol.range.end.character; ---------------- sammccall wrote: > kbobyrev wrote: > > sammccall wrote: > > > How useful are folding ranges when symbols start/end on the same line? Do we really want to emit them? > > I think they are useful from the LSP perspective, if characters didn't matter in the ranges they wouldn't be included in the protocol at all and there wouldn't be any way for clients to specify their preferences. > > > > I don't think it's a common use case, but I do think it's a totally valid one. Maybe those should be the first candidates for excluding when there is a limit and maybe we could completely cut them for performance. But from the LSP perspective it seems logical to have those. > > > > What do you think? > Well, I don't think "the protocol allows regions within a line, therefore we must emit them" is a great argument. You mention a valid use case, but you haven't *described* any use cases - what specific C++ intra-line region is the user likely to fold in a way that's useful? > > I think that it's hard to point to concrete benefits, but the costs are clear enough: > - responses will be (much) bigger, which we know some clients don't deal well with > - clients are not likely to do any smart filtering, so I think this will lead to performance/ux problems in practice (especially if most implementations only support folding blocks etc) > - it makes decisions on what folding regions to emit harder, e.g. should we fold function calls, not fold them, or fold them only if start/end are on different lines? > - we need two different modes, to handle clients that support line-folds vs clients that support char-folds. (If we only emit multi-line folds we could also only emit the inner (or the outer) fold for a pair of lines, and the result would be suitable for both types of editors) > > > when there is a limit > It's pretty important that this feature behaves consistently, for it to be useful. If we're going to only-sometimes enable folding of certain constructs, it better be for a reason that's pretty obvious to the user (I believe single vs multiline qualifies, but "the document complexity exceeds X" certainly doesn't.) For this reason I don't think we should implement that capabilities feature (or should do it in some totally naive and unobtrusive way, like truncation) As discussed online, we should emit single-line ranges. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82436/new/ https://reviews.llvm.org/D82436 From cfe-commits at lists.llvm.org Tue Jul 7 02:08:24 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:08:24 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: <14718124c67c9c4645e7a8eae9b96aec@localhost.localdomain> vsavchenko updated this revision to Diff 275949. vsavchenko added a comment. Fix comments and add a test for downcasts Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 Files: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp clang/test/Analysis/equality_tracking.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D82445.275949.patch Type: text/x-patch Size: 44018 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:08:40 2020 From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:08:40 +0000 (UTC) Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failure In-Reply-To: References: Message-ID: <3e6503ead6f2801c87becae85d9b5465@localhost.localdomain> DavidSpickett updated this revision to Diff 275950. DavidSpickett added a comment. - Removed \ from regex, not needed for POSIX syntax. - Reflowed text in commit description. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83055/new/ https://reviews.llvm.org/D83055 Files: clang/test/Driver/program-path-priority.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83055.275950.patch Type: text/x-patch Size: 6084 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:13:34 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:13:34 +0000 (UTC) Subject: [PATCH] D83286: [analyzer][solver] Track symbol disequalities Message-ID: vsavchenko created this revision. vsavchenko added reviewers: NoQ, dcoughlin, ASDenysPetrov, xazax.hun, Szelethus. Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware. Herald added a project: clang. This commmit adds another relation that we can track separately from range constraints. Symbol disequality can help us understand that two equivalence classes are not equal to each other. We can generalize this knowledge to classes because for every a,b,c, and d that a == b, c == d, and b != c it is true that a != d. As a result, we can reason about other equalities/disequalities of symbols that we know nothing else about, i.e. no constraint ranges associated with them. However, we also benefit from the knowledge of disequal symbols by following the rule: if a != b and b == C where C is a constant, a != C This information can refine associated ranges for different classes and reduce the number of false positives and paths to explore. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83286 Files: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp clang/test/Analysis/equality_tracking.c clang/test/Analysis/mutually_exclusive_null_fp.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83286.275952.patch Type: text/x-patch Size: 24561 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:16:27 2020 From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:16:27 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: hans added inline comments. ================ Comment at: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp:170 PassManagerBuilder::PassManagerBuilder() { OptLevel = 2; ---------------- Oh, just noticed: I think CallGraphProfile should be initialized along with the other flags here. ================ Comment at: llvm/test/Other/opt-O2-pipeline.ll:289 +; CHECK-NEXT: Branch Probability Analysis +; CHECK-NEXT: Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ---------------- nikic wrote: > Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use? > > PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided. I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway. I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Tue Jul 7 02:20:34 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 09:20:34 +0000 (UTC) Subject: [PATCH] D83190: [analyzer] Model iterator random incrementation symmetrically In-Reply-To: References: Message-ID: gamesh411 updated this revision to Diff 275954. gamesh411 added a comment. fix tidy diagnostic Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83190/new/ https://reviews.llvm.org/D83190 Files: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp clang/test/Analysis/iterator-modeling.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83190.275954.patch Type: text/x-patch Size: 9073 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:20:43 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:20:43 +0000 (UTC) Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver infra In-Reply-To: References: Message-ID: vsavchenko updated this revision to Diff 275955. vsavchenko added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82381/new/ https://reviews.llvm.org/D82381 Files: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82381.275955.patch Type: text/x-patch Size: 15865 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:22:04 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:22:04 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: <56630943dfbb38fd6151bc5d90951377@localhost.localdomain> vsavchenko updated this revision to Diff 275956. vsavchenko added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 Files: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp clang/test/Analysis/equality_tracking.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D82445.275956.patch Type: text/x-patch Size: 44001 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:22:30 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:22:30 +0000 (UTC) Subject: [PATCH] D83286: [analyzer][solver] Track symbol disequalities In-Reply-To: References: Message-ID: <2d5879383c98d67a56ccc816032fc161@localhost.localdomain> vsavchenko updated this revision to Diff 275957. vsavchenko added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83286/new/ https://reviews.llvm.org/D83286 Files: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp clang/test/Analysis/equality_tracking.c clang/test/Analysis/mutually_exclusive_null_fp.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83286.275957.patch Type: text/x-patch Size: 24561 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:24:46 2020 From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:24:46 +0000 (UTC) Subject: [PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v9.2.0 In-Reply-To: References: Message-ID: atrosinenko marked 3 inline comments as done. atrosinenko added inline comments. ================ Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:154 + SmallString<128> MultilibInclude(GCCInstallation.getInstallPath()); + llvm::sys::path::append(MultilibInclude, "include"); ---------------- krisb wrote: > I'd guard this by `if (GCCInstallation.isValid())` to avoid adding include directories with relative paths if `GCCInstallation.getInstallPath()` is empty. Fixed. ================ Comment at: clang/lib/Driver/ToolChains/MSP430.cpp:239 + Arg *SspFlag = Args.getLastArg( + options::OPT_fno_stack_protector, options::OPT_fstack_protector, + options::OPT_fstack_protector_all, options::OPT_fstack_protector_strong); ---------------- krisb wrote: > Is the check for `fno-stack-protector` necessary here? Looks as the checks for 'positive' options should be enough to do the trick. While the "negative" option is not mentioned at all by the specs: ``` $ msp430-elf-gcc -dumpspecs | grep stack-protector %{fstack-protector|fstack-protector-all|fstack-protector-strong|fstack-protector-explicit:-lssp_nonshared -lssp} ``` it seems these options are already basically preprocessed by gcc driver: ``` $ msp430-elf-gcc -### empty.o 2>&1 | grep -Eo " -l[a-z_0-9]*" | tr "\n" " " -lgcc -lmul_none -lc -lgcc -lcrt -lnosys -lgcc -lgcc $ msp430-elf-gcc -### empty.o -fstack-protector 2>&1 | grep -Eo " -l[a-z_0-9]*" | tr "\n" " " -lssp_nonshared -lssp -lgcc -lmul_none -lc -lgcc -lcrt -lnosys -lgcc -lgcc $ msp430-elf-gcc -### empty.o -fstack-protector -fno-stack-protector 2>&1 | grep -Eo " -l[a-z_0-9]*" | tr "\n" " " -lgcc -lmul_none -lc -lgcc -lcrt -lnosys -lgcc -lgcc ``` and they seem to have the usual semantics of "the last one takes effect". ================ Comment at: clang/test/Driver/msp430-toolchain.c:5 + +// Test for include paths (cannot use -###) + ---------------- krisb wrote: > This way looks okay to me, but I believe you should be able to check cc1 command (though -###) for `-internal-isystem`, right? It works, thank you! Will wait for unit test results on Windows. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81676/new/ https://reviews.llvm.org/D81676 From cfe-commits at lists.llvm.org Tue Jul 7 02:25:57 2020 From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:25:57 +0000 (UTC) Subject: [PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v9.2.0 In-Reply-To: References: Message-ID: atrosinenko updated this revision to Diff 275959. atrosinenko added a comment. Address the review comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81676/new/ https://reviews.llvm.org/D81676 Files: clang/include/clang/Driver/Options.td clang/lib/Basic/Targets/MSP430.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/MSP430.cpp clang/lib/Driver/ToolChains/MSP430.h clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include-fixed/limits.h clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include/stddef.h clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/include/stdio.h clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o clang/test/Driver/msp430-toolchain.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D81676.275959.patch Type: text/x-patch Size: 32346 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:30:45 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:30:45 +0000 (UTC) Subject: [PATCH] D80202: [ASTMatchers] Performance optimization for memoization In-Reply-To: References: Message-ID: sammccall added inline comments. ================ Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:902 // Maps (matcher, node) -> the match result for memoization. - typedef std::map MemoizationMap; + typedef std::map> MemoizationMap; MemoizationMap ResultCache; ---------------- klimek wrote: > Ok, if this actually matters, we should also not use a std::map here, but a llvm::DenseMap (or do we rely on iteration invalidation semantics here?). Belated +1. 5% seems like this performance *does* matter, so DenseMap::find_as should be yet faster. It looks like BoundNodesTreeBuilder would need a DenseMapInfo, but all the other members are hashable already. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80202/new/ https://reviews.llvm.org/D80202 From cfe-commits at lists.llvm.org Tue Jul 7 02:31:12 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?G=C3=A1bor_Horv=C3=A1th_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 09:31:12 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: <63c615eda2c61f57e12ae703e61fcbef@localhost.localdomain> xazax.hun added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:506 + APSIntType Type(Int); + return Int == Type.getZeroValue(); +} ---------------- Does the semantics if this differ from ` llvm::APInt::isNullValue`? ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1254 + // sufficient. + return S1->get() == S2->get() && + S1->get() == S2->get(); ---------------- Sorry, but I am a bit confused here. Does `haveEqualConstraints` have anything to do with equivalence classes? I.e., what if I have two symbols with the same constraints (but those two symbols were never compared). ``` void f(int a, int b) { int c = clamp(a, 5, 10); int d = clamp(b, 5, 10); } ``` In the code above if analyzer understands clamp, the range for `c` and `d` will be the same. Even though we never really compared them. I would expect `haveEqualConstraints` to return true, even if they do not belong to the same equivalence class. Do I miss something? ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1380 +ConstraintMap ento::getConstraintMap(ProgramStateRef State) { + ConstraintMap::Factory &F = State->get_context(); ---------------- So we basically do a conversion to Symbol -> Ranges from Class -> Ranges. I wonder if it is possible to get rid of this conversion in the future to get some performance benefits. We could either make all code work with both kind of range maps or have something like (Symbol + Class) -> Ranges to avoid conversion. What do you think? I am not opposed to this code at the moment, I just wonder if there is a relatively low hanging fruit for some performance gains in the future. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 From cfe-commits at lists.llvm.org Tue Jul 7 02:37:12 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?G=C3=A1bor_Horv=C3=A1th_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 09:37:12 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: xazax.hun added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1254 + // sufficient. + return S1->get() == S2->get() && + S1->get() == S2->get(); ---------------- xazax.hun wrote: > Sorry, but I am a bit confused here. > > Does `haveEqualConstraints` have anything to do with equivalence classes? > > I.e., what if I have two symbols with the same constraints (but those two symbols were never compared). > ``` > void f(int a, int b) { > int c = clamp(a, 5, 10); > int d = clamp(b, 5, 10); > } > ``` > > In the code above if analyzer understands clamp, the range for `c` and `d` will be the same. Even though we never really compared them. > I would expect `haveEqualConstraints` to return true, even if they do not belong to the same equivalence class. > > Do I miss something? Never mind, I misunderstood this function. It operates on program states not on symbols. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 From cfe-commits at lists.llvm.org Tue Jul 7 02:42:50 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:42:50 +0000 (UTC) Subject: [PATCH] D83212: [Fixed Point] Add fixed-point shift operations and consteval. In-Reply-To: References: Message-ID: ebevhan updated this revision to Diff 275962. ebevhan added a comment. Fix test. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83212/new/ https://reviews.llvm.org/D83212 Files: clang/include/clang/Basic/FixedPoint.h clang/lib/AST/ExprConstant.cpp clang/lib/Basic/FixedPoint.cpp clang/lib/Sema/SemaExpr.cpp clang/test/Frontend/fixed_point_errors.c clang/test/Frontend/fixed_point_shift.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83212.275962.patch Type: text/x-patch Size: 11297 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:52:59 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:52:59 +0000 (UTC) Subject: [PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of RecoveryExpr. In-Reply-To: References: Message-ID: <49653dd8c2c831ee43e6b659f23c9c9e@localhost.localdomain> sammccall added inline comments. ================ Comment at: clang/include/clang/AST/Expr.h:6229 +/// +/// FIXME: RecoveryExpr is C++ only, make it work for C by supporting dependence +/// mechanism for C language in clang. ---------------- this could be a little more specific (e.g. what does C++ only mean)... FIXME: RecoveryExpr is currently generated by default in C++ mode only, as dependence isn't handled properly on several C-only codepaths. ================ Comment at: clang/lib/AST/ComputeDependence.cpp:498 ExprDependence clang::computeDependence(RecoveryExpr *E) { - // Mark the expression as value- and instantiation- dependent to reuse - // existing suppressions for dependent code, e.g. avoiding - // constant-evaluation. - // FIXME: drop type+value+instantiation once Error is sufficient to suppress - // bogus dianostics. + // RecoveryExpr dependence-bits setting: + // - type-dep is set if we don't know about the type (fallback to an opaque ---------------- I can't really follow this explanation. - The first bullet says when, the other two bullets say why - the reasons given don't seem to be very principled ones (e.g. suppressing constant-evaluation is indeed a nice effect of value-dependency, but I don't think it's the *reason* for the value-dependency, rather that the value depends on how the error is resolved) - I don't understand the connection between the "setting" list and the "explanations" one. ================ Comment at: clang/lib/AST/ComputeDependence.cpp:499 + // RecoveryExpr dependence-bits setting: + // - type-dep is set if we don't know about the type (fallback to an opaque + // dependent type); ---------------- , or if the type is known and dependent Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83215/new/ https://reviews.llvm.org/D83215 From cfe-commits at lists.llvm.org Tue Jul 7 02:53:19 2020 From: cfe-commits at lists.llvm.org (Manuel Klimek via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:53:19 +0000 (UTC) Subject: [PATCH] D83218: Hand Allocator and IdentifierTable into FormatTokenLexer. In-Reply-To: References: Message-ID: <83a230165c5b29e41dc6581d1cf720a2@localhost.localdomain> klimek updated this revision to Diff 275964. klimek added a comment. Address review comment. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83218/new/ https://reviews.llvm.org/D83218 Files: clang/lib/Format/FormatTokenLexer.cpp clang/lib/Format/FormatTokenLexer.h clang/lib/Format/TokenAnalyzer.cpp Index: clang/lib/Format/TokenAnalyzer.cpp =================================================================== --- clang/lib/Format/TokenAnalyzer.cpp +++ clang/lib/Format/TokenAnalyzer.cpp @@ -64,11 +64,16 @@ std::pair TokenAnalyzer::process() { tooling::Replacements Result; - FormatTokenLexer Tokens(Env.getSourceManager(), Env.getFileID(), - Env.getFirstStartColumn(), Style, Encoding); + llvm::SpecificBumpPtrAllocator Allocator; + IdentifierTable IdentTable(getFormattingLangOpts(Style)); + FormatTokenLexer Lex(Env.getSourceManager(), Env.getFileID(), + Env.getFirstStartColumn(), Style, Encoding, Allocator, - UnwrappedLineParser Parser(Style, Tokens.getKeywords(), - Env.getFirstStartColumn(), Tokens.lex(), *this); + IdentTable); + ArrayRef Toks(Lex.lex()); + SmallVector Tokens(Toks.begin(), Toks.end()); + UnwrappedLineParser Parser(Style, Lex.getKeywords(), + Env.getFirstStartColumn(), Tokens, *this); Parser.parse(); assert(UnwrappedLines.rbegin()->empty()); unsigned Penalty = 0; @@ -76,14 +81,14 @@ LLVM_DEBUG(llvm::dbgs() << "Run " << Run << "...\n"); SmallVector AnnotatedLines; - TokenAnnotator Annotator(Style, Tokens.getKeywords()); + TokenAnnotator Annotator(Style, Lex.getKeywords()); for (unsigned i = 0, e = UnwrappedLines[Run].size(); i != e; ++i) { AnnotatedLines.push_back(new AnnotatedLine(UnwrappedLines[Run][i])); Annotator.annotate(*AnnotatedLines.back()); } std::pair RunResult = - analyze(Annotator, AnnotatedLines, Tokens); + analyze(Annotator, AnnotatedLines, Lex); LLVM_DEBUG({ llvm::dbgs() << "Replacements for run " << Run << ":\n"; Index: clang/lib/Format/FormatTokenLexer.h =================================================================== --- clang/lib/Format/FormatTokenLexer.h +++ clang/lib/Format/FormatTokenLexer.h @@ -38,7 +38,9 @@ class FormatTokenLexer { public: FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, unsigned Column, - const FormatStyle &Style, encoding::Encoding Encoding); + const FormatStyle &Style, encoding::Encoding Encoding, + llvm::SpecificBumpPtrAllocator &Allocator, + IdentifierTable &IdentTable); ArrayRef lex(); @@ -103,10 +105,10 @@ const SourceManager &SourceMgr; FileID ID; const FormatStyle &Style; - IdentifierTable IdentTable; + IdentifierTable &IdentTable; AdditionalKeywords Keywords; encoding::Encoding Encoding; - llvm::SpecificBumpPtrAllocator Allocator; + llvm::SpecificBumpPtrAllocator &Allocator; // Index (in 'Tokens') of the last token that starts a new line. unsigned FirstInLineIndex; SmallVector Tokens; Index: clang/lib/Format/FormatTokenLexer.cpp =================================================================== --- clang/lib/Format/FormatTokenLexer.cpp +++ clang/lib/Format/FormatTokenLexer.cpp @@ -22,13 +22,15 @@ namespace clang { namespace format { -FormatTokenLexer::FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, - unsigned Column, const FormatStyle &Style, - encoding::Encoding Encoding) +FormatTokenLexer::FormatTokenLexer( + const SourceManager &SourceMgr, FileID ID, unsigned Column, + const FormatStyle &Style, encoding::Encoding Encoding, + llvm::SpecificBumpPtrAllocator &Allocator, + IdentifierTable &IdentTable) : FormatTok(nullptr), IsFirstToken(true), StateStack({LexerState::NORMAL}), Column(Column), TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID), - Style(Style), IdentTable(getFormattingLangOpts(Style)), - Keywords(IdentTable), Encoding(Encoding), FirstInLineIndex(0), + Style(Style), IdentTable(IdentTable), Keywords(IdentTable), + Encoding(Encoding), Allocator(Allocator), FirstInLineIndex(0), FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin), MacroBlockEndRegex(Style.MacroBlockEnd) { Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83218.275964.patch Type: text/x-patch Size: 4411 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 02:59:40 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 09:59:40 +0000 (UTC) Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for recovery expr. In-Reply-To: References: Message-ID: sammccall added inline comments. ================ Comment at: clang/lib/Sema/SemaOverload.cpp:12944 + Fn->getBeginLoc(), RParenLoc, SubExprs, + ReturnType.isNull() + ? ReturnType ---------------- here we're splitting the type (e.g. int&&) into a type + VK, and passing both to createrecoveryexpr. Why not do that on recoveryexpr side? e.g. if we request a recoveryexpr of type int&, return an LValue recoveryexpr of type int? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83201/new/ https://reviews.llvm.org/D83201 From cfe-commits at lists.llvm.org Tue Jul 7 03:00:37 2020 From: cfe-commits at lists.llvm.org (Manuel Klimek via cfe-commits) Date: Tue, 07 Jul 2020 03:00:37 -0700 (PDT) Subject: [clang] 8c2a613 - Hand Allocator and IdentifierTable into FormatTokenLexer. Message-ID: <5f0447c5.1c69fb81.c6a54.5b74@mx.google.com> Author: Manuel Klimek Date: 2020-07-07T11:56:34+02:00 New Revision: 8c2a613976075368a1f6e3ac3c9c8b1927b465ec URL: https://github.com/llvm/llvm-project/commit/8c2a613976075368a1f6e3ac3c9c8b1927b465ec DIFF: https://github.com/llvm/llvm-project/commit/8c2a613976075368a1f6e3ac3c9c8b1927b465ec.diff LOG: Hand Allocator and IdentifierTable into FormatTokenLexer. This allows us to share the allocator in the future so we can create tokens while parsing. Differential Revision: https://reviews.llvm.org/D83218 Added: Modified: clang/lib/Format/FormatTokenLexer.cpp clang/lib/Format/FormatTokenLexer.h clang/lib/Format/TokenAnalyzer.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp index dbbe6f814ace..1fd153d1112e 100644 --- a/clang/lib/Format/FormatTokenLexer.cpp +++ b/clang/lib/Format/FormatTokenLexer.cpp @@ -22,13 +22,15 @@ namespace clang { namespace format { -FormatTokenLexer::FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, - unsigned Column, const FormatStyle &Style, - encoding::Encoding Encoding) +FormatTokenLexer::FormatTokenLexer( + const SourceManager &SourceMgr, FileID ID, unsigned Column, + const FormatStyle &Style, encoding::Encoding Encoding, + llvm::SpecificBumpPtrAllocator &Allocator, + IdentifierTable &IdentTable) : FormatTok(nullptr), IsFirstToken(true), StateStack({LexerState::NORMAL}), Column(Column), TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID), - Style(Style), IdentTable(getFormattingLangOpts(Style)), - Keywords(IdentTable), Encoding(Encoding), FirstInLineIndex(0), + Style(Style), IdentTable(IdentTable), Keywords(IdentTable), + Encoding(Encoding), Allocator(Allocator), FirstInLineIndex(0), FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin), MacroBlockEndRegex(Style.MacroBlockEnd) { Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr, diff --git a/clang/lib/Format/FormatTokenLexer.h b/clang/lib/Format/FormatTokenLexer.h index 219cd46f98ed..6b08677e3369 100644 --- a/clang/lib/Format/FormatTokenLexer.h +++ b/clang/lib/Format/FormatTokenLexer.h @@ -38,7 +38,9 @@ enum LexerState { class FormatTokenLexer { public: FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, unsigned Column, - const FormatStyle &Style, encoding::Encoding Encoding); + const FormatStyle &Style, encoding::Encoding Encoding, + llvm::SpecificBumpPtrAllocator &Allocator, + IdentifierTable &IdentTable); ArrayRef lex(); @@ -103,10 +105,10 @@ class FormatTokenLexer { const SourceManager &SourceMgr; FileID ID; const FormatStyle &Style; - IdentifierTable IdentTable; + IdentifierTable &IdentTable; AdditionalKeywords Keywords; encoding::Encoding Encoding; - llvm::SpecificBumpPtrAllocator Allocator; + llvm::SpecificBumpPtrAllocator &Allocator; // Index (in 'Tokens') of the last token that starts a new line. unsigned FirstInLineIndex; SmallVector Tokens; diff --git a/clang/lib/Format/TokenAnalyzer.cpp b/clang/lib/Format/TokenAnalyzer.cpp index eb98a205d526..f1459a808ff8 100644 --- a/clang/lib/Format/TokenAnalyzer.cpp +++ b/clang/lib/Format/TokenAnalyzer.cpp @@ -64,11 +64,16 @@ TokenAnalyzer::TokenAnalyzer(const Environment &Env, const FormatStyle &Style) std::pair TokenAnalyzer::process() { tooling::Replacements Result; - FormatTokenLexer Tokens(Env.getSourceManager(), Env.getFileID(), - Env.getFirstStartColumn(), Style, Encoding); + llvm::SpecificBumpPtrAllocator Allocator; + IdentifierTable IdentTable(getFormattingLangOpts(Style)); + FormatTokenLexer Lex(Env.getSourceManager(), Env.getFileID(), + Env.getFirstStartColumn(), Style, Encoding, Allocator, - UnwrappedLineParser Parser(Style, Tokens.getKeywords(), - Env.getFirstStartColumn(), Tokens.lex(), *this); + IdentTable); + ArrayRef Toks(Lex.lex()); + SmallVector Tokens(Toks.begin(), Toks.end()); + UnwrappedLineParser Parser(Style, Lex.getKeywords(), + Env.getFirstStartColumn(), Tokens, *this); Parser.parse(); assert(UnwrappedLines.rbegin()->empty()); unsigned Penalty = 0; @@ -76,14 +81,14 @@ std::pair TokenAnalyzer::process() { LLVM_DEBUG(llvm::dbgs() << "Run " << Run << "...\n"); SmallVector AnnotatedLines; - TokenAnnotator Annotator(Style, Tokens.getKeywords()); + TokenAnnotator Annotator(Style, Lex.getKeywords()); for (unsigned i = 0, e = UnwrappedLines[Run].size(); i != e; ++i) { AnnotatedLines.push_back(new AnnotatedLine(UnwrappedLines[Run][i])); Annotator.annotate(*AnnotatedLines.back()); } std::pair RunResult = - analyze(Annotator, AnnotatedLines, Tokens); + analyze(Annotator, AnnotatedLines, Lex); LLVM_DEBUG({ llvm::dbgs() << "Replacements for run " << Run << ":\n"; From cfe-commits at lists.llvm.org Tue Jul 7 03:00:52 2020 From: cfe-commits at lists.llvm.org (Manuel Klimek via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 10:00:52 +0000 (UTC) Subject: [PATCH] D83218: Hand Allocator and IdentifierTable into FormatTokenLexer. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG8c2a61397607: Hand Allocator and IdentifierTable into FormatTokenLexer. (authored by klimek). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83218/new/ https://reviews.llvm.org/D83218 Files: clang/lib/Format/FormatTokenLexer.cpp clang/lib/Format/FormatTokenLexer.h clang/lib/Format/TokenAnalyzer.cpp Index: clang/lib/Format/TokenAnalyzer.cpp =================================================================== --- clang/lib/Format/TokenAnalyzer.cpp +++ clang/lib/Format/TokenAnalyzer.cpp @@ -64,11 +64,16 @@ std::pair TokenAnalyzer::process() { tooling::Replacements Result; - FormatTokenLexer Tokens(Env.getSourceManager(), Env.getFileID(), - Env.getFirstStartColumn(), Style, Encoding); + llvm::SpecificBumpPtrAllocator Allocator; + IdentifierTable IdentTable(getFormattingLangOpts(Style)); + FormatTokenLexer Lex(Env.getSourceManager(), Env.getFileID(), + Env.getFirstStartColumn(), Style, Encoding, Allocator, - UnwrappedLineParser Parser(Style, Tokens.getKeywords(), - Env.getFirstStartColumn(), Tokens.lex(), *this); + IdentTable); + ArrayRef Toks(Lex.lex()); + SmallVector Tokens(Toks.begin(), Toks.end()); + UnwrappedLineParser Parser(Style, Lex.getKeywords(), + Env.getFirstStartColumn(), Tokens, *this); Parser.parse(); assert(UnwrappedLines.rbegin()->empty()); unsigned Penalty = 0; @@ -76,14 +81,14 @@ LLVM_DEBUG(llvm::dbgs() << "Run " << Run << "...\n"); SmallVector AnnotatedLines; - TokenAnnotator Annotator(Style, Tokens.getKeywords()); + TokenAnnotator Annotator(Style, Lex.getKeywords()); for (unsigned i = 0, e = UnwrappedLines[Run].size(); i != e; ++i) { AnnotatedLines.push_back(new AnnotatedLine(UnwrappedLines[Run][i])); Annotator.annotate(*AnnotatedLines.back()); } std::pair RunResult = - analyze(Annotator, AnnotatedLines, Tokens); + analyze(Annotator, AnnotatedLines, Lex); LLVM_DEBUG({ llvm::dbgs() << "Replacements for run " << Run << ":\n"; Index: clang/lib/Format/FormatTokenLexer.h =================================================================== --- clang/lib/Format/FormatTokenLexer.h +++ clang/lib/Format/FormatTokenLexer.h @@ -38,7 +38,9 @@ class FormatTokenLexer { public: FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, unsigned Column, - const FormatStyle &Style, encoding::Encoding Encoding); + const FormatStyle &Style, encoding::Encoding Encoding, + llvm::SpecificBumpPtrAllocator &Allocator, + IdentifierTable &IdentTable); ArrayRef lex(); @@ -103,10 +105,10 @@ const SourceManager &SourceMgr; FileID ID; const FormatStyle &Style; - IdentifierTable IdentTable; + IdentifierTable &IdentTable; AdditionalKeywords Keywords; encoding::Encoding Encoding; - llvm::SpecificBumpPtrAllocator Allocator; + llvm::SpecificBumpPtrAllocator &Allocator; // Index (in 'Tokens') of the last token that starts a new line. unsigned FirstInLineIndex; SmallVector Tokens; Index: clang/lib/Format/FormatTokenLexer.cpp =================================================================== --- clang/lib/Format/FormatTokenLexer.cpp +++ clang/lib/Format/FormatTokenLexer.cpp @@ -22,13 +22,15 @@ namespace clang { namespace format { -FormatTokenLexer::FormatTokenLexer(const SourceManager &SourceMgr, FileID ID, - unsigned Column, const FormatStyle &Style, - encoding::Encoding Encoding) +FormatTokenLexer::FormatTokenLexer( + const SourceManager &SourceMgr, FileID ID, unsigned Column, + const FormatStyle &Style, encoding::Encoding Encoding, + llvm::SpecificBumpPtrAllocator &Allocator, + IdentifierTable &IdentTable) : FormatTok(nullptr), IsFirstToken(true), StateStack({LexerState::NORMAL}), Column(Column), TrailingWhitespace(0), SourceMgr(SourceMgr), ID(ID), - Style(Style), IdentTable(getFormattingLangOpts(Style)), - Keywords(IdentTable), Encoding(Encoding), FirstInLineIndex(0), + Style(Style), IdentTable(IdentTable), Keywords(IdentTable), + Encoding(Encoding), Allocator(Allocator), FirstInLineIndex(0), FormattingDisabled(false), MacroBlockBeginRegex(Style.MacroBlockBegin), MacroBlockEndRegex(Style.MacroBlockEnd) { Lex.reset(new Lexer(ID, SourceMgr.getBuffer(ID), SourceMgr, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83218.275967.patch Type: text/x-patch Size: 4411 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 03:14:29 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 10:14:29 +0000 (UTC) Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit. In-Reply-To: References: Message-ID: <28fff785bd0884046bea4a6eaa1baad8@localhost.localdomain> sammccall added a comment. What's the rationale/motivation for this? I'd expect this to break a lot of subtle assumptions, because the invariant "nothing can be dependent without being instantiation-dependent" is a useful one. It also doesn't seem correct from first principles. My mental model is: - dependence describes code where some properties are unknown because a template wasn't instantiated yet - we've generalized this to "some properties are unknown because we don't know what this piece of code is supposed to say" - we can never know the value at compile-time even in contexts where we should, so RecoveryExpr is value-dependent - we only know the type at compile-time if the RecoveryExpr's type is known and not itself dependent, so RecoveryExpr is usually value-dependent - the code may intend to refer to entities valid only in certain instantiations (consider `(void)f(T())` where f is an overloaded function). So RecoveryExpr is at least sometimes instantiation-dependent At best I think we could say that the expr is only instantiation-dependent if it occurs in a template scope - otherwise there's no template we might fail to instantiate. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83213/new/ https://reviews.llvm.org/D83213 From cfe-commits at lists.llvm.org Tue Jul 7 03:32:32 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 10:32:32 +0000 (UTC) Subject: [PATCH] D83290: [clangd] Enable async preambles by default Message-ID: kadircet created this revision. Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, javed.absar, ilya-biryukov. Herald added a project: clang. We've been testing this internally for a couple weeks now and it seems to be stable enough. Let's flip the flag before branch cut to increase testing coverage and have enough time to revert if need be. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83290 Files: clang-tools-extra/clangd/ClangdServer.h clang-tools-extra/clangd/TUScheduler.h Index: clang-tools-extra/clangd/TUScheduler.h =================================================================== --- clang-tools-extra/clangd/TUScheduler.h +++ clang-tools-extra/clangd/TUScheduler.h @@ -194,7 +194,7 @@ /// Whether to run PreamblePeer asynchronously. /// No-op if AsyncThreadsCount is 0. - bool AsyncPreambleBuilds = false; + bool AsyncPreambleBuilds = true; /// Used to create a context that wraps each single operation. /// Typically to inject per-file configuration. Index: clang-tools-extra/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/clangd/ClangdServer.h +++ clang-tools-extra/clangd/ClangdServer.h @@ -100,7 +100,7 @@ bool StorePreamblesInMemory = true; /// Reuse even stale preambles, and rebuild them in the background. /// This improves latency at the cost of accuracy. - bool AsyncPreambleBuilds = false; + bool AsyncPreambleBuilds = true; /// If true, ClangdServer builds a dynamic in-memory index for symbols in /// opened files and uses the index to augment code completion results. -------------- next part -------------- A non-text attachment was scrubbed... Name: D83290.275978.patch Type: text/x-patch Size: 1145 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 03:34:59 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 10:34:59 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: vsavchenko marked 8 inline comments as done. vsavchenko added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:506 + APSIntType Type(Int); + return Int == Type.getZeroValue(); +} ---------------- xazax.hun wrote: > Does the semantics if this differ from ` llvm::APInt::isNullValue`? Good catch! ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1254 + // sufficient. + return S1->get() == S2->get() && + S1->get() == S2->get(); ---------------- xazax.hun wrote: > xazax.hun wrote: > > Sorry, but I am a bit confused here. > > > > Does `haveEqualConstraints` have anything to do with equivalence classes? > > > > I.e., what if I have two symbols with the same constraints (but those two symbols were never compared). > > ``` > > void f(int a, int b) { > > int c = clamp(a, 5, 10); > > int d = clamp(b, 5, 10); > > } > > ``` > > > > In the code above if analyzer understands clamp, the range for `c` and `d` will be the same. Even though we never really compared them. > > I would expect `haveEqualConstraints` to return true, even if they do not belong to the same equivalence class. > > > > Do I miss something? > Never mind, I misunderstood this function. It operates on program states not on symbols. Nothing to be sorry about, I'm happy to clarify! `haveEqualConstraints` is here for our join heuristic that helps removing duplicating paths. ================ Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1380 +ConstraintMap ento::getConstraintMap(ProgramStateRef State) { + ConstraintMap::Factory &F = State->get_context(); ---------------- xazax.hun wrote: > So we basically do a conversion to Symbol -> Ranges from Class -> Ranges. > I wonder if it is possible to get rid of this conversion in the future to get some performance benefits. > We could either make all code work with both kind of range maps or have something like (Symbol + Class) -> Ranges to avoid conversion. > What do you think? > > I am not opposed to this code at the moment, I just wonder if there is a relatively low hanging fruit for some performance gains in the future. This is here only for a very specific mode - when we double check found warnings with Z3. That mode needs constraints assigned to symbols, so here we construct such a set on-the-fly. So, we store ALL of the ranges in the map Class -> Ranges and construct Symbol -> Ranges on very special occasions. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 From cfe-commits at lists.llvm.org Tue Jul 7 03:41:05 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 10:41:05 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: vsavchenko updated this revision to Diff 275981. vsavchenko added a comment. Get rid of 'isZero' Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 Files: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp clang/test/Analysis/equality_tracking.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D82445.275981.patch Type: text/x-patch Size: 43898 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 03:53:03 2020 From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 10:53:03 +0000 (UTC) Subject: [PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v9.2.0 In-Reply-To: References: Message-ID: <4a756b5c3117694d68154d957d55f6d3@localhost.localdomain> atrosinenko updated this revision to Diff 275983. atrosinenko added a comment. Fix path separators in unit test on Windows Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81676/new/ https://reviews.llvm.org/D81676 Files: clang/include/clang/Driver/Options.td clang/lib/Basic/Targets/MSP430.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/MSP430.cpp clang/lib/Driver/ToolChains/MSP430.h clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include-fixed/limits.h clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include/stddef.h clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/include/stdio.h clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o clang/test/Driver/msp430-toolchain.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D81676.275983.patch Type: text/x-patch Size: 32350 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:00:42 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:00:42 +0000 (UTC) Subject: [PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' In-Reply-To: References: Message-ID: <80927a752bbabb16c03d38b19a400109@localhost.localdomain> kadircet added inline comments. ================ Comment at: .gitignore:57 +# clangd index. (".clangd" is a config file now, thus trailing slash) +.clangd/ +.cache ---------------- why do we still need this ? i thought index (and other caches) would reside in `.cache` ? ================ Comment at: clang-tools-extra/clangd/index/Background.h:61 + // CDBDirectory is the first directory containing a CDB in parent directories + // of a file, or user's home directory if none was found, e.g. stdlib headers. static Factory createDiskBackedStorageFactory( ---------------- nit: maybe talk about XDG_CACHE instead of home directory as fallback location. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 From cfe-commits at lists.llvm.org Tue Jul 7 04:11:01 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:11:01 +0000 (UTC) Subject: [PATCH] D83293: [clang-tidy] Fix an unused-raii check crash on objective-c++. Message-ID: hokein created this revision. hokein added a reviewer: gribozavr2. Herald added a subscriber: xazax.hun. Herald added a project: clang. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83293 Files: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm @@ -0,0 +1,15 @@ +// RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0 + +struct Foo { + ~Foo() {} +}; + + at interface ABC { +} +- (Foo)set:(int)p; + at end + +void test(ABC* s) { + [s set:1]; // ok, no crash, no diagnostic emitted. + return; +} Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -27,9 +27,10 @@ // Look for temporaries that are constructed in-place and immediately // destroyed. Look for temporaries created by a functional cast but not for // those returned from a call. - auto BindTemp = - cxxBindTemporaryExpr(unless(has(ignoringParenImpCasts(callExpr())))) - .bind("temp"); + auto BindTemp = cxxBindTemporaryExpr( + unless(has(ignoringParenImpCasts(callExpr()))), + unless(has(ignoringParenImpCasts(objcMessageExpr())))) + .bind("temp"); Finder->addMatcher( traverse(ast_type_traits::TK_AsIs, exprWithCleanups( @@ -79,6 +80,7 @@ auto Matches = match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); const auto *TL = selectFirst("t", Matches); + assert(TL); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, getLangOpts()), -------------- next part -------------- A non-text attachment was scrubbed... Name: D83293.275987.patch Type: text/x-patch Size: 1754 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:13:59 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:13:59 +0000 (UTC) Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due to invalid SourceLocation In-Reply-To: References: Message-ID: gribozavr2 accepted this revision. gribozavr2 added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:149 + case OO_PipePipe: + // Less common binary operators + case OO_ArrowStar: ---------------- Please drop this comment, I don't think it helps understand the code. ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2192 R"cpp( +class osstream {}; struct X { ---------------- I don't think we need a separate class to show the left shift operator. The declaration below can be: ``` friend X operator<<(X&, const X&); ``` ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2199 + X operator,(X&); + // TODO: Test for `->*`. Fix crash before }; ---------------- "TODO: Fix the crash on `->*` and add a test for it." ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2376 + | | | `-x + | | `-IdExpression + | | `-UnqualifiedId ---------------- eduucaldas wrote: > gribozavr2 wrote: > > I'm not sure about this part where `++` is wrapped in IdExpression -- shouldn't the syntax tree look identical to a builtin postfix `++` (see another test in this file)? > This comes back to a discussion we had a month ago about operators ( `+`, `!`, etc) > **Question**: Should we represent operators (built-in or overloaded) in the syntax tree uniformly? If so in which way? > **Context**: The ClangAST stores built-in operators as mere tokens, whereas overloaded operators are represented as a `DeclRefExpr`. That makes a lot of sense for the ClangAST, as we might refer back to the declaration of the overloaded operator, but the declaration of built-in operator doesn't exist. > **Conclusion**: Have the same representation for both types of operators. I have implemented the "unboxed" representation of overloaded operators, i.e. just storing their token in the syntax tree. I have not committed that, but I can do it just after this patch. SGTM. Please just leave a FIXME or TODO in this patch that shows that certain parts of tests are not final. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82954/new/ https://reviews.llvm.org/D82954 From cfe-commits at lists.llvm.org Tue Jul 7 04:15:30 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:15:30 +0000 (UTC) Subject: [PATCH] D83293: [clang-tidy] Fix an unused-raii check crash on objective-c++. In-Reply-To: References: Message-ID: <7888948d73f29abbc7c33c116ae2df41@localhost.localdomain> gribozavr2 accepted this revision. gribozavr2 added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm:3 + +struct Foo { + ~Foo() {} ---------------- Foo => CxxClass ABC => ObjcClass Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83293/new/ https://reviews.llvm.org/D83293 From cfe-commits at lists.llvm.org Tue Jul 7 04:18:45 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:18:45 +0000 (UTC) Subject: [PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts. Message-ID: ebevhan created this revision. ebevhan added reviewers: rjmccall, leonardchan, bjope. Herald added a project: clang. Herald added a subscriber: cfe-commits. This patch adds codegen to Clang for fixed-point shift operations. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83294 Files: clang/lib/CodeGen/CGExprScalar.cpp clang/test/Frontend/fixed_point_compound.c clang/test/Frontend/fixed_point_shift.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83294.275990.patch Type: text/x-patch Size: 21022 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:27:48 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:27:48 +0000 (UTC) Subject: [PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers In-Reply-To: References: Message-ID: <28010c5d9b77c5c546909ac3f872f9cd@localhost.localdomain> njames93 updated this revision to Diff 275991. njames93 added a comment. Removed all hasClass related changes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81552/new/ https://reviews.llvm.org/D81552 Files: clang/docs/LibASTMatchersReference.html clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D81552.275991.patch Type: text/x-patch Size: 5477 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:29:53 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:29:53 +0000 (UTC) Subject: [PATCH] D81552: [ASTMatchers] Added hasDirectBase Matcher In-Reply-To: References: Message-ID: njames93 added a comment. I've removed the hasClass changes as they dont entirely belong in here and weren't well received. Now with just the hasDirectBase this should be in a good state. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81552/new/ https://reviews.llvm.org/D81552 From cfe-commits at lists.llvm.org Tue Jul 7 04:35:04 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:35:04 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <321d4aa24d26b49c2c41ed9163e6f855@localhost.localdomain> ABataev added a comment. In D83268#2135081 , @Hahnfeld wrote: > This is definitely not NFC and breaks API compatibility (but apparently nobody cares anymore?). +1. Better to introduce new entry points and mark these ones as deprecated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 04:35:08 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:35:08 +0000 (UTC) Subject: [PATCH] D83293: [clang-tidy] Fix an unused-raii check crash on objective-c++. In-Reply-To: References: Message-ID: <26e527c2ff8b8bca52eac8bf857ae926@localhost.localdomain> hokein updated this revision to Diff 275994. hokein marked an inline comment as done. hokein added a comment. fix names. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83293/new/ https://reviews.llvm.org/D83293 Files: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm @@ -0,0 +1,15 @@ +// RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0 + +struct CxxClass { + ~CxxClass() {} +}; + + at interface ObjcClass { +} +- (CxxClass)set:(int)p; + at end + +void test(ObjcClass *s) { + [s set:1]; // ok, no crash, no diagnostic emitted. + return; +} Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -27,9 +27,10 @@ // Look for temporaries that are constructed in-place and immediately // destroyed. Look for temporaries created by a functional cast but not for // those returned from a call. - auto BindTemp = - cxxBindTemporaryExpr(unless(has(ignoringParenImpCasts(callExpr())))) - .bind("temp"); + auto BindTemp = cxxBindTemporaryExpr( + unless(has(ignoringParenImpCasts(callExpr()))), + unless(has(ignoringParenImpCasts(objcMessageExpr())))) + .bind("temp"); Finder->addMatcher( traverse(ast_type_traits::TK_AsIs, exprWithCleanups( @@ -79,6 +80,7 @@ auto Matches = match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); const auto *TL = selectFirst("t", Matches); + assert(TL); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, getLangOpts()), -------------- next part -------------- A non-text attachment was scrubbed... Name: D83293.275994.patch Type: text/x-patch Size: 1781 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:37:06 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via cfe-commits) Date: Tue, 07 Jul 2020 04:37:06 -0700 (PDT) Subject: [clang-tools-extra] 3b1e3d2 - [clang-tidy] Fix an unused-raii check crash on objective-c++. Message-ID: <5f045e62.1c69fb81.8865a.155d@mx.google.com> Author: Haojian Wu Date: 2020-07-07T13:36:20+02:00 New Revision: 3b1e3d22735b37eea3ce52d655009f5cd4ad2262 URL: https://github.com/llvm/llvm-project/commit/3b1e3d22735b37eea3ce52d655009f5cd4ad2262 DIFF: https://github.com/llvm/llvm-project/commit/3b1e3d22735b37eea3ce52d655009f5cd4ad2262.diff LOG: [clang-tidy] Fix an unused-raii check crash on objective-c++. Differential Revision: https://reviews.llvm.org/D83293 Added: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm Modified: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp index 34a489e324e4..70ce413d20ff 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -27,9 +27,10 @@ void UnusedRaiiCheck::registerMatchers(MatchFinder *Finder) { // Look for temporaries that are constructed in-place and immediately // destroyed. Look for temporaries created by a functional cast but not for // those returned from a call. - auto BindTemp = - cxxBindTemporaryExpr(unless(has(ignoringParenImpCasts(callExpr())))) - .bind("temp"); + auto BindTemp = cxxBindTemporaryExpr( + unless(has(ignoringParenImpCasts(callExpr()))), + unless(has(ignoringParenImpCasts(objcMessageExpr())))) + .bind("temp"); Finder->addMatcher( traverse(ast_type_traits::TK_AsIs, exprWithCleanups( @@ -79,6 +80,7 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) { auto Matches = match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); const auto *TL = selectFirst("t", Matches); + assert(TL); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, getLangOpts()), diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm new file mode 100644 index 000000000000..432fd5329c56 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm @@ -0,0 +1,15 @@ +// RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0 + +struct CxxClass { + ~CxxClass() {} +}; + + at interface ObjcClass { +} +- (CxxClass)set:(int)p; + at end + +void test(ObjcClass *s) { + [s set:1]; // ok, no crash, no diagnostic emitted. + return; +} From cfe-commits at lists.llvm.org Tue Jul 7 04:37:13 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:37:13 +0000 (UTC) Subject: [PATCH] D83293: [clang-tidy] Fix an unused-raii check crash on objective-c++. In-Reply-To: References: Message-ID: <02782d047d1959776bb3c721b365c47c@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG3b1e3d22735b: [clang-tidy] Fix an unused-raii check crash on objective-c++. (authored by hokein). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83293/new/ https://reviews.llvm.org/D83293 Files: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unused-raii-crash.mm @@ -0,0 +1,15 @@ +// RUN: clang-tidy %s -checks=-*,bugprone-unused-raii -- | count 0 + +struct CxxClass { + ~CxxClass() {} +}; + + at interface ObjcClass { +} +- (CxxClass)set:(int)p; + at end + +void test(ObjcClass *s) { + [s set:1]; // ok, no crash, no diagnostic emitted. + return; +} Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -27,9 +27,10 @@ // Look for temporaries that are constructed in-place and immediately // destroyed. Look for temporaries created by a functional cast but not for // those returned from a call. - auto BindTemp = - cxxBindTemporaryExpr(unless(has(ignoringParenImpCasts(callExpr())))) - .bind("temp"); + auto BindTemp = cxxBindTemporaryExpr( + unless(has(ignoringParenImpCasts(callExpr()))), + unless(has(ignoringParenImpCasts(objcMessageExpr())))) + .bind("temp"); Finder->addMatcher( traverse(ast_type_traits::TK_AsIs, exprWithCleanups( @@ -79,6 +80,7 @@ auto Matches = match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); const auto *TL = selectFirst("t", Matches); + assert(TL); D << FixItHint::CreateInsertion( Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, getLangOpts()), -------------- next part -------------- A non-text attachment was scrubbed... Name: D83293.275995.patch Type: text/x-patch Size: 1781 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:39:37 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:39:37 +0000 (UTC) Subject: [PATCH] D62574: Initial draft of target-configurable address spaces. In-Reply-To: References: Message-ID: <278733c9bdde1d2e4b47af68f0f9d734@localhost.localdomain> ebevhan added a subscriber: danilaml. ebevhan added a comment. In D62574#2133160 , @danilaml wrote: > What are the remaining roadblocks left before this patch can be merged? I'm interested in having a target-specific way to define the allowed explicit/implicit address space conversions. This has been on my backburner for various reasons, so I'm not sure what the status is any more. I could try rebasing it and seeing where things are at. I don't believe that the issues I mentioned last have been dealt with, though. This was also only an initial concept. I think that even once all the issues with the patch have been ironed out, it would require a round of wider review since it's a fairly hefty API change. > Also, it appears that currently whether implicit casts between pointers of different AS are allowed is determined by the superset relations only, however https://reviews.llvm.org/D73360 introduced another (openCL-specific) variable into the mix: whether the conversion is a top level or not. IMHO, this should also be configured by the target, although I'm not sure whether it needs a separate hook (isBitcastNoop or similar?) or it needs to check the legality of the implicit casts differently. That patch only seems to apply to C++, I think? The restriction on top-level-only conversion should be correct, at least in C++. It's generally not safe to alter address spaces below the top level. C is just very permissive about it. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62574/new/ https://reviews.llvm.org/D62574 From cfe-commits at lists.llvm.org Tue Jul 7 04:45:13 2020 From: cfe-commits at lists.llvm.org (=?utf-8?b?QmFsb2doLCDDgWTDoW0gdmlhIFBoYWJyaWNhdG9y?= via cfe-commits) Date: Tue, 07 Jul 2020 11:45:13 +0000 (UTC) Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator checkers Message-ID: baloghadamsoftware created this revision. baloghadamsoftware added reviewers: NoQ, gamesh411, martong, balazske. baloghadamsoftware added a project: clang. Herald added subscribers: ASDenysPetrov, steakhal, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity. Herald added a reviewer: Szelethus. The patch that introduces handling pointers implemented as iterators may cause crash in some projects because pointer difference is mistakenly handled as pointer decrement. (Similair case for iterators implemented as class instances are already handled correctly.) This patch fixes this issue. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83295 Files: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp clang/test/Analysis/iterator-modeling.cpp clang/test/Analysis/iterator-range.cpp Index: clang/test/Analysis/iterator-range.cpp =================================================================== --- clang/test/Analysis/iterator-range.cpp +++ clang/test/Analysis/iterator-range.cpp @@ -935,3 +935,7 @@ // expected-note at -1{{Iterator decremented ahead of its valid range}} } +void ptr_iter_diff(cont_with_ptr_iterator &c) { + auto i0 = c.begin(), i1 = c.end(); + ptrdiff_t len = i1 - i0; // no-crash +} Index: clang/test/Analysis/iterator-modeling.cpp =================================================================== --- clang/test/Analysis/iterator-modeling.cpp +++ clang/test/Analysis/iterator-modeling.cpp @@ -1972,6 +1972,11 @@ clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.end() - 2}} } +void ptr_iter_diff(cont_with_ptr_iterator &c) { + auto i0 = c.begin(), i1 = c.end(); + ptrdiff_t len = i1 - i0; // no-crash +} + void clang_analyzer_printState(); void print_state(std::vector &V) { Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp @@ -169,6 +169,8 @@ verifyDereference(C, LVal); } else if (isRandomIncrOrDecrOperator(OK)) { SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext()); + if (!BO->getRHS()->getType()->isIntegralOrEnumerationType()) + return; verifyRandomIncrOrDecr(C, BinaryOperator::getOverloadedOperator(OK), LVal, RVal); } Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp +++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp @@ -272,6 +272,8 @@ handleComparison(C, BO, Result, LVal, RVal, BinaryOperator::getOverloadedOperator(OK)); } else if (isRandomIncrOrDecrOperator(OK)) { + if (!BO->getRHS()->getType()->isIntegralOrEnumerationType()) + return; handlePtrIncrOrDecr(C, BO->getLHS(), BinaryOperator::getOverloadedOperator(OK), RVal); } @@ -461,6 +463,9 @@ RPos = getIteratorPosition(State, RVal); } + if (!LPos || !RPos) + return; + // We cannot make assumptions on `UnknownVal`. Let us conjure a symbol // instead. if (RetVal.isUnknown()) { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83295.275996.patch Type: text/x-patch Size: 2487 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:54:14 2020 From: cfe-commits at lists.llvm.org (Manuel Klimek via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:54:14 +0000 (UTC) Subject: [PATCH] D83296: [clang-format] Add a MacroExpander. Message-ID: klimek created this revision. klimek added a reviewer: sammccall. Herald added subscribers: cfe-commits, mgorny. Herald added a project: clang. The MacroExpander allows to expand simple (non-resursive) macro definitions from a macro identifier token and macro arguments. It annotates the tokens with a newly introduced MacroContext that keeps track of the role a token played in expanding the macro in order to be able to reconstruct the macro expansion from an expanded (formatted) token stream. Made Token explicitly copy-able to enable copying tokens from the parsed macro definition. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83296 Files: clang/lib/Format/CMakeLists.txt clang/lib/Format/FormatToken.h clang/lib/Format/MacroExpander.cpp clang/lib/Format/MacroExpander.h clang/unittests/Format/CMakeLists.txt clang/unittests/Format/MacroExpanderTest.cpp clang/unittests/Format/TestLexer.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D83296.275998.patch Type: text/x-patch Size: 22617 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 04:55:08 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 11:55:08 +0000 (UTC) Subject: [PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' In-Reply-To: References: Message-ID: <4468e98012d5118433e1e67009436cd3@localhost.localdomain> sammccall marked 5 inline comments as done. sammccall added inline comments. ================ Comment at: .gitignore:57 +# clangd index. (".clangd" is a config file now, thus trailing slash) +.clangd/ +.cache ---------------- kadircet wrote: > why do we still need this ? i thought index (and other caches) would reside in `.cache` ? Otherwise we're going to end up with indexes from old versions of clangd checked in :-( ================ Comment at: .gitignore:58 +.clangd/ +.cache # static analyzer regression testing project files ---------------- hokein wrote: > I'm afraid that many projects have to update their `.gitignore`, but this is a tradeoff... Yeah. This is a consequence of naming the config file `.clangd`, which I think is pretty desirable. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 From cfe-commits at lists.llvm.org Tue Jul 7 04:59:29 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?G=C3=A1bor_Horv=C3=A1th_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 11:59:29 +0000 (UTC) Subject: [PATCH] D82445: [analyzer][solver] Track symbol equivalence In-Reply-To: References: Message-ID: <0d45d4ce389f968e83d3e9a46e54005e@localhost.localdomain> xazax.hun accepted this revision. xazax.hun added a comment. Thanks, LGTM! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82445/new/ https://reviews.llvm.org/D82445 From cfe-commits at lists.llvm.org Tue Jul 7 05:04:02 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:04:02 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <794d9cddd1b69c0c4486551ad370c987@localhost.localdomain> jdoerfert added a comment. In D83268#2135081 , @Hahnfeld wrote: > This is definitely not NFC and breaks API compatibility (but apparently nobody cares anymore?). This is the device RTL. I am not aware we (want to) keep the API stable. If we are, I'm not sure why: - Dynamic linking (among other things) is not really an option so people that link against the device runtime (should) do so statically. - Linking against an old device runtime with a new clang seems unreasonable to me. If you replace clang you must replace the static runtime as the new clang might use new functions. In D83268#2135655 , @ABataev wrote: > In D83268#2135081 , @Hahnfeld wrote: > > > This is definitely not NFC and breaks API compatibility (but apparently nobody cares anymore?). > > > +1. Better to introduce new entry points and mark these ones as deprecated. Same response as above. What is the use case here which we want to continue to support? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 05:06:06 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:06:06 +0000 (UTC) Subject: [PATCH] D83298: Add ability to make fixups to CompilerInvocation after option parsing Message-ID: dang created this revision. dang added a reviewer: Bigcheese. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang. Depends on D83211 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83298 Files: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -256,6 +256,14 @@ return KeyPath & Value; } +static void FixupInvocation(CompilerInvocation &Invocation) { + LangOptions &LangOpts = *Invocation.getLangOpts(); + CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts(); + CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument; + CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents; + CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents; +} + //===----------------------------------------------------------------------===// // Deserialization (from args) //===----------------------------------------------------------------------===// @@ -1180,16 +1188,8 @@ Opts.InstrumentFunctionEntryBare = Args.hasArg(OPT_finstrument_function_entry_bare); - Opts.XRayInstrumentFunctions = - Args.hasArg(OPT_fxray_instrument); - Opts.XRayAlwaysEmitCustomEvents = - Args.hasArg(OPT_fxray_always_emit_customevents); - Opts.XRayAlwaysEmitTypedEvents = - Args.hasArg(OPT_fxray_always_emit_typedevents); Opts.XRayInstructionThreshold = getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags); - Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops); - Opts.XRayOmitFunctionIndex = Args.hasArg(OPT_fno_xray_function_index); auto XRayInstrBundles = Args.getAllArgValues(OPT_fxray_instrumentation_bundle); @@ -3350,13 +3350,6 @@ systemBlacklists.begin(), systemBlacklists.end()); - // -fxray-instrument - Opts.XRayInstrument = Args.hasArg(OPT_fxray_instrument); - Opts.XRayAlwaysEmitCustomEvents = - Args.hasArg(OPT_fxray_always_emit_customevents); - Opts.XRayAlwaysEmitTypedEvents = - Args.hasArg(OPT_fxray_always_emit_typedevents); - // -fxray-{always,never}-instrument= filenames. Opts.XRayAlwaysInstrumentFiles = Args.getAllArgValues(OPT_fxray_always_instrument); @@ -3710,6 +3703,7 @@ } Success &= Res.parseSimpleArgs(Args, Diags); + FixupInvocation(Res); llvm::sys::Process::UseANSIEscapeCodes( Res.DiagnosticOpts->UseANSIEscapeCodes); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1281,7 +1281,7 @@ Alias, AliasArgs<["full"]>, HelpText<"Enable cf-protection in 'full' mode">; -defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay instrumentation sleds on function entry and exit">; +defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay instrumentation sleds on function entry and exit", "", "", [], "LangOpts->XRayInstrument">; def fxray_instruction_threshold_EQ : JoinedOrSeparate<["-"], "fxray-instruction-threshold=">, @@ -1309,15 +1309,15 @@ HelpText<"List of modes to link in by default into XRay instrumented binaries.">; defm xray_always_emit_customevents : OptInFFlag<"xray-always-emit-customevents", - "Always emit __xray_customevent(...) calls even if the containing function is not always instrumented">; + "Always emit __xray_customevent(...) calls even if the containing function is not always instrumented", "", "", [], "LangOpts->XRayAlwaysEmitCustomEvents">; defm xray_always_emit_typedevents : OptInFFlag<"xray-always-emit-typedevents", - "Always emit __xray_typedevent(...) calls even if the containing function is not always instrumented">; + "Always emit __xray_typedevent(...) calls even if the containing function is not always instrumented", "", "", [], "LangOpts->XRayAlwaysEmitTypedEvents">; defm xray_ignore_loops : OptInFFlag<"xray-ignore-loops", - "Don't instrument functions with loops unless they also meet the minimum function size">; + "Don't instrument functions with loops unless they also meet the minimum function size", "", "", [], "CodeGenOpts.XRayIgnoreLoops">; defm xray_function_index : OptOutFFlag<"xray-function-index", "", - "Omit function index section at the expense of single-function patching performance">; + "Omit function index section at the expense of single-function patching performance", "", [], "CodeGenOpts.XRayOmitFunctionIndex">; def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group, Flags<[CC1Option]>, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83298.276004.patch Type: text/x-patch Size: 4547 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:09:22 2020 From: cfe-commits at lists.llvm.org (Hsiangkai Wang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:09:22 +0000 (UTC) Subject: [PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9. In-Reply-To: References: Message-ID: <427688bfb6a14fd87156df9255591f58@localhost.localdomain> HsiangKai updated this revision to Diff 276005. HsiangKai added a comment. Address @rogfer01 and @fpallares' comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80802/new/ https://reviews.llvm.org/D80802 Files: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp llvm/lib/Target/RISCV/RISCVInstrFormats.td llvm/lib/Target/RISCV/RISCVInstrFormatsV.td llvm/lib/Target/RISCV/RISCVInstrInfo.h llvm/lib/Target/RISCV/RISCVInstrInfoV.td llvm/test/MC/RISCV/rvv/convert.s llvm/test/MC/RISCV/rvv/ext.s llvm/test/MC/RISCV/rvv/fothers.s llvm/test/MC/RISCV/rvv/invalid.s llvm/test/MC/RISCV/rvv/load.s llvm/test/MC/RISCV/rvv/mask.s llvm/test/MC/RISCV/rvv/snippet.s llvm/test/MC/RISCV/rvv/store.s llvm/test/MC/RISCV/rvv/vsetvl.s -------------- next part -------------- A non-text attachment was scrubbed... Name: D80802.276005.patch Type: text/x-patch Size: 129048 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:10:24 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:10:24 +0000 (UTC) Subject: [PATCH] D83071: Add support for options with two flags for controlling the same field. In-Reply-To: References: Message-ID: <052139caeaaa4c622cf89943e9860f90@localhost.localdomain> dang updated this revision to Diff 276007. dang added a comment. Make mergers use values directly instead of constant references Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83071/new/ https://reviews.llvm.org/D83071 Files: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/Option/OptParser.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D83071.276007.patch Type: text/x-patch Size: 8305 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:12:24 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:12:24 +0000 (UTC) Subject: [PATCH] D82860: Port ObjCMTAction to new option parsing system In-Reply-To: References: Message-ID: <7d37224158819852d54c9aaa2e6172f0@localhost.localdomain> dang updated this revision to Diff 276008. dang added a comment. Make mergers use values directly instead of constant references. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82860/new/ https://reviews.llvm.org/D82860 Files: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/Option/OptParser.td llvm/utils/TableGen/OptParserEmitter.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82860.276008.patch Type: text/x-patch Size: 27572 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:13:13 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:13:13 +0000 (UTC) Subject: [PATCH] D83071: Add support for options with two flags for controlling the same field. In-Reply-To: References: Message-ID: <1ec67e80f25b84a154f5afc1016e9f25@localhost.localdomain> dang updated this revision to Diff 276009. dang added a comment. Rebase on top of some changes to parent patches. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83071/new/ https://reviews.llvm.org/D83071 Files: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/Option/OptParser.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D83071.276009.patch Type: text/x-patch Size: 7912 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:16:11 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:16:11 +0000 (UTC) Subject: [PATCH] D83298: Add ability to make fixups to CompilerInvocation after option parsing In-Reply-To: References: Message-ID: <5b9bfb6c82053f6ae166b864bac6c80c@localhost.localdomain> dang updated this revision to Diff 276010. dang added a comment. Move the UseANSIEscapeCodes fixup to the correct place. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83298/new/ https://reviews.llvm.org/D83298 Files: clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -255,6 +255,17 @@ return KeyPath & Value; } +static void FixupInvocation(CompilerInvocation &Invocation) { + LangOptions &LangOpts = *Invocation.getLangOpts(); + DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts(); + CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts(); + CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument; + CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents; + CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents; + + llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes); +} + //===----------------------------------------------------------------------===// // Deserialization (from args) //===----------------------------------------------------------------------===// @@ -1179,16 +1190,8 @@ Opts.InstrumentFunctionEntryBare = Args.hasArg(OPT_finstrument_function_entry_bare); - Opts.XRayInstrumentFunctions = - Args.hasArg(OPT_fxray_instrument); - Opts.XRayAlwaysEmitCustomEvents = - Args.hasArg(OPT_fxray_always_emit_customevents); - Opts.XRayAlwaysEmitTypedEvents = - Args.hasArg(OPT_fxray_always_emit_typedevents); Opts.XRayInstructionThreshold = getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags); - Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops); - Opts.XRayOmitFunctionIndex = Args.hasArg(OPT_fno_xray_function_index); auto XRayInstrBundles = Args.getAllArgValues(OPT_fxray_instrumentation_bundle); @@ -3349,13 +3352,6 @@ systemBlacklists.begin(), systemBlacklists.end()); - // -fxray-instrument - Opts.XRayInstrument = Args.hasArg(OPT_fxray_instrument); - Opts.XRayAlwaysEmitCustomEvents = - Args.hasArg(OPT_fxray_always_emit_customevents); - Opts.XRayAlwaysEmitTypedEvents = - Args.hasArg(OPT_fxray_always_emit_typedevents); - // -fxray-{always,never}-instrument= filenames. Opts.XRayAlwaysInstrumentFiles = Args.getAllArgValues(OPT_fxray_always_instrument); @@ -3709,9 +3705,7 @@ } Success &= Res.parseSimpleArgs(Args, Diags); - - llvm::sys::Process::UseANSIEscapeCodes( - Res.DiagnosticOpts->UseANSIEscapeCodes); + FixupInvocation(Res); Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags); Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -1281,7 +1281,7 @@ Alias, AliasArgs<["full"]>, HelpText<"Enable cf-protection in 'full' mode">; -defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay instrumentation sleds on function entry and exit">; +defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay instrumentation sleds on function entry and exit", "", "", [], "LangOpts->XRayInstrument">; def fxray_instruction_threshold_EQ : JoinedOrSeparate<["-"], "fxray-instruction-threshold=">, @@ -1309,15 +1309,15 @@ HelpText<"List of modes to link in by default into XRay instrumented binaries.">; defm xray_always_emit_customevents : OptInFFlag<"xray-always-emit-customevents", - "Always emit __xray_customevent(...) calls even if the containing function is not always instrumented">; + "Always emit __xray_customevent(...) calls even if the containing function is not always instrumented", "", "", [], "LangOpts->XRayAlwaysEmitCustomEvents">; defm xray_always_emit_typedevents : OptInFFlag<"xray-always-emit-typedevents", - "Always emit __xray_typedevent(...) calls even if the containing function is not always instrumented">; + "Always emit __xray_typedevent(...) calls even if the containing function is not always instrumented", "", "", [], "LangOpts->XRayAlwaysEmitTypedEvents">; defm xray_ignore_loops : OptInFFlag<"xray-ignore-loops", - "Don't instrument functions with loops unless they also meet the minimum function size">; + "Don't instrument functions with loops unless they also meet the minimum function size", "", "", [], "CodeGenOpts.XRayIgnoreLoops">; defm xray_function_index : OptOutFFlag<"xray-function-index", "", - "Omit function index section at the expense of single-function patching performance">; + "Omit function index section at the expense of single-function patching performance", "", [], "CodeGenOpts.XRayOmitFunctionIndex">; def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group, Flags<[CC1Option]>, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83298.276010.patch Type: text/x-patch Size: 4820 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:20:35 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:20:35 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added a comment. In D83268#2135724 , @jdoerfert wrote: > In D83268#2135081 , @Hahnfeld wrote: > > > This is definitely not NFC and breaks API compatibility (but apparently nobody cares anymore?). > > > This is the device RTL. I am not aware we (want to) keep the API stable. If we are, I'm not sure why: > > - Dynamic linking (among other things) is not really an option so people that link against the device runtime (should) do so statically. > - Linking against an old device runtime with a new clang seems unreasonable to me. If you replace clang you must replace the static runtime as the new clang might use new functions. > > > > In D83268#2135655 , @ABataev wrote: > > > In D83268#2135081 , @Hahnfeld wrote: > > > > > This is definitely not NFC and breaks API compatibility (but apparently nobody cares anymore?). > > > > > > +1. Better to introduce new entry points and mark these ones as deprecated. > > > Same response as above. What is the use case here which we want to continue to support? Use of the new library with the previous version of the compiler. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 05:25:48 2020 From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:25:48 +0000 (UTC) Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute In-Reply-To: References: Message-ID: <6dfee5003fc2f2a5a141a77d290fb35a@localhost.localdomain> uweigand added a comment. Another ping ... See also http://lists.llvm.org/pipermail/cfe-dev/2020-July/066162.html Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81583/new/ https://reviews.llvm.org/D81583 From cfe-commits at lists.llvm.org Tue Jul 7 05:46:24 2020 From: cfe-commits at lists.llvm.org (Alex Cameron via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:46:24 +0000 (UTC) Subject: [PATCH] D83188: [clang-tidy] bugprone-bool-pointer-implicit-conversion doesn't handle members In-Reply-To: References: Message-ID: <93ece871a37c5529c38887d3fdd1a6c9@localhost.localdomain> tetsuo-cpp updated this revision to Diff 276022. tetsuo-cpp added a comment. Address comments: Rename variables, remove unnecessary tests and avoid unnecessary check. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83188/new/ https://reviews.llvm.org/D83188 Files: clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-bool-pointer-implicit-conversion.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83188.276022.patch Type: text/x-patch Size: 5886 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:54:10 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:54:10 +0000 (UTC) Subject: [PATCH] D83099: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. sammccall marked 2 inline comments as done. Closed by commit rG9b55bc4d1197: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' (authored by sammccall). Changed prior to commit: https://reviews.llvm.org/D83099?vs=275645&id=276027#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 Files: .gitignore clang-tools-extra/clangd/index/Background.h clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp clang-tools-extra/clangd/test/background-index.test llvm/.gitignore Index: llvm/.gitignore =================================================================== --- llvm/.gitignore +++ llvm/.gitignore @@ -59,8 +59,6 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd #==============================================================================# # Files created in tree by the Go bindings. Index: clang-tools-extra/clangd/test/background-index.test =================================================================== --- clang-tools-extra/clangd/test/background-index.test +++ clang-tools-extra/clangd/test/background-index.test @@ -15,8 +15,8 @@ # RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD # Test that the index is writing files in the expected location. -# RUN: ls %t/.clangd/index/foo.cpp.*.idx -# RUN: ls %t/sub_dir/.clangd/index/foo.h.*.idx +# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx +# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx # Test the index is read from disk: delete code and restart clangd. # RUN: rm %t/foo.cpp Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp =================================================================== --- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp +++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp @@ -95,8 +95,8 @@ }; // Creates and owns IndexStorages for multiple CDBs. -// When a CDB root is found, shards are stored in $ROOT/.clangd/index. -// When no root is found, the fallback path is ~/.cache/clangd/index. +// When a CDB root is found, shards are stored in $ROOT/.cache/clangd/index/. +// When no root is found, the fallback path is ~/.cache/clangd/index/. class DiskBackedIndexStorageManager { public: DiskBackedIndexStorageManager( @@ -115,7 +115,7 @@ llvm::SmallString<128> StorageDir(FallbackDir); if (auto PI = GetProjectInfo(File)) { StorageDir = PI->SourceRoot; - llvm::sys::path::append(StorageDir, ".clangd", "index"); + llvm::sys::path::append(StorageDir, ".cache", "clangd", "index"); } auto &IndexStorage = IndexStorageMap[StorageDir]; if (!IndexStorage) Index: clang-tools-extra/clangd/index/Background.h =================================================================== --- clang-tools-extra/clangd/index/Background.h +++ clang-tools-extra/clangd/index/Background.h @@ -56,9 +56,9 @@ using Factory = llvm::unique_function; // Creates an Index Storage that saves shards into disk. Index storage uses - // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory - // is the first directory containing a CDB in parent directories of a file, or - // user's home directory if none was found, e.g. standard library headers. + // CDBDirectory + ".cache/clangd/index/" as the folder to save shards. + // CDBDirectory is the first directory containing a CDB in parent directories + // of a file, or user cache directory if none was found, e.g. stdlib headers. static Factory createDiskBackedStorageFactory( std::function(PathRef)> GetProjectInfo); }; Index: .gitignore =================================================================== --- .gitignore +++ .gitignore @@ -53,10 +53,11 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd +# clangd index. (".clangd" is a config file now, thus trailing slash) +.clangd/ +.cache # static analyzer regression testing project files /clang/utils/analyzer/projects/*/CachedSource /clang/utils/analyzer/projects/*/PatchedSource /clang/utils/analyzer/projects/*/ScanBuildResults -/clang/utils/analyzer/projects/*/RefScanBuildResults \ No newline at end of file +/clang/utils/analyzer/projects/*/RefScanBuildResults -------------- next part -------------- A non-text attachment was scrubbed... Name: D83099.276027.patch Type: text/x-patch Size: 3809 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:55:56 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:55:56 +0000 (UTC) Subject: [PATCH] D83099: Revert "[clangd] Store index in '.clangd/index' instead of '.clangd-index'" In-Reply-To: References: Message-ID: <6ed8e2fe8467b3075ce87b55a2243ac4@localhost.localdomain> This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG9b55bc4d1197: [clangd] Store index in '.cache/clangd/index' instead of '.clangd/index' (authored by sammccall). Changed prior to commit: https://reviews.llvm.org/D83099?vs=275244&id=275660#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83099/new/ https://reviews.llvm.org/D83099 Files: .gitignore clang-tools-extra/clangd/index/Background.h clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp clang-tools-extra/clangd/test/background-index.test llvm/.gitignore Index: llvm/.gitignore =================================================================== --- llvm/.gitignore +++ llvm/.gitignore @@ -59,8 +59,6 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd #==============================================================================# # Files created in tree by the Go bindings. Index: clang-tools-extra/clangd/test/background-index.test =================================================================== --- clang-tools-extra/clangd/test/background-index.test +++ clang-tools-extra/clangd/test/background-index.test @@ -15,8 +15,8 @@ # RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD # Test that the index is writing files in the expected location. -# RUN: ls %t/.clangd/index/foo.cpp.*.idx -# RUN: ls %t/sub_dir/.clangd/index/foo.h.*.idx +# RUN: ls %t/.cache/clangd/index/foo.cpp.*.idx +# RUN: ls %t/sub_dir/.cache/clangd/index/foo.h.*.idx # Test the index is read from disk: delete code and restart clangd. # RUN: rm %t/foo.cpp Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp =================================================================== --- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp +++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp @@ -95,8 +95,8 @@ }; // Creates and owns IndexStorages for multiple CDBs. -// When a CDB root is found, shards are stored in $ROOT/.clangd/index. -// When no root is found, the fallback path is ~/.cache/clangd/index. +// When a CDB root is found, shards are stored in $ROOT/.cache/clangd/index/. +// When no root is found, the fallback path is ~/.cache/clangd/index/. class DiskBackedIndexStorageManager { public: DiskBackedIndexStorageManager( @@ -115,7 +115,7 @@ llvm::SmallString<128> StorageDir(FallbackDir); if (auto PI = GetProjectInfo(File)) { StorageDir = PI->SourceRoot; - llvm::sys::path::append(StorageDir, ".clangd", "index"); + llvm::sys::path::append(StorageDir, ".cache", "clangd", "index"); } auto &IndexStorage = IndexStorageMap[StorageDir]; if (!IndexStorage) Index: clang-tools-extra/clangd/index/Background.h =================================================================== --- clang-tools-extra/clangd/index/Background.h +++ clang-tools-extra/clangd/index/Background.h @@ -56,9 +56,9 @@ using Factory = llvm::unique_function; // Creates an Index Storage that saves shards into disk. Index storage uses - // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory - // is the first directory containing a CDB in parent directories of a file, or - // user's home directory if none was found, e.g. standard library headers. + // CDBDirectory + ".cache/clangd/index/" as the folder to save shards. + // CDBDirectory is the first directory containing a CDB in parent directories + // of a file, or user cache directory if none was found, e.g. stdlib headers. static Factory createDiskBackedStorageFactory( std::function(PathRef)> GetProjectInfo); }; Index: .gitignore =================================================================== --- .gitignore +++ .gitignore @@ -53,10 +53,11 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd +# clangd index. (".clangd" is a config file now, thus trailing slash) +.clangd/ +.cache # static analyzer regression testing project files /clang/utils/analyzer/projects/*/CachedSource /clang/utils/analyzer/projects/*/PatchedSource /clang/utils/analyzer/projects/*/ScanBuildResults -/clang/utils/analyzer/projects/*/RefScanBuildResults \ No newline at end of file +/clang/utils/analyzer/projects/*/RefScanBuildResults -------------- next part -------------- A non-text attachment was scrubbed... Name: D83099.275660.patch Type: text/x-patch Size: 3809 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:56:21 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:56:21 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: kbobyrev updated this revision to Diff 276029. kbobyrev added a comment. Convert prefix paths to native slash format for _serialization_ calls (deserializations should use UNIX slashes). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.276029.patch Type: text/x-patch Size: 25823 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 05:56:58 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 12:56:58 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added inline comments. ================ Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:42 - /// *outlined_function, int16_t - /// IsOMPRuntimeInitialized); OMPRTL_NVPTX__kmpc_kernel_prepare_parallel, ---------------- I think, instead the optimizer can try to detect if the runtime library is used by the kernel and switch this flag to `0` if no runtime calls are used in the kernel. For non-SPMD mode in most cases, the runtime is required, but in some cases, it can be disabled. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:04:57 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:04:57 +0000 (UTC) Subject: [PATCH] D82938: [clangd] Implement path and URI translation for remote index In-Reply-To: References: Message-ID: kbobyrev updated this revision to Diff 276030. kbobyrev added a comment. Add assertions for ensuring paths have UNIX slashes during deserialization. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82938/new/ https://reviews.llvm.org/D82938 Files: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/Client.h clang-tools-extra/clangd/index/remote/Index.proto clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h clang-tools-extra/clangd/index/remote/server/Server.cpp clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82938.276030.patch Type: text/x-patch Size: 26090 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 06:17:10 2020 From: cfe-commits at lists.llvm.org (Diogo N. Sampaio via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:17:10 +0000 (UTC) Subject: [PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width In-Reply-To: References: Message-ID: <7d9ec1750c562e3b0d18f2ad4ac18f58@localhost.localdomain> dnsampaio updated this revision to Diff 276034. dnsampaio added a comment. Herald added a subscriber: danielkiss. Rebased. Now the AAPCS explicitly avoids conflicts with the C11, by not imposing any restriction when the natural container will overlap a zero lenght bit-field: https://github.com/ARM-software/abi-aa/commit/2334fc7611ede31b33e314ddd0dc90579015b322 Both 32 and 64 bit versions were updated on the same way. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72932/new/ https://reviews.llvm.org/D72932 Files: clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Driver/Options.td clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGRecordLayout.h clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/aapcs-bitfield.c clang/test/CodeGen/bitfield-2.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D72932.276034.patch Type: text/x-patch Size: 230319 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 06:17:17 2020 From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:17:17 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: JonChesterfield added a comment. I'm not sure we have a consensus on api stability. Usually llvm allows mixing libraries and compilers from different sources, e.g. the various libunwind or compiler-rt vs libgcc. Libomptarget in general appears to be considered fixed and has external users (intel, maybe gcc). The device runtime would be ill served by this default. This is the only openmp device runtime library which works with llvm. It's statically linked, usually as bitcode when performance is important. The code used to handle target offloading for nvptx is spread across the compiler and the runtime, probably not optimally. I'm not familiar with the gcc-nvptx-openmp implementation. Reading through https://gcc.gnu.org/wiki/Offloading strongly suggests a totally independent implementation to this one. I don't think gcc can be using this runtime library for nvptx. It definitely doesn't for amdgcn. Proprietary compilers might be using this code, but we can have no duty of care to toolchains that use this code without telling us they're doing so. Therefore the only backwards/forwards compatibility we can strive for is between different versions of clang and the device runtime. That seems potentially useful - one could use a release clang binary while working on the deviceRTL or vice versa. It's an expensive developer convenience though. We would pay with things like the API rot fixed above. Introducing a faster lowering for an openmp construct would mean a redundant path through clang and some version checking to guess which runtime library we're targeting, which is not presently versioned. Likewise moving code between compiler and runtime becomes much more expensive to implement. Getting it wrong is inevitable given our test coverage. I think the project is much better served by assuming that the runtime library used by clang is the one from the same hash in the monorepo. That leaves us free to fix debt and improve performance, at the price of needing to build clang from (near to) trunk while developing the rtl. Perhaps we can embrace API stability later on, once we have things like versioning and a solid optimisation pipeline in place, especially if gcc wants to use the deviceRTL for nvptx. Now is too early. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:25:26 2020 From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:25:26 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: JonChesterfield accepted this revision. JonChesterfield added a comment. This revision is now accepted and ready to land. Aside from the API stability concern this looks uncontentious. Removes dead arguments, generally makes things simpler. Thus LGTM. @Hahnfeld @ABataev - are you sufficiently persuaded that preserving the current interface is not worth the development cost? ================ Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:42 - /// *outlined_function, int16_t - /// IsOMPRuntimeInitialized); OMPRTL_NVPTX__kmpc_kernel_prepare_parallel, ---------------- ABataev wrote: > I think, instead the optimizer can try to detect if the runtime library is used by the kernel and switch this flag to `0` if no runtime calls are used in the kernel. For non-SPMD mode in most cases, the runtime is required, but in some cases, it can be disabled. If we can detect that no runtime calls are used, we should be able to do better than passing a different argument. E.g. delete some setup calls. Failing that, if we want to pass an argument which says 'actually don't do any work', it shouldn't be the same argument used to check whether the runtime has been initialised. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:29:44 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:29:44 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added a comment. In D83268#2135930 , @JonChesterfield wrote: > Aside from the API stability concern this looks uncontentious. Removes dead arguments, generally makes things simpler. Thus LGTM. > > @Hahnfeld @ABataev - are you sufficiently persuaded that preserving the current interface is not worth the development cost? No, I'm not. Long before that, we relied on the API stability and already have some runtime calls marked as deprecated. Especially taking into account, that libomp can be built separately. ================ Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:42 - /// *outlined_function, int16_t - /// IsOMPRuntimeInitialized); OMPRTL_NVPTX__kmpc_kernel_prepare_parallel, ---------------- JonChesterfield wrote: > ABataev wrote: > > I think, instead the optimizer can try to detect if the runtime library is used by the kernel and switch this flag to `0` if no runtime calls are used in the kernel. For non-SPMD mode in most cases, the runtime is required, but in some cases, it can be disabled. > If we can detect that no runtime calls are used, we should be able to do better than passing a different argument. E.g. delete some setup calls. > > Failing that, if we want to pass an argument which says 'actually don't do any work', it shouldn't be the same argument used to check whether the runtime has been initialised. No, I don't think you can do this in all cases Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:31:22 2020 From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits) Date: Tue, 07 Jul 2020 06:31:22 -0700 (PDT) Subject: [clang] 41bbb87 - [NFC] Use hasAnyName matcher in place of anyOf(hasName()...) Message-ID: <5f04792a.1c69fb81.5cfe3.c7f4@mx.google.com> Author: Nathan James Date: 2020-07-07T14:31:04+01:00 New Revision: 41bbb875e4da392ae37300d3a6282b6595f14503 URL: https://github.com/llvm/llvm-project/commit/41bbb875e4da392ae37300d3a6282b6595f14503 DIFF: https://github.com/llvm/llvm-project/commit/41bbb875e4da392ae37300d3a6282b6595f14503.diff LOG: [NFC] Use hasAnyName matcher in place of anyOf(hasName()...) Added: Modified: clang-tools-extra/clang-move/Move.cpp clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp clang-tools-extra/clang-tidy/cert/CommandProcessorCheck.cpp clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-move/Move.cpp b/clang-tools-extra/clang-move/Move.cpp index 28184a0dce0c..3f09f68a8046 100644 --- a/clang-tools-extra/clang-move/Move.cpp +++ b/clang-tools-extra/clang-move/Move.cpp @@ -552,20 +552,22 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { // Match static functions/variable definitions which are defined in named // namespaces. - Optional> HasAnySymbolNames; + SmallVector QualNames; + QualNames.reserve(Context->Spec.Names.size()); for (StringRef SymbolName : Context->Spec.Names) { - llvm::StringRef GlobalSymbolName = SymbolName.trim().ltrim(':'); - const auto HasName = hasName(("::" + GlobalSymbolName).str()); - HasAnySymbolNames = - HasAnySymbolNames ? anyOf(*HasAnySymbolNames, HasName) : HasName; + QualNames.push_back(("::" + SymbolName.trim().ltrim(':')).str()); } - if (!HasAnySymbolNames) { + if (QualNames.empty()) { llvm::errs() << "No symbols being moved.\n"; return; } + + ast_matchers::internal::Matcher HasAnySymbolNames = + hasAnyName(SmallVector(QualNames.begin(), QualNames.end())); + auto InMovedClass = - hasOutermostEnclosingClass(cxxRecordDecl(*HasAnySymbolNames)); + hasOutermostEnclosingClass(cxxRecordDecl(HasAnySymbolNames)); // Matchers for helper declarations in old.cc. auto InAnonymousNS = hasParent(namespaceDecl(isAnonymous())); @@ -612,17 +614,17 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { // Create a MatchCallback for class declarations. MatchCallbacks.push_back(std::make_unique(this)); // Match moved class declarations. - auto MovedClass = cxxRecordDecl(InOldFiles, *HasAnySymbolNames, - isDefinition(), TopLevelDecl) - .bind("moved_class"); + auto MovedClass = + cxxRecordDecl(InOldFiles, HasAnySymbolNames, isDefinition(), TopLevelDecl) + .bind("moved_class"); Finder->addMatcher(MovedClass, MatchCallbacks.back().get()); // Match moved class methods (static methods included) which are defined // outside moved class declaration. - Finder->addMatcher( - cxxMethodDecl(InOldFiles, ofOutermostEnclosingClass(*HasAnySymbolNames), - isDefinition()) - .bind("class_method"), - MatchCallbacks.back().get()); + Finder->addMatcher(cxxMethodDecl(InOldFiles, + ofOutermostEnclosingClass(HasAnySymbolNames), + isDefinition()) + .bind("class_method"), + MatchCallbacks.back().get()); // Match static member variable definition of the moved class. Finder->addMatcher( varDecl(InMovedClass, InOldFiles, isDefinition(), isStaticDataMember()) @@ -630,20 +632,20 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { MatchCallbacks.back().get()); MatchCallbacks.push_back(std::make_unique(this)); - Finder->addMatcher(functionDecl(InOldFiles, *HasAnySymbolNames, TopLevelDecl) + Finder->addMatcher(functionDecl(InOldFiles, HasAnySymbolNames, TopLevelDecl) .bind("function"), MatchCallbacks.back().get()); MatchCallbacks.push_back(std::make_unique(this)); Finder->addMatcher( - varDecl(InOldFiles, *HasAnySymbolNames, TopLevelDecl).bind("var"), + varDecl(InOldFiles, HasAnySymbolNames, TopLevelDecl).bind("var"), MatchCallbacks.back().get()); // Match enum definition in old.h. Enum helpers (which are defined in old.cc) // will not be moved for now no matter whether they are used or not. MatchCallbacks.push_back(std::make_unique(this)); Finder->addMatcher( - enumDecl(InOldHeader, *HasAnySymbolNames, isDefinition(), TopLevelDecl) + enumDecl(InOldHeader, HasAnySymbolNames, isDefinition(), TopLevelDecl) .bind("enum"), MatchCallbacks.back().get()); @@ -653,7 +655,7 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) { MatchCallbacks.push_back(std::make_unique(this)); Finder->addMatcher(namedDecl(anyOf(typedefDecl().bind("typedef"), typeAliasDecl().bind("type_alias")), - InOldHeader, *HasAnySymbolNames, TopLevelDecl), + InOldHeader, HasAnySymbolNames, TopLevelDecl), MatchCallbacks.back().get()); } diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp index 4a15f5d111df..7c8c26370118 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp @@ -19,12 +19,10 @@ namespace bugprone { void MisplacedOperatorInStrlenInAllocCheck::registerMatchers( MatchFinder *Finder) { - const auto StrLenFunc = functionDecl(anyOf( - hasName("::strlen"), hasName("::std::strlen"), hasName("::strnlen"), - hasName("::std::strnlen"), hasName("::strnlen_s"), - hasName("::std::strnlen_s"), hasName("::wcslen"), - hasName("::std::wcslen"), hasName("::wcsnlen"), hasName("::std::wcsnlen"), - hasName("::wcsnlen_s"), hasName("std::wcsnlen_s"))); + const auto StrLenFunc = functionDecl(hasAnyName( + "::strlen", "::std::strlen", "::strnlen", "::std::strnlen", "::strnlen_s", + "::std::strnlen_s", "::wcslen", "::std::wcslen", "::wcsnlen", + "::std::wcsnlen", "::wcsnlen_s", "std::wcsnlen_s")); const auto BadUse = callExpr(callee(StrLenFunc), @@ -42,12 +40,10 @@ void MisplacedOperatorInStrlenInAllocCheck::registerMatchers( hasDescendant(BadUse)), BadUse); - const auto Alloc0Func = - functionDecl(anyOf(hasName("::malloc"), hasName("std::malloc"), - hasName("::alloca"), hasName("std::alloca"))); - const auto Alloc1Func = - functionDecl(anyOf(hasName("::calloc"), hasName("std::calloc"), - hasName("::realloc"), hasName("std::realloc"))); + const auto Alloc0Func = functionDecl( + hasAnyName("::malloc", "std::malloc", "::alloca", "std::alloca")); + const auto Alloc1Func = functionDecl( + hasAnyName("::calloc", "std::calloc", "::realloc", "std::realloc")); const auto Alloc0FuncPtr = varDecl(hasType(isConstQualified()), diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp index 04ae878b7024..2a6a0ae53a4f 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp @@ -19,10 +19,9 @@ namespace bugprone { void MisplacedPointerArithmeticInAllocCheck::registerMatchers( MatchFinder *Finder) { - const auto AllocFunc = functionDecl( - anyOf(hasName("::malloc"), hasName("std::malloc"), hasName("::alloca"), - hasName("::calloc"), hasName("std::calloc"), hasName("::realloc"), - hasName("std::realloc"))); + const auto AllocFunc = + functionDecl(hasAnyName("::malloc", "std::malloc", "::alloca", "::calloc", + "std::calloc", "::realloc", "std::realloc")); const auto AllocFuncPtr = varDecl(hasType(isConstQualified()), diff --git a/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp index 844d672f121f..ee4681883964 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp @@ -54,8 +54,7 @@ void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) { .bind("wait")); auto hasWaitDescendantC = hasDescendant( - callExpr(callee(functionDecl( - anyOf(hasName("cnd_wait"), hasName("cnd_timedwait"))))) + callExpr(callee(functionDecl(hasAnyName("cnd_wait", "cnd_timedwait")))) .bind("wait")); if (getLangOpts().CPlusPlus) { // Check for `CON54-CPP` diff --git a/clang-tools-extra/clang-tidy/cert/CommandProcessorCheck.cpp b/clang-tools-extra/clang-tidy/cert/CommandProcessorCheck.cpp index 72b39d18f9f1..131ae9b3ed55 100644 --- a/clang-tools-extra/clang-tidy/cert/CommandProcessorCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/CommandProcessorCheck.cpp @@ -19,8 +19,7 @@ namespace cert { void CommandProcessorCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( callExpr( - callee(functionDecl(anyOf(hasName("::system"), hasName("::popen"), - hasName("::_popen"))) + callee(functionDecl(hasAnyName("::system", "::popen", "::_popen")) .bind("func")), // Do not diagnose when the call expression passes a null pointer // constant to system(); that only checks for the presence of a diff --git a/clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp index 2b3093338564..f4051c34aad9 100644 --- a/clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp @@ -19,7 +19,7 @@ namespace cert { void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( namespaceDecl(unless(isExpansionInSystemHeader()), - anyOf(hasName("std"), hasName("posix")), + hasAnyName("std", "posix"), has(decl(unless(anyOf( functionDecl(isExplicitTemplateSpecialization()), cxxRecordDecl(isExplicitTemplateSpecialization())))))) diff --git a/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp b/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp index dd7f76370887..13646ccbafa6 100644 --- a/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp @@ -42,14 +42,13 @@ void PreferIsaOrDynCastInConditionalsCheck::registerMatchers( auto CallExpression = callExpr( - allOf(unless(isMacroID()), unless(cxxMemberCallExpr()), - allOf(callee(namedDecl(anyOf(hasName("isa"), hasName("cast"), - hasName("cast_or_null"), - hasName("dyn_cast"), - hasName("dyn_cast_or_null"))) - .bind("func")), - hasArgument(0, anyOf(declRefExpr().bind("arg"), - cxxMemberCallExpr().bind("arg")))))) + allOf( + unless(isMacroID()), unless(cxxMemberCallExpr()), + allOf(callee(namedDecl(hasAnyName("isa", "cast", "cast_or_null", + "dyn_cast", "dyn_cast_or_null")) + .bind("func")), + hasArgument(0, anyOf(declRefExpr().bind("arg"), + cxxMemberCallExpr().bind("arg")))))) .bind("rhs"); Finder->addMatcher( diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp index 2156cd73d7c8..63f9f066f194 100644 --- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp @@ -645,8 +645,7 @@ void AvoidBindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { void AvoidBindCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( callExpr( - callee(namedDecl( - anyOf(hasName("::boost::bind"), hasName("::std::bind")))), + callee(namedDecl(hasAnyName("::boost::bind", "::std::bind"))), hasArgument( 0, anyOf(expr(hasType(memberPointerType())).bind("ref"), expr(hasParent(materializeTemporaryExpr().bind("ref"))), diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index dd18d866e508..215ba341f21f 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -146,9 +146,8 @@ StatementMatcher makeArrayLoopMatcher() { /// - If the end iterator variable 'g' is defined, it is the same as 'f'. StatementMatcher makeIteratorLoopMatcher() { StatementMatcher BeginCallMatcher = - cxxMemberCallExpr( - argumentCountIs(0), - callee(cxxMethodDecl(anyOf(hasName("begin"), hasName("cbegin"))))) + cxxMemberCallExpr(argumentCountIs(0), + callee(cxxMethodDecl(hasAnyName("begin", "cbegin")))) .bind(BeginCallName); DeclarationMatcher InitDeclMatcher = @@ -162,8 +161,7 @@ StatementMatcher makeIteratorLoopMatcher() { varDecl(hasInitializer(anything())).bind(EndVarName); StatementMatcher EndCallMatcher = cxxMemberCallExpr( - argumentCountIs(0), - callee(cxxMethodDecl(anyOf(hasName("end"), hasName("cend"))))); + argumentCountIs(0), callee(cxxMethodDecl(hasAnyName("end", "cend")))); StatementMatcher IteratorBoundMatcher = expr(anyOf(ignoringParenImpCasts( @@ -280,8 +278,7 @@ StatementMatcher makePseudoArrayLoopMatcher() { )); StatementMatcher SizeCallMatcher = cxxMemberCallExpr( - argumentCountIs(0), - callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))), + argumentCountIs(0), callee(cxxMethodDecl(hasAnyName("size", "length"))), on(anyOf(hasType(pointsTo(RecordWithBeginEnd)), hasType(RecordWithBeginEnd)))); diff --git a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp index e0be718decb2..4182b51c02b0 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp @@ -541,14 +541,11 @@ static bool hasUnguardedAccess(const FieldDecl *FD, ProgramStateRef State) { auto FieldAccessM = memberExpr(hasDeclaration(equalsNode(FD))).bind("access"); auto AssertLikeM = callExpr(callee(functionDecl( - anyOf(hasName("exit"), hasName("panic"), hasName("error"), - hasName("Assert"), hasName("assert"), hasName("ziperr"), - hasName("assfail"), hasName("db_error"), hasName("__assert"), - hasName("__assert2"), hasName("_wassert"), hasName("__assert_rtn"), - hasName("__assert_fail"), hasName("dtrace_assfail"), - hasName("yy_fatal_error"), hasName("_XCAssertionFailureHandler"), - hasName("_DTAssertionFailureHandler"), - hasName("_TSAssertionFailureHandler"))))); + hasAnyName("exit", "panic", "error", "Assert", "assert", "ziperr", + "assfail", "db_error", "__assert", "__assert2", "_wassert", + "__assert_rtn", "__assert_fail", "dtrace_assfail", + "yy_fatal_error", "_XCAssertionFailureHandler", + "_DTAssertionFailureHandler", "_TSAssertionFailureHandler")))); auto NoReturnFuncM = callExpr(callee(functionDecl(isNoReturn()))); From cfe-commits at lists.llvm.org Tue Jul 7 06:34:41 2020 From: cfe-commits at lists.llvm.org (John Fastabend via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:34:41 +0000 (UTC) Subject: [PATCH] D83242: [RFC][BPF] support expr with typedef type for FIELD_EXISTENCE reloc In-Reply-To: References: Message-ID: <4e2b432311e28d0c12fe7db0179ae7e3@localhost.localdomain> jrfastab added a comment. Agreed also useful for us. I can pull it in and test if that is useful. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83242/new/ https://reviews.llvm.org/D83242 From cfe-commits at lists.llvm.org Tue Jul 7 06:36:24 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:36:24 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: jdoerfert marked an inline comment as done. jdoerfert added a comment. > I don't think gcc can be using this runtime library for nvptx. Yes, and: We are (going to) use clang specific intrinsics to avoid CUDA (soon). > Use of the new library with the previous version of the compiler. Except that you cannot generally expect this to work. In our supported use case the library is kept as bitcode (LLVM-IR). Bitcode is not backward compatible. An old toolchain (clang, llvm-link, ...) cannot be fed new IR and be expected to work. So, we are already not able to give a stability guarantee here, why pretend we do. The bitcode runtime has to be kept in-sync with the toolchain. ================ Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:42 - /// *outlined_function, int16_t - /// IsOMPRuntimeInitialized); OMPRTL_NVPTX__kmpc_kernel_prepare_parallel, ---------------- JonChesterfield wrote: > ABataev wrote: > > I think, instead the optimizer can try to detect if the runtime library is used by the kernel and switch this flag to `0` if no runtime calls are used in the kernel. For non-SPMD mode in most cases, the runtime is required, but in some cases, it can be disabled. > If we can detect that no runtime calls are used, we should be able to do better than passing a different argument. E.g. delete some setup calls. > > Failing that, if we want to pass an argument which says 'actually don't do any work', it shouldn't be the same argument used to check whether the runtime has been initialised. We can detect all we want but switching it *does not have any effect*. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:36:41 2020 From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:36:41 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <6ca33676f6970fcb2a608079255ca56b@localhost.localdomain> JonChesterfield added a comment. In D83268#2135938 , @ABataev wrote: > > @Hahnfeld @ABataev - are you sufficiently persuaded that preserving the current interface is not worth the development cost? > > No, I'm not. Long before that, we relied on the API stability and already have some runtime calls marked as deprecated. Especially taking into account, that libomp can be built separately. Yes, the existing v# naming and deprecated comments should also go. What can libomp be built by separately? Nvcc and gcc don't use this runtime. That leaves us with downstream proprietary compilers derived from clang that are already stuck carrying extensive compatibility patches and usually ship as one large toolchain blob which only needs to be internally self consistent. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:37:47 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:37:47 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <75af94adfeef8a349cbf80350687479b@localhost.localdomain> jdoerfert added a comment. > Especially taking into account, that libomp can be built separately. This is *not* affecting libomp in any way. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:37:55 2020 From: cfe-commits at lists.llvm.org (serge via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:37:55 +0000 (UTC) Subject: [PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush In-Reply-To: References: Message-ID: serge-sans-paille added a comment. Some nit-picking, lgtm otherwise. Please wait for @calixte review though :-) ================ Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c:49 dlerror(); - void (*gcov_flush1)() = (void (*)())dlsym(f1_handle, "__gcov_flush"); - if (gcov_flush1 == NULL) { - fprintf(stderr, "unable to find __gcov_flush in func.shared': %s\n", dlerror()); + void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset"); + if (gcov_reset1 == NULL) { ---------------- Do we also need to test gcov_flush symbol here too? ================ Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov:56 +// CHECK-NEXT: 1: 50: if (gcov_reset1 == NULL) { +// CHECK-NEXT: #####: 51: fprintf(stderr, "unable to find __gcov_reset in func.shared': %s\n", dlerror()); // CHECK-NEXT: #####: 52: return EXIT_FAILURE; ---------------- Same question here, what about gcov_flush symbol? ================ Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov:55 +// CHECK-NEXT: 1: 49: void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset"); +// CHECK-NEXT: 1: 50: if (gcov_reset1 == NULL) { +// CHECK-NEXT: #####: 51: fprintf(stderr, "unable to find __gcov_reset in func.shared': %s\n", dlerror()); ---------------- And here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83149/new/ https://reviews.llvm.org/D83149 From cfe-commits at lists.llvm.org Tue Jul 7 06:43:53 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:43:53 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <5a4d0c6716176b0918f2d199f6747f93@localhost.localdomain> arsenm added inline comments. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167 + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile) ---------------- yaxunl wrote: > yaxunl wrote: > > yaxunl wrote: > > > tra wrote: > > > > arsenm wrote: > > > > > yaxunl wrote: > > > > > > arsenm wrote: > > > > > > > arsenm wrote: > > > > > > > > yaxunl wrote: > > > > > > > > > arsenm wrote: > > > > > > > > > > I don't think the detection should fail if this is missing > > > > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken. > > > > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests > > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > > > > what is the directory structure of your most modern layout? > > > > > /opt/rocm/amdgcn/bitcode/foo.bc > > > > > > > > > > The plan is to remove this and rely on symlinks in the resource directory though > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it > > > > > > > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code. > > > > > > > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version. > > > > > > > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary. > > > > > > Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version. > > > > > > > > Currently clang includes some wrapper headers by default, which does not work with ROCm 3.5 since those device functions are defined in HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable including those wrapper headers. This is one example why we need detect HIP version. > I think we need to separate HIP runtime detection and device library detection and also separate hasValidHIPRuntime and hasValidDeviceLibrary. ROCm toolchain only need to make sure hasValidDeviceLibrary but HIP toolchain need both hasValidDeviceLibrary and hasValidHIPRuntime. Regardless of whether there's a version file or if does anything, I think the absence of one implies do the most modern thing CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Tue Jul 7 06:45:04 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:45:04 +0000 (UTC) Subject: [PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend In-Reply-To: References: Message-ID: <32c8916a16a8363b5dffd938a64439d2@localhost.localdomain> lei added inline comments. ================ Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:13791 + // Ensure that the load from the narrow width is being zero extended to i128. + if ((!ValidLDType) || (LD->getValueType(0) != MVT::i128) || + (LD->getExtensionType() != ISD::ZEXTLOAD)) ---------------- nit: don't need `()` aroud `!ValidLDType` ================ Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:13797 + // we are creating in order to pattern match to the appropriate instruction + // in the backend. + SDValue Width = DAG.getIntPtrConstant(MemoryType.getScalarSizeInBits(), dl); ---------------- I don't think we need to explicitly say this sine everything we do here is for pattern matching to appropriate instructions in the backend... ================ Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:13798 + // in the backend. + SDValue Width = DAG.getIntPtrConstant(MemoryType.getScalarSizeInBits(), dl); + SDValue LoadOps[] = {LD->getChain(), LD->getBasePtr(), Width}; ---------------- Can just merge this into the next line and remove this tmp value. ================ Comment at: llvm/test/CodeGen/PowerPC/p10-vsx-builtins.ll:6 +; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \ +; RUN: FileCheck %s + ---------------- Please add tests for BE. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82502/new/ https://reviews.llvm.org/D82502 From cfe-commits at lists.llvm.org Tue Jul 7 06:46:01 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:46:01 +0000 (UTC) Subject: [PATCH] D83301: [clang-tidy] More strict on matching the standard memset function in memset-usage check. Message-ID: hokein created this revision. hokein added a reviewer: gribozavr2. Herald added a subscriber: xazax.hun. Herald added a project: clang. The check assumed the matched function call has 3 arguments, but the matcher didn't guaranteed that. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83301 Files: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp @@ -75,3 +75,8 @@ // despite v == 0. memset(p, -1, v); } + +void *memset(int); +void NoCrash() { + memset(1); +} Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp @@ -20,11 +20,18 @@ namespace bugprone { void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) { - // Note: void *memset(void *buffer, int fill_char, size_t byte_count); + // Match the standard memset: + // void *memset(void *buffer, int fill_char, size_t byte_count); + auto MemsetDecl = + functionDecl(hasName("::memset"), + hasParameter(0, hasType(pointerType(pointee(voidType())))), + hasParameter(1, hasType(isInteger())), + hasParameter(2, hasType(isInteger()))); + // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended. Finder->addMatcher( callExpr( - callee(functionDecl(hasName("::memset"))), + callee(MemsetDecl), hasArgument(1, characterLiteral(equals(static_cast('0'))) .bind("char-zero-fill")), unless( @@ -36,14 +43,14 @@ // Look for memset with an integer literal in its fill_char argument. // Will check if it gets truncated. - Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))), + Finder->addMatcher(callExpr(callee(MemsetDecl), hasArgument(1, integerLiteral().bind("num-fill")), unless(isInTemplateInstantiation())), this); // Look for memset(x, y, 0) as that is most likely an argument swap. Finder->addMatcher( - callExpr(callee(functionDecl(hasName("::memset"))), + callExpr(callee(MemsetDecl), unless(hasArgument(1, anyOf(characterLiteral(equals( static_cast('0'))), integerLiteral()))), -------------- next part -------------- A non-text attachment was scrubbed... Name: D83301.276041.patch Type: text/x-patch Size: 2485 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 06:46:03 2020 From: cfe-commits at lists.llvm.org (Jeremy Morse via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:46:03 +0000 (UTC) Subject: [PATCH] D83048: [LiveDebugValues] 3/4 Add Xclang and CodeGen options for using instr-ref variable locations In-Reply-To: References: Message-ID: <9c92b5cd90c98f848aa95cc4cc260c00@localhost.localdomain> jmorse updated this revision to Diff 276040. jmorse added a comment. (Rebase, only affecting LiveDebugValues.cpp) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83048/new/ https://reviews.llvm.org/D83048 Files: clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Driver/CC1Options.td clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/CodeGen/CommandFlags.h llvm/include/llvm/Target/TargetOptions.h llvm/lib/CodeGen/CommandFlags.cpp llvm/lib/CodeGen/LiveDebugValues/LiveDebugValues.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83048.276040.patch Type: text/x-patch Size: 7337 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 06:46:42 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:46:42 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added a comment. In D83268#2135955 , @jdoerfert wrote: > > Especially taking into account, that libomp can be built separately. > > This is *not* affecting libomp in any way. libomptarget and device runtimes are part of libomp. If you're going to remove some params, you'll need to modify the runtime functions too, no? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:47:42 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:47:42 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <1cb89fe40acdc399e6b7aef1055455a8@localhost.localdomain> ABataev added a comment. In D83268#2135954 , @JonChesterfield wrote: > In D83268#2135938 , @ABataev wrote: > > > > @Hahnfeld @ABataev - are you sufficiently persuaded that preserving the current interface is not worth the development cost? > > > > No, I'm not. Long before that, we relied on the API stability and already have some runtime calls marked as deprecated. Especially taking into account, that libomp can be built separately. > > > Yes, the existing v# naming and deprecated comments should also go. > > What can libomp be built by separately? Nvcc and gcc don't use this runtime. That leaves us with downstream proprietary compilers derived from clang that are already stuck carrying extensive compatibility patches and usually ship as one large toolchain blob which only needs to be internally self consistent. Answered already: the previous version of the compiler with the new version of the runtime. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:48:46 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 13:48:46 +0000 (UTC) Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker In-Reply-To: References: Message-ID: <611967e13f427162dd6eb4fd7d723efb@localhost.localdomain> balazske added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:27 + : public Checker> { + mutable std::unique_ptr BT; + ---------------- The bug type can be initialized here: `BT{this, "...", "..."}` How did this compile with only one text argument to constructor? I think the first is a short name of the bug, second is a category that is not omittable. The text that is used here should be passed to the `BugReport`. `BugType::getDescription` returns the "name" of the bug that is the first argument. But I am not sure what matters from these texts, the code design looks confusing. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:50 + if (isa(Index->IgnoreParenCasts())) + return; + ---------------- `if (isa(Index))` should be used. `IntegerLiteral` is a subclass of `Expr`, not a `QualType`. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:72 + llvm::APSInt::getMaxValue(C.getASTContext().getIntWidth(IndexType), + IndexType->isUnsignedIntegerType()); + const nonloc::ConcreteInt MaxIndexValue{MaxIndex}; ---------------- I would use `SVB.getBasicValueFactory().getMaxValue(IndexType)` to get the max value. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:82 + SVB.evalBinOp(State, BO_Sub, SizeInElements, ConstantOne, + C.getASTContext().UnsignedLongLongTy); + ---------------- `SValBuilder::getArrayIndexType` should be better than the `UnsignedLongLongTy`. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:86 + const SVal TypeCanIndexEveryElement = SVB.evalBinOp( + State, BO_LE, SizeInElementsMinusOne, MaxIndexValue, IndexType); + ---------------- I think `SVB.getConditionType()` should be used for condition result. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:121 + // Mark the array expression interesting. + R->markInteresting(FirstElement->getSuperRegion()); + C.emitReport(std::move(R)); ---------------- I am not sure if this `markInteresting` call is correct. ================ Comment at: clang/test/Analysis/sufficient-size-array-indexing-32bit.c:37 +const short two_byte_signed_index = 1; // sizeof(short) == 2 +const int four_byte_signed_index = 1; // sizeof(int) == 4 + ---------------- I do not know if it is safe to make such assumptions about `sizeof`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69318/new/ https://reviews.llvm.org/D69318 From cfe-commits at lists.llvm.org Tue Jul 7 06:48:52 2020 From: cfe-commits at lists.llvm.org (Joel E. Denny via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:48:52 +0000 (UTC) Subject: [PATCH] D83057: [OpenMP][NFC] Remove hard-coded line numbers from more tests In-Reply-To: References: Message-ID: <0cfd1c5348fefdcbb3827d66e4234c47@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGed39becd274d: [OpenMP][NFC] Remove hard-coded line numbers from more tests (authored by jdenny). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83057/new/ https://reviews.llvm.org/D83057 Files: clang/test/OpenMP/target_defaultmap_codegen.cpp clang/test/OpenMP/target_map_codegen.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83057.276043.patch Type: text/x-patch Size: 18524 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 06:48:53 2020 From: cfe-commits at lists.llvm.org (Joel E. Denny via cfe-commits) Date: Tue, 07 Jul 2020 06:48:53 -0700 (PDT) Subject: [clang] ed39bec - [OpenMP][NFC] Remove hard-coded line numbers from more tests Message-ID: <5f047d45.1c69fb81.45879.1f6b@mx.google.com> Author: Joel E. Denny Date: 2020-07-07T09:48:22-04:00 New Revision: ed39becd274dae5537c24b2107737d718527e718 URL: https://github.com/llvm/llvm-project/commit/ed39becd274dae5537c24b2107737d718527e718 DIFF: https://github.com/llvm/llvm-project/commit/ed39becd274dae5537c24b2107737d718527e718.diff LOG: [OpenMP][NFC] Remove hard-coded line numbers from more tests This is a continuation of D82224. Reviewed By: grokos Differential Revision: https://reviews.llvm.org/D83057 Added: Modified: clang/test/OpenMP/target_defaultmap_codegen.cpp clang/test/OpenMP/target_map_codegen.cpp Removed: ################################################################################ diff --git a/clang/test/OpenMP/target_defaultmap_codegen.cpp b/clang/test/OpenMP/target_defaultmap_codegen.cpp index 140574c18c74..3deff63273d5 100644 --- a/clang/test/OpenMP/target_defaultmap_codegen.cpp +++ b/clang/test/OpenMP/target_defaultmap_codegen.cpp @@ -20,7 +20,7 @@ // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY10 %s // SIMD-ONLY10-NOT: {{__kmpc|__tgt}} -// CK1-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l44.region_id = weak constant i8 0 +// CK1-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK1-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 @@ -70,7 +70,7 @@ void implicit_maps_double_complex (int a){ // SIMD-ONLY10-NOT: {{__kmpc|__tgt}} #ifdef CK2 -// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l94.region_id = weak constant i8 0 +// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK2-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_TO | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545 @@ -120,7 +120,7 @@ void implicit_maps_double_complex (int a){ // SIMD-ONLY10-NOT: {{__kmpc|__tgt}} #ifdef CK3 -// CK3-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l144.region_id = weak constant i8 0 +// CK3-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546 @@ -173,7 +173,7 @@ void implicit_maps_double_complex (int a){ // For a 32-bit targets, the value doesn't fit the size of the pointer, // therefore it is passed by reference with a map 'to' specification. -// CK4-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l209.region_id = weak constant i8 0 +// CK4-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK4-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -242,7 +242,7 @@ void implicit_maps_double (int a){ // SIMD-ONLY8-NOT: {{__kmpc|__tgt}} #ifdef CK5 -// CK5-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l266.region_id = weak constant i8 0 +// CK5-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK5-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 @@ -293,7 +293,7 @@ void implicit_maps_array (int a){ // SIMD-ONLY8-NOT: {{__kmpc|__tgt}} #ifdef CK6 -// CK6-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l317.region_id = weak constant i8 0 +// CK6-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK6-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_TO | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545 @@ -344,7 +344,7 @@ void implicit_maps_array (int a){ // SIMD-ONLY8-NOT: {{__kmpc|__tgt}} #ifdef CK7 -// CK7-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l368.region_id = weak constant i8 0 +// CK7-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK7-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546 @@ -395,7 +395,7 @@ void implicit_maps_array (int a){ // SIMD-ONLY8-NOT: {{__kmpc|__tgt}} #ifdef CK8 -// CK8-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l419.region_id = weak constant i8 0 +// CK8-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK8-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_TO | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 @@ -498,7 +498,7 @@ void zero_size_section_and_private_maps (int ii){ #ifdef CK10 -// CK10-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l523.region_id = weak constant i8 0 +// CK10-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK10: [[SIZE:@.+]] = private {{.*}}constant [1 x i64] [i64 {{8|4}}] // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 @@ -546,7 +546,7 @@ void explicit_maps_single (){ #ifdef CK11 -// CK11-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l571.region_id = weak constant i8 0 +// CK11-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK11: [[SIZE09:@.+]] = private {{.*}}constant [1 x i64] [i64 {{8|4}}] // Map types: OMP_MAP_TO | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545 @@ -594,7 +594,7 @@ void explicit_maps_single (){ #ifdef CK12 -// CK12-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l619.region_id = weak constant i8 0 +// CK12-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK12: [[SIZE09:@.+]] = private {{.*}}constant [1 x i64] [i64 {{8|4}}] // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546 @@ -642,7 +642,7 @@ void explicit_maps_single (){ #ifdef CK13 -// CK13-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l667.region_id = weak constant i8 0 +// CK13-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK13: [[SIZE09:@.+]] = private {{.*}}constant [1 x i64] [i64 {{8|4}}] // Map types: OMP_MAP_TO | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 @@ -690,7 +690,7 @@ void explicit_maps_single (){ #ifdef CK14 -// CK14-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l715.region_id = weak constant i8 0 +// CK14-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK14: [[SIZE09:@.+]] = private {{.*}}constant [1 x i64] zeroinitializer // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 @@ -737,7 +737,7 @@ void explicit_maps_single (){ // SIMD-ONLY12-NOT: {{__kmpc|__tgt}} #ifdef CK15 -// CK15-LABEL: @.__omp_offloading_{{.*}}implicit_maps_variable_length_array{{.*}}_l787.region_id = weak constant i8 0 +// CK15-LABEL: @.__omp_offloading_{{.*}}implicit_maps_variable_length_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // We don't have a constant map size for VLAs. // Map types: @@ -820,7 +820,7 @@ void implicit_maps_variable_length_array (int a){ #ifdef CK16 // CK16-DAG: [[ST:%.+]] = type { i32, double } -// CK16-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l849.region_id = weak constant i8 0 +// CK16-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK16-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 {{16|12}}] // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 // CK16-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 544] @@ -877,7 +877,7 @@ void implicit_maps_struct (int a){ #ifdef CK17 // CK17-DAG: [[ST:%.+]] = type { i32, double } -// CK17-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l906.region_id = weak constant i8 0 +// CK17-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK17-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 {{16|12}}] // Map types: OMP_MAP_TO | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 545 // CK17-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 545] @@ -934,7 +934,7 @@ void implicit_maps_struct (int a){ #ifdef CK18 // CK18-DAG: [[ST:%.+]] = type { i32, double } -// CK18-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l963.region_id = weak constant i8 0 +// CK18-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK18-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 {{16|12}}] // Map types: OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 546 // CK18-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 546] @@ -991,7 +991,7 @@ void implicit_maps_struct (int a){ #ifdef CK19 // CK19-DAG: [[ST:%.+]] = type { i32, double } -// CK19-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l1020.region_id = weak constant i8 0 +// CK19-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK19-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 {{16|12}}] // Map types: OMP_MAP_TO | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 // CK19-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 547] @@ -1050,7 +1050,7 @@ void implicit_maps_struct (int a){ // For a 32-bit targets, the value doesn't fit the size of the pointer, // therefore it is passed by reference with a map 'to' specification. -// CK20-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l1086.region_id = weak constant i8 0 +// CK20-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK20-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8] // Map types: OMP_MAP_LITERAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -1120,7 +1120,7 @@ void implicit_maps_double (int a){ #ifdef CK21 // CK21-DAG: [[ST:%.+]] = type { i32, double } -// CK21-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l1149.region_id = weak constant i8 0 +// CK21-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK21-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 {{16|12}}] // Map types: OMP_MAP_TO + OMP_MAP_FROM + OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 // CK21-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 547] @@ -1176,7 +1176,7 @@ void implicit_maps_struct (int a){ // SIMD-ONLY9-NOT: {{__kmpc|__tgt}} #ifdef CK22 -// CK22-LABEL: @.__omp_offloading_{{.*}}implicit_maps_pointer{{.*}}_l1200.region_id = weak constant i8 0 +// CK22-LABEL: @.__omp_offloading_{{.*}}implicit_maps_pointer{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK22-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] zeroinitializer // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 @@ -1413,11 +1413,11 @@ void bar(float *&a, int *&b) { // SIMD-ONLY18-NOT: {{__kmpc|__tgt}} #ifdef CK24 -// CK24-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1443.region_id = weak constant i8 0 +// CK24-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK24: [[SIZE00:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] [i[[Z:64|32]] 4] // CK24: [[MTYPE00:@.+]] = private {{.*}}constant [1 x i64] [i64 1059] -// CK24-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l1462.region_id = weak constant i8 0 +// CK24-LABEL: @.__omp_offloading_{{.*}}explicit_maps_single{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK24: [[SIZE01:@.+]] = private {{.*}}constant [1 x i[[Z:64|32]]] [i[[Z:64|32]] 4] // CK24: [[MTYPE01:@.+]] = private {{.*}}constant [1 x i64] [i64 1063] @@ -1488,7 +1488,7 @@ void explicit_maps_single (int ii){ extern int x; #pragma omp declare target to(x) -// CK25-LABEL: @.__omp_offloading_{{.*}}declare_target_to{{.*}}_l1499.region_id = weak constant i8 0 +// CK25-LABEL: @.__omp_offloading_{{.*}}declare_target_to{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 void declare_target_to() { diff --git a/clang/test/OpenMP/target_map_codegen.cpp b/clang/test/OpenMP/target_map_codegen.cpp index 3c34222939f0..92e0224a2de3 100644 --- a/clang/test/OpenMP/target_map_codegen.cpp +++ b/clang/test/OpenMP/target_map_codegen.cpp @@ -39,7 +39,7 @@ class B { }; double B::VAR = 1.0; -// CK1-LABEL: @.__omp_offloading_{{.*}}implicit_maps_integer{{.*}}_l68.region_id = weak constant i8 0 +// CK1-LABEL: @.__omp_offloading_{{.*}}implicit_maps_integer{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK1-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -98,12 +98,12 @@ void implicit_maps_integer (int a){ // SIMD-ONLY1-NOT: {{__kmpc|__tgt}} #ifdef CK2 -// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_reference{{.*}}_l128.region_id = weak constant i8 0 +// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_reference{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK2: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 // CK2: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 800] -// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_reference{{.*}}_l147.region_id = weak constant i8 0 +// CK2-LABEL: @.__omp_offloading_{{.*}}implicit_maps_reference{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK2: [[SIZES2:@.+]] = {{.+}}constant [1 x i64] zeroinitializer // Map types: OMP_MAP_IS_PTR | OMP_MAP_IMPLICIT = 544 // CK2: [[TYPES2:@.+]] = {{.+}}constant [1 x i64] [i64 544] @@ -188,7 +188,7 @@ void implicit_maps_reference (int a, int *b){ // SIMD-ONLY2-NOT: {{__kmpc|__tgt}} #ifdef CK3 -// CK3-LABEL: @.__omp_offloading_{{.*}}implicit_maps_parameter{{.*}}_l214.region_id = weak constant i8 0 +// CK3-LABEL: @.__omp_offloading_{{.*}}implicit_maps_parameter{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK3-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -242,7 +242,7 @@ void implicit_maps_parameter (int a){ // SIMD-ONLY3-NOT: {{__kmpc|__tgt}} #ifdef CK4 -// CK4-LABEL: @.__omp_offloading_{{.*}}implicit_maps_nested_integer{{.*}}_l276.region_id = weak constant i8 0 +// CK4-LABEL: @.__omp_offloading_{{.*}}implicit_maps_nested_integer{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK4-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -308,7 +308,7 @@ void implicit_maps_nested_integer (int a){ // SIMD-ONLY4-NOT: {{__kmpc|__tgt}} #ifdef CK5 -// CK5-LABEL: @.__omp_offloading_{{.*}}implicit_maps_nested_integer_and_enum{{.*}}_l340.region_id = weak constant i8 0 +// CK5-LABEL: @.__omp_offloading_{{.*}}implicit_maps_nested_integer_and_enum{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK5-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -368,7 +368,7 @@ void implicit_maps_nested_integer_and_enum (int a){ // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck -allow-deprecated-dag-overlap --check-prefix SIMD-ONLY5 %s // SIMD-ONLY5-NOT: {{__kmpc|__tgt}} #ifdef CK6 -// CK6-LABEL: @.__omp_offloading_{{.*}}implicit_maps_host_global{{.*}}_l397.region_id = weak constant i8 0 +// CK6-LABEL: @.__omp_offloading_{{.*}}implicit_maps_host_global{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK6-DAG: [[GBL:@Gi]] = global i32 0 // CK6-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] @@ -428,7 +428,7 @@ void implicit_maps_host_global (int a){ // For a 32-bit targets, the value doesn't fit the size of the pointer, // therefore it is passed by reference with a map 'to' specification. -// CK7-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l464.region_id = weak constant i8 0 +// CK7-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK7-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -497,7 +497,7 @@ void implicit_maps_double (int a){ // SIMD-ONLY7-NOT: {{__kmpc|__tgt}} #ifdef CK8 -// CK8-LABEL: @.__omp_offloading_{{.*}}implicit_maps_float{{.*}}_l524.region_id = weak constant i8 0 +// CK8-LABEL: @.__omp_offloading_{{.*}}implicit_maps_float{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK8-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 4] // Map types: OMP_MAP_PRIVATE_VAL | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -551,7 +551,7 @@ void implicit_maps_float (int a){ // SIMD-ONLY8-NOT: {{__kmpc|__tgt}} #ifdef CK9 -// CK9-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l575.region_id = weak constant i8 0 +// CK9-LABEL: @.__omp_offloading_{{.*}}implicit_maps_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK9-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 16] // Map types: OMP_MAP_TO + OMP_MAP_FROM + OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 @@ -602,7 +602,7 @@ void implicit_maps_array (int a){ // SIMD-ONLY9-NOT: {{__kmpc|__tgt}} #ifdef CK10 -// CK10-LABEL: @.__omp_offloading_{{.*}}implicit_maps_pointer{{.*}}_l626.region_id = weak constant i8 0 +// CK10-LABEL: @.__omp_offloading_{{.*}}implicit_maps_pointer{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK10-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] zeroinitializer // Map types: OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 544 @@ -654,7 +654,7 @@ void implicit_maps_pointer (){ // SIMD-ONLY10-NOT: {{__kmpc|__tgt}} #ifdef CK11 -// CK11-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l678.region_id = weak constant i8 0 +// CK11-LABEL: @.__omp_offloading_{{.*}}implicit_maps_double_complex{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK11-DAG: [[SIZES:@.+]] = {{.+}}constant [2 x i64] [i64 16, i64 {{8|4}}] // Map types: OMP_MAP_TO | OMP_MAP_FROM | OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 @@ -707,7 +707,7 @@ void implicit_maps_double_complex (int a, int *b){ // For a 32-bit targets, the value doesn't fit the size of the pointer, // therefore it is passed by reference with a map 'to' specification. -// CK12-LABEL: @.__omp_offloading_{{.*}}implicit_maps_float_complex{{.*}}_l743.region_id = weak constant i8 0 +// CK12-LABEL: @.__omp_offloading_{{.*}}implicit_maps_float_complex{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK12-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 8] // Map types: OMP_MAP_PRIVATE_VAL + OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 800 @@ -775,7 +775,7 @@ void implicit_maps_float_complex (int a){ // SIMD-ONLY12-NOT: {{__kmpc|__tgt}} #ifdef CK13 -// CK13-LABEL: @.__omp_offloading_{{.*}}implicit_maps_variable_length_array{{.*}}_l825.region_id = weak constant i8 0 +// CK13-LABEL: @.__omp_offloading_{{.*}}implicit_maps_variable_length_array{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // We don't have a constant map size for VLAs. // Map types: @@ -859,7 +859,7 @@ void implicit_maps_variable_length_array (int a){ // CK14-DAG: [[ST:%.+]] = type { i32, double } -// CK14-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}_l877.region_id = weak constant i8 0 +// CK14-LABEL: @.__omp_offloading_{{.*}}foo{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // Map types: @@ -1207,7 +1207,7 @@ void implicit_maps_templated_function (int a){ #ifdef CK17 // CK17-DAG: [[ST:%.+]] = type { i32, double } -// CK17-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l1236.region_id = weak constant i8 0 +// CK17-LABEL: @.__omp_offloading_{{.*}}implicit_maps_struct{{.*}}_l{{[0-9]+}}.region_id = weak constant i8 0 // CK17-DAG: [[SIZES:@.+]] = {{.+}}constant [1 x i64] [i64 {{16|12}}] // Map types: OMP_MAP_TO + OMP_MAP_FROM + OMP_MAP_TARGET_PARAM | OMP_MAP_IMPLICIT = 547 // CK17-DAG: [[TYPES:@.+]] = {{.+}}constant [1 x i64] [i64 547] From cfe-commits at lists.llvm.org Tue Jul 7 06:50:58 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:50:58 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <674acf42a1ffd2f971097300e7345000@localhost.localdomain> jdoerfert added a comment. In D83268#2135989 , @ABataev wrote: > In D83268#2135954 , @JonChesterfield wrote: > > > What can libomp be built by separately? Nvcc and gcc don't use this runtime. That leaves us with downstream proprietary compilers derived from clang that are already stuck carrying extensive compatibility patches and usually ship as one large toolchain blob which only needs to be internally self consistent. > > > Answered already: the previous version of the compiler with the new version of the runtime. Still cannot be expected to work: https://reviews.llvm.org/D83268#2135951 Are there other use cases? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:53:05 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:53:05 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: jdoerfert added a comment. In D83268#2135988 , @ABataev wrote: > In D83268#2135955 , @jdoerfert wrote: > > > > Especially taking into account, that libomp can be built separately. > > > > This is *not* affecting libomp in any way. > > > libomptarget and device runtimes are part of libomp. If you're going to remove some params, you'll need to modify the runtime functions too, no? No they are not. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:54:37 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:54:37 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added a comment. In D83268#2136021 , @jdoerfert wrote: > In D83268#2135988 , @ABataev wrote: > > > In D83268#2135955 , @jdoerfert wrote: > > > > > > Especially taking into account, that libomp can be built separately. > > > > > > This is *not* affecting libomp in any way. > > > > > > libomptarget and device runtimes are part of libomp. If you're going to remove some params, you'll need to modify the runtime functions too, no? > > > No they are not. `llvm-project/openmp/libomptarget` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:55:10 2020 From: cfe-commits at lists.llvm.org (Joel E. Denny via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:55:10 +0000 (UTC) Subject: [PATCH] D83057: [OpenMP][NFC] Remove hard-coded line numbers from more tests In-Reply-To: References: Message-ID: <6ed2b569a410c58f21e95eba4ac093d1@localhost.localdomain> jdenny added a comment. Thanks for the quick review. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83057/new/ https://reviews.llvm.org/D83057 From cfe-commits at lists.llvm.org Tue Jul 7 06:56:41 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:56:41 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added a comment. In D83268#2135951 , @jdoerfert wrote: > > I don't think gcc can be using this runtime library for nvptx. > > Yes, and: We are (going to) use clang specific intrinsics to avoid CUDA (soon). > > > Use of the new library with the previous version of the compiler. > > Except that you cannot generally expect this to work. In our supported use case the library is kept as bitcode (LLVM-IR). Bitcode is not backward compatible. An old toolchain (clang, llvm-link, ...) cannot be fed new IR and be expected to work. So, we are already not able to give a stability guarantee here, why pretend we do. The bitcode runtime has to be kept in-sync with the toolchain. There is still compatibility between clang10 and clang11. Or they are incompatible in LLVM IR level? Also, there was a mode (I don't remember if it was removed or not) where the runtime library could be linked as `.a` library, without LLVM IR inlining. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 06:59:40 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 13:59:40 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <15aae2f23c2cbc4ad40373217bd87561@localhost.localdomain> jdoerfert added a comment. In D83268#2136031 , @ABataev wrote: > There is still compatibility between clang10 and clang11. Or they are incompatible in LLVM IR level? That is the point. They might or might not be, right? There is no guarantee they are. > Also, there was a mode (I don't remember if it was removed or not) where the runtime library could be linked as `.a` library, without LLVM IR inlining. That mode is deprecated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 07:00:23 2020 From: cfe-commits at lists.llvm.org (Joel E. Denny via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:00:23 +0000 (UTC) Subject: [PATCH] D83057: [OpenMP][NFC] Remove hard-coded line numbers from more tests In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGed39becd274d: [OpenMP][NFC] Remove hard-coded line numbers from more tests (authored by jdenny). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83057/new/ https://reviews.llvm.org/D83057 Files: clang/test/OpenMP/target_defaultmap_codegen.cpp clang/test/OpenMP/target_map_codegen.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83057.275661.patch Type: text/x-patch Size: 18524 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 07:00:38 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:00:38 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: jdoerfert added a comment. In D83268#2136029 , @ABataev wrote: > `llvm-project/openmp/libomptarget` Please use more words. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 07:01:15 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:01:15 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <839dbeaf2ca28a50c19f8c3071bd94bc@localhost.localdomain> ABataev added a comment. In D83268#2136054 , @jdoerfert wrote: > In D83268#2136029 , @ABataev wrote: > > > `llvm-project/openmp/libomptarget` > > > Please use more words. libomptarget is part of libomp Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 07:04:22 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:04:22 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: ABataev added a comment. In D83268#2136049 , @jdoerfert wrote: > In D83268#2136031 , @ABataev wrote: > > > There is still compatibility between clang10 and clang11. Or they are incompatible in LLVM IR level? > > > That is the point. They might or might not be, right? There is no guarantee they are. Better to ask the users. Maybe, send an RFC to openmp-devs? > > >> Also, there was a mode (I don't remember if it was removed or not) where the runtime library could be linked as `.a` library, without LLVM IR inlining. > > That mode is deprecated. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 07:07:33 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:07:33 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: jdoerfert added a comment. In D83268#2136055 , @ABataev wrote: > In D83268#2136054 , @jdoerfert wrote: > > > In D83268#2136029 , @ABataev wrote: > > > > > `llvm-project/openmp/libomptarget` > > > > > > Please use more words. > > > libomptarget is part of libomp As mentioned before, no it is not. Despite the similarity in name, libomp and libomptarget are distinct libraries, this was a conscious design choice. FWIW, this patch does *not* modify libomptarget either. This modifies *the device runtime*, aka. libomptarget-nvptx-sm_XXX.bc. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 07:07:35 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:07:35 +0000 (UTC) Subject: [PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization In-Reply-To: References: Message-ID: <328025d1b47fcb5c1d424ba31d48a638@localhost.localdomain> aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM, this seems like a pretty clean solution. Thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80301/new/ https://reviews.llvm.org/D80301 From cfe-commits at lists.llvm.org Tue Jul 7 07:12:04 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:12:04 +0000 (UTC) Subject: [PATCH] D80897: [OpenMP] Initial support for std::complex in target regions In-Reply-To: References: Message-ID: jdoerfert updated this revision to Diff 276053. jdoerfert marked an inline comment as done. jdoerfert added a comment. Addressed comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80897/new/ https://reviews.llvm.org/D80897 Files: clang/lib/Headers/CMakeLists.txt clang/lib/Headers/__clang_cuda_complex_builtins.h clang/lib/Headers/__clang_cuda_math.h clang/lib/Headers/openmp_wrappers/complex clang/lib/Headers/openmp_wrappers/complex.h clang/test/Headers/Inputs/include/cmath clang/test/Headers/Inputs/include/complex clang/test/Headers/Inputs/include/cstdlib clang/test/Headers/nvptx_device_math_complex.c clang/test/Headers/nvptx_device_math_complex.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D80897.276053.patch Type: text/x-patch Size: 30112 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 07:21:05 2020 From: cfe-commits at lists.llvm.org (Jonas Hahnfeld via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:21:05 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <66cc765ee6c473de8742d0ae31e1c0ce@localhost.localdomain> Hahnfeld added a comment. In D83268#2135930 , @JonChesterfield wrote: > Aside from the API stability concern this looks uncontentious. Removes dead arguments, generally makes things simpler. Thus LGTM. > > @Hahnfeld @ABataev - are you sufficiently persuaded that preserving the current interface is not worth the development cost? I'm neither, and I've long argued that being able to build the OpenMP runtime(s) without Clang trunk is an important use case. These arguments have gone largely unheard, so I'll not join this discussion once more. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 07:22:12 2020 From: cfe-commits at lists.llvm.org (=?UTF-8?B?QmFsw6F6cyBLw6lyaQ==?= via cfe-commits) Date: Tue, 07 Jul 2020 07:22:12 -0700 (PDT) Subject: [clang] 85f5d12 - [ASTImporter] Corrected import of repeated friend declarations. Message-ID: <5f048514.1c69fb81.2e511.6c4a@mx.google.com> Author: Balázs Kéri Date: 2020-07-07T16:24:24+02:00 New Revision: 85f5d1261c9a3f0abc4ae370005a1127174f2ce1 URL: https://github.com/llvm/llvm-project/commit/85f5d1261c9a3f0abc4ae370005a1127174f2ce1 DIFF: https://github.com/llvm/llvm-project/commit/85f5d1261c9a3f0abc4ae370005a1127174f2ce1.diff LOG: [ASTImporter] Corrected import of repeated friend declarations. Summary: Import declarations in correct order if a class contains multiple redundant friend (type or decl) declarations. If the order is incorrect this could cause false structural equivalences and wrong declaration chains after import. Reviewers: a.sidorin, shafik, a_sidorin Reviewed By: shafik Subscribers: dkrupp, Szelethus, gamesh411, teemperor, martong, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D75740 Added: Modified: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index a47be2da4aab..8ec6db622f0a 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -3646,6 +3646,54 @@ ExpectedDecl ASTNodeImporter::VisitIndirectFieldDecl(IndirectFieldDecl *D) { return ToIndirectField; } +/// Used as return type of getFriendCountAndPosition. +struct FriendCountAndPosition { + /// Number of similar looking friends. + unsigned int TotalCount; + /// Index of the specific FriendDecl. + unsigned int IndexOfDecl; +}; + +template +FriendCountAndPosition getFriendCountAndPosition( + const FriendDecl *FD, + std::function GetCanTypeOrDecl) { + unsigned int FriendCount = 0; + llvm::Optional FriendPosition; + const auto *RD = cast(FD->getLexicalDeclContext()); + + T TypeOrDecl = GetCanTypeOrDecl(FD); + + for (const FriendDecl *FoundFriend : RD->friends()) { + if (FoundFriend == FD) { + FriendPosition = FriendCount; + ++FriendCount; + } else if (!FoundFriend->getFriendDecl() == !FD->getFriendDecl() && + GetCanTypeOrDecl(FoundFriend) == TypeOrDecl) { + ++FriendCount; + } + } + + assert(FriendPosition && "Friend decl not found in own parent."); + + return {FriendCount, *FriendPosition}; +} + +FriendCountAndPosition getFriendCountAndPosition(const FriendDecl *FD) { + if (FD->getFriendType()) + return getFriendCountAndPosition(FD, [](const FriendDecl *F) { + if (TypeSourceInfo *TSI = F->getFriendType()) + return TSI->getType().getCanonicalType(); + llvm_unreachable("Wrong friend object type."); + }); + else + return getFriendCountAndPosition(FD, [](const FriendDecl *F) { + if (Decl *D = F->getFriendDecl()) + return D->getCanonicalDecl(); + llvm_unreachable("Wrong friend object type."); + }); +} + ExpectedDecl ASTNodeImporter::VisitFriendDecl(FriendDecl *D) { // Import the major distinguishing characteristics of a declaration. DeclContext *DC, *LexicalDC; @@ -3654,25 +3702,37 @@ ExpectedDecl ASTNodeImporter::VisitFriendDecl(FriendDecl *D) { // Determine whether we've already imported this decl. // FriendDecl is not a NamedDecl so we cannot use lookup. - auto *RD = cast(DC); + // We try to maintain order and count of redundant friend declarations. + const auto *RD = cast(DC); FriendDecl *ImportedFriend = RD->getFirstFriend(); + SmallVector ImportedEquivalentFriends; while (ImportedFriend) { + bool Match = false; if (D->getFriendDecl() && ImportedFriend->getFriendDecl()) { - if (IsStructuralMatch(D->getFriendDecl(), ImportedFriend->getFriendDecl(), - /*Complain=*/false)) - return Importer.MapImported(D, ImportedFriend); - + Match = + IsStructuralMatch(D->getFriendDecl(), ImportedFriend->getFriendDecl(), + /*Complain=*/false); } else if (D->getFriendType() && ImportedFriend->getFriendType()) { - if (Importer.IsStructurallyEquivalent( - D->getFriendType()->getType(), - ImportedFriend->getFriendType()->getType(), true)) - return Importer.MapImported(D, ImportedFriend); + Match = Importer.IsStructurallyEquivalent( + D->getFriendType()->getType(), + ImportedFriend->getFriendType()->getType(), /*Complain=*/false); } + if (Match) + ImportedEquivalentFriends.push_back(ImportedFriend); + ImportedFriend = ImportedFriend->getNextFriend(); } + FriendCountAndPosition CountAndPosition = getFriendCountAndPosition(D); + + assert(ImportedEquivalentFriends.size() <= CountAndPosition.TotalCount && + "Class with non-matching friends is imported, ODR check wrong?"); + if (ImportedEquivalentFriends.size() == CountAndPosition.TotalCount) + return Importer.MapImported( + D, ImportedEquivalentFriends[CountAndPosition.IndexOfDecl]); // Not found. Create it. + // The declarations will be put into order later by ImportDeclContext. FriendDecl::FriendUnion ToFU; if (NamedDecl *FriendD = D->getFriendDecl()) { NamedDecl *ToFriendD; diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index d6a5afeeb489..f92ea8de1651 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -3974,6 +3974,56 @@ TEST_P(ImportFriendClasses, ImportOfClassDefinitionAndFwdFriendShouldBeLinked) { EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl()); } +TEST_P(ImportFriendClasses, ImportOfRepeatedFriendType) { + const char *Code = + R"( + class Container { + friend class X; + friend class X; + }; + )"; + Decl *ToTu = getToTuDecl(Code, Lang_CXX03); + Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc"); + + auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl()); + auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl()); + auto *FromFriend1 = + FirstDeclMatcher().match(FromTu, friendDecl()); + auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl()); + + FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03); + FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03); + + EXPECT_NE(ToImportedFriend1, ToImportedFriend2); + EXPECT_EQ(ToFriend1, ToImportedFriend1); + EXPECT_EQ(ToFriend2, ToImportedFriend2); +} + +TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) { + const char *Code = + R"( + class Container { + friend void f(); + friend void f(); + }; + )"; + Decl *ToTu = getToTuDecl(Code, Lang_CXX03); + Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc"); + + auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl()); + auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl()); + auto *FromFriend1 = + FirstDeclMatcher().match(FromTu, friendDecl()); + auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl()); + + FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03); + FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03); + + EXPECT_NE(ToImportedFriend1, ToImportedFriend2); + EXPECT_EQ(ToFriend1, ToImportedFriend1); + EXPECT_EQ(ToFriend2, ToImportedFriend2); +} + TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) { auto *Code = R"( template diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp b/clang/unittests/AST/StructuralEquivalenceTest.cpp index 08512d606279..2b5ce0fed51d 100644 --- a/clang/unittests/AST/StructuralEquivalenceTest.cpp +++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp @@ -759,6 +759,27 @@ TEST_F(StructuralEquivalenceRecordTest, RecordsWithDifferentBody) { EXPECT_FALSE(testStructuralMatch(t)); } +TEST_F(StructuralEquivalenceRecordTest, SameFriendMultipleTimes) { + auto t = makeNamedDecls("struct foo { friend class X; };", + "struct foo { friend class X; friend class X; };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, SameFriendsDifferentOrder) { + auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };", + "struct foo { friend class Y; friend class X; };", + Lang_CXX11); + EXPECT_FALSE(testStructuralMatch(t)); +} + +TEST_F(StructuralEquivalenceRecordTest, SameFriendsSameOrder) { + auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };", + "struct foo { friend class X; friend class Y; };", + Lang_CXX11); + EXPECT_TRUE(testStructuralMatch(t)); +} + struct StructuralEquivalenceLambdaTest : StructuralEquivalenceTest {}; TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentMethods) { From cfe-commits at lists.llvm.org Tue Jul 7 07:22:25 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 14:22:25 +0000 (UTC) Subject: [PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG85f5d1261c9a: [ASTImporter] Corrected import of repeated friend declarations. (authored by balazske). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75740/new/ https://reviews.llvm.org/D75740 Files: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D75740.276056.patch Type: text/x-patch Size: 7680 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 07:29:33 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:29:33 +0000 (UTC) Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute In-Reply-To: References: Message-ID: hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/CodeGen/TargetInfo.cpp:523 + if (isa(RT->getDecl())) { + if (!(AllowNoUniqueAddr && FD->hasAttr())) + return false; ---------------- Minor nit: The nested `if` could be merged with the outer one: ``` if (isa(RT->getDecl()) && !(AllowNoUniqueAddr && FD->hasAttr())) return false; ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81583/new/ https://reviews.llvm.org/D81583 From cfe-commits at lists.llvm.org Tue Jul 7 07:32:37 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 14:32:37 +0000 (UTC) Subject: [PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG85f5d1261c9a: [ASTImporter] Corrected import of repeated friend declarations. (authored by balazske). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75740/new/ https://reviews.llvm.org/D75740 Files: clang/lib/AST/ASTImporter.cpp clang/unittests/AST/ASTImporterTest.cpp clang/unittests/AST/StructuralEquivalenceTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D75740.275664.patch Type: text/x-patch Size: 7680 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Tue Jul 7 07:33:31 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:33:31 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: <5c199598ed0d5dad7454416ba0e5fe0b@localhost.localdomain> aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM with a testing request. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp:34 + const BlockDecl *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl(); + for (const BlockDecl::Capture &CapturedVar : EscapingBlockDecl->captures()) { + const VarDecl *Var = CapturedVar.getVariable(); ---------------- ellis wrote: > aaron.ballman wrote: > > This makes me think we should extend the `hasAnyCaptures()` AST matcher so it works with blocks as well as lambdas. It would be nice to do all of this from the matcher interface. > Should I add a TODO for this? Naw, I don't think it's that critical. I'm mostly just surprised we haven't done that before now given how similar blocks and lambdas are. ================ Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m:1 +// RUN: %check_clang_tidy %s bugprone-no-escape %t + ---------------- Can you add an additional RUN line so we get coverage of the blocks-enabled behavior? Something like: ``` // RUN: %check_clang_tidy %s bugprone-no-escape %t -- -- -fblocks -x c ``` I'm not 100% certain I have that syntax right, but the idea is to run the test as though it were a C compilation unit with blocks explicitly enabled. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Tue Jul 7 07:38:29 2020 From: cfe-commits at lists.llvm.org (Alexander Richardson via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:38:29 +0000 (UTC) Subject: [PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py In-Reply-To: References: Message-ID: <97e375991d060115d195b0367ef34567@localhost.localdomain> arichardson added a comment. @MaskRay are you okay with me committing this change and delaying the global search-replace? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78478/new/ https://reviews.llvm.org/D78478 From cfe-commits at lists.llvm.org Tue Jul 7 07:44:04 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 14:44:04 +0000 (UTC) Subject: [PATCH] D81552: [ASTMatchers] Added hasDirectBase Matcher In-Reply-To: References: Message-ID: <95700289de4e3f4f8368d0e5add94b18@localhost.localdomain> aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM with a whitespace nit. ================ Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:2895 + BaseSpecMatcher) { + + return Node.hasDefinition() && ---------------- Can remove the newline. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81552/new/ https://reviews.llvm.org/D81552 From cfe-commits at lists.llvm.org Tue Jul 7 07:46:29 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 14:46:29 +0000 (UTC) Subject: [PATCH] D81061: [Analyzer][VLASizeChecker] Fix problem with zero index assumption. In-Reply-To: References: Message-ID: balazske added a comment. Ping This is a better fix for the previous problem, and makes the code better too. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81061/new/ https://reviews.llvm.org/D81061 From cfe-commits at lists.llvm.org Tue Jul 7 08:00:38 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 15:00:38 +0000 (UTC) Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block In-Reply-To: References: Message-ID: njames93 added inline comments. ================ Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m:1 +// RUN: %check_clang_tidy %s bugprone-no-escape %t + ---------------- aaron.ballman wrote: > Can you add an additional RUN line so we get coverage of the blocks-enabled behavior? Something like: > ``` > // RUN: %check_clang_tidy %s bugprone-no-escape %t -- -- -fblocks -x c > ``` > I'm not 100% certain I have that syntax right, but the idea is to run the test as though it were a C compilation unit with blocks explicitly enabled. check_clang_tidy will add `-fobjc-abi-version=2`, `-fobjc-arc` and `-fblocks` if the file extension is `.m` or `.mm`. You can trick it with `assume-filename` to stop that happening ``` // RUN: %check_clang_tidy %s -assume-filename=bugprone-no-escape.c bugprone-no-escape %t -- -- -fblocks ``` Not 100% certain that is the right syntax but that feels like the designed way to run the test as a C compilation unit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82904/new/ https://reviews.llvm.org/D82904 From cfe-commits at lists.llvm.org Tue Jul 7 08:01:51 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 15:01:51 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <4cb21cbbd7c04d05fb830d40eb344a0a@localhost.localdomain> jdoerfert added a comment. In D83268#2136060 , @ABataev wrote: > Better to ask the users. Maybe, send an RFC to openmp-devs? Sure: http://lists.llvm.org/pipermail/openmp-dev/2020-July/003531.html Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 From cfe-commits at lists.llvm.org Tue Jul 7 08:02:00 2020 From: cfe-commits at lists.llvm.org (David Greene via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 15:02:00 +0000 (UTC) Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if asked In-Reply-To: References: Message-ID: greened marked an inline comment as done. greened added inline comments. ================ Comment at: llvm/utils/update_cc_test_checks.py:133 + parser.add_argument('--include-generated-funcs', action='store_true', + help='Output checks for functions not in source') parser.add_argument('tests', nargs='+') ---------------- jdoerfert wrote: > greened wrote: > > greened wrote: > > > jdoerfert wrote: > > > > I think this should go into common.py (after D78618). I would also make this the default but OK. > > > Yes I suppose it should in case `opt` and friends generate functions. I hadn't considered that use-case. > > > > > > While I would like to make it default unfortunately it would require updating a bunch of the existing clang tests which doesn't seem too friendly. See the patch update comment for details. > > > > > Just realized it wouldn't necessarily require regeneration of tests, it would just cause regenerated tests to change a lot when they are eventually regenerated. We should discuss as to whether that's acceptable. I think for now this should be non-default to at least get the functionality in without disturbing existing users and then we can discuss a separate change to make it default. > > > > It's also possible we could change how clang orders functions. I discovered there's a difference in clang 10 vs. 11 in the order functions are output when OpenMP outlining happens. clang 10 seems to preserve the source order of functions and clang 11 does not. Perhaps that needs to be fixed as I don't know whether that change was intentional or not. > Best case, without the option the original behavior is preserved. Is that not the case? That's right. I was referring to making this behavior default. If we do that, we could clean up the script code a bit but it would mean clang tests would change pretty dramatically when they are regenerated. If we fix the clang output, the test changes wouldn't be so dramatic. The way clang is behaving now, I would expect any tests that use `-fopenmp`, have multiple functions with OpenMP regions and use function prototypes for some of those functions would break given clang's reordering of function definitions. Perhaps we don't have any tests like that though. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83004/new/ https://reviews.llvm.org/D83004 From cfe-commits at lists.llvm.org Tue Jul 7 08:02:32 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Tue, 07 Jul 2020 15:02:32 +0000 (UTC) Subject: [PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'. In-Reply-To: References: Message-ID: balazske added a comment. The original plan was to enable the check for the functions listed in ERR33-C . But there are many other functions that work in similar way (like `mmap` that is not in the list but there is a request for similar check). The knowledge about what functions should be checked and how is built into the checker. Unless we find a way to specify this data in an external way, maybe as part of "summary" (if the summary contains extra information about what kind of return value indicates an error result). The current way of summary (`StdLibraryFunctionsChecker`) could be extended to make the summary data available for any checker. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72705/new/ https://reviews.llvm.org/D72705 From cfe-commits at lists.llvm.org Tue Jul 7 08:03:38 2020 From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 15:03:38 +0000 (UTC) Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang In-Reply-To: References: Message-ID: ABataev accepted this revision. ABataev added a comment. LGTM with a nit. ================ Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787 + if (getLangOpts().OpenMP < 51 && Kind == OMPC_default && + static_cast(Val.getValue().Type) == + OMP_DEFAULT_firstprivate) { ---------------- ABataev wrote: > No need for cast here. Still no need for the cast Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75591/new/ https://reviews.llvm.org/D75591 From cfe-commits at lists.llvm.org Tue Jul 7 08:04:10 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Tue, 07 Jul 2020 15:04:10 +0000 (UTC) Subject: [PATCH] D82278: Fix traversal over CXXConstructExpr in Syntactic mode In-Reply-To: References: Message-ID: <3eb337c71c5e26a90514c7e73638bd5b@localhost.localdomain> aaron.ballman added reviewers: rsmith, sammccall. aaron.ballman added inline comments. ================ Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp:80 auto Matches = - match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); + match(traverse(TK_AsIs, expr(hasDescendant(typeLoc().bind("t")))), *E, + *Result.Context); ---------------- While I believe the change is necessary here, it's not obvious to me what "hints" tell me this behavior is correct for the given matchers. None of the matchers look like they're going to care about implicit nodes, so how am I to know that AsIs is correct or not as a reviewer? As it stands, I sort of feel like I have to take it on faith that this change is correct and it looks a little suspicious because the code using the matcher is creating a fix-it at what now may be the location of an implicit node. ================ Comment at: clang/lib/AST/Expr.cpp:3001 Expr *A = C->getArg(0); - if (A->getSourceRange() == SR || !isa(C)) + if (A->getSourceRange() == SR || C->isElidable()) { E = A; ---------------- Looks like the change introduced new curly braces for a single-line if. ================ Comment at: clang/lib/AST/ParentMapContext.cpp:157 + if (auto *C = dyn_cast(E)) { + if (C->getSourceRange() == SR) ---------------- `const auto *` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82278/new/ https://reviews.llvm.org/D82278 From cfe-commits at lists.llvm.org Tue Jul 7 08:05:21 2020 From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits) Date: Tue, 07 Jul 2020 08:05:21 -0700 (PDT) Subject: [clang] b0d3ea1 - [ASTMatchers] Added hasDirectBase Matcher Message-ID: <5f048f31.1c69fb81.101c5.24a6@mx.google.com> Author: Nathan James Date: 2020-07-07T16:05:11+01:00 New Revision: b0d3ea171bd56b3b079be9213935925e1499df15 URL: https://github.com/llvm/llvm-project/commit/b0d3ea171bd56b3b079be9213935925e1499df15 DIFF: https://github.com/llvm/llvm-project/commit/b0d3ea171bd56b3b079be9213935925e1499df15.diff LOG: [ASTMatchers] Added hasDirectBase Matcher Adds a matcher called `hasDirectBase` for matching the `CXXBaseSpecifier` of a class that directly derives from another class. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D81552 Added: Modified: clang/docs/LibASTMatchersReference.html clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Removed: ################################################################################ diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 9c04322f0ae6..2256cbf71869 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -5658,7 +5658,7 @@

AST Traversal Matchers

Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
 
 Example:
-matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase")))))
+matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
   class Foo;
   class Bar : Foo {};
   class Baz : Bar {};
@@ -5670,6 +5670,20 @@ 

AST Traversal Matchers

+Matcher<CXXRecordDecl>hasDirectBaseMatcher<CXXBaseSpecifier> BaseSpecMatcher +
Matches C++ classes that have a direct base matching BaseSpecMatcher.
+
+Example:
+matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
+  class Foo;
+  class Bar : Foo {};
+  class Baz : Bar {};
+  class SpecialBase;
+  class Proxy : SpecialBase {};  // matches Proxy
+  class IndirectlyDerived : Proxy {};  // doesn't match
+
+ + Matcher<CXXRecordDecl>hasMethodMatcher<CXXMethodDecl> InnerMatcher
Matches the first method of a class or struct that satisfies InnerMatcher.
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 153b51753085..f16fb876cdd3 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2862,7 +2862,7 @@ AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
 /// BaseSpecMatcher.
 ///
 /// Example:
-/// matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase")))))
+/// matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
 /// \code
 ///   class Foo;
 ///   class Bar : Foo {};
@@ -2878,6 +2878,26 @@ AST_MATCHER_P(CXXRecordDecl, hasAnyBase, internal::Matcher,
   return internal::matchesAnyBase(Node, BaseSpecMatcher, Finder, Builder);
 }
 
+/// Matches C++ classes that have a direct base matching \p BaseSpecMatcher.
+///
+/// Example:
+/// matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
+/// \code
+///   class Foo;
+///   class Bar : Foo {};
+///   class Baz : Bar {};
+///   class SpecialBase;
+///   class Proxy : SpecialBase {};  // matches Proxy
+///   class IndirectlyDerived : Proxy {};  // doesn't match
+/// \endcode
+AST_MATCHER_P(CXXRecordDecl, hasDirectBase, internal::Matcher,
+              BaseSpecMatcher) {
+  return Node.hasDefinition() &&
+         llvm::any_of(Node.bases(), [&](const CXXBaseSpecifier &Base) {
+           return BaseSpecMatcher.matches(Base, Finder, Builder);
+         });
+}
+
 /// Similar to \c isDerivedFrom(), but also matches classes that directly
 /// match \c Base.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index f01c68a518d9..a0a65092a92b 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -278,6 +278,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasDefinition);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
+  REGISTER_MATCHER(hasDirectBase);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
   REGISTER_MATCHER(hasEitherOperand);
   REGISTER_MATCHER(hasElementType);

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index fa7f75b58b4e..aeb4fd098d22 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -3125,5 +3125,44 @@ TEST(IsVirtual, NoVirtualBase) {
                          cxxRecordDecl(hasAnyBase(isVirtual()))));
 }
 
+TEST(BaseSpecifier, hasDirectBase) {
+  EXPECT_TRUE(matches(
+      R"cc(
+    class Base {};
+    class Derived : Base{};
+    )cc",
+      cxxRecordDecl(hasName("Derived"),
+                    hasDirectBase(hasType(cxxRecordDecl(hasName("Base")))))));
+
+  StringRef MultiDerived = R"cc(
+    class Base {};
+    class Base2 {};
+    class Derived : Base, Base2{};
+    )cc";
+
+  EXPECT_TRUE(matches(
+      MultiDerived,
+      cxxRecordDecl(hasName("Derived"),
+                    hasDirectBase(hasType(cxxRecordDecl(hasName("Base")))))));
+  EXPECT_TRUE(matches(
+      MultiDerived,
+      cxxRecordDecl(hasName("Derived"),
+                    hasDirectBase(hasType(cxxRecordDecl(hasName("Base2")))))));
+
+  StringRef Indirect = R"cc(
+    class Base {};
+    class Intermediate : Base {};
+    class Derived : Intermediate{};
+    )cc";
+
+  EXPECT_TRUE(
+      matches(Indirect, cxxRecordDecl(hasName("Derived"),
+                                      hasDirectBase(hasType(cxxRecordDecl(
+                                          hasName("Intermediate")))))));
+  EXPECT_TRUE(notMatches(
+      Indirect,
+      cxxRecordDecl(hasName("Derived"),
+                    hasDirectBase(hasType(cxxRecordDecl(hasName("Base")))))));
+}
 } // namespace ast_matchers
 } // namespace clang


        

From cfe-commits at lists.llvm.org  Tue Jul  7 08:05:36 2020
From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:05:36 +0000 (UTC)
Subject: [PATCH] D81552: [ASTMatchers] Added hasDirectBase Matcher
In-Reply-To: 
References: 
Message-ID: <14fa183986d2ca6df2a30bb12e2bfc80@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0d3ea171bd5: [ASTMatchers] Added hasDirectBase Matcher (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D81552?vs=275991&id=276073#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81552/new/

https://reviews.llvm.org/D81552

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81552.276073.patch
Type: text/x-patch
Size: 5475 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:08:13 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:08:13 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <152d7138d19a8808e7fdc08c57e52636@localhost.localdomain>

ABataev added inline comments.


================
Comment at: clang/lib/Parse/ParseExpr.cpp:1933
         }
+        if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+          // Consume ':'
----------------
You need to insert an additional check for `OMPClauseKind == llvm::omp::Clause::OMPC_to || OMPClauseKind == llvm::omp::Clause::OMPC_from` here. I.e. we shall expect stride not only if the version is 5.0, but also if the current clauses is `to` or `from`


================
Comment at: clang/lib/Parse/ParseExpr.cpp:1938-1947
+            // Stride can only be null or one for any clause that is not to or
+            // from
+            if (OMPClauseKind != llvm::omp::Clause::OMPC_to &&
+                OMPClauseKind != llvm::omp::Clause::OMPC_from) {
+              Expr::EvalResult Result;
+              Expr *StrideExpr = Stride.get();
+              if (StrideExpr) {
----------------
No, what I meant, that `ParseExpression()` should be called only if `OMPClauseKind == llvm::omp::Clause::OMPC_to || OMPClauseKind == llvm::omp::Clause::OMPC_from` 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Tue Jul  7 08:15:13 2020
From: cfe-commits at lists.llvm.org (David Tenty via cfe-commits)
Date: Tue, 07 Jul 2020 08:15:13 -0700 (PDT)
Subject: [clang] 1a2f482 - [Clang] Handle AIX Include management in the driver
Message-ID: <5f049181.1c69fb81.1507e.273f@mx.google.com>


Author: Shuhong Liu
Date: 2020-07-07T11:15:06-04:00
New Revision: 1a2f4824cb2d472649e65f845510ac0e47ca98c1

URL: https://github.com/llvm/llvm-project/commit/1a2f4824cb2d472649e65f845510ac0e47ca98c1
DIFF: https://github.com/llvm/llvm-project/commit/1a2f4824cb2d472649e65f845510ac0e47ca98c1.diff

LOG: [Clang] Handle AIX Include management in the driver

Summary: Modify the AIX clang toolchain to include AIX dependencies in the search path

Reviewers: daltenty, stevewan, hubert.reinterpretcast

Reviewed By: daltenty, stevewan, hubert.reinterpretcast

Subscribers: ormris, hubert.reinterpretcast, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82677

Added: 
    clang/test/Driver/aix-toolchain-include.cpp

Modified: 
    clang/lib/Driver/ToolChains/AIX.cpp
    clang/lib/Driver/ToolChains/AIX.h
    clang/lib/Frontend/InitHeaderSearch.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 0194f452111a..ac5544eedb00 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -13,12 +13,15 @@
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
 
 using AIX = clang::driver::toolchains::AIX;
 using namespace clang::driver;
 using namespace clang::driver::tools;
+using namespace clang::driver::toolchains;
 
 using namespace llvm::opt;
+using namespace llvm::sys;
 
 void aix::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
                                   const InputInfo &Output,
@@ -163,6 +166,43 @@ AIX::AIX(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
   getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
 }
 
+// Returns the effective header sysroot path to use.
+// This comes from either -isysroot or --sysroot.
+llvm::StringRef
+AIX::GetHeaderSysroot(const llvm::opt::ArgList &DriverArgs) const {
+  if (DriverArgs.hasArg(options::OPT_isysroot))
+    return DriverArgs.getLastArgValue(options::OPT_isysroot);
+  if (!getDriver().SysRoot.empty())
+    return getDriver().SysRoot;
+  return "/";
+}
+
+void AIX::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
+                                    ArgStringList &CC1Args) const {
+  // Return if -nostdinc is specified as a driver option.
+  if (DriverArgs.hasArg(options::OPT_nostdinc))
+    return;
+
+  llvm::StringRef Sysroot = GetHeaderSysroot(DriverArgs);
+  const Driver &D = getDriver();
+
+  // Add the Clang builtin headers (/include).
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+    SmallString<128> P(D.ResourceDir);
+    path::append(P, "/include");
+    addSystemInclude(DriverArgs, CC1Args, P.str());
+  }
+
+  // Return if -nostdlibinc is specified as a driver option.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+    return;
+
+  // Add /usr/include.
+  SmallString<128> UP(Sysroot);
+  path::append(UP, "/usr/include");
+  addSystemInclude(DriverArgs, CC1Args, UP.str());
+}
+
 auto AIX::buildAssembler() const -> Tool * { return new aix::Assembler(*this); }
 
 auto AIX::buildLinker() const -> Tool * { return new aix::Linker(*this); }

diff  --git a/clang/lib/Driver/ToolChains/AIX.h b/clang/lib/Driver/ToolChains/AIX.h
index 69b948bc0ea8..942bb3cceb8a 100644
--- a/clang/lib/Driver/ToolChains/AIX.h
+++ b/clang/lib/Driver/ToolChains/AIX.h
@@ -63,9 +63,16 @@ class LLVM_LIBRARY_VISIBILITY AIX : public ToolChain {
   bool isPIEDefault() const override { return false; }
   bool isPICDefaultForced() const override { return true; }
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+                            llvm::opt::ArgStringList &CC1Args) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
+
+private:
+  llvm::StringRef GetHeaderSysroot(const llvm::opt::ArgList &DriverArgs) const;
 };
 
 } // end namespace toolchains

diff  --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp
index 159cd47f7831..16f1f1670e8d 100644
--- a/clang/lib/Frontend/InitHeaderSearch.cpp
+++ b/clang/lib/Frontend/InitHeaderSearch.cpp
@@ -381,6 +381,7 @@ void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(
   case llvm::Triple::Linux:
   case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
+  case llvm::Triple::AIX:
     llvm_unreachable("Include management is handled in the driver.");
     break;
   case llvm::Triple::Win32:
@@ -424,6 +425,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang,
   case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::AIX:
     return;
 
   case llvm::Triple::Win32:

diff  --git a/clang/test/Driver/aix-toolchain-include.cpp b/clang/test/Driver/aix-toolchain-include.cpp
new file mode 100644
index 000000000000..dc8b272936a4
--- /dev/null
+++ b/clang/test/Driver/aix-toolchain-include.cpp
@@ -0,0 +1,136 @@
+// Tests that the AIX toolchain adds system includes to its search path.
+
+// Check powerpc-ibm-aix, 32-bit/64-bit.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// CHECK-INTERNAL-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// CHECK-NOSTDINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE-NOT:	"-internal-isystem"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdlibinc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// CHECK-NOSTDLIBINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK-NOSTDLIBINC-INCLUDE-NOT:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nobuiltininc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nobuiltininc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nobuiltininc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nobuiltininc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nobuiltininc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+
+// CHECK-NOBUILTININC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOBUILTININC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOBUILTININC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOBUILTININC-INCLUDE-NOT:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|\\\\)}}include"
+// CHECK-NOBUILTININC-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"


        

From cfe-commits at lists.llvm.org  Tue Jul  7 08:15:23 2020
From: cfe-commits at lists.llvm.org (David Tenty via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:15:23 +0000 (UTC)
Subject: [PATCH] D82677: [Clang] Handle AIX Include management in the driver
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a2f4824cb2d: [Clang] Handle AIX Include management in the driver (authored by ShuhongL, committed by daltenty).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82677/new/

https://reviews.llvm.org/D82677

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Driver/aix-toolchain-include.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82677.276075.patch
Type: text/x-patch
Size: 9785 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:18:40 2020
From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:18:40 +0000 (UTC)
Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of
 copy and move ctors
In-Reply-To: 
References: 
Message-ID: <793360b0833570f0a4f95a1d50f4c6df@localhost.localdomain>

oontvoo updated this revision to Diff 276076.
oontvoo marked 2 inline comments as done.
oontvoo added a comment.

prevent diagnostics for dependent types


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83263/new/

https://reviews.llvm.org/D83263

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83263.276076.patch
Type: text/x-patch
Size: 5002 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:20:16 2020
From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:20:16 +0000 (UTC)
Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of
 copy and move ctors
In-Reply-To: 
References: 
Message-ID: <53b892383306de090ab07078987833cc@localhost.localdomain>

oontvoo updated this revision to Diff 276077.
oontvoo added a comment.

lint


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83263/new/

https://reviews.llvm.org/D83263

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83263.276077.patch
Type: text/x-patch
Size: 4991 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:31:00 2020
From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:31:00 +0000 (UTC)
Subject: [PATCH] D83263: [WIP] Clang crashed while checking for deletion of
 copy and move ctors
In-Reply-To: 
References: 
Message-ID: <8263ddffe27bd4e90afb70bc985cd8d5@localhost.localdomain>

oontvoo updated this revision to Diff 276084.
oontvoo added a comment.

one more test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83263/new/

https://reviews.llvm.org/D83263

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaObjCXX/attr-trivial-abi.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83263.276084.patch
Type: text/x-patch
Size: 5338 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:32:22 2020
From: cfe-commits at lists.llvm.org (Raphael Isemann via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:32:22 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: <2bce8f0e712c79cbe442bf41c6777203@localhost.localdomain>

teemperor added a comment.

I think we are talking about different things. My question was why is this a 'Shell' test (like, a test in the `Shell` directory that uses FileCheck) and not a test in the `API` directory (using Python). An 'API' test could use the proper expression testing tools. And it could actually run when doing on-device testing (which is to my knowledge not supported for Shell tests) which seems important for a test concerning a bug that only triggers when doing on-device testing (beside that one ubuntu ARM bot).

Also when looking over the ARM-specific test, I think there might be two bugs that were involved in triggering it. One is the bug fixed here which triggers that Clang will produce its own layout for those classes. Now I also wonder why the layout the expression parser Clang generates doesn't match the one from the test (which appears to be a second bug). The ARM-specific test doesn't have any information in its AST that isn't also available in the expression AST, so why would they produce different layouts? Not sure what exactly is behind the "differences in how it deals with tail padding" description but I assume this is related to tail padding reuse? If yes, then maybe the second bug is that the records in our AST are (not) PODs in the expression AST (see the inline comment for where the tail padding is enabled/disabling based on whether the RD is POD).



================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:2197
     // least as many of them as possible).
     return RD->isTrivial() && RD->isCXX11StandardLayout();
   }
----------------
See here for the POD check that we might get wrong.


================
Comment at: lldb/test/Shell/Expr/Inputs/layout.cpp:22
+
+class D2 : public B2, public Mixin {};
+
----------------
I think there should be some comment that explains why this test is structured like this (maybe point out where the tail padding change is happening).


================
Comment at: lldb/test/Shell/Expr/Inputs/layout.cpp:40
+  D2 d2;
+  D3 d3;
+
----------------
Do we actually need these locals in addition to the globals?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008




From cfe-commits at lists.llvm.org  Tue Jul  7 08:36:21 2020
From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:36:21 +0000 (UTC)
Subject: [PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass
 Matchers
In-Reply-To: 
References: 
Message-ID: 

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb0d3ea171bd5: [ASTMatchers] Added hasDirectBase Matcher (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D81552?vs=270000&id=275666#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81552/new/

https://reviews.llvm.org/D81552

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81552.275666.patch
Type: text/x-patch
Size: 5475 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:36:21 2020
From: cfe-commits at lists.llvm.org (David Tenty via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:36:21 +0000 (UTC)
Subject: [PATCH] D82677: [Clang] Handle AIX Include management in the driver
In-Reply-To: 
References: 
Message-ID: <83c1b2075a6a9acd8fe25cdb20d744b3@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a2f4824cb2d: [Clang] Handle AIX Include management in the driver (authored by ShuhongL, committed by daltenty).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82677/new/

https://reviews.llvm.org/D82677

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Driver/aix-toolchain-include.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82677.275667.patch
Type: text/x-patch
Size: 9785 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:40:07 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:40:07 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <4606f9e916f3f0c00d942bee7e28ccdf@localhost.localdomain>

sammccall added a comment.

This looks better to me but:

- i think we need to consider what happens when paths are not under the expected path, and handle that in some appropriate way
- I find it hard to see what the tests are actually testing - would be good to make them more explicit, using a few minimal helpers, and avoiding fancy abstractions like URI schemes



================
Comment at: clang-tools-extra/clangd/index/remote/Index.proto:102
   Position end = 2;
-  string file_uri = 3;
+  // clangd::SymbolLocation storees FileURI, but the protocol transmits only a
+  // part of its body. Because paths are different on the remote and local
----------------
storees -> stores

isn't it conceptually simpler to talk about a "relative path" rather than a "part of a URI body"?
(apart from anything else, no need to worry about whether it's escaped or not...)


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:36
+/// provided by the client. \p IndexRoot is expected to have UNIX slashes.
+std::string relativePathToURI(llvm::StringRef RelativePath,
+                              llvm::StringRef IndexRoot) {
----------------
mention error return (or return Optional)


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:52
+/// to send over the wire to the client.
+std::string uriToRelativePath(llvm::StringRef URI,
+                              llvm::StringRef IndexedProjectRoot) {
----------------
this should check the scheme too - it must be file
(we can't reasonably treat IndexedProjectRoot as scheme-relative... but not to any *particular* scheme!)


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:119
+SymbolLocation toProtobuf(const clangd::SymbolLocation &Location,
+                          llvm::StringRef IndexedProjectRoot) {
   remote::SymbolLocation Result;
----------------
nit: indexedprojectroot -> indexroot, unless there's some reason for the asymmetry? it seems like the same concept in the opposite direction


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:123
   *Result.mutable_end() = toProtobuf(Location.End);
-  *Result.mutable_file_uri() = Location.FileURI;
+  *Result.mutable_file_path() =
+      uriToRelativePath(Location.FileURI, IndexedProjectRoot);
----------------
how do you want to handle the case where the path is in fact not relative stored under the root?


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:133
+  const std::string Header = IncludeHeader.IncludeHeader.str();
+  auto URI = URI::parse(Header);
+  Result.set_header(URI ? uriToRelativePath(IncludeHeader.IncludeHeader.str(),
----------------
Don't try to parse if it's not a URI (starts with < or ").
As written this code will crash in debug mode if it's not a URI, due to unhandled error. Please add a test!


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:145
+  std::string Header = Message.header();
+  if (llvm::sys::path::is_relative(Header))
+    Header = relativePathToURI(Header, IndexRoot);
----------------
you seem to have this check in a few places - I'd suggest it should be in the relativePathToURI function and there should be some plan for handling errors.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h:15
+// on indexing machine and client machine
+// ("/remote/machine/projects/llvm/include/HelloWorld.h" versus
+// "/usr/local/username/llvm/include/HelloWorld.h"), they need to be converted
----------------
nit: llvm -> llvm-project


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h:42
 clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request);
+/// Deserializes clangd types and translates relative paths into
+/// machine-native URIs.
----------------
again, one particular overload is not really the place for this comment, I think. (File comment looks good)


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h:52
 LookupRequest toProtobuf(const clangd::LookupRequest &From);
 FuzzyFindRequest toProtobuf(const clangd::FuzzyFindRequest &From);
 RefsRequest toProtobuf(const clangd::RefsRequest &From);
----------------
this also needs the index root, for the proximity path (I'm not sure why they're not URIs, that's unfortunate...)


================
Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:50
+      : Index(std::move(Index)) {
+    llvm::SmallString<256> NativePath = llvm::StringRef(IndexRoot);
+    llvm::sys::path::native(NativePath);
----------------
please pass this in as a constructor param rather than accessing the flag directly


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:25
 
+const char *unittestURIToFilesystem(const char *UnittestURI,
+                                    llvm::UniqueStringSaver &Strings) {
----------------
The File scheme is special. Using a different URI scheme here when we only support `file` in production is confusing and seems like a last resort to be used when we can't make it work any other way.
(For example we use it in lit tests because we must specify input filenames and the presence/absence of drive letters caused problems)
What's being solved there that the much smaller hammer of testPath() plus a local testPathURI() helper can't solve?


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:122
+  clangd::Ref Original;
+  const auto RemoteIndexPrefix = testPath("remote/machine/project/");
+  const auto RelativePath = llvm::sys::path::convert_to_slash(
----------------
auto -> std::string (here and in other places where the type is neither overly unreadable nor spelled in the function name)


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:122
+  clangd::Ref Original;
+  const auto RemoteIndexPrefix = testPath("remote/machine/project/");
+  const auto RelativePath = llvm::sys::path::convert_to_slash(
----------------
sammccall wrote:
> auto -> std::string (here and in other places where the type is neither overly unreadable nor spelled in the function name)
it's not great practice to be assembling the test data from prefix + relative if the code we're testing is splitting it into prefix + relative - easy for the same bugs to cancel each other out.

Is testPath("remote/dir/MarshallingTests.cpp") directly too long?


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:126
+      "MarshallingTests.cpp");
+  const auto URI = URI::createFile(RemoteIndexPrefix + RelativePath);
+  Original.Location.FileURI = Strings.save(URI.toString()).begin();
----------------
(I'd suggest a helper testPathURI("remote/dir/MarshallingTests.cpp") for this)


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:130
+  EXPECT_EQ(Serialized.location().file_path(), RelativePath);
+  // Local index prefix should have UNIX slashes since the relative path in
+  // Protobuf message will.
----------------
hmm, I don't think that's the reason.
Either that's the contract of fromProtobuf, or it's not required and we shouldn't do it.


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:146
+  Ref WithAbsolutePath;
+  *WithAbsolutePath.mutable_location()->mutable_file_path() = "/usr/local/bin/";
+  Deserialized = fromProtobuf(WithAbsolutePath, &Strings, LocalIndexPrefix);
----------------
nit: use a file path rather than directory?


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:34
+
 TEST(RemoteMarshallingTest, SymbolSerialization) {
   const auto *Header = R"(
----------------
At this point I really think we should be writing these symbols out instead of trying to parse them from C++ - it's pretty hard to see exactly what fields are set and what is tested when the test is so highly factored.

If you like this approach think everything new is covered in other tests, I'd just remove the changes to this one.


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:45
+    const auto SymToProtobufAndBack = fromProtobuf(
+        ProtobufMessage, &Strings, std::string(testRoot()) + '/', "unittest");
     EXPECT_TRUE(SymToProtobufAndBack.hasValue());
----------------
kbobyrev wrote:
> sammccall wrote:
> > this is `testPath("unittest")`, isn't it?
> > 
> > I mean, forward vs backslashes are going to differ, but the current expression is going to produce `C:\test/unittest` which doesn't seem better.
> I don't understand: `std::string(testRoot()) + '/'` is `/clangd-test/` on unix and `testPath("unittest")` is `/clangd-test/unittest`. I understand the slashes argument, but could you please elaborate on the former?
sorry, I guess I meant testRoot("/").


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938




From cfe-commits at lists.llvm.org  Tue Jul  7 08:44:13 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:44:13 +0000 (UTC)
Subject: [PATCH] D83233: [clangd] Enable reading config from files by default.
In-Reply-To: 
References: 
Message-ID: <2a75a0014fd65b62fda94041094bf65e@localhost.localdomain>

sammccall marked 4 inline comments as done.
sammccall added inline comments.


================
Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:436
+        "Project config is from a .clangd file in the project directory.\n"
+        "User config is from clangd/config.yaml in the following directories:\n"
+        "\tWindows: %USERPROFILE%\\AppData\\Local\n"
----------------
hokein wrote:
> nit: maybe worth mentioning that the user config has higher privilege.
I think this is the sort of detail best left to the actual documentation.
I've added a... forward declaration of that documentation here, to the URL where it will soon exist.


================
Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:700
+    ProviderStack.push_back(
+        config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS));
+    llvm::SmallString<256> UserConfig;
----------------
kadircet wrote:
> should we first update the background index storage location?
This is done. (There will still be old .clangd directories around, but that will ~always be true)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83233/new/

https://reviews.llvm.org/D83233




From cfe-commits at lists.llvm.org  Tue Jul  7 08:52:12 2020
From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:52:12 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: 

nikic added inline comments.


================
Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT:         Branch Probability Analysis
+; CHECK-NEXT:         Block Frequency Analysis
 ; CHECK-NEXT:     FunctionPass Manager
----------------
hans wrote:
> nikic wrote:
> > Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use?
> > 
> > PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided.
> I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> 
> I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.

It would only help if there is some way to only fetch the analysis conditionally. I believe many PGO passes use something like PSI.hasProfileSummary() or F.hasProfileData() for that.

> I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?

Right, just disabling this by default in clang/opt would also work.

For reference, the current compile-time numbers for this patch: https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff&to=8df840660bb764b6653fcfd9ac7a72cc6adebde6&stat=instructions Not huge, but it adds up (some similar regressions have been introduced in LLVM 10).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Tue Jul  7 08:52:17 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:52:17 +0000 (UTC)
Subject: [PATCH] D83315: Turn arcmt-* options into a single option
Message-ID: 

dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

- The new option, -arcmt-action, is a simple enum based option.
- The driver is modified to translate the existing -ccc-acmt-* options accordingly

Depends on D83298 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83315

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/ARCMT/GC-check-warn-nsalloc.m
  clang/test/ARCMT/GC-check.m
  clang/test/ARCMT/atautorelease-check.m
  clang/test/ARCMT/check-api.m
  clang/test/ARCMT/check-with-pch.m
  clang/test/ARCMT/check-with-serialized-diag.m
  clang/test/ARCMT/checking-in-arc.m
  clang/test/ARCMT/checking.m
  clang/test/ARCMT/cxx-checking.mm
  clang/test/ARCMT/driver-migrate.m
  clang/test/ARCMT/migrate-emit-errors.m
  clang/test/ARCMT/migrate-plist-output.m
  clang/test/ARCMT/migrate-space-in-path.m
  clang/test/ARCMT/migrate-with-pch.m
  clang/test/ARCMT/migrate.m
  clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
  clang/test/ARCMT/nonobjc-to-objc-cast-2.m
  clang/test/ARCMT/releases-driver.m
  clang/test/ARCMT/releases-driver.m.result
  clang/test/ARCMT/verify.m
  clang/test/ARCMT/with-arc-mode-modify.m
  clang/test/ARCMT/with-arc-mode-modify.m.result
  llvm/utils/TableGen/OptParserEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83315.276088.patch
Type: text/x-patch
Size: 18163 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 08:53:00 2020
From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 15:53:00 +0000 (UTC)
Subject: [PATCH] D83317: [Sema] Teach -Wcast-align to compute alignment of
 CXXThisExpr
Message-ID: 

ahatanak created this revision.
ahatanak added reviewers: rjmccall, jyknight.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.

This fixes https://bugs.llvm.org/show_bug.cgi?id=46605.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83317

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp


Index: clang/test/SemaCXX/warn-cast-align.cpp
===================================================================
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,9 +44,16 @@
   c = IntPtr(P);
 }
 
+struct __attribute__((aligned(16))) AlignedS {
+  char m[16];
+};
+
 struct __attribute__((aligned(16))) A {
   char m0[16];
   char m1[16];
+  AlignedS *getAlignedS() {
+    return (AlignedS *)m1;
+  }
 };
 
 struct B0 {
@@ -92,6 +99,9 @@
 
 struct D5 : virtual D0 {
   char m0[16];
+  AlignedS *get() {
+    return (AlignedS *)m0; // expected-warning {{cast from 'char *' to 'AlignedS *'}}
+  }
 };
 
 struct D6 : virtual D5 {
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13487,12 +13487,14 @@
   }
   case Stmt::MemberExprClass: {
     auto *ME = cast(E);
-    if (ME->isArrow())
-      break;
     auto *FD = dyn_cast(ME->getMemberDecl());
     if (!FD || FD->getType()->isReferenceType())
       break;
-    auto P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
+    Optional> P;
+    if (ME->isArrow())
+      P = getBaseAlignmentAndOffsetFromPtr(ME->getBase(), Ctx);
+    else
+      P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
     if (!P)
       break;
     const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(FD->getParent());
@@ -13556,6 +13558,11 @@
     }
     break;
   }
+  case Stmt::CXXThisExprClass: {
+    auto *RD = E->getType()->getPointeeType()->getAsCXXRecordDecl();
+    CharUnits Alignment = Ctx.getASTRecordLayout(RD).getNonVirtualAlignment();
+    return std::make_pair(Alignment, CharUnits::Zero());
+  }
   case Stmt::UnaryOperatorClass: {
     auto *UO = cast(E);
     if (UO->getOpcode() == UO_AddrOf)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83317.276086.patch
Type: text/x-patch
Size: 1916 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 09:07:00 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits)
Date: Tue, 07 Jul 2020 16:07:00 +0000 (UTC)
Subject: [PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.
In-Reply-To: 
References: 
Message-ID: 

balazske added a comment.

Possible improvements (this is at least a note for me):

- The checker can try to find a check for error-return value until the symbol (to check) is released. The warning is generated only if no check for error-return was found. This way works for functions that return a numerical value that has other meaningful values beside the error-return value. There is not necessary that the check for the error return is the first check. For other functions the first use of the return value must be the check for error-return. (What way to choose is a property of the system call to check.)
- More kinds of error-return kinds can be added. For example: If a function has a numerical return value where -1 is error return, a check for "> x" could be accepted instead of check for "> -1".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72705/new/

https://reviews.llvm.org/D72705




From cfe-commits at lists.llvm.org  Tue Jul  7 09:08:53 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:08:53 +0000 (UTC)
Subject: [PATCH] D70605: [OpenCL] Fix address space for implicit conversion
 (PR43145)
In-Reply-To: 
References: 
Message-ID: <6331aad3ecf1ae1ca1b56a8ebab72673@localhost.localdomain>

ebevhan added a comment.

I know this is some really late feedback on this patch. I struck upon some issues with while rebasing D62574 .



================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:4106
+      NewToType = Context.getAddrSpaceQualType(NewToType,
+                                               FromPteeType.getAddressSpace());
+      if (ToType->isObjCObjectPointerType())
----------------
I don't think this will manage to properly repack the type if it's hidden behind enough sugar. When I enable C++ address space conversions in a non-OpenCL context, this breaks the derived-to-base example in CodeGenCXX/address-space-cast.cpp.

IsPointerConversion doesn't have an issue with this since it reconstructs the destination type with the appropriate qualifiers through BuildSimilarlyQualifiedPointerType.

Wouldn't it make more sense to have *PointerConversion only handle the derived-to-base and leave the address space conversion to *QualificationConversion?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70605/new/

https://reviews.llvm.org/D70605




From cfe-commits at lists.llvm.org  Tue Jul  7 09:09:50 2020
From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:09:50 +0000 (UTC)
Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block
In-Reply-To: 
References: 
Message-ID: 

ellis updated this revision to Diff 276095.
ellis added a comment.

Add RUN line to test in C


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82904/new/

https://reviews.llvm.org/D82904

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82904.276095.patch
Type: text/x-patch
Size: 10063 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 09:13:54 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:13:54 +0000 (UTC)
Subject: [PATCH] D62574: Initial draft of target-configurable address spaces.
In-Reply-To: 
References: 
Message-ID: <3f141566b5347d92ea3431eff72a92e7@localhost.localdomain>

ebevhan added a comment.

It seems that D70605  attempted to ameliorate the issues that I observed (pointer-conversion doing too much), but it didn't manage to solve the problem fully.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62574/new/

https://reviews.llvm.org/D62574




From cfe-commits at lists.llvm.org  Tue Jul  7 09:34:45 2020
From: cfe-commits at lists.llvm.org (Simon Pilgrim via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:34:45 +0000 (UTC)
Subject: [PATCH] D83254: [X86] Enabled a bunch of 64-bit Interlocked*
 functions intrinsics on 32-bit Windows to match recent MSVC
In-Reply-To: 
References: 
Message-ID: 

RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83254/new/

https://reviews.llvm.org/D83254




From cfe-commits at lists.llvm.org  Tue Jul  7 09:34:48 2020
From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:34:48 +0000 (UTC)
Subject: [PATCH] D77150: [Analyzer] New Option for ContainerModeling:
 AggressiveEraseModeling
In-Reply-To: 
References: 
Message-ID: 

NoQ added inline comments.


================
Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:647-653
     CmdLineOption
   ]>,
----------------
baloghadamsoftware wrote:
> Szelethus wrote:
> > Szelethus wrote:
> > > NoQ wrote:
> > > > baloghadamsoftware wrote:
> > > > > Szelethus wrote:
> > > > > > Ah, okay, I see which one you refer to. We should totally make this non-user facing as well. 
> > > > > The option is not about state split! It is for choosing between the (default) conservative approach and a more aggressive one. It is absolutely for the user to set. Some users prefer less false positive for the price of losing true positives. However, some other users prefer more true positives for the price of additional false positives. This is why we have checker options to be able to serve both groups.
> > > > > 
> > > > > This feature was explicitly requested by our users who first disabled iterator checkers because of the too many false positives but later re-enabled them because they run into a bug in a production system which could have been prevented by enabling them. However, they run into another bug that our checker did not find because of its conservative behavior. They requested a more aggressive one but we must not do it for everyone. The concept of the Analyzer is that we apply the conservative approach by default and the aggressive can be enabled by analyzer and checker options.
> > > > These options are unlikely to be on-by-default in vanilla clang because of having a fundamentally unfixable class of false positives associated with them. Honestly, i've never seen users who are actually ok with false positives. I've regularly seen users say that they are ok with false positives when they wanted their false negatives fixed, but it always turned out that they don't understand what they're asking for and they quickly changed their mind when they saw the result. But you guys basically vend your own tool to your own customers and bear your own responsibility and i therefore can't tell you what to do in your realm, and i'm ok with having options that allow you to disagree with my choices.
> > > > 
> > > > inb4, "//`-analyzer-config` is not user-facing!!!11//"
> > > >inb4, "-analyzer-config is not user-facing!!!11"
> > > I was starting to breath really heavy and type really fast :D
> > > 
> > > Jokes aside, I'll spill the beans, we don't have a really convenient way to tweak these options through CodeChecker just yet, so for the time being, they really aren't, but maybe one day.
> > > 
> > > With that said, I also agree with you regarding options that overapproximate the analysis (greater code coverage with more false and true positives). User facing options should be the ones where the nature of the bug itself if subjective, like whether we want to check the initializedness of pointees. We sure can regard them as unwanted, or we could regard them as totally fine, so an option is a great compromise.
> > > 
> > > >[...] it always turned out that they don't understand what they're asking for [...]
> > > 
> > > This is why I think this shouldn't be user-facing. You need to be quite knowledgeable about the analyzer, and IteratorChecker in particular to make good judgement about enabling the option added in this patch. That doesn't mean you shouldn't experiment with it, but I'd prefer to not expose it too much.
> > > 
> > > I just don't see this feature being that desired by many if they knew the costs, even if one user really wants it. We could however, in that case, say
> > > "Hey, there is this option you can enable that might help you hunt down more bugs. It does change the actual analysis itself, and experience showed that it might result in more false positives and could impact performance, so we opted not to make it user-facing, but it is there, if you feel adventurous."
> > Granted, I might be demonizing the cons of these options too much, but the description doesn't help on understanding it that much either O:)
> So you both are saying that I should tell the user that we cannot help, the community does not support that he catches this bug in early phase with the analyzer. He must catch it in the testing phase for higher costs. This is not the best way to build confidence in the analyzer.
> 
> In my perception options are used to serve one users need without harming others. I never understand why there is so much resistance against introducing an option that does not change the default behavior at all.
1. That's right, implementing every single suggestion users have is a terrible idea. Not everything is possible, not everything is feasible. Populism should not be put ahead of common sense. As an extreme example, imagine you're in the 80's and a user complained that they need a voice recognition feature in their computer ("Why do I have to type all this text, it's so slow???"). Would you be ready to inform them that it'll take 30 years and a few revolutionary breakthroughs in computer science to implement? Would you be ready to tell them that learning how to touch-type will make their typing faster than anything they could ever achieve with dictation? Because that's your job as a programmer to be assertive and to be able to say "no" or "maybe later" or "you're not using the program correctly" when user demands don't make sense or are impossible to implement or if the user doesn't know what they're asking for. Developers of every single program that has any users at all constantly struggle with this.

2. Supporting multiple configurations is much harder than supporting a single configuration. I wish I could say that it will be entirely up to you to maintain these configurations, including the situations when it doesn't cause problems yet but obstructs future development. However, I can't say that, due to 3.

3. You can't control who uses your option once it's landed in open-source. By committing the option to the upstream LLVM, you're not shipping this option to just one user, you're shipping it to the entire world.

4. You can't simply say "I know it may sometimes work incorrectly but I tested it and it works for me". The option may behave fine on codebases in your company but completely ruin reputation of the static analyzer by producing a lot of false positives on a famous open-source project that you didn't test it on. This is why we care a lot about correctness and not introducing new sources of false positives.

5. You may say that the users know what they're doing when they turn the option on, and that they're willing to accept some false positives. That's not true though; you don't personally brief every user of your option. They may try it simply because they heard about it from someone else. They're not always willing to read documentation. One user may enable the option for all other developers and they may never learn that this was an option to begin with.

6. In particular, i believe that false positives destroy confidence in the analyzer much more than false negatives. I also don't trust the users when they say they don't care about false positives. I heard this many times from a variety of people but when I gave them what they wanted they immediately started complaining about false positives every single time.

7. Static analysis is not a one-size-fits-all solution to bug finding. Instead of trying to find a way to find every kind of bug statically, you should be trying to find the best tool for the job. There are areas in which static analysis excels, like finding exotic execution paths not covered by tests, but it's not good for everything.

8. Static analysis is not necessarily cheaper than testing or code review or dynamic analysis. Understanding a single analyzer report may take hours.

9. False positives reduce cost-effectiveness of static analysis dramatically. They may cause the user to spend a lot of time trying to understand an incorrect warning, or the users may introduce a new bug when they try to silence the warning without understanding the warning and/or the surrounding code.

10. Last but not least, honestly, we have significantly more important problems to fix. If you claim that adding an option makes a few users happy without changing anything for anybody else, then you must also admit that you're doing a lot of work for just a small portion of users, when you could spend your time (and our time) benefiting *every* user instead.

So, like, options aren't too bad on their own but they're definitely not as free as you describe. You still need to think about *all* users who can potentially access the option, not just the one who's in front of you. "The analyzer produces false positives under an option" still means that the analyzer produces false positives in one of the supported configurations. Marking features as opt-in doesn't give you an excuse for shipping bad features.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77150/new/

https://reviews.llvm.org/D77150




From cfe-commits at lists.llvm.org  Tue Jul  7 09:38:14 2020
From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:38:14 +0000 (UTC)
Subject: [PATCH] D80897: [OpenMP] Initial support for std::complex in target
 regions
In-Reply-To: 
References: 
Message-ID: <371d15dc8c9757cdece177c45e9f0b30@localhost.localdomain>

tra accepted this revision.
tra added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80897/new/

https://reviews.llvm.org/D80897




From cfe-commits at lists.llvm.org  Tue Jul  7 09:42:58 2020
From: cfe-commits at lists.llvm.org (Francesco Petrogalli via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:42:58 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: 

fpetrogalli updated this revision to Diff 276106.
fpetrogalli added a comment.

Removed the unrelated change of the empty line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===================================================================
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -112,6 +112,12 @@
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE 1
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE_MATMUL_FP64 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
 // The following tests may need to be revised in the future since
 // SVE2 is currently still part of Future Architecture Technologies
 // (https://developer.arm.com/docs/ddi0602/latest)
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -114,10 +114,16 @@
   std::pair Split = StringRef(MarchLowerCase).split("+");
 
   llvm::AArch64::ArchKind ArchKind = llvm::AArch64::parseArch(Split.first);
-  if (ArchKind == llvm::AArch64::ArchKind::INVALID ||
-      !llvm::AArch64::getArchFeatures(ArchKind, Features) ||
-      (Split.second.size() &&
-       !DecodeAArch64Features(D, Split.second, Features, ArchKind)))
+
+  if (!llvm::AArch64::getArchFeatures(ArchKind, Features))
+    return false;
+
+  if (ArchKind == llvm::AArch64::ArchKind::ARMV8_6A) {
+    Features.push_back("+i8mm");
+    Features.push_back("+bf16");
+  }
+
+  if (!DecodeAArch64Features(D, Split.second, Features, ArchKind))
     return false;
 
   return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83079.276106.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 09:44:41 2020
From: cfe-commits at lists.llvm.org (Danila Malyutin via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:44:41 +0000 (UTC)
Subject: [PATCH] D62574: Initial draft of target-configurable address spaces.
In-Reply-To: 
References: 
Message-ID: 

danilaml added a comment.

In D62574#2135662 , @ebevhan wrote:

> It's generally not safe to alter address spaces below the top level. C is just very permissive about it.


Isn't that also true for the top-level casts? Unless when it is. And the target should know when it's safe or not. It's just that for non top-level casts there is added condition that casts are noop (i.e. don't change the bit pattern of the pointer). At least that's how I see it.

I think that you are write about that patch being targeted at C++ (need to do some C tests), but having the same implicit conversion being legal in C and not in C++ would be a bit confusing for the users (especially when the target knows it's completely safe). Anyway, this is not as important as getting this target-configurable AS work done. Without it, I guess the only option for downstream works to customize the behavior is to introduce their own LangAS-level AS entries, which is definitely not ideal.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62574/new/

https://reviews.llvm.org/D62574




From cfe-commits at lists.llvm.org  Tue Jul  7 09:45:32 2020
From: cfe-commits at lists.llvm.org (Aaron En Ye Shi via cfe-commits)
Date: Tue, 07 Jul 2020 09:45:32 -0700 (PDT)
Subject: [clang] c64bb3f - [HIP] Use default triple in llvm-mc for system ld
Message-ID: <5f04a6ac.1c69fb81.97920.2b7f@mx.google.com>


Author: Aaron En Ye Shi
Date: 2020-07-07T16:44:51Z
New Revision: c64bb3f7367a924e9d17dfccccc1c92897e6cbe1

URL: https://github.com/llvm/llvm-project/commit/c64bb3f7367a924e9d17dfccccc1c92897e6cbe1
DIFF: https://github.com/llvm/llvm-project/commit/c64bb3f7367a924e9d17dfccccc1c92897e6cbe1.diff

LOG: [HIP] Use default triple in llvm-mc for system ld

The Ubuntu system ld does not recognize the amdgcn-amd-amdhsa target.
Instead the host object with embedded device fat binary should not be
assembled by that triple. It should use default triple, so that the
object is compatible with system ld.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D83145

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/HIP.cpp
    clang/test/Driver/hip-link-save-temps.hip
    clang/test/Driver/hip-toolchain-rdc-separate.hip
    clang/test/Driver/hip-toolchain-rdc-static-lib.hip
    clang/test/Driver/hip-toolchain-rdc.hip

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp
index f75be81622bf..15c9dbf3488d 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -193,8 +193,7 @@ void AMDGCN::Linker::constructGenerateObjFileFromHIPFatBinary(
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-triple", Args.MakeArgString(TC.getTripleString()),
-                       "-o",      Output.getFilename(),
+  ArgStringList McArgs{"-o",      Output.getFilename(),
                        McinFile,  "--filetype=obj"};
   const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),

diff  --git a/clang/test/Driver/hip-link-save-temps.hip b/clang/test/Driver/hip-link-save-temps.hip
index 60f71d0c5249..f2d3630dd119 100644
--- a/clang/test/Driver/hip-link-save-temps.hip
+++ b/clang/test/Driver/hip-link-save-temps.hip
@@ -45,8 +45,7 @@
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" "obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
-// CHECK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
-// CHECK-SAME: "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
+// CHECK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
 // OUT: "{{.*ld.*}}" {{.*}} "-o" "executable" {{.*}} "[[OBJBUNDLE]]"
 // NOUT: "{{.*ld.*}}" {{.*}} "-o" "a.out" {{.*}} "[[OBJBUNDLE]]"
 // SLO: "{{.*llvm-ar.*}}" "rcsD" "libTest.a" {{.*}} "[[OBJBUNDLE]]"

diff  --git a/clang/test/Driver/hip-toolchain-rdc-separate.hip b/clang/test/Driver/hip-toolchain-rdc-separate.hip
index f65b95c7de77..ab89e19256be 100644
--- a/clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -122,8 +122,7 @@
 // LINK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // LINK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// LINK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
-// LINK-SAME: "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
+// LINK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
 
 // LINK: [[LD:".*ld.*"]] {{.*}} "-o" "a.out" {{.*}} "[[A_OBJ_HOST]]"
 // LINK-SAME: "[[B_OBJ_HOST]]" "[[OBJBUNDLE]]"

diff  --git a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
index 56b54afbf29f..dc29b0f87e36 100644
--- a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -78,7 +78,6 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]

diff  --git a/clang/test/Driver/hip-toolchain-rdc.hip b/clang/test/Driver/hip-toolchain-rdc.hip
index 045bbf44ae91..97d5e59c0c4b 100644
--- a/clang/test/Driver/hip-toolchain-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-rdc.hip
@@ -90,8 +90,7 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // output the executable
 // CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]


        

From cfe-commits at lists.llvm.org  Tue Jul  7 09:45:38 2020
From: cfe-commits at lists.llvm.org (Aaron Enye Shi via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:45:38 +0000 (UTC)
Subject: [PATCH] D83145: [HIP] Use default triple in llvm-mc for system ld
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rGc64bb3f7367a: [HIP] Use default triple in llvm-mc for system ld (authored by ashi1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83145/new/

https://reviews.llvm.org/D83145

Files:
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip


Index: clang/test/Driver/hip-toolchain-rdc.hip
===================================================================
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -90,8 +90,7 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // output the executable
 // CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===================================================================
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -78,7 +78,6 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===================================================================
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -122,8 +122,7 @@
 // LINK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // LINK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// LINK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
-// LINK-SAME: "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
+// LINK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
 
 // LINK: [[LD:".*ld.*"]] {{.*}} "-o" "a.out" {{.*}} "[[A_OBJ_HOST]]"
 // LINK-SAME: "[[B_OBJ_HOST]]" "[[OBJBUNDLE]]"
Index: clang/test/Driver/hip-link-save-temps.hip
===================================================================
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -45,8 +45,7 @@
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" "obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
-// CHECK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
-// CHECK-SAME: "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
+// CHECK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
 // OUT: "{{.*ld.*}}" {{.*}} "-o" "executable" {{.*}} "[[OBJBUNDLE]]"
 // NOUT: "{{.*ld.*}}" {{.*}} "-o" "a.out" {{.*}} "[[OBJBUNDLE]]"
 // SLO: "{{.*llvm-ar.*}}" "rcsD" "libTest.a" {{.*}} "[[OBJBUNDLE]]"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -193,8 +193,7 @@
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-triple", Args.MakeArgString(TC.getTripleString()),
-                       "-o",      Output.getFilename(),
+  ArgStringList McArgs{"-o",      Output.getFilename(),
                        McinFile,  "--filetype=obj"};
   const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83145.276108.patch
Type: text/x-patch
Size: 3890 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 09:53:09 2020
From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:53:09 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: 

shafik added a comment.

In D83008#2136303 , @teemperor wrote:

> I think we are talking about different things. My question was why is this a 'Shell' test (like, a test in the `Shell` directory that uses FileCheck) and not a test in the `API` directory (using Python). An 'API' test could use the proper expression testing tools. And it could actually run when doing on-device testing (which is to my knowledge not supported for Shell tests) which seems important for a test concerning a bug that only triggers when doing on-device testing (beside that one ubuntu ARM bot).


I did not realize the shell tests were not tested on device.

> Also when looking over the ARM-specific test, I think there might be two bugs that were involved in triggering it. One is the bug fixed here which triggers that Clang will produce its own layout for those classes. Now I also wonder why the layout the expression parser Clang generates doesn't match the one from the test (which appears to be a second bug). The ARM-specific test doesn't have any information in its AST that isn't also available in the expression AST, so why would they produce different layouts? Not sure what exactly is behind the "differences in how it deals with tail padding" description but I assume this is related to tail padding reuse? If yes, then maybe the second bug is that the records in our AST are (not) PODs in the expression AST (see the inline comment for where the tail padding is enabled/disabling based on whether the RD is POD).

So we are hitting this code for non-arm64 case:

  case TargetCXXABI::UseTailPaddingUnlessPOD03:
    //...
    return RD->isPOD();

and we return `false` which is correct for the original test case since it has a base class and base therefore not an aggregate (until C++17) see it here  and struct that had the difference I was looking at. I did not check for the test cases in the PR though.

In the arm64 case from the original problem we hit the following:

  case TargetCXXABI::UseTailPaddingUnlessPOD11:
     // ...
     return RD->isTrivial() && RD->isCXX11StandardLayout();

which returns `true` for the original case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008




From cfe-commits at lists.llvm.org  Tue Jul  7 09:54:48 2020
From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 16:54:48 +0000 (UTC)
Subject: [PATCH] D83317: [Sema] Teach -Wcast-align to compute alignment of
 CXXThisExpr
In-Reply-To: 
References: 
Message-ID: <2fed42e58b8b918601395d0bafc7d407@localhost.localdomain>

rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83317/new/

https://reviews.llvm.org/D83317




From cfe-commits at lists.llvm.org  Tue Jul  7 10:01:33 2020
From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:01:33 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <6978c55b55316cb167aafd7d5978f431@localhost.localdomain>

zequanwu marked an inline comment as done.
zequanwu added inline comments.


================
Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT:         Branch Probability Analysis
+; CHECK-NEXT:         Block Frequency Analysis
 ; CHECK-NEXT:     FunctionPass Manager
----------------
nikic wrote:
> hans wrote:
> > nikic wrote:
> > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use?
> > > 
> > > PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided.
> > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > 
> > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> 
> It would only help if there is some way to only fetch the analysis conditionally. I believe many PGO passes use something like PSI.hasProfileSummary() or F.hasProfileData() for that.
> 
> > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> 
> Right, just disabling this by default in clang/opt would also work.
> 
> For reference, the current compile-time numbers for this patch: https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff&to=8df840660bb764b6653fcfd9ac7a72cc6adebde6&stat=instructions Not huge, but it adds up (some similar regressions have been introduced in LLVM 10).
Do you mean disabling it just for LPM or both?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Tue Jul  7 10:03:20 2020
From: cfe-commits at lists.llvm.org (Sven van Haastregt via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:03:20 +0000 (UTC)
Subject: [PATCH] D70605: [OpenCL] Fix address space for implicit conversion
 (PR43145)
In-Reply-To: 
References: 
Message-ID: 

svenvh marked an inline comment as done.
svenvh added inline comments.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:4106
+      NewToType = Context.getAddrSpaceQualType(NewToType,
+                                               FromPteeType.getAddressSpace());
+      if (ToType->isObjCObjectPointerType())
----------------
ebevhan wrote:
> I don't think this will manage to properly repack the type if it's hidden behind enough sugar. When I enable C++ address space conversions in a non-OpenCL context, this breaks the derived-to-base example in CodeGenCXX/address-space-cast.cpp.
> 
> IsPointerConversion doesn't have an issue with this since it reconstructs the destination type with the appropriate qualifiers through BuildSimilarlyQualifiedPointerType.
> 
> Wouldn't it make more sense to have *PointerConversion only handle the derived-to-base and leave the address space conversion to *QualificationConversion?
> Wouldn't it make more sense to have *PointerConversion only handle the derived-to-base and leave the address space conversion to *QualificationConversion?

I didn't have a thorough look to understand all implications of that, but maybe it's worth trying.  Not sure I'll be able to follow up on this any time soon, would you be able to give it a try?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70605/new/

https://reviews.llvm.org/D70605




From cfe-commits at lists.llvm.org  Tue Jul  7 10:07:45 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:07:45 +0000 (UTC)
Subject: [PATCH] D70605: [OpenCL] Fix address space for implicit conversion
 (PR43145)
In-Reply-To: 
References: 
Message-ID: <55ed5515e5e83fded772b722d122090a@localhost.localdomain>

ebevhan added inline comments.


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:4106
+      NewToType = Context.getAddrSpaceQualType(NewToType,
+                                               FromPteeType.getAddressSpace());
+      if (ToType->isObjCObjectPointerType())
----------------
svenvh wrote:
> ebevhan wrote:
> > I don't think this will manage to properly repack the type if it's hidden behind enough sugar. When I enable C++ address space conversions in a non-OpenCL context, this breaks the derived-to-base example in CodeGenCXX/address-space-cast.cpp.
> > 
> > IsPointerConversion doesn't have an issue with this since it reconstructs the destination type with the appropriate qualifiers through BuildSimilarlyQualifiedPointerType.
> > 
> > Wouldn't it make more sense to have *PointerConversion only handle the derived-to-base and leave the address space conversion to *QualificationConversion?
> > Wouldn't it make more sense to have *PointerConversion only handle the derived-to-base and leave the address space conversion to *QualificationConversion?
> 
> I didn't have a thorough look to understand all implications of that, but maybe it's worth trying.  Not sure I'll be able to follow up on this any time soon, would you be able to give it a try?
I'll see if I can have a look, or at least make the existing implementation a bit more thorough.

To be entirely honest, I feel a bit stupid right now: I forgot that **I** added the derived-to-base test in the test case I mentioned in my local experimental branch, so of course you wouldn't be able to use that as a baseline. Oops!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70605/new/

https://reviews.llvm.org/D70605




From cfe-commits at lists.llvm.org  Tue Jul  7 10:11:09 2020
From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:11:09 +0000 (UTC)
Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block
In-Reply-To: 
References: 
Message-ID: <42ddedfeb219fa7385555961f41dc078@localhost.localdomain>

ellis updated this revision to Diff 276118.
ellis added a comment.

Update commit message


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82904/new/

https://reviews.llvm.org/D82904

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82904.276118.patch
Type: text/x-patch
Size: 10063 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:12:01 2020
From: cfe-commits at lists.llvm.org (Aaron Enye Shi via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:12:01 +0000 (UTC)
Subject: [PATCH] D83145: [HIP] Use default triple in llvm-mc for system ld
In-Reply-To: 
References: 
Message-ID: <221d6da457ab927bd7d5b493c6fdeffb@localhost.localdomain>

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc64bb3f7367a: [HIP] Use default triple in llvm-mc for system ld (authored by ashi1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83145/new/

https://reviews.llvm.org/D83145

Files:
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip
  clang/test/Driver/hip-toolchain-rdc.hip


Index: clang/test/Driver/hip-toolchain-rdc.hip
===================================================================
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -90,8 +90,7 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // output the executable
 // CHECK: [[LD:".*ld.*"]] {{.*}}"-o" "a.out" {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===================================================================
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -78,7 +78,6 @@
 // CHECK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // CHECK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// CHECK: [[MC:".*llvm-mc"]] "-triple" "amdgcn-amd-amdhsa"
-// CHECK-SAME: "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
+// CHECK: [[MC:".*llvm-mc"]] "-o" [[OBJBUNDLE:".*o"]] "{{.*}}.mcin" "--filetype=obj"
 
 // CHECK: [[AR:".*llvm-ar.*"]] "rcsD" "{{.*}}.out" [[A_OBJ_HOST]] [[B_OBJ_HOST]] [[OBJBUNDLE]]
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===================================================================
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -122,8 +122,7 @@
 // LINK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
 // LINK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
 
-// LINK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
-// LINK-SAME: "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
+// LINK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
 
 // LINK: [[LD:".*ld.*"]] {{.*}} "-o" "a.out" {{.*}} "[[A_OBJ_HOST]]"
 // LINK-SAME: "[[B_OBJ_HOST]]" "[[OBJBUNDLE]]"
Index: clang/test/Driver/hip-link-save-temps.hip
===================================================================
--- clang/test/Driver/hip-link-save-temps.hip
+++ clang/test/Driver/hip-link-save-temps.hip
@@ -45,8 +45,7 @@
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" "obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
 // CHECK: "{{.*lld.*}}" {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" "obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
-// CHECK: {{".*llvm-mc.*"}} "-triple" "amdgcn-amd-amdhsa" "-o"
-// CHECK-SAME: "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
+// CHECK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*.o]]" "{{.*}}.mcin" "--filetype=obj"
 // OUT: "{{.*ld.*}}" {{.*}} "-o" "executable" {{.*}} "[[OBJBUNDLE]]"
 // NOUT: "{{.*ld.*}}" {{.*}} "-o" "a.out" {{.*}} "[[OBJBUNDLE]]"
 // SLO: "{{.*llvm-ar.*}}" "rcsD" "libTest.a" {{.*}} "[[OBJBUNDLE]]"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -193,8 +193,7 @@
 
   Objf << ObjBuffer;
 
-  ArgStringList McArgs{"-triple", Args.MakeArgString(TC.getTripleString()),
-                       "-o",      Output.getFilename(),
+  ArgStringList McArgs{"-o",      Output.getFilename(),
                        McinFile,  "--filetype=obj"};
   const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc"));
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83145.275671.patch
Type: text/x-patch
Size: 3890 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:18:18 2020
From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:18:18 +0000 (UTC)
Subject: [PATCH] D82930: [HIP] Fix rocm detection
In-Reply-To: 
References: 
Message-ID: <09c048a0f1a052e910a041d1cc35b982@localhost.localdomain>

tra added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+    llvm::ErrorOr> VersionFile =
+        FS.getBufferForFile(BinPath + "/.hipVersion");
+    if (!VersionFile)
----------------
arsenm wrote:
> yaxunl wrote:
> > yaxunl wrote:
> > > yaxunl wrote:
> > > > tra wrote:
> > > > > arsenm wrote:
> > > > > > yaxunl wrote:
> > > > > > > arsenm wrote:
> > > > > > > > arsenm wrote:
> > > > > > > > > yaxunl wrote:
> > > > > > > > > > arsenm wrote:
> > > > > > > > > > > I don't think the detection should fail if this is missing
> > > > > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken.
> > > > > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests
> > > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it
> > > > > > > what is the directory structure of your most modern layout?
> > > > > > /opt/rocm/amdgcn/bitcode/foo.bc
> > > > > > 
> > > > > > The plan is to remove this and rely on symlinks in the resource directory though
> > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it
> > > > > 
> > > > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code.
> > > > > 
> > > > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version.
> > > > > 
> > > > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary.
> > > > 
> > > > Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version.
> > > > 
> > > > 
> > > Currently clang includes some wrapper headers by default, which does not work with ROCm 3.5 since those device functions are defined in HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable including those wrapper headers. This is one example why we need detect HIP version.
> > I think we need to separate HIP runtime detection and device library detection and also separate hasValidHIPRuntime and hasValidDeviceLibrary. ROCm toolchain only need to make sure hasValidDeviceLibrary but HIP toolchain need both hasValidDeviceLibrary and hasValidHIPRuntime.
> Regardless of whether there's a version file or if does anything, I think the absence of one implies do the most modern thing
"The most modern thing" is an ever moving target. If the failure modes keep changing it will create a source of new problems every time something changes. Probably not a big issue in this case, but with (eventually) wide enough user base there will be some.

I assume that AMD does not have much of legacy user base yet for compilations with clang, so defaulting to a recent version may be sensible (unlike CUDA where clang had to deal with a lot of existing CUDA users using old CUDA versions). That said, I'd recommend pinning it to a **specific** version, so the expectations remain stable. Then we can document the failure/fallback in a way users can deal with -- `if no version file is found, clang assumes version x.y and expects to find files X, Y and Z in directory A, B, C. You can specify the locations manually with --something-something-X=A or specify the version with --hip-version=3.7`. 

Considering that clang is being used from various derived tools, you may not always have the luxury of having the whole ROCm installation around and need to be able to override the expectations via command line flags.

If we have a way to override the version, then it does not matter all that much which version we pick as a fallback. If the guess is wrong, we can always correct it with a flag.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82930/new/

https://reviews.llvm.org/D82930




From cfe-commits at lists.llvm.org  Tue Jul  7 10:21:19 2020
From: cfe-commits at lists.llvm.org (Jennifer Yu via cfe-commits)
Date: Tue, 07 Jul 2020 10:21:19 -0700 (PDT)
Subject: [clang] 6cf0dac - orrectly generate invert xor value for Binary
 Atomics of int size > 64
Message-ID: <5f04af0f.1c69fb81.70ffa.04e6@mx.google.com>


Author: Jennifer Yu
Date: 2020-07-07T10:20:14-07:00
New Revision: 6cf0dac1ca3fd56c51f6a60f0be01cc25a1a2c6a

URL: https://github.com/llvm/llvm-project/commit/6cf0dac1ca3fd56c51f6a60f0be01cc25a1a2c6a
DIFF: https://github.com/llvm/llvm-project/commit/6cf0dac1ca3fd56c51f6a60f0be01cc25a1a2c6a.diff

LOG: orrectly generate invert xor value for Binary Atomics of int size > 64

When using __sync_nand_and_fetch with __int128, a problem is found that
the wrong value for the 'invert' value gets emitted to the xor in case
where the int size is greater than 64 bits.

This is because uses of llvm::ConstantInt::get which zero extends the
greater than 64 bits, so instead -1 that we require, it end up
getting 18446744073709551615

This patch replaces the call to llvm::ConstantInt::get with the call
to llvm::Constant::getAllOnesValue which works for all integer types.

Reviewers: jfp, erichkeane, rjmccall, hfinkel

Differential Revision: https://reviews.llvm.org/D82832

Added: 
    

Modified: 
    clang/lib/CodeGen/CGBuiltin.cpp
    clang/test/CodeGen/Atomics.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 91969267cdb9..1d81ede5dc31 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -219,8 +219,9 @@ static RValue EmitBinaryAtomicPost(CodeGenFunction &CGF,
       Kind, Args[0], Args[1], llvm::AtomicOrdering::SequentiallyConsistent);
   Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]);
   if (Invert)
-    Result = CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
-                                     llvm::ConstantInt::get(IntType, -1));
+    Result =
+        CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
+                                llvm::ConstantInt::getAllOnesValue(IntType));
   Result = EmitFromInt(CGF, Result, T, ValueType);
   return RValue::get(Result);
 }

diff  --git a/clang/test/CodeGen/Atomics.c b/clang/test/CodeGen/Atomics.c
index d960ac6df2f9..ebc9c139775a 100644
--- a/clang/test/CodeGen/Atomics.c
+++ b/clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@ signed int si;
 unsigned int ui;
 signed long long sll;
 unsigned long long ull;
+__int128 s128;
+unsigned  __int128 u128;
 
 void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
 {
@@ -48,6 +50,8 @@ void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
   (void) __sync_fetch_and_xor (&ui, 1); // CHECK: atomicrmw xor i32
   (void) __sync_fetch_and_xor (&sll, 1); // CHECK: atomicrmw xor i64
   (void) __sync_fetch_and_xor (&ull, 1); // CHECK: atomicrmw xor i64
+  (void) __sync_fetch_and_xor (&u128, 1); // CHECK: atomicrmw xor i128
+  (void) __sync_fetch_and_xor (&s128, 1); // CHECK: atomicrmw xor i128
 
   (void) __sync_fetch_and_nand (&sc, 1); // CHECK: atomicrmw nand i8
   (void) __sync_fetch_and_nand (&uc, 1); // CHECK: atomicrmw nand i8
@@ -168,27 +172,43 @@ void test_op_and_fetch (void)
   sc = __sync_nand_and_fetch (&sc, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   uc = __sync_nand_and_fetch (&uc, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   ss = __sync_nand_and_fetch (&ss, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   us = __sync_nand_and_fetch (&us, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   si = __sync_nand_and_fetch (&si, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   ui = __sync_nand_and_fetch (&ui, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   sll = __sync_nand_and_fetch (&sll, uc); // CHECK: atomicrmw nand
                                           // CHECK: and
                                           // CHECK: xor
+                                          // CHECK: -1
   ull = __sync_nand_and_fetch (&ull, uc); // CHECK: atomicrmw nand
                                           // CHECK: and
                                           // CHECK: xor
+                                          // CHECK: -1
+  u128 = __sync_nand_and_fetch (&u128, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+                                          // CHECK: -1
+  s128 = __sync_nand_and_fetch (&s128, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+                                          // CHECK: -1
 
   sc = __sync_and_and_fetch (&sc, uc); // CHECK: atomicrmw and
   uc = __sync_and_and_fetch (&uc, uc); // CHECK: atomicrmw and


        

From cfe-commits at lists.llvm.org  Tue Jul  7 10:21:33 2020
From: cfe-commits at lists.llvm.org (Jennifer Yu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:21:33 +0000 (UTC)
Subject: [PATCH] D82832: Correctly generate invert xor value for Binary
 Atomics of int size > 64
In-Reply-To: 
References: 
Message-ID: <1ba6ccbfcfb4c7472187a4370889111d@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cf0dac1ca3f: orrectly generate invert xor value for Binary Atomics of int size > 64 (authored by jyu2).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82832/new/

https://reviews.llvm.org/D82832

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/Atomics.c


Index: clang/test/CodeGen/Atomics.c
===================================================================
--- clang/test/CodeGen/Atomics.c
+++ clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@
 unsigned int ui;
 signed long long sll;
 unsigned long long ull;
+__int128 s128;
+unsigned  __int128 u128;
 
 void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
 {
@@ -48,6 +50,8 @@
   (void) __sync_fetch_and_xor (&ui, 1); // CHECK: atomicrmw xor i32
   (void) __sync_fetch_and_xor (&sll, 1); // CHECK: atomicrmw xor i64
   (void) __sync_fetch_and_xor (&ull, 1); // CHECK: atomicrmw xor i64
+  (void) __sync_fetch_and_xor (&u128, 1); // CHECK: atomicrmw xor i128
+  (void) __sync_fetch_and_xor (&s128, 1); // CHECK: atomicrmw xor i128
 
   (void) __sync_fetch_and_nand (&sc, 1); // CHECK: atomicrmw nand i8
   (void) __sync_fetch_and_nand (&uc, 1); // CHECK: atomicrmw nand i8
@@ -168,27 +172,43 @@
   sc = __sync_nand_and_fetch (&sc, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   uc = __sync_nand_and_fetch (&uc, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   ss = __sync_nand_and_fetch (&ss, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   us = __sync_nand_and_fetch (&us, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   si = __sync_nand_and_fetch (&si, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   ui = __sync_nand_and_fetch (&ui, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   sll = __sync_nand_and_fetch (&sll, uc); // CHECK: atomicrmw nand
                                           // CHECK: and
                                           // CHECK: xor
+                                          // CHECK: -1
   ull = __sync_nand_and_fetch (&ull, uc); // CHECK: atomicrmw nand
                                           // CHECK: and
                                           // CHECK: xor
+                                          // CHECK: -1
+  u128 = __sync_nand_and_fetch (&u128, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+                                          // CHECK: -1
+  s128 = __sync_nand_and_fetch (&s128, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+                                          // CHECK: -1
 
   sc = __sync_and_and_fetch (&sc, uc); // CHECK: atomicrmw and
   uc = __sync_and_and_fetch (&uc, uc); // CHECK: atomicrmw and
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -219,8 +219,9 @@
       Kind, Args[0], Args[1], llvm::AtomicOrdering::SequentiallyConsistent);
   Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]);
   if (Invert)
-    Result = CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
-                                     llvm::ConstantInt::get(IntType, -1));
+    Result =
+        CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
+                                llvm::ConstantInt::getAllOnesValue(IntType));
   Result = EmitFromInt(CGF, Result, T, ValueType);
   return RValue::get(Result);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82832.276125.patch
Type: text/x-patch
Size: 4114 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:23:20 2020
From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:23:20 +0000 (UTC)
Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block
In-Reply-To: 
References: 
Message-ID: <5c179bfbf9a2f5830b58dfa603d13da0@localhost.localdomain>

ellis added a comment.

Hey @aaron.ballman, thanks for accepting my diff! Would you mind landing my diff since I don't have commit access yet?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82904/new/

https://reviews.llvm.org/D82904




From cfe-commits at lists.llvm.org  Tue Jul  7 10:30:04 2020
From: cfe-commits at lists.llvm.org (Erik Pilkington via cfe-commits)
Date: Tue, 07 Jul 2020 10:30:04 -0700 (PDT)
Subject: [clang] 7437a94 - [SemaObjC] Add a warning for @selector expressions
 that potentially refer to objc_direct methods
Message-ID: <5f04b11c.1c69fb81.9852f.a69b@mx.google.com>


Author: Erik Pilkington
Date: 2020-07-07T13:29:54-04:00
New Revision: 7437a9496528b838e6939dbcbb69a0acb5e1332d

URL: https://github.com/llvm/llvm-project/commit/7437a9496528b838e6939dbcbb69a0acb5e1332d
DIFF: https://github.com/llvm/llvm-project/commit/7437a9496528b838e6939dbcbb69a0acb5e1332d.diff

LOG: [SemaObjC] Add a warning for @selector expressions that potentially refer to objc_direct methods

By default, only warn when the selector matches a direct method in the current
class. This commit also adds a more strict off-by-default warning when there
isn't a non-direct method in the current class.

rdar://64621668

Differential revision: https://reviews.llvm.org/D82611

Added: 
    clang/test/SemaObjC/potentially-direct-selector.m

Modified: 
    clang/include/clang/Basic/DiagnosticGroups.td
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/lib/Sema/SemaExprObjC.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 37e0b77e79ed..76c38686a050 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1099,6 +1099,11 @@ def ObjCSignedCharBool : DiagGroup<"objc-signed-char-bool",
    ObjCBoolConstantConversion,
    TautologicalObjCBoolCompare]>;
 
+def ObjCPotentiallyDirectSelector : DiagGroup<"potentially-direct-selector">;
+def ObjCStrictPotentiallyDirectSelector :
+  DiagGroup<"strict-potentially-direct-selector",
+            [ObjCPotentiallyDirectSelector]>;
+
 // Inline ASM warnings.
 def ASMOperandWidths : DiagGroup<"asm-operand-widths">;
 def ASM : DiagGroup<"asm", [

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c935545610e0..e99fd3d1f105 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1378,8 +1378,14 @@ def warn_multiple_selectors: Warning<
   "several methods with selector %0 of mismatched types are found "
   "for the @selector expression">,
   InGroup, DefaultIgnore;
-def err_direct_selector_expression: Error<
+def err_direct_selector_expression : Error<
   "@selector expression formed with direct selector %0">;
+def warn_potentially_direct_selector_expression : Warning<
+  "@selector expression formed with potentially direct selector %0">,
+  InGroup;
+def warn_strict_potentially_direct_selector_expression : Warning<
+  warn_potentially_direct_selector_expression.Text>,
+  InGroup, DefaultIgnore;
 
 def err_objc_kindof_nonobject : Error<
   "'__kindof' specifier cannot be applied to non-object type %0">;

diff  --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp
index 192e4184d144..228a1ec3ba1f 100644
--- a/clang/lib/Sema/SemaExprObjC.cpp
+++ b/clang/lib/Sema/SemaExprObjC.cpp
@@ -1228,33 +1228,66 @@ static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc,
   }
 }
 
-static void HelperToDiagnoseDirectSelectorsExpr(Sema &S, SourceLocation AtLoc,
-                                                Selector Sel,
-                                                ObjCMethodList &MethList,
-                                                bool &onlyDirect) {
+static ObjCMethodDecl *LookupDirectMethodInMethodList(Sema &S, Selector Sel,
+                                                      ObjCMethodList &MethList,
+                                                      bool &onlyDirect,
+                                                      bool &anyDirect) {
+  (void)Sel;
   ObjCMethodList *M = &MethList;
-  for (M = M->getNext(); M; M = M->getNext()) {
+  ObjCMethodDecl *DirectMethod = nullptr;
+  for (; M; M = M->getNext()) {
     ObjCMethodDecl *Method = M->getMethod();
-    if (Method->getSelector() != Sel)
+    if (!Method)
       continue;
-    if (!Method->isDirectMethod())
+    assert(Method->getSelector() == Sel && "Method with wrong selector in method list");
+    if (Method->isDirectMethod()) {
+      anyDirect = true;
+      DirectMethod = Method;
+    } else
       onlyDirect = false;
   }
+
+  return DirectMethod;
 }
 
-static void DiagnoseDirectSelectorsExpr(Sema &S, SourceLocation AtLoc,
-                                        Selector Sel, bool &onlyDirect) {
-  for (Sema::GlobalMethodPool::iterator b = S.MethodPool.begin(),
-       e = S.MethodPool.end(); b != e; b++) {
-    // first, instance methods
-    ObjCMethodList &InstMethList = b->second.first;
-    HelperToDiagnoseDirectSelectorsExpr(S, AtLoc, Sel, InstMethList,
-                                        onlyDirect);
+// Search the global pool for (potentially) direct methods matching the given
+// selector. If a non-direct method is found, set \param onlyDirect to false. If
+// a direct method is found, set \param anyDirect to true. Returns a direct
+// method, if any.
+static ObjCMethodDecl *LookupDirectMethodInGlobalPool(Sema &S, Selector Sel,
+                                                      bool &onlyDirect,
+                                                      bool &anyDirect) {
+  auto Iter = S.MethodPool.find(Sel);
+  if (Iter == S.MethodPool.end())
+    return nullptr;
 
-    // second, class methods
-    ObjCMethodList &ClsMethList = b->second.second;
-    HelperToDiagnoseDirectSelectorsExpr(S, AtLoc, Sel, ClsMethList, onlyDirect);
-  }
+  ObjCMethodDecl *DirectInstance = LookupDirectMethodInMethodList(
+      S, Sel, Iter->second.first, onlyDirect, anyDirect);
+  ObjCMethodDecl *DirectClass = LookupDirectMethodInMethodList(
+      S, Sel, Iter->second.second, onlyDirect, anyDirect);
+
+  return DirectInstance ? DirectInstance : DirectClass;
+}
+
+static ObjCMethodDecl *findMethodInCurrentClass(Sema &S, Selector Sel) {
+  auto *CurMD = S.getCurMethodDecl();
+  if (!CurMD)
+    return nullptr;
+  ObjCInterfaceDecl *IFace = CurMD->getClassInterface();
+
+  // The language enforce that only one direct method is present in a given
+  // class, so we just need to find one method in the current class to know
+  // whether Sel is potentially direct in this context.
+  if (ObjCMethodDecl *MD = IFace->lookupMethod(Sel, /*isInstance=*/true))
+    return MD;
+  if (ObjCMethodDecl *MD = IFace->lookupPrivateMethod(Sel, /*isInstance=*/true))
+    return MD;
+  if (ObjCMethodDecl *MD = IFace->lookupMethod(Sel, /*isInstance=*/false))
+    return MD;
+  if (ObjCMethodDecl *MD = IFace->lookupPrivateMethod(Sel, /*isInstance=*/false))
+    return MD;
+
+  return nullptr;
 }
 
 ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
@@ -1280,15 +1313,38 @@ ExprResult Sema::ParseObjCSelectorExpression(Selector Sel,
     } else
         Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
   } else {
-    bool onlyDirect = Method->isDirectMethod();
-    DiagnoseDirectSelectorsExpr(*this, AtLoc, Sel, onlyDirect);
     DiagnoseMismatchedSelectors(*this, AtLoc, Method, LParenLoc, RParenLoc,
                                 WarnMultipleSelectors);
+
+    bool onlyDirect = true;
+    bool anyDirect = false;
+    ObjCMethodDecl *GlobalDirectMethod =
+        LookupDirectMethodInGlobalPool(*this, Sel, onlyDirect, anyDirect);
+
     if (onlyDirect) {
       Diag(AtLoc, diag::err_direct_selector_expression)
           << Method->getSelector();
       Diag(Method->getLocation(), diag::note_direct_method_declared_at)
           << Method->getDeclName();
+    } else if (anyDirect) {
+      // If we saw any direct methods, see if we see a direct member of the
+      // current class. If so, the @selector will likely be used to refer to
+      // this direct method.
+      ObjCMethodDecl *LikelyTargetMethod = findMethodInCurrentClass(*this, Sel);
+      if (LikelyTargetMethod && LikelyTargetMethod->isDirectMethod()) {
+        Diag(AtLoc, diag::warn_potentially_direct_selector_expression) << Sel;
+        Diag(LikelyTargetMethod->getLocation(),
+             diag::note_direct_method_declared_at)
+            << LikelyTargetMethod->getDeclName();
+      } else if (!LikelyTargetMethod) {
+        // Otherwise, emit the "strict" variant of this diagnostic, unless
+        // LikelyTargetMethod is non-direct.
+        Diag(AtLoc, diag::warn_strict_potentially_direct_selector_expression)
+            << Sel;
+        Diag(GlobalDirectMethod->getLocation(),
+             diag::note_direct_method_declared_at)
+            << GlobalDirectMethod->getDeclName();
+      }
     }
   }
 

diff  --git a/clang/test/SemaObjC/potentially-direct-selector.m b/clang/test/SemaObjC/potentially-direct-selector.m
new file mode 100644
index 000000000000..04f9d2111c9b
--- /dev/null
+++ b/clang/test/SemaObjC/potentially-direct-selector.m
@@ -0,0 +1,157 @@
+// RUN: %clang_cc1 %s -Wpotentially-direct-selector -verify
+// RUN: %clang_cc1 %s -Wstrict-potentially-direct-selector -verify=expected,strict
+
+#define NS_DIRECT __attribute__((objc_direct))
+
+__attribute__((objc_root_class))
+ at interface Dummies
+-(void)inBase;
+-(void)inBaseImpl;
+-(void)inBaseCat;
+-(void)inBaseCatImpl;
+-(void)inDerived;
+-(void)inDerivedImpl;
+-(void)inDerivedCat;
+-(void)inDerivedCatImpl;
++(void)inBaseClass;
++(void)inDerivedClass;
++(void)inDerivedCatClass;
+ at end
+
+__attribute__((objc_root_class))
+ at interface Base
+-(void)inBase NS_DIRECT; // expected-note + {{direct method}}
++(void)inBaseClass NS_DIRECT;  // expected-note + {{direct method}}
+ at end
+
+ at implementation Base
+-(void)inBaseImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inBase {}
++(void)inBaseClass {}
+ at end
+
+ at interface Base (Cat)
+-(void)inBaseCat NS_DIRECT; // expected-note + {{direct method}}
+ at end
+
+ at implementation Base (Cat)
+-(void)inBaseCatImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inBaseCat {}
+ at end
+
+ at interface Derived : Base
+-(void)inDerived NS_DIRECT; // expected-note + {{direct method}}
++(void)inDerivedClass NS_DIRECT;  // expected-note + {{direct method}}
+ at end
+
+ at implementation Derived
+-(void)inDerivedImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inDerived {}
++(void)inDerivedClass {}
+ at end
+
+ at interface Derived (Cat)
+-(void)inDerivedCat NS_DIRECT; // expected-note + {{direct method}}
++(void)inDerivedCatClass NS_DIRECT; // expected-note + {{direct method}}
+ at end
+
+ at implementation Derived (Cat)
+-(void)inDerivedCatImpl NS_DIRECT { // expected-note + {{direct method}}
+}
+-(void)inDerivedCat {}
++(void)inDerivedCatClass {}
+
+-(void)test1 {
+  (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+}
+ at end
+
+void test2() {
+  (void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+}
+
+ at interface OnlyBase : Base @end
+ at implementation OnlyBase
+-(void)test3 {
+  (void)@selector(inBase); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseClass); // expected-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+}
+ at end
+
+__attribute__((objc_root_class))
+ at interface Unrelated @end
+ at implementation Unrelated
+-(void)test4 {
+  (void)@selector(inBase); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerived); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCat); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatImpl); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inBaseClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+  (void)@selector(inDerivedCatClass); // strict-warning{{@selector expression formed with potentially direct selector}}
+}
+ at end
+
+ at implementation Dummies
+-(void)inBase {}
+-(void)inBaseImpl {}
+-(void)inBaseCat {}
+-(void)inBaseCatImpl {}
+-(void)inDerived {}
+-(void)inDerivedImpl {}
+-(void)inDerivedCat {}
+-(void)inDerivedCatImpl {}
++(void)inBaseClass {}
++(void)inDerivedClass {}
++(void)inDerivedCatClass {}
+
+-(void)test5 {
+  (void)@selector(inBase);
+  (void)@selector(inBaseImpl);
+  (void)@selector(inBaseCat);
+  (void)@selector(inBaseCatImpl);
+  (void)@selector(inDerived);
+  (void)@selector(inDerivedImpl);
+  (void)@selector(inDerivedCat);
+  (void)@selector(inDerivedCatImpl);
+  (void)@selector(inDerivedClass);
+  (void)@selector(inBaseClass);
+  (void)@selector(inDerivedCatClass);
+}
+ at end


        

From cfe-commits at lists.llvm.org  Tue Jul  7 10:30:06 2020
From: cfe-commits at lists.llvm.org (Erik Pilkington via cfe-commits)
Date: Tue, 07 Jul 2020 10:30:06 -0700 (PDT)
Subject: [clang] 2f71cf6 - [SemaObjC] Fix a -Wobjc-signed-char-bool
 false-positive with binary conditional operator
Message-ID: <5f04b11e.1c69fb81.85f01.9fed@mx.google.com>


Author: Erik Pilkington
Date: 2020-07-07T13:29:54-04:00
New Revision: 2f71cf6d77c5cc679968851080d0513d84ddccb6

URL: https://github.com/llvm/llvm-project/commit/2f71cf6d77c5cc679968851080d0513d84ddccb6
DIFF: https://github.com/llvm/llvm-project/commit/2f71cf6d77c5cc679968851080d0513d84ddccb6.diff

LOG: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional operator

We were previously bypassing the conditional expression special case for binary
conditional expressions.

rdar://64134411

Differential revision: https://reviews.llvm.org/D81751

Added: 
    

Modified: 
    clang/lib/Sema/SemaChecking.cpp
    clang/test/SemaObjC/signed-char-bool-conversion.m

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2b52415b2800..77858b17d62c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
       }
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
                                      SourceLocation CC, QualType T);
 
 static void CheckConditionalOperand(Sema &S, Expr *E, QualType T,
                                     SourceLocation CC, bool &ICContext) {
   E = E->IgnoreParenImpCasts();
 
-  if (isa(E))
-    return CheckConditionalOperator(S, cast(E), CC, T);
+  if (auto *CO = dyn_cast(E))
+    return CheckConditionalOperator(S, CO, CC, T);
 
   AnalyzeImplicitConversions(S, E, CC);
   if (E->getType() != T)
     return CheckImplicitConversion(S, E, T, CC, &ICContext);
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
                                      SourceLocation CC, QualType T) {
   AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
 
+  Expr *TrueExpr = E->getTrueExpr();
+  if (auto *BCO = dyn_cast(E))
+    TrueExpr = BCO->getCommon();
+
   bool Suspicious = false;
-  CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
+  CheckConditionalOperand(S, TrueExpr, T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
   if (T->isBooleanType())
@@ -11975,7 +11979,7 @@ static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
   if (E->getType() == T) return;
 
   Suspicious = false;
-  CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(),
+  CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
                           E->getType(), CC, &Suspicious);
   if (!Suspicious)
     CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
@@ -12038,7 +12042,7 @@ static void AnalyzeImplicitConversions(
 
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
-  if (auto *CO = dyn_cast(SourceExpr)) {
+  if (auto *CO = dyn_cast(SourceExpr)) {
     CheckConditionalOperator(S, CO, CC, T);
     return;
   }

diff  --git a/clang/test/SemaObjC/signed-char-bool-conversion.m b/clang/test/SemaObjC/signed-char-bool-conversion.m
index 183f60fafcd5..9442d8fa86a9 100644
--- a/clang/test/SemaObjC/signed-char-bool-conversion.m
+++ b/clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@ int main() {
   f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+               ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+}


        

From cfe-commits at lists.llvm.org  Tue Jul  7 10:30:18 2020
From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:30:18 +0000 (UTC)
Subject: [PATCH] D82611: [SemaObjC] Add a warning for @selector expressions
 that potentially refer to objc_direct methods
In-Reply-To: 
References: 
Message-ID: <99c4aedf4d9aefb52c57d2fc302ef55f@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG7437a9496528: [SemaObjC] Add a warning for @selector expressions that potentially refer to… (authored by erik.pilkington).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82611/new/

https://reviews.llvm.org/D82611

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/potentially-direct-selector.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82611.276129.patch
Type: text/x-patch
Size: 15290 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:30:22 2020
From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:30:22 +0000 (UTC)
Subject: [PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool
 false-positive with binary conditional operator
In-Reply-To: 
References: 
Message-ID: 

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f71cf6d77c5: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D81751?vs=270455&id=276130#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81751/new/

https://reviews.llvm.org/D81751

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/signed-char-bool-conversion.m


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===================================================================
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+               ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@
       }
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
                                      SourceLocation CC, QualType T);
 
 static void CheckConditionalOperand(Sema &S, Expr *E, QualType T,
                                     SourceLocation CC, bool &ICContext) {
   E = E->IgnoreParenImpCasts();
 
-  if (isa(E))
-    return CheckConditionalOperator(S, cast(E), CC, T);
+  if (auto *CO = dyn_cast(E))
+    return CheckConditionalOperator(S, CO, CC, T);
 
   AnalyzeImplicitConversions(S, E, CC);
   if (E->getType() != T)
     return CheckImplicitConversion(S, E, T, CC, &ICContext);
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
                                      SourceLocation CC, QualType T) {
   AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
 
+  Expr *TrueExpr = E->getTrueExpr();
+  if (auto *BCO = dyn_cast(E))
+    TrueExpr = BCO->getCommon();
+
   bool Suspicious = false;
-  CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
+  CheckConditionalOperand(S, TrueExpr, T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
   if (T->isBooleanType())
@@ -11975,7 +11979,7 @@
   if (E->getType() == T) return;
 
   Suspicious = false;
-  CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(),
+  CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
                           E->getType(), CC, &Suspicious);
   if (!Suspicious)
     CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
@@ -12038,7 +12042,7 @@
 
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
-  if (auto *CO = dyn_cast(SourceExpr)) {
+  if (auto *CO = dyn_cast(SourceExpr)) {
     CheckConditionalOperator(S, CO, CC, T);
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81751.276130.patch
Type: text/x-patch
Size: 3347 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:31:24 2020
From: cfe-commits at lists.llvm.org (Michael Spencer via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:31:24 +0000 (UTC)
Subject: [PATCH] D83315: Turn arcmt-* options into a single option
In-Reply-To: 
References: 
Message-ID: <529d0c7d3436f22d788a48c7f6f2a7a7@localhost.localdomain>

Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

I have a slight preference for `-arcmt-action=`, but up to you if you want to change it. Otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83315/new/

https://reviews.llvm.org/D83315




From cfe-commits at lists.llvm.org  Tue Jul  7 10:31:24 2020
From: cfe-commits at lists.llvm.org (Aaron Ballman via cfe-commits)
Date: Tue, 07 Jul 2020 10:31:24 -0700 (PDT)
Subject: [clang-tools-extra] dfa0db7 - Warn pointer captured in async block
Message-ID: <5f04b16c.1c69fb81.35cd.7256@mx.google.com>


Author: Ellis Hoag
Date: 2020-07-07T13:31:14-04:00
New Revision: dfa0db79d0e37d5cf24a63d1e2b7ba5f40617574

URL: https://github.com/llvm/llvm-project/commit/dfa0db79d0e37d5cf24a63d1e2b7ba5f40617574
DIFF: https://github.com/llvm/llvm-project/commit/dfa0db79d0e37d5cf24a63d1e2b7ba5f40617574.diff

LOG: Warn pointer captured in async block

The block arguments in dispatch_async() and dispatch_after() are
guaranteed to escape. If those blocks capture any pointers with the
noescape attribute then it is an error.

Added: 
    clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
    clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
    clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
    clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m

Modified: 
    clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
    clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
    clang-tools-extra/docs/ReleaseNotes.rst
    clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index d010c3ce7e52..3f735a8484d8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -34,6 +34,7 @@
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
 #include "MultipleStatementMacroCheck.h"
+#include "NoEscapeCheck.h"
 #include "NotNullTerminatedResultCheck.h"
 #include "ParentVirtualCallCheck.h"
 #include "PosixReturnCheck.h"
@@ -120,6 +121,7 @@ class BugproneModule : public ClangTidyModule {
         "bugprone-multiple-statement-macro");
     CheckFactories.registerCheck(
         "bugprone-narrowing-conversions");
+    CheckFactories.registerCheck("bugprone-no-escape");
     CheckFactories.registerCheck(
         "bugprone-not-null-terminated-result");
     CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 6cc60ff0d7bc..6e7a94928a5a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -29,6 +29,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
   MultipleStatementMacroCheck.cpp
+  NoEscapeCheck.cpp
   NotNullTerminatedResultCheck.cpp
   ParentVirtualCallCheck.cpp
   PosixReturnCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
new file mode 100644
index 000000000000..654e80d9a9c6
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.cpp
@@ -0,0 +1,51 @@
+//===--- NoEscapeCheck.cpp - clang-tidy -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "NoEscapeCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void NoEscapeCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::dispatch_async"))),
+                              argumentCountIs(2),
+                              hasArgument(1, blockExpr().bind("arg-block"))),
+                     this);
+  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::dispatch_after"))),
+                              argumentCountIs(3),
+                              hasArgument(2, blockExpr().bind("arg-block"))),
+                     this);
+}
+
+void NoEscapeCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *MatchedEscapingBlock =
+      Result.Nodes.getNodeAs("arg-block");
+  const BlockDecl *EscapingBlockDecl = MatchedEscapingBlock->getBlockDecl();
+  for (const BlockDecl::Capture &CapturedVar : EscapingBlockDecl->captures()) {
+    const VarDecl *Var = CapturedVar.getVariable();
+    if (Var && Var->hasAttr()) {
+      // FIXME: Add a method to get the location of the use of a CapturedVar so
+      // that we can diagnose the use of the pointer instead of the block.
+      diag(MatchedEscapingBlock->getBeginLoc(),
+           "pointer %0 with attribute 'noescape' is captured by an "
+           "asynchronously-executed block")
+          << Var;
+      diag(Var->getBeginLoc(), "the 'noescape' attribute is declared here.",
+           DiagnosticIDs::Note);
+    }
+  }
+}
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang

diff  --git a/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h b/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
new file mode 100644
index 000000000000..126c37c9df0a
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/NoEscapeCheck.h
@@ -0,0 +1,39 @@
+//===--- NoEscapeCheck.h - clang-tidy ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Block arguments in `dispatch_async()` and `dispatch_after()` are guaranteed
+/// to escape. If those blocks capture any pointers with the `noescape`
+/// attribute, then we warn the user of their error.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-no-escape.html
+class NoEscapeCheck : public ClangTidyCheck {
+public:
+  NoEscapeCheck(StringRef Name, ClangTidyContext *Context)
+      : ClangTidyCheck(Name, Context) {}
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+    return LangOpts.Blocks;
+  }
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_NOESCAPECHECK_H

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index c66d5eb6069e..c08fd45c2f96 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,6 +94,12 @@ New checks
   result of a memory allocation function (``malloc()``, ``calloc()``,
   ``realloc()``, ``alloca()``) instead of its argument.
 
+- New :doc:`bugprone-no-escape
+  ` check.
+
+  Finds pointers with the ``noescape`` attribute that are captured by an
+  asynchronously-executed block.
+
 - New :doc:`bugprone-spuriously-wake-up-functions
   ` check.
 
@@ -206,14 +212,14 @@ Changes in existing checks
   Now checks ``std::basic_string_view`` by default.
 
 - Improved :doc:`readability-else-after-return
-  ` check now supports a 
+  ` check now supports a
   `WarnOnConditionVariables` option to control whether to refactor condition
   variables where possible.
 
 - Improved :doc:`readability-identifier-naming
   ` check.
 
-  Now able to rename member references in class template definitions with 
+  Now able to rename member references in class template definitions with
   explicit access.
 
 - Improved :doc:`readability-qualified-auto

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
new file mode 100644
index 000000000000..ea137b9679cc
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - bugprone-no-escape
+
+bugprone-no-escape
+==================
+
+Finds pointers with the ``noescape`` attribute that are captured by an
+asynchronously-executed block. The block arguments in ``dispatch_async()`` and
+``dispatch_after()`` are guaranteed to escape, so it is an error if a pointer with the
+``noescape`` attribute is captured by one of these blocks.
+
+The following is an example of an invalid use of the ``noescape`` attribute.
+
+  .. code-block:: objc
+    void foo(__attribute__((noescape)) int *p) {
+      dispatch_async(queue, ^{
+        *p = 123;
+      });
+    });

diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 7356c585d20c..78fed1a8ed9c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@ Clang-Tidy Checks
    `bugprone-misplaced-widening-cast `_,
    `bugprone-move-forwarding-reference `_, "Yes"
    `bugprone-multiple-statement-macro `_,
+   `bugprone-no-escape `_, "Yes"
    `bugprone-not-null-terminated-result `_, "Yes"
    `bugprone-parent-virtual-call `_, "Yes"
    `bugprone-posix-return `_, "Yes"

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m b/clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
new file mode 100644
index 000000000000..11dba3345fa1
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-no-escape.m
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s bugprone-no-escape %t
+// RUN: %check_clang_tidy %s -assume-filename=bugprone-no-escape.c bugprone-no-escape %t -- -- -fblocks
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef struct dispatch_time_s *dispatch_time_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
+
+extern dispatch_queue_t queue;
+
+void test_noescape_attribute(__attribute__((noescape)) int *p, int *q) {
+  dispatch_async(queue, ^{
+    *p = 123;
+    // CHECK-MESSAGES: :[[@LINE-2]]:25: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+    // CHECK-MESSAGES: :[[@LINE-4]]:30: note: the 'noescape' attribute is declared here.
+  });
+
+  dispatch_after(456, queue, ^{
+    *p = 789;
+    // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: pointer 'p' with attribute 'noescape' is captured by an asynchronously-executed block [bugprone-no-escape]
+  });
+
+  dispatch_async(queue, ^{
+    *q = 0;
+    // CHECK-MESSAGES-NOT: :[[@LINE-2]]:25: warning: pointer 'q' with attribute 'noescape' is captured by an asynchronously-executed block
+  });
+}


        

From cfe-commits at lists.llvm.org  Tue Jul  7 10:32:22 2020
From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:32:22 +0000 (UTC)
Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block
In-Reply-To: 
References: 
Message-ID: <7f028ce6b2756ca84f9407d2601518cb@localhost.localdomain>

aaron.ballman closed this revision.
aaron.ballman added a comment.

In D82904#2136686 , @ellis wrote:

> Hey @aaron.ballman, thanks for accepting my diff! Would you mind landing my diff since I don't have commit access yet?


Gladly -- I've committed on your behalf in dfa0db79d0e37d5cf24a63d1e2b7ba5f40617574 , thank you for the patch!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82904/new/

https://reviews.llvm.org/D82904




From cfe-commits at lists.llvm.org  Tue Jul  7 10:34:30 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:34:30 +0000 (UTC)
Subject: [PATCH] D83325: [Sema] Be more thorough when unpacking the
 AS-qualified pointee for a pointer conversion.
Message-ID: 

ebevhan created this revision.
ebevhan added reviewers: svenvh, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When performing a pointer conversion as the second conversion
in an SCS where the conversion is a derived-to-base and the
address space of the type wants to change, we need to defer
the address space conversion until the third step since we
must perform two ImplicitCasts at once otherwise. We do this
by repacking the destination type we give to
CheckPointerConversion with the source address space.

However, this repacking does not take sugar into account, so
if the address spaces in question are hidden behind nodes like
AttributedType or MacroQualifiedType, it won't work properly.
Also, if the source AS is Default, getAddrSpaceQualType fails,
since it cannot apply a Default AS.

Use the canonical destination type to ensure that we strip
any sugar that would get in the way.

I'm unsure if this is currently broken upstream without other
patches to exploit the behavior, but the fix seems to work for
the use case in D62574 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83325

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/address-space-cast.cpp


Index: clang/test/CodeGenCXX/address-space-cast.cpp
===================================================================
--- clang/test/CodeGenCXX/address-space-cast.cpp
+++ clang/test/CodeGenCXX/address-space-cast.cpp
@@ -6,6 +6,16 @@
 void func_pvoid(__private__ void *x);
 void func_pint(__private__ int *x);
 
+class Base {
+};
+
+class Derived : public Base {
+};
+
+void fn(Derived *p) {
+  __private__ Base *b = (__private__ Base *)p;
+}
+
 void test_cast(char *gen_char_ptr, void *gen_void_ptr, int *gen_int_ptr) {
   // CHECK: %[[cast:.*]] = addrspacecast i8* %{{.*}} to i8 addrspace(5)*
   // CHECK-NEXT: store i8 addrspace(5)* %[[cast]]
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4237,14 +4237,21 @@
     }
 
     // Defer address space conversion to the third conversion.
+    // FIXME: If PerformImplicitConversion did not try to pass the final
+    // destination type to every conversion function in here, this would not
+    // be necessary since the address space conversion would be handled as
+    // a qualification conversion instead.
     QualType FromPteeType = From->getType()->getPointeeType();
     QualType ToPteeType = ToType->getPointeeType();
     QualType NewToType = ToType;
     if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
         FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
-      NewToType = Context.removeAddrSpaceQualType(ToPteeType);
-      NewToType = Context.getAddrSpaceQualType(NewToType,
-                                               FromPteeType.getAddressSpace());
+      NewToType =
+          Context.removeAddrSpaceQualType(ToPteeType.getCanonicalType());
+      if (FromPteeType.getAddressSpace() != LangAS::Default)
+        NewToType = Context.getAddrSpaceQualType(
+            NewToType, FromPteeType.getAddressSpace());
+
       if (ToType->isObjCObjectPointerType())
         NewToType = Context.getObjCObjectPointerType(NewToType);
       else if (ToType->isBlockPointerType())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83325.276132.patch
Type: text/x-patch
Size: 2105 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:36:04 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:36:04 +0000 (UTC)
Subject: [PATCH] D62574: Initial draft of target-configurable address spaces.
In-Reply-To: 
References: 
Message-ID: <93c0d2f05280d1686fd658aab07eb645@localhost.localdomain>

ebevhan added a comment.

In D62574#2136553 , @danilaml wrote:

> In D62574#2135662 , @ebevhan wrote:
>
> > It's generally not safe to alter address spaces below the top level. C is just very permissive about it.
>
>
> Isn't that also true for the top-level casts? Unless when it is. And the target should know when it's safe or not. It's just that for non top-level casts there is added condition that casts are noop (i.e. don't change the bit pattern of the pointer). At least that's how I see it.


Yes, I see what you mean. I think that the default assumption in Clang at the moment is that it is not safe to do so, hence the current design. Not that there are many targets that use address spaces, so perhaps that assumption is too conservative for ones that do downstream.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62574/new/

https://reviews.llvm.org/D62574




From cfe-commits at lists.llvm.org  Tue Jul  7 10:38:30 2020
From: cfe-commits at lists.llvm.org (Michael Spencer via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:38:30 +0000 (UTC)
Subject: [PATCH] D82574: Merge TableGen files used for clang options
In-Reply-To: 
References: 
Message-ID: <87b99b90a55fe4ae64f65c342576f77b@localhost.localdomain>

Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

LGTM. We can look at splitting it up again once we know what the dependencies are.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82574/new/

https://reviews.llvm.org/D82574




From cfe-commits at lists.llvm.org  Tue Jul  7 10:45:34 2020
From: cfe-commits at lists.llvm.org (Jennifer Yu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:45:34 +0000 (UTC)
Subject: [PATCH] D82832: Correctly generate invert xor value for Binary
 Atomics of int size > 64
In-Reply-To: 
References: 
Message-ID: <0ca19c7b12057b6d9fda247b517fc873@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cf0dac1ca3f: orrectly generate invert xor value for Binary Atomics of int size > 64 (authored by jyu2).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82832/new/

https://reviews.llvm.org/D82832

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/Atomics.c


Index: clang/test/CodeGen/Atomics.c
===================================================================
--- clang/test/CodeGen/Atomics.c
+++ clang/test/CodeGen/Atomics.c
@@ -10,6 +10,8 @@
 unsigned int ui;
 signed long long sll;
 unsigned long long ull;
+__int128 s128;
+unsigned  __int128 u128;
 
 void test_op_ignore (void) // CHECK-LABEL: define void @test_op_ignore
 {
@@ -48,6 +50,8 @@
   (void) __sync_fetch_and_xor (&ui, 1); // CHECK: atomicrmw xor i32
   (void) __sync_fetch_and_xor (&sll, 1); // CHECK: atomicrmw xor i64
   (void) __sync_fetch_and_xor (&ull, 1); // CHECK: atomicrmw xor i64
+  (void) __sync_fetch_and_xor (&u128, 1); // CHECK: atomicrmw xor i128
+  (void) __sync_fetch_and_xor (&s128, 1); // CHECK: atomicrmw xor i128
 
   (void) __sync_fetch_and_nand (&sc, 1); // CHECK: atomicrmw nand i8
   (void) __sync_fetch_and_nand (&uc, 1); // CHECK: atomicrmw nand i8
@@ -168,27 +172,43 @@
   sc = __sync_nand_and_fetch (&sc, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   uc = __sync_nand_and_fetch (&uc, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   ss = __sync_nand_and_fetch (&ss, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   us = __sync_nand_and_fetch (&us, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   si = __sync_nand_and_fetch (&si, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   ui = __sync_nand_and_fetch (&ui, uc); // CHECK: atomicrmw nand
                                         // CHECK: and
                                         // CHECK: xor
+                                        // CHECK: -1
   sll = __sync_nand_and_fetch (&sll, uc); // CHECK: atomicrmw nand
                                           // CHECK: and
                                           // CHECK: xor
+                                          // CHECK: -1
   ull = __sync_nand_and_fetch (&ull, uc); // CHECK: atomicrmw nand
                                           // CHECK: and
                                           // CHECK: xor
+                                          // CHECK: -1
+  u128 = __sync_nand_and_fetch (&u128, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+                                          // CHECK: -1
+  s128 = __sync_nand_and_fetch (&s128, uc); // CHECK: atomicrmw nand
+                                          // CHECK: and
+                                          // CHECK: xor
+                                          // CHECK: -1
 
   sc = __sync_and_and_fetch (&sc, uc); // CHECK: atomicrmw and
   uc = __sync_and_and_fetch (&uc, uc); // CHECK: atomicrmw and
Index: clang/lib/CodeGen/CGBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -219,8 +219,9 @@
       Kind, Args[0], Args[1], llvm::AtomicOrdering::SequentiallyConsistent);
   Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]);
   if (Invert)
-    Result = CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
-                                     llvm::ConstantInt::get(IntType, -1));
+    Result =
+        CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
+                                llvm::ConstantInt::getAllOnesValue(IntType));
   Result = EmitFromInt(CGF, Result, T, ValueType);
   return RValue::get(Result);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82832.275673.patch
Type: text/x-patch
Size: 4114 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:45:44 2020
From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:45:44 +0000 (UTC)
Subject: [PATCH] D82611: [SemaObjC] Add a warning for @selector expressions
 that potentially refer to objc_direct methods
In-Reply-To: 
References: 
Message-ID: <4e33d38ea7f09c4051537f575169eb39@localhost.localdomain>

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
erik.pilkington marked an inline comment as done.
Closed by commit rG7437a9496528: [SemaObjC] Add a warning for @selector expressions that potentially refer to… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D82611?vs=273549&id=275674#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82611/new/

https://reviews.llvm.org/D82611

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/potentially-direct-selector.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82611.275674.patch
Type: text/x-patch
Size: 15290 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:45:47 2020
From: cfe-commits at lists.llvm.org (Erik Pilkington via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:45:47 +0000 (UTC)
Subject: [PATCH] D81751: [SemaObjC] Fix a -Wobjc-signed-char-bool
 false-positive with binary conditional operator
In-Reply-To: 
References: 
Message-ID: <31e8084ed14eaa5e3e2563f82f6e3b9f@localhost.localdomain>

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2f71cf6d77c5: [SemaObjC] Fix a -Wobjc-signed-char-bool false-positive with binary conditional… (authored by erik.pilkington).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D81751?vs=270455&id=275675#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81751/new/

https://reviews.llvm.org/D81751

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjC/signed-char-bool-conversion.m


Index: clang/test/SemaObjC/signed-char-bool-conversion.m
===================================================================
--- clang/test/SemaObjC/signed-char-bool-conversion.m
+++ clang/test/SemaObjC/signed-char-bool-conversion.m
@@ -108,3 +108,15 @@
   f(); // expected-note {{in instantiation of function template specialization 'f' requested here}}
 }
 #endif
+
+void t5(BOOL b) {
+  int i;
+  b = b ?: YES; // no warning
+  b = b ?: i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = (b = i) // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+               ?: YES;
+  b = (1 ? YES : i) ?: YES; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+  b = b ?: (1 ? i : i); // expected-warning 2 {{implicit conversion from integral type 'int' to 'BOOL'}}
+
+  b = b ? YES : (i ?: 0); // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11936,27 +11936,31 @@
       }
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
                                      SourceLocation CC, QualType T);
 
 static void CheckConditionalOperand(Sema &S, Expr *E, QualType T,
                                     SourceLocation CC, bool &ICContext) {
   E = E->IgnoreParenImpCasts();
 
-  if (isa(E))
-    return CheckConditionalOperator(S, cast(E), CC, T);
+  if (auto *CO = dyn_cast(E))
+    return CheckConditionalOperator(S, CO, CC, T);
 
   AnalyzeImplicitConversions(S, E, CC);
   if (E->getType() != T)
     return CheckImplicitConversion(S, E, T, CC, &ICContext);
 }
 
-static void CheckConditionalOperator(Sema &S, ConditionalOperator *E,
+static void CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
                                      SourceLocation CC, QualType T) {
   AnalyzeImplicitConversions(S, E->getCond(), E->getQuestionLoc());
 
+  Expr *TrueExpr = E->getTrueExpr();
+  if (auto *BCO = dyn_cast(E))
+    TrueExpr = BCO->getCommon();
+
   bool Suspicious = false;
-  CheckConditionalOperand(S, E->getTrueExpr(), T, CC, Suspicious);
+  CheckConditionalOperand(S, TrueExpr, T, CC, Suspicious);
   CheckConditionalOperand(S, E->getFalseExpr(), T, CC, Suspicious);
 
   if (T->isBooleanType())
@@ -11975,7 +11979,7 @@
   if (E->getType() == T) return;
 
   Suspicious = false;
-  CheckImplicitConversion(S, E->getTrueExpr()->IgnoreParenImpCasts(),
+  CheckImplicitConversion(S, TrueExpr->IgnoreParenImpCasts(),
                           E->getType(), CC, &Suspicious);
   if (!Suspicious)
     CheckImplicitConversion(S, E->getFalseExpr()->IgnoreParenImpCasts(),
@@ -12038,7 +12042,7 @@
 
   // For conditional operators, we analyze the arguments as if they
   // were being fed directly into the output.
-  if (auto *CO = dyn_cast(SourceExpr)) {
+  if (auto *CO = dyn_cast(SourceExpr)) {
     CheckConditionalOperator(S, CO, CC, T);
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81751.275675.patch
Type: text/x-patch
Size: 3347 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 10:50:29 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:50:29 +0000 (UTC)
Subject: [PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete
 __gcov_flush
In-Reply-To: 
References: 
Message-ID: 

MaskRay marked 6 inline comments as done.
MaskRay added inline comments.


================
Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c:49
   dlerror();
-  void (*gcov_flush1)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
-  if (gcov_flush1 == NULL) {
-    fprintf(stderr, "unable to find __gcov_flush in func.shared': %s\n", dlerror());
+  void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset");
+  if (gcov_reset1 == NULL) {
----------------
serge-sans-paille wrote:
> Do we also need to test gcov_flush symbol here too?
`__gcov_flush` is deleted. We don't need to test it.


================
Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov:56
+// CHECK-NEXT:        1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:    #####:   51:    fprintf(stderr, "unable to find __gcov_reset in func.shared': %s\n", dlerror());
 // CHECK-NEXT:    #####:   52:    return EXIT_FAILURE;
----------------
serge-sans-paille wrote:
> Same question here, what about gcov_flush symbol?
`__gcov_flush` is deleted. We don't need to test it.


================
Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov:55
+// CHECK-NEXT:        1:   49:  void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset");
+// CHECK-NEXT:        1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:    #####:   51:    fprintf(stderr, "unable to find __gcov_reset in func.shared': %s\n", dlerror());
----------------
serge-sans-paille wrote:
> And here.
`__gcov_flush` is deleted. We don't need to test it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83149/new/

https://reviews.llvm.org/D83149




From cfe-commits at lists.llvm.org  Tue Jul  7 10:52:04 2020
From: cfe-commits at lists.llvm.org (Ellis Hoag via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:52:04 +0000 (UTC)
Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block
In-Reply-To: 
References: 
Message-ID: <1ac8ef47e478e8201ddd5d50dac859e9@localhost.localdomain>

ellis marked an inline comment as done.
ellis added inline comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst:13
+
+  .. code-block:: objc
+    void foo(__attribute__((noescape)) int *p) {
----------------
It looks like I triggered a build failure for the clang-tools docs http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/62418

I think the fix is to add a new line here, but I haven't been able to test it locally.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82904/new/

https://reviews.llvm.org/D82904




From cfe-commits at lists.llvm.org  Tue Jul  7 10:54:40 2020
From: cfe-commits at lists.llvm.org (Aaron Ballman via cfe-commits)
Date: Tue, 07 Jul 2020 10:54:40 -0700 (PDT)
Subject: [clang-tools-extra] aef04d3 - Speculatively fix the sphinx build.
Message-ID: <5f04b6e0.1c69fb81.a0b21.aed8@mx.google.com>


Author: Aaron Ballman
Date: 2020-07-07T13:54:28-04:00
New Revision: aef04d3306bff492f69f50675f65c9c4eedfab57

URL: https://github.com/llvm/llvm-project/commit/aef04d3306bff492f69f50675f65c9c4eedfab57
DIFF: https://github.com/llvm/llvm-project/commit/aef04d3306bff492f69f50675f65c9c4eedfab57.diff

LOG: Speculatively fix the sphinx build.

Added: 
    

Modified: 
    clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
index ea137b9679cc..770a71cc0425 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst
@@ -11,6 +11,7 @@ asynchronously-executed block. The block arguments in ``dispatch_async()`` and
 The following is an example of an invalid use of the ``noescape`` attribute.
 
   .. code-block:: objc
+
     void foo(__attribute__((noescape)) int *p) {
       dispatch_async(queue, ^{
         *p = 123;


        

From cfe-commits at lists.llvm.org  Tue Jul  7 10:55:32 2020
From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 17:55:32 +0000 (UTC)
Subject: [PATCH] D82904: [clang-tidy] Warn pointer captured in async block
In-Reply-To: 
References: 
Message-ID: <3250e3dfdf7e0f2347cf7b29e23b0ef4@localhost.localdomain>

aaron.ballman added inline comments.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/bugprone-no-escape.rst:13
+
+  .. code-block:: objc
+    void foo(__attribute__((noescape)) int *p) {
----------------
ellis wrote:
> It looks like I triggered a build failure for the clang-tools docs http://lab.llvm.org:8011/builders/clang-tools-sphinx-docs/builds/62418
> 
> I think the fix is to add a new line here, but I haven't been able to test it locally.
I pushed that fix up before getting your email. I'll keep an eye on the bot to ensure the fix worked. Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82904/new/

https://reviews.llvm.org/D82904




From cfe-commits at lists.llvm.org  Tue Jul  7 10:56:58 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via cfe-commits)
Date: Tue, 07 Jul 2020 10:56:58 -0700 (PDT)
Subject: [clang] 80a1b95 - [SystemZ ABI] Allow class types in
 GetSingleElementType
Message-ID: <5f04b76a.1c69fb81.0df5.7623@mx.google.com>


Author: Ulrich Weigand
Date: 2020-07-07T19:56:19+02:00
New Revision: 80a1b95b8e72674cef7efb39636dc73c248ae6f3

URL: https://github.com/llvm/llvm-project/commit/80a1b95b8e72674cef7efb39636dc73c248ae6f3
DIFF: https://github.com/llvm/llvm-project/commit/80a1b95b8e72674cef7efb39636dc73c248ae6f3.diff

LOG: [SystemZ ABI] Allow class types in GetSingleElementType

The SystemZ ABI specifies that aggregate types with just a single
member of floating-point type shall be passed as if they were just
a scalar of that type.  This applies to both struct and class types
(but not unions).

However, the current ABI support code in clang only checks this
case for struct types, which means that for class types, generated
code does not adhere to the platform ABI.

Fixed by accepting both struct and class types in the
SystemZABIInfo::GetSingleElementType routine.

Added: 
    

Modified: 
    clang/lib/CodeGen/TargetInfo.cpp
    clang/test/CodeGen/systemz-abi.c
    clang/test/CodeGen/systemz-abi.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 7947aff6cc2f..801adc29acd1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7208,7 +7208,9 @@ bool SystemZABIInfo::isFPArgumentType(QualType Ty) const {
 }
 
 QualType SystemZABIInfo::GetSingleElementType(QualType Ty) const {
-  if (const RecordType *RT = Ty->getAsStructureType()) {
+  const RecordType *RT = Ty->getAs();
+
+  if (RT && RT->isStructureOrClassType()) {
     const RecordDecl *RD = RT->getDecl();
     QualType Found;
 

diff  --git a/clang/test/CodeGen/systemz-abi.c b/clang/test/CodeGen/systemz-abi.c
index 35adbbe301c4..9f9cb2275bfa 100644
--- a/clang/test/CodeGen/systemz-abi.c
+++ b/clang/test/CodeGen/systemz-abi.c
@@ -155,6 +155,17 @@ struct agg_nofloat3 pass_agg_nofloat3(struct agg_nofloat3 arg) { return arg; }
 // CHECK-LABEL: define void @pass_agg_nofloat3(%struct.agg_nofloat3* noalias sret align 4 %{{.*}}, i32 %{{.*}})
 
 
+// Union types likewise are *not* float-like aggregate types
+
+union union_float { float a; };
+union union_float pass_union_float(union union_float arg) { return arg; }
+// CHECK-LABEL: define void @pass_union_float(%union.union_float* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+
+union union_double { double a; };
+union union_double pass_union_double(union union_double arg) { return arg; }
+// CHECK-LABEL: define void @pass_union_double(%union.union_double* noalias sret align 8 %{{.*}}, i64 %{{.*}})
+
+
 // Accessing variable argument lists
 
 int va_int(__builtin_va_list l) { return __builtin_va_arg(l, int); }

diff  --git a/clang/test/CodeGen/systemz-abi.cpp b/clang/test/CodeGen/systemz-abi.cpp
index cb381e88dd8f..7604dea41dde 100644
--- a/clang/test/CodeGen/systemz-abi.cpp
+++ b/clang/test/CodeGen/systemz-abi.cpp
@@ -2,10 +2,24 @@
 // RUN: %clang_cc1 -triple s390x-linux-gnu -emit-llvm -x c++ -o - %s -mfloat-abi soft \
 // RUN:   | FileCheck %s --check-prefix=SOFT-FLOAT
 
+// Verify that class types are also recognized as float-like aggregate types
+
+class agg_float_class { float a; };
+class agg_float_class pass_agg_float_class(class agg_float_class arg) { return arg; }
+// CHECK-LABEL: define void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL: define void @_Z20pass_agg_float_class15agg_float_class(%class.agg_float_class* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+
+class agg_double_class { double a; };
+class agg_double_class pass_agg_double_class(class agg_double_class arg) { return arg; }
+// CHECK-LABEL: define void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret align 8 %{{.*}}, double %{{.*}})
+// SOFT-FLOAT-LABEL: define void @_Z21pass_agg_double_class16agg_double_class(%class.agg_double_class* noalias sret align 8 %{{.*}}, i64 %{{.*}})
+
+
 // For compatibility with GCC, this structure is passed in an FPR in C++,
 // but passed in a GPR in C (checked in systemz-abi.c).
 
 struct agg_float_cpp { float a; int : 0; };
 struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp arg) { return arg; }
 // CHECK-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, float %{{.*}})
-// SOFT-FLOAT:  define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+


        

From cfe-commits at lists.llvm.org  Tue Jul  7 11:02:43 2020
From: cfe-commits at lists.llvm.org (Steven Wan via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:02:43 +0000 (UTC)
Subject: [PATCH] D79842: [clang][Driver] Correct tool search path priority
In-Reply-To: 
References: 
Message-ID: 

stevewan added a comment.

Yes, this issue was hit with the reland applied. When given a `--` format LLVM_DEFAULT_TARGET_TRIPLE, Clang would expand the target triple to `---`, and therefore causes the name mismatch between what the driver searches for and what the test case creates as the dummy tool.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79842/new/

https://reviews.llvm.org/D79842




From cfe-commits at lists.llvm.org  Tue Jul  7 11:04:22 2020
From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:04:22 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <1ffa4242979b5c754de3686e6cb3a85b@localhost.localdomain>

Xiangling_L updated this revision to Diff 276143.
Xiangling_L marked 14 inline comments as done.
Xiangling_L added a comment.

Fixed typedef issue on incomplete array field and add a test for it;
Added a test for where pack attribute on object also apply on base classes;
Addressed other comments;


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-Wpacked.cpp
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-pack-attr-on-base.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79719.276143.patch
Type: text/x-patch
Size: 65689 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 11:04:32 2020
From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:04:32 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <0233dc3cd40f3c87310528dfd8d6f470@localhost.localdomain>

Xiangling_L added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1225
+                       Context.getTargetInfo().getTriple().isPS4() ||
+                       Context.getTargetInfo().getTriple().isOSAIX()))
+               ? CharUnits::One()
----------------
hubert.reinterpretcast wrote:
> Thanks; verified that this is correct with `xlclang++` from IBM XL C/C++ for AIX with:
> ```
> struct A {
>   char x;
> };
> struct B {
>   int x;
> };
> struct __attribute__((__packed__)) C : A, B {} c;
> ```
> 
> Length is 5:
> ```
> [10]    m   0x00000004      .bss     1  extern                    c
> [11]    a4  0x00000005       0    0     CM       RW    0    0
> ```
> 
> @Xiangling_L, I suggest adding a case for this to the tests.
Sure, I will add it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Tue Jul  7 11:05:33 2020
From: cfe-commits at lists.llvm.org (Atmn Patel via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:05:33 +0000 (UTC)
Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing
 attribute to clang
In-Reply-To: 
References: 
Message-ID: <18113c629292031dcd34cffd2c681bbf@localhost.localdomain>

atmnpatel added inline comments.


================
Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+      static_cast(Val.getValue().Type) ==
+          OMP_DEFAULT_firstprivate) {
----------------
ABataev wrote:
> ABataev wrote:
> > No need for cast here. 
> Still no need for the cast
Sorry, I saw that before and checked if I could remove it and I can't. Val.getValue().Type is an unsigned int and the other is an enum.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591




From cfe-commits at lists.llvm.org  Tue Jul  7 11:07:39 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:07:39 +0000 (UTC)
Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing
 attribute to clang
In-Reply-To: 
References: 
Message-ID: 

ABataev added inline comments.


================
Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+      static_cast(Val.getValue().Type) ==
+          OMP_DEFAULT_firstprivate) {
----------------
atmnpatel wrote:
> ABataev wrote:
> > ABataev wrote:
> > > No need for cast here. 
> > Still no need for the cast
> Sorry, I saw that before and checked if I could remove it and I can't. Val.getValue().Type is an unsigned int and the other is an enum.
This enum should be converted to `int` implicitly, no?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591




From cfe-commits at lists.llvm.org  Tue Jul  7 11:10:49 2020
From: cfe-commits at lists.llvm.org (Zola Bridges via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:10:49 +0000 (UTC)
Subject: [PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses
In-Reply-To: 
References: 
Message-ID: <6e53767aca44da48de42fa830f591d11@localhost.localdomain>

zbrid updated this revision to Diff 276147.
zbrid added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79910/new/

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79910.276147.patch
Type: text/x-patch
Size: 8050 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 11:12:24 2020
From: cfe-commits at lists.llvm.org (Atmn Patel via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:12:24 +0000 (UTC)
Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing
 attribute to clang
In-Reply-To: 
References: 
Message-ID: <3baa8e029802ff893400395d3cab09e8@localhost.localdomain>

atmnpatel marked an inline comment as done.
atmnpatel added inline comments.


================
Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+      static_cast(Val.getValue().Type) ==
+          OMP_DEFAULT_firstprivate) {
----------------
ABataev wrote:
> atmnpatel wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > No need for cast here. 
> > > Still no need for the cast
> > Sorry, I saw that before and checked if I could remove it and I can't. Val.getValue().Type is an unsigned int and the other is an enum.
> This enum should be converted to `int` implicitly, no?
When we moved the definition of this enum over from clang to llvm, we converted them to strongly typed enums.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591




From cfe-commits at lists.llvm.org  Tue Jul  7 11:14:07 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:14:07 +0000 (UTC)
Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing
 attribute to clang
In-Reply-To: 
References: 
Message-ID: <9c9ca0c4acd9f51c8ad2904aeaf47d6e@localhost.localdomain>

ABataev added inline comments.


================
Comment at: clang/lib/Parse/ParseOpenMP.cpp:2787
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+      static_cast(Val.getValue().Type) ==
+          OMP_DEFAULT_firstprivate) {
----------------
atmnpatel wrote:
> ABataev wrote:
> > atmnpatel wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > No need for cast here. 
> > > > Still no need for the cast
> > > Sorry, I saw that before and checked if I could remove it and I can't. Val.getValue().Type is an unsigned int and the other is an enum.
> > This enum should be converted to `int` implicitly, no?
> When we moved the definition of this enum over from clang to llvm, we converted them to strongly typed enums.
I see. Ok then, leave it as is


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591




From cfe-commits at lists.llvm.org  Tue Jul  7 11:23:41 2020
From: cfe-commits at lists.llvm.org (serge via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:23:41 +0000 (UTC)
Subject: [PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete
 __gcov_flush
In-Reply-To: 
References: 
Message-ID: 

serge-sans-paille added inline comments.


================
Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c:49
   dlerror();
-  void (*gcov_flush1)() = (void (*)())dlsym(f1_handle, "__gcov_flush");
-  if (gcov_flush1 == NULL) {
-    fprintf(stderr, "unable to find __gcov_flush in func.shared': %s\n", dlerror());
+  void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset");
+  if (gcov_reset1 == NULL) {
----------------
MaskRay wrote:
> serge-sans-paille wrote:
> > Do we also need to test gcov_flush symbol here too?
> `__gcov_flush` is deleted. We don't need to test it.
Sorry, I meant `__gcov_dump`


================
Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov:56
+// CHECK-NEXT:        1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:    #####:   51:    fprintf(stderr, "unable to find __gcov_reset in func.shared': %s\n", dlerror());
 // CHECK-NEXT:    #####:   52:    return EXIT_FAILURE;
----------------
MaskRay wrote:
> serge-sans-paille wrote:
> > Same question here, what about gcov_flush symbol?
> `__gcov_flush` is deleted. We don't need to test it.
Sorry, I meant `__gcov_dump`


================
Comment at: compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov:55
+// CHECK-NEXT:        1:   49:  void (*gcov_reset1)() = (void (*)())dlsym(f1_handle, "__gcov_reset");
+// CHECK-NEXT:        1:   50:  if (gcov_reset1 == NULL) {
+// CHECK-NEXT:    #####:   51:    fprintf(stderr, "unable to find __gcov_reset in func.shared': %s\n", dlerror());
----------------
MaskRay wrote:
> serge-sans-paille wrote:
> > And here.
> `__gcov_flush` is deleted. We don't need to test it.
Sorry, I meant `__gcov_dump`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83149/new/

https://reviews.llvm.org/D83149




From cfe-commits at lists.llvm.org  Tue Jul  7 11:26:40 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:26:40 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

uweigand updated this revision to Diff 276151.
uweigand added a comment.

Rebased against mainline.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/systemz-abi.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81583.276151.patch
Type: text/x-patch
Size: 6453 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 11:28:41 2020
From: cfe-commits at lists.llvm.org (Zola Bridges via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:28:41 +0000 (UTC)
Subject: [PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses
In-Reply-To: 
References: 
Message-ID: <6611c6f397896b3308f0f941769787cb@localhost.localdomain>

zbrid updated this revision to Diff 276153.
zbrid added a comment.
Herald added a subscriber: jfb.

update seses flag


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79910/new/

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79910.276153.patch
Type: text/x-patch
Size: 10042 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 11:30:43 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:30:43 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <8837813feb0caaae2fc54443bdf23889@localhost.localdomain>

logan-5 added a comment.

In D82728#2135149 , @dblaikie wrote:

> Is the implementation you're proposing fairly consistent with GCC's? Run it over any big codebases to check it warns in the same places GCC does?


This patch has the same behavior as `-Wsuggest-override` in GCC >= 9. In GCC <9, it would suggest adding `override` to `void foo() final`, but in GCC >=9, `final` is enough to suppress the warning. This patch's `-Wsuggest-override`, as well as Clang's pre-existing `-Winconsistent-missing-override`, are also silenced by `final`. (https://godbolt.org/z/hbxLK6)

I built Clang itself with a Clang that had this patch, and with GCC with `-Wsuggest-override`, and compared the results--they were identical (except for the warning text). (618 warnings, for those interested.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 11:32:23 2020
From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:32:23 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <5fa370484d2c00434d77a7c43ba55372@localhost.localdomain>

zequanwu marked an inline comment as done.
zequanwu added inline comments.


================
Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT:         Branch Probability Analysis
+; CHECK-NEXT:         Block Frequency Analysis
 ; CHECK-NEXT:     FunctionPass Manager
----------------
zequanwu wrote:
> nikic wrote:
> > hans wrote:
> > > nikic wrote:
> > > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use?
> > > > 
> > > > PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided.
> > > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > > 
> > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > 
> > It would only help if there is some way to only fetch the analysis conditionally. I believe many PGO passes use something like PSI.hasProfileSummary() or F.hasProfileData() for that.
> > 
> > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > 
> > Right, just disabling this by default in clang/opt would also work.
> > 
> > For reference, the current compile-time numbers for this patch: https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff&to=8df840660bb764b6653fcfd9ac7a72cc6adebde6&stat=instructions Not huge, but it adds up (some similar regressions have been introduced in LLVM 10).
> Do you mean disabling it just for LPM or both?
> I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
For Clang, a better fix I think is that `Opts.CallGraphProfile` should based on both whether the integrated assembler is used and whether profile instrumentation is turned on. What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Tue Jul  7 11:33:40 2020
From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:33:40 +0000 (UTC)
Subject: [PATCH] D82930: [HIP] Fix rocm detection
In-Reply-To: 
References: 
Message-ID: <4c6e31e14bdd01982defe9806ccb10da@localhost.localdomain>

arsenm added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+    llvm::ErrorOr> VersionFile =
+        FS.getBufferForFile(BinPath + "/.hipVersion");
+    if (!VersionFile)
----------------
tra wrote:
> arsenm wrote:
> > yaxunl wrote:
> > > yaxunl wrote:
> > > > yaxunl wrote:
> > > > > tra wrote:
> > > > > > arsenm wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > arsenm wrote:
> > > > > > > > > arsenm wrote:
> > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > arsenm wrote:
> > > > > > > > > > > > I don't think the detection should fail if this is missing
> > > > > > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken.
> > > > > > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests
> > > > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it
> > > > > > > > what is the directory structure of your most modern layout?
> > > > > > > /opt/rocm/amdgcn/bitcode/foo.bc
> > > > > > > 
> > > > > > > The plan is to remove this and rely on symlinks in the resource directory though
> > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it
> > > > > > 
> > > > > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code.
> > > > > > 
> > > > > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version.
> > > > > > 
> > > > > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary.
> > > > > 
> > > > > Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version.
> > > > > 
> > > > > 
> > > > Currently clang includes some wrapper headers by default, which does not work with ROCm 3.5 since those device functions are defined in HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable including those wrapper headers. This is one example why we need detect HIP version.
> > > I think we need to separate HIP runtime detection and device library detection and also separate hasValidHIPRuntime and hasValidDeviceLibrary. ROCm toolchain only need to make sure hasValidDeviceLibrary but HIP toolchain need both hasValidDeviceLibrary and hasValidHIPRuntime.
> > Regardless of whether there's a version file or if does anything, I think the absence of one implies do the most modern thing
> "The most modern thing" is an ever moving target. If the failure modes keep changing it will create a source of new problems every time something changes. Probably not a big issue in this case, but with (eventually) wide enough user base there will be some.
> 
> I assume that AMD does not have much of legacy user base yet for compilations with clang, so defaulting to a recent version may be sensible (unlike CUDA where clang had to deal with a lot of existing CUDA users using old CUDA versions). That said, I'd recommend pinning it to a **specific** version, so the expectations remain stable. Then we can document the failure/fallback in a way users can deal with -- `if no version file is found, clang assumes version x.y and expects to find files X, Y and Z in directory A, B, C. You can specify the locations manually with --something-something-X=A or specify the version with --hip-version=3.7`. 
> 
> Considering that clang is being used from various derived tools, you may not always have the luxury of having the whole ROCm installation around and need to be able to override the expectations via command line flags.
> 
> If we have a way to override the version, then it does not matter all that much which version we pick as a fallback. If the guess is wrong, we can always correct it with a flag.
Unlike CUDA we're not really chasing some 3rd party thing that periodically drops unpredictable changes. We know what the most modern thing is on tip of tree


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82930/new/

https://reviews.llvm.org/D82930




From cfe-commits at lists.llvm.org  Tue Jul  7 11:35:03 2020
From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:35:03 +0000 (UTC)
Subject: [PATCH] D82659: Fix missing build dependency on omp_gen.
In-Reply-To: 
References: 
Message-ID: 

michele.scandale added a comment.

Why `omp_gen` is now a dependency of `clang-tablegen-targets` rather than being in the `LLVM_COMMON_DEPENDS` list like `clang-tablegen-targets`?

Moreover I've noticed that with the recent changes where  `omp_gen` has been added as a dependency in several libraries, this was done unconditionally breaking the Clang standalone build.
For the same issue `intrinsics_gen` is added only if `CLANG_BUILT_STANDALONE ` is false.

At this point I think that something like:

  # All targets below may depend on all tablegen'd files.
  get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
  add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
  set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
  list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
  if(NOT CLANG_BUILT_STANDALONE)
    list(APPEND LLVM_COMMON_DEPENDS omg_gen)
  endif()

would fix all the issues, and it would allow removing the explicit dependencies added to each clang library.

Is there any issue with my reasoning?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82659/new/

https://reviews.llvm.org/D82659




From cfe-commits at lists.llvm.org  Tue Jul  7 11:40:59 2020
From: cfe-commits at lists.llvm.org (Vy Nguyen via cfe-commits)
Date: Tue, 07 Jul 2020 11:40:59 -0700 (PDT)
Subject: [clang] a707da4 - Clang crashed while checking for deletion of copy
 and move ctors
Message-ID: <5f04c1bb.1c69fb81.91e0a.33ab@mx.google.com>


Author: Vy Nguyen
Date: 2020-07-07T14:40:37-04:00
New Revision: a707da4728dea51c1446cf582a46fb271f3969c3

URL: https://github.com/llvm/llvm-project/commit/a707da4728dea51c1446cf582a46fb271f3969c3
DIFF: https://github.com/llvm/llvm-project/commit/a707da4728dea51c1446cf582a46fb271f3969c3.diff

LOG: Clang crashed while checking for deletion of copy and move ctors

    Crash:
       @     0x559d129463fc  clang::CXXRecordDecl::defaultedCopyConstructorIsDeleted()
        @     0x559d1288d3e5  clang::Sema::checkIllFormedTrivialABIStruct()::$_7::operator()()
        @     0x559d12884c34  clang::Sema::checkIllFormedTrivialABIStruct()
        @     0x559d1288412e  clang::Sema::CheckCompletedCXXClass()
        @     0x559d1288d843  clang::Sema::ActOnFinishCXXMemberSpecification()
        @     0x559d12020109  clang::Parser::ParseCXXMemberSpecification()
        @     0x559d1201e80c  clang::Parser::ParseClassSpecifier()
        @     0x559d1204e807  clang::Parser::ParseDeclarationSpecifiers()
        @     0x559d120e9aa9  clang::Parser::ParseSingleDeclarationAfterTemplate()
        @     0x559d120e8f21  clang::Parser::ParseTemplateDeclarationOrSpecialization()
        @     0x559d120e8886  clang::Parser::ParseDeclarationStartingWithTemplate()
        @     0x559d1204a1d4  clang::Parser::ParseDeclaration()
        @     0x559d12004b1d  clang::Parser::ParseExternalDeclaration()
        @     0x559d12017689  clang::Parser::ParseInnerNamespace()
        @     0x559d12017024  clang::Parser::ParseNamespace()
        @     0x559d1204a29b  clang::Parser::ParseDeclaration()
        @     0x559d12004c74  clang::Parser::ParseExternalDeclaration()

    Subscribers: cfe-commits

    Tags: #clang

    Differential Revision: https://reviews.llvm.org/D83263

Added: 
    clang/test/SemaCXX/attr-trivial-abi.cpp

Modified: 
    clang/lib/Sema/SemaDeclCXX.cpp
    clang/test/SemaObjCXX/attr-trivial-abi.mm

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ef555788ee0e..eb001a77518b 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9719,6 +9719,10 @@ void Sema::checkIllFormedTrivialABIStruct(CXXRecordDecl &RD) {
 
   // Ill-formed if the copy and move constructors are deleted.
   auto HasNonDeletedCopyOrMoveConstructor = [&]() {
+    // If the type is dependent, then assume it might have
+    // implicit copy or move ctor because we won't know yet at this point.
+    if (RD.isDependentType())
+      return true;
     if (RD.needsImplicitCopyConstructor() &&
         !RD.defaultedCopyConstructorIsDeleted())
       return true;

diff  --git a/clang/test/SemaCXX/attr-trivial-abi.cpp b/clang/test/SemaCXX/attr-trivial-abi.cpp
new file mode 100644
index 000000000000..334b471d2ab8
--- /dev/null
+++ b/clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+void __attribute__((trivial_abi)) foo(); // expected-warning {{'trivial_abi' attribute only applies to classes}}
+
+// Should not crash.
+template 
+class __attribute__((trivial_abi)) a { a(a &&); };
+
+struct [[clang::trivial_abi]] S0 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S1 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}} expected-note {{is polymorphic}}
+  virtual void m();
+};
+
+struct S3_2 {
+  virtual void m();
+} __attribute__((trivial_abi)); // expected-warning {{'trivial_abi' cannot be applied to 'S3_2'}} expected-note {{is polymorphic}}
+
+struct __attribute__((trivial_abi)) S3_3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3_3'}} expected-note {{has a field of a non-trivial class type}}
+  S3_3(S3_3 &&);
+  S3_2 s32;
+};
+
+// Diagnose invalid trivial_abi even when the type is templated because it has a non-trivial field.
+template 
+struct __attribute__((trivial_abi)) S3_4 { // expected-warning {{'trivial_abi' cannot be applied to 'S3_4'}} expected-note {{has a field of a non-trivial class type}}
+  S3_4(S3_4 &&);
+  S3_2 s32;
+};
+
+struct S4 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}} expected-note {{has a virtual base}}
+};
+
+struct __attribute__((trivial_abi)) S9 : public S4 {
+};
+
+struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' attribute takes no arguments}}
+  int a;
+};
+
+// Do not warn about deleted ctors  when 'trivial_abi' is used to annotate a template class.
+template 
+struct __attribute__((trivial_abi)) S10 {
+  T p;
+};
+
+S10 p1;
+
+template 
+struct S14 {
+  T a;
+};
+
+template 
+struct __attribute__((trivial_abi)) S15 : S14 {
+};
+
+S15 s15;
+
+template 
+struct __attribute__((trivial_abi)) S16 {
+  S14 a;
+};
+
+S16 s16;
+
+template 
+struct __attribute__((trivial_abi)) S17 {
+};
+
+S17 s17;
+
+namespace deletedCopyMoveConstructor {
+struct __attribute__((trivial_abi)) CopyMoveDeleted { // expected-warning {{'trivial_abi' cannot be applied to 'CopyMoveDeleted'}} expected-note {{copy constructors and move constructors are all deleted}}
+  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
+  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
+};
+
+struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{copy constructors and move constructors are all deleted}}
+  CopyMoveDeleted a;
+};
+
+struct __attribute__((trivial_abi)) CopyDeleted {
+  CopyDeleted(const CopyDeleted &) = delete;
+  CopyDeleted(CopyDeleted &&) = default;
+};
+
+struct __attribute__((trivial_abi)) MoveDeleted {
+  MoveDeleted(const MoveDeleted &) = default;
+  MoveDeleted(MoveDeleted &&) = delete;
+};
+
+struct __attribute__((trivial_abi)) S19 { // expected-warning {{'trivial_abi' cannot be applied to 'S19'}} expected-note {{copy constructors and move constructors are all deleted}}
+  CopyDeleted a;
+  MoveDeleted b;
+};
+
+// This is fine since the move constructor isn't deleted.
+struct __attribute__((trivial_abi)) S20 {
+  int &&a; // a member of rvalue reference type deletes the copy constructor.
+};
+} // namespace deletedCopyMoveConstructor

diff  --git a/clang/test/SemaObjCXX/attr-trivial-abi.mm b/clang/test/SemaObjCXX/attr-trivial-abi.mm
index 537c1390a54a..87b79c14d07a 100644
--- a/clang/test/SemaObjCXX/attr-trivial-abi.mm
+++ b/clang/test/SemaObjCXX/attr-trivial-abi.mm
@@ -57,7 +57,7 @@ struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' at
 };
 
 // Do not warn when 'trivial_abi' is used to annotate a template class.
-template
+template 
 struct __attribute__((trivial_abi)) S10 {
   T p;
 };
@@ -76,21 +76,27 @@ struct __attribute__((trivial_abi)) S10 { // expected-warning {{'trivial_abi
   __weak id b;
 };
 
-template
+template 
 struct __attribute__((trivial_abi)) S15 : S14 {
 };
 
 S15 s15;
 
-template
+template 
 struct __attribute__((trivial_abi)) S16 {
   S14 a;
 };
 
 S16 s16;
 
-template
+template 
 struct __attribute__((trivial_abi)) S17 { // expected-warning {{'trivial_abi' cannot be applied to 'S17'}} expected-note {{has a __weak field}}
+  S17();
+  S17(S17 &&);
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S18 { // expected-warning {{'trivial_abi' cannot be applied to 'S18'}} expected-note {{has a __weak field}}
   __weak id a;
 };
 


        

From cfe-commits at lists.llvm.org  Tue Jul  7 11:41:02 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:41:02 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <347bb7f1d9f389c8737569bd10da6479@localhost.localdomain>

logan-5 updated this revision to Diff 276162.
logan-5 added a comment.

clang-formatted the diff.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82728.276162.patch
Type: text/x-patch
Size: 7674 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 11:43:22 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:43:22 +0000 (UTC)
Subject: [PATCH] D62574: Initial draft of target-configurable address spaces.
In-Reply-To: 
References: 
Message-ID: <96b4277ffdf4c5f39d5305914fd48dbb@localhost.localdomain>

ebevhan updated this revision to Diff 276163.
ebevhan added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62574/new/

https://reviews.llvm.org/D62574

Files:
  clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaFixItUtils.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CodeGenCXX/address-space-cast.cpp
  clang/test/Sema/address_space_print_macro.c
  clang/test/Sema/address_spaces.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62574.276163.patch
Type: text/x-patch
Size: 47390 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 11:53:29 2020
From: cfe-commits at lists.llvm.org (Sjoerd Meijer via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:53:29 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: 

SjoerdMeijer added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:118
+
+  if (!llvm::AArch64::getArchFeatures(ArchKind, Features))
+    return false;
----------------
Would it be more consistent to move this....


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:273
   const auto ItRFP16FML = std::find(Features.rbegin(), Features.rend(), "+fp16fml");
   if (llvm::is_contained(Features, "+v8.4a")) {
     const auto ItRFullFP16  = std::find(Features.rbegin(), Features.rend(), "+fullfp16");
----------------
...to somewhere here where implied target features are handled....


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:373
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
----------------
For example, to here.


================
Comment at: clang/test/Preprocessor/aarch64-target-features.c:115
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1
----------------
Can you add a run line for v8.5 if there isn't already one, and add CHECK-NOTs for these macros.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079




From cfe-commits at lists.llvm.org  Tue Jul  7 11:58:35 2020
From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:58:35 +0000 (UTC)
Subject: [PATCH] D82930: [HIP] Fix rocm detection
In-Reply-To: 
References: 
Message-ID: <8fc92581ba9093cb2b31e5b3017b29cd@localhost.localdomain>

tra added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:167
+    llvm::ErrorOr> VersionFile =
+        FS.getBufferForFile(BinPath + "/.hipVersion");
+    if (!VersionFile)
----------------
arsenm wrote:
> tra wrote:
> > arsenm wrote:
> > > yaxunl wrote:
> > > > yaxunl wrote:
> > > > > yaxunl wrote:
> > > > > > tra wrote:
> > > > > > > arsenm wrote:
> > > > > > > > yaxunl wrote:
> > > > > > > > > arsenm wrote:
> > > > > > > > > > arsenm wrote:
> > > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > > arsenm wrote:
> > > > > > > > > > > > > I don't think the detection should fail if this is missing
> > > > > > > > > > > > why? this file is unique to HIP installation. If it is missing, the installation is broken.
> > > > > > > > > > > Because I should be able to use this without a complete hip installation. Without a specified version, it should assume the most modern layout. This will for example break pointing --rocm-path at the device library build directory for library tests
> > > > > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it
> > > > > > > > > what is the directory structure of your most modern layout?
> > > > > > > > /opt/rocm/amdgcn/bitcode/foo.bc
> > > > > > > > 
> > > > > > > > The plan is to remove this and rely on symlinks in the resource directory though
> > > > > > > > I also don't see what value checking the version really provides; it may be informative to print it, but I don't think it's useful to derive information from it
> > > > > > > 
> > > > > > > In CUDA it's used to detect which back-end features to enable (they depend on what's supported by ptxas supplied by that CUDA version). I don't think that would be relevant to AMDGPU as it does not need external dependencies to generate GPU code.
> > > > > > > 
> > > > > > > It may be useful for filesystem layout detection. E.g. where to find bitcode files and what names to expect. This part seems to be relevant for ROCm, but I'm not sure if the layout is closely tied to the version.
> > > > > > > 
> > > > > > We are required to support previous ROCm releases for certain time range. To do that we need to detect HIP version and enable/disable certain HIP features based on HIP version when necessary.
> > > > > > 
> > > > > > Therefore if we have a new directory structure for ROCm, that directory structure should contain a HIP version file so that we can detect HIP version.
> > > > > > 
> > > > > > 
> > > > > Currently clang includes some wrapper headers by default, which does not work with ROCm 3.5 since those device functions are defined in HIP headers of ROCm 3.5. To support ROCm 3.5, we have to disable including those wrapper headers. This is one example why we need detect HIP version.
> > > > I think we need to separate HIP runtime detection and device library detection and also separate hasValidHIPRuntime and hasValidDeviceLibrary. ROCm toolchain only need to make sure hasValidDeviceLibrary but HIP toolchain need both hasValidDeviceLibrary and hasValidHIPRuntime.
> > > Regardless of whether there's a version file or if does anything, I think the absence of one implies do the most modern thing
> > "The most modern thing" is an ever moving target. If the failure modes keep changing it will create a source of new problems every time something changes. Probably not a big issue in this case, but with (eventually) wide enough user base there will be some.
> > 
> > I assume that AMD does not have much of legacy user base yet for compilations with clang, so defaulting to a recent version may be sensible (unlike CUDA where clang had to deal with a lot of existing CUDA users using old CUDA versions). That said, I'd recommend pinning it to a **specific** version, so the expectations remain stable. Then we can document the failure/fallback in a way users can deal with -- `if no version file is found, clang assumes version x.y and expects to find files X, Y and Z in directory A, B, C. You can specify the locations manually with --something-something-X=A or specify the version with --hip-version=3.7`. 
> > 
> > Considering that clang is being used from various derived tools, you may not always have the luxury of having the whole ROCm installation around and need to be able to override the expectations via command line flags.
> > 
> > If we have a way to override the version, then it does not matter all that much which version we pick as a fallback. If the guess is wrong, we can always correct it with a flag.
> Unlike CUDA we're not really chasing some 3rd party thing that periodically drops unpredictable changes. We know what the most modern thing is on tip of tree
> Unlike CUDA we're not really chasing some 3rd party thing that periodically drops unpredictable changes. We know what the most modern thing is on tip of tree
We're in agreement on this part. If lack of the version file is non-fatal, I'm fine with whatever version AMD picks as the default.

I'm just pointing out that you'll likely need a way to keep compiler working even if the filesystem does not have everything you expect for the full end-to-end compilation, be it the version file or bitcode. Reasonable default is fine. Overrides can be implemented later, if necessary. 



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82930/new/

https://reviews.llvm.org/D82930




From cfe-commits at lists.llvm.org  Tue Jul  7 11:58:40 2020
From: cfe-commits at lists.llvm.org (Valentin Clement via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:58:40 +0000 (UTC)
Subject: [PATCH] D82659: Fix missing build dependency on omp_gen.
In-Reply-To: 
References: 
Message-ID: <85315bf7f239eb177058e0c1bfe66ee2@localhost.localdomain>

clementval added a comment.

In D82659#2136909 , @michele.scandale wrote:

> Why `omp_gen` is now a dependency of `clang-tablegen-targets` rather than being in the `LLVM_COMMON_DEPENDS` list like `clang-tablegen-targets`?
>
> Moreover I've noticed that with the recent changes where  `omp_gen` has been added as a dependency in several libraries, this was done unconditionally breaking the Clang standalone build.
>  For the same issue `intrinsics_gen` is added only if `CLANG_BUILT_STANDALONE ` is false.
>
> At this point I think that something like:
>
>   # All targets below may depend on all tablegen'd files.
>   get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
>   add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
>   set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Misc")
>   list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)
>   if(NOT CLANG_BUILT_STANDALONE)
>     list(APPEND LLVM_COMMON_DEPENDS omg_gen)
>   endif()
>
>
> would fix all the issues, and it would allow removing the explicit dependencies added to each clang library.
>
> Is there any issue with my reasoning?


Looks good but just one question ... When clang is built as standalone it does not build the OpenMP part inside Clang? I haven't seen any code to avoid compiling the OpenMP parsing and semantic checking inside clang.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82659/new/

https://reviews.llvm.org/D82659




From cfe-commits at lists.llvm.org  Tue Jul  7 11:59:33 2020
From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 18:59:33 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <6153ea3acff7507abf2e1ca0aac242bc@localhost.localdomain>

dblaikie added a comment.

In D82728#2136887 , @logan-5 wrote:

> In D82728#2135149 , @dblaikie wrote:
>
> > Is the implementation you're proposing fairly consistent with GCC's? Run it over any big codebases to check it warns in the same places GCC does?
>
>
> This patch has the same behavior as `-Wsuggest-override` in GCC >= 9. In GCC <9, it would suggest adding `override` to `void foo() final`, but in GCC >=9, `final` is enough to suppress the warning. This patch's `-Wsuggest-override`, as well as Clang's pre-existing `-Winconsistent-missing-override`, are also silenced by `final`. (https://godbolt.org/z/hbxLK6)
>
> I built Clang itself with a Clang that had this patch, and with GCC with `-Wsuggest-override`, and compared the results--they were identical (except for the warning text). (618 warnings, for those interested.)


Awesome! Really appreciate the data.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 12:01:54 2020
From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:01:54 +0000 (UTC)
Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating
 point on targets lacking support.
In-Reply-To: 
References: 
Message-ID: <12c45e54eb1d3265345aefd4a65dc775@localhost.localdomain>

kpn updated this revision to Diff 276166.
kpn added a comment.

Add the -fexperimental-strict-floating-point flag to enable on hosts that are not marked as supporting strict FP yet. Add test and documentation.

Update tests to use the new flag. This eliminates the XFAIL lines and should keep the tests running like before.

Hopefully this will work for 11.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/builtins-ppc-fpconstrained.c
  clang/test/CodeGen/fp-strictfp-exp.cpp
  clang/test/CodeGen/fp-strictfp.cpp
  clang/test/CodeGen/fpconstrained-cmp-double.c
  clang/test/CodeGen/fpconstrained-cmp-float.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80952.276166.patch
Type: text/x-patch
Size: 26308 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 12:02:51 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:02:51 +0000 (UTC)
Subject: [PATCH] D83334: [OPENMP]Fix PR46593: Reduction initializer missing
 construnctor call.
Message-ID: 

ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.

If user-defined reductions with the initializer are used with classes,
wthe compiler misses the constructor call whe trying to create a private
copy of the reduction variable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83334

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83334.276168.patch
Type: text/x-patch
Size: 5118 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 12:07:48 2020
From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:07:48 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: 

dblaikie added a comment.

I'm generally on board with this, but would like @rsmith 's sign off to be sure.

I think it might be nice to make the -Wno-inconsistent-missing-override -Wsuggest-override situation a bit better (by having it still do the same thing as -Wsuggest-override) but I don't feel /too/ strongly about it.



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3064
   if (MD->size_overridden_methods() > 0) {
-    unsigned DiagID = isa(MD)
-                          ? diag::warn_destructor_marked_not_override_overriding
-                          : diag::warn_function_marked_not_override_overriding;
-    Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-    const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-    Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+    auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) {
+      unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;
----------------
Generally I'd recommend default ref capture `[&]` on any lambda that doesn't escape its scope - normal scopes don't need to document which variables you use inside them, and I think the same applies to lambdas (bit more debatable when the lambda is named and called later, even within the same scope - so if you feel strongly about keeping it the way it is, that's OK)


================
Comment at: clang/test/SemaCXX/warn-suggest-override:3-4
+
+class A {
+ public:
+  ~A() {}
----------------
I'd probably simplify these tests by using struct, so everything's implicitly public, rather than class and having to make things public.

Also probably member function declarations rather than definitions would be simpler?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 12:11:53 2020
From: cfe-commits at lists.llvm.org (Yifan Shen via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:11:53 +0000 (UTC)
Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event
In-Reply-To: 
References: 
Message-ID: <3e539c6e06c4098e7fd0da3e92a7614f@localhost.localdomain>

aelitashen updated this revision to Diff 276172.
aelitashen added a comment.

Add test for loading symbols, other module info and Add version to module info


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82477.276172.patch
Type: text/x-patch
Size: 9248 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 12:12:35 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:12:35 +0000 (UTC)
Subject: [PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete
 __gcov_flush
In-Reply-To: 
References: 
Message-ID: <124dd2b787fd224376b807d33ea808b4@localhost.localdomain>

MaskRay updated this revision to Diff 276173.
MaskRay marked 6 inline comments as done.
MaskRay added a comment.

Test __gcov_dump


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83149/new/

https://reviews.llvm.org/D83149

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/CodeGen/code-coverage.c
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/GCDAProfiling.c
  compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
  compiler-rt/test/profile/Posix/gcov-dlopen.c
  compiler-rt/test/profile/Posix/gcov-shared-flush.c
  compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
  compiler-rt/test/profile/gcov-dump-and-remove.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83149.276173.patch
Type: text/x-patch
Size: 15649 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 12:14:30 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:14:30 +0000 (UTC)
Subject: [PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete
 __gcov_flush
In-Reply-To: 
References: 
Message-ID: 

MaskRay added a comment.

`compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov` is clumsy to update. The filename is also wrong: gcov has nothing to do with instrprof.

I'll update the tests separately like my fba8523fb55c8e3bc853df7a250845cf51e5fc99 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83149/new/

https://reviews.llvm.org/D83149




From cfe-commits at lists.llvm.org  Tue Jul  7 12:19:26 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:19:26 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <03278fe517e2a4210e5a619a5507111e@localhost.localdomain>

MaskRay added inline comments.


================
Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT:         Branch Probability Analysis
+; CHECK-NEXT:         Block Frequency Analysis
 ; CHECK-NEXT:     FunctionPass Manager
----------------
zequanwu wrote:
> zequanwu wrote:
> > nikic wrote:
> > > hans wrote:
> > > > nikic wrote:
> > > > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use?
> > > > > 
> > > > > PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided.
> > > > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > > > 
> > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > > > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > > 
> > > It would only help if there is some way to only fetch the analysis conditionally. I believe many PGO passes use something like PSI.hasProfileSummary() or F.hasProfileData() for that.
> > > 
> > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > > 
> > > Right, just disabling this by default in clang/opt would also work.
> > > 
> > > For reference, the current compile-time numbers for this patch: https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff&to=8df840660bb764b6653fcfd9ac7a72cc6adebde6&stat=instructions Not huge, but it adds up (some similar regressions have been introduced in LLVM 10).
> > Do you mean disabling it just for LPM or both?
> > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> For Clang, a better fix I think is that `Opts.CallGraphProfile` should based on both whether the integrated assembler is used and whether profile instrumentation is turned on. What do you think?
I'd prefer not having `CallGraphProfile`

* `-no-integrated-as -S` => no .cgprofile (.llvm_addrsig behaves this way)
* `-S` -> .cgprofile


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Tue Jul  7 12:26:26 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:26:26 +0000 (UTC)
Subject: [PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for
 update_{llc,cc}_test_checks.py
In-Reply-To: 
References: 
Message-ID: <36e75243a0d79cd53a837dc3b21f062c@localhost.localdomain>

MaskRay accepted this revision.
MaskRay added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478




From cfe-commits at lists.llvm.org  Tue Jul  7 12:27:12 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:27:12 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: 

logan-5 marked 2 inline comments as done.
logan-5 added a comment.

In D82728#2137021 , @dblaikie wrote:

> I think it might be nice to make the -Wno-inconsistent-missing-override -Wsuggest-override situation a bit better (by having it still do the same thing as -Wsuggest-override) but I don't feel /too/ strongly about it.


So, ironing this out would mean the code would need this structure:

  if (Inconsistent && IsWarningEnabled(-Winconsistent-missing-override))
      Emit(-Winconsistent-missing-override);
  else
      Emit(-Wsuggest-override);

The issue is that I wasn't able to find a way to ask if a warning is enabled and make a control flow decision based on that. If there is an API for doing this, it's hidden well. :) So I fell back to just doing `if (Inconsistent)` instead, which has this quirk if the inconsistent version of the warning is disabled.



================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3064
   if (MD->size_overridden_methods() > 0) {
-    unsigned DiagID = isa(MD)
-                          ? diag::warn_destructor_marked_not_override_overriding
-                          : diag::warn_function_marked_not_override_overriding;
-    Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-    const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-    Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+    auto EmitDiag = [this, MD](unsigned DiagDtor, unsigned DiagFn) {
+      unsigned DiagID = isa(MD) ? DiagDtor : DiagFn;
----------------
dblaikie wrote:
> Generally I'd recommend default ref capture `[&]` on any lambda that doesn't escape its scope - normal scopes don't need to document which variables you use inside them, and I think the same applies to lambdas (bit more debatable when the lambda is named and called later, even within the same scope - so if you feel strongly about keeping it the way it is, that's OK)
I don't feel strongly at all; I'm fine with `[&]`. I'll make that change.


================
Comment at: clang/test/SemaCXX/warn-suggest-override:3-4
+
+class A {
+ public:
+  ~A() {}
----------------
dblaikie wrote:
> I'd probably simplify these tests by using struct, so everything's implicitly public, rather than class and having to make things public.
> 
> Also probably member function declarations rather than definitions would be simpler?
Can do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 12:31:08 2020
From: cfe-commits at lists.llvm.org (Greg Clayton via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:31:08 +0000 (UTC)
Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event
In-Reply-To: 
References: 
Message-ID: <729ba1cb4d367dac286464e13a5e95eb@localhost.localdomain>

clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

So looks like you didn't use "git commit --amend -a" again here. These changes are incremental changes on your patch which hasn't been submitted yet?



================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:21
+        program_basename = "a.out.stripped"
+        program= self.getBuildArtifact(program_basename)
         self.build_and_launch(program)
----------------
add a space after "program"


================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:33-34
+        program_module = active_modules[program_basename]
+        self.assertIn('name', program_module, 'make sure name is in module')
+        self.assertEqual(program_basename, program_module['name'])
+        self.assertTrue('symbolFilePath' not in program_module, 'Make sure a.out.stripped has no debug info')
----------------
Do a similar check for ='path'
```
self.assertIn('name', program_module, 'make sure "name" is in module')
self.assertEqual(program_basename, program_module['name'])
self.assertIn('path', program_module, 'make sure "path" is in module')
self.assertEqual(program, program_module['path'])
```
In general, make sure you test every key that you have added support for.


================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:35
+        self.assertEqual(program_basename, program_module['name'])
+        self.assertTrue('symbolFilePath' not in program_module, 'Make sure a.out.stripped has no debug info')
+        symbol_path = self.getBuildArtifact("a.out")
----------------
Check for the symbol status here:
```
self.assertEqual('Symbols not found.', program_module['symbolStatus'])
```


================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:40
+        program_module = active_modules[program_basename]
+        self.assertEqual(program_basename, program_module['name'])
+        self.assertEqual('Symbols loaded.', program_module['symbolStatus'])
----------------
verify 'path' again


================
Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:346
+    object.try_emplace("symbolFilePath", symbol_path);
   }
   std::string loaded_addr = std::to_string(
----------------
Add an else clause here:

```
} else {
  object.try_emplace("symbolStatus", "Symbols not found.");
}
```


================
Comment at: lldb/tools/lldb-vscode/JSONUtils.cpp:352-357
+  uint32_t num_versions = module.GetVersion(version_nums, sizeof(version_nums)/sizeof(uint32_t));
+  for (uint32_t i=0; i

Conanap created this revision.
Conanap added reviewers: PowerPC, power-llvm-team, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.

Implemented the following vector right and left shift builtins and its test cases:

  vector unsigned __int128 vec_sl(vector unsigned __int128 a, vector unsigned __int128 b)
  vector signed __int128 vec_sl(vector signed __int128 a, vector unsigned __int128 b)
  vector unsigned __int128 vec_sr(vector unsigned __int128 a, vector unsigned __int128 b)
  vector signed __int128 vec_sr(vector signed __int128 a, vector unsigned __int128 b)
  vector unsigned __int128 vec_sra(vector unsigned __int128 a, vector unsigned __int128 b)
  vector signed __int128 vec_sra(vector signed __int128 a, vector unsigned __int128 b)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83338

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83338.276179.patch
Type: text/x-patch
Size: 5729 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 12:41:04 2020
From: cfe-commits at lists.llvm.org (Richard Smith - zygoloid via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:41:04 +0000 (UTC)
Subject: [PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr
 attribute
In-Reply-To: 
References: 
Message-ID: <0951b56eb371830d04a6a1feca04c935@localhost.localdomain>

rsmith added a comment.

@aaron.ballman We will need to do something like this in general, but I'm not sure it's going to be as easy as just inheriting the attribute in the general case. What do you think?



================
Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3540
+    Attr *IA = Previous->getAttr();
+    D->addAttr(IA);
+  } else if (!Previous->hasAttr() &&
----------------
I think it would be more consistent to clone the attribute here (and mark it as inherited) rather than attaching the same attribute to multiple declarations.


================
Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3544
+    Attr *IA = D->getAttr();
+    Previous->addAttr(IA);
+  }
----------------
I think we should only propagate attributes forwards along redeclaration chains. Is this single-step-backwards propagation necessary?


================
Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3709
+  // it needs to be added to all the declarations in the redeclarable chain.
+  mergeInheritableAttributes(D, Previous);
 }
----------------
Please add a FIXME to do this is general.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83174/new/

https://reviews.llvm.org/D83174




From cfe-commits at lists.llvm.org  Tue Jul  7 12:46:06 2020
From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:46:06 +0000 (UTC)
Subject: [PATCH] D83301: [clang-tidy] More strict on matching the standard
 memset function in memset-usage check.
In-Reply-To: 
References: 
Message-ID: <61a3bf07b9e7a4e0281ae177fd49622b@localhost.localdomain>

njames93 added a comment.

If you want to be super explicit. Why not add `parameterCountIs(3)`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83301/new/

https://reviews.llvm.org/D83301




From cfe-commits at lists.llvm.org  Tue Jul  7 12:54:34 2020
From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 19:54:34 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: 

cchen marked an inline comment as done.
cchen added inline comments.


================
Comment at: clang/lib/Parse/ParseExpr.cpp:1933
         }
+        if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+          // Consume ':'
----------------
ABataev wrote:
> You need to insert an additional check for `OMPClauseKind == llvm::omp::Clause::OMPC_to || OMPClauseKind == llvm::omp::Clause::OMPC_from` here. I.e. we shall expect stride not only if the version is 5.0, but also if the current clauses is `to` or `from`
Got it, I was thinking that we might want to emit diagnostic message for OpenMP version < 50. Thanks for your explaination.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Tue Jul  7 13:02:17 2020
From: cfe-commits at lists.llvm.org (Yitzhak Mandelbaum via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:02:17 +0000 (UTC)
Subject: [PATCH] D82278: Fix traversal over CXXConstructExpr in Syntactic mode
In-Reply-To: 
References: 
Message-ID: <3efd986a602d4b2cd1747059d93128af@localhost.localdomain>

ymandel added a comment.

Thanks for this fix!



================
Comment at: clang/lib/AST/Expr.cpp:3001
         Expr *A = C->getArg(0);
-        if (A->getSourceRange() == SR || !isa(C))
+        if (A->getSourceRange() == SR || C->isElidable()) {
           E = A;
----------------
aaron.ballman wrote:
> Looks like the change introduced new curly braces for a single-line if.
Why is it necessary to check isElidable?  I think the logic here is subtle (since the AST doesn't explicitly tag implicit expressions), so please add an explanatory comment.


================
Comment at: clang/lib/AST/ParentMapContext.cpp:163
       if (const auto *C = dyn_cast(E)) {
-        if (C->getSourceRange() == SR || !isa(C))
+        if (C->getSourceRange() == SR || C->isElidable())
           return true;
----------------
Same here. Please comment on the logic.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82278/new/

https://reviews.llvm.org/D82278




From cfe-commits at lists.llvm.org  Tue Jul  7 13:07:38 2020
From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:07:38 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <8e93769302a4f38cdd818db8476133ca@localhost.localdomain>

cchen marked an inline comment as done.
cchen added inline comments.


================
Comment at: clang/lib/Parse/ParseExpr.cpp:1933
         }
+        if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+          // Consume ':'
----------------
cchen wrote:
> ABataev wrote:
> > You need to insert an additional check for `OMPClauseKind == llvm::omp::Clause::OMPC_to || OMPClauseKind == llvm::omp::Clause::OMPC_from` here. I.e. we shall expect stride not only if the version is 5.0, but also if the current clauses is `to` or `from`
> Got it, I was thinking that we might want to emit diagnostic message for OpenMP version < 50. Thanks for your explaination.
Just want to make sure the error message for OpenMP5.0, for this case: `#pragma omp target data map(to: marr[10][0:2:2])`.

OpenMP45:
We don't expect stride at all, so we only emit the error message expecting ']' just as before.

OpenMP50:
Should I emit the new error message to inform user that stride can not use in clause other than to or from?

Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Tue Jul  7 13:09:03 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:09:03 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <2373b07f5f25a216cf1504fe34227bd2@localhost.localdomain>

ABataev added inline comments.


================
Comment at: clang/lib/Parse/ParseExpr.cpp:1933
         }
+        if (getLangOpts().OpenMP >= 50 && Tok.is(tok::colon)) {
+          // Consume ':'
----------------
cchen wrote:
> cchen wrote:
> > ABataev wrote:
> > > You need to insert an additional check for `OMPClauseKind == llvm::omp::Clause::OMPC_to || OMPClauseKind == llvm::omp::Clause::OMPC_from` here. I.e. we shall expect stride not only if the version is 5.0, but also if the current clauses is `to` or `from`
> > Got it, I was thinking that we might want to emit diagnostic message for OpenMP version < 50. Thanks for your explaination.
> Just want to make sure the error message for OpenMP5.0, for this case: `#pragma omp target data map(to: marr[10][0:2:2])`.
> 
> OpenMP45:
> We don't expect stride at all, so we only emit the error message expecting ']' just as before.
> 
> OpenMP50:
> Should I emit the new error message to inform user that stride can not use in clause other than to or from?
> 
> Thanks.
I think, the same behavior just like for OpenMP 4.5 should be fine here since stride is not allowed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Tue Jul  7 13:19:16 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:19:16 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <2947602739edff6d426ab48fc1dcc9c2@localhost.localdomain>

hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1064
     setSize(getSize() + PtrWidth);
     setDataSize(getSize());
   }
----------------
I would suggest setting `HandledFirstNonOverlappingEmptyField` to `true` here with an assertion that the current type is not a union.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+      DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+      !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;
----------------
The condition is still more complex than I think it should be.

If we have found a "first" other-than-overlapping-empty-field, then we should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases.

If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for `FieldOffset == CharUnits::Zero()` to be true, then I think the correction would be to set `HandledFirstNonOverlappingEmptyField` in more places.

I would like to remove the check on `FieldOffset == CharUnits::Zero()` from here and instead have an assertion that `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == CharUnits::Zero()`.

Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to `FoundFirstNonOverlappingEmptyField`.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1832
     EffectiveFieldSize = FieldSize = CharUnits::Zero();
     const ArrayType* ATy = Context.getAsArrayType(D->getType());
+    TypeInfo TI = Context.getTypeInfo(D->getType());
----------------
`ATy` seems to be an unused variable now.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1834
+    TypeInfo TI = Context.getTypeInfo(D->getType());
+    FieldAlign = Context.toCharUnitsFromBits(TI.Align);
+    AlignIsRequired = TI.AlignIsRequired;
----------------
I guess this works (we have a test for it), but the previous code made a point to use the element type and not the array type (and the comment above says we can't directly query `getTypeInfo` with the array type). @Xiangling_L, can you confirm if the comment is out-of-date and update it?


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1909
+  if (DefaultsToAIXPowerAlignment && !AlignIsRequired &&
+      (IsUnion || FoundFirstNonOverlappingEmptyFieldToHandle)) {
+    auto upgradeAlignment = [&](const BuiltinType *BTy) {
----------------
It should now be the case that `FoundFirstNonOverlappingEmptyFieldToHandle` is `true` for all union members that are not empty, meaning that the `IsUnion` part of the check only serves to admit attempts to handle types that are empty (and thus does not have subobjects that would induce an alignment upgrade).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Tue Jul  7 13:19:56 2020
From: cfe-commits at lists.llvm.org (Zola Bridges via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:19:56 +0000 (UTC)
Subject: [PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses
In-Reply-To: 
References: 
Message-ID: <3d36bf37259a01a0219a32f3f5f921f6@localhost.localdomain>

zbrid updated this revision to Diff 276196.
zbrid added a comment.

rebase prior to commit


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79910/new/

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79910.276196.patch
Type: text/x-patch
Size: 10042 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 13:21:38 2020
From: cfe-commits at lists.llvm.org (Zola Bridges via cfe-commits)
Date: Tue, 07 Jul 2020 13:21:38 -0700 (PDT)
Subject: [clang] 9d9e499 - [x86][seses] Add clang flag; Use lvi-cfi with seses
Message-ID: <5f04d952.1c69fb81.90e26.de02@mx.google.com>


Author: Zola Bridges
Date: 2020-07-07T13:20:13-07:00
New Revision: 9d9e499840af670b9644af77ce846c52085c23a1

URL: https://github.com/llvm/llvm-project/commit/9d9e499840af670b9644af77ce846c52085c23a1
DIFF: https://github.com/llvm/llvm-project/commit/9d9e499840af670b9644af77ce846c52085c23a1.diff

LOG: [x86][seses] Add clang flag; Use lvi-cfi with seses

This patch creates a clang flag to enable SESES. This flag also ensures that
lvi-cfi is on when using seses via clang.

SESES should use lvi-cfi to mitigate returns and indirect branches.

The flag to enable the SESES functionality only without lvi-cfi is now
-x86-seses-enable-without-lvi-cfi to warn users part of the mitigation is not
enabled if they use this flag. This is useful in case folks want to see the
cost of SESES separate from the LVI-CFI.

Reviewed By: sconstab

Differential Revision: https://reviews.llvm.org/D79910

Added: 
    

Modified: 
    clang/docs/ClangCommandLineReference.rst
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/ToolChains/Arch/X86.cpp
    clang/test/Driver/x86-target-features.c
    llvm/lib/Target/X86/X86.td
    llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
    llvm/lib/Target/X86/X86Subtarget.h
    llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

Removed: 
    


################################################################################
diff  --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst
index 672c4ae80e73..0b56b7ac4206 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2755,6 +2755,10 @@ Generate a \_\_mcount\_loc section entry for each \_\_fentry\_\_ call.
 
 Make StdCall calling convention the default
 
+.. option:: -mseses, -mno-seses
+
+Enable speculative execution side effect suppression (SESES). Includes LVI control flow integrity mitigations
+
 .. option:: -msign-return-address=
 
 Select return address signing scope

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 745c696bcaa3..c95d427da267 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2264,6 +2264,11 @@ def mlvi_cfi : Flag<["-"], "mlvi-cfi">, Group, Flags<[CoreOption,Driver
   HelpText<"Enable only control-flow mitigations for Load Value Injection (LVI)">;
 def mno_lvi_cfi : Flag<["-"], "mno-lvi-cfi">, Group, Flags<[CoreOption,DriverOption]>,
   HelpText<"Disable control-flow mitigations for Load Value Injection (LVI)">;
+def m_seses : Flag<["-"], "mseses">, Group, Flags<[CoreOption, DriverOption]>,
+  HelpText<"Enable speculative execution side effect suppression (SESES). "
+    "Includes LVI control flow integrity mitigations">;
+def mno_seses : Flag<["-"], "mno-seses">, Group, Flags<[CoreOption, DriverOption]>,
+  HelpText<"Disable speculative execution side effect suppression (SESES)">;
 
 def mrelax : Flag<["-"], "mrelax">, Group,
   HelpText<"Enable linker relaxation">;

diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index dbbc025de38c..aa95c4189d1e 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -184,6 +184,24 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
     LVIOpt = options::OPT_mlvi_cfi;
   }
 
+  if (Args.hasFlag(options::OPT_m_seses, options::OPT_mno_seses, false)) {
+    if (LVIOpt == options::OPT_mlvi_hardening)
+      D.Diag(diag::err_drv_argument_not_allowed_with)
+          << D.getOpts().getOptionName(options::OPT_mlvi_hardening)
+          << D.getOpts().getOptionName(options::OPT_m_seses);
+
+    if (SpectreOpt != clang::driver::options::ID::OPT_INVALID)
+      D.Diag(diag::err_drv_argument_not_allowed_with)
+          << D.getOpts().getOptionName(SpectreOpt)
+          << D.getOpts().getOptionName(options::OPT_m_seses);
+
+    Features.push_back("+seses");
+    if (!Args.hasArg(options::OPT_mno_lvi_cfi)) {
+      Features.push_back("+lvi-cfi");
+      LVIOpt = options::OPT_mlvi_cfi;
+    }
+  }
+
   if (SpectreOpt != clang::driver::options::ID::OPT_INVALID &&
       LVIOpt != clang::driver::options::ID::OPT_INVALID) {
     D.Diag(diag::err_drv_argument_not_allowed_with)

diff  --git a/clang/test/Driver/x86-target-features.c b/clang/test/Driver/x86-target-features.c
index 817caeecd71e..85a9374ab905 100644
--- a/clang/test/Driver/x86-target-features.c
+++ b/clang/test/Driver/x86-target-features.c
@@ -178,6 +178,27 @@
 // RUN: %clang -target i386-linux-gnu -mlvi-hardening -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=LVIHARDENING-RETPOLINE-EXTERNAL-THUNK %s
 // LVIHARDENING-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 'mretpoline-external-thunk' not allowed with 'mlvi-hardening'
 
+// RUN: %clang -target i386-linux-gnu -mseses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES %s
+// RUN: %clang -target i386-linux-gnu -mno-seses %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SESES %s
+// SESES: "-target-feature" "+seses"
+// SESES: "-target-feature" "+lvi-cfi"
+// NO-SESES-NOT: seses
+// NO-SESES-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mno-lvi-cfi %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-NOLVICFI %s
+// SESES-NOLVICFI: "-target-feature" "+seses"
+// SESES-NOLVICFI-NOT: lvi-cfi
+
+// RUN: %clang -target i386-linux-gnu -mseses -mspeculative-load-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-SLH %s
+// SESES-SLH: error: invalid argument 'mspeculative-load-hardening' not allowed with 'mseses'
+// RUN: %clang -target i386-linux-gnu -mseses -mretpoline %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-RETPOLINE %s
+// SESES-RETPOLINE: error: invalid argument 'mretpoline' not allowed with 'mseses'
+// RUN: %clang -target i386-linux-gnu -mseses -mretpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-RETPOLINE-EXTERNAL-THUNK %s
+// SESES-RETPOLINE-EXTERNAL-THUNK: error: invalid argument 'mretpoline-external-thunk' not allowed with 'mseses'
+
+// RUN: %clang -target i386-linux-gnu -mseses -mlvi-hardening %s -### -o %t.o 2>&1 | FileCheck -check-prefix=SESES-LVIHARDENING %s
+// SESES-LVIHARDENING: error: invalid argument 'mlvi-hardening' not allowed with 'mseses'
+
 // RUN: %clang -target i386-linux-gnu -mwaitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WAITPKG %s
 // RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s
 // WAITPKG: "-target-feature" "+waitpkg"

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index eb50e6bf9ff1..dc1ff72add49 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -455,6 +455,15 @@ def FeatureLVIControlFlowIntegrity
           "LFENCE instruction to serialize control flow. Also decompose RET "
           "instructions into a POP+LFENCE+JMP sequence.">;
 
+// Enable SESES to mitigate speculative execution attacks
+def FeatureSpeculativeExecutionSideEffectSuppression
+    : SubtargetFeature<
+          "seses", "UseSpeculativeExecutionSideEffectSuppression", "true",
+          "Prevent speculative execution side channel timing attacks by "
+          "inserting a speculation barrier before memory reads, memory writes, "
+          "and conditional branches. Implies LVI Control Flow integrity.",
+          [FeatureLVIControlFlowIntegrity]>;
+
 // Mitigate LVI attacks against data loads
 def FeatureLVILoadHardening
     : SubtargetFeature<

diff  --git a/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp b/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
index 75138f2de696..7e91c37367d2 100644
--- a/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
+++ b/llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
@@ -30,7 +30,7 @@ using namespace llvm;
 STATISTIC(NumLFENCEsInserted, "Number of lfence instructions inserted");
 
 static cl::opt EnableSpeculativeExecutionSideEffectSuppression(
-    "x86-seses-enable",
+    "x86-seses-enable-without-lvi-cfi",
     cl::desc("Force enable speculative execution side effect suppression. "
              "(Note: User must pass -mlvi-cfi in order to mitigate indirect "
              "branches and returns.)"),
@@ -91,10 +91,12 @@ bool X86SpeculativeExecutionSideEffectSuppression::runOnMachineFunction(
   const auto &OptLevel = MF.getTarget().getOptLevel();
   const X86Subtarget &Subtarget = MF.getSubtarget();
 
-  // Check whether SESES needs to run as the fallback for LVI at O0 or if the
-  // user explicitly passed the SESES flag.
+  // Check whether SESES needs to run as the fallback for LVI at O0, whether the
+  // user explicitly passed an SESES flag, or whether the SESES target feature
+  // was set.
   if (!EnableSpeculativeExecutionSideEffectSuppression &&
-      !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None))
+      !(Subtarget.useLVILoadHardening() && OptLevel == CodeGenOpt::None) &&
+      !Subtarget.useSpeculativeExecutionSideEffectSuppression())
     return false;
 
   LLVM_DEBUG(dbgs() << "********** " << getPassName() << " : " << MF.getName()

diff  --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h
index 6a2879e4a5d7..de45d357e3c2 100644
--- a/llvm/lib/Target/X86/X86Subtarget.h
+++ b/llvm/lib/Target/X86/X86Subtarget.h
@@ -442,6 +442,9 @@ class X86Subtarget final : public X86GenSubtargetInfo {
   /// POP+LFENCE+JMP sequence.
   bool UseLVIControlFlowIntegrity = false;
 
+  /// Enable Speculative Execution Side Effect Suppression
+  bool UseSpeculativeExecutionSideEffectSuppression = false;
+
   /// Insert LFENCE instructions to prevent data speculatively injected into
   /// loads from being used maliciously.
   bool UseLVILoadHardening = false;
@@ -759,6 +762,9 @@ class X86Subtarget final : public X86GenSubtargetInfo {
   bool useGLMDivSqrtCosts() const { return UseGLMDivSqrtCosts; }
   bool useLVIControlFlowIntegrity() const { return UseLVIControlFlowIntegrity; }
   bool useLVILoadHardening() const { return UseLVILoadHardening; }
+  bool useSpeculativeExecutionSideEffectSuppression() const {
+    return UseSpeculativeExecutionSideEffectSuppression;
+  }
 
   unsigned getPreferVectorWidth() const { return PreferVectorWidth; }
   unsigned getRequiredVectorWidth() const { return RequiredVectorWidth; }

diff  --git a/llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll b/llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
index acbdc9e9387e..fdd56382448a 100644
--- a/llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
+++ b/llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll
@@ -1,8 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable %s -o - | FileCheck %s
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi %s -o - | FileCheck %s
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-one-lfence-per-bb %s -o - | FileCheck %s --check-prefix=X86-ONE-LFENCE
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-omit-branch-lfences %s -o - | FileCheck %s --check-prefix=X86-OMIT-BR
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -x86-seses-enable-without-lvi-cfi -x86-seses-only-lfence-non-const %s -o - | FileCheck %s --check-prefix=X86-NON-CONST
 
 define void @_Z4buzzv() {
 ; CHECK-LABEL: _Z4buzzv:


        

From cfe-commits at lists.llvm.org  Tue Jul  7 13:21:42 2020
From: cfe-commits at lists.llvm.org (Zola Bridges via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:21:42 +0000 (UTC)
Subject: [PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses
In-Reply-To: 
References: 
Message-ID: <55efb5eb8e3afd20ee03935dc7a3f536@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d9e499840af: [x86][seses] Add clang flag; Use lvi-cfi with seses (authored by zbrid).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79910/new/

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79910.276197.patch
Type: text/x-patch
Size: 10042 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 13:28:19 2020
From: cfe-commits at lists.llvm.org (Zola Bridges via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:28:19 +0000 (UTC)
Subject: [PATCH] D79910: [x86][seses] Add clang flag; Use lvi-cfi with seses
In-Reply-To: 
References: 
Message-ID: <1fd4847c1a78012fb11b04a4f237ccd2@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG9d9e499840af: [x86][seses] Add clang flag; Use lvi-cfi with seses (authored by zbrid).
Herald added a subscriber: jfb.

Changed prior to commit:
  https://reviews.llvm.org/D79910?vs=272117&id=275687#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79910/new/

https://reviews.llvm.org/D79910

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/test/Driver/x86-target-features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86SpeculativeExecutionSideEffectSuppression.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/speculative-execution-side-effect-suppression.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79910.275687.patch
Type: text/x-patch
Size: 10042 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 13:33:42 2020
From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:33:42 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <12b503b0bff707e1b02cdf54c5697e75@localhost.localdomain>

zequanwu added inline comments.


================
Comment at: llvm/test/Other/opt-O2-pipeline.ll:289
+; CHECK-NEXT:         Branch Probability Analysis
+; CHECK-NEXT:         Block Frequency Analysis
 ; CHECK-NEXT:     FunctionPass Manager
----------------
MaskRay wrote:
> zequanwu wrote:
> > zequanwu wrote:
> > > nikic wrote:
> > > > hans wrote:
> > > > > nikic wrote:
> > > > > > Is it possible to switch this pass to use LazyBPI / LazyBFA, only fetched if PGO is actually in use?
> > > > > > 
> > > > > > PGO functionality that most people don't use adding expensive analysis passes like PDT should be avoided.
> > > > > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > > > > 
> > > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > > > > I wonder if just switching to LazyBlockFrequencyInfo would help though. It looks to me like the CGProfile would request info about each function anyway.
> > > > 
> > > > It would only help if there is some way to only fetch the analysis conditionally. I believe many PGO passes use something like PSI.hasProfileSummary() or F.hasProfileData() for that.
> > > > 
> > > > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > > > 
> > > > Right, just disabling this by default in clang/opt would also work.
> > > > 
> > > > For reference, the current compile-time numbers for this patch: https://llvm-compile-time-tracker.com/compare.php?from=516ff1d4baee28b1911737e47b42973567adf8ff&to=8df840660bb764b6653fcfd9ac7a72cc6adebde6&stat=instructions Not huge, but it adds up (some similar regressions have been introduced in LLVM 10).
> > > Do you mean disabling it just for LPM or both?
> > > I was surprised to see that Clang sets Opts.CallGraphProfile solely based on whether the integrated assembler is used. Maybe a better fix is to only set that to true when a profile is actually being used?
> > For Clang, a better fix I think is that `Opts.CallGraphProfile` should based on both whether the integrated assembler is used and whether profile instrumentation is turned on. What do you think?
> I'd prefer not having `CallGraphProfile`
> 
> * `-no-integrated-as -S` => no .cgprofile (.llvm_addrsig behaves this way)
> * `-S` -> .cgprofile
As discussed above, I think `CGProfilePass` should be disabled by default in clang unless `-no-integrated-as` is not given and `-fprofile-instrument-use-path=` is given. So, `Opts.CallGraphProfile` is a convenient switch for that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Tue Jul  7 13:46:44 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:46:44 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

efriedma added a comment.

I'm tempted to say this is a bugfix for the implementation of no_unique_address, and just fix it globally for all ABIs.  We're never going to get anything done here if we require a separate patch for each ABI variant clang supports.



================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:524
+  if (isa(RT->getDecl()) &&
+      !(AllowNoUniqueAddr && FD->hasAttr()))
     return false;
----------------
Does this do the right thing with a field that's an array of empty classes?


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:7245
       // do count.  So do anonymous bitfields that aren't zero-sized.
-      if (getContext().getLangOpts().CPlusPlus &&
-          FD->isZeroLengthBitField(getContext()))
-        continue;
+      if (getContext().getLangOpts().CPlusPlus) {
+        if (FD->isZeroLengthBitField(getContext()))
----------------
Only loosely relevant to this patch, but checking getLangOpts().CPlusPlus here seems weird; doesn't that break calling functions defined in C from C++ code?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Tue Jul  7 13:55:24 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 20:55:24 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <3131e859d3b6b863bfe8cb384cd70e82@localhost.localdomain>

logan-5 updated this revision to Diff 276187.
logan-5 added a comment.

Addressed minor feedback.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82728.276187.patch
Type: text/x-patch
Size: 7513 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 14:00:01 2020
From: cfe-commits at lists.llvm.org (Francesco Petrogalli via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 21:00:01 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: <817f724bec6ecbcd0dc2fcefc71b1b89@localhost.localdomain>

fpetrogalli updated this revision to Diff 276204.
fpetrogalli added a comment.

Addressed code review, moving the code and adding more testing, including the `v8.5` one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===================================================================
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -112,6 +112,60 @@
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE 1
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE_MATMUL_FP64 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.5-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_5 %s
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_5: __ARM_FEATURE_SVE 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MM %s
+// CHECK-SVE-8_6-NOI8MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MM:     __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MM:     __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nobf16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOBF16 %s
+// CHECK-SVE-8_6-NOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16:     __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16:     __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOF32MM %s
+// CHECK-SVE-8_6-NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOF32MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOF32MM:     __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOF32MM:     __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nobf16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16 %s
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOBF16:     __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MMNOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM:     __ARM_FEATURE_SVE_BF16 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16NOF32MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16NOF32MM:     __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM:     __ARM_FEATURE_SVE 1
+
 // The following tests may need to be revised in the future since
 // SVE2 is currently still part of Future Architecture Technologies
 // (https://developer.arm.com/docs/ddi0602/latest)
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -365,6 +365,15 @@
     }
   }
 
+  if (llvm::is_contained(Features, "+v8.6a")) {
+    if (!llvm::is_contained(Features, "-i8mm") &&
+        !llvm::is_contained(Features, "+noi8mm"))
+      Features.push_back("+i8mm");
+    if (!llvm::is_contained(Features, "-bf16") &&
+        !llvm::is_contained(Features, "+nobf16"))
+      Features.push_back("+bf16");
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
                                options::OPT_munaligned_access))
     if (A->getOption().matches(options::OPT_mno_unaligned_access))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83079.276204.patch
Type: text/x-patch
Size: 4821 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 14:18:49 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 21:18:49 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: <100238c1dc5f8ed1016bda1c00066ba4@localhost.localdomain>

hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:521
+  // [[no_unique_address]] attribute (since C++20).  Those do count
+  // as empty according to the Itanium ABI.  This property is currently
+  // only respected if the AllowNoUniqueAddr parameter is true.
----------------
This check is being done after removal of the array types by `AllowArrays`, so this code is also conferring the property of being empty to arrays. It seems GCC erroneously does the same for base class fields (but not for direct members).

```
struct Empty {};

struct A {
  Empty emp [[no_unique_address]][3];
};

struct B : A {
  float f;
};

struct C {
  Empty emp [[no_unique_address]][3];
  float f;
};

extern char szb[sizeof(B)];
extern char szb[sizeof(float)]; // GCC likes this
extern char szc[sizeof(C)];
extern char szc[sizeof(float)]; // GCC does not like this
```

Compiler Explorer link: https://godbolt.org/z/NFuca9


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:7231
         // Empty bases don't affect things either way.
-        if (isEmptyRecord(getContext(), Base, true))
+        if (isEmptyRecord(getContext(), Base, true, true))
           continue;
----------------
The Itanium ABI defines "empty data member" as:
> A potentially-overlapping non-static data member of empty class type.

That definition does not include non-static data members of array type whose base element type is an empty class type.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:7249
+        if (FD->hasAttr() &&
+            isEmptyRecord(getContext(), FD->getType(), true, true))
+          continue;
----------------
Should this be controlled by an `-fclang-abi-compat` option?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Tue Jul  7 14:25:22 2020
From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 21:25:22 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <5399fc3dabfd74b0db3bc53d5b466f23@localhost.localdomain>

zequanwu updated this revision to Diff 276208.
zequanwu marked an inline comment as done.
zequanwu added a comment.
Herald added subscribers: dexonsmith, steven_wu.

- Disable `enable-call-graph-profile` by default in opt.
- Disable `CGProfilePass` by default in clang unless `-no-integrated-as` is not given and `-fprofile-instrument-use-path=` is given, as this pass only generates module metadata when profile data is given.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/NewPMDriver.h
  llvm/tools/opt/opt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83013.276208.patch
Type: text/x-patch
Size: 17883 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 14:35:09 2020
From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 21:35:09 +0000 (UTC)
Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default
In-Reply-To: 
References: 
Message-ID: <4245b603e2f99e36d9b6757b159dc5c2@localhost.localdomain>

yaxunl updated this revision to Diff 276211.
yaxunl added a comment.

refactor CUDACheckLambdaCapture and add comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78655.276211.patch
Type: text/x-patch
Size: 14012 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 14:53:25 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 21:53:25 +0000 (UTC)
Subject: [PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from
 the device runtime
Message-ID: 

jdoerfert created this revision.
jdoerfert added reviewers: hfinkel, jhuber6, fghanim, JonChesterfield, grokos, AndreyChurbanov, ye-luo, tianshilei1992, ggeorgakoudis, Hahnfeld, ABataev, hbae, ronlieb, gregrodgers.
Herald added subscribers: cfe-commits, aaron.ballman, sstefan1, jfb, guansong, bollu, yaxunl, jvesely.
Herald added projects: clang, OpenMP.

We carried a lot of unused and untested code in the device runtime.
Among other reasons, we are planning major rewrites for which reduced
size is going to help a lot.

The number of code lines reduced by 14%!

Before:
-------

Language                     files          blank        comment           code
-------------------------------------------------------------------------------

CUDA                            13            489            841           2454
C/C++ Header                    14            322            493           1377
C                               12            117            124            559
CMake                            4             64             64            262

C++                              1              6              6             39
-------------------------------------------------------------------------------

SUM:                            44            998           1528           4691
-------------------------------------------------------------------------------

After:
------

Language                     files          blank        comment           code
-------------------------------------------------------------------------------

CUDA                            13            366            733           1879
C/C++ Header                    14            317            484           1293
C                               12            117            124            559
CMake                            4             64             64            262

C++                              1              6              6             39
-------------------------------------------------------------------------------

SUM:                            44            870           1411           4032
-------------------------------------------------------------------------------


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83349

Files:
  clang/test/OpenMP/nvptx_target_simd_codegen.cpp
  openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h
  openmp/libomptarget/deviceRTLs/common/omptarget.h
  openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu
  openmp/libomptarget/deviceRTLs/common/src/libcall.cu
  openmp/libomptarget/deviceRTLs/common/src/loop.cu
  openmp/libomptarget/deviceRTLs/common/src/omptarget.cu
  openmp/libomptarget/deviceRTLs/common/src/parallel.cu
  openmp/libomptarget/deviceRTLs/common/src/reduction.cu
  openmp/libomptarget/deviceRTLs/common/src/support.cu
  openmp/libomptarget/deviceRTLs/common/src/sync.cu
  openmp/libomptarget/deviceRTLs/common/support.h
  openmp/libomptarget/deviceRTLs/interface.h
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83349.276225.patch
Type: text/x-patch
Size: 50590 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 14:55:03 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 21:55:03 +0000 (UTC)
Subject: [PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from
 the device runtime
In-Reply-To: 
References: 
Message-ID: <8cbd312bf659f8b68b583f150cda4cf3@localhost.localdomain>

jdoerfert added a comment.

Please let me know if something slipped through my "clever" grep logic and is actually used.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83349/new/

https://reviews.llvm.org/D83349




From cfe-commits at lists.llvm.org  Tue Jul  7 15:04:19 2020
From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:04:19 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: <1d2140de4508c8fe8d311da2344180e7@localhost.localdomain>

shafik updated this revision to Diff 276229.
shafik marked 5 inline comments as done.
shafik added a comment.

- Removing spurious local variables in test
- Simplifying the test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/Shell/Expr/Inputs/layout.cpp
  lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test


Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
@@ -0,0 +1,7 @@
+# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t
+
+# RUN: %lldb %t -b -s %s | FileCheck %s
+
+expr (intptr_t)&d3g.f2 - (intptr_t)&d3g
+# CHECK: (lldb) expr (intptr_t)&d3g.f2 - (intptr_t)&d3g
+# CHECK: (long) $0 = 8
Index: lldb/test/Shell/Expr/Inputs/layout.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/layout.cpp
@@ -0,0 +1,17 @@
+#include 
+
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {
+};
+
+D d3g;
+
+int main() {
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-    // FIXME: This appears to be reversed.
     if (Base->IsVirtual)
-      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-    else
       HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+    else
+      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83008.276229.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 15:09:03 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:09:03 +0000 (UTC)
Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls.
In-Reply-To: 
References: 
Message-ID: <71cf5fc1afd8b75c83b6def7bd084593@localhost.localdomain>

efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:94
 /// If it contains any dynamic allocas, returns false.
 static bool canTRE(Function &F) {
   // Because of PR962, we don't TRE dynamic allocas.
----------------
If we're not going to try to do TRE at all on calls not marked "tail", we can probably drop this check.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:808
   // Until this is resolved, disable this transformation if that would ever
   // happen.  This bug is PR962.
   for (Function::iterator BBI = F.begin(), E = F.end(); BBI != E; /*in loop*/) {
----------------
Can you move this FIXME into a more appropriate spot?


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:335
+        II->getIntrinsicID() == Intrinsic::assume)
+      return true;
+
----------------
avl wrote:
> efriedma wrote:
> > What is the new handling for lifetime.end/assume doing?
> They are just skipped. In following test case:
> 
> 
> ```
>   call void @_Z5test5i(i32 %sub)
>   call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %1) #5
>   call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #5
>   br label %return
> 
> ```
> 
> they are generated in between call and ret. It is safe to ignore them while checking whether transformation is possible.
It makes sense we can ignore lifetime.end on an alloca: we know the call doesn't refer to the alloca.  (Maybe we should check that the pointer argument is pointing at an alloca?  That should usually be true anyway, but better to be on the safe side, I guess.)

I don't think it's safe to hoist assume without additional checks; I think we'd need to check that the call is marked "willreturn"?

Since this is sort of tricky, I'd prefer to split this off into a followup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82085/new/

https://reviews.llvm.org/D82085




From cfe-commits at lists.llvm.org  Tue Jul  7 15:09:14 2020
From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:09:14 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: 

dblaikie added a comment.

In D82728#2137061 , @logan-5 wrote:

> In D82728#2137021 , @dblaikie wrote:
>
> > I think it might be nice to make the -Wno-inconsistent-missing-override -Wsuggest-override situation a bit better (by having it still do the same thing as -Wsuggest-override) but I don't feel /too/ strongly about it.
>
>
> So, ironing this out would mean the code would need this structure:
>
>   if (Inconsistent && IsWarningEnabled(-Winconsistent-missing-override))
>        Emit(-Winconsistent-missing-override);
>    else
>        Emit(-Wsuggest-override);
>
> The issue is that I wasn't able to find a way to ask if a warning is enabled and make a control flow decision based on that. If there is an API for doing this, it's hidden well. :) So I fell back to just doing `if (Inconsistent)` instead, which has this quirk if the inconsistent version of the warning is disabled.


Oh, yep, there's a way - it's usually used for performance-costly warnings, to not spend the resources computing the warning if it's disabled anyway.

Here's an arbitrary example: https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaDecl.cpp#L7237


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 15:30:31 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:30:31 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <2ac9d0be3e0e2128fa6edc727379cca4@localhost.localdomain>

logan-5 added a comment.

In D82728#2137492 , @dblaikie wrote:

> Oh, yep, there's a way - it's usually used for performance-costly warnings, to not spend the resources computing the warning if it's disabled anyway.


Wow, thanks--overlooked that in a big way. That'll definitely solve the problem. Fixed up patch on the way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 15:47:58 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:47:58 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <15931b4681184795fec2789c2f2f959f@localhost.localdomain>

logan-5 updated this revision to Diff 276248.
logan-5 added a comment.

Fall back to -Wsuggest-override if -Winconsistent-missing-override is disabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82728.276248.patch
Type: text/x-patch
Size: 7637 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 15:49:24 2020
From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:49:24 +0000 (UTC)
Subject: [PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from
 the device runtime
In-Reply-To: 
References: 
Message-ID: <269d00e12a4a974bd20e2ae1470e97ab@localhost.localdomain>

JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Applied to the amdgcn implementation. Compiles fine, tests all passing. Seems likely that this lot really is dead.

Interesting that this removes*_data_sharing_environment. I think some of the allocated objects will be more obviously dead after this patch.

Love it. Thanks! We can have this as soon as we hit consensus on dropping the API stability aspiration


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83349/new/

https://reviews.llvm.org/D83349




From cfe-commits at lists.llvm.org  Tue Jul  7 15:52:46 2020
From: cfe-commits at lists.llvm.org (Nithin VR via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:52:46 +0000 (UTC)
Subject: [PATCH] D81315: [analyzer] Warning for default constructed unique
 pointer dereferences
In-Reply-To: 
References: 
Message-ID: 

vrnithinkumar marked an inline comment as done.
vrnithinkumar added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:202-219
+ProgramStateRef
+SmartPtrModeling::updateTrackedRegion(const CallEvent &Call, CheckerContext &C,
+                                      const MemRegion *ThisValRegion) const {
+  ProgramStateRef State = C.getState();
+  auto NumArgs = Call.getNumArgs();
+
+  if (NumArgs == 0) {
----------------
NoQ wrote:
> Szelethus wrote:
> > Hmm, this function feels clunky. So, if the call has no arguments, we set the smart pointer to null, otherwise if its a single-argument then we set it to whatever the argument is? 
> > 
> > How about `operator[]`, that also takes a single argument, but isn't a memory region? `get`, `get_deleter` don't take any arguments, but they don't set the internal pointee to null either. The name `updateTrackedRegion` however suggests that whatever operation was done, this is the one-tool-to-solve-it-all function to take care of it.
> > 
> > I think this function handles too many things as once, and the name and lack of documentation obfuscates its purpose. How about we put the relevant code to `handleRelease`, and repurpose the rest of the function like this:
> > 
> > `updateOwnedRegion(CallEvent, CheckerContext, MemRegion of the smart pointer, MemRegion to take ownership of)`
> > 
> > What do you think?
> Yup, I completely agree. I think this structure will naturally evolve into something cleaner once more modeling gets added.
Thanks for the detailed comment.

I totally agree this method is handling many things. 
For methods like `get`, `get_deleter` this makes no sense at all.

I will add TODO there,  will address this  in a later patch once we get a clear picture after more modeling added.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81315/new/

https://reviews.llvm.org/D81315




From cfe-commits at lists.llvm.org  Tue Jul  7 15:55:37 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:55:37 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <01de8af836e1f3e632e7fa3a100d34f6@localhost.localdomain>

MaskRay added a comment.

I still haven't seen a strong argument keeping a command line option `-enable-npm-call-graph-profile`. Asked in D62627 .

`Opts.getProfileUse() != CodeGenOptions::ProfileNone ` in

  Opts.CallGraphProfile = Opts.getProfileUse() != CodeGenOptions::ProfileNone &&
                            !Opts.DisableIntegratedAS;

is redundant. CGProfile.cpp is a no-op if no function provides `getEntryFreq()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Tue Jul  7 15:57:34 2020
From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 22:57:34 +0000 (UTC)
Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default
In-Reply-To: 
References: 
Message-ID: <346925338e4fa181997a3fc105dc166c@localhost.localdomain>

tra added inline comments.


================
Comment at: clang/lib/Sema/SemaCUDA.cpp:757-759
+  // In host compilation, deferred diagnostics are only emitted for functions
+  // which are sure to be emitted on host side since there is no reliable
+  // way to check if a function is emitted on device side. Therefore in
----------------
I don't think this is completely correct. Postponed diags get emitted if we know we're attempoting to codegen wrong things.
E.g. during host compilation when HD function used by host code ends up attempting to call a device function.
It also works in the other direction -- it kicks in during device compilation when HD function calls a host function.
AFAICT it has nothing to do with what happens on the other side of the compilation, but rather what we're attempting to codegen during *this* compilation.

I don't think that we can reason that checks can be done on the host side only, based only on the argument you're making above (at least based on the way I understand it).

The point you're making below that a captured lambda created by device code can't ever be used by the host code is probably a better argument why the check may not be necessary.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655




From cfe-commits at lists.llvm.org  Tue Jul  7 16:02:53 2020
From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 23:02:53 +0000 (UTC)
Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments
In-Reply-To: 
References: 
Message-ID: 

JonChesterfield added a comment.

__kmpc_spmd_kernel_init is always called with RequiresDataSharing == 0
Specifically, it's only called from clang, and emitSPMDEntryHeader unconditionally passes zero to it

I.e. I think there's more stuff that can be cleaned up in the theme of the above, suggest in later patches


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83268/new/

https://reviews.llvm.org/D83268




From cfe-commits at lists.llvm.org  Tue Jul  7 16:08:26 2020
From: cfe-commits at lists.llvm.org (Amy Huang via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 23:08:26 +0000 (UTC)
Subject: [PATCH] D79147: [WIP] Merge -debug-info-kind=constructor into
 -debug-info-kind=limited
In-Reply-To: 
References: 
Message-ID: <7f4be141dbd810a854c4e9616b282c42@localhost.localdomain>

akhuang updated this revision to Diff 276252.
akhuang added a comment.
Herald added a subscriber: fedor.sergeev.

Instead of merging =constructor and =limited, change the default to use =constructor


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79147/new/

https://reviews.llvm.org/D79147

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-g-opts.c
  clang/test/Driver/cuda-dwarf-2.cu
  clang/test/Driver/debug-options-as.c
  clang/test/Driver/debug-options.c
  clang/test/Driver/integrated-as.s
  clang/test/Driver/myriad-toolchain.c
  clang/test/Driver/split-debug.c
  lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79147.276252.patch
Type: text/x-patch
Size: 11839 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 16:14:52 2020
From: cfe-commits at lists.llvm.org (Michael Spencer via cfe-commits)
Date: Tue, 07 Jul 2020 16:14:52 -0700 (PDT)
Subject: [clang] 64788d7 - [clang] Include missing LangOpts in `getModuleHash`.
Message-ID: <5f0501ec.1c69fb81.b4aa4.94a7@mx.google.com>


Author: Michael Spencer
Date: 2020-07-07T17:13:23-06:00
New Revision: 64788d7d5377345af5e3080d26cb6a76c324ab5b

URL: https://github.com/llvm/llvm-project/commit/64788d7d5377345af5e3080d26cb6a76c324ab5b
DIFF: https://github.com/llvm/llvm-project/commit/64788d7d5377345af5e3080d26cb6a76c324ab5b.diff

LOG: [clang] Include missing LangOpts in `getModuleHash`.

`ObjCRuntime` and `CommentOpts.BlockCommandNames` are checked by
`ASTReader::checkLanguageOptions`, but are not part of the module
context hash. This can lead to errors when using implicit modules if
different TUs have different values for these options when using the
same module cache.

This was not hit very often due to the rare usage of
`-fblock-command-names=` and that `ObjCRuntime` is by default set by
the target triple, which is part of the existing context hash.

Added: 
    

Modified: 
    clang/include/clang/Basic/ObjCRuntime.h
    clang/lib/Frontend/CompilerInvocation.cpp
    clang/test/Modules/context-hash.c
    llvm/include/llvm/Support/VersionTuple.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/ObjCRuntime.h b/clang/include/clang/Basic/ObjCRuntime.h
index 1c4a69269dee..26403bfa98c9 100644
--- a/clang/include/clang/Basic/ObjCRuntime.h
+++ b/clang/include/clang/Basic/ObjCRuntime.h
@@ -476,6 +476,10 @@ class ObjCRuntime {
   friend bool operator!=(const ObjCRuntime &left, const ObjCRuntime &right) {
     return !(left == right);
   }
+
+  friend llvm::hash_code hash_value(const ObjCRuntime &OCR) {
+    return llvm::hash_combine(OCR.getKind(), OCR.getVersion());
+  }
 };
 
 raw_ostream &operator<<(raw_ostream &out, const ObjCRuntime &value);

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index f58854cd9e08..6f6af917e3a3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3852,6 +3852,10 @@ std::string CompilerInvocation::getModuleHash() const {
   for (StringRef Feature : LangOpts->ModuleFeatures)
     code = hash_combine(code, Feature);
 
+  code = hash_combine(code, LangOpts->ObjCRuntime);
+  const auto &BCN = LangOpts->CommentOpts.BlockCommandNames;
+  code = hash_combine(code, hash_combine_range(BCN.begin(), BCN.end()));
+
   // Extend the signature with the target options.
   code = hash_combine(code, TargetOpts->Triple, TargetOpts->CPU,
                       TargetOpts->ABI);

diff  --git a/clang/test/Modules/context-hash.c b/clang/test/Modules/context-hash.c
index 33dfb2f15a2c..8bb7422f6a54 100644
--- a/clang/test/Modules/context-hash.c
+++ b/clang/test/Modules/context-hash.c
@@ -1,3 +1,6 @@
+// This test verifies that only strict hashing includes search paths and
+// diagnostics in the module context hash.
+
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fsyntax-only -internal-isystem \
 // RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
@@ -20,8 +23,25 @@
 // RUN: echo %t > %t.path
 // RUN: cat %t.path %t1 %t2 %t3 %t4 | FileCheck %s
 
-// This test verifies that only strict hashing includes search paths and
-// diagnostics in the module context hash.
+// This tests things verified by ASTReader::checkLanguageOptions that are not
+// part of LangOpts.def.
+
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t1
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fobjc-runtime=macosx-1.0.0.0 \
+// RUN:   -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t2
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fcomment-block-commands=lp,bj \
+// RUN:   -fmodules-cache-path=%t -x objective-c %s -Rmodule-build 2> %t3
+// RUN: echo %t > %t.path
+// RUN: cat %t.path %t1 %t2 %t3 | FileCheck --check-prefix=LANGOPTS %s
 
 #include 
 
@@ -32,3 +52,10 @@
 // CHECK: cstd-[[AST_HASH]].pcm'
 // CHECK-NOT: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
 // CHECK: cstd-[[AST_HASH]].pcm'
+
+// LANGOPTS: [[PREFIX:(.*[/\\])+[a-zA-Z0-9.-]+]]
+// LANGOPTS: building module 'cstd' as '[[PREFIX]]{{[/\\]}}[[CONTEXT_HASH:[A-Z0-9]+]]{{[/\\]}}cstd-[[AST_HASH:[A-Z0-9]+]].pcm'
+// LANGOPTS-NOT: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
+// LANGOPTS: cstd-[[AST_HASH]].pcm'
+// LANGOPTS-NOT: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
+// LANGOPTS: cstd-[[AST_HASH]].pcm'

diff  --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
index ad89e40f0f14..6f3711f06f1a 100644
--- a/llvm/include/llvm/Support/VersionTuple.h
+++ b/llvm/include/llvm/Support/VersionTuple.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_SUPPORT_VERSIONTUPLE_H
 #define LLVM_SUPPORT_VERSIONTUPLE_H
 
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
 #include 
 #include 
@@ -144,6 +145,10 @@ class VersionTuple {
     return !(X < Y);
   }
 
+  friend llvm::hash_code hash_value(const VersionTuple &VT) {
+    return llvm::hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build);
+  }
+
   /// Retrieve a string representation of the version number.
   std::string getAsString() const;
 


        

From cfe-commits at lists.llvm.org  Tue Jul  7 16:17:30 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 23:17:30 +0000 (UTC)
Subject: [PATCH] D82906: [flang][openmp] Use common Directive and Clause enum
 from llvm/Frontend
In-Reply-To: 
References: 
Message-ID: <750fe88b56d6dee5b32222221de2b4fb@localhost.localdomain>

jdoerfert added a comment.

YAY :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82906/new/

https://reviews.llvm.org/D82906




From cfe-commits at lists.llvm.org  Tue Jul  7 16:31:52 2020
From: cfe-commits at lists.llvm.org (Michael Kruse via Phabricator via cfe-commits)
Date: Tue, 07 Jul 2020 23:31:52 +0000 (UTC)
Subject: [PATCH] D76342: [OpenMP] Implement '#pragma omp tile'
In-Reply-To: 
References: 
Message-ID: <83204dabeae601d790649bd1d1d431fa@localhost.localdomain>

Meinersbur updated this revision to Diff 276259.
Meinersbur added a comment.

- Rebase, especially omp_gen
- Some cleanup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76342/new/

https://reviews.llvm.org/D76342

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Index/openmp-tile.c
  clang/test/OpenMP/tile_ast_print.cpp
  clang/test/OpenMP/tile_codegen.cpp
  clang/test/OpenMP/tile_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76342.276259.patch
Type: text/x-patch
Size: 165399 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 17:08:38 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:08:38 +0000 (UTC)
Subject: [PATCH] D83176: [OpenMPIRBuilder][Fix] Move llvm::omp::types to
 OpenMPIRBuilder.
In-Reply-To: 
References: 
Message-ID: <91f32270b7e1471eaa7199c29854722c@localhost.localdomain>

jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM.



================
Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:1125
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+}
----------------
While we are here, remove `uninitializeTypes`


================
Comment at: llvm/lib/Transforms/IPO/OpenMPOpt.cpp:313
   {                                                                            \
     SmallVector ArgsTypes({__VA_ARGS__});                           \
     Function *F = M.getFunction(_Name);                                        \
----------------
hoyFB wrote:
> sstefan1 wrote:
> > I wasn't sure how to handle `__VA_ARGS__` here, since we would need `OMPBuilder` in front of every type. 
> > That is why helper macros above exist. The problem with this is that this creates some unused variables in `OpenMPOpt`.
> > 
> > Not sure if `-Wno-unused-variable` would be a good thing to do temporarily? Is there another way to handle `__VA_ARGS__` here?
> Could it be possible to use `OMPBuilder. _Name`, `OMPBuilder. _ReturnType` everywhere?
Since this will (soonish) be replaced by tablegen definitions we can apply the following workaround:

Keep your helper macros but add
`(void) VarName;`
after each declaration :) 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83176/new/

https://reviews.llvm.org/D83176




From cfe-commits at lists.llvm.org  Tue Jul  7 17:11:23 2020
From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:11:23 +0000 (UTC)
Subject: [PATCH] D79147: Switch to using -debug-info-kind=constructor as
 default (from =limited)
In-Reply-To: 
References: 
Message-ID: <76110580d3f03c425f2a4a56a09cc62d@localhost.localdomain>

dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Could you include some comparative data in the description/commit message demonstrating this generally ends up emitting all the same types for a clang build before/after (& explanations for a sample of any differences)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79147/new/

https://reviews.llvm.org/D79147




From cfe-commits at lists.llvm.org  Tue Jul  7 17:13:34 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:13:34 +0000 (UTC)
Subject: [PATCH] D71739: [AssumeBundles] Use operand bundles to encode
 alignment assumptions
In-Reply-To: 
References: 
Message-ID: <09008075e8f920e7b57073b7f3c2c848@localhost.localdomain>

jdoerfert accepted this revision.
jdoerfert added a comment.

LGTM. @lebedev.ri ?



================
Comment at: llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp:227
   }
-
-  if (!AAPtr)
-    return false;
-
-  // Sign extend the offset to 64 bits (so that it is like all of the other
-  // expressions).
-  unsigned OffSCEVBits = OffSCEV->getType()->getPrimitiveSizeInBits();
-  if (OffSCEVBits < 64)
-    OffSCEV = SE->getSignExtendExpr(OffSCEV, Int64Ty);
-  else if (OffSCEVBits > 64)
-    return false;
-
-  AAPtr = AAPtr->stripPointerCasts();
-  return true;
+  return false;
 }
----------------
Early exit please.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71739/new/

https://reviews.llvm.org/D71739




From cfe-commits at lists.llvm.org  Tue Jul  7 17:24:36 2020
From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:24:36 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <1b64154b65c1cbd140210ad6d9472984@localhost.localdomain>

dblaikie added a comment.

Generally looks good to me (description/commit message should be updated now that the inconsistent inconsistency is no longer an issue)



================
Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
----------------
Does GCC have suggest-destructor-override as a separate warning too?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 17:24:43 2020
From: cfe-commits at lists.llvm.org (Yifan Shen via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:24:43 +0000 (UTC)
Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event
In-Reply-To: 
References: 
Message-ID: <9eccc8f0e5f86a1b75501a99b33c2d17@localhost.localdomain>

aelitashen updated this revision to Diff 276274.
aelitashen added a comment.

Fix messy diff stack


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82477.276274.patch
Type: text/x-patch
Size: 10437 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 17:27:03 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:27:03 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
Message-ID: 

LukeZhuang created this revision.
LukeZhuang added reviewers: lebedev.ri, erichkeane, xbolva00, RKSimon, rsmith.
LukeZhuang added a project: clang.
Herald added subscribers: cfe-commits, martong.

Previously some places that should have handled `__builtin_expect_with_probability` is missing, so in some case it acts differently than `__builtin_expect`.
For example it was not handled in constant folding, thus in the following program, the "if" condition should be constantly true and folded, but previously it was not handled and cause warning "control may reach end of non-void function" (while `__builtin_expect` does not):

  __attribute__((noreturn)) extern void bar();
  int foo(int x, int y) {
    if (y) {
      if (__builtin_expect_with_probability(1, 1, 1))
        bar();
    }
     else
      return 0;
  }

Now it's fixed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83362

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===================================================================
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,16 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+    if (__builtin_expect_with_probability(1, 1, 1))
+      bar();
+  } else {
+    return 0;
+  }
+}  // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-    // For __builtin_unpredictable, __builtin_expect, and
-    // __builtin_assume_aligned, just return the value of the subexpression.
+    // For __builtin_unpredictable, __builtin_expect,
+    // __builtin_expect_with_probability and __builtin_assume_aligned,
+    // just return the value of the subexpression.
     // __builtin_addressof is going from a reference to a pointer, but those
     // are represented the same way in the analyzer.
     assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
     return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83362.276270.patch
Type: text/x-patch
Size: 2068 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 17:31:31 2020
From: cfe-commits at lists.llvm.org (Greg Clayton via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:31:31 +0000 (UTC)
Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event
In-Reply-To: 
References: 
Message-ID: <943ede9351ed46836075b3561c0e7fd0@localhost.localdomain>

clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

Just test for paths and this will be good to go!



================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:35
+        self.assertEqual(program_basename, program_module['name'])
+        self.assertIn('path', program_module, 'make sure path is in module')
+        self.assertTrue('symbolFilePath' not in program_module, 'Make sure a.out.stripped has no debug info')
----------------
add a check for the path:
```
self.assertEqual(program, program_module['path'])
```


================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:42
+        program_module = active_modules[program_basename]
+        self.assertEqual(program_basename, program_module['name'])
+        self.assertEqual('Symbols loaded.', program_module['symbolStatus'])
----------------
check 'path' again here.


================
Comment at: lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py:47
+        self.assertIn('addressRange', program_module)
\ No newline at end of file

----------------
add a newline


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477




From cfe-commits at lists.llvm.org  Tue Jul  7 17:41:32 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:41:32 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: 

logan-5 marked an inline comment as done.
logan-5 added inline comments.


================
Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
----------------
dblaikie wrote:
> Does GCC have suggest-destructor-override as a separate warning too?
It does not. In fact, there's no way to get GCC to warn about destructors missing `override`. (Which is somewhat defensible, since `override` is really great for preventing subtle signature mismatches/typos, but destructors don't really have those problems.) However, Clang already has a destructor-specific flavor of the inconsistent-override warning, so I added -Wsuggest-destructor-override for symmetry with -Winconsistent-missing-[destructor-]override.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 17:43:31 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:43:31 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <6f7f9ef9006a3fcda1d803174146945d@localhost.localdomain>

logan-5 marked an inline comment as done.
logan-5 added inline comments.


================
Comment at: clang/test/SemaCXX/warn-suggest-destructor-override:1
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
----------------
logan-5 wrote:
> dblaikie wrote:
> > Does GCC have suggest-destructor-override as a separate warning too?
> It does not. In fact, there's no way to get GCC to warn about destructors missing `override`. (Which is somewhat defensible, since `override` is really great for preventing subtle signature mismatches/typos, but destructors don't really have those problems.) However, Clang already has a destructor-specific flavor of the inconsistent-override warning, so I added -Wsuggest-destructor-override for symmetry with -Winconsistent-missing-[destructor-]override.
Note that this really is the best of both worlds, since it lets Clang's -Wsuggest-override behave identically to GCC's (not warning on destructors), as well as be consistent with its own already existing override warnings (with a special extra flag to enable warnings for destructors).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Tue Jul  7 17:48:06 2020
From: cfe-commits at lists.llvm.org (Akira Hatanaka via cfe-commits)
Date: Tue, 07 Jul 2020 17:48:06 -0700 (PDT)
Subject: [clang] 0402705 - [Sema] Teach -Wcast-align to compute alignment of
 CXXThisExpr
Message-ID: <5f0517c6.1c69fb81.ee2f8.429a@mx.google.com>


Author: Akira Hatanaka
Date: 2020-07-07T17:45:04-07:00
New Revision: 04027052a72f982c9e09472427ec7339415fb777

URL: https://github.com/llvm/llvm-project/commit/04027052a72f982c9e09472427ec7339415fb777
DIFF: https://github.com/llvm/llvm-project/commit/04027052a72f982c9e09472427ec7339415fb777.diff

LOG: [Sema] Teach -Wcast-align to compute alignment of CXXThisExpr

This fixes https://bugs.llvm.org/show_bug.cgi?id=46605.

rdar://problem/65158878

Differential Revision: https://reviews.llvm.org/D83317

Added: 
    

Modified: 
    clang/lib/Sema/SemaChecking.cpp
    clang/test/SemaCXX/warn-cast-align.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 77858b17d62c..efaf36a69306 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -13560,12 +13560,14 @@ static getBaseAlignmentAndOffsetFromLValue(const Expr *E, ASTContext &Ctx) {
   }
   case Stmt::MemberExprClass: {
     auto *ME = cast(E);
-    if (ME->isArrow())
-      break;
     auto *FD = dyn_cast(ME->getMemberDecl());
     if (!FD || FD->getType()->isReferenceType())
       break;
-    auto P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
+    Optional> P;
+    if (ME->isArrow())
+      P = getBaseAlignmentAndOffsetFromPtr(ME->getBase(), Ctx);
+    else
+      P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
     if (!P)
       break;
     const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(FD->getParent());
@@ -13629,6 +13631,11 @@ static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx) {
     }
     break;
   }
+  case Stmt::CXXThisExprClass: {
+    auto *RD = E->getType()->getPointeeType()->getAsCXXRecordDecl();
+    CharUnits Alignment = Ctx.getASTRecordLayout(RD).getNonVirtualAlignment();
+    return std::make_pair(Alignment, CharUnits::Zero());
+  }
   case Stmt::UnaryOperatorClass: {
     auto *UO = cast(E);
     if (UO->getOpcode() == UO_AddrOf)

diff  --git a/clang/test/SemaCXX/warn-cast-align.cpp b/clang/test/SemaCXX/warn-cast-align.cpp
index 53cd75fb1405..1e84ba9cd67a 100644
--- a/clang/test/SemaCXX/warn-cast-align.cpp
+++ b/clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,9 +44,16 @@ void test1(void *P) {
   c = IntPtr(P);
 }
 
+struct __attribute__((aligned(16))) AlignedS {
+  char m[16];
+};
+
 struct __attribute__((aligned(16))) A {
   char m0[16];
   char m1[16];
+  AlignedS *getAlignedS() {
+    return (AlignedS *)m1;
+  }
 };
 
 struct B0 {
@@ -92,6 +99,9 @@ struct __attribute__((aligned(16))) D4 : virtual D2 {
 
 struct D5 : virtual D0 {
   char m0[16];
+  AlignedS *get() {
+    return (AlignedS *)m0; // expected-warning {{cast from 'char *' to 'AlignedS *'}}
+  }
 };
 
 struct D6 : virtual D5 {


        

From cfe-commits at lists.llvm.org  Tue Jul  7 17:48:10 2020
From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:48:10 +0000 (UTC)
Subject: [PATCH] D83317: [Sema] Teach -Wcast-align to compute alignment of
 CXXThisExpr
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG04027052a72f: [Sema] Teach -Wcast-align to compute alignment of CXXThisExpr (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83317/new/

https://reviews.llvm.org/D83317

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp


Index: clang/test/SemaCXX/warn-cast-align.cpp
===================================================================
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -44,9 +44,16 @@
   c = IntPtr(P);
 }
 
+struct __attribute__((aligned(16))) AlignedS {
+  char m[16];
+};
+
 struct __attribute__((aligned(16))) A {
   char m0[16];
   char m1[16];
+  AlignedS *getAlignedS() {
+    return (AlignedS *)m1;
+  }
 };
 
 struct B0 {
@@ -92,6 +99,9 @@
 
 struct D5 : virtual D0 {
   char m0[16];
+  AlignedS *get() {
+    return (AlignedS *)m0; // expected-warning {{cast from 'char *' to 'AlignedS *'}}
+  }
 };
 
 struct D6 : virtual D5 {
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -13560,12 +13560,14 @@
   }
   case Stmt::MemberExprClass: {
     auto *ME = cast(E);
-    if (ME->isArrow())
-      break;
     auto *FD = dyn_cast(ME->getMemberDecl());
     if (!FD || FD->getType()->isReferenceType())
       break;
-    auto P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
+    Optional> P;
+    if (ME->isArrow())
+      P = getBaseAlignmentAndOffsetFromPtr(ME->getBase(), Ctx);
+    else
+      P = getBaseAlignmentAndOffsetFromLValue(ME->getBase(), Ctx);
     if (!P)
       break;
     const ASTRecordLayout &Layout = Ctx.getASTRecordLayout(FD->getParent());
@@ -13629,6 +13631,11 @@
     }
     break;
   }
+  case Stmt::CXXThisExprClass: {
+    auto *RD = E->getType()->getPointeeType()->getAsCXXRecordDecl();
+    CharUnits Alignment = Ctx.getASTRecordLayout(RD).getNonVirtualAlignment();
+    return std::make_pair(Alignment, CharUnits::Zero());
+  }
   case Stmt::UnaryOperatorClass: {
     auto *UO = cast(E);
     if (UO->getOpcode() == UO_AddrOf)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83317.276283.patch
Type: text/x-patch
Size: 1916 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 17:48:37 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:48:37 +0000 (UTC)
Subject: [PATCH] D83004: [UpdateCCTestChecks] Include generated functions if
 asked
In-Reply-To: 
References: 
Message-ID: <206eade602cee464ba4d566b6282c24c@localhost.localdomain>

jdoerfert added inline comments.


================
Comment at: llvm/utils/update_cc_test_checks.py:133
+  parser.add_argument('--include-generated-funcs', action='store_true',
+                      help='Output checks for functions not in source')
   parser.add_argument('tests', nargs='+')
----------------
greened wrote:
> jdoerfert wrote:
> > greened wrote:
> > > greened wrote:
> > > > jdoerfert wrote:
> > > > > I think this should go into common.py (after D78618). I would also make this the default but OK.
> > > > Yes I suppose it should in case `opt` and friends generate functions.  I hadn't considered that use-case.
> > > > 
> > > > While I would like to make it default unfortunately it would require updating a bunch of the existing clang tests which doesn't seem too friendly.  See the patch update comment for details.
> > > > 
> > > Just realized it wouldn't necessarily require regeneration of tests, it would just cause regenerated tests to change a lot when they are eventually regenerated.  We should discuss as to whether that's acceptable.  I think for now this should be non-default to at least get the functionality in without disturbing existing users and then we can discuss a separate change to make it default.
> > > 
> > > It's also possible we could change how clang orders functions.  I discovered there's a difference in clang 10 vs. 11 in the order functions are output when OpenMP outlining happens.  clang 10 seems to preserve the source order of functions and clang 11 does not.  Perhaps that needs to be fixed as I don't know whether that change was intentional or not.
> > Best case, without the option the original behavior is preserved. Is that not the case?
> That's right.  I was referring to making this behavior default.  If we do that, we could clean up the script code a bit but it would mean clang tests would change pretty dramatically when they are regenerated.  If we fix the clang output, the test changes wouldn't be so dramatic.
> 
> The way clang is behaving now, I would expect any tests that use `-fopenmp`, have multiple functions with OpenMP regions and use function prototypes for some of those functions would break given clang's reordering of function definitions.  Perhaps we don't have any tests like that though.
We (almost) do not have OpenMP tests with autogenerated test lines. Partially, because we do not test new functions. I would really like this to be available for OpenMP, both in _cc_ and IR tests. If people can opt out of this, especially if the default is "off", the ordering is not a problem (IMHO). With UTC_ARGS we also remember the choice so I really don't see the downside to this being in the common part for all scripts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83004/new/

https://reviews.llvm.org/D83004




From cfe-commits at lists.llvm.org  Tue Jul  7 17:59:51 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 00:59:51 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <099da621c8e3549f2157c7935f12bafb@localhost.localdomain>

hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1254
+  // space or zero-extent array.
+  if (DefaultsToAIXPowerAlignment && !getDataSize().isZero()) {
+    PreferredBaseAlign = BaseAlign;
----------------
This needs to check `HandledFirstNonOverlappingEmptyField`:
```
struct A {
  char x[0];
};
struct B {
  double d;
};
struct C : A, B { char x; } c;
```


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1255
+  if (DefaultsToAIXPowerAlignment && !getDataSize().isZero()) {
+    PreferredBaseAlign = BaseAlign;
+  }
----------------
Note that `PreferredBaseAlign` is only truly meaningful after this line, and related fields, such as `UnpackedPreferredBaseAlign`, require similar treatment. With `UnpackedAlignTo` being dependent on a meaningful value of `UnpackedPreferredBaseAlign`, it needs an update here as well.

Consider the following source. Noting that `C` and `D` are identical except for the packed attribute and yield identical layout properties despite that difference, we should be getting a `-Wpacked` warning with `-Wpacked` (but it is missing).
```
struct A {
  double d;
};

struct B {
  char x[8];
};

struct [[gnu::packed]] C : B, A { // expected-warning {{packed attribute is unnecessary}}
  char x alignas(4)[8];
} c;

struct D : B, A {
  char x alignas(4)[8];
} d;
```
```
*** Dumping AST Record Layout
         0 | struct C
         0 |   struct B (base)
         0 |     char [8] x
         8 |   struct A (base)
         8 |     double d
        16 |   char [8] x
           | [sizeof=24, dsize=24, align=4, preferredalign=4,
           |  nvsize=24, nvalign=4, preferrednvalign=4]
```
```
*** Dumping AST Record Layout
         0 | struct D
         0 |   struct B (base)
         0 |     char [8] x
         8 |   struct A (base)
         8 |     double d
        16 |   char [8] x
           | [sizeof=24, dsize=24, align=4, preferredalign=4,
           |  nvsize=24, nvalign=4, preferrednvalign=4]
```



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Tue Jul  7 18:04:59 2020
From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 01:04:59 +0000 (UTC)
Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition
 and MC Tests for Load and Store VSX Vector with Zero or Sign Extend
Message-ID: 

Conanap created this revision.
Conanap added reviewers: power-llvm-team, PowerPC, saghir, nemanjai, hfinkel.
Conanap added projects: LLVM, clang, PowerPC.

Includes instruction defintion and MC Tests for above instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83364

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===================================================================
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3                       # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3                       # encoding: [0xcf,0x1b,0x22,0x10]
             vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2                       # encoding: [0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2                       # encoding: [0x1b,0x10,0x01,0x7c]
+            lxvrbx 32, 1, 2
+# CHECK-BE: lxvrhx 33, 1, 2                       # encoding: [0x7c,0x21,0x10,0x5b]
+# CHECK-LE: lxvrhx 33, 1, 2                       # encoding: [0x5b,0x10,0x21,0x7c]
+            lxvrhx 33, 1, 2
+# CHECK-BE: lxvrdx 34, 1, 2                       # encoding: [0x7c,0x41,0x10,0xdb]
+# CHECK-LE: lxvrdx 34, 1, 2                       # encoding: [0xdb,0x10,0x41,0x7c]
+            lxvrdx 34, 1, 2
+# CHECK-BE: lxvrwx 35, 1, 2                       # encoding: [0x7c,0x61,0x10,0x9b]
+# CHECK-LE: lxvrwx 35, 1, 2                       # encoding: [0x9b,0x10,0x61,0x7c]
+            lxvrwx 35, 1, 2
+# CHECK-BE: stxvrbx 32, 3, 1                      # encoding: [0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1                      # encoding: [0x1b,0x09,0x03,0x7c]
+            stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1                      # encoding: [0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1                      # encoding: [0x5b,0x09,0x23,0x7c]
+            stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1                      # encoding: [0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1                      # encoding: [0x9b,0x09,0x43,0x7c]
+            stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1                      # encoding: [0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1                      # encoding: [0xdb,0x09,0x63,0x7c]
+            stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===================================================================
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -278,3 +278,27 @@
 
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
+
+# CHECK: lxvrbx 32, 1, 2
+0x7c 0x01 0x10 0x1b
+
+# CHECK: lxvrhx 33, 1, 2
+0x7c 0x21 0x10 0x5b
+
+# CHECK: lxvrdx 34, 1, 2
+0x7c 0x41 0x10 0xdb
+
+# CHECK: lxvrwx 35, 1, 2
+0x7c 0x61 0x10 0x9b
+
+# CHECK: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -428,6 +428,22 @@
 def PrefixInstrs : Predicate<"Subtarget->hasPrefixInstrs()">;
 def IsISA3_1 : Predicate<"Subtarget->isISA3_1()">;
 
+let mayLoad = 1, mayStore = 0, Predicates = [IsISA3_1] in {
+  // The XFormMemOp flag is set on the instruction format.
+  def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;
+  def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>;
+  def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>;
+  def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>;
+}
+
+let mayLoad = 0, mayStore = 1, Predicates = [IsISA3_1] in {
+  // The XFormMemOp flag is set on the instruction format.
+  def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>;
+  def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>;
+  def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>;
+  def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>;
+}
+
 let Predicates = [PrefixInstrs] in {
   let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
     defm PADDI8 :


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83364.276282.patch
Type: text/x-patch
Size: 3953 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 18:10:23 2020
From: cfe-commits at lists.llvm.org (Yifan Shen via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 01:10:23 +0000 (UTC)
Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event
In-Reply-To: 
References: 
Message-ID: <94935f63a2f86be33271ae9fc409f770@localhost.localdomain>

aelitashen updated this revision to Diff 276294.
aelitashen added a comment.

Add Path Verification in Test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/module/Makefile
  lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py
  lldb/test/API/tools/lldb-vscode/module/main.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/JSONUtils.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82477.276294.patch
Type: text/x-patch
Size: 10565 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 18:28:40 2020
From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits)
Date: Tue, 07 Jul 2020 18:28:40 -0700 (PDT)
Subject: [clang] 065fc1e - PR45521: Preserve the value kind when performing a
 standard conversion
Message-ID: <5f052148.1c69fb81.66175.5455@mx.google.com>


Author: Richard Smith
Date: 2020-07-07T18:28:28-07:00
New Revision: 065fc1eafe7c6f67f8029bcd38e6864b3c429e35

URL: https://github.com/llvm/llvm-project/commit/065fc1eafe7c6f67f8029bcd38e6864b3c429e35
DIFF: https://github.com/llvm/llvm-project/commit/065fc1eafe7c6f67f8029bcd38e6864b3c429e35.diff

LOG: PR45521: Preserve the value kind when performing a standard conversion
sequence on a glvalue expression.

If the sequence is supposed to perform an lvalue-to-rvalue conversion,
then one will be specified as the first conversion in the sequence.
Otherwise, one should not be invented.

Added: 
    

Modified: 
    clang/lib/Sema/SemaExprCXX.cpp
    clang/lib/Sema/SemaOverload.cpp
    clang/test/SemaCXX/references.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 0a0bb3952cd8..d885920b6c14 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4203,8 +4203,8 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
     break;
 
   case ICK_Compatible_Conversion:
-      From = ImpCastExprToType(From, ToType, CK_NoOp,
-                               VK_RValue, /*BasePath=*/nullptr, CCK).get();
+    From = ImpCastExprToType(From, ToType, CK_NoOp, From->getValueKind(),
+                             /*BasePath=*/nullptr, CCK).get();
     break;
 
   case ICK_Writeback_Conversion:
@@ -4441,11 +4441,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
     break;
 
   case ICK_Qualification: {
-    // The qualification keeps the category of the inner expression, unless the
-    // target type isn't a reference.
-    ExprValueKind VK =
-        ToType->isReferenceType() ? From->getValueKind() : VK_RValue;
-
+    ExprValueKind VK = From->getValueKind();
     CastKind CK = CK_NoOp;
 
     if (ToType->isReferenceType() &&

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d68be854aeeb..599e81d1b4d0 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4709,7 +4709,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
                               Sema::ReferenceConversions::NestedQualification)
                              ? ICK_Qualification
                              : ICK_Identity;
-    ICS.Standard.FromTypePtr = T2.getAsOpaquePtr();
+    ICS.Standard.setFromType(T2);
     ICS.Standard.setToType(0, T2);
     ICS.Standard.setToType(1, T1);
     ICS.Standard.setToType(2, T1);

diff  --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp
index f30e16d990eb..eaab1ae833e4 100644
--- a/clang/test/SemaCXX/references.cpp
+++ b/clang/test/SemaCXX/references.cpp
@@ -201,3 +201,9 @@ namespace RefCollapseTypePrinting {
   template void add_rref(); // expected-note {{instantiation of}}
   template void add_rref(); // expected-note {{instantiation of}}
 }
+
+namespace PR45521 {
+  struct a { template a(const b * const&); };
+  int *d;
+  const a &r = d;
+}


        

From cfe-commits at lists.llvm.org  Tue Jul  7 20:24:19 2020
From: cfe-commits at lists.llvm.org (Qiu Chaofan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 03:24:19 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: <3edefe85a4e0035499f8c0f959b4ca31@localhost.localdomain>

qiucf added a comment.

Thanks for this patch!

If I understand correctly, only `isEmptyRecord`/`isEmptyField` and places checking any field is zero bit-width may need change for this? Since `isSingleElementStruct` and `isHomogeneousAggregate` just use them to skip empty fields in aggregate. I didn't see direct checking for empty fields on PowerPC. So all change needed on PPC seems to be generic. By enabling `AllowNoUniqueAddr` in these methods, case in https://lists.llvm.org/pipermail/llvm-dev/2020-July/143141.html can be correctly recognized as homogeneous aggregate.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Tue Jul  7 21:02:04 2020
From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 04:02:04 +0000 (UTC)
Subject: [PATCH] D83286: [analyzer][solver] Track symbol disequalities
In-Reply-To: 
References: 
Message-ID: 

NoQ added a comment.

This looks great to me but i'd very much rather have someone else have a look, just because of the nature of the problem (:



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1586
+  // 4. Update disequality relations
+  if (const ClassSet *DisequalToOther = DisequalityInfo.lookup(Other)) {
+    ClassSet DisequalToThis = getDisequalClasses(State);
----------------
Nit: I think it's a bit messy to use `getDisequalClasses()` in some places but manual lookup in other places. Like, someone may change the function and believe that they changed the entire lookup mechanism but fail to notice that the function wasn't used consitently. I think this may be worth encapsulating.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1727
+
+  // Let's check if know anything about these two classes being not equal to
+  // each other.
----------------
Parse error; missing "we"?


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1913-1915
+        // DisequalToDisequalSet is guaranteed to be non-null for consistent
+        // disequality info.
+        ClassSet NewSet = ClassSetFactory.remove(*DisequalToDisequalSet, Class);
----------------
I actually wouldn't mind duplicating a direct assertion here, given that consistency checks are pretty complicated on their own :)


================
Comment at: clang/test/Analysis/mutually_exclusive_null_fp.cpp:25
+
+  return compare(*aData, *bData);
+}
----------------
`// no-warning` please? These marks make tests a lot easier to understand when you break them 5 years later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83286/new/

https://reviews.llvm.org/D83286




From cfe-commits at lists.llvm.org  Tue Jul  7 22:07:53 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 05:07:53 +0000 (UTC)
Subject: [PATCH] D83369: hwasan: Don't pass the tagged-globals target-feature
 to non-aarch64 backends.
Message-ID: 

craig.topper created this revision.
craig.topper added reviewers: pcc, vitalybuka, hctim.
Herald added subscribers: danielkiss, kristof.beyls.
Herald added a project: clang.

The other backends don't know what this feature is and print a
message to stderr.

I recently tried to rework some target feature stuff in X86 and
this unknown feature tripped an assert I added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83369

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===================================================================
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in '-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POINTER-ALL
Index: clang/lib/Driver/SanitizerArgs.cpp
===================================================================
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@
     CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
     CmdArgs.push_back("-target-feature");
     CmdArgs.push_back("+tagged-globals");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83369.276311.patch
Type: text/x-patch
Size: 1566 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 23:20:53 2020
From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 06:20:53 +0000 (UTC)
Subject: [PATCH] D82659: Fix missing build dependency on omp_gen.
In-Reply-To: 
References: 
Message-ID: <73cfa182f8947318a2073b00c2f8cf94@localhost.localdomain>

michele.scandale added a comment.

In D82659#2136999 , @clementval wrote:

> Looks good but just one question ... When clang is built as standalone it does not build the OpenMP part inside Clang? I haven't seen any code to avoid compiling the OpenMP parsing and semantic checking inside clang.


I don't think there is a way to avoid compiling the OpenMP support in Clang. The standalone build is just building the content of the `clang` directory as a separate CMake project reusing the an already built LLVM -- therefore the `libLLVMFrontendOpenMP` as well as the `OMP.h.inc` would have been generated already.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82659/new/

https://reviews.llvm.org/D82659




From cfe-commits at lists.llvm.org  Tue Jul  7 23:57:44 2020
From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 06:57:44 +0000 (UTC)
Subject: [PATCH] D82739: Improve heuristic resolution of dependent types in
 TargetFinder
In-Reply-To: 
References: 
Message-ID: <80271eaacb7c388727987cf26a617849@localhost.localdomain>

nridge marked an inline comment as done.
nridge added a comment.

In D82739#2133155 , @hokein wrote:

> looks like we use this heuristic for go-to-def, I think we might want to use it in more places, e.g.  libindex (for xrefs), sema code completion (so that `this->a.^` can suggest something).


Yeah, this is a great point. I would definitely like to reuse this heuristic resolution for other features like code completion (including in https://github.com/clangd/clangd/issues/443 where I hope to build on it to improve the original STR which involves completion).

I will explore relocating this code to a place where things like code completion can reuse it, in a follow-up patch.



================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:198
+    // analyzing it.
+    if (E && BT->getKind() == BuiltinType::Dependent) {
+      T = resolveDependentExprToType(E);
----------------
hokein wrote:
> I think this is the key point of the fix?
> 
> It would be nice if you could find a way to split it into two (one for refactoring, one for the fix). The diff of this patch contains large chunk of refactoring changes which make the fix less obvious.
Yeah, sorry about that. I've split the patch and cleaned it up further (to avoid unnecessary reordering of functions) to make the diff neater.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82739/new/

https://reviews.llvm.org/D82739




From cfe-commits at lists.llvm.org  Tue Jul  7 23:57:57 2020
From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 06:57:57 +0000 (UTC)
Subject: [PATCH] D83371: [clangd] Factor out some helper functions related to
 heuristic resolution in TargetFinder
Message-ID: 

nridge created this revision.
nridge added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Two helpers are introduced:

- Some of the logic previously in TargetFinder::Visit*() methods is factored out into resolveDependentExprToDecls().
- Some of the logic in getMembersReferencedViaDependentName() is factored out into resolveTypeToRecordDecl().

D82739  will build on this and use these functions in new ways.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83371

Files:
  clang-tools-extra/clangd/FindTarget.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83371.276319.patch
Type: text/x-patch
Size: 4856 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Tue Jul  7 23:59:11 2020
From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 06:59:11 +0000 (UTC)
Subject: [PATCH] D82739: Improve heuristic resolution of dependent types in
 TargetFinder
In-Reply-To: 
References: 
Message-ID: 

nridge updated this revision to Diff 276320.
nridge added a comment.

Split patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82739/new/

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82739.276320.patch
Type: text/x-patch
Size: 4583 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 00:00:06 2020
From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:00:06 +0000 (UTC)
Subject: [PATCH] D82739: Improve heuristic resolution of dependent types in
 TargetFinder
In-Reply-To: 
References: 
Message-ID: 

nridge added a comment.

Split out the refactoring into D83371  which this depends on now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82739/new/

https://reviews.llvm.org/D82739




From cfe-commits at lists.llvm.org  Wed Jul  8 00:06:19 2020
From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:06:19 +0000 (UTC)
Subject: [PATCH] D83371: [clangd] Factor out some helper functions related to
 heuristic resolution in TargetFinder
In-Reply-To: 
References: 
Message-ID: 

nridge updated this revision to Diff 276321.
nridge added a comment.

Improve patch split


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83371/new/

https://reviews.llvm.org/D83371

Files:
  clang-tools-extra/clangd/FindTarget.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83371.276321.patch
Type: text/x-patch
Size: 4743 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 00:06:54 2020
From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:06:54 +0000 (UTC)
Subject: [PATCH] D82739: Improve heuristic resolution of dependent types in
 TargetFinder
In-Reply-To: 
References: 
Message-ID: 

nridge updated this revision to Diff 276322.
nridge added a comment.

Improve patch split


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82739/new/

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82739.276322.patch
Type: text/x-patch
Size: 4928 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 00:20:36 2020
From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:20:36 +0000 (UTC)
Subject: [PATCH] D82805: [clang] Fix a crash on passing C structure of
 incompatible type to function with reference parameter
In-Reply-To: 
References: 
Message-ID: 

ArcsinX added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82805/new/

https://reviews.llvm.org/D82805




From cfe-commits at lists.llvm.org  Wed Jul  8 00:32:29 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Johel_Ernesto_Guerrero_Pe=C3=B1a_via_Phabricator?= via cfe-commits)
Date: Wed, 08 Jul 2020 07:32:29 +0000 (UTC)
Subject: [PATCH] D79773: [clang-format] Improve clang-formats handling of
 concepts
In-Reply-To: 
References: 
Message-ID: <3356041c09895652f31528e2b2873fd5@localhost.localdomain>

JohelEGP added a comment.

Ah, that makes sense. The very definition of Allman is to always break before braces. I suppose I'll need to use `BreakBeforeBraces: Custom` and `BraceWrapping:`. I did some testing and noticed that the weird format comes with any of these:

  BreakBeforeBraces: Custom
  BraceWrapping:
    AfterControlStatement: MultiLine

  BreakBeforeBraces: Custom
  BraceWrapping:
    AfterFunction: true

Since a requires-expression is neither a control statement nor a function, I suppose it might eventually need its own `BraceWrapping` nested configuration flag. For now, I'd prefer if they never break.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79773/new/

https://reviews.llvm.org/D79773




From cfe-commits at lists.llvm.org  Wed Jul  8 00:34:29 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:34:29 +0000 (UTC)
Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for
 recovery expr.
In-Reply-To: 
References: 
Message-ID: <218e2d19c893eca1937ff17cb355a5eb@localhost.localdomain>

hokein updated this revision to Diff 276325.
hokein marked an inline comment as done.
hokein added a comment.

address comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83201/new/

https://reviews.llvm.org/D83201

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83201.276325.patch
Type: text/x-patch
Size: 4186 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 00:34:51 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:34:51 +0000 (UTC)
Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for
 recovery expr.
In-Reply-To: 
References: 
Message-ID: 

hokein added inline comments.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:12944
+      Fn->getBeginLoc(), RParenLoc, SubExprs,
+      ReturnType.isNull()
+          ? ReturnType
----------------
sammccall wrote:
> here we're splitting the type (e.g. int&&) into a type + VK, and passing both to createrecoveryexpr.
> 
> Why not do that on recoveryexpr side? e.g. if we request a recoveryexpr of type int&, return an LValue recoveryexpr of type int?
right, good idea, this is simpler. I was somehow taking `CallExpr` as a reference when writing this code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83201/new/

https://reviews.llvm.org/D83201




From cfe-commits at lists.llvm.org  Wed Jul  8 00:36:40 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:36:40 +0000 (UTC)
Subject: [PATCH] D83233: [clangd] Enable reading config from files by default.
In-Reply-To: 
References: 
Message-ID: 

hokein accepted this revision.
hokein added a comment.

looks like you didn't upload the latest version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83233/new/

https://reviews.llvm.org/D83233




From cfe-commits at lists.llvm.org  Wed Jul  8 00:51:55 2020
From: cfe-commits at lists.llvm.org (Sander de Smalen via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:51:55 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: 

sdesmalen added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:369
+  if (llvm::is_contained(Features, "+v8.6a")) {
+    if (!llvm::is_contained(Features, "-i8mm") &&
+        !llvm::is_contained(Features, "+noi8mm"))
----------------
Is this correct and/or necessary? I would expect LLVM to just handle features in the order they're passed, and the architecture version is always processed first, e.g. `-march=armv8.6-a+noi8mm` will always first process `armv8.6a` before processing features like `noi8mm`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079




From cfe-commits at lists.llvm.org  Wed Jul  8 00:52:05 2020
From: cfe-commits at lists.llvm.org (Nithin VR via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 07:52:05 +0000 (UTC)
Subject: [PATCH] D81315: [analyzer] Warning for default constructed unique
 pointer dereferences
In-Reply-To: 
References: 
Message-ID: <83b121d01b13ebd8ceef028d6d38c583@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG20e271a98de5: [analyzer] Warning for default constructed unique_ptr dereference (authored by vrnithinkumar).

Changed prior to commit:
  https://reviews.llvm.org/D81315?vs=275434&id=276327#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81315/new/

https://reviews.llvm.org/D81315

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/smart-ptr.cpp
  clang/test/Analysis/use-after-move.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81315.276327.patch
Type: text/x-patch
Size: 23709 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 00:52:05 2020
From: cfe-commits at lists.llvm.org (Nithin Vadukkumchery Rajendrakumar via cfe-commits)
Date: Wed, 08 Jul 2020 00:52:05 -0700 (PDT)
Subject: [clang] 20e271a - [analyzer] Warning for default constructed
 unique_ptr dereference
Message-ID: <5f057b25.1c69fb81.322bd.00de@mx.google.com>


Author: Nithin Vadukkumchery Rajendrakumar
Date: 2020-07-08T09:51:02+02:00
New Revision: 20e271a98de5609e22766e56f9c374b150f06982

URL: https://github.com/llvm/llvm-project/commit/20e271a98de5609e22766e56f9c374b150f06982
DIFF: https://github.com/llvm/llvm-project/commit/20e271a98de5609e22766e56f9c374b150f06982.diff

LOG: [analyzer] Warning for default constructed unique_ptr dereference

Summary: Add support for warning incase of default constructed unique pointer dereferences

Reviewed By: NoQ, Szelethus, vsavchenko, xazax.hun

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81315

Added: 
    clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
    clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp

Modified: 
    clang/docs/analyzer/checkers.rst
    clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
    clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
    clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
    clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
    clang/test/Analysis/Inputs/system-header-simulator-cxx.h
    clang/test/Analysis/analyzer-config.c
    clang/test/Analysis/smart-ptr.cpp
    clang/test/Analysis/use-after-move.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index d14bd2d68af9..1583da7aff09 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1836,6 +1836,19 @@ Check unreachable code.
    [x retain]; // warn
  }
 
+.. _alpha-cplusplus-SmartPtr:
+
+alpha.cplusplus.SmartPtr (C++)
+""""""""""""""""""""""""""""""
+Check for dereference of null smart pointers.
+
+.. code-block:: cpp
+
+ void deref_smart_ptr() {
+   std::unique_ptr P;
+   *P; // warn: dereference of a default constructed smart unique_ptr
+ }
+
 alpha.llvm
 ^^^^^^^^^^
 

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index dc1269890f93..cbd925400328 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -577,9 +577,17 @@ def CXXSelfAssignmentChecker : Checker<"SelfAssignment">,
   Documentation,
   Hidden;
 
-def SmartPtrModeling: Checker<"SmartPtr">,
+def SmartPtrModeling: Checker<"SmartPtrModeling">,
   HelpText<"Model behavior of C++ smart pointers">,
   Documentation,
+    CheckerOptions<[
+    CmdLineOption,
+  ]>,
   Hidden;
 
 def MoveChecker: Checker<"Move">,
@@ -736,6 +744,11 @@ def MismatchedIteratorChecker : Checker<"MismatchedIterator">,
   Dependencies<[IteratorModeling]>,
   Documentation;
 
+def SmartPtrChecker: Checker<"SmartPtr">,
+  HelpText<"Find the dereference of null SmrtPtr">,
+  Dependencies<[SmartPtrModeling]>,
+  Documentation;
+
 } // end: "alpha.cplusplus"
 
 

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
index a71469e90ea2..d75f9f63286d 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -788,6 +788,10 @@ class CXXMemberOperatorCall : public CXXInstanceCall {
     // to implicit this-parameter on the declaration.
     return CallArgumentIndex + 1;
   }
+
+  OverloadedOperatorKind getOverloadedOperator() const {
+    return getOriginExpr()->getOperator();
+  }
 };
 
 /// Represents an implicit call to a C++ destructor.

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 80cac237fc3b..9be1fdeb3ebf 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -98,6 +98,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   ReturnValueChecker.cpp
   RunLoopAutoreleaseLeakChecker.cpp
   SimpleStreamChecker.cpp
+  SmartPtrChecker.cpp
   SmartPtrModeling.cpp
   StackAddrEscapeChecker.cpp
   StdLibraryFunctionsChecker.cpp

diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h b/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
new file mode 100644
index 000000000000..89b8965e4c9a
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
@@ -0,0 +1,40 @@
+//=== SmartPtr.h - Tracking smart pointer state. -------------------*- C++ -*-//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines inter-checker API for the smart pointer modeling. It allows
+// dependent checkers to figure out if an smart pointer is null or not.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
+#define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+
+namespace clang {
+namespace ento {
+namespace smartptr {
+
+/// Set of STL smart pointer class which we are trying to model.
+const llvm::StringSet<> StdSmartPtrs = {
+    "shared_ptr",
+    "unique_ptr",
+    "weak_ptr",
+};
+
+/// Returns true if the event call is on smart pointer.
+bool isStdSmartPtrCall(const CallEvent &Call);
+
+/// Returns whether the smart pointer is null or not.
+bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion);
+
+} // namespace smartptr
+} // namespace ento
+} // namespace clang
+
+#endif // LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SMARTPTR_H

diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
new file mode 100644
index 000000000000..7bb25f397d01
--- /dev/null
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
@@ -0,0 +1,80 @@
+// SmartPtrChecker.cpp - Check for smart pointer dereference - C++ --------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines a checker that check for null dereference of C++ smart
+// pointer.
+//
+//===----------------------------------------------------------------------===//
+#include "SmartPtr.h"
+
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/AST/Type.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class SmartPtrChecker : public Checker {
+  BugType NullDereferenceBugType{this, "Null SmartPtr dereference",
+                                 "C++ Smart Pointer"};
+
+public:
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+
+private:
+  void reportBug(CheckerContext &C, const CallEvent &Call) const;
+};
+} // end of anonymous namespace
+
+void SmartPtrChecker::checkPreCall(const CallEvent &Call,
+                                   CheckerContext &C) const {
+  if (!smartptr::isStdSmartPtrCall(Call))
+    return;
+  ProgramStateRef State = C.getState();
+  const auto *OC = dyn_cast(&Call);
+  if (!OC)
+    return;
+  const MemRegion *ThisRegion = OC->getCXXThisVal().getAsRegion();
+  if (!ThisRegion)
+    return;
+
+  OverloadedOperatorKind OOK = OC->getOverloadedOperator();
+  if (OOK == OO_Star || OOK == OO_Arrow) {
+    if (smartptr::isNullSmartPtr(State, ThisRegion))
+      reportBug(C, Call);
+  }
+}
+
+void SmartPtrChecker::reportBug(CheckerContext &C,
+                                const CallEvent &Call) const {
+  ExplodedNode *ErrNode = C.generateErrorNode();
+  if (!ErrNode)
+    return;
+
+  auto R = std::make_unique(
+      NullDereferenceBugType, "Dereference of null smart pointer", ErrNode);
+  C.emitReport(std::move(R));
+}
+
+void ento::registerSmartPtrChecker(CheckerManager &Mgr) {
+  Mgr.registerChecker();
+}
+
+bool ento::shouldRegisterSmartPtrChecker(const CheckerManager &mgr) {
+  const LangOptions &LO = mgr.getLangOpts();
+  return LO.CPlusPlus;
+}

diff  --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
index 8250fd46b926..91f289078814 100644
--- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -12,27 +12,80 @@
 //===----------------------------------------------------------------------===//
 
 #include "Move.h"
+#include "SmartPtr.h"
 
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/Type.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
 
 using namespace clang;
 using namespace ento;
 
 namespace {
-class SmartPtrModeling : public Checker {
+class SmartPtrModeling : public Checker {
+
   bool isNullAfterMoveMethod(const CallEvent &Call) const;
 
 public:
+  // Whether the checker should model for null dereferences of smart pointers.
+  DefaultBool ModelSmartPtrDereference;
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+
+private:
+  ProgramStateRef updateTrackedRegion(const CallEvent &Call, CheckerContext &C,
+                                      const MemRegion *ThisValRegion) const;
+  void handleReset(const CallEvent &Call, CheckerContext &C) const;
+  void handleRelease(const CallEvent &Call, CheckerContext &C) const;
+  void handleSwap(const CallEvent &Call, CheckerContext &C) const;
+
+  using SmartPtrMethodHandlerFn =
+      void (SmartPtrModeling::*)(const CallEvent &Call, CheckerContext &) const;
+  CallDescriptionMap SmartPtrMethodHandlers{
+      {{"reset"}, &SmartPtrModeling::handleReset},
+      {{"release"}, &SmartPtrModeling::handleRelease},
+      {{"swap", 1}, &SmartPtrModeling::handleSwap}};
 };
 } // end of anonymous namespace
 
+REGISTER_MAP_WITH_PROGRAMSTATE(TrackedRegionMap, const MemRegion *, SVal)
+
+// Define the inter-checker API.
+namespace clang {
+namespace ento {
+namespace smartptr {
+bool isStdSmartPtrCall(const CallEvent &Call) {
+  const auto *MethodDecl = dyn_cast_or_null(Call.getDecl());
+  if (!MethodDecl || !MethodDecl->getParent())
+    return false;
+
+  const auto *RecordDecl = MethodDecl->getParent();
+  if (!RecordDecl || !RecordDecl->getDeclContext()->isStdNamespace())
+    return false;
+
+  if (RecordDecl->getDeclName().isIdentifier()) {
+    return smartptr::StdSmartPtrs.count(RecordDecl->getName().lower());
+  }
+  return false;
+}
+
+bool isNullSmartPtr(const ProgramStateRef State, const MemRegion *ThisRegion) {
+  const auto *InnerPointVal = State->get(ThisRegion);
+  return InnerPointVal && InnerPointVal->isZeroConstant();
+}
+} // namespace smartptr
+} // namespace ento
+} // namespace clang
+
 bool SmartPtrModeling::isNullAfterMoveMethod(const CallEvent &Call) const {
   // TODO: Update CallDescription to support anonymous calls?
   // TODO: Handle other methods, such as .get() or .release().
@@ -44,27 +97,133 @@ bool SmartPtrModeling::isNullAfterMoveMethod(const CallEvent &Call) const {
 
 bool SmartPtrModeling::evalCall(const CallEvent &Call,
                                 CheckerContext &C) const {
-  if (!isNullAfterMoveMethod(Call))
+
+  if (!smartptr::isStdSmartPtrCall(Call))
     return false;
 
-  ProgramStateRef State = C.getState();
-  const MemRegion *ThisR =
-      cast(&Call)->getCXXThisVal().getAsRegion();
+  if (isNullAfterMoveMethod(Call)) {
+    ProgramStateRef State = C.getState();
+    const MemRegion *ThisR =
+        cast(&Call)->getCXXThisVal().getAsRegion();
+
+    if (!move::isMovedFrom(State, ThisR)) {
+      // TODO: Model this case as well. At least, avoid invalidation of globals.
+      return false;
+    }
+
+    // TODO: Add a note to bug reports describing this decision.
+    C.addTransition(
+        State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
+                        C.getSValBuilder().makeZeroVal(Call.getResultType())));
+    return true;
+  }
 
-  if (!move::isMovedFrom(State, ThisR)) {
-    // TODO: Model this case as well. At least, avoid invalidation of globals.
+  if (!ModelSmartPtrDereference)
     return false;
+
+  if (const auto *CC = dyn_cast(&Call)) {
+    if (CC->getDecl()->isCopyOrMoveConstructor())
+      return false;
+
+    const MemRegion *ThisValRegion = CC->getCXXThisVal().getAsRegion();
+    if (!ThisValRegion)
+      return false;
+
+    auto State = updateTrackedRegion(Call, C, ThisValRegion);
+    C.addTransition(State);
+    return true;
+  }
+
+  const SmartPtrMethodHandlerFn *Handler = SmartPtrMethodHandlers.lookup(Call);
+  if (!Handler)
+    return false;
+  (this->**Handler)(Call, C);
+
+  return C.isDifferent();
+}
+
+void SmartPtrModeling::checkDeadSymbols(SymbolReaper &SymReaper,
+                                        CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+  // Clean up dead regions from the region map.
+  TrackedRegionMapTy TrackedRegions = State->get();
+  for (auto E : TrackedRegions) {
+    const MemRegion *Region = E.first;
+    bool IsRegDead = !SymReaper.isLiveRegion(Region);
+
+    if (IsRegDead)
+      State = State->remove(Region);
+  }
+  C.addTransition(State);
+}
+
+void SmartPtrModeling::handleReset(const CallEvent &Call,
+                                   CheckerContext &C) const {
+  const auto *IC = dyn_cast(&Call);
+  if (!IC)
+    return;
+
+  const MemRegion *ThisValRegion = IC->getCXXThisVal().getAsRegion();
+  if (!ThisValRegion)
+    return;
+  auto State = updateTrackedRegion(Call, C, ThisValRegion);
+  C.addTransition(State);
+  // TODO: Make sure to ivalidate the the region in the Store if we don't have
+  // time to model all methods.
+}
+
+void SmartPtrModeling::handleRelease(const CallEvent &Call,
+                                     CheckerContext &C) const {
+  const auto *IC = dyn_cast(&Call);
+  if (!IC)
+    return;
+
+  const MemRegion *ThisValRegion = IC->getCXXThisVal().getAsRegion();
+  if (!ThisValRegion)
+    return;
+
+  auto State = updateTrackedRegion(Call, C, ThisValRegion);
+
+  const auto *InnerPointVal = State->get(ThisValRegion);
+  if (InnerPointVal) {
+    State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
+                            *InnerPointVal);
+  }
+  C.addTransition(State);
+  // TODO: Add support to enable MallocChecker to start tracking the raw
+  // pointer.
+}
+
+void SmartPtrModeling::handleSwap(const CallEvent &Call,
+                                  CheckerContext &C) const {
+  // TODO: Add support to handle swap method.
+}
+
+ProgramStateRef
+SmartPtrModeling::updateTrackedRegion(const CallEvent &Call, CheckerContext &C,
+                                      const MemRegion *ThisValRegion) const {
+  // TODO: Refactor and clean up handling too many things.
+  ProgramStateRef State = C.getState();
+  auto NumArgs = Call.getNumArgs();
+
+  if (NumArgs == 0) {
+    auto NullSVal = C.getSValBuilder().makeNull();
+    State = State->set(ThisValRegion, NullSVal);
+  } else if (NumArgs == 1) {
+    auto ArgVal = Call.getArgSVal(0);
+    assert(Call.getArgExpr(0)->getType()->isPointerType() &&
+           "Adding a non pointer value to TrackedRegionMap");
+    State = State->set(ThisValRegion, ArgVal);
   }
 
-  // TODO: Add a note to bug reports describing this decision.
-  C.addTransition(
-      State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
-                      C.getSValBuilder().makeZeroVal(Call.getResultType())));
-  return true;
+  return State;
 }
 
 void ento::registerSmartPtrModeling(CheckerManager &Mgr) {
-  Mgr.registerChecker();
+  auto *Checker = Mgr.registerChecker();
+  Checker->ModelSmartPtrDereference =
+      Mgr.getAnalyzerOptions().getCheckerBooleanOption(
+          Checker, "ModelSmartPtrDereference");
 }
 
 bool ento::shouldRegisterSmartPtrModeling(const CheckerManager &mgr) {

diff  --git a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
index 4729b0439ad0..fe4b9d081e9c 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -946,10 +946,15 @@ namespace std {
   template  // TODO: Implement the stub for deleter.
   class unique_ptr {
   public:
+    unique_ptr() {}
+    unique_ptr(T *) {}
     unique_ptr(const unique_ptr &) = delete;
     unique_ptr(unique_ptr &&);
 
     T *get() const;
+    T *release() const;
+    void reset(T *p = nullptr) const;
+    void swap(unique_ptr &p) const;
 
     typename std::add_lvalue_reference::type operator*() const;
     T *operator->() const;

diff  --git a/clang/test/Analysis/analyzer-config.c b/clang/test/Analysis/analyzer-config.c
index 56c749cc45d8..7599cb052d44 100644
--- a/clang/test/Analysis/analyzer-config.c
+++ b/clang/test/Analysis/analyzer-config.c
@@ -40,6 +40,7 @@
 // CHECK-NEXT: core.CallAndMessage:ParameterCount = true
 // CHECK-NEXT: core.CallAndMessage:UndefReceiver = true
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
+// CHECK-NEXT: cplusplus.SmartPtrModeling:ModelSmartPtrDereference = false
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
 // CHECK-NEXT: ctu-import-threshold = 8

diff  --git a/clang/test/Analysis/smart-ptr.cpp b/clang/test/Analysis/smart-ptr.cpp
index ae6966b4e6f4..4ab7e2bbd3bf 100644
--- a/clang/test/Analysis/smart-ptr.cpp
+++ b/clang/test/Analysis/smart-ptr.cpp
@@ -1,16 +1,18 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection\
-// RUN:   -analyzer-checker cplusplus.Move,cplusplus.SmartPtr\
+// RUN:   -analyzer-checker cplusplus.Move,alpha.cplusplus.SmartPtr\
+// RUN:   -analyzer-config cplusplus.SmartPtrModeling:ModelSmartPtrDereference=true\
 // RUN:   -std=c++11 -verify %s
 
 #include "Inputs/system-header-simulator-cxx.h"
 
 void clang_analyzer_warnIfReached();
+void clang_analyzer_numTimesReached();
 
 void derefAfterMove(std::unique_ptr P) {
   std::unique_ptr Q = std::move(P);
   if (Q)
     clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
-  *Q.get() = 1; // no-warning
+  *Q.get() = 1;                     // no-warning
   if (P)
     clang_analyzer_warnIfReached(); // no-warning
   // TODO: Report a null dereference (instead).
@@ -26,3 +28,76 @@ void bar(S *s, void (S::*func)(void)) {
   (s->*func)(); // no-crash
 }
 } // namespace testUnknownCallee
+
+class A {
+public:
+  A(){};
+  void foo();
+};
+
+A *return_null() {
+  return nullptr;
+}
+
+void derefAfterValidCtr() {
+  std::unique_ptr P(new A());
+  P->foo(); // No warning.
+}
+
+void derefOfUnknown(std::unique_ptr P) {
+  P->foo(); // No warning.
+}
+
+void derefAfterDefaultCtr() {
+  std::unique_ptr P;
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNull() {
+  std::unique_ptr P(nullptr);
+  *P; // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefAfterCtrWithNullReturnMethod() {
+  std::unique_ptr P(return_null());
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefAfterRelease() {
+  std::unique_ptr P(new A());
+  P.release();
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefAfterReset() {
+  std::unique_ptr P(new A());
+  P.reset();
+  clang_analyzer_numTimesReached(); // expected-warning {{1}}
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNull() {
+  std::unique_ptr P(new A());
+  P.reset(nullptr);
+  P->foo(); // expected-warning {{Dereference of null smart pointer [alpha.cplusplus.SmartPtr]}}
+}
+
+void derefAfterResetWithNonNull() {
+  std::unique_ptr P;
+  P.reset(new A());
+  P->foo(); // No warning.
+}
+
+void derefAfterReleaseAndResetWithNonNull() {
+  std::unique_ptr P(new A());
+  P.release();
+  P.reset(new A());
+  P->foo(); // No warning.
+}
+
+void derefOnReleasedNullRawPtr() {
+  std::unique_ptr P;
+  A *AP = P.release();
+  AP->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+}

diff  --git a/clang/test/Analysis/use-after-move.cpp b/clang/test/Analysis/use-after-move.cpp
index c25f4393cdf9..d7b6c74fabd6 100644
--- a/clang/test/Analysis/use-after-move.cpp
+++ b/clang/test/Analysis/use-after-move.cpp
@@ -1,36 +1,36 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=All\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=All\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,aggressive
 
 // RUN: not %clang_analyze_cc1 -verify %s \
@@ -49,7 +49,7 @@
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=All -DAGGRESSIVE_DFS\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,aggressive %s 2>&1 | FileCheck %s
 
 #include "Inputs/system-header-simulator-cxx.h"


        

From cfe-commits at lists.llvm.org  Wed Jul  8 01:03:23 2020
From: cfe-commits at lists.llvm.org (Nithin VR via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 08:03:23 +0000 (UTC)
Subject: [PATCH] D81315: [analyzer] Warning for default constructed unique
 pointer dereferences
In-Reply-To: 
References: 
Message-ID: <9779d944d0f82ec8249e808a686ce80e@localhost.localdomain>

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20e271a98de5: [analyzer] Warning for default constructed unique_ptr dereference (authored by vrnithinkumar).

Changed prior to commit:
  https://reviews.llvm.org/D81315?vs=275434&id=275699#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81315/new/

https://reviews.llvm.org/D81315

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/smart-ptr.cpp
  clang/test/Analysis/use-after-move.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81315.275699.patch
Type: text/x-patch
Size: 23709 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 01:26:43 2020
From: cfe-commits at lists.llvm.org (Mikael Holmen via cfe-commits)
Date: Wed, 08 Jul 2020 01:26:43 -0700 (PDT)
Subject: [clang] cfcf8e1 - [analyzer] Silence gcc -Wparentheses warning [NFC]
Message-ID: <5f058343.1c69fb81.5c9fc.7c51@mx.google.com>


Author: Mikael Holmen
Date: 2020-07-08T10:23:59+02:00
New Revision: cfcf8e17ef537686e03c58921a10593a2b0c4a3d

URL: https://github.com/llvm/llvm-project/commit/cfcf8e17ef537686e03c58921a10593a2b0c4a3d
DIFF: https://github.com/llvm/llvm-project/commit/cfcf8e17ef537686e03c58921a10593a2b0c4a3d.diff

LOG: [analyzer] Silence gcc -Wparentheses warning [NFC]

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Core/BugReporter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 7df8dea56055..72be4e81c83d 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2145,12 +2145,12 @@ PathSensitiveBugReport::PathSensitiveBugReport(
          "*modeling*, not *diagnostics*.");
 
   assert(
-      bt.getCheckerName().startswith("debug") ||
-      !isHidden(ErrorNode->getState()
-                    ->getAnalysisManager()
-                    .getCheckerManager()
-                    ->getCheckerRegistryData(),
-                bt.getCheckerName()) &&
+      (bt.getCheckerName().startswith("debug") ||
+       !isHidden(ErrorNode->getState()
+                     ->getAnalysisManager()
+                     .getCheckerManager()
+                     ->getCheckerRegistryData(),
+                 bt.getCheckerName())) &&
           "Hidden checkers musn't emit diagnostics as they are by definition "
           "non-user facing!");
 }


        

From cfe-commits at lists.llvm.org  Wed Jul  8 01:29:55 2020
From: cfe-commits at lists.llvm.org (Petr Hosek via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 08:29:55 +0000 (UTC)
Subject: [PATCH] D80873: [clang][cmake] Force CMAKE_LINKER for multistage
 build in case of BOOTSTRAP_LLVM_ENABLE_LLD and MSVC
In-Reply-To: 
References: 
Message-ID: 

phosek added inline comments.


================
Comment at: clang/CMakeLists.txt:751
+  if(BOOTSTRAP_LLVM_ENABLE_LLD)
+    if(MSVC AND NOT BOOTSTRAP_CMAKE_SYSTEM_NAME)
+      set(${CLANG_STAGE}_LINKER -DCMAKE_LINKER=${LLVM_RUNTIME_OUTPUT_INTDIR}/lld-link.exe)
----------------
I don't understand the second part of this condition, can you elaborate? Why not set `CMAKE_LINKER` to `lld-link.exe` even if `BOOTSTRAP_CMAKE_SYSTEM_NAME STREQUAL "Windows"`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80873/new/

https://reviews.llvm.org/D80873




From cfe-commits at lists.llvm.org  Wed Jul  8 01:32:38 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 08:32:38 +0000 (UTC)
Subject: [PATCH] D83373: [analyzer][tests] Make test interruption safe
Message-ID: 

vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin, xazax.hun.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83373

Files:
  clang/utils/analyzer/SATest.py


Index: clang/utils/analyzer/SATest.py
===================================================================
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -132,27 +132,35 @@
         pass
 
     finally:
-        print("Please wait for docker to clean up")
-        call("docker stop satest", shell=True)
+        docker_cleanup()
 
 
 def docker_run(args, command, docker_args=""):
-    return call("docker run --rm --name satest "
-                "-v {llvm}:/llvm-project "
-                "-v {build}:/build "
-                "-v {clang}:/analyzer "
-                "-v {scripts}:/scripts "
-                "-v {projects}:/projects "
-                "{docker_args} "
-                "satest-image:latest {command}"
-                .format(llvm=args.llvm_project_dir,
-                        build=args.build_dir,
-                        clang=args.clang_dir,
-                        scripts=SCRIPTS_DIR,
-                        projects=PROJECTS_DIR,
-                        docker_args=docker_args,
-                        command=command),
-                shell=True)
+    try:
+        return call("docker run --rm --name satest "
+                    "-v {llvm}:/llvm-project "
+                    "-v {build}:/build "
+                    "-v {clang}:/analyzer "
+                    "-v {scripts}:/scripts "
+                    "-v {projects}:/projects "
+                    "{docker_args} "
+                    "satest-image:latest {command}"
+                    .format(llvm=args.llvm_project_dir,
+                            build=args.build_dir,
+                            clang=args.clang_dir,
+                            scripts=SCRIPTS_DIR,
+                            projects=PROJECTS_DIR,
+                            docker_args=docker_args,
+                            command=command),
+                    shell=True)
+
+    except KeyboardInterrupt:
+        docker_cleanup()
+
+
+def docker_cleanup():
+    print("Please wait for docker to clean up")
+    call("docker stop satest", shell=True)
 
 
 def main():


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83373.276337.patch
Type: text/x-patch
Size: 2087 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 01:43:08 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits)
Date: Wed, 08 Jul 2020 08:43:08 +0000 (UTC)
Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker
In-Reply-To: 
References: 
Message-ID: 

gamesh411 marked 7 inline comments as done.
gamesh411 added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:27
+    : public Checker> {
+  mutable std::unique_ptr BT;
+
----------------
balazske wrote:
> The bug type can be initialized here:
> `BT{this, "...", "..."}`
> How did this compile with only one text argument to constructor? I think the first is a short name of the bug, second is a category that is not omittable. The text that is used here should be passed to the `BugReport`. `BugType::getDescription` returns the "name" of the bug that is the first argument. But I am not sure what matters from these texts, the code design looks confusing.
I think because it is initialized with a `BuiltinBug`, which must be a subclass of BugType. I don't really know what should be preferable nowadays, as this code was actually written more than a year ago. Thanks for pointing out that it can be initialized there, I think lazy initialization seems not that important with this particular checker.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:50
+  if (isa(Index->IgnoreParenCasts()))
+    return;
+
----------------
balazske wrote:
> `if (isa(Index))` should be used. `IntegerLiteral` is a subclass of `Expr`, not a `QualType`.
The way I have structured the code is very misleading, sorry for that, I will move the type extraction if lower, where it is actually used.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:72
+      llvm::APSInt::getMaxValue(C.getASTContext().getIntWidth(IndexType),
+                                IndexType->isUnsignedIntegerType());
+  const nonloc::ConcreteInt MaxIndexValue{MaxIndex};
----------------
balazske wrote:
> I would use `SVB.getBasicValueFactory().getMaxValue(IndexType)` to get the max value.
Good point, thanks for pointing out such a method existed in `BasicValueFactory`!


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:82
+      SVB.evalBinOp(State, BO_Sub, SizeInElements, ConstantOne,
+                    C.getASTContext().UnsignedLongLongTy);
+
----------------
balazske wrote:
> `SValBuilder::getArrayIndexType` should be better than the `UnsignedLongLongTy`.
Seems reasonable :)


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:86
+  const SVal TypeCanIndexEveryElement = SVB.evalBinOp(
+      State, BO_LE, SizeInElementsMinusOne, MaxIndexValue, IndexType);
+
----------------
balazske wrote:
> I think `SVB.getConditionType()` should be used for condition result.
I will use that, thanks.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:121
+  // Mark the array expression interesting.
+  R->markInteresting(FirstElement->getSuperRegion());
+  C.emitReport(std::move(R));
----------------
balazske wrote:
> I am not sure if this `markInteresting` call is correct. 
What I wanted to do conceptually is to mark the array itself interesting. I am however not sure whether this is the best way. I will try this and `FirstElement` itself and maybe look at whether there are some additional notes emitted along the way.


================
Comment at: clang/test/Analysis/sufficient-size-array-indexing-32bit.c:37
+const short two_byte_signed_index = 1; // sizeof(short) == 2
+const int four_byte_signed_index = 1;  // sizeof(int) == 4
+
----------------
balazske wrote:
> I do not know if it is safe to make such assumptions about `sizeof`.
You are definitely right! However it is common as per:
https://en.cppreference.com/w/cpp/language/types#Data_models
```
Data models

The choices made by each implementation about the sizes of the fundamental types are collectively known as data model. Four data models found wide acceptance:

32 bit systems:

        LP32 or 2/4/4 (int is 16-bit, long and pointer are 32-bit) 

            Win16 API 

        ILP32 or 4/4/4 (int, long, and pointer are 32-bit); 

            Win32 API
            Unix and Unix-like systems (Linux, macOS) 

64 bit systems:

        LLP64 or 4/4/8 (int and long are 32-bit, pointer is 64-bit) 

            Win64 API 

        LP64 or 4/8/8 (int is 32-bit, long and pointer are 64-bit) 

            Unix and Unix-like systems (Linux, macOS) 

Other models are very rare. For example, ILP64 (8/8/8: int, long, and pointer are 64-bit) only appeared in some early 64-bit Unix systems (e.g. Unicos on Cray). 
```
Only ILP32 has 16 bit ints.
Next idea would be to use fixed-width integer types from `cstdint`. But tests should not use system headers, and there are mentions in test files to `int32_t`, howevery they are just typedefs for int. And I think we maintaining a whole standard library headers is a bit too much a hassle.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69318/new/

https://reviews.llvm.org/D69318




From cfe-commits at lists.llvm.org  Wed Jul  8 01:53:27 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 08:53:27 +0000 (UTC)
Subject: [PATCH] D83374: [analyzer][tests] Fix zip unpacking
Message-ID: 

vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83374

Files:
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===================================================================
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -601,7 +601,7 @@
                    stdout=build_log_file, shell=True)
 
     def _unpack_zip(self, directory: str, build_log_file: IO):
-        zip_files = list(glob.glob(os.path.join(directory, "/*.zip")))
+        zip_files = list(glob.glob(directory + "/*.zip"))
 
         if len(zip_files) == 0:
             raise ValueError(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83374.276341.patch
Type: text/x-patch
Size: 529 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 02:08:18 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 09:08:18 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: 

eduucaldas updated this revision to Diff 276344.
eduucaldas marked 4 inline comments as done.
eduucaldas added a comment.

answering minor comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82954.276344.patch
Type: text/x-patch
Size: 9833 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 02:08:29 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 09:08:29 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: <54082135eade5a2e2ad665a19795e814@localhost.localdomain>

eduucaldas added inline comments.


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2192
       R"cpp(
+class osstream {};
 struct X {
----------------
gribozavr2 wrote:
> I don't think we need a separate class to show the left shift operator. The declaration below can be:
> 
> ```
>   friend X operator<<(X&, const X&);
> ```
If we don't bother much about "realistic" operator declarations we could drop all the `friend` and declare every operator in their most concise form. WDYT


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954




From cfe-commits at lists.llvm.org  Wed Jul  8 02:19:08 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits)
Date: Wed, 08 Jul 2020 09:19:08 +0000 (UTC)
Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker
In-Reply-To: 
References: 
Message-ID: 

gamesh411 updated this revision to Diff 276346.
gamesh411 added a comment.

apply review suggestions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69318/new/

https://reviews.llvm.org/D69318

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp
  clang/test/Analysis/sufficient-size-array-indexing-32bit.c
  clang/test/Analysis/sufficient-size-array-indexing-64bit.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69318.276346.patch
Type: text/x-patch
Size: 21522 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 02:35:36 2020
From: cfe-commits at lists.llvm.org (Vaibhav Garg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 09:35:36 +0000 (UTC)
Subject: [PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr
 attribute
In-Reply-To: 
References: 
Message-ID: 

gargvaibhav64 updated this revision to Diff 276351.
gargvaibhav64 edited the summary of this revision.
gargvaibhav64 added a comment.

I incorporated the changes


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83174/new/

https://reviews.llvm.org/D83174

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/inherit-attribute/a.h
  clang/test/Modules/Inputs/inherit-attribute/b.h
  clang/test/Modules/Inputs/inherit-attribute/c.h
  clang/test/Modules/Inputs/inherit-attribute/module.modulemap
  clang/test/Modules/inherit-attribute.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83174.276351.patch
Type: text/x-patch
Size: 3517 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 03:14:44 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 10:14:44 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: <4abc56ffe41a97b9dff5399e89107219@localhost.localdomain>

gribozavr2 added inline comments.


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2192
       R"cpp(
+class osstream {};
 struct X {
----------------
eduucaldas wrote:
> gribozavr2 wrote:
> > I don't think we need a separate class to show the left shift operator. The declaration below can be:
> > 
> > ```
> >   friend X operator<<(X&, const X&);
> > ```
> If we don't bother much about "realistic" operator declarations we could drop all the `friend` and declare every operator in their most concise form. WDYT
I think we shouldn't try to make tests realistic in terms of function names etc., but we should try to cover as many different AST shapes as possible. In the case of binary operators, we have three cases -- free function, friend function, member function, that all generate slightly different ASTs, so I believe we should try to cover them all.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954




From cfe-commits at lists.llvm.org  Wed Jul  8 03:18:02 2020
From: cfe-commits at lists.llvm.org (Alex Richardson via cfe-commits)
Date: Wed, 08 Jul 2020 03:18:02 -0700 (PDT)
Subject: [clang] a80afc0 - [UpdateTestChecks] Add UTC_ARGS support for
 update_{llc,cc}_test_checks.py
Message-ID: <5f059d5a.1c69fb81.dfb46.c835@mx.google.com>


Author: Alex Richardson
Date: 2020-07-08T11:00:10+01:00
New Revision: a80afc032859ebe65af283f76b38a0f5921b683f

URL: https://github.com/llvm/llvm-project/commit/a80afc032859ebe65af283f76b38a0f5921b683f
DIFF: https://github.com/llvm/llvm-project/commit/a80afc032859ebe65af283f76b38a0f5921b683f.diff

LOG: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

https://reviews.llvm.org/D69701 added support for on-the-fly argument
changes for update scripts. I recently wanted to keep some manual check
lines in a test generated by update_cc_test_checks.py in our CHERI fork, so
this commit adds support for UTC_ARGS in update_cc_test_checks.py. And since
I was refactoring the code to be in common.py, I also added it for
update_llc_test_checks.py.

Reviewed By: jdoerfert, MaskRay
Differential Revision: https://reviews.llvm.org/D78478

Added: 
    clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
    clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
    clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test

Modified: 
    clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
    clang/test/utils/update_cc_test_checks/mangled_names.test
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
    llvm/utils/update_cc_test_checks.py
    llvm/utils/update_llc_test_checks.py

Removed: 
    


################################################################################
diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
index 005b2f242747..e76cf074bdb7 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature
 // Example input for update_cc_test_checks
 // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
 

diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c b/clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
new file mode 100644
index 000000000000..8956e6b52a21
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+int checks_please() {
+  return 1;
+}
+
+// UTC_ARGS: --disable
+
+int no_checks_please() {
+  // Manual CHECK line should be retained:
+  // CHECK: manual check line
+  return -1;
+}
+
+// UTC_ARGS: --enable
+
+
+int checks_again() {
+  return 2;
+}

diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected b/clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
new file mode 100644
index 000000000000..cb7846c7b3d5
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
@@ -0,0 +1,29 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @checks_please(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    ret i32 1
+//
+int checks_please() {
+  return 1;
+}
+
+// UTC_ARGS: --disable
+
+int no_checks_please() {
+  // Manual CHECK line should be retained:
+  // CHECK: manual check line
+  return -1;
+}
+
+// UTC_ARGS: --enable
+
+
+// CHECK-LABEL: @checks_again(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    ret i32 2
+//
+int checks_again() {
+  return 2;
+}

diff  --git a/clang/test/utils/update_cc_test_checks/mangled_names.test b/clang/test/utils/update_cc_test_checks/mangled_names.test
index 082ed74304f0..bc88c9b5a382 100644
--- a/clang/test/utils/update_cc_test_checks/mangled_names.test
+++ b/clang/test/utils/update_cc_test_checks/mangled_names.test
@@ -8,6 +8,11 @@
 ## Also try the --function-signature flag
 # RUN: %update_cc_test_checks %t.c --function-signature
 # RUN: 
diff  -u %t.c %S/Inputs/mangled_names.c.funcsig.expected
-## Verify that running without the --function-signature flag removes the -SAME: lines:
+## Running it again should implicitly add the function-signature flag due to UTC_ARGS:
 # RUN: %update_cc_test_checks %t.c
-# RUN: 
diff  -u %t.c %S/Inputs/mangled_names.c.expected
+# RUN: 
diff  -u %t.c %S/Inputs/mangled_names.c.funcsig.expected
+## Verify that running without the --function-signature flag removes the -SAME: lines:
+## We have to remove the UTC_ARGS comment first:
+# RUN: grep -v UTC_ARGS %t.c > %t-no-args.c
+# RUN: %update_cc_test_checks %t-no-args.c
+# RUN: 
diff  -u %t-no-args.c %S/Inputs/mangled_names.c.expected

diff  --git a/clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test b/clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
new file mode 100644
index 000000000000..629b01f9d066
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
@@ -0,0 +1,6 @@
+# RUN: cp -f %S/Inputs/on_the_fly_arg_change.c %t.c
+# RUN: %update_cc_test_checks %t.c
+# RUN: 
diff  -u %t.c %S/Inputs/on_the_fly_arg_change.c.expected
+## Check that running the script again does not change the result:
+# RUN: %update_cc_test_checks %t.c
+# RUN: 
diff  -u %t.c %S/Inputs/on_the_fly_arg_change.c.expected

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
index 96b06de79c93..3c49f489a353 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
@@ -1,4 +1,3 @@
-; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; Example input for update_llc_test_checks (taken from CodeGen/X86/iabs.ll)
 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86 --check-prefix=X86-NO-CMOV
 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-CMOV

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
new file mode 100644
index 000000000000..ed5d949bb092
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
@@ -0,0 +1,22 @@
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s
+
+declare void @foo()
+
+define i64 @check_lines_1() {
+  ret i64 1
+}
+
+; UTC_ARGS: --disable
+
+define i64 @no_check_lines() {
+; A check line that would not be auto-generated (should not be removed!).
+; CHECK: manual check line
+  ret i64 2
+}
+
+; UTC_ARGS: --enable --no_x86_scrub_rip
+
+define i64 @check_lines_2() {
+  %result = call i64 @no_check_lines()
+  ret i64 %result
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
new file mode 100644
index 000000000000..f1955c4af252
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s
+
+declare void @foo()
+
+define i64 @check_lines_1() {
+; CHECK-LABEL: check_lines_1:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movl $1, %eax
+; CHECK-NEXT:    xorl %edx, %edx
+; CHECK-NEXT:    retl
+  ret i64 1
+}
+
+; UTC_ARGS: --disable
+
+define i64 @no_check_lines() {
+; A check line that would not be auto-generated (should not be removed!).
+; CHECK: manual check line
+  ret i64 2
+}
+
+; UTC_ARGS: --enable --no_x86_scrub_rip
+
+define i64 @check_lines_2() {
+; CHECK-LABEL: check_lines_2:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    calll no_check_lines
+; CHECK-NEXT:    retl
+  %result = call i64 @no_check_lines()
+  ret i64 %result
+}

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
index 74c2b6cd70ed..36d0f5d9ff7e 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
@@ -2,14 +2,24 @@
 ## Basic test checking that update_llc_test_checks.py can update a file with multiple check prefixes
 
 # RUN: cp -f %S/Inputs/basic.ll %t.ll && %update_llc_test_checks %t.ll
-# RUN: 
diff  -u %S/Inputs/basic.ll.expected %t.ll
-## The flags --x86_scrub_rip and --extra_scrub should have any effect for this
+# RUN: echo '; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py' > %t.expected.ll
+# RUN: cat %S/Inputs/basic.ll.expected >> %t.expected.ll
+# RUN: 
diff  -u %t.expected.ll %t.ll
+
+## The flags --x86_scrub_rip and --extra_scrub should not have any effect on this
 ## test. Check the output is identical.
-# RUN: cp -f %S/Inputs/basic.ll %t.ll &&  %update_llc_test_checks --extra_scrub %t.ll
-# RUN: 
diff  -u %S/Inputs/basic.ll.expected %t.ll
-# RUN: cp -f %S/Inputs/basic.ll %t.ll &&  %update_llc_test_checks --x86_scrub_rip %t.ll
-# RUN: 
diff  -u %S/Inputs/basic.ll.expected %t.ll
+# RUN: cp -f %S/Inputs/basic.ll %t.ll && %update_llc_test_checks --extra_scrub %t.ll
+# RUN: echo '; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --extra_scrub' > %t.expected.ll
+# RUN: cat %S/Inputs/basic.ll.expected >> %t.expected.ll
+# RUN: 
diff  -u %t.expected.ll %t.ll
+# RUN: cp -f %S/Inputs/basic.ll %t.ll && %update_llc_test_checks --no_x86_scrub_rip %t.ll
+# RUN: echo '; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no_x86_scrub_rip' > %t.expected.ll
+# RUN: cat %S/Inputs/basic.ll.expected >> %t.expected.ll
+# RUN: 
diff  -u %t.expected.ll %t.ll
+
 ## Finally, run the script on an already updated file and verify that all previous
 ## CHECK lines are removed.
 # RUN: %update_llc_test_checks %t.ll
-# RUN: 
diff  -u %S/Inputs/basic.ll.expected %t.ll
+# RUN: echo '; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --no_x86_scrub_rip' > %t.expected.ll
+# RUN: cat %S/Inputs/basic.ll.expected >> %t.expected.ll
+# RUN: 
diff  -u %t.expected.ll %t.ll

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
new file mode 100644
index 000000000000..ec85fd7cb7ef
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
@@ -0,0 +1,6 @@
+# RUN: cp -f %S/Inputs/on_the_fly_arg_change.ll %t.ll
+# RUN: %update_llc_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/on_the_fly_arg_change.ll.expected
+## Check that running the script again does not change the result:
+# RUN: %update_llc_test_checks %t.ll
+# RUN: 
diff  -u %t.ll %S/Inputs/on_the_fly_arg_change.ll.expected

diff  --git a/llvm/utils/update_cc_test_checks.py b/llvm/utils/update_cc_test_checks.py
index 7c69ff339cfb..5851f19e3d2d 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -19,16 +19,13 @@
 import distutils.spawn
 import json
 import os
+import re
 import shlex
-import string
 import subprocess
 import sys
-import re
 import tempfile
 
-from UpdateTestChecks import asm, common
-
-ADVERT = '// NOTE: Assertions have been autogenerated by '
+from UpdateTestChecks import common
 
 SUBST = {
     '%clang': [],
@@ -110,6 +107,11 @@ def parse_clang_ast_json(node):
   return ret
 
 
+def str_to_commandline(value):
+  if not value:
+    return []
+  return shlex.split(value)
+
 def config():
   parser = argparse.ArgumentParser(
       description=__doc__,
@@ -117,7 +119,7 @@ def config():
   parser.add_argument('--llvm-bin', help='llvm $prefix/bin path')
   parser.add_argument('--clang',
                       help='"clang" executable, defaults to $llvm_bin/clang')
-  parser.add_argument('--clang-args',
+  parser.add_argument('--clang-args', default=[], type=str_to_commandline,
                       help='Space-separated extra args to clang, e.g. --clang-args=-v')
   parser.add_argument('--opt',
                       help='"opt" executable, defaults to $llvm_bin/opt')
@@ -131,7 +133,6 @@ def config():
                       help='Keep function signature information around for the check line')
   parser.add_argument('tests', nargs='+')
   args = common.parse_commandline_args(parser)
-  args.clang_args = shlex.split(args.clang_args or '')
 
   if args.clang is None:
     if args.llvm_bin is None:
@@ -165,7 +166,7 @@ def config():
     # defer this error message until we find that opt is actually needed.
     args.opt = None
 
-  return args
+  return args, parser
 
 
 def get_function_body(args, filename, clang_args, extra_commands, prefixes, triple_in_cmd, func_dict):
@@ -196,31 +197,15 @@ def get_function_body(args, filename, clang_args, extra_commands, prefixes, trip
 
 
 def main():
-  args = config()
+  initial_args, parser = config()
   script_name = os.path.basename(__file__)
-  autogenerated_note = (ADVERT + 'utils/' + script_name)
-
-  for filename in args.tests:
-    with open(filename) as f:
-      input_lines = [l.rstrip() for l in f]
-
-    first_line = input_lines[0] if input_lines else ""
-    if 'autogenerated' in first_line and script_name not in first_line:
-      common.warn("Skipping test which wasn't autogenerated by " + script_name, filename)
-      continue
-
-    if args.update_only:
-      if not first_line or 'autogenerated' not in first_line:
-        common.warn("Skipping test which isn't autogenerated: " + filename)
-        continue
-
-    # Extract RUN lines.
-    run_lines = common.find_run_lines(filename, input_lines)
 
+  for ti in common.itertests(initial_args.tests, parser, 'utils/' + script_name,
+                             comment_prefix='//'):
     # Build a list of clang command lines and check prefixes from RUN lines.
     run_list = []
     line2spell_and_mangled_list = collections.defaultdict(list)
-    for l in run_lines:
+    for l in ti.run_lines:
       commands = [cmd.strip() for cmd in l.split('|')]
 
       triple_in_cmd = None
@@ -234,7 +219,7 @@ def main():
         print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
         continue
       clang_args[0:1] = SUBST[clang_args[0]]
-      clang_args = [filename if i == '%s' else i for i in clang_args] + args.clang_args
+      clang_args = [ti.path if i == '%s' else i for i in clang_args] + ti.args.clang_args
 
       # Permit piping the output through opt
       if not (len(commands) == 2 or
@@ -253,18 +238,6 @@ def main():
         check_prefixes = ['CHECK']
       run_list.append((check_prefixes, clang_args, commands[1:-1], triple_in_cmd))
 
-    # Strip CHECK lines which are in `prefix_set`, update test file.
-    prefix_set = set([prefix for p in run_list for prefix in p[0]])
-    input_lines = []
-    with open(filename, 'r+') as f:
-      for line in f:
-        m = common.CHECK_RE.match(line)
-        if not (m and m.group(1) in prefix_set) and line != '//\n':
-          input_lines.append(line)
-      f.seek(0)
-      f.writelines(input_lines)
-      f.truncate()
-
     # Execute clang, generate LLVM IR, and extract functions.
     func_dict = {}
     for p in run_list:
@@ -275,18 +248,23 @@ def main():
       common.debug('Extracted clang cmd: clang {}'.format(clang_args))
       common.debug('Extracted FileCheck prefixes: {}'.format(prefixes))
 
-      get_function_body(args, filename, clang_args, extra_commands, prefixes, triple_in_cmd, func_dict)
+      get_function_body(ti.args, ti.path, clang_args, extra_commands, prefixes, triple_in_cmd, func_dict)
 
       # Invoke clang -Xclang -ast-dump=json to get mapping from start lines to
       # mangled names. Forward all clang args for now.
-      for k, v in get_line2spell_and_mangled(args, clang_args).items():
+      for k, v in get_line2spell_and_mangled(ti.args, clang_args).items():
         line2spell_and_mangled_list[k].append(v)
 
-    output_lines = [autogenerated_note]
-    for idx, line in enumerate(input_lines):
-      # Discard any previous script advertising.
-      if line.startswith(ADVERT):
-        continue
+    prefix_set = set([prefix for p in run_list for prefix in p[0]])
+    output_lines = []
+    for line_info in ti.iterlines(output_lines):
+      idx = line_info.line_number
+      line = line_info.line
+      args = line_info.args
+      include_line = True
+      m = common.CHECK_RE.match(line)
+      if m and m.group(1) in prefix_set:
+        continue  # Don't append the existing CHECK lines
       if idx in line2spell_and_mangled_list:
         added = set()
         for spell, mangled in line2spell_and_mangled_list[idx]:
@@ -298,16 +276,25 @@ def main():
           if mangled in added or spell not in line:
             continue
           if args.functions is None or any(re.search(regex, spell) for regex in args.functions):
+            last_line = output_lines[-1].strip()
+            while last_line == '//':
+              # Remove the comment line since we will generate a new  comment
+              # line as part of common.add_ir_checks()
+              output_lines.pop()
+              last_line = output_lines[-1].strip()
             if added:
               output_lines.append('//')
             added.add(mangled)
             common.add_ir_checks(output_lines, '//', run_list, func_dict, mangled,
                                  False, args.function_signature)
-      output_lines.append(line.rstrip('\n'))
+            if line.rstrip('\n') == '//':
+              include_line = False
 
+      if include_line:
+        output_lines.append(line.rstrip('\n'))
 
-    common.debug('Writing %d lines to %s...' % (len(output_lines), filename))
-    with open(filename, 'wb') as f:
+    common.debug('Writing %d lines to %s...' % (len(output_lines), ti.path))
+    with open(ti.path, 'wb') as f:
       f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
   return 0

diff  --git a/llvm/utils/update_llc_test_checks.py b/llvm/utils/update_llc_test_checks.py
index d873c60187b7..05fca340760e 100755
--- a/llvm/utils/update_llc_test_checks.py
+++ b/llvm/utils/update_llc_test_checks.py
@@ -10,19 +10,13 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import os         # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import re
+import os  # Used to advertise this file's name ("autogenerated_note").
 
 from UpdateTestChecks import asm, common
 
-ADVERT = ' NOTE: Assertions have been autogenerated by '
 # llc is the only llc-like in the LLVM tree but downstream forks can add
 # additional ones here if they have them.
-LLC_LIKE_TOOLS = ('llc',) 
+LLC_LIKE_TOOLS = ('llc',)
 
 def main():
   parser = argparse.ArgumentParser(description=__doc__)
@@ -42,35 +36,21 @@ def main():
       '--no_x86_scrub_mem_shuffle', action='store_true', default=False,
       help='Reduce scrubbing shuffles with memory operands')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
 
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-    with open(test) as f:
-      input_lines = [l.rstrip() for l in f]
-
-    first_line = input_lines[0] if input_lines else ""
-    if 'autogenerated' in first_line and script_name not in first_line:
-      common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-      continue
-
-    if args.update_only:
-      if not first_line or 'autogenerated' not in first_line:
-        common.warn("Skipping test which isn't autogenerated: " + test)
-        continue
-
+  for ti in common.itertests(initial_args.tests, parser,
+                             script_name='utils/' + script_name):
     triple_in_ir = None
-    for l in input_lines:
+    for l in ti.input_lines:
       m = common.TRIPLE_IR_RE.match(l)
       if m:
         triple_in_ir = m.groups()[0]
         break
 
-    run_lines = common.find_run_lines(test, input_lines)
     run_list = []
-    for l in run_lines:
+    for l in ti.run_lines:
       if '|' not in l:
         common.warn('Skipping unparseable RUN line: ' + l)
         continue
@@ -103,7 +83,7 @@ def main():
 
       llc_cmd_args = llc_cmd[len(llc_tool):].strip()
       llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
-      if test.endswith('.mir'):
+      if ti.path.endswith('.mir'):
         llc_cmd_args += ' -x mir'
       check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
                                for item in m.group(1).split(',')]
@@ -114,13 +94,10 @@ def main():
       # now, we just ignore all but the last.
       run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
 
-    if test.endswith('.mir'):
-      comment_sym = '#'
+    if ti.path.endswith('.mir'):
       check_indent = '  '
     else:
-      comment_sym = ';'
       check_indent = ''
-    autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
 
     func_dict = {}
     for p in run_list:
@@ -131,13 +108,12 @@ def main():
       common.debug('Extracted LLC cmd:', llc_tool, llc_args)
       common.debug('Extracted FileCheck prefixes:', str(prefixes))
 
-      raw_tool_output = common.invoke_tool(args.llc_binary or llc_tool,
-                                           llc_args, test)
+      raw_tool_output = common.invoke_tool(ti.args.llc_binary or llc_tool, llc_args, ti.path)
       triple = triple_in_cmd or triple_in_ir
       if not triple:
         triple = asm.get_triple_from_march(march_in_cmd)
 
-      asm.build_function_body_dictionary_for_triple(args, raw_tool_output,
+      asm.build_function_body_dictionary_for_triple(ti.args, raw_tool_output,
           triple, prefixes, func_dict)
 
     is_in_function = False
@@ -146,9 +122,9 @@ def main():
     prefix_set = set([prefix for p in run_list for prefix in p[0]])
     common.debug('Rewriting FileCheck prefixes:', str(prefix_set))
     output_lines = []
-    output_lines.append(autogenerated_note)
-
-    for input_line in input_lines:
+    for input_info in ti.iterlines(output_lines):
+      input_line = input_info.line
+      args = input_info.args
       if is_in_function_start:
         if input_line == '':
           continue
@@ -172,10 +148,6 @@ def main():
           is_in_function = False
         continue
 
-      # Discard any previous script advertising.
-      if input_line.startswith(comment_sym + ADVERT):
-        continue
-
       # If it's outside a function, it just gets copied to the output.
       output_lines.append(input_line)
 
@@ -188,9 +160,9 @@ def main():
         continue
       is_in_function = is_in_function_start = True
 
-    common.debug('Writing %d lines to %s...' % (len(output_lines), test))
+    common.debug('Writing %d lines to %s...' % (len(output_lines), ti.path))
 
-    with open(test, 'wb') as f:
+    with open(ti.path, 'wb') as f:
       f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines])
 
 


        

From cfe-commits at lists.llvm.org  Wed Jul  8 03:18:13 2020
From: cfe-commits at lists.llvm.org (Alexander Richardson via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 10:18:13 +0000 (UTC)
Subject: [PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for
 update_{llc,cc}_test_checks.py
In-Reply-To: 
References: 
Message-ID: <7d951ca1e1ee9c1dd1b821c0275ebaa2@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rGa80afc032859: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78478.276359.patch
Type: text/x-patch
Size: 21233 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 03:22:07 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 10:22:07 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: 

eduucaldas updated this revision to Diff 276361.
eduucaldas added a comment.

Reflect fix on RecursiveASTVisitor


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276361.patch
Type: text/x-patch
Size: 5353 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 03:30:28 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 10:30:28 +0000 (UTC)
Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for
 recovery expr.
In-Reply-To: 
References: 
Message-ID: <82018b515855b847dd0a3d91e7008d2c@localhost.localdomain>

sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/AST/ExprClassification.cpp:147
 
+  case Expr::RecoveryExprClass:
+    return ClassifyExprValueKind(Lang, E, E->getValueKind());
----------------
there's a block of cases with a similar implementation (near OpaqueValueKind), maybe move there


================
Comment at: clang/lib/Sema/SemaOverload.cpp:12944
+      Fn->getBeginLoc(), RParenLoc, SubExprs,
+      ReturnType.isNull()
+          ? ReturnType
----------------
hokein wrote:
> sammccall wrote:
> > here we're splitting the type (e.g. int&&) into a type + VK, and passing both to createrecoveryexpr.
> > 
> > Why not do that on recoveryexpr side? e.g. if we request a recoveryexpr of type int&, return an LValue recoveryexpr of type int?
> right, good idea, this is simpler. I was somehow taking `CallExpr` as a reference when writing this code.
Hmm, this does seem simpler to me but it also seems that a few places deliberately make this mapping between two related concepts explicit.
Maybe we should at least have a comment on createrecoveryexpr that the value category will be inferred from the (reference) type.


================
Comment at: clang/test/SemaCXX/recovery-expr-type.cpp:66
+
+namespace test4 {
+int &&f(int);  // expected-note {{candidate function not viable}}
----------------
I liked the comment explaining the purpose of the test (no crash for wrong value category)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83201/new/

https://reviews.llvm.org/D83201




From cfe-commits at lists.llvm.org  Wed Jul  8 03:47:10 2020
From: cfe-commits at lists.llvm.org (Alexander Richardson via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 10:47:10 +0000 (UTC)
Subject: [PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for
 update_{llc,cc}_test_checks.py
In-Reply-To: 
References: 
Message-ID: <25d5c74becc54713c4b420e4fc1ab59b@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rGa80afc032859: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78478/new/

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78478.275705.patch
Type: text/x-patch
Size: 21233 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 04:12:33 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:12:33 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <325f742c5f8f232015f94a94543446eb@localhost.localdomain>

kbobyrev updated this revision to Diff 276366.
kbobyrev marked 12 inline comments as done.
kbobyrev added a comment.

Store progress. Still WIP.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276366.patch
Type: text/x-patch
Size: 28814 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 04:21:07 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:21:07 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <69850a900517c11b70bad72189854f43@localhost.localdomain>

kbobyrev marked 2 inline comments as done.
kbobyrev added inline comments.


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:25
 
+const char *unittestURIToFilesystem(const char *UnittestURI,
+                                    llvm::UniqueStringSaver &Strings) {
----------------
sammccall wrote:
> The File scheme is special. Using a different URI scheme here when we only support `file` in production is confusing and seems like a last resort to be used when we can't make it work any other way.
> (For example we use it in lit tests because we must specify input filenames and the presence/absence of drive letters caused problems)
> What's being solved there that the much smaller hammer of testPath() plus a local testPathURI() helper can't solve?
This is dealing with the consequences of test infrastructure being set up in a way that makes all URIs in Symbols and Refs use "unittest" scheme, this helper simply translates those URIs into "file" URIs which are the ones being supported in production. I can not understand why this is not desirable but I'll just clear all URIs and leave those two tests as sanity checks.


================
Comment at: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp:130
+  EXPECT_EQ(Serialized.location().file_path(), RelativePath);
+  // Local index prefix should have UNIX slashes since the relative path in
+  // Protobuf message will.
----------------
sammccall wrote:
> hmm, I don't think that's the reason.
> Either that's the contract of fromProtobuf, or it's not required and we shouldn't do it.
Ah, `llvm::sys::path::append` already does that for me. Okay, makes sense to remove this then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938




From cfe-commits at lists.llvm.org  Wed Jul  8 04:27:27 2020
From: cfe-commits at lists.llvm.org (Ole Strohm via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:27:27 +0000 (UTC)
Subject: [PATCH] D82781: [OpenCL] Fix missing address space deduction in
 template variables
In-Reply-To: 
References: 
Message-ID: <408cdc8cd74666c0d39fd11435894daf@localhost.localdomain>

olestrohm updated this revision to Diff 276369.
olestrohm marked an inline comment as done.
olestrohm added a comment.

I've removed the comments calling for a fix because I no longer feel that this approach needs that. Given the code that already exists, and without changing too much of it, adding address space deduction in both cases seems like the right choice.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82781/new/

https://reviews.llvm.org/D82781

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaOpenCLCXX/address-space-deduction.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82781.276369.patch
Type: text/x-patch
Size: 4035 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 04:30:17 2020
From: cfe-commits at lists.llvm.org (Denys Petrov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:30:17 +0000 (UTC)
Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver
 infra
In-Reply-To: 
References: 
Message-ID: 

ASDenysPetrov added a comment.

Hi @vsavchenko , sorry for the late review.



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:367-378
+RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F,
+                          const llvm::APSInt &Point) const {
+  llvm::APSInt Upper = Point;
+  llvm::APSInt Lower = Point;
+
+  ++Upper;
+  --Lower;
----------------
Useful function. But I'd better rename it to `subtract` as we are working with sets (as a mathimatical collection). We should have a such one for the Ranges not only for Points.
We have `intersect`, `delete` aka `subtract`. And we also need to have functions `union` and `symmetricDifference` to cover full palette of common operations on sets.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734
   //        expressions which we currently do not know how to negate.
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) {
+  Optional getRangeForInvertedSub(SymbolRef Sym) {
     if (const SymSymExpr *SSE = dyn_cast(Sym)) {
----------------
As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you do Negate operation inside.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:841-844
+  RangeSet getTrueRange(QualType T) {
+    RangeSet TypeRange = infer(T);
+    return assumeNonZero(TypeRange, T);
+  }
----------------
Don't you think this is too complicated for such a simple getter?
Maybe we can just construct the range using smth about `RangeSet(RangeFactory, ++Zero, --Zero);` ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82381/new/

https://reviews.llvm.org/D82381




From cfe-commits at lists.llvm.org  Wed Jul  8 04:46:54 2020
From: cfe-commits at lists.llvm.org (Sylvestre Ledru via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:46:54 +0000 (UTC)
Subject: [PATCH] D83386: clang: Don't show a trailing space with --version
 when not built from the repo
Message-ID: 

sylvestre.ledru created this revision.
sylvestre.ledru added reviewers: thakis, hans.
Herald added a project: clang.

Reported here:
https://bugs.llvm.org/show_bug.cgi?id=38998#c15


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83386

Files:
  clang/lib/Basic/Version.cpp


Index: clang/lib/Basic/Version.cpp
===================================================================
--- clang/lib/Basic/Version.cpp
+++ clang/lib/Basic/Version.cpp
@@ -97,8 +97,12 @@
 #ifdef CLANG_VENDOR
   OS << CLANG_VENDOR;
 #endif
-  OS << ToolName << " version " CLANG_VERSION_STRING " "
-     << getClangFullRepositoryVersion();
+  OS << ToolName << " version " CLANG_VERSION_STRING;
+
+  std::string repo = getClangFullRepositoryVersion();
+  if (!repo.empty()) {
+    OS << " " << repo;
+  }
 
   return OS.str();
 }
@@ -111,7 +115,13 @@
 #ifdef CLANG_VENDOR
   OS << CLANG_VENDOR;
 #endif
-  OS << "Clang " CLANG_VERSION_STRING " " << getClangFullRepositoryVersion();
+  OS << "Clang " CLANG_VERSION_STRING;
+
+  std::string repo = getClangFullRepositoryVersion();
+  if (!repo.empty()) {
+    OS << " " << repo;
+  }
+
   return OS.str();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83386.276376.patch
Type: text/x-patch
Size: 857 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 04:51:10 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:51:10 +0000 (UTC)
Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for
 recovery expr.
In-Reply-To: 
References: 
Message-ID: <21ef062ed4e046c3a1a3604a4636dae3@localhost.localdomain>

hokein updated this revision to Diff 276379.
hokein marked 3 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83201/new/

https://reviews.llvm.org/D83201

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83201.276379.patch
Type: text/x-patch
Size: 4079 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 04:51:36 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:51:36 +0000 (UTC)
Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for
 recovery expr.
In-Reply-To: 
References: 
Message-ID: <4595df2ad97c64891df6fd6f256c2721@localhost.localdomain>

hokein added inline comments.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:12944
+      Fn->getBeginLoc(), RParenLoc, SubExprs,
+      ReturnType.isNull()
+          ? ReturnType
----------------
sammccall wrote:
> hokein wrote:
> > sammccall wrote:
> > > here we're splitting the type (e.g. int&&) into a type + VK, and passing both to createrecoveryexpr.
> > > 
> > > Why not do that on recoveryexpr side? e.g. if we request a recoveryexpr of type int&, return an LValue recoveryexpr of type int?
> > right, good idea, this is simpler. I was somehow taking `CallExpr` as a reference when writing this code.
> Hmm, this does seem simpler to me but it also seems that a few places deliberately make this mapping between two related concepts explicit.
> Maybe we should at least have a comment on createrecoveryexpr that the value category will be inferred from the (reference) type.
> Hmm, this does seem simpler to me but it also seems that a few places deliberately make this mapping between two related concepts explicit.

yeah, that's true for at least `CallExpr`. Expr provides a `setValueKind` method, ideally (if we enable the type propagation), we could call it to set the value category here. I think it is fine to leave it at recoveryexpr side -- our case is really simple.




================
Comment at: clang/test/SemaCXX/recovery-expr-type.cpp:66
+
+namespace test4 {
+int &&f(int);  // expected-note {{candidate function not viable}}
----------------
sammccall wrote:
> I liked the comment explaining the purpose of the test (no crash for wrong value category)
oops, the comment gets lost during my rebase :(.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83201/new/

https://reviews.llvm.org/D83201




From cfe-commits at lists.llvm.org  Wed Jul  8 04:53:24 2020
From: cfe-commits at lists.llvm.org (Anastasia Stulova via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:53:24 +0000 (UTC)
Subject: [PATCH] D82781: [OpenCL] Fix missing address space deduction in
 template variables
In-Reply-To: 
References: 
Message-ID: 

Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82781/new/

https://reviews.llvm.org/D82781




From cfe-commits at lists.llvm.org  Wed Jul  8 04:53:53 2020
From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:53:53 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <7669de96cdfce141fe2c95b6440eecdb@localhost.localdomain>

hans added a comment.

In D83013#2137607 , @MaskRay wrote:

> `Opts.getProfileUse() != CodeGenOptions::ProfileNone ` in
>
>   Opts.CallGraphProfile = Opts.getProfileUse() != CodeGenOptions::ProfileNone &&
>                             !Opts.DisableIntegratedAS;
>
>
> is redundant. CGProfile.cpp is a no-op if no function provides `getEntryFreq()`.


It's a functional no-op, but it runs the BFI analysis, which as Nikita pointed out above adds some compile-time cost. Not scheduling the pass unless we're using profile info seems like a reasonable way to avoid that cost to me.

The alternative of using LazyBlockFrequencyInfoPass and checking PSI->hasProfileSummary() first would also work I guess. If you think that's cleaner, maybe that's the better way to go.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Wed Jul  8 04:55:21 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via cfe-commits)
Date: Wed, 08 Jul 2020 04:55:21 -0700 (PDT)
Subject: [clang] 96a5cff - [AST][RecoveryExpr] Fix the value category for
 recovery expr.
Message-ID: <5f05b429.1c69fb81.2066a.d16c@mx.google.com>


Author: Haojian Wu
Date: 2020-07-08T13:55:07+02:00
New Revision: 96a5cfff208d8e86a598e64412d9ef5dde0f9c9e

URL: https://github.com/llvm/llvm-project/commit/96a5cfff208d8e86a598e64412d9ef5dde0f9c9e
DIFF: https://github.com/llvm/llvm-project/commit/96a5cfff208d8e86a598e64412d9ef5dde0f9c9e.diff

LOG: [AST][RecoveryExpr] Fix the value category for recovery expr.

RecoveryExpr was always lvalue, but it is wrong if we use it to model
broken function calls, function call expression has more compliated rules:

- a call to a function whose return type is an lvalue reference yields an lvalue;
- a call to a function whose return type is an rvalue reference yields an xvalue;
- a call to a function whose return type is nonreference type yields a prvalue;

This patch makes the recovery-expr align with the function call if it is
modeled a broken call.

Differential revision: https://reviews.llvm.org/D83201

Added: 
    

Modified: 
    clang/lib/AST/Expr.cpp
    clang/lib/AST/ExprClassification.cpp
    clang/lib/Sema/SemaOverload.cpp
    clang/test/AST/ast-dump-recovery.cpp
    clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 96a70307235b..343a271c3394 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4779,8 +4779,10 @@ QualType OMPArraySectionExpr::getBaseOriginalType(const Expr *Base) {
 
 RecoveryExpr::RecoveryExpr(ASTContext &Ctx, QualType T, SourceLocation BeginLoc,
                            SourceLocation EndLoc, ArrayRef SubExprs)
-    : Expr(RecoveryExprClass, T, VK_LValue, OK_Ordinary), BeginLoc(BeginLoc),
-      EndLoc(EndLoc), NumExprs(SubExprs.size()) {
+    : Expr(RecoveryExprClass, T.getNonReferenceType(),
+           T->isDependentType() ? VK_LValue : getValueKindForType(T),
+           OK_Ordinary),
+      BeginLoc(BeginLoc), EndLoc(EndLoc), NumExprs(SubExprs.size()) {
   assert(!T.isNull());
   assert(llvm::all_of(SubExprs, [](Expr* E) { return E != nullptr; }));
 

diff  --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp
index 42873d090ffa..31aa734ffedb 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -130,7 +130,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
   case Expr::UnresolvedLookupExprClass:
   case Expr::UnresolvedMemberExprClass:
   case Expr::TypoExprClass:
-  case Expr::RecoveryExprClass:
   case Expr::DependentCoawaitExprClass:
   case Expr::CXXDependentScopeMemberExprClass:
   case Expr::DependentScopeDeclRefExprClass:
@@ -276,6 +275,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
       return Cl::CL_PRValue;
     }
 
+  case Expr::RecoveryExprClass:
   case Expr::OpaqueValueExprClass:
     return ClassifyExprValueKind(Lang, E, E->getValueKind());
 

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 599e81d1b4d0..8635397f4806 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -12818,7 +12818,7 @@ static QualType chooseRecoveryType(OverloadCandidateSet &CS,
   auto ConsiderCandidate = [&](const OverloadCandidate &Candidate) {
     if (!Candidate.Function)
       return;
-    QualType T = Candidate.Function->getCallResultType();
+    QualType T = Candidate.Function->getReturnType();
     if (T.isNull())
       return;
     if (!Result)

diff  --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp
index e2a715130628..740864a26481 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -4,7 +4,6 @@
 int some_func(int *);
 
 // CHECK:     VarDecl {{.*}} invalid_call
-// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:  `-RecoveryExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:    |-UnresolvedLookupExpr {{.*}} 'some_func'
 // CHECK-NEXT:    `-IntegerLiteral {{.*}} 123
@@ -34,7 +33,6 @@ int ambig_func(double);
 int ambig_func(float);
 
 // CHECK:     VarDecl {{.*}} ambig_call
-// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:  `-RecoveryExpr {{.*}} 'int' contains-errors
 // CHECK-NEXT:    |-UnresolvedLookupExpr {{.*}} 'ambig_func'
 // CHECK-NEXT:    `-IntegerLiteral {{.*}} 123
@@ -211,3 +209,16 @@ struct {
 } NoCrashOnInvalidInitList = {
   .abc = nullptr,
 };
+
+// Verify the value category of recovery expression.
+int prvalue(int);
+int &lvalue(int);
+int &&xvalue(int);
+void ValueCategory() {
+  // CHECK:  RecoveryExpr {{.*}} 'int' contains-errors
+  prvalue(); // call to a function (nonreference return type) yields a prvalue (not print by default)
+  // CHECK:  RecoveryExpr {{.*}} 'int' contains-errors lvalue
+  lvalue(); // call to a function (lvalue reference return type) yields an lvalue.
+  // CHECK:  RecoveryExpr {{.*}} 'int' contains-errors xvalue
+  xvalue(); // call to a function (rvalue reference return type) yields an xvalue.
+}

diff  --git a/clang/test/SemaCXX/recovery-expr-type.cpp b/clang/test/SemaCXX/recovery-expr-type.cpp
index df40e5cd6021..6cd79326e8c3 100644
--- a/clang/test/SemaCXX/recovery-expr-type.cpp
+++ b/clang/test/SemaCXX/recovery-expr-type.cpp
@@ -62,3 +62,9 @@ constexpr auto x2 = AA::foo2(); // expected-error {{be initialized by a con
                                      // expected-note {{in instantiation of member function}} \
                                      // expected-note {{in call to}}
 }
+
+// verify no assertion failure on violating value category.
+namespace test4 {
+int &&f(int);  // expected-note {{candidate function not viable}}
+int &&k = f(); // expected-error {{no matching function for call}}
+}


        

From cfe-commits at lists.llvm.org  Wed Jul  8 04:55:38 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:55:38 +0000 (UTC)
Subject: [PATCH] D83201: [AST][RecoveryExpr] Fix the value category for
 recovery expr.
In-Reply-To: 
References: 
Message-ID: <925de6f9d07a3c510661024fbeaf63f1@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG96a5cfff208d: [AST][RecoveryExpr] Fix the value category for recovery expr. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83201/new/

https://reviews.llvm.org/D83201

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83201.276380.patch
Type: text/x-patch
Size: 4079 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 04:56:49 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 11:56:49 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: 

eduucaldas marked 2 inline comments as done.
eduucaldas added inline comments.


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2192
       R"cpp(
+class osstream {};
 struct X {
----------------
gribozavr2 wrote:
> eduucaldas wrote:
> > gribozavr2 wrote:
> > > I don't think we need a separate class to show the left shift operator. The declaration below can be:
> > > 
> > > ```
> > >   friend X operator<<(X&, const X&);
> > > ```
> > If we don't bother much about "realistic" operator declarations we could drop all the `friend` and declare every operator in their most concise form. WDYT
> I think we shouldn't try to make tests realistic in terms of function names etc., but we should try to cover as many different AST shapes as possible. In the case of binary operators, we have three cases -- free function, friend function, member function, that all generate slightly different ASTs, so I believe we should try to cover them all.
But those all regard the operators declaration. 
Here we test the operator call expression - `CXXOperatorCallExpr`.

I think we should test friend function declarations when we add support for them in the tree, and then we add tests for declaration of friend operators, friend member functions and whatnot.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954




From cfe-commits at lists.llvm.org  Wed Jul  8 05:02:27 2020
From: cfe-commits at lists.llvm.org (Sylvestre Ledru via cfe-commits)
Date: Wed, 08 Jul 2020 05:02:27 -0700 (PDT)
Subject: [clang] bbea4d5 - clang: Don't show a trailing space with --version
 when not built from the repo
Message-ID: <5f05b5d3.1c69fb81.35566.92d4@mx.google.com>


Author: Sylvestre Ledru
Date: 2020-07-08T14:02:02+02:00
New Revision: bbea4d5e6b82a683dccaa8f4916e2a44f5dd3490

URL: https://github.com/llvm/llvm-project/commit/bbea4d5e6b82a683dccaa8f4916e2a44f5dd3490
DIFF: https://github.com/llvm/llvm-project/commit/bbea4d5e6b82a683dccaa8f4916e2a44f5dd3490.diff

LOG: clang: Don't show a trailing space with --version when not built from the repo

Reported here:
https://bugs.llvm.org/show_bug.cgi?id=38998#c15

Reviewers: hans

Differential Revision: https://reviews.llvm.org/D83386

Added: 
    

Modified: 
    clang/lib/Basic/Version.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Version.cpp b/clang/lib/Basic/Version.cpp
index c4b7d34ed168..286107cab9d7 100644
--- a/clang/lib/Basic/Version.cpp
+++ b/clang/lib/Basic/Version.cpp
@@ -97,8 +97,12 @@ std::string getClangToolFullVersion(StringRef ToolName) {
 #ifdef CLANG_VENDOR
   OS << CLANG_VENDOR;
 #endif
-  OS << ToolName << " version " CLANG_VERSION_STRING " "
-     << getClangFullRepositoryVersion();
+  OS << ToolName << " version " CLANG_VERSION_STRING;
+
+  std::string repo = getClangFullRepositoryVersion();
+  if (!repo.empty()) {
+    OS << " " << repo;
+  }
 
   return OS.str();
 }
@@ -111,7 +115,13 @@ std::string getClangFullCPPVersion() {
 #ifdef CLANG_VENDOR
   OS << CLANG_VENDOR;
 #endif
-  OS << "Clang " CLANG_VERSION_STRING " " << getClangFullRepositoryVersion();
+  OS << "Clang " CLANG_VERSION_STRING;
+
+  std::string repo = getClangFullRepositoryVersion();
+  if (!repo.empty()) {
+    OS << " " << repo;
+  }
+
   return OS.str();
 }
 


        

From cfe-commits at lists.llvm.org  Wed Jul  8 05:02:34 2020
From: cfe-commits at lists.llvm.org (Sylvestre Ledru via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:02:34 +0000 (UTC)
Subject: [PATCH] D83386: clang: Don't show a trailing space with --version
 when not built from the repo
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbea4d5e6b82: clang: Don't show a trailing space with --version when not built from the repo (authored by sylvestre.ledru).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83386/new/

https://reviews.llvm.org/D83386

Files:
  clang/lib/Basic/Version.cpp


Index: clang/lib/Basic/Version.cpp
===================================================================
--- clang/lib/Basic/Version.cpp
+++ clang/lib/Basic/Version.cpp
@@ -97,8 +97,12 @@
 #ifdef CLANG_VENDOR
   OS << CLANG_VENDOR;
 #endif
-  OS << ToolName << " version " CLANG_VERSION_STRING " "
-     << getClangFullRepositoryVersion();
+  OS << ToolName << " version " CLANG_VERSION_STRING;
+
+  std::string repo = getClangFullRepositoryVersion();
+  if (!repo.empty()) {
+    OS << " " << repo;
+  }
 
   return OS.str();
 }
@@ -111,7 +115,13 @@
 #ifdef CLANG_VENDOR
   OS << CLANG_VENDOR;
 #endif
-  OS << "Clang " CLANG_VERSION_STRING " " << getClangFullRepositoryVersion();
+  OS << "Clang " CLANG_VERSION_STRING;
+
+  std::string repo = getClangFullRepositoryVersion();
+  if (!repo.empty()) {
+    OS << " " << repo;
+  }
+
   return OS.str();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83386.276382.patch
Type: text/x-patch
Size: 857 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 05:05:48 2020
From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:05:48 +0000 (UTC)
Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support
 for Clang and LLVM
In-Reply-To: 
References: 
Message-ID: 

LukeGeeson updated this revision to Diff 276383.
LukeGeeson marked 2 inline comments as done.
LukeGeeson added a comment.

Addressed Mikhail's feedback: Sorted CPU lists accordingly


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83206/new/

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/unittests/Support/TargetParserTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83206.276383.patch
Type: text/x-patch
Size: 14148 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 05:14:39 2020
From: cfe-commits at lists.llvm.org (Denys Petrov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:14:39 +0000 (UTC)
Subject: [PATCH] D83286: [analyzer][solver] Track symbol disequalities
In-Reply-To: 
References: 
Message-ID: <98d298988553d907cd7b7094273520e4@localhost.localdomain>

ASDenysPetrov added a comment.

@vsavchenko

> if a != b and b == C where C is a constant, a != C

Did you take into account that e.g. `a > b` also is a disequality.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83286/new/

https://reviews.llvm.org/D83286




From cfe-commits at lists.llvm.org  Wed Jul  8 05:26:53 2020
From: cfe-commits at lists.llvm.org (Anton Korobeynikov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:26:53 +0000 (UTC)
Subject: [PATCH] D82646: [MSP430] Align the _Complex ABI with current
 msp430-gcc
In-Reply-To: 
References: 
Message-ID: <77e44bfc36b3335c7807965a0c7a9073@localhost.localdomain>

asl added inline comments.


================
Comment at: clang/test/CodeGen/msp430-abi-complex.c:8
+
+void complex_float_arg_first(float _Complex x, int n) {
+// CHECK-LABEL: @complex_float_arg_first
----------------
What's about Complex Int?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82646/new/

https://reviews.llvm.org/D82646




From cfe-commits at lists.llvm.org  Wed Jul  8 05:27:40 2020
From: cfe-commits at lists.llvm.org (Dave Green via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:27:40 +0000 (UTC)
Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support
 for Clang and LLVM
In-Reply-To: 
References: 
Message-ID: <5cbb453f61c59705957d39609af8ceb8@localhost.localdomain>

dmgreen added a comment.

I would expect this to be very similar to https://reviews.llvm.org/rG8bf99f1e6f0f9b426d6060361ea6d9d47c1868d1, but some parts seems to be missing. Can you make sure that everything is included and in a sensible order.



================
Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:131
+AARCH64_CPU_NAME("cortex-a78", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
+                 (AArch64::AEK_RAS | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | AArch64::AEK_SSBS))
+AARCH64_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
----------------
This no longer has FP16?

AEK_RAS I believe should be included in ARMV8_2A,


================
Comment at: llvm/include/llvm/Support/ARMTargetParser.def:301
+             (ARM::AEK_RAS | ARM::AEK_DOTPROD))
+ARM_CPU_NAME("cortex-a78",ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
+             (ARM::AEK_RAS | ARM::AEK_DOTPROD))
----------------
All these can go in a better order, please. A78 can go next to A77. Same everywhere else.


================
Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.cpp:196
+  case CortexX1:
+  case CortexA78:
+    PrefFunctionLogAlignment = 4;
----------------
These can go with the other CortexAXX cpu's, which seem to set the same PrefFunctionLogAlignment. Same for the ARM equivalent.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83206/new/

https://reviews.llvm.org/D83206




From cfe-commits at lists.llvm.org  Wed Jul  8 05:31:28 2020
From: cfe-commits at lists.llvm.org (Eugene Leviant via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:31:28 +0000 (UTC)
Subject: [PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type
 tests until after ICP
In-Reply-To: 
References: 
Message-ID: 

evgeny777 accepted this revision.
evgeny777 added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73242/new/

https://reviews.llvm.org/D73242




From cfe-commits at lists.llvm.org  Wed Jul  8 05:39:27 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:39:27 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: <1c60bd6d136edb0d0ea43ca976ad41c9@localhost.localdomain>

gribozavr2 added inline comments.


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:2192
       R"cpp(
+class osstream {};
 struct X {
----------------
eduucaldas wrote:
> gribozavr2 wrote:
> > eduucaldas wrote:
> > > gribozavr2 wrote:
> > > > I don't think we need a separate class to show the left shift operator. The declaration below can be:
> > > > 
> > > > ```
> > > >   friend X operator<<(X&, const X&);
> > > > ```
> > > If we don't bother much about "realistic" operator declarations we could drop all the `friend` and declare every operator in their most concise form. WDYT
> > I think we shouldn't try to make tests realistic in terms of function names etc., but we should try to cover as many different AST shapes as possible. In the case of binary operators, we have three cases -- free function, friend function, member function, that all generate slightly different ASTs, so I believe we should try to cover them all.
> But those all regard the operators declaration. 
> Here we test the operator call expression - `CXXOperatorCallExpr`.
> 
> I think we should test friend function declarations when we add support for them in the tree, and then we add tests for declaration of friend operators, friend member functions and whatnot.
The call expression AST node can be meaningfully different between calls to member and non-member functions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954




From cfe-commits at lists.llvm.org  Wed Jul  8 05:54:44 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:54:44 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <4694521591c425af93c6cc94cdd663e9@localhost.localdomain>

gribozavr2 added a comment.

> Fix crash on `user defined literals`

WDYT:

Implement support for user defined literals (which also fixes a crash)

> Given an UserDefinedLiteral 1.2_w:
>  Problem: Lexer generates one Token for the literal, but ClangAST
>  references two source locations
>  Fix: Ignore the operator and interpret it as the underlying literal.
>  e.g.: 1.2_w token generates syntax node IntegerLiteral(1.2_w)

WDYT:

A user defined literal (for example, `1.2_w`) is one token. The Clang AST for a user defined literal references two source locations: the beginning of the token (the location of `1` in `1.2_w`) and the beginning of the suffix (the location of `_`). When constructing the syntax tree, we were trying to find a token that starts at the underscore, but couldn't find one, and crashed on an assertion failure. To fix this issue, we ignore the Clang AST nodes for UDLs that have source locations that point in the middle of a token.



================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:634
+    // `SourceLocation`s. As a result one of these nodes has a valid
+    // `SourceLocation` that doesn't point to a token.
+    //
----------------
"The semantic AST node for has child nodes that reference two source locations, the location of the beginning of the token (`1`), and the location of the beginning of the UDL suffix (`_`). The UDL suffix location does not point to the beginning of a token, so we can't represent the UDL suffix as a separate syntax tree node."


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1197-1199
+    1.2_w; // calls operator "" _w(1.2L)
+    12_w;  // calls operator "" _w("12")
+    12_x;  // calls operator<'1', '2'> "" _x()
----------------
Indent -2.


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1200
+    12_x;  // calls operator<'1', '2'> "" _x()
+}
+    )cpp",
----------------
Could you also add tests for user-defined string literals and user-defined character literals? ("abc"_mystr, u"abc"_mystr, 'c'_mychar)


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1265
+    | |-UserDefinedLiteralExpression
+    | | `-12_w
+    | `-;
----------------
It looks somewhat weird to me that integer and floating point literals end up with the same syntax tree node type. WDYT about making different nodes for different literals (integer, floating-point, string, character)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157




From cfe-commits at lists.llvm.org  Wed Jul  8 05:56:52 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:56:52 +0000 (UTC)
Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver
 infra
In-Reply-To: 
References: 
Message-ID: <1c768d38ade24c23ff09ad477f080a26@localhost.localdomain>

vsavchenko marked 3 inline comments as done.
vsavchenko added a comment.

Hi @ASDenysPetrov no problem at all!  Thanks for taking your time and checking it.



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:367-378
+RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F,
+                          const llvm::APSInt &Point) const {
+  llvm::APSInt Upper = Point;
+  llvm::APSInt Lower = Point;
+
+  ++Upper;
+  --Lower;
----------------
ASDenysPetrov wrote:
> Useful function. But I'd better rename it to `subtract` as we are working with sets (as a mathimatical collection). We should have a such one for the Ranges not only for Points.
> We have `intersect`, `delete` aka `subtract`. And we also need to have functions `union` and `symmetricDifference` to cover full palette of common operations on sets.
I agree that we should have a full set of functions.  I don't agree however, that this function is a `subtract`.  Subtract is an operation on two sets and here we have a set and a point.  One might argue that a point is just a very simple set, that's true, but real `subtract` would be more complex in its implementation.

Naming it `delete`, on the other hand, I was coming from a notion of deleting points or neighbourhoods (https://en.wikipedia.org/wiki/Neighbourhood_(mathematics)#Deleted_neighbourhood).


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734
   //        expressions which we currently do not know how to negate.
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) {
+  Optional getRangeForInvertedSub(SymbolRef Sym) {
     if (const SymSymExpr *SSE = dyn_cast(Sym)) {
----------------
ASDenysPetrov wrote:
> As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you do Negate operation inside.
I'm not super happy about my name either, but I feel like it describes it better than the previous name and your version.  That function doesn't work for any `SymSymExpr` and it doesn't simply negate whatever we gave it.  It works specifically for symbolic subtractions and this is the information I want to be reflected in the name.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:841-844
+  RangeSet getTrueRange(QualType T) {
+    RangeSet TypeRange = infer(T);
+    return assumeNonZero(TypeRange, T);
+  }
----------------
ASDenysPetrov wrote:
> Don't you think this is too complicated for such a simple getter?
> Maybe we can just construct the range using smth about `RangeSet(RangeFactory, ++Zero, --Zero);` ?
It is more complex than a false range but there is a reason for it.

First of all, `RangeSet` can't have ranges where the end is greater than its start.  Only `Intersect` can handle such ranges correctly.  Another thing is that ranges like that mean `[MIN, --Zero], [++Zero, MAX]` and without a type we can't really say what `MIN` and `MAX` are, so such constructor for `RangeSet` simply cannot exist.

Another point is that we do need to have `[MIN, -1], [+1, MAX]` as opposed to `[-1, -1], [+1, +1]` because of C language (it doesn't have boolean type), and because of the cases like `a - b` where we know that `a != b`.

I hope that answers the question.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82381/new/

https://reviews.llvm.org/D82381




From cfe-commits at lists.llvm.org  Wed Jul  8 05:59:35 2020
From: cfe-commits at lists.llvm.org (Djordje Todorovic via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 12:59:35 +0000 (UTC)
Subject: [PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1
 option
In-Reply-To: 
References: 
Message-ID: <65b81f9d7c29c9b29f18a7bacc357758@localhost.localdomain>

djtodoro marked an inline comment as done.
djtodoro added inline comments.


================
Comment at: clang/lib/CodeGen/BackendUtil.cpp:855
 
+class ClangCustomPassManager : public legacy::PassManager {
+public:
----------------
djtodoro wrote:
> vsk wrote:
> > Please factor out OptCustomPassManager from opt and generalize it so it can be used by both opt and clang. That should help ensure that extensions and bug fixes are only made to one custom 'debugify' pass manager.
> I'll try that with the latest code. I remember I've tried it once, but I ended up moving it into the IR library (since we need to link it within legacy pass manager).
Hi @vsk, I've posted the patch as D83391. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547




From cfe-commits at lists.llvm.org  Wed Jul  8 06:01:56 2020
From: cfe-commits at lists.llvm.org (Djordje Todorovic via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:01:56 +0000 (UTC)
Subject: [PATCH] D82547: [Debugify] Expose debugify (original mode) as CC1
 option
In-Reply-To: 
References: 
Message-ID: <294e44c035816bd60e72f816cef88fc9@localhost.localdomain>

djtodoro updated this revision to Diff 276398.
djtodoro added a comment.

- Rebase on top of D83391 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82547/new/

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/debugify-each-original.c
  llvm/docs/HowToUpdateDebugInfo.rst

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82547.276398.patch
Type: text/x-patch
Size: 6225 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:06:26 2020
From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:06:26 +0000 (UTC)
Subject: [PATCH] D79842: [clang][Driver] Correct tool search path priority
In-Reply-To: 
References: 
Message-ID: 

DavidSpickett added a comment.

Right, I see the issue.

The code that gets the default triple name (https://reviews.llvm.org/D13340?id=36227#inline-108606) looks up the one you have in cmake, not the actual default which you get in --version. We could "fix" this by doing so when we make the tool name as well, but this breaks whatever mips toolchain was using that. (their tools won't be mips-unknown-elf-)

So yes it looks up powerpc64le-linux-gnu but shows powerpc64le-unknown-linux-gnu. Can't go back to using cmake's value because on Mac OS, cmake has x86_64-darwin, clang has x86_64-darwin. Writing to both is a short term option so I will try that and fold it into https://reviews.llvm.org/D83055. (will add you on review once I update it)

(this whole default triple lookup should probably go but I'd really like to do that in its own commit)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79842/new/

https://reviews.llvm.org/D79842




From cfe-commits at lists.llvm.org  Wed Jul  8 06:09:39 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:09:39 +0000 (UTC)
Subject: [PATCH] D83071: Add support for options with two flags for
 controlling the same field.
In-Reply-To: 
References: 
Message-ID: <5fc6c407f09075f8c2148d62dcd86cd0@localhost.localdomain>

dang updated this revision to Diff 276400.
dang added a comment.

Split into two macro kinds.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83071/new/

https://reviews.llvm.org/D83071

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83071.276400.patch
Type: text/x-patch
Size: 18193 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:10:39 2020
From: cfe-commits at lists.llvm.org (Erich Keane via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:10:39 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: <46ca55e9a1f3a61382fcc2e78bf6fe37@localhost.localdomain>

erichkeane added inline comments.


================
Comment at: clang/test/Sema/builtin-expect-with-probability.cpp:12
+  }
+}  // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
----------------
Please also validate this by doing some sort of test in a constexpr function if possible. That way you can make sure the parameter is evaluated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Wed Jul  8 06:11:21 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:11:21 +0000 (UTC)
Subject: [PATCH] D83286: [analyzer][solver] Track symbol disequalities
In-Reply-To: 
References: 
Message-ID: <4ac64a08bbd992c5194b3deb2ec07d53@localhost.localdomain>

vsavchenko added a comment.

In D83286#2138734 , @ASDenysPetrov wrote:

> Did you take into account that e.g. `a > b` also is a disequality.


It is a very good point! I didn't take them into account (yet?) because they make the implementation a bit harder.
Right now we can decide by the look of the assumption (or symbolic expression) if it's an equality/disequality check.  Later on, if we see an expression that looks like equality/disequality, we can try to see what we know about its operands.  So here we have a fairly easy table (2x2) of possible outcomes: if our current knowledge of the equality/disequality matches the current check - it's true, if it's opposite - it's false.

When it comes to things like `a > b`, we can consider it as disequality when we start tracking it because `a > b -> a != b`, but cannot in the second case because `a != b -/-> a > b`.  As the result, this beautiful symmetry that I use is gone and we need to add more data into `EqualityInfo` so we support the one-sidedness of that implication.

It is not a big change, but I would prefer making it separately.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83286/new/

https://reviews.llvm.org/D83286




From cfe-commits at lists.llvm.org  Wed Jul  8 06:13:40 2020
From: cfe-commits at lists.llvm.org (Valentin Clement via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:13:40 +0000 (UTC)
Subject: [PATCH] D82659: Fix missing build dependency on omp_gen.
In-Reply-To: 
References: 
Message-ID: <91ca3cc1797895e101b5e918290afaf1@localhost.localdomain>

clementval added a comment.

In D82659#2138228 , @michele.scandale wrote:

> In D82659#2136999 , @clementval wrote:
>
> > Looks good but just one question ... When clang is built as standalone it does not build the OpenMP part inside Clang? I haven't seen any code to avoid compiling the OpenMP parsing and semantic checking inside clang.
>
>
> I don't think there is a way to avoid compiling the OpenMP support in Clang. The standalone build is just building the content of the `clang` directory as a separate CMake project reusing the an already built LLVM -- therefore the `libLLVMFrontendOpenMP` as well as the `OMP.h.inc` would have been generated already.


Ok then your fix should work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82659/new/

https://reviews.llvm.org/D82659




From cfe-commits at lists.llvm.org  Wed Jul  8 06:17:42 2020
From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:17:42 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: <5ac0bf7637c6f129413511462b10645c@localhost.localdomain>

shafik added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:2197
     // least as many of them as possible).
     return RD->isTrivial() && RD->isCXX11StandardLayout();
   }
----------------
teemperor wrote:
> See here for the POD check that we might get wrong.
I don't believe we are getting this wrong or at least not in the original problem. Going back and checking it we seem to be getting this right.


================
Comment at: lldb/test/Shell/Expr/Inputs/layout.cpp:40
+  D2 d2;
+  D3 d3;
+
----------------
teemperor wrote:
> Do we actually need these locals in addition to the globals?
I left them in by accident.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008




From cfe-commits at lists.llvm.org  Wed Jul  8 06:28:09 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:28:09 +0000 (UTC)
Subject: [PATCH] D83301: [clang-tidy] More strict on matching the standard
 memset function in memset-usage check.
In-Reply-To: 
References: 
Message-ID: <1ce2a9c82d728d54f243d1d3d9dece9a@localhost.localdomain>

hokein updated this revision to Diff 276405.
hokein added a comment.

add parameterCountIs(3).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83301/new/

https://reviews.llvm.org/D83301

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
@@ -75,3 +75,8 @@
   // despite v == 0.
   memset(p, -1, v);
 }
+
+void *memset(int);
+void NoCrash() {
+  memset(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
@@ -20,11 +20,19 @@
 namespace bugprone {
 
 void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
-  // Note: void *memset(void *buffer, int fill_char, size_t byte_count);
+  // Match the standard memset:
+  // void *memset(void *buffer, int fill_char, size_t byte_count);
+  auto MemsetDecl =
+      functionDecl(hasName("::memset"),
+                   parameterCountIs(3),
+                   hasParameter(0, hasType(pointerType(pointee(voidType())))),
+                   hasParameter(1, hasType(isInteger())),
+                   hasParameter(2, hasType(isInteger())));
+
   // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended.
   Finder->addMatcher(
       callExpr(
-          callee(functionDecl(hasName("::memset"))),
+          callee(MemsetDecl),
           hasArgument(1, characterLiteral(equals(static_cast('0')))
                              .bind("char-zero-fill")),
           unless(
@@ -36,14 +44,14 @@
 
   // Look for memset with an integer literal in its fill_char argument.
   // Will check if it gets truncated.
-  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))),
+  Finder->addMatcher(callExpr(callee(MemsetDecl),
                               hasArgument(1, integerLiteral().bind("num-fill")),
                               unless(isInTemplateInstantiation())),
                      this);
 
   // Look for memset(x, y, 0) as that is most likely an argument swap.
   Finder->addMatcher(
-      callExpr(callee(functionDecl(hasName("::memset"))),
+      callExpr(callee(MemsetDecl),
                unless(hasArgument(1, anyOf(characterLiteral(equals(
                                                static_cast('0'))),
                                            integerLiteral()))),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83301.276405.patch
Type: text/x-patch
Size: 2526 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:28:36 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:28:36 +0000 (UTC)
Subject: [PATCH] D83301: [clang-tidy] More strict on matching the standard
 memset function in memset-usage check.
In-Reply-To: 
References: 
Message-ID: 

hokein added a comment.

In D83301#2137140 , @njames93 wrote:

> If you want to be super explicit. Why not add `parameterCountIs(3)`?


good idea.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83301/new/

https://reviews.llvm.org/D83301




From cfe-commits at lists.llvm.org  Wed Jul  8 06:31:10 2020
From: cfe-commits at lists.llvm.org (Anastasia Stulova via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:31:10 +0000 (UTC)
Subject: [PATCH] D82756: Port some floating point options to new option
 marshalling infrastructure
In-Reply-To: 
References: 
Message-ID: <456265f6efbd87196ced152960dbd571@localhost.localdomain>

Anastasia added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:1176
+defm reciprocal_math : OptInFFlag< "reciprocal-math", "Allow division operations to be reassociated", "", "", [], "LangOpts->AllowRecip">;
+def fapprox_func : Flag<["-"], "fapprox-func">, Group, Flags<[CC1Option, NoDriverOption]>,
+  MarshallingInfoFlag<"LangOpts->ApproxFunc", "false">;
----------------
could this also be OptInFFlag?


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2805
     CmdArgs.push_back("-menable-unsafe-fp-math");
+    ApproxFunc = true;
+  }
----------------
Is this a bug fix ?


================
Comment at: clang/test/CodeGen/fp-function-attrs.cpp:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffinite-math-only -menable-unsafe-fp-math \
+// RUN:   -menable-no-infs -menable-no-nans -fno-signed-zeros -freciprocal-math \
+// RUN:   -fapprox-func -mreassociate -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s
----------------
Not clear why do you need to pass these extra flags now?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82756/new/

https://reviews.llvm.org/D82756




From cfe-commits at lists.llvm.org  Wed Jul  8 06:31:19 2020
From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:31:19 +0000 (UTC)
Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failure
In-Reply-To: 
References: 
Message-ID: <571c5717eecc49530a9f792926814186@localhost.localdomain>

DavidSpickett updated this revision to Diff 276406.
DavidSpickett added a subscriber: stevewan.
DavidSpickett added a comment.

- Write to cmake and clang's default triple to also fix failure reported by @stevewan.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055

Files:
  clang/test/Driver/program-path-priority.c
  clang/test/lit.cfg.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83055.276406.patch
Type: text/x-patch
Size: 7466 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:37:19 2020
From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:37:19 +0000 (UTC)
Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures
In-Reply-To: 
References: 
Message-ID: 

DavidSpickett added a comment.

For the record my logic here is that I could change the tool names to use the same name as --version. However that will break whatever mips toolchain needed this code in the first place. (https://reviews.llvm.org/D13340?id=36227#inline-108606)

This default triple lookup code had some support to be removed anyway, so I'd rather patch up this test first before doing so. So that it's easier to roll back if there are still users of it. Having tests of the existing behaviour is a good thing and I don't think writing to both potential default triples undermines that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055




From cfe-commits at lists.llvm.org  Wed Jul  8 06:38:19 2020
From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:38:19 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: 

shafik updated this revision to Diff 276407.
shafik added a comment.

Moved from shell test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/API/lang/cpp/alignas_base_class/Makefile
  lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
  lldb/test/API/lang/cpp/alignas_base_class/main.cpp


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @no_debug_info_test
+    def test(self):
+        self.build()
+        self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+        # The offset of f2 should be 8 because of `alignas(8)`.
+        self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-    // FIXME: This appears to be reversed.
     if (Base->IsVirtual)
-      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-    else
       HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+    else
+      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83008.276407.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:38:23 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:38:23 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: 

eduucaldas updated this revision to Diff 276408.
eduucaldas marked an inline comment as done.
eduucaldas added a comment.

Switch to `TraverseCXXOperatorCallExpr`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82954.276408.patch
Type: text/x-patch
Size: 10417 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:39:36 2020
From: cfe-commits at lists.llvm.org (Raphael Isemann via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:39:36 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: 

teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the patch!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008




From cfe-commits at lists.llvm.org  Wed Jul  8 06:44:56 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:44:56 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: 

gribozavr2 accepted this revision.
gribozavr2 added inline comments.


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:820
+      // A postfix unary operator is declared as taking two operands. The
+      // second operand is used to differ from its prefix counterpart. In the
+      // semantic AST this "phantom" operand is represented as a
----------------
"is used to distinguish"


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:823
+      // `IntegerLiteral` with invalid `SourceLocation`. We skip visiting this
+      // operand because we are not able to generate a syntax node from a
+      // semantic node with an invalid `SourceLocation`.
----------------
"... because does not correspond to anything written in the source code"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954




From cfe-commits at lists.llvm.org  Wed Jul  8 06:49:45 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:49:45 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: <6db7727f55f6b7d2c36abed6fc48afd2@localhost.localdomain>

eduucaldas updated this revision to Diff 276411.
eduucaldas marked 2 inline comments as done.
eduucaldas added a comment.

minor fix comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82954.276411.patch
Type: text/x-patch
Size: 10383 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 06:59:59 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 13:59:59 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

uweigand updated this revision to Diff 276414.
uweigand added a comment.

Handle array of empty records correctly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/systemz-abi.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81583.276414.patch
Type: text/x-patch
Size: 8351 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:04:53 2020
From: cfe-commits at lists.llvm.org (Bernhard Manfred Gruber via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:04:53 +0000 (UTC)
Subject: [PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type
 support for C++20 concepts and decltype
In-Reply-To: 
References: 
Message-ID: <5dc0d9d61a6c85d02a854af39a100eba@localhost.localdomain>

bernhardmgruber added a comment.

Ping.

Is there anything I am not seeing here that you still would like me to do? I feel like you are waiting for something obvious from my side :S.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80514/new/

https://reviews.llvm.org/D80514




From cfe-commits at lists.llvm.org  Wed Jul  8 07:07:04 2020
From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:07:04 +0000 (UTC)
Subject: [PATCH] D81003: [clang] SequenceChecker: Also visit default arguments
 and default initializers.
In-Reply-To: 
References: 
Message-ID: <3020181e82da820ff9394615ffa931a9@localhost.localdomain>

riccibruno added a comment.

@rsmith I have modified this patch to address your comment above (we should track where default argument(s) and/or default member initializer(s) were used). You accepted this originally but I would like to make sure that you are happy with the updated patch.

I was also confused for a while about the example:

  int a;
  struct S { int b = ++a; };
  void Test() {
    int c = S{}.b + a; // Warn in C++14 and above, but not before.
  }

I *think* that this should warn in C++14 and above, because `S` is an aggregate in C++14 and above, and the default member initializers of an aggregate are also part of the full-expression containing the initialization of the aggregate (`[intro.execution]p12`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81003/new/

https://reviews.llvm.org/D81003




From cfe-commits at lists.llvm.org  Wed Jul  8 07:07:28 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:07:28 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: <87bcec424736baacd37b0acc88cfcb78@localhost.localdomain>

uweigand marked 6 inline comments as done.
uweigand added inline comments.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:521
+  // [[no_unique_address]] attribute (since C++20).  Those do count
+  // as empty according to the Itanium ABI.  This property is currently
+  // only respected if the AllowNoUniqueAddr parameter is true.
----------------
hubert.reinterpretcast wrote:
> This check is being done after removal of the array types by `AllowArrays`, so this code is also conferring the property of being empty to arrays. It seems GCC erroneously does the same for base class fields (but not for direct members).
> 
> ```
> struct Empty {};
> 
> struct A {
>   Empty emp [[no_unique_address]][3];
> };
> 
> struct B : A {
>   float f;
> };
> 
> struct C {
>   Empty emp [[no_unique_address]][3];
>   float f;
> };
> 
> extern char szb[sizeof(B)];
> extern char szb[sizeof(float)]; // GCC likes this
> extern char szc[sizeof(C)];
> extern char szc[sizeof(float)]; // GCC does not like this
> ```
> 
> Compiler Explorer link: https://godbolt.org/z/NFuca9
This version should fix clang; I agree that GCC still gets this wrong.


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:524
+  if (isa(RT->getDecl()) &&
+      !(AllowNoUniqueAddr && FD->hasAttr()))
     return false;
----------------
efriedma wrote:
> Does this do the right thing with a field that's an array of empty classes?
You're right.  As Hubert notes, arrays of empty classes do not count as empty.  This version should fix the problem.  


================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:7245
       // do count.  So do anonymous bitfields that aren't zero-sized.
-      if (getContext().getLangOpts().CPlusPlus &&
-          FD->isZeroLengthBitField(getContext()))
-        continue;
+      if (getContext().getLangOpts().CPlusPlus) {
+        if (FD->isZeroLengthBitField(getContext()))
----------------
efriedma wrote:
> Only loosely relevant to this patch, but checking getLangOpts().CPlusPlus here seems weird; doesn't that break calling functions defined in C from C++ code?
I agree that this difference between C and C++ is weird, but it does match the behavior of GCC.  (Which is itself weird, but a long-standing accident that we probably cannot fix without breaking existing code at this point.)

Now, you bring up an interesting point: When C++ code calls a function defined in C code, the C++ part would have to refer to an `extern "C"` declaration.  The correct thing to do would probably be to handle those according to the C ABI rules, not the C++ rules, in this case where the two differ.  But currently GCC doesn't do that either.  (But since that would be broken anyway, I think we **can** fix that.)  In any case, I agree that this is really a separate problem, distinct from this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Wed Jul  8 07:07:29 2020
From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:07:29 +0000 (UTC)
Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default
In-Reply-To: 
References: 
Message-ID: 

yaxunl updated this revision to Diff 276417.
yaxunl added a comment.

revised by Artem's comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78655.276417.patch
Type: text/x-patch
Size: 13788 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:08:37 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:08:37 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

uweigand marked 2 inline comments as done.
uweigand added a comment.

In D81583#2137277 , @efriedma wrote:

> I'm tempted to say this is a bugfix for the implementation of no_unique_address, and just fix it globally for all ABIs.  We're never going to get anything done here if we require a separate patch for each ABI variant clang supports.


Well, I can certainly do that.  Would you prefer me to completely remove the AllowNoUniqueAddress parameter, or keep it but default to true (so ABIs can still override if necessary)?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Wed Jul  8 07:08:52 2020
From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:08:52 +0000 (UTC)
Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default
In-Reply-To: 
References: 
Message-ID: <6b58eea93cdbd3c5c1ac1b8c86a5cfee@localhost.localdomain>

yaxunl marked 3 inline comments as done.
yaxunl added inline comments.


================
Comment at: clang/lib/Sema/SemaCUDA.cpp:757-759
+  // In host compilation, deferred diagnostics are only emitted for functions
+  // which are sure to be emitted on host side since there is no reliable
+  // way to check if a function is emitted on device side. Therefore in
----------------
tra wrote:
> I don't think this is completely correct. Postponed diags get emitted if we know we're attempoting to codegen wrong things.
> E.g. during host compilation when HD function used by host code ends up attempting to call a device function.
> It also works in the other direction -- it kicks in during device compilation when HD function calls a host function.
> AFAICT it has nothing to do with what happens on the other side of the compilation, but rather what we're attempting to codegen during *this* compilation.
> 
> I don't think that we can reason that checks can be done on the host side only, based only on the argument you're making above (at least based on the way I understand it).
> 
> The point you're making below that a captured lambda created by device code can't ever be used by the host code is probably a better argument why the check may not be necessary.
> 
Revised the comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655




From cfe-commits at lists.llvm.org  Wed Jul  8 07:10:31 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:10:31 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

uweigand added a comment.

In D81583#2138127 , @qiucf wrote:

> Thanks for this patch!
>
> If I understand correctly, only `isEmptyRecord`/`isEmptyField` and places checking any field is zero bit-width may need change for this? Since `isSingleElementStruct` and `isHomogeneousAggregate` just use them to skip empty fields in aggregate. I didn't see direct checking for empty fields on PowerPC. So all change needed on PPC seems to be generic. By enabling `AllowNoUniqueAddr` in these methods, case in https://lists.llvm.org/pipermail/llvm-dev/2020-July/143141.html can be correctly recognized as homogeneous aggregate.


I agree that probably the only required change is to set the `AllowNoUniqueAddr` parameter to true in those methods.  Given the discussion with @efriedma above, that may actually happen automatically if we remove the parameter (or default it to true).

In any case, I guess it would still be good to also have test cases for this aspect of the ABI on Power ...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Wed Jul  8 07:20:46 2020
From: cfe-commits at lists.llvm.org (Francesco Petrogalli via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:20:46 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: <7bcfd21e007076d473d7108fb36adfd2@localhost.localdomain>

fpetrogalli marked 2 inline comments as done.
fpetrogalli added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:369
+  if (llvm::is_contained(Features, "+v8.6a")) {
+    if (!llvm::is_contained(Features, "-i8mm") &&
+        !llvm::is_contained(Features, "+noi8mm"))
----------------
sdesmalen wrote:
> Is this correct and/or necessary? I would expect LLVM to just handle features in the order they're passed, and the architecture version is always processed first, e.g. `-march=armv8.6-a+noi8mm` will always first process `armv8.6a` before processing features like `noi8mm`.
I was expecting that too, but in in this place the `+i8mm` is added after whatever the user have passed to -march, which means that without this extra check the user input `-mattr=armv8.6a+sve+noimm8` becomes broken because we are adding `-target-feature=+i8mm` after `-i8mm`.  This behavior is guarded by a regression tests that starts failing if I don't use these extra checks. This was not needed in the original place were I added the functionality because the `+i8mm` was being added right after `+v8.6a` and before splitting up the `+sve+noi8mm`, so that the user input was the one (un)setting the feature.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079




From cfe-commits at lists.llvm.org  Wed Jul  8 07:29:42 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:29:42 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rGea8bba7e8d0d: Fix crash on overloaded postfix unary operators due to invalid sloc (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82954.276427.patch
Type: text/x-patch
Size: 10383 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:29:44 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via cfe-commits)
Date: Wed, 08 Jul 2020 07:29:44 -0700 (PDT)
Subject: [clang] ea8bba7 - Fix crash on overloaded postfix unary operators due
 to invalid sloc
Message-ID: <5f05d858.1c69fb81.afd8b.04a5@mx.google.com>


Author: Eduardo Caldas
Date: 2020-07-08T14:09:40Z
New Revision: ea8bba7e8d0db3541a386ad649c4bf21d53e8380

URL: https://github.com/llvm/llvm-project/commit/ea8bba7e8d0db3541a386ad649c4bf21d53e8380
DIFF: https://github.com/llvm/llvm-project/commit/ea8bba7e8d0db3541a386ad649c4bf21d53e8380.diff

LOG: Fix crash on overloaded postfix unary operators due to invalid sloc

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82954

Added: 
    

Modified: 
    clang/lib/Tooling/Syntax/BuildTree.cpp
    clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 4371a303bb9d..361455e69f5a 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TypeLoc.h"
@@ -114,6 +115,85 @@ struct GetStartLoc : TypeLocVisitor {
 };
 } // namespace
 
+static syntax::NodeKind getOperatorNodeKind(const CXXOperatorCallExpr &E) {
+  switch (E.getOperator()) {
+  // Comparison
+  case OO_EqualEqual:
+  case OO_ExclaimEqual:
+  case OO_Greater:
+  case OO_GreaterEqual:
+  case OO_Less:
+  case OO_LessEqual:
+  case OO_Spaceship:
+  // Assignment
+  case OO_Equal:
+  case OO_SlashEqual:
+  case OO_PercentEqual:
+  case OO_CaretEqual:
+  case OO_PipeEqual:
+  case OO_LessLessEqual:
+  case OO_GreaterGreaterEqual:
+  case OO_PlusEqual:
+  case OO_MinusEqual:
+  case OO_StarEqual:
+  case OO_AmpEqual:
+  // Binary computation
+  case OO_Slash:
+  case OO_Percent:
+  case OO_Caret:
+  case OO_Pipe:
+  case OO_LessLess:
+  case OO_GreaterGreater:
+  case OO_AmpAmp:
+  case OO_PipePipe:
+  case OO_ArrowStar:
+  case OO_Comma:
+    return syntax::NodeKind::BinaryOperatorExpression;
+  case OO_Tilde:
+  case OO_Exclaim:
+    return syntax::NodeKind::PrefixUnaryOperatorExpression;
+  // Prefix/Postfix increment/decrement
+  case OO_PlusPlus:
+  case OO_MinusMinus:
+    switch (E.getNumArgs()) {
+    case 1:
+      return syntax::NodeKind::PrefixUnaryOperatorExpression;
+    case 2:
+      return syntax::NodeKind::PostfixUnaryOperatorExpression;
+    default:
+      llvm_unreachable("Invalid number of arguments for operator");
+    }
+  // Operators that can be unary or binary
+  case OO_Plus:
+  case OO_Minus:
+  case OO_Star:
+  case OO_Amp:
+    switch (E.getNumArgs()) {
+    case 1:
+      return syntax::NodeKind::PrefixUnaryOperatorExpression;
+    case 2:
+      return syntax::NodeKind::BinaryOperatorExpression;
+    default:
+      llvm_unreachable("Invalid number of arguments for operator");
+    }
+    return syntax::NodeKind::BinaryOperatorExpression;
+  // Not yet supported by SyntaxTree
+  case OO_New:
+  case OO_Delete:
+  case OO_Array_New:
+  case OO_Array_Delete:
+  case OO_Coawait:
+  case OO_Call:
+  case OO_Subscript:
+  case OO_Arrow:
+    return syntax::NodeKind::UnknownExpression;
+  case OO_Conditional: // not overloadable
+  case NUM_OVERLOADED_OPERATORS:
+  case OO_None:
+    llvm_unreachable("Not an overloadable operator");
+  }
+}
+
 /// Gets the range of declarator as defined by the C++ grammar. E.g.
 ///     `int a;` -> range of `a`,
 ///     `int *a;` -> range of `*a`,
@@ -733,8 +813,29 @@ class BuildTreeVisitor : public RecursiveASTVisitor {
     return true;
   }
 
+  bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
+    if (getOperatorNodeKind(*S) ==
+        syntax::NodeKind::PostfixUnaryOperatorExpression) {
+      // A postfix unary operator is declared as taking two operands. The second
+      // operand is used to distinguish from its prefix counterpart. In the
+      // semantic AST this "phantom" operand is represented as a
+      // `IntegerLiteral` with invalid `SourceLocation`. We skip visiting this
+      // operand because it does not correspond to anything written in source
+      // code
+      for (auto *child : S->children()) {
+        if (child->getSourceRange().isInvalid())
+          continue;
+        if (!TraverseStmt(child))
+          return false;
+      }
+      return WalkUpFromCXXOperatorCallExpr(S);
+    } else
+      return RecursiveASTVisitor::TraverseCXXOperatorCallExpr(S);
+  }
+
   bool WalkUpFromCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
-    if (S->isInfixBinaryOp()) {
+    switch (getOperatorNodeKind(*S)) {
+    case syntax::NodeKind::BinaryOperatorExpression:
       Builder.markExprChild(
           S->getArg(0),
           syntax::NodeRole::BinaryOperatorExpression_leftHandSide);
@@ -747,8 +848,31 @@ class BuildTreeVisitor : public RecursiveASTVisitor {
       Builder.foldNode(Builder.getExprRange(S),
                        new (allocator()) syntax::BinaryOperatorExpression, S);
       return true;
+    case syntax::NodeKind::PrefixUnaryOperatorExpression:
+      Builder.markChildToken(
+          S->getOperatorLoc(),
+          syntax::NodeRole::OperatorExpression_operatorToken);
+      Builder.markExprChild(S->getArg(0),
+                            syntax::NodeRole::UnaryOperatorExpression_operand);
+      Builder.foldNode(Builder.getExprRange(S),
+                       new (allocator()) syntax::PrefixUnaryOperatorExpression,
+                       S);
+      return true;
+    case syntax::NodeKind::PostfixUnaryOperatorExpression:
+      Builder.markChildToken(
+          S->getOperatorLoc(),
+          syntax::NodeRole::OperatorExpression_operatorToken);
+      Builder.markExprChild(S->getArg(0),
+                            syntax::NodeRole::UnaryOperatorExpression_operand);
+      Builder.foldNode(Builder.getExprRange(S),
+                       new (allocator()) syntax::PostfixUnaryOperatorExpression,
+                       S);
+      return true;
+    case syntax::NodeKind::UnknownExpression:
+      return RecursiveASTVisitor::WalkUpFromCXXOperatorCallExpr(S);
+    default:
+      llvm_unreachable("getOperatorNodeKind() does not return this value");
     }
-    return RecursiveASTVisitor::WalkUpFromCXXOperatorCallExpr(S);
   }
 
   bool WalkUpFromNamespaceDecl(NamespaceDecl *S) {

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 094a495c65a8..acd0fbf2b52e 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -2193,11 +2193,18 @@ struct X {
   X& operator=(const X&);
   friend X operator+(X, const X&);
   friend bool operator<(const X&, const X&);
+  friend X operator<<(X&, const X&);
+  X operator,(X&);
+  // TODO: Fix crash on member function pointer and add a test for `->*`
+  // TODO: Unbox operators in syntax tree. 
+  // Represent operators by `+` instead of `IdExpression-UnqualifiedId-+`
 };
 void test(X x, X y) {
   x = y;
   x + y;
   x < y;
+  x << y;
+  x, y;
 }
 )cpp",
       R"txt(
@@ -2262,6 +2269,40 @@ void test(X x, X y) {
 | |   |   |   `-&
 | |   |   `-)
 | |   `-;
+| |-UnknownDeclaration
+| | `-SimpleDeclaration
+| |   |-friend
+| |   |-X
+| |   |-SimpleDeclarator
+| |   | |-operator
+| |   | |-<<
+| |   | `-ParametersAndQualifiers
+| |   |   |-(
+| |   |   |-SimpleDeclaration
+| |   |   | |-X
+| |   |   | `-SimpleDeclarator
+| |   |   |   `-&
+| |   |   |-,
+| |   |   |-SimpleDeclaration
+| |   |   | |-const
+| |   |   | |-X
+| |   |   | `-SimpleDeclarator
+| |   |   |   `-&
+| |   |   `-)
+| |   `-;
+| |-SimpleDeclaration
+| | |-X
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-,
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   |-SimpleDeclaration
+| | |   | |-X
+| | |   | `-SimpleDeclarator
+| | |   |   `-&
+| | |   `-)
+| | `-;
 | |-}
 | `-;
 `-SimpleDeclaration
@@ -2319,6 +2360,185 @@ void test(X x, X y) {
     | |   `-UnqualifiedId
     | |     `-y
     | `-;
+    |-ExpressionStatement
+    | |-BinaryOperatorExpression
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-x
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-<<
+    | | `-IdExpression
+    | |   `-UnqualifiedId
+    | |     `-y
+    | `-;
+    |-ExpressionStatement
+    | |-BinaryOperatorExpression
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-x
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-,
+    | | `-IdExpression
+    | |   `-UnqualifiedId
+    | |     `-y
+    | `-;
+    `-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UserDefinedUnaryPrefixOperator) {
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+      R"cpp(
+struct X {
+  X operator++();
+  bool operator!();
+  X* operator&();
+};
+void test(X x) {
+  ++x;
+  !x;
+  &x;
+}
+)cpp",
+      R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-X
+| |-{
+| |-SimpleDeclaration
+| | |-X
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-++
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-SimpleDeclaration
+| | |-bool
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-!
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-SimpleDeclaration
+| | |-X
+| | |-SimpleDeclarator
+| | | |-*
+| | | |-operator
+| | | |-&
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-}
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-x
+  |   `-)
+  `-CompoundStatement
+    |-{
+    |-ExpressionStatement
+    | |-PrefixUnaryOperatorExpression
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-++
+    | | `-IdExpression
+    | |   `-UnqualifiedId
+    | |     `-x
+    | `-;
+    |-ExpressionStatement
+    | |-PrefixUnaryOperatorExpression
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-!
+    | | `-IdExpression
+    | |   `-UnqualifiedId
+    | |     `-x
+    | `-;
+    |-ExpressionStatement
+    | |-PrefixUnaryOperatorExpression
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-&
+    | | `-IdExpression
+    | |   `-UnqualifiedId
+    | |     `-x
+    | `-;
+    `-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UserDefinedUnaryPostfixOperator) {
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+      R"cpp(
+struct X {
+  X operator++(int);
+};
+void test(X x) {
+  x++;
+}
+)cpp",
+      R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-X
+| |-{
+| |-SimpleDeclaration
+| | |-X
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-++
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   |-SimpleDeclaration
+| | |   | `-int
+| | |   `-)
+| | `-;
+| |-}
+| `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-x
+  |   `-)
+  `-CompoundStatement
+    |-{
+    |-ExpressionStatement
+    | |-PostfixUnaryOperatorExpression
+    | | |-IdExpression
+    | | | `-UnqualifiedId
+    | | |   `-x
+    | | `-IdExpression
+    | |   `-UnqualifiedId
+    | |     `-++
+    | `-;
     `-}
 )txt"));
 }


        

From cfe-commits at lists.llvm.org  Wed Jul  8 07:33:41 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:33:41 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <0ed58d6b4ebdac10d024400c6179468e@localhost.localdomain>

eduucaldas marked 2 inline comments as done.
eduucaldas added inline comments.


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1265
+    | |-UserDefinedLiteralExpression
+    | | `-12_w
+    | `-;
----------------
gribozavr2 wrote:
> It looks somewhat weird to me that integer and floating point literals end up with the same syntax tree node type. WDYT about making different nodes for different literals (integer, floating-point, string, character)?
Makes sense. Let's follow the [[ https://eel.is/c++draft/lex.ext#nt:user-defined-literal | grammar ]] then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157




From cfe-commits at lists.llvm.org  Wed Jul  8 07:38:08 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:38:08 +0000 (UTC)
Subject: [PATCH] D82954: Fix crash on overloaded postfix unary operators due
 to invalid SourceLocation
In-Reply-To: 
References: 
Message-ID: <25797bf87d25a47f0131cb31988dee69@localhost.localdomain>

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGea8bba7e8d0d: Fix crash on overloaded postfix unary operators due to invalid sloc (authored by eduucaldas).

Changed prior to commit:
  https://reviews.llvm.org/D82954?vs=275318&id=275709#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82954/new/

https://reviews.llvm.org/D82954

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82954.275709.patch
Type: text/x-patch
Size: 10383 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:46:39 2020
From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:46:39 +0000 (UTC)
Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition
 and MC Tests for Load and Store VSX Vector with Zero or Sign Extend
In-Reply-To: 
References: 
Message-ID: 

amyk accepted this revision as: amyk.
amyk added a comment.
This revision is now accepted and ready to land.

This LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83364/new/

https://reviews.llvm.org/D83364




From cfe-commits at lists.llvm.org  Wed Jul  8 07:47:58 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:47:58 +0000 (UTC)
Subject: [PATCH] D83398: [OPENMP50]Perform data mapping analysis only for
 explicitly mapped data.
Message-ID: 

ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

According to OpenMP 5.0, the restrictions for mapping of overlapped data
apply only for explicitly mapped data, there is no restriction for
implicitly mapped data just like in OpenMP 4.5.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83398

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_map_messages.cpp


Index: clang/test/OpenMP/target_map_messages.cpp
===================================================================
--- clang/test/OpenMP/target_map_messages.cpp
+++ clang/test/OpenMP/target_map_messages.cpp
@@ -598,6 +598,7 @@
   const int (&l)[5] = da;
   SC1 s;
   SC1 *p;
+  int Arr[10];
 #pragma omp target data map // expected-error {{expected '(' after 'map'}} le45-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}} le50-error {{expected at least one 'map', 'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}}
 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
 #pragma omp target data map() // expected-error {{expected expression}}
@@ -737,6 +738,12 @@
 #pragma omp target map(release: a) // expected-error {{map type 'release' is not allowed for '#pragma omp target'}}
   {}
 
+#pragma omp target data map(Arr[0:4]) // le45-note {{used here}}
+  {
+#pragma omp target
+    Arr[0] = 2; // le45-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
+  }
+
   return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
 #endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===================================================================
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -17428,6 +17428,7 @@
                           /*CurrentRegionOnly=*/true, CurComponents, CKind))
       break;
     if (CKind == OMPC_map &&
+        (SemaRef.getLangOpts().OpenMP <= 45 || StartLoc.isValid()) &&
         checkMapConflicts(SemaRef, DSAS, CurDeclaration, SimpleExpr,
                           /*CurrentRegionOnly=*/false, CurComponents, CKind))
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83398.276434.patch
Type: text/x-patch
Size: 2033 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:53:26 2020
From: cfe-commits at lists.llvm.org (Sam McCall via cfe-commits)
Date: Wed, 08 Jul 2020 07:53:26 -0700 (PDT)
Subject: [clang-tools-extra] 69c22ed - [clangd] Enable reading config from
 files behind a flag
Message-ID: <5f05dde6.1c69fb81.1b0ba.0513@mx.google.com>


Author: Sam McCall
Date: 2020-07-08T16:48:01+02:00
New Revision: 69c22edb7d30983f1bb9d21154e427ebcc5f699c

URL: https://github.com/llvm/llvm-project/commit/69c22edb7d30983f1bb9d21154e427ebcc5f699c
DIFF: https://github.com/llvm/llvm-project/commit/69c22edb7d30983f1bb9d21154e427ebcc5f699c.diff

LOG: [clangd] Enable reading config from files behind a flag

Reviewers: kadircet, hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83233

Added: 
    

Modified: 
    clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index c77f92d3f183..6e3d6a231da1 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -320,7 +320,7 @@ opt Test{
     "lit-test",
     cat(Misc),
     desc("Abbreviation for -input-style=delimited -pretty -sync "
-         "-enable-test-scheme -log=verbose. "
+         "-enable-test-scheme -enable-config=0 -log=verbose. "
          "Intended to simplify lit tests"),
     init(false),
     Hidden,
@@ -427,6 +427,20 @@ opt AsyncPreamble{
     Hidden,
 };
 
+opt EnableConfig{
+    "enable-config",
+    cat(Misc),
+    desc(
+        "Read user and project configuration from YAML files.\n"
+        "Project config is from a .clangd file in the project directory.\n"
+        "User config is from clangd/config.yaml in the following directories:\n"
+        "\tWindows: %USERPROFILE%\\AppData\\Local\n"
+        "\tMac OS: ~/Library/Preferences/\n"
+        "\tOthers: $XDG_CONFIG_HOME, usually ~/.config\n"
+        "Configuration is documented at https://clangd.llvm.org/config.html"),
+    init(false),
+};
+
 /// Supports a test URI scheme with relaxed constraints for lit tests.
 /// The path in a test URI will be combined with a platform-specific fake
 /// directory to form an absolute path. For example, test:///a.cpp is resolved
@@ -510,6 +524,9 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
     InputStyle = JSONStreamStyle::Delimited;
     LogLevel = Logger::Verbose;
     PrettyPrint = true;
+    // Disable config system by default to avoid external reads.
+    if (!EnableConfig.getNumOccurrences())
+      EnableConfig = false;
     // Disable background index on lit tests by default to prevent disk writes.
     if (!EnableBackgroundIndex.getNumOccurrences())
       EnableBackgroundIndex = false;
@@ -677,6 +694,23 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
   CCOpts.RunParser = CodeCompletionParse;
 
   RealThreadsafeFS TFS;
+  std::unique_ptr Config;
+  if (EnableConfig) {
+    std::vector> ProviderStack;
+    ProviderStack.push_back(
+        config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS));
+    llvm::SmallString<256> UserConfig;
+    if (llvm::sys::path::user_config_directory(UserConfig)) {
+      llvm::sys::path::append(UserConfig, "clangd", "config.yaml");
+      vlog("User config file is {0}", UserConfig);
+      ProviderStack.push_back(config::Provider::fromYAMLFile(UserConfig, TFS));
+    } else {
+      elog("Couldn't determine user config file, not loading");
+    }
+    Config = config::Provider::combine(std::move(ProviderStack));
+    Opts.ConfigProvider = Config.get();
+  }
+
   // Initialize and run ClangdLSPServer.
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();


        

From cfe-commits at lists.llvm.org  Wed Jul  8 07:53:32 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:53:32 +0000 (UTC)
Subject: [PATCH] D83233: [clangd] Enable reading config from files by default.
In-Reply-To: 
References: 
Message-ID: <1c66fdc754523cd350e50fbee40ed0d5@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG69c22edb7d30: [clangd] Enable reading config from files behind a flag (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D83233?vs=275724&id=276437#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83233/new/

https://reviews.llvm.org/D83233

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===================================================================
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -320,7 +320,7 @@
     "lit-test",
     cat(Misc),
     desc("Abbreviation for -input-style=delimited -pretty -sync "
-         "-enable-test-scheme -log=verbose. "
+         "-enable-test-scheme -enable-config=0 -log=verbose. "
          "Intended to simplify lit tests"),
     init(false),
     Hidden,
@@ -427,6 +427,20 @@
     Hidden,
 };
 
+opt EnableConfig{
+    "enable-config",
+    cat(Misc),
+    desc(
+        "Read user and project configuration from YAML files.\n"
+        "Project config is from a .clangd file in the project directory.\n"
+        "User config is from clangd/config.yaml in the following directories:\n"
+        "\tWindows: %USERPROFILE%\\AppData\\Local\n"
+        "\tMac OS: ~/Library/Preferences/\n"
+        "\tOthers: $XDG_CONFIG_HOME, usually ~/.config\n"
+        "Configuration is documented at https://clangd.llvm.org/config.html"),
+    init(false),
+};
+
 /// Supports a test URI scheme with relaxed constraints for lit tests.
 /// The path in a test URI will be combined with a platform-specific fake
 /// directory to form an absolute path. For example, test:///a.cpp is resolved
@@ -510,6 +524,9 @@
     InputStyle = JSONStreamStyle::Delimited;
     LogLevel = Logger::Verbose;
     PrettyPrint = true;
+    // Disable config system by default to avoid external reads.
+    if (!EnableConfig.getNumOccurrences())
+      EnableConfig = false;
     // Disable background index on lit tests by default to prevent disk writes.
     if (!EnableBackgroundIndex.getNumOccurrences())
       EnableBackgroundIndex = false;
@@ -677,6 +694,23 @@
   CCOpts.RunParser = CodeCompletionParse;
 
   RealThreadsafeFS TFS;
+  std::unique_ptr Config;
+  if (EnableConfig) {
+    std::vector> ProviderStack;
+    ProviderStack.push_back(
+        config::Provider::fromAncestorRelativeYAMLFiles(".clangd", TFS));
+    llvm::SmallString<256> UserConfig;
+    if (llvm::sys::path::user_config_directory(UserConfig)) {
+      llvm::sys::path::append(UserConfig, "clangd", "config.yaml");
+      vlog("User config file is {0}", UserConfig);
+      ProviderStack.push_back(config::Provider::fromYAMLFile(UserConfig, TFS));
+    } else {
+      elog("Couldn't determine user config file, not loading");
+    }
+    Config = config::Provider::combine(std::move(ProviderStack));
+    Opts.ConfigProvider = Config.get();
+  }
+
   // Initialize and run ClangdLSPServer.
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83233.276437.patch
Type: text/x-patch
Size: 2763 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:55:54 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:55:54 +0000 (UTC)
Subject: [PATCH] D83315: Turn arcmt-* options into a single option
In-Reply-To: 
References: 
Message-ID: <30fda6527475da530a21587ee6597a3e@localhost.localdomain>

dang updated this revision to Diff 276438.
dang added a comment.

Instead of using a Separate option kind (-arcmt-action action) use a Joined kind (-arcmt-action=*)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83315/new/

https://reviews.llvm.org/D83315

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/ARCMT/GC-check-warn-nsalloc.m
  clang/test/ARCMT/GC-check.m
  clang/test/ARCMT/atautorelease-check.m
  clang/test/ARCMT/check-api.m
  clang/test/ARCMT/check-with-pch.m
  clang/test/ARCMT/check-with-serialized-diag.m
  clang/test/ARCMT/checking-in-arc.m
  clang/test/ARCMT/checking.m
  clang/test/ARCMT/cxx-checking.mm
  clang/test/ARCMT/driver-migrate.m
  clang/test/ARCMT/migrate-emit-errors.m
  clang/test/ARCMT/migrate-plist-output.m
  clang/test/ARCMT/migrate-space-in-path.m
  clang/test/ARCMT/migrate-with-pch.m
  clang/test/ARCMT/migrate.m
  clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
  clang/test/ARCMT/nonobjc-to-objc-cast-2.m
  clang/test/ARCMT/releases-driver.m
  clang/test/ARCMT/releases-driver.m.result
  clang/test/ARCMT/verify.m
  clang/test/ARCMT/with-arc-mode-modify.m
  clang/test/ARCMT/with-arc-mode-modify.m.result
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83315.276438.patch
Type: text/x-patch
Size: 21338 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 07:56:59 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 14:56:59 +0000 (UTC)
Subject: [PATCH] D83371: [clangd] Factor out some helper functions related to
 heuristic resolution in TargetFinder
In-Reply-To: 
References: 
Message-ID: <85bc6c789775da373e501c763cd845fb@localhost.localdomain>

hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks, looks good.



================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:64
+// resolves it to a CXXRecordDecl in which we can try name lookup.
+CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
+  if (auto *ICNT = T->getAs()) {
----------------
nit: add assert(T), or even use `const Type&` as the parameter type.


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:158
+// or more declarations that it likely references.
+std::vector resolveDependentExprToDecls(const Expr *E) {
+  switch (E->getStmtClass()) {
----------------
nit: add  `assert(E->isTypeDepndent())`;




================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:159
+std::vector resolveDependentExprToDecls(const Expr *E) {
+  switch (E->getStmtClass()) {
+  case Stmt::CXXDependentScopeMemberExprClass: {
----------------
nit: looks like the code will be a bit simpler if we just use if branch like 

```
if (const auto * a = dyn_cast(xxxx));
```

but up to you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83371/new/

https://reviews.llvm.org/D83371




From cfe-commits at lists.llvm.org  Wed Jul  8 08:14:34 2020
From: cfe-commits at lists.llvm.org (Kamau Bridgeman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:14:34 +0000 (UTC)
Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition
 and MC Tests for Load and Store VSX Vector with Zero or Sign Extend
In-Reply-To: 
References: 
Message-ID: <526a382a1d5f74d936c924e50dd630d7@localhost.localdomain>

kamaub accepted this revision.
kamaub added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83364/new/

https://reviews.llvm.org/D83364




From cfe-commits at lists.llvm.org  Wed Jul  8 08:15:22 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits)
Date: Wed, 08 Jul 2020 15:15:22 +0000 (UTC)
Subject: [PATCH] D83087: DomTree: remove explicit use of
 DomTreeNodeBase::iterator
In-Reply-To: 
References: 
Message-ID: <6e51ef276d884aed7596bc4eca51c1f9@localhost.localdomain>

nhaehnle added a comment.

In D83087#2134881 , @kuhar wrote:

> modulo accidental formatting changes.


I'm not aware of any. Some line breaks changed because "const_iterator" is longer than "iterator".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83087/new/

https://reviews.llvm.org/D83087




From cfe-commits at lists.llvm.org  Wed Jul  8 08:15:38 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:15:38 +0000 (UTC)
Subject: [PATCH] D82739: Improve heuristic resolution of dependent types in
 TargetFinder
In-Reply-To: 
References: 
Message-ID: <735e2e6cf4f68ca2fcd14c30e5be3c2e@localhost.localdomain>

hokein added a comment.

In D82739#2138260 , @nridge wrote:

> In D82739#2133155 , @hokein wrote:
>
> > looks like we use this heuristic for go-to-def, I think we might want to use it in more places, e.g.  libindex (for xrefs), sema code completion (so that `this->a.^` can suggest something).
>
>
> Yeah, this is a great point. I would definitely like to reuse this heuristic resolution for other features like code completion (including in https://github.com/clangd/clangd/issues/443 where I hope to build on it to improve the original STR which involves completion).
>
> I will explore relocating this code to a place where things like code completion can reuse it, in a follow-up patch.


thanks, this sounds a good plan.



================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:196
   switch (E->getStmtClass()) {
   case Stmt::CXXDependentScopeMemberExprClass: {
     const auto *ME = llvm::cast(E);
----------------
I'm doubting whether we will miss some other exprs, since we are using it to find the decls for the base expr of `CXXDependentScopeMemberExpr`. 

could you try the following testcase (also add it to the unittest)?

```
struct A {
  void foo() {}
};
struct B {
  A getA();
};

template  struct C {
  C c;

  void bar() { this->c.getA().foo(); }
};
```


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:198
+    // analyzing it.
+    if (E && BT->getKind() == BuiltinType::Dependent) {
+      T = resolveDependentExprToType(E);
----------------
nridge wrote:
> hokein wrote:
> > I think this is the key point of the fix?
> > 
> > It would be nice if you could find a way to split it into two (one for refactoring, one for the fix). The diff of this patch contains large chunk of refactoring changes which make the fix less obvious.
> Yeah, sorry about that. I've split the patch and cleaned it up further (to avoid unnecessary reordering of functions) to make the diff neater.
it looks better now, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82739/new/

https://reviews.llvm.org/D82739




From cfe-commits at lists.llvm.org  Wed Jul  8 08:25:45 2020
From: cfe-commits at lists.llvm.org (via cfe-commits)
Date: Wed, 08 Jul 2020 08:25:45 -0700 (PDT)
Subject: [clang] 6aab27b - [OpenMPIRBuilder][Fix] Move llvm::omp::types to
 OpenMPIRBuilder.
Message-ID: <5f05e579.1c69fb81.c0b9c.0790@mx.google.com>


Author: sstefan1
Date: 2020-07-08T17:23:55+02:00
New Revision: 6aab27ba851f132f01ea8e87f92243918dc23cfd

URL: https://github.com/llvm/llvm-project/commit/6aab27ba851f132f01ea8e87f92243918dc23cfd
DIFF: https://github.com/llvm/llvm-project/commit/6aab27ba851f132f01ea8e87f92243918dc23cfd.diff

LOG: [OpenMPIRBuilder][Fix] Move llvm::omp::types to OpenMPIRBuilder.

Summary:
D82193 exposed a problem with global type definitions in
`OMPConstants.h`. This causes a race when running in thinLTO mode.
Types now live inside of OpenMPIRBuilder to prevent this from happening.

Reviewers: jdoerfert

Subscribers: yaxunl, hiraditya, guansong, dexonsmith, aaron.ballman, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D83176

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDecl.cpp
    clang/lib/CodeGen/CGExpr.cpp
    clang/lib/CodeGen/CGOpenMPRuntime.cpp
    clang/lib/CodeGen/CGOpenMPRuntime.h
    clang/lib/CodeGen/CGStmtOpenMP.cpp
    clang/lib/CodeGen/CodeGenFunction.cpp
    clang/lib/CodeGen/CodeGenModule.cpp
    clang/lib/CodeGen/CodeGenModule.h
    llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
    llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
    llvm/lib/Frontend/OpenMP/OMPConstants.cpp
    llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 09593531af83..1729c7ed3c31 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1401,7 +1401,7 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
   Address address = Address::invalid();
   Address AllocaAddr = Address::invalid();
   Address OpenMPLocalAddr = Address::invalid();
-  if (CGM.getOpenMPIRBuilder())
+  if (CGM.getLangOpts().OpenMPIRBuilder)
     OpenMPLocalAddr = OMPBuilderCBHelpers::getAddressOfLocalVariable(*this, &D);
   else
     OpenMPLocalAddr =

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2547690ed3a3..be5d976f346c 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2398,7 +2398,7 @@ EmitBitCastOfLValueToProperType(CodeGenFunction &CGF,
 static LValue EmitThreadPrivateVarDeclLValue(
     CodeGenFunction &CGF, const VarDecl *VD, QualType T, Address Addr,
     llvm::Type *RealVarTy, SourceLocation Loc) {
-  if (CGF.CGM.getOpenMPIRBuilder())
+  if (CGF.CGM.getLangOpts().OpenMPIRBuilder)
     Addr = CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
         CGF, VD, Addr, Loc);
   else

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 858dbbf81f20..fb2ce60f2e41 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1060,7 +1060,7 @@ static FieldDecl *addFieldToRecordDecl(ASTContext &C, DeclContext *DC,
 CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator,
                                  StringRef Separator)
     : CGM(CGM), FirstSeparator(FirstSeparator), Separator(Separator),
-      OffloadEntriesInfoManager(CGM) {
+      OMPBuilder(CGM.getModule()), OffloadEntriesInfoManager(CGM) {
   ASTContext &C = CGM.getContext();
   RecordDecl *RD = C.buildImplicitRecord("ident_t");
   QualType KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1);
@@ -1081,7 +1081,7 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator,
   KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
 
   // Initialize Types used in OpenMPIRBuilder from OMPKinds.def
-  llvm::omp::types::initializeTypes(CGM.getModule());
+  OMPBuilder.initialize();
   loadOffloadInfoMetadata();
 }
 
@@ -1278,8 +1278,8 @@ static llvm::Function *emitParallelOrTeamsOutlinedFunction(
 
   // TODO: Temporarily inform the OpenMPIRBuilder, if any, about the new
   //       parallel region to make cancellation barriers work properly.
-  llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder();
-  PushAndPopStackRAII PSR(OMPBuilder, CGF, HasCancel);
+  llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
+  PushAndPopStackRAII PSR(&OMPBuilder, CGF, HasCancel);
   CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind,
                                     HasCancel, OutlinedHelperName);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
@@ -1316,7 +1316,7 @@ llvm::Function *CGOpenMPRuntime::emitTaskOutlinedFunction(
         CGF.EmitLoadOfPointerLValue(CGF.GetAddrOfLocalVar(TaskTVar),
                                     TaskTVar->getType()->castAs())
             .getPointer(CGF)};
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_omp_task),
                         TaskArgs);
   };
@@ -1563,8 +1563,8 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
   CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
   CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
   llvm::CallInst *Call = CGF.Builder.CreateCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___kmpc_global_thread_num),
+      OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                            OMPRTL___kmpc_global_thread_num),
       emitUpdateLocation(CGF, Loc));
   Call->setCallingConv(CGF.getRuntimeCC());
   Elem.second.ThreadID = Call;
@@ -1783,7 +1783,7 @@ Address CGOpenMPRuntime::getAddrOfThreadPrivate(CodeGenFunction &CGF,
                          CGM.getSize(CGM.GetTargetTypeStoreSize(VarTy)),
                          getOrCreateThreadPrivateCache(VD)};
   return Address(CGF.EmitRuntimeCall(
-                     llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                     OMPBuilder.getOrCreateRuntimeFunction(
                          CGM.getModule(), OMPRTL___kmpc_threadprivate_cached),
                      Args),
                  VDAddr.getAlignment());
@@ -1795,7 +1795,7 @@ void CGOpenMPRuntime::emitThreadPrivateVarInit(
   // Call kmp_int32 __kmpc_global_thread_num(&loc) to init OpenMP runtime
   // library.
   llvm::Value *OMPLoc = emitUpdateLocation(CGF, Loc);
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_global_thread_num),
                       OMPLoc);
   // Call __kmpc_threadprivate_register(&loc, &var, ctor, cctor/*NULL*/, dtor)
@@ -1804,7 +1804,7 @@ void CGOpenMPRuntime::emitThreadPrivateVarInit(
       OMPLoc, CGF.Builder.CreatePointerCast(VDAddr.getPointer(), CGM.VoidPtrTy),
       Ctor, CopyCtor, Dtor};
   CGF.EmitRuntimeCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      OMPBuilder.getOrCreateRuntimeFunction(
           CGM.getModule(), OMPRTL___kmpc_threadprivate_register),
       Args);
 }
@@ -2068,7 +2068,7 @@ Address CGOpenMPRuntime::getAddrOfArtificialThreadPrivate(CodeGenFunction &CGF,
   return Address(
       CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
           CGF.EmitRuntimeCall(
-              llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+              OMPBuilder.getOrCreateRuntimeFunction(
                   CGM.getModule(), OMPRTL___kmpc_threadprivate_cached),
               Args),
           VarLVType->getPointerTo(/*AddrSpace=*/0)),
@@ -2122,8 +2122,8 @@ void CGOpenMPRuntime::emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
     return;
   llvm::Value *RTLoc = emitUpdateLocation(CGF, Loc);
   auto &M = CGM.getModule();
-  auto &&ThenGen = [&M, OutlinedFn, CapturedVars, RTLoc](CodeGenFunction &CGF,
-                                                         PrePostActionTy &) {
+  auto &&ThenGen = [&M, OutlinedFn, CapturedVars, RTLoc,
+                    this](CodeGenFunction &CGF, PrePostActionTy &) {
     // Build call __kmpc_fork_call(loc, n, microtask, var1, .., varn);
     CGOpenMPRuntime &RT = CGF.CGM.getOpenMPRuntime();
     llvm::Value *Args[] = {
@@ -2135,18 +2135,17 @@ void CGOpenMPRuntime::emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
     RealArgs.append(CapturedVars.begin(), CapturedVars.end());
 
     llvm::FunctionCallee RTLFn =
-        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-            M, OMPRTL___kmpc_fork_call);
+        OMPBuilder.getOrCreateRuntimeFunction(M, OMPRTL___kmpc_fork_call);
     CGF.EmitRuntimeCall(RTLFn, RealArgs);
   };
-  auto &&ElseGen = [&M, OutlinedFn, CapturedVars, RTLoc,
-                    Loc](CodeGenFunction &CGF, PrePostActionTy &) {
+  auto &&ElseGen = [&M, OutlinedFn, CapturedVars, RTLoc, Loc,
+                    this](CodeGenFunction &CGF, PrePostActionTy &) {
     CGOpenMPRuntime &RT = CGF.CGM.getOpenMPRuntime();
     llvm::Value *ThreadID = RT.getThreadID(CGF, Loc);
     // Build calls:
     // __kmpc_serialized_parallel(&Loc, GTid);
     llvm::Value *Args[] = {RTLoc, ThreadID};
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             M, OMPRTL___kmpc_serialized_parallel),
                         Args);
 
@@ -2165,7 +2164,7 @@ void CGOpenMPRuntime::emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
 
     // __kmpc_end_serialized_parallel(&Loc, GTid);
     llvm::Value *EndArgs[] = {RT.emitUpdateLocation(CGF, Loc), ThreadID};
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             M, OMPRTL___kmpc_end_serialized_parallel),
                         EndArgs);
   };
@@ -2284,12 +2283,12 @@ void CGOpenMPRuntime::emitCriticalRegion(CodeGenFunction &CGF,
         CGF.EmitScalarExpr(Hint), CGM.Int32Ty, /*isSigned=*/false));
   }
   CommonActionTy Action(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      OMPBuilder.getOrCreateRuntimeFunction(
           CGM.getModule(),
           Hint ? OMPRTL___kmpc_critical_with_hint : OMPRTL___kmpc_critical),
       EnterArgs,
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___kmpc_end_critical),
+      OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                            OMPRTL___kmpc_end_critical),
       Args);
   CriticalOpGen.setAction(Action);
   emitInlinedDirective(CGF, OMPD_critical, CriticalOpGen);
@@ -2306,10 +2305,10 @@ void CGOpenMPRuntime::emitMasterRegion(CodeGenFunction &CGF,
   // }
   // Prepare arguments and build a call to __kmpc_master
   llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
-  CommonActionTy Action(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CommonActionTy Action(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_master),
                         Args,
-                        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                        OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_end_master),
                         Args,
                         /*Conditional=*/true);
@@ -2322,15 +2321,14 @@ void CGOpenMPRuntime::emitTaskyieldCall(CodeGenFunction &CGF,
                                         SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
     return;
-  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
-  if (OMPBuilder) {
-    OMPBuilder->CreateTaskyield(CGF.Builder);
+  if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
+    OMPBuilder.CreateTaskyield(CGF.Builder);
   } else {
     // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
     llvm::Value *Args[] = {
         emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
         llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)};
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_omp_taskyield),
                         Args);
   }
@@ -2349,10 +2347,10 @@ void CGOpenMPRuntime::emitTaskgroupRegion(CodeGenFunction &CGF,
   // __kmpc_end_taskgroup(ident_t *, gtid);
   // Prepare arguments and build a call to __kmpc_taskgroup
   llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
-  CommonActionTy Action(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CommonActionTy Action(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_taskgroup),
                         Args,
-                        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                        OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_end_taskgroup),
                         Args);
   TaskgroupOpGen.setAction(Action);
@@ -2459,10 +2457,10 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
   }
   // Prepare arguments and build a call to __kmpc_single
   llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
-  CommonActionTy Action(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CommonActionTy Action(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_single),
                         Args,
-                        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                        OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_end_single),
                         Args,
                         /*Conditional=*/true);
@@ -2509,7 +2507,7 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
         CpyFn,                        // void (*) (void *, void *) 
         DidItVal                      // i32 did_it
     };
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_copyprivate),
                         Args);
   }
@@ -2526,10 +2524,10 @@ void CGOpenMPRuntime::emitOrderedRegion(CodeGenFunction &CGF,
   // Prepare arguments and build a call to __kmpc_ordered
   if (IsThreads) {
     llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
-    CommonActionTy Action(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CommonActionTy Action(OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_ordered),
                           Args,
-                          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                          OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_end_ordered),
                           Args);
     OrderedOpGen.setAction(Action);
@@ -2578,9 +2576,8 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
   // Check if we should use the OMPBuilder
   auto *OMPRegionInfo =
       dyn_cast_or_null(CGF.CapturedStmtInfo);
-  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
-  if (OMPBuilder) {
-    CGF.Builder.restoreIP(OMPBuilder->CreateBarrier(
+  if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
+    CGF.Builder.restoreIP(OMPBuilder.CreateBarrier(
         CGF.Builder, Kind, ForceSimpleCall, EmitChecks));
     return;
   }
@@ -2597,8 +2594,8 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
   if (OMPRegionInfo) {
     if (!ForceSimpleCall && OMPRegionInfo->hasCancel()) {
       llvm::Value *Result = CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-              CGM.getModule(), OMPRTL___kmpc_cancel_barrier),
+          OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                                OMPRTL___kmpc_cancel_barrier),
           Args);
       if (EmitChecks) {
         // if (__kmpc_cancel_barrier()) {
@@ -2618,7 +2615,7 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
       return;
     }
   }
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_barrier),
                       Args);
 }
@@ -2870,7 +2867,7 @@ void CGOpenMPRuntime::emitForStaticFinish(CodeGenFunction &CGF,
                                    : OMP_IDENT_WORK_SECTIONS),
       getThreadID(CGF, Loc)};
   auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_for_static_fini),
                       Args);
 }
@@ -2919,7 +2916,7 @@ void CGOpenMPRuntime::emitNumThreadsClause(CodeGenFunction &CGF,
   llvm::Value *Args[] = {
       emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
       CGF.Builder.CreateIntCast(NumThreads, CGF.Int32Ty, /*isSigned*/ true)};
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_push_num_threads),
                       Args);
 }
@@ -2934,21 +2931,20 @@ void CGOpenMPRuntime::emitProcBindClause(CodeGenFunction &CGF,
   llvm::Value *Args[] = {
       emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
       llvm::ConstantInt::get(CGM.IntTy, unsigned(ProcBind), /*isSigned=*/true)};
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_push_proc_bind),
                       Args);
 }
 
 void CGOpenMPRuntime::emitFlush(CodeGenFunction &CGF, ArrayRef,
                                 SourceLocation Loc, llvm::AtomicOrdering AO) {
-  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
-  if (OMPBuilder) {
-    OMPBuilder->CreateFlush(CGF.Builder);
+  if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
+    OMPBuilder.CreateFlush(CGF.Builder);
   } else {
     if (!CGF.HaveInsertPoint())
       return;
     // Build call void __kmpc_flush(ident_t *loc)
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_flush),
                         emitUpdateLocation(CGF, Loc));
   }
@@ -4302,12 +4298,12 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
       DeviceID = CGF.Builder.getInt64(OMP_DEVICEID_UNDEF);
     AllocArgs.push_back(DeviceID);
     NewTask = CGF.EmitRuntimeCall(
-        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+        OMPBuilder.getOrCreateRuntimeFunction(
             CGM.getModule(), OMPRTL___kmpc_omp_target_task_alloc),
         AllocArgs);
   } else {
     NewTask =
-        CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+        CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                                 CGM.getModule(), OMPRTL___kmpc_omp_task_alloc),
                             AllocArgs);
   }
@@ -4324,7 +4320,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
     llvm::Value *Tid = getThreadID(CGF, DC->getBeginLoc());
     Tid = CGF.Builder.CreateIntCast(Tid, CGF.IntTy, /*isSigned=*/false);
     llvm::Value *EvtVal = CGF.EmitRuntimeCall(
-        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+        OMPBuilder.getOrCreateRuntimeFunction(
             CGM.getModule(), OMPRTL___kmpc_task_allow_completion_event),
         {Loc, Tid, NewTask});
     EvtVal = CGF.EmitScalarConversion(EvtVal, C.VoidPtrTy, Evt->getType(),
@@ -4463,7 +4459,7 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
     // FIXME: Emit the function and ignore its result for now unless the
     // runtime function is properly implemented.
     (void)CGF.EmitRuntimeCall(
-        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+        OMPBuilder.getOrCreateRuntimeFunction(
             CGM.getModule(), OMPRTL___kmpc_omp_reg_task_with_affinity),
         {LocRef, GTid, NewTask, NumOfElements, AffinListPtr});
   }
@@ -4966,7 +4962,7 @@ Address CGOpenMPRuntime::emitDepobjDependClause(
   llvm::Value *Args[] = {ThreadID, Size, Allocator};
 
   llvm::Value *Addr =
-      CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_alloc),
                           Args, ".dep.arr.addr");
   Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
@@ -5019,7 +5015,7 @@ void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction &CGF, LValue DepobjLVal,
   llvm::Value *Args[] = {ThreadID, DepObjAddr, Allocator};
 
   // _kmpc_free(gtid, addr, nullptr);
-  (void)CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  (void)CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                                 CGM.getModule(), OMPRTL___kmpc_free),
                             Args);
 }
@@ -5120,11 +5116,11 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
     }
     if (!Data.Dependences.empty()) {
       CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+          OMPBuilder.getOrCreateRuntimeFunction(
               CGM.getModule(), OMPRTL___kmpc_omp_task_with_deps),
           DepTaskArgs);
     } else {
-      CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_omp_task),
                           TaskArgs);
     }
@@ -5144,8 +5140,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
     DepWaitTaskArgs[5] = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
   }
   auto &M = CGM.getModule();
-  auto &&ElseCodeGen = [&M, &TaskArgs, ThreadID, NewTaskNewTaskTTy, TaskEntry,
-                        &Data, &DepWaitTaskArgs,
+  auto &&ElseCodeGen = [this, &M, &TaskArgs, ThreadID, NewTaskNewTaskTTy,
+                        TaskEntry, &Data, &DepWaitTaskArgs,
                         Loc](CodeGenFunction &CGF, PrePostActionTy &) {
     CodeGenFunction::RunCleanupsScope LocalScope(CGF);
     // Build void __kmpc_omp_wait_deps(ident_t *, kmp_int32 gtid,
@@ -5153,9 +5149,9 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
     // ndeps_noalias, kmp_depend_info_t *noalias_dep_list); if dependence info
     // is specified.
     if (!Data.Dependences.empty())
-      CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-                              M, OMPRTL___kmpc_omp_wait_deps),
-                          DepWaitTaskArgs);
+      CGF.EmitRuntimeCall(
+          OMPBuilder.getOrCreateRuntimeFunction(M, OMPRTL___kmpc_omp_wait_deps),
+          DepWaitTaskArgs);
     // Call proxy_task_entry(gtid, new_task);
     auto &&CodeGen = [TaskEntry, ThreadID, NewTaskNewTaskTTy,
                       Loc](CodeGenFunction &CGF, PrePostActionTy &Action) {
@@ -5170,10 +5166,10 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
     // Build void __kmpc_omp_task_complete_if0(ident_t *, kmp_int32 gtid,
     // kmp_task_t *new_task);
     RegionCodeGenTy RCG(CodeGen);
-    CommonActionTy Action(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CommonActionTy Action(OMPBuilder.getOrCreateRuntimeFunction(
                               M, OMPRTL___kmpc_omp_task_begin_if0),
                           TaskArgs,
-                          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                          OMPBuilder.getOrCreateRuntimeFunction(
                               M, OMPRTL___kmpc_omp_task_complete_if0),
                           TaskArgs);
     RCG.setAction(Action);
@@ -5269,7 +5265,7 @@ void CGOpenMPRuntime::emitTaskLoopCall(CodeGenFunction &CGF, SourceLocation Loc,
       Result.TaskDupFn ? CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
                              Result.TaskDupFn, CGF.VoidPtrTy)
                        : llvm::ConstantPointerNull::get(CGF.VoidPtrTy)};
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_taskloop),
                       TaskArgs);
 }
@@ -5613,7 +5609,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
       Lock         // kmp_critical_name *&
   };
   llvm::Value *Res = CGF.EmitRuntimeCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      OMPBuilder.getOrCreateRuntimeFunction(
           CGM.getModule(),
           WithNowait ? OMPRTL___kmpc_reduce_nowait : OMPRTL___kmpc_reduce),
       Args);
@@ -5656,7 +5652,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
   RegionCodeGenTy RCG(CodeGen);
   CommonActionTy Action(
       nullptr, llvm::None,
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      OMPBuilder.getOrCreateRuntimeFunction(
           CGM.getModule(), WithNowait ? OMPRTL___kmpc_end_reduce_nowait
                                       : OMPRTL___kmpc_end_reduce),
       EndArgs);
@@ -5781,7 +5777,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
         Lock       // kmp_critical_name *&
     };
     CommonActionTy Action(nullptr, llvm::None,
-                          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+                          OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_end_reduce),
                           EndArgs);
     AtomicRCG.setAction(Action);
@@ -6121,7 +6117,7 @@ llvm::Value *CGOpenMPRuntime::emitTaskReductionInit(
         CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
             TaskRedInput.getPointer(), CGM.VoidPtrTy)};
     return CGF.EmitRuntimeCall(
-        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+        OMPBuilder.getOrCreateRuntimeFunction(
             CGM.getModule(), OMPRTL___kmpc_taskred_modifier_init),
         Args);
   }
@@ -6132,7 +6128,7 @@ llvm::Value *CGOpenMPRuntime::emitTaskReductionInit(
       llvm::ConstantInt::get(CGM.IntTy, Size, /*isSigned=*/true),
       CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(TaskRedInput.getPointer(),
                                                       CGM.VoidPtrTy)};
-  return CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  return CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                                  CGM.getModule(), OMPRTL___kmpc_taskred_init),
                              Args);
 }
@@ -6150,7 +6146,7 @@ void CGOpenMPRuntime::emitTaskReductionFini(CodeGenFunction &CGF,
                                                 IsWorksharingReduction ? 1 : 0,
                                                 /*isSigned=*/true)};
   (void)CGF.EmitRuntimeCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      OMPBuilder.getOrCreateRuntimeFunction(
           CGM.getModule(), OMPRTL___kmpc_task_reduction_modifier_fini),
       Args);
 }
@@ -6186,7 +6182,7 @@ Address CGOpenMPRuntime::getTaskReductionItem(CodeGenFunction &CGF,
                              SharedLVal.getPointer(CGF), CGM.VoidPtrTy)};
   return Address(
       CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+          OMPBuilder.getOrCreateRuntimeFunction(
               CGM.getModule(), OMPRTL___kmpc_task_reduction_get_th_data),
           Args),
       SharedLVal.getAlignment());
@@ -6197,15 +6193,14 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction &CGF,
   if (!CGF.HaveInsertPoint())
     return;
 
-  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
-  if (OMPBuilder) {
-    OMPBuilder->CreateTaskwait(CGF.Builder);
+  if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
+    OMPBuilder.CreateTaskwait(CGF.Builder);
   } else {
     // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
     // global_tid);
     llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
     // Ignore return result until untied tasks are supported.
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___kmpc_omp_taskwait),
                         Args);
   }
@@ -6266,7 +6261,7 @@ void CGOpenMPRuntime::emitCancellationPointCall(
           CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
       // Ignore return result until untied tasks are supported.
       llvm::Value *Result = CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+          OMPBuilder.getOrCreateRuntimeFunction(
               CGM.getModule(), OMPRTL___kmpc_cancellationpoint),
           Args);
       // if (__kmpc_cancellationpoint()) {
@@ -6296,17 +6291,15 @@ void CGOpenMPRuntime::emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc,
   auto &M = CGM.getModule();
   if (auto *OMPRegionInfo =
           dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-    auto &&ThenGen = [&M, Loc, CancelRegion,
+    auto &&ThenGen = [this, &M, Loc, CancelRegion,
                       OMPRegionInfo](CodeGenFunction &CGF, PrePostActionTy &) {
       CGOpenMPRuntime &RT = CGF.CGM.getOpenMPRuntime();
       llvm::Value *Args[] = {
           RT.emitUpdateLocation(CGF, Loc), RT.getThreadID(CGF, Loc),
           CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
       // Ignore return result until untied tasks are supported.
-      llvm::Value *Result =
-          CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-                                  M, OMPRTL___kmpc_cancel),
-                              Args);
+      llvm::Value *Result = CGF.EmitRuntimeCall(
+          OMPBuilder.getOrCreateRuntimeFunction(M, OMPRTL___kmpc_cancel), Args);
       // if (__kmpc_cancel()) {
       //   exit from construct;
       // }
@@ -6402,7 +6395,7 @@ void CGOpenMPRuntime::emitUsesAllocatorsInit(CodeGenFunction &CGF,
       CGF.EmitLoadOfScalar(AllocatorTraitsLVal, AllocatorTraits->getExprLoc());
 
   llvm::Value *AllocatorVal =
-      CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_init_allocator),
                           {ThreadId, MemSpaceHandle, NumTraits, Traits});
   // Store to allocator.
@@ -6426,8 +6419,8 @@ void CGOpenMPRuntime::emitUsesAllocatorsFini(CodeGenFunction &CGF,
                                           CGF.getContext().VoidPtrTy,
                                           Allocator->getExprLoc());
   (void)CGF.EmitRuntimeCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___kmpc_destroy_allocator),
+      OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                            OMPRTL___kmpc_destroy_allocator),
       {ThreadId, AllocatorVal});
 }
 
@@ -9068,8 +9061,8 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
   // pre-existing components.
   llvm::Value *OffloadingArgs[] = {Handle};
   llvm::Value *PreviousSize = MapperCGF.EmitRuntimeCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___tgt_mapper_num_components),
+      OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                            OMPRTL___tgt_mapper_num_components),
       OffloadingArgs);
   llvm::Value *ShiftedPreviousSize = MapperCGF.Builder.CreateShl(
       PreviousSize,
@@ -9176,7 +9169,7 @@ void CGOpenMPRuntime::emitUserDefinedMapper(const OMPDeclareMapperDecl *D,
     llvm::Value *OffloadingArgs[] = {Handle, CurBaseArg, CurBeginArg,
                                      CurSizeArg, CurMapType};
     MapperCGF.EmitRuntimeCall(
-        llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+        OMPBuilder.getOrCreateRuntimeFunction(
             CGM.getModule(), OMPRTL___tgt_push_mapper_component),
         OffloadingArgs);
   }
@@ -9258,8 +9251,8 @@ void CGOpenMPRuntime::emitUDMapperArrayInitOrDel(
   // data structure.
   llvm::Value *OffloadingArgs[] = {Handle, Base, Begin, ArraySize, MapTypeArg};
   MapperCGF.EmitRuntimeCall(
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___tgt_push_mapper_component),
+      OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                            OMPRTL___tgt_push_mapper_component),
       OffloadingArgs);
 }
 
@@ -9282,7 +9275,7 @@ void CGOpenMPRuntime::emitTargetNumIterationsCall(
     if (llvm::Value *NumIterations = SizeEmitter(CGF, *LD)) {
       llvm::Value *Args[] = {DeviceID, NumIterations};
       CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+          OMPBuilder.getOrCreateRuntimeFunction(
               CGM.getModule(), OMPRTL___kmpc_push_target_tripcount),
           Args);
     }
@@ -9411,7 +9404,7 @@ void CGOpenMPRuntime::emitTargetCall(
                                        NumTeams,
                                        NumThreads};
       Return = CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+          OMPBuilder.getOrCreateRuntimeFunction(
               CGM.getModule(), HasNowait ? OMPRTL___tgt_target_teams_nowait
                                          : OMPRTL___tgt_target_teams),
           OffloadingArgs);
@@ -9424,7 +9417,7 @@ void CGOpenMPRuntime::emitTargetCall(
                                        InputInfo.SizesArray.getPointer(),
                                        MapTypesArray};
       Return = CGF.EmitRuntimeCall(
-          llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+          OMPBuilder.getOrCreateRuntimeFunction(
               CGM.getModule(),
               HasNowait ? OMPRTL___tgt_target_nowait : OMPRTL___tgt_target),
           OffloadingArgs);
@@ -10060,7 +10053,7 @@ llvm::Function *CGOpenMPRuntime::emitRequiresDirectiveRegFun() {
            "Target or declare target region expected.");
     if (HasRequiresUnifiedSharedMemory)
       Flags = OMP_REQ_UNIFIED_SHARED_MEMORY;
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___tgt_register_requires),
                         llvm::ConstantInt::get(CGM.Int64Ty, Flags));
     CGF.FinishFunction();
@@ -10088,9 +10081,8 @@ void CGOpenMPRuntime::emitTeamsCall(CodeGenFunction &CGF,
   RealArgs.append(std::begin(Args), std::end(Args));
   RealArgs.append(CapturedVars.begin(), CapturedVars.end());
 
-  llvm::FunctionCallee RTLFn =
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___kmpc_fork_teams);
+  llvm::FunctionCallee RTLFn = OMPBuilder.getOrCreateRuntimeFunction(
+      CGM.getModule(), OMPRTL___kmpc_fork_teams);
   CGF.EmitRuntimeCall(RTLFn, RealArgs);
 }
 
@@ -10118,7 +10110,7 @@ void CGOpenMPRuntime::emitNumTeamsClause(CodeGenFunction &CGF,
   // Build call __kmpc_push_num_teamss(&loc, global_tid, num_teams, thread_limit)
   llvm::Value *PushNumTeamsArgs[] = {RTLoc, getThreadID(CGF, Loc), NumTeamsVal,
                                      ThreadLimitVal};
-  CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                           CGM.getModule(), OMPRTL___kmpc_push_num_teams),
                       PushNumTeamsArgs);
 }
@@ -10173,7 +10165,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
     llvm::Value *OffloadingArgs[] = {
         DeviceID,         PointerNum,    BasePointersArrayArg,
         PointersArrayArg, SizesArrayArg, MapTypesArrayArg};
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___tgt_target_data_begin),
                         OffloadingArgs);
 
@@ -10210,7 +10202,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
     llvm::Value *OffloadingArgs[] = {
         DeviceID,         PointerNum,    BasePointersArrayArg,
         PointersArrayArg, SizesArrayArg, MapTypesArrayArg};
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+    CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                             CGM.getModule(), OMPRTL___tgt_target_data_end),
                         OffloadingArgs);
   };
@@ -10372,9 +10364,9 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
       llvm_unreachable("Unexpected standalone target data directive.");
       break;
     }
-    CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-                            CGM.getModule(), RTLFn),
-                        OffloadingArgs);
+    CGF.EmitRuntimeCall(
+        OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(), RTLFn),
+        OffloadingArgs);
   };
 
   auto &&TargetThenGen = [this, &ThenGen, &D, &InputInfo, &MapTypesArray](
@@ -11065,15 +11057,13 @@ void CGOpenMPRuntime::emitDoacrossInit(CodeGenFunction &CGF,
           CGF.Builder.CreateConstArrayGEP(DimsAddr, 0).getPointer(),
           CGM.VoidPtrTy)};
 
-  llvm::FunctionCallee RTLFn =
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___kmpc_doacross_init);
+  llvm::FunctionCallee RTLFn = OMPBuilder.getOrCreateRuntimeFunction(
+      CGM.getModule(), OMPRTL___kmpc_doacross_init);
   CGF.EmitRuntimeCall(RTLFn, Args);
   llvm::Value *FiniArgs[DoacrossCleanupTy::DoacrossFinArgs] = {
       emitUpdateLocation(CGF, D.getEndLoc()), getThreadID(CGF, D.getEndLoc())};
-  llvm::FunctionCallee FiniRTLFn =
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-          CGM.getModule(), OMPRTL___kmpc_doacross_fini);
+  llvm::FunctionCallee FiniRTLFn = OMPBuilder.getOrCreateRuntimeFunction(
+      CGM.getModule(), OMPRTL___kmpc_doacross_fini);
   CGF.EHStack.pushCleanup(NormalAndEHCleanup, FiniRTLFn,
                                              llvm::makeArrayRef(FiniArgs));
 }
@@ -11101,12 +11091,12 @@ void CGOpenMPRuntime::emitDoacrossOrdered(CodeGenFunction &CGF,
       CGF.Builder.CreateConstArrayGEP(CntAddr, 0).getPointer()};
   llvm::FunctionCallee RTLFn;
   if (C->getDependencyKind() == OMPC_DEPEND_source) {
-    RTLFn = llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-        CGM.getModule(), OMPRTL___kmpc_doacross_post);
+    RTLFn = OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                                  OMPRTL___kmpc_doacross_post);
   } else {
     assert(C->getDependencyKind() == OMPC_DEPEND_sink);
-    RTLFn = llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
-        CGM.getModule(), OMPRTL___kmpc_doacross_wait);
+    RTLFn = OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
+                                                  OMPRTL___kmpc_doacross_wait);
   }
   CGF.EmitRuntimeCall(RTLFn, Args);
 }
@@ -11210,14 +11200,13 @@ Address CGOpenMPRuntime::getAddressOfLocalVariable(CodeGenFunction &CGF,
   llvm::Value *Args[] = {ThreadID, Size, Allocator};
 
   llvm::Value *Addr =
-      CGF.EmitRuntimeCall(llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(
+      CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
                               CGM.getModule(), OMPRTL___kmpc_alloc),
                           Args, getName({CVD->getName(), ".void.addr"}));
   llvm::Value *FiniArgs[OMPAllocateCleanupTy::CleanupArgs] = {ThreadID, Addr,
                                                               Allocator};
-  llvm::FunctionCallee FiniRTLFn =
-      llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(CGM.getModule(),
-                                                        OMPRTL___kmpc_free);
+  llvm::FunctionCallee FiniRTLFn = OMPBuilder.getOrCreateRuntimeFunction(
+      CGM.getModule(), OMPRTL___kmpc_free);
 
   CGF.EHStack.pushCleanup(NormalAndEHCleanup, FiniRTLFn,
                                                 llvm::makeArrayRef(FiniArgs));

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h
index dea92e16e59f..eb22f155f5ef 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -25,6 +25,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/AtomicOrdering.h"
@@ -37,6 +38,7 @@ class GlobalVariable;
 class StructType;
 class Type;
 class Value;
+class OpenMPIRBuilder;
 } // namespace llvm
 
 namespace clang {
@@ -284,6 +286,8 @@ class CGOpenMPRuntime {
     ~LastprivateConditionalRAII();
   };
 
+  llvm::OpenMPIRBuilder &getOMPBuilder() { return OMPBuilder; }
+
 protected:
   CodeGenModule &CGM;
   StringRef FirstSeparator, Separator;
@@ -368,6 +372,8 @@ class CGOpenMPRuntime {
   llvm::Value *getCriticalRegionLock(StringRef CriticalName);
 
 private:
+  /// An OpenMP-IR-Builder instance.
+  llvm::OpenMPIRBuilder OMPBuilder;
   /// Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource = nullptr;

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 4141acfcd1fb..7135135d2a41 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1569,8 +1569,7 @@ static void emitEmptyBoundParameters(CodeGenFunction &,
 Address CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable(
     CodeGenFunction &CGF, const VarDecl *VD) {
   CodeGenModule &CGM = CGF.CGM;
-  auto OMPBuilder = CGM.getOpenMPIRBuilder();
-  assert(OMPBuilder && "OMPIRBuilder does not exist!");
+  auto &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
 
   if (!VD)
     return Address::invalid();
@@ -1607,11 +1606,11 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable(
     Allocator = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Allocator,
                                                                 CGM.VoidPtrTy);
 
-  llvm::Value *Addr = OMPBuilder->CreateOMPAlloc(
+  llvm::Value *Addr = OMPBuilder.CreateOMPAlloc(
       CGF.Builder, Size, Allocator,
       getNameWithSeparators({CVD->getName(), ".void.addr"}, ".", "."));
   llvm::CallInst *FreeCI =
-      OMPBuilder->CreateOMPFree(CGF.Builder, Addr, Allocator);
+      OMPBuilder.CreateOMPFree(CGF.Builder, Addr, Allocator);
 
   CGF.EHStack.pushCleanup(NormalAndEHCleanup, FreeCI);
   Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
@@ -1629,8 +1628,7 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
       CGM.getContext().getTargetInfo().isTLSSupported())
     return VDAddr;
 
-  llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder();
-  assert(OMPBuilder && "OpenMPIRBuilder is not initialized or used.");
+  llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
 
   llvm::Type *VarTy = VDAddr.getElementType();
   llvm::Value *Data =
@@ -1640,7 +1638,7 @@ Address CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
   llvm::Twine CacheName = Twine(CGM.getMangledName(VD)).concat(Suffix);
 
   llvm::CallInst *ThreadPrivateCacheCall =
-      OMPBuilder->CreateCachedThreadPrivate(CGF.Builder, Data, Size, CacheName);
+      OMPBuilder.CreateCachedThreadPrivate(CGF.Builder, Data, Size, CacheName);
 
   return Address(ThreadPrivateCacheCall, VDAddr.getAlignment());
 }
@@ -1657,7 +1655,8 @@ std::string CodeGenFunction::OMPBuilderCBHelpers::getNameWithSeparators(
   return OS.str().str();
 }
 void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+    llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
     // Check if we have any if clause associated with the directive.
     llvm::Value *IfCond = nullptr;
     if (const auto *C = S.getSingleClause())
@@ -1708,9 +1707,9 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
 
     CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
     CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
-    Builder.restoreIP(OMPBuilder->CreateParallel(Builder, BodyGenCB, PrivCB,
-                                                 FiniCB, IfCond, NumThreads,
-                                                 ProcBind, S.hasCancel()));
+    Builder.restoreIP(OMPBuilder.CreateParallel(Builder, BodyGenCB, PrivCB,
+                                                FiniCB, IfCond, NumThreads,
+                                                ProcBind, S.hasCancel()));
     return;
   }
 
@@ -3615,7 +3614,8 @@ static void emitMaster(CodeGenFunction &CGF, const OMPExecutableDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+    llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
     using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
     const CapturedStmt *CS = S.getInnermostCapturedStmt();
@@ -3635,7 +3635,7 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
 
     CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
     CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
-    Builder.restoreIP(OMPBuilder->CreateMaster(Builder, BodyGenCB, FiniCB));
+    Builder.restoreIP(OMPBuilder.CreateMaster(Builder, BodyGenCB, FiniCB));
 
     return;
   }
@@ -3644,7 +3644,8 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) {
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+    llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
     using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
 
     const CapturedStmt *CS = S.getInnermostCapturedStmt();
@@ -3675,7 +3676,7 @@ void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) {
 
     CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
     CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
-    Builder.restoreIP(OMPBuilder->CreateCritical(
+    Builder.restoreIP(OMPBuilder.CreateCritical(
         Builder, BodyGenCB, FiniCB, S.getDirectiveName().getAsString(),
         HintInst));
 
@@ -5876,7 +5877,8 @@ void CodeGenFunction::EmitOMPCancelDirective(const OMPCancelDirective &S) {
       break;
     }
   }
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder()) {
+  if (CGM.getLangOpts().OpenMPIRBuilder) {
+    llvm::OpenMPIRBuilder &OMPBuilder = CGM.getOpenMPRuntime().getOMPBuilder();
     // TODO: This check is necessary as we only generate `omp parallel` through
     // the OpenMPIRBuilder for now.
     if (S.getCancelRegion() == OMPD_parallel) {
@@ -5885,7 +5887,7 @@ void CodeGenFunction::EmitOMPCancelDirective(const OMPCancelDirective &S) {
         IfCondition = EmitScalarExpr(IfCond,
                                      /*IgnoreResultAssign=*/true);
       return Builder.restoreIP(
-          OMPBuilder->CreateCancel(Builder, IfCondition, S.getCancelRegion()));
+          OMPBuilder.CreateCancel(Builder, IfCondition, S.getCancelRegion()));
     }
   }
 

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index babb0ea76aba..8ce488f35dd3 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -87,8 +87,8 @@ CodeGenFunction::~CodeGenFunction() {
   // seems to be a reasonable spot. We do it here, as opposed to the deletion
   // time of the CodeGenModule, because we have to ensure the IR has not yet
   // been "emitted" to the outside, thus, modifications are still sensible.
-  if (llvm::OpenMPIRBuilder *OMPBuilder = CGM.getOpenMPIRBuilder())
-    OMPBuilder->finalize();
+  if (CGM.getLangOpts().OpenMPIRBuilder)
+    CGM.getOpenMPRuntime().getOMPBuilder().finalize();
 }
 
 // Map the LangOption for exception behavior into

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 71778ac31660..4ae8ce7e5ccf 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -222,14 +222,6 @@ void CodeGenModule::createOpenMPRuntime() {
       OpenMPRuntime.reset(new CGOpenMPRuntime(*this));
     break;
   }
-
-  // The OpenMP-IR-Builder should eventually replace the above runtime codegens
-  // but we are not there yet so they both reside in CGModule for now and the
-  // OpenMP-IR-Builder is opt-in only.
-  if (LangOpts.OpenMPIRBuilder) {
-    OMPBuilder.reset(new llvm::OpenMPIRBuilder(TheModule));
-    OMPBuilder->initialize();
-  }
 }
 
 void CodeGenModule::createCUDARuntime() {

diff  --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 1ebc907bbf65..a6c4a1f7b278 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -324,7 +324,6 @@ class CodeGenModule : public CodeGenTypeCache {
   std::unique_ptr ObjCRuntime;
   std::unique_ptr OpenCLRuntime;
   std::unique_ptr OpenMPRuntime;
-  std::unique_ptr OMPBuilder;
   std::unique_ptr CUDARuntime;
   std::unique_ptr DebugInfo;
   std::unique_ptr ObjCData;
@@ -597,9 +596,6 @@ class CodeGenModule : public CodeGenTypeCache {
     return *OpenMPRuntime;
   }
 
-  /// Return a pointer to the configured OpenMPIRBuilder, if any.
-  llvm::OpenMPIRBuilder *getOpenMPIRBuilder() { return OMPBuilder.get(); }
-
   /// Return a reference to the configured CUDA runtime.
   CGCUDARuntime &getCUDARuntime() {
     assert(CUDARuntime != nullptr);

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
index bfdecdd5d711..d171d0a2b6c4 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
@@ -89,35 +89,6 @@ enum class IdentFlag {
 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
 
-/// Forward declarations for LLVM-IR types (simple, function and structure) are
-/// generated below. Their names are defined and used in OpenMP/OMPKinds.def.
-/// Here we provide the forward declarations, the initializeTypes function will
-/// provide the values.
-///
-///{
-namespace types {
-
-#define OMP_TYPE(VarName, InitValue) extern Type *VarName;
-#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize)                             \
-  extern ArrayType *VarName##Ty;                                               \
-  extern PointerType *VarName##PtrTy;
-#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
-  extern FunctionType *VarName;                                                \
-  extern PointerType *VarName##Ptr;
-#define OMP_STRUCT_TYPE(VarName, StrName, ...)                                 \
-  extern StructType *VarName;                                                  \
-  extern PointerType *VarName##Ptr;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-
-/// Helper to initialize all types defined in OpenMP/OMPKinds.def.
-void initializeTypes(Module &M);
-
-/// Helper to uninitialize all types defined in OpenMP/OMPKinds.def.
-void uninitializeTypes();
-
-} // namespace types
-///}
-
 } // end namespace omp
 
 } // end namespace llvm

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 3c2dd6ed4860..2a3a64a5f4ac 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -39,7 +39,7 @@ class OpenMPIRBuilder {
   void finalize();
 
   /// Add attributes known for \p FnID to \p Fn.
-  static void addAttributes(omp::RuntimeFunction FnID, Function &Fn);
+  void addAttributes(omp::RuntimeFunction FnID, Function &Fn);
 
   /// Type used throughout for insertion points.
   using InsertPointTy = IRBuilder<>::InsertPoint;
@@ -199,8 +199,8 @@ class OpenMPIRBuilder {
   }
 
   /// Return the function declaration for the runtime function with \p FnID.
-  static FunctionCallee getOrCreateRuntimeFunction(Module &M,
-                                                   omp::RuntimeFunction FnID);
+  FunctionCallee getOrCreateRuntimeFunction(Module &M,
+                                            omp::RuntimeFunction FnID);
 
   Function *getOrCreateRuntimeFunctionPtr(omp::RuntimeFunction FnID);
 
@@ -381,7 +381,31 @@ class OpenMPIRBuilder {
                                       llvm::ConstantInt *Size,
                                       const llvm::Twine &Name = Twine(""));
 
+  /// Declarations for LLVM-IR types (simple, array, function and structure) are
+  /// generated below. Their names are defined and used in OpenMPKinds.def. Here
+  /// we provide the declarations, the initializeTypes function will provide the
+  /// values.
+  ///
+  ///{
+#define OMP_TYPE(VarName, InitValue) Type *VarName = nullptr;
+#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize)                             \
+  ArrayType *VarName##Ty = nullptr;                                            \
+  PointerType *VarName##PtrTy = nullptr;
+#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
+  FunctionType *VarName = nullptr;                                             \
+  PointerType *VarName##Ptr = nullptr;
+#define OMP_STRUCT_TYPE(VarName, StrName, ...)                                 \
+  StructType *VarName = nullptr;                                               \
+  PointerType *VarName##Ptr = nullptr;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+
+  ///}
+
 private:
+  /// Create all simple and struct types exposed by the runtime and remember
+  /// the llvm::PointerTypes of them for easy access later.
+  void initializeTypes(Module &M);
+
   /// Common interface for generating entry calls for OMP Directives.
   /// if the directive has a region/body, It will set the insertion
   /// point to the body

diff  --git a/llvm/lib/Frontend/OpenMP/OMPConstants.cpp b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
index 471f0361191e..fdee3c5ef658 100644
--- a/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
@@ -17,61 +17,5 @@
 
 using namespace llvm;
 using namespace omp;
-using namespace types;
 
 #include "llvm/Frontend/OpenMP/OMP.cpp.inc"
-
-/// Declarations for LLVM-IR types (simple, array, function and structure) are
-/// generated below. Their names are defined and used in OpenMPKinds.def. Here
-/// we provide the declarations, the initializeTypes function will provide the
-/// values.
-///
-///{
-#define OMP_TYPE(VarName, InitValue) Type *llvm::omp::types::VarName = nullptr;
-#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize)                             \
-  ArrayType *llvm::omp::types::VarName##Ty = nullptr;                          \
-  PointerType *llvm::omp::types::VarName##PtrTy = nullptr;
-#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
-  FunctionType *llvm::omp::types::VarName = nullptr;                           \
-  PointerType *llvm::omp::types::VarName##Ptr = nullptr;
-#define OMP_STRUCT_TYPE(VarName, StrName, ...)                                 \
-  StructType *llvm::omp::types::VarName = nullptr;                             \
-  PointerType *llvm::omp::types::VarName##Ptr = nullptr;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-
-///}
-
-void llvm::omp::types::initializeTypes(Module &M) {
-  if (Void)
-    return;
-
-  LLVMContext &Ctx = M.getContext();
-  // Create all simple and struct types exposed by the runtime and remember
-  // the llvm::PointerTypes of them for easy access later.
-  StructType *T;
-#define OMP_TYPE(VarName, InitValue) VarName = InitValue;
-#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize)                             \
-  VarName##Ty = ArrayType::get(ElemTy, ArraySize);                             \
-  VarName##PtrTy = PointerType::getUnqual(VarName##Ty);
-#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
-  VarName = FunctionType::get(ReturnType, {__VA_ARGS__}, IsVarArg);            \
-  VarName##Ptr = PointerType::getUnqual(VarName);
-#define OMP_STRUCT_TYPE(VarName, StructName, ...)                              \
-  T = M.getTypeByName(StructName);                                             \
-  if (!T)                                                                      \
-    T = StructType::create(Ctx, {__VA_ARGS__}, StructName);                    \
-  VarName = T;                                                                 \
-  VarName##Ptr = PointerType::getUnqual(T);
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-}
-
-void llvm::omp::types::uninitializeTypes() {
-#define OMP_TYPE(VarName, InitValue) VarName = nullptr;
-#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
-  VarName = nullptr;                                                           \
-  VarName##Ptr = nullptr;
-#define OMP_STRUCT_TYPE(VarName, StrName, ...)                                 \
-  VarName = nullptr;                                                           \
-  VarName##Ptr = nullptr;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-}

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 3e945544170c..b7212edab6ab 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -31,7 +31,6 @@
 
 using namespace llvm;
 using namespace omp;
-using namespace types;
 
 static cl::opt
     OptimisticAttributes("openmp-ir-builder-optimistic-attributes", cl::Hidden,
@@ -1092,3 +1091,24 @@ Value *OpenMPIRBuilder::getOMPCriticalRegionLock(StringRef CriticalName) {
   std::string Name = getNameWithSeparators({Prefix, "var"}, ".", ".");
   return getOrCreateOMPInternalVariable(KmpCriticalNameTy, Name);
 }
+
+// Create all simple and struct types exposed by the runtime and remember
+// the llvm::PointerTypes of them for easy access later.
+void OpenMPIRBuilder::initializeTypes(Module &M) {
+  LLVMContext &Ctx = M.getContext();
+  StructType *T;
+#define OMP_TYPE(VarName, InitValue) VarName = InitValue;
+#define OMP_ARRAY_TYPE(VarName, ElemTy, ArraySize)                             \
+  VarName##Ty = ArrayType::get(ElemTy, ArraySize);                             \
+  VarName##PtrTy = PointerType::getUnqual(VarName##Ty);
+#define OMP_FUNCTION_TYPE(VarName, IsVarArg, ReturnType, ...)                  \
+  VarName = FunctionType::get(ReturnType, {__VA_ARGS__}, IsVarArg);            \
+  VarName##Ptr = PointerType::getUnqual(VarName);
+#define OMP_STRUCT_TYPE(VarName, StructName, ...)                              \
+  T = M.getTypeByName(StructName);                                             \
+  if (!T)                                                                      \
+    T = StructType::create(Ctx, {__VA_ARGS__}, StructName);                    \
+  VarName = T;                                                                 \
+  VarName##Ptr = PointerType::getUnqual(T);
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+}

diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 60813500359b..8ad562f513e4 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -29,7 +29,6 @@
 
 using namespace llvm;
 using namespace omp;
-using namespace types;
 
 #define DEBUG_TYPE "openmp-opt"
 
@@ -263,11 +262,11 @@ struct OMPInformationCache : public InformationCache {
       ICV.InitValue = nullptr;                                                 \
       break;                                                                   \
     case ICV_ZERO:                                                             \
-      ICV.InitValue =                                                          \
-          ConstantInt::get(Type::getInt32Ty(Int32->getContext()), 0);          \
+      ICV.InitValue = ConstantInt::get(                                        \
+          Type::getInt32Ty(OMPBuilder.Int32->getContext()), 0);                \
       break;                                                                   \
     case ICV_FALSE:                                                            \
-      ICV.InitValue = ConstantInt::getFalse(Int1->getContext());               \
+      ICV.InitValue = ConstantInt::getFalse(OMPBuilder.Int1->getContext());    \
       break;                                                                   \
     case ICV_LAST:                                                             \
       break;                                                                   \
@@ -332,16 +331,39 @@ struct OMPInformationCache : public InformationCache {
 
     Module &M = *((*ModuleSlice.begin())->getParent());
 
+    // Helper macros for handling __VA_ARGS__ in OMP_RTL
+#define OMP_TYPE(VarName, ...)                                                 \
+  Type *VarName = OMPBuilder.VarName;                                          \
+  (void)VarName;
+
+#define OMP_ARRAY_TYPE(VarName, ...)                                           \
+  ArrayType *VarName##Ty = OMPBuilder.VarName##Ty;                             \
+  (void)VarName##Ty;                                                           \
+  PointerType *VarName##PtrTy = OMPBuilder.VarName##PtrTy;                     \
+  (void)VarName##PtrTy;
+
+#define OMP_FUNCTION_TYPE(VarName, ...)                                        \
+  FunctionType *VarName = OMPBuilder.VarName;                                  \
+  (void)VarName;                                                               \
+  PointerType *VarName##Ptr = OMPBuilder.VarName##Ptr;                         \
+  (void)VarName##Ptr;
+
+#define OMP_STRUCT_TYPE(VarName, ...)                                          \
+  StructType *VarName = OMPBuilder.VarName;                                    \
+  (void)VarName;                                                               \
+  PointerType *VarName##Ptr = OMPBuilder.VarName##Ptr;                         \
+  (void)VarName##Ptr;
+
 #define OMP_RTL(_Enum, _Name, _IsVarArg, _ReturnType, ...)                     \
   {                                                                            \
     SmallVector ArgsTypes({__VA_ARGS__});                           \
     Function *F = M.getFunction(_Name);                                        \
-    if (declMatchesRTFTypes(F, _ReturnType, ArgsTypes)) {                      \
+    if (declMatchesRTFTypes(F, OMPBuilder._ReturnType, ArgsTypes)) {           \
       auto &RFI = RFIs[_Enum];                                                 \
       RFI.Kind = _Enum;                                                        \
       RFI.Name = _Name;                                                        \
       RFI.IsVarArg = _IsVarArg;                                                \
-      RFI.ReturnType = _ReturnType;                                            \
+      RFI.ReturnType = OMPBuilder._ReturnType;                                 \
       RFI.ArgumentTypes = std::move(ArgsTypes);                                \
       RFI.Declaration = F;                                                     \
       unsigned NumUses = CollectUses(RFI);                                     \
@@ -593,11 +615,11 @@ struct OpenMPOpt {
            "Unexpected replacement value!");
 
     // TODO: Use dominance to find a good position instead.
-    auto CanBeMoved = [](CallBase &CB) {
+    auto CanBeMoved = [this](CallBase &CB) {
       unsigned NumArgs = CB.getNumArgOperands();
       if (NumArgs == 0)
         return true;
-      if (CB.getArgOperand(0)->getType() != IdentPtr)
+      if (CB.getArgOperand(0)->getType() != OMPInfoCache.OMPBuilder.IdentPtr)
         return false;
       for (unsigned u = 1; u < NumArgs; ++u)
         if (isa(CB.getArgOperand(u)))
@@ -632,7 +654,7 @@ struct OpenMPOpt {
     // existing and used by one of the calls, or created from scratch.
     if (CallBase *CI = dyn_cast(ReplVal)) {
       if (CI->getNumArgOperands() > 0 &&
-          CI->getArgOperand(0)->getType() == IdentPtr) {
+          CI->getArgOperand(0)->getType() == OMPInfoCache.OMPBuilder.IdentPtr) {
         Value *Ident = getCombinedIdentFromCallUsesIn(RFI, F,
                                                       /* GlobalOnly */ true);
         CI->setArgOperand(0, Ident);

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index ae0dff43b94c..2ba9d85a0f9e 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -19,7 +19,6 @@
 
 using namespace llvm;
 using namespace omp;
-using namespace types;
 
 namespace {
 
@@ -50,7 +49,6 @@ class OpenMPIRBuilderTest : public testing::Test {
   void TearDown() override {
     BB = nullptr;
     M.reset();
-    uninitializeTypes();
   }
 
   LLVMContext Ctx;


        

From cfe-commits at lists.llvm.org  Wed Jul  8 08:25:50 2020
From: cfe-commits at lists.llvm.org (Stefan Stipanovic via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:25:50 +0000 (UTC)
Subject: [PATCH] D83176: [OpenMPIRBuilder][Fix] Move llvm::omp::types to
 OpenMPIRBuilder.
In-Reply-To: 
References: 
Message-ID: <4bfcf1805ee8544dce8c60675209d86c@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG6aab27ba851f: [OpenMPIRBuilder][Fix] Move llvm::omp::types to OpenMPIRBuilder. (authored by sstefan1).

Changed prior to commit:
  https://reviews.llvm.org/D83176?vs=275549&id=276445#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83176/new/

https://reviews.llvm.org/D83176

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83176.276445.patch
Type: text/x-patch
Size: 59148 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 08:26:16 2020
From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:26:16 +0000 (UTC)
Subject: [PATCH] D82805: [clang] Fix a crash on passing C structure of
 incompatible type to function with reference parameter
In-Reply-To: 
References: 
Message-ID: <33ef317958d7c539e46eab40148093f0@localhost.localdomain>

riccibruno accepted this revision.
riccibruno added a comment.
This revision is now accepted and ready to land.

This LGTM, with a few wording nits.

> This patch fix clang crashes at using these functions in C and passing incompatible structures as parameters in case of __builtin_va_list/__builtin_ms_va_list are structures.

This patch fix a crash when using these functions in C where an argument of structure type is incompatible with the parameter type.

Do you want me to commit it for you? If so I need a name and an email for the attribution.



================
Comment at: clang/lib/Sema/SemaInit.cpp:4698
+/// We also can get here in C if we call builtin which is declared as
+/// a function with reference arguments (e.g. __builtin_va_end()).
 static void TryReferenceInitializationCore(Sema &S,
----------------
s/call builtin/call a builtin/
s/with reference arguments/with a parameter of reference type/

The second wording change is important since "argument" != "parameter".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82805/new/

https://reviews.llvm.org/D82805




From cfe-commits at lists.llvm.org  Wed Jul  8 08:31:49 2020
From: cfe-commits at lists.llvm.org (Sam McCall via cfe-commits)
Date: Wed, 08 Jul 2020 08:31:49 -0700 (PDT)
Subject: [clang-tools-extra] a15d798 - [clangd] Improve serialization error
 messages. NFC
Message-ID: <5f05e6e5.1c69fb81.9d7dd.083c@mx.google.com>


Author: Sam McCall
Date: 2020-07-08T17:31:40+02:00
New Revision: a15d798594ae340b037efec2cdba5ec77221e7e7

URL: https://github.com/llvm/llvm-project/commit/a15d798594ae340b037efec2cdba5ec77221e7e7
DIFF: https://github.com/llvm/llvm-project/commit/a15d798594ae340b037efec2cdba5ec77221e7e7.diff

LOG: [clangd] Improve serialization error messages. NFC

Added: 
    

Modified: 
    clang-tools-extra/clangd/RIFF.cpp
    clang-tools-extra/clangd/RIFF.h
    clang-tools-extra/clangd/index/Serialization.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/RIFF.cpp b/clang-tools-extra/clangd/RIFF.cpp
index cdbae4f72739..b87c2d56af0c 100644
--- a/clang-tools-extra/clangd/RIFF.cpp
+++ b/clang-tools-extra/clangd/RIFF.cpp
@@ -8,25 +8,29 @@
 
 #include "RIFF.h"
 #include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
 
 namespace clang {
 namespace clangd {
 namespace riff {
 
-static llvm::Error makeError(const char *Msg) {
-  return llvm::createStringError(llvm::inconvertibleErrorCode(), Msg);
+static llvm::Error makeError(const llvm::Twine &Msg) {
+  return llvm::make_error(Msg,
+                                             llvm::inconvertibleErrorCode());
 }
 
 llvm::Expected readChunk(llvm::StringRef &Stream) {
   if (Stream.size() < 8)
-    return makeError("incomplete chunk header");
+    return makeError("incomplete chunk header: " + llvm::Twine(Stream.size()) +
+                     " bytes available");
   Chunk C;
   std::copy(Stream.begin(), Stream.begin() + 4, C.ID.begin());
   Stream = Stream.drop_front(4);
   uint32_t Len = llvm::support::endian::read32le(Stream.take_front(4).begin());
   Stream = Stream.drop_front(4);
   if (Stream.size() < Len)
-    return makeError("truncated chunk");
+    return makeError("truncated chunk: want " + llvm::Twine(Len) + ", got " +
+                     llvm::Twine(Stream.size()));
   C.Data = Stream.take_front(Len);
   Stream = Stream.drop_front(Len);
   if (Len % 2 & !Stream.empty()) { // Skip padding byte.
@@ -53,7 +57,7 @@ llvm::Expected readFile(llvm::StringRef Stream) {
   if (!RIFF)
     return RIFF.takeError();
   if (RIFF->ID != fourCC("RIFF"))
-    return makeError("not a RIFF container");
+    return makeError("not a RIFF container: root is " + fourCCStr(RIFF->ID));
   if (RIFF->Data.size() < 4)
     return makeError("RIFF chunk too short");
   File F;

diff  --git a/clang-tools-extra/clangd/RIFF.h b/clang-tools-extra/clangd/RIFF.h
index d827a90f2bd7..96d8ab5463d3 100644
--- a/clang-tools-extra/clangd/RIFF.h
+++ b/clang-tools-extra/clangd/RIFF.h
@@ -44,6 +44,9 @@ using FourCC = std::array;
 inline constexpr FourCC fourCC(const char (&Literal)[5]) {
   return FourCC{{Literal[0], Literal[1], Literal[2], Literal[3]}};
 }
+inline constexpr llvm::StringRef fourCCStr(const FourCC &Data) {
+  return llvm::StringRef(&Data[0], Data.size());
+}
 // A chunk is a section in a RIFF container.
 struct Chunk {
   FourCC ID;

diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp b/clang-tools-extra/clangd/index/Serialization.cpp
index 06527a615c20..11d70b550642 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -426,20 +426,25 @@ llvm::Expected readRIFF(llvm::StringRef Data) {
   if (!RIFF)
     return RIFF.takeError();
   if (RIFF->Type != riff::fourCC("CdIx"))
-    return makeError("wrong RIFF type");
+    return makeError("wrong RIFF filetype: " + riff::fourCCStr(RIFF->Type));
   llvm::StringMap Chunks;
   for (const auto &Chunk : RIFF->Chunks)
     Chunks.try_emplace(llvm::StringRef(Chunk.ID.data(), Chunk.ID.size()),
                        Chunk.Data);
 
-  for (llvm::StringRef RequiredChunk : {"meta", "stri"})
+  if (!Chunks.count("meta"))
+    return makeError("missing meta chunk");
+  Reader Meta(Chunks.lookup("meta"));
+  auto SeenVersion = Meta.consume32();
+  if (SeenVersion != Version)
+    return makeError("wrong version: want " + llvm::Twine(Version) + ", got " +
+                     llvm::Twine(SeenVersion));
+
+  // meta chunk is checked above, as we prefer the "version mismatch" error.
+  for (llvm::StringRef RequiredChunk : {"stri"})
     if (!Chunks.count(RequiredChunk))
       return makeError("missing required chunk " + RequiredChunk);
 
-  Reader Meta(Chunks.lookup("meta"));
-  if (Meta.consume32() != Version)
-    return makeError("wrong version");
-
   auto Strings = readStringTable(Chunks.lookup("stri"));
   if (!Strings)
     return Strings.takeError();
@@ -665,7 +670,7 @@ std::unique_ptr loadIndex(llvm::StringRef SymbolFilename,
   trace::Span OverallTracer("LoadIndex");
   auto Buffer = llvm::MemoryBuffer::getFile(SymbolFilename);
   if (!Buffer) {
-    elog("Can't open {0}", SymbolFilename);
+    elog("Can't open {0}: {1}", SymbolFilename, Buffer.getError().message());
     return nullptr;
   }
 
@@ -682,7 +687,7 @@ std::unique_ptr loadIndex(llvm::StringRef SymbolFilename,
       if (I->Relations)
         Relations = std::move(*I->Relations);
     } else {
-      elog("Bad Index: {0}", I.takeError());
+      elog("Bad index file: {0}", I.takeError());
       return nullptr;
     }
   }


        

From cfe-commits at lists.llvm.org  Wed Jul  8 08:32:07 2020
From: cfe-commits at lists.llvm.org (Denys Petrov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:32:07 +0000 (UTC)
Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver
 infra
In-Reply-To: 
References: 
Message-ID: <32d2f66ea016b53597dc454ed0a7cc6b@localhost.localdomain>

ASDenysPetrov added a comment.

@vsavchenko
Thank you.
Despite of all of my nits, LGTM!



================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:367-378
+RangeSet RangeSet::Delete(BasicValueFactory &BV, Factory &F,
+                          const llvm::APSInt &Point) const {
+  llvm::APSInt Upper = Point;
+  llvm::APSInt Lower = Point;
+
+  ++Upper;
+  --Lower;
----------------
vsavchenko wrote:
> ASDenysPetrov wrote:
> > Useful function. But I'd better rename it to `subtract` as we are working with sets (as a mathimatical collection). We should have a such one for the Ranges not only for Points.
> > We have `intersect`, `delete` aka `subtract`. And we also need to have functions `union` and `symmetricDifference` to cover full palette of common operations on sets.
> I agree that we should have a full set of functions.  I don't agree however, that this function is a `subtract`.  Subtract is an operation on two sets and here we have a set and a point.  One might argue that a point is just a very simple set, that's true, but real `subtract` would be more complex in its implementation.
> 
> Naming it `delete`, on the other hand, I was coming from a notion of deleting points or neighbourhoods (https://en.wikipedia.org/wiki/Neighbourhood_(mathematics)#Deleted_neighbourhood).
>One might argue that a point is just a very simple set
That's actually what I mean :) and for this particular case you may leave the implementation as is. And for me it still does what `subtract` does. But I'm OK,  I don't insist.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734
   //        expressions which we currently do not know how to negate.
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) {
+  Optional getRangeForInvertedSub(SymbolRef Sym) {
     if (const SymSymExpr *SSE = dyn_cast(Sym)) {
----------------
vsavchenko wrote:
> ASDenysPetrov wrote:
> > As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you do Negate operation inside.
> I'm not super happy about my name either, but I feel like it describes it better than the previous name and your version.  That function doesn't work for any `SymSymExpr` and it doesn't simply negate whatever we gave it.  It works specifically for symbolic subtractions and this is the information I want to be reflected in the name.
Oh, I just assumed //...Sub// at the end as a //subexpression// but you mean //subtraction//. What I'm trying to say is that we can rename it like `getRangeFor...`//the expression which this function can handle//. E.g. `getRangeForNegatedSubtractionSymSymExpr`. My point is in a speaking name.

I think //invertion// is not something appropriate in terms of applying minus operator. I think invertion of zero should be something opposite but not a zero. Because when you would like to implement the function which turns [A, B] into [MIN, A)U(B, MAX], what would be the name of it? I think this is an //invertion//.

But this is not a big deal, it's just my thoughts.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:841-844
+  RangeSet getTrueRange(QualType T) {
+    RangeSet TypeRange = infer(T);
+    return assumeNonZero(TypeRange, T);
+  }
----------------
vsavchenko wrote:
> ASDenysPetrov wrote:
> > Don't you think this is too complicated for such a simple getter?
> > Maybe we can just construct the range using smth about `RangeSet(RangeFactory, ++Zero, --Zero);` ?
> It is more complex than a false range but there is a reason for it.
> 
> First of all, `RangeSet` can't have ranges where the end is greater than its start.  Only `Intersect` can handle such ranges correctly.  Another thing is that ranges like that mean `[MIN, --Zero], [++Zero, MAX]` and without a type we can't really say what `MIN` and `MAX` are, so such constructor for `RangeSet` simply cannot exist.
> 
> Another point is that we do need to have `[MIN, -1], [+1, MAX]` as opposed to `[-1, -1], [+1, +1]` because of C language (it doesn't have boolean type), and because of the cases like `a - b` where we know that `a != b`.
> 
> I hope that answers the question.
I just want this function has low complexity and be more lightweight as `getFalseRange`. And if we have any chance to simplify it (and you have all the data to get MIN and MAX), it'd be cool.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82381/new/

https://reviews.llvm.org/D82381




From cfe-commits at lists.llvm.org  Wed Jul  8 08:39:24 2020
From: cfe-commits at lists.llvm.org (Bruno Ricci via cfe-commits)
Date: Wed, 08 Jul 2020 08:39:24 -0700 (PDT)
Subject: [clang] 7a7d50e - [clang][NFC] Also test for serialization in
 test/AST/ast-dump-APValue-*
Message-ID: <5f05e8ac.1c69fb81.726c2.01eb@mx.google.com>


Author: Bruno Ricci
Date: 2020-07-08T16:39:11+01:00
New Revision: 7a7d50e1f0d84c701fd2aa1b84a73a3e194fb91a

URL: https://github.com/llvm/llvm-project/commit/7a7d50e1f0d84c701fd2aa1b84a73a3e194fb91a
DIFF: https://github.com/llvm/llvm-project/commit/7a7d50e1f0d84c701fd2aa1b84a73a3e194fb91a.diff

LOG: [clang][NFC] Also test for serialization in test/AST/ast-dump-APValue-*

This does not actually exercise the serialization of APValue, but it
will at least prevent a regression in the future. NFC.

Added: 
    

Modified: 
    clang/test/AST/ast-dump-APValue-anon-union.cpp
    clang/test/AST/ast-dump-APValue-arithmetic.cpp
    clang/test/AST/ast-dump-APValue-array.cpp
    clang/test/AST/ast-dump-APValue-struct.cpp
    clang/test/AST/ast-dump-APValue-todo.cpp
    clang/test/AST/ast-dump-APValue-union.cpp
    clang/test/AST/ast-dump-APValue-vector.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/AST/ast-dump-APValue-anon-union.cpp b/clang/test/AST/ast-dump-APValue-anon-union.cpp
index c50fe70be911..1c9480c5a943 100644
--- a/clang/test/AST/ast-dump-APValue-anon-union.cpp
+++ b/clang/test/AST/ast-dump-APValue-anon-union.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 struct S0 {
   union {

diff  --git a/clang/test/AST/ast-dump-APValue-arithmetic.cpp b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
index a4e1d82eeb37..835d8c810834 100644
--- a/clang/test/AST/ast-dump-APValue-arithmetic.cpp
+++ b/clang/test/AST/ast-dump-APValue-arithmetic.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 void Test() {
   constexpr int Int = 42;

diff  --git a/clang/test/AST/ast-dump-APValue-array.cpp b/clang/test/AST/ast-dump-APValue-array.cpp
index 4b7dfab09eaf..f9b38ec332a5 100644
--- a/clang/test/AST/ast-dump-APValue-array.cpp
+++ b/clang/test/AST/ast-dump-APValue-array.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 struct S0 {
   int arr[2];

diff  --git a/clang/test/AST/ast-dump-APValue-struct.cpp b/clang/test/AST/ast-dump-APValue-struct.cpp
index d69ddffda031..4730404abc28 100644
--- a/clang/test/AST/ast-dump-APValue-struct.cpp
+++ b/clang/test/AST/ast-dump-APValue-struct.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 struct S0 {
   int i = 0;

diff  --git a/clang/test/AST/ast-dump-APValue-todo.cpp b/clang/test/AST/ast-dump-APValue-todo.cpp
index 5de8146910f7..78cc9cf36c73 100644
--- a/clang/test/AST/ast-dump-APValue-todo.cpp
+++ b/clang/test/AST/ast-dump-APValue-todo.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 int i;
 struct S {

diff  --git a/clang/test/AST/ast-dump-APValue-union.cpp b/clang/test/AST/ast-dump-APValue-union.cpp
index afb69de9f587..c717b6ece738 100644
--- a/clang/test/AST/ast-dump-APValue-union.cpp
+++ b/clang/test/AST/ast-dump-APValue-union.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 union U0 {
   int i = 42;

diff  --git a/clang/test/AST/ast-dump-APValue-vector.cpp b/clang/test/AST/ast-dump-APValue-vector.cpp
index fe2dcd934056..a9ec1d361c41 100644
--- a/clang/test/AST/ast-dump-APValue-vector.cpp
+++ b/clang/test/AST/ast-dump-APValue-vector.cpp
@@ -1,6 +1,14 @@
+// Test without serialization:
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
 // RUN:            -ast-dump %s -ast-dump-filter Test \
 // RUN: | FileCheck --strict-whitespace --match-full-lines %s
+//
+// Test with serialization:
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -Wno-unused-value -std=gnu++17 \
+// RUN:           -include-pch %t -ast-dump-all -ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace --match-full-lines %s
 
 void Test() {
   constexpr int __attribute__((vector_size(sizeof(int) * 1))) v1i = {1};


        

From cfe-commits at lists.llvm.org  Wed Jul  8 08:39:52 2020
From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:39:52 +0000 (UTC)
Subject: [PATCH] D82805: [clang] Fix a crash on passing C structure of
 incompatible type to function with reference parameter
In-Reply-To: 
References: 
Message-ID: 

ArcsinX added a comment.

In D82805#2139243 , @riccibruno wrote:

> Do you want me to commit it for you?


Yes, thank you.

>   If so I need a name and an email for the attribution.

Aleksandr Platonov 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82805/new/

https://reviews.llvm.org/D82805




From cfe-commits at lists.llvm.org  Wed Jul  8 08:41:01 2020
From: cfe-commits at lists.llvm.org (Jakub Kuderski via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:41:01 +0000 (UTC)
Subject: [PATCH] D83087: DomTree: remove explicit use of
 DomTreeNodeBase::iterator
In-Reply-To: 
References: 
Message-ID: 

kuhar added a comment.

In D83087#2139211 , @nhaehnle wrote:

> In D83087#2134881 , @kuhar wrote:
>
> > modulo accidental formatting changes.
>
>
> I'm not aware of any. Some line breaks changed because "const_iterator" is longer than "iterator".


Ack.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83087/new/

https://reviews.llvm.org/D83087




From cfe-commits at lists.llvm.org  Wed Jul  8 08:45:47 2020
From: cfe-commits at lists.llvm.org (Stefan Stipanovic via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:45:47 +0000 (UTC)
Subject: [PATCH] D83176: [OpenMPIRBuilder][Fix] Move llvm::omp::types to
 OpenMPIRBuilder.
In-Reply-To: 
References: 
Message-ID: <4becfdf965d80e4601a147745050f086@localhost.localdomain>

This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6aab27ba851f: [OpenMPIRBuilder][Fix] Move llvm::omp::types to OpenMPIRBuilder. (authored by sstefan1).

Changed prior to commit:
  https://reviews.llvm.org/D83176?vs=275549&id=275711#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83176/new/

https://reviews.llvm.org/D83176

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83176.275711.patch
Type: text/x-patch
Size: 59148 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 08:52:50 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:52:50 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <4fec79df90c1f086c84c701786201ec1@localhost.localdomain>

kbobyrev updated this revision to Diff 276454.
kbobyrev marked 10 inline comments as done.
kbobyrev added a comment.

Address the rest of the comments and refactor code.

Patch is ready for the review again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276454.patch
Type: text/x-patch
Size: 39413 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 08:54:49 2020
From: cfe-commits at lists.llvm.org (Mitch Phillips via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:54:49 +0000 (UTC)
Subject: [PATCH] D83369: hwasan: Don't pass the tagged-globals target-feature
 to non-aarch64 backends.
In-Reply-To: 
References: 
Message-ID: 

hctim accepted this revision.
hctim added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83369/new/

https://reviews.llvm.org/D83369




From cfe-commits at lists.llvm.org  Wed Jul  8 08:55:37 2020
From: cfe-commits at lists.llvm.org (Marco Biasini via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:55:37 +0000 (UTC)
Subject: [PATCH] D83402: ParsedAttrInfo: Change spelling to use StringRef
 instead of const char*
Message-ID: 

biasmv created this revision.
biasmv added reviewers: aaron.ballman, nikic.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Store available spellings for attributes as a StringRef instead of a naked const char*. On my machine, this seems to be slightly beneficial for compile times on CTMark. Compilations were executed 10x with and without the change

  Program                          const char* StringRef   diff
  
      CTMark/sqlite3/sqlite3.test     0.91        0.90    -0.7%
    typeset/consumer-typeset.test     2.79        2.77    -0.5%
      CTMark/ClamAV/clamscan.test     3.86        3.85    -0.3%
  TMark/mafft/pairlocalalign.test     1.47        1.46    -0.2%
        CTMark/Bullet/bullet.test    21.75       21.73    -0.1%
   ark/tramp3d-v4/tramp3d-v4.test    18.17       18.19     0.1%
          CTMark/SPASS/SPASS.test     3.55        3.55    -0.1%
        CTMark/lencod/lencod.test     2.80        2.80    -0.1%
   TMark/7zip/7zip-benchmark.test    31.91       31.94     0.1%
         CTMark/kimwitu++/kc.test    11.45       11.45    -0.1%
   Geomean difference                                     -0.2%


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83402

Files:
  clang/include/clang/Sema/ParsedAttr.h


Index: clang/include/clang/Sema/ParsedAttr.h
===================================================================
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -21,6 +21,7 @@
 #include "clang/Sema/Ownership.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Registry.h"
@@ -63,7 +64,7 @@
   /// The syntaxes supported by this attribute and how they're spelled.
   struct Spelling {
     AttributeCommonInfo::Syntax Syntax;
-    const char *NormalizedFullName;
+    llvm::StringRef NormalizedFullName;
   };
   ArrayRef Spellings;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83402.276449.patch
Type: text/x-patch
Size: 736 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 08:57:54 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:57:54 +0000 (UTC)
Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver
 infra
In-Reply-To: 
References: 
Message-ID: 

vsavchenko marked 2 inline comments as done.
vsavchenko added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734
   //        expressions which we currently do not know how to negate.
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) {
+  Optional getRangeForInvertedSub(SymbolRef Sym) {
     if (const SymSymExpr *SSE = dyn_cast(Sym)) {
----------------
ASDenysPetrov wrote:
> vsavchenko wrote:
> > ASDenysPetrov wrote:
> > > As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you do Negate operation inside.
> > I'm not super happy about my name either, but I feel like it describes it better than the previous name and your version.  That function doesn't work for any `SymSymExpr` and it doesn't simply negate whatever we gave it.  It works specifically for symbolic subtractions and this is the information I want to be reflected in the name.
> Oh, I just assumed //...Sub// at the end as a //subexpression// but you mean //subtraction//. What I'm trying to say is that we can rename it like `getRangeFor...`//the expression which this function can handle//. E.g. `getRangeForNegatedSubtractionSymSymExpr`. My point is in a speaking name.
> 
> I think //invertion// is not something appropriate in terms of applying minus operator. I think invertion of zero should be something opposite but not a zero. Because when you would like to implement the function which turns [A, B] into [MIN, A)U(B, MAX], what would be the name of it? I think this is an //invertion//.
> 
> But this is not a big deal, it's just my thoughts.
My thought process here was that we are trying to get range for `A - B` and there is also information on `B - A`, so we can get something for `A - B` based on that.  So, it doesn't really matter what it does under the hood with ranges, it matters what its semantics are.  Here I called `B - A` //an inverted subtraction//.
I don't really know what would be the best name, but I thought that this one makes more sense.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:841-844
+  RangeSet getTrueRange(QualType T) {
+    RangeSet TypeRange = infer(T);
+    return assumeNonZero(TypeRange, T);
+  }
----------------
ASDenysPetrov wrote:
> vsavchenko wrote:
> > ASDenysPetrov wrote:
> > > Don't you think this is too complicated for such a simple getter?
> > > Maybe we can just construct the range using smth about `RangeSet(RangeFactory, ++Zero, --Zero);` ?
> > It is more complex than a false range but there is a reason for it.
> > 
> > First of all, `RangeSet` can't have ranges where the end is greater than its start.  Only `Intersect` can handle such ranges correctly.  Another thing is that ranges like that mean `[MIN, --Zero], [++Zero, MAX]` and without a type we can't really say what `MIN` and `MAX` are, so such constructor for `RangeSet` simply cannot exist.
> > 
> > Another point is that we do need to have `[MIN, -1], [+1, MAX]` as opposed to `[-1, -1], [+1, +1]` because of C language (it doesn't have boolean type), and because of the cases like `a - b` where we know that `a != b`.
> > 
> > I hope that answers the question.
> I just want this function has low complexity and be more lightweight as `getFalseRange`. And if we have any chance to simplify it (and you have all the data to get MIN and MAX), it'd be cool.
`infer(QualType T)` does just that ☺️ So it is a pretty low complexity.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82381/new/

https://reviews.llvm.org/D82381




From cfe-commits at lists.llvm.org  Wed Jul  8 08:59:03 2020
From: cfe-commits at lists.llvm.org (Alexey Lapshin via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 15:59:03 +0000 (UTC)
Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls.
In-Reply-To: 
References: 
Message-ID: <1ad09a58e825afc0e0c9fa8a09b15be8@localhost.localdomain>

avl marked 3 inline comments as done.
avl added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:94
 /// If it contains any dynamic allocas, returns false.
 static bool canTRE(Function &F) {
   // Because of PR962, we don't TRE dynamic allocas.
----------------
efriedma wrote:
> If we're not going to try to do TRE at all on calls not marked "tail", we can probably drop this check.
It looks to me that original idea(PR962) was to avoid inefficient code which is generated for dynamic alloca. 

Currently there would still be generated inefficient code:

Doing TRE for dynamic alloca requires correct stack adjustment to avoid extra stack usage. 
i.e. dynamic stack reservation done for alloca should be restored 
in the end of the current iteration. Current TRE implementation does not do this.

Please, consider the test case:


```
#include 

int count;
__attribute__((noinline)) void globalIncrement(const int* param) { 
	count += *param; 
}

void test(int recurseCount)
{
    if (recurseCount == 0) return;
    {
    int *temp = (int*)alloca(100);
    globalIncrement(temp);
    }
    test(recurseCount - 1);
}


```
Following is the x86 asm generated for the above test case in assumption that dynamic allocas are possible:

```

.LBB1_2:
        movq    %rsp, %rdi
        addq    $-112, %rdi   <<<<<<<<<<<<<< dynamic stack reservation, need to be restored before "jne .LBB1_2"
        movq    %rdi, %rsp
        callq   _Z15globalIncrementPKi
        addl    $-1, %ebx
        jne     .LBB1_2
```

So, it looks like we still have inefficient code here and it was a reason for avoiding TRE.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:808
   // Until this is resolved, disable this transformation if that would ever
   // happen.  This bug is PR962.
   for (Function::iterator BBI = F.begin(), E = F.end(); BBI != E; /*in loop*/) {
----------------
efriedma wrote:
> Can you move this FIXME into a more appropriate spot?
OK.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:335
+        II->getIntrinsicID() == Intrinsic::assume)
+      return true;
+
----------------
efriedma wrote:
> avl wrote:
> > efriedma wrote:
> > > What is the new handling for lifetime.end/assume doing?
> > They are just skipped. In following test case:
> > 
> > 
> > ```
> >   call void @_Z5test5i(i32 %sub)
> >   call void @llvm.lifetime.end.p0i8(i64 24, i8* nonnull %1) #5
> >   call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0) #5
> >   br label %return
> > 
> > ```
> > 
> > they are generated in between call and ret. It is safe to ignore them while checking whether transformation is possible.
> It makes sense we can ignore lifetime.end on an alloca: we know the call doesn't refer to the alloca.  (Maybe we should check that the pointer argument is pointing at an alloca?  That should usually be true anyway, but better to be on the safe side, I guess.)
> 
> I don't think it's safe to hoist assume without additional checks; I think we'd need to check that the call is marked "willreturn"?
> 
> Since this is sort of tricky, I'd prefer to split this off into a followup.
>It makes sense we can ignore lifetime.end on an alloca: we know the call doesn't refer to the alloca. (Maybe we should check that the pointer argument is pointing at an alloca? That should usually be true anyway, but better to be on the safe side, I guess.)

OK, I would add checking that the pointer argument of lifetime.end is pointing to an alloca.

>I don't think it's safe to hoist assume without additional checks; I think we'd need to check that the call is marked "willreturn"?

>Since this is sort of tricky, I'd prefer to split this off into a followup.

Ok, I would split Intrinsic::assume into another review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82085/new/

https://reviews.llvm.org/D82085




From cfe-commits at lists.llvm.org  Wed Jul  8 09:01:02 2020
From: cfe-commits at lists.llvm.org (Bruno Ricci via cfe-commits)
Date: Wed, 08 Jul 2020 09:01:02 -0700 (PDT)
Subject: [clang] 1ba6fb9 - [clang] Fix a crash when passing a C structure of
 incompatible type to a function with a reference parameter.
Message-ID: <5f05edbe.1c69fb81.fe4a7.0341@mx.google.com>


Author: Aleksandr Platonov
Date: 2020-07-08T16:57:54+01:00
New Revision: 1ba6fb9293967de21ae33be10603bf5ae0ce1c96

URL: https://github.com/llvm/llvm-project/commit/1ba6fb9293967de21ae33be10603bf5ae0ce1c96
DIFF: https://github.com/llvm/llvm-project/commit/1ba6fb9293967de21ae33be10603bf5ae0ce1c96.diff

LOG: [clang] Fix a crash when passing a C structure of incompatible type to a function with a reference parameter.

__builtin_va_*() and __builtin_ms_va_*() are declared as functions with a
parameter of reference type.

This patch fixes a crash when using these functions in C where an argument
of structure type is incompatible with the parameter type.

Differential Revision: https://reviews.llvm.org/D82805

Reviewed By: riccibruno

Patch by: Aleksandr Platonov 

Added: 
    clang/test/Sema/init-ref-c.c

Modified: 
    clang/lib/Sema/SemaInit.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index d46e7f86d6b3..eb07de65d266 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4693,6 +4693,9 @@ static bool isNonReferenceableGLValue(Expr *E) {
 }
 
 /// Reference initialization without resolving overloaded functions.
+///
+/// We also can get here in C if we call a builtin which is declared as
+/// a function with a parameter of reference type (such as __builtin_va_end()).
 static void TryReferenceInitializationCore(Sema &S,
                                            const InitializedEntity &Entity,
                                            const InitializationKind &Kind,
@@ -4769,15 +4772,20 @@ static void TryReferenceInitializationCore(Sema &S,
     // an rvalue. DR1287 removed the "implicitly" here.
     if (RefRelationship == Sema::Ref_Incompatible && T2->isRecordType() &&
         (isLValueRef || InitCategory.isRValue())) {
-      ConvOvlResult = TryRefInitWithConversionFunction(
-          S, Entity, Kind, Initializer, /*AllowRValues*/ isRValueRef,
-          /*IsLValueRef*/ isLValueRef, Sequence);
-      if (ConvOvlResult == OR_Success)
-        return;
-      if (ConvOvlResult != OR_No_Viable_Function)
-        Sequence.SetOverloadFailure(
-            InitializationSequence::FK_ReferenceInitOverloadFailed,
-            ConvOvlResult);
+      if (S.getLangOpts().CPlusPlus) {
+        // Try conversion functions only for C++.
+        ConvOvlResult = TryRefInitWithConversionFunction(
+            S, Entity, Kind, Initializer, /*AllowRValues*/ isRValueRef,
+            /*IsLValueRef*/ isLValueRef, Sequence);
+        if (ConvOvlResult == OR_Success)
+          return;
+        if (ConvOvlResult != OR_No_Viable_Function)
+          Sequence.SetOverloadFailure(
+              InitializationSequence::FK_ReferenceInitOverloadFailed,
+              ConvOvlResult);
+      } else {
+        ConvOvlResult = OR_No_Viable_Function;
+      }
     }
   }
 

diff  --git a/clang/test/Sema/init-ref-c.c b/clang/test/Sema/init-ref-c.c
new file mode 100644
index 000000000000..38d8c44e2fdf
--- /dev/null
+++ b/clang/test/Sema/init-ref-c.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
+
+void f() {
+  struct EmptyStruct {};
+  struct EmptyStruct S;
+  __builtin_va_end(S); // no-crash, expected-error {{non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'struct EmptyStruct'}}
+}
\ No newline at end of file


        

From cfe-commits at lists.llvm.org  Wed Jul  8 09:01:06 2020
From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:01:06 +0000 (UTC)
Subject: [PATCH] D82805: [clang] Fix a crash on passing C structure of
 incompatible type to function with reference parameter
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ba6fb929396: [clang] Fix a crash when passing a C structure of incompatible type to a… (authored by ArcsinX, committed by riccibruno).

Changed prior to commit:
  https://reviews.llvm.org/D82805?vs=274789&id=276457#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82805/new/

https://reviews.llvm.org/D82805

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/init-ref-c.c


Index: clang/test/Sema/init-ref-c.c
===================================================================
--- /dev/null
+++ clang/test/Sema/init-ref-c.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple arm-unknown-gnu -fsyntax-only -verify %s
+
+void f() {
+  struct EmptyStruct {};
+  struct EmptyStruct S;
+  __builtin_va_end(S); // no-crash, expected-error {{non-const lvalue reference to type '__builtin_va_list' cannot bind to a value of unrelated type 'struct EmptyStruct'}}
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4693,6 +4693,9 @@
 }
 
 /// Reference initialization without resolving overloaded functions.
+///
+/// We also can get here in C if we call a builtin which is declared as
+/// a function with a parameter of reference type (such as __builtin_va_end()).
 static void TryReferenceInitializationCore(Sema &S,
                                            const InitializedEntity &Entity,
                                            const InitializationKind &Kind,
@@ -4769,15 +4772,20 @@
     // an rvalue. DR1287 removed the "implicitly" here.
     if (RefRelationship == Sema::Ref_Incompatible && T2->isRecordType() &&
         (isLValueRef || InitCategory.isRValue())) {
-      ConvOvlResult = TryRefInitWithConversionFunction(
-          S, Entity, Kind, Initializer, /*AllowRValues*/ isRValueRef,
-          /*IsLValueRef*/ isLValueRef, Sequence);
-      if (ConvOvlResult == OR_Success)
-        return;
-      if (ConvOvlResult != OR_No_Viable_Function)
-        Sequence.SetOverloadFailure(
-            InitializationSequence::FK_ReferenceInitOverloadFailed,
-            ConvOvlResult);
+      if (S.getLangOpts().CPlusPlus) {
+        // Try conversion functions only for C++.
+        ConvOvlResult = TryRefInitWithConversionFunction(
+            S, Entity, Kind, Initializer, /*AllowRValues*/ isRValueRef,
+            /*IsLValueRef*/ isLValueRef, Sequence);
+        if (ConvOvlResult == OR_Success)
+          return;
+        if (ConvOvlResult != OR_No_Viable_Function)
+          Sequence.SetOverloadFailure(
+              InitializationSequence::FK_ReferenceInitOverloadFailed,
+              ConvOvlResult);
+      } else {
+        ConvOvlResult = OR_No_Viable_Function;
+      }
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82805.276457.patch
Type: text/x-patch
Size: 2386 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 09:12:04 2020
From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:12:04 +0000 (UTC)
Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition
 and MC Tests for Load and Store VSX Vector with Zero or Sign Extend
In-Reply-To: 
References: 
Message-ID: 

lei added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:431
 
+let mayLoad = 1, mayStore = 0, Predicates = [IsISA3_1] in {
+  // The XFormMemOp flag is set on the instruction format.
----------------
Instead of creating a new section like this, why not add to the existing one on line 469?  I realize that does not have `Predicates = [IsISA3_1]`, but I think that is an oversight from previous patch and it should be added as those instructions are also part of ISA3.1.


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:439
+
+let mayLoad = 0, mayStore = 1, Predicates = [IsISA3_1] in {
+  // The XFormMemOp flag is set on the instruction format.
----------------
same.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83364/new/

https://reviews.llvm.org/D83364




From cfe-commits at lists.llvm.org  Wed Jul  8 09:14:15 2020
From: cfe-commits at lists.llvm.org (Qiu Chaofan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:14:15 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

qiucf added a comment.

> In any case, I guess it would still be good to also have test cases for this aspect of the ABI on Power ...

Sure, I'd like to do pre-commit for PPC tests. (or after this landed and enable/remove `AllowNoUniqueAddr`)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Wed Jul  8 09:14:56 2020
From: cfe-commits at lists.llvm.org (Denys Petrov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:14:56 +0000 (UTC)
Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver
 infra
In-Reply-To: 
References: 
Message-ID: 

ASDenysPetrov added a comment.

@vsavchenko 
OK, let it be. )


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82381/new/

https://reviews.llvm.org/D82381




From cfe-commits at lists.llvm.org  Wed Jul  8 09:19:00 2020
From: cfe-commits at lists.llvm.org (=?UTF-8?Q?Nicolai_H=C3=A4hnle?= via cfe-commits)
Date: Wed, 08 Jul 2020 09:19:00 -0700 (PDT)
Subject: [clang] 3fa989d - DomTree: remove explicit use of
 DomTreeNodeBase::iterator
Message-ID: <5f05f1f4.1c69fb81.c7d17.0c82@mx.google.com>


Author: Nicolai Hähnle
Date: 2020-07-08T18:18:49+02:00
New Revision: 3fa989d4fd6b854209ba4e950d96b91d6d5797b4

URL: https://github.com/llvm/llvm-project/commit/3fa989d4fd6b854209ba4e950d96b91d6d5797b4
DIFF: https://github.com/llvm/llvm-project/commit/3fa989d4fd6b854209ba4e950d96b91d6d5797b4.diff

LOG: DomTree: remove explicit use of DomTreeNodeBase::iterator

Summary:
Almost all uses of these iterators, including implicit ones, really
only need the const variant (as it should be). The only exception is
in NewGVN, which changes the order of dominator tree child nodes.

Change-Id: I4b5bd71e32d71b0c67b03d4927d93fe9413726d4

Reviewers: arsenm, RKSimon, mehdi_amini, courbet, rriddle, aartbik

Subscribers: wdng, Prazek, hiraditya, kuhar, rogfer01, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, vkmr, Kayjukh, jurahul, msifontes, cfe-commits, llvm-commits

Tags: #clang, #mlir, #llvm

Differential Revision: https://reviews.llvm.org/D83087

Added: 
    

Modified: 
    clang/include/clang/Analysis/Analyses/Dominators.h
    llvm/include/llvm/CodeGen/MachineDominators.h
    llvm/include/llvm/IR/Dominators.h
    llvm/lib/Target/X86/X86InstrInfo.cpp
    llvm/lib/Transforms/Scalar/EarlyCSE.cpp
    llvm/lib/Transforms/Scalar/Sink.cpp
    llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
    mlir/include/mlir/IR/Dominance.h
    mlir/lib/Transforms/CSE.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h b/clang/include/clang/Analysis/Analyses/Dominators.h
index 51d86f6e4540..95a661138df4 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -349,7 +349,7 @@ ClangCFGPostDomReverseChildrenGetter::Get(
 ///
 template <> struct GraphTraits {
   using NodeRef = ::clang::DomTreeNode *;
-  using ChildIteratorType = ::clang::DomTreeNode::iterator;
+  using ChildIteratorType = ::clang::DomTreeNode::const_iterator;
 
   static NodeRef getEntryNode(NodeRef N) { return N; }
   static ChildIteratorType child_begin(NodeRef N) { return N->begin(); }

diff  --git a/llvm/include/llvm/CodeGen/MachineDominators.h b/llvm/include/llvm/CodeGen/MachineDominators.h
index 2d26163a76aa..cf3af4d38223 100644
--- a/llvm/include/llvm/CodeGen/MachineDominators.h
+++ b/llvm/include/llvm/CodeGen/MachineDominators.h
@@ -261,7 +261,8 @@ template  struct GraphTraits;
 template <>
 struct GraphTraits
     : public MachineDomTreeGraphTraitsBase {};
+                                           MachineDomTreeNode::const_iterator> {
+};
 
 template <>
 struct GraphTraits

diff  --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h
index 0084ac0b655a..71595cb15df4 100644
--- a/llvm/include/llvm/IR/Dominators.h
+++ b/llvm/include/llvm/IR/Dominators.h
@@ -208,7 +208,8 @@ template  struct DomTreeGraphTraitsBase {
 
 template <>
 struct GraphTraits
-    : public DomTreeGraphTraitsBase {};
+    : public DomTreeGraphTraitsBase {
+};
 
 template <>
 struct GraphTraits

diff  --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp
index 46ff62f7a4ed..42c111173570 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -8660,8 +8660,7 @@ namespace {
       }
 
       // Visit the children of this block in the dominator tree.
-      for (MachineDomTreeNode::iterator I = Node->begin(), E = Node->end();
-           I != E; ++I) {
+      for (auto I = Node->begin(), E = Node->end(); I != E; ++I) {
         Changed |= VisitNode(*I, TLSBaseAddrReg);
       }
 

diff  --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 1dac64a12d3e..ddfc8555b0a0 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -620,8 +620,8 @@ class EarlyCSE {
   public:
     StackNode(ScopedHTType &AvailableValues, LoadHTType &AvailableLoads,
               InvariantHTType &AvailableInvariants, CallHTType &AvailableCalls,
-              unsigned cg, DomTreeNode *n, DomTreeNode::iterator child,
-              DomTreeNode::iterator end)
+              unsigned cg, DomTreeNode *n, DomTreeNode::const_iterator child,
+              DomTreeNode::const_iterator end)
         : CurrentGeneration(cg), ChildGeneration(cg), Node(n), ChildIter(child),
           EndIter(end),
           Scopes(AvailableValues, AvailableLoads, AvailableInvariants,
@@ -635,7 +635,7 @@ class EarlyCSE {
     unsigned childGeneration() { return ChildGeneration; }
     void childGeneration(unsigned generation) { ChildGeneration = generation; }
     DomTreeNode *node() { return Node; }
-    DomTreeNode::iterator childIter() { return ChildIter; }
+    DomTreeNode::const_iterator childIter() { return ChildIter; }
 
     DomTreeNode *nextChild() {
       DomTreeNode *child = *ChildIter;
@@ -643,7 +643,7 @@ class EarlyCSE {
       return child;
     }
 
-    DomTreeNode::iterator end() { return EndIter; }
+    DomTreeNode::const_iterator end() { return EndIter; }
     bool isProcessed() { return Processed; }
     void process() { Processed = true; }
 
@@ -651,8 +651,8 @@ class EarlyCSE {
     unsigned CurrentGeneration;
     unsigned ChildGeneration;
     DomTreeNode *Node;
-    DomTreeNode::iterator ChildIter;
-    DomTreeNode::iterator EndIter;
+    DomTreeNode::const_iterator ChildIter;
+    DomTreeNode::const_iterator EndIter;
     NodeScope Scopes;
     bool Processed = false;
   };

diff  --git a/llvm/lib/Transforms/Scalar/Sink.cpp b/llvm/lib/Transforms/Scalar/Sink.cpp
index 677d86f8c7b4..48f289c8f17d 100644
--- a/llvm/lib/Transforms/Scalar/Sink.cpp
+++ b/llvm/lib/Transforms/Scalar/Sink.cpp
@@ -166,8 +166,8 @@ static bool SinkInstruction(Instruction *Inst,
   // dominated by one of the successors.
   // Look at all the dominated blocks and see if we can sink it in one.
   DomTreeNode *DTN = DT.getNode(Inst->getParent());
-  for (DomTreeNode::iterator I = DTN->begin(), E = DTN->end();
-      I != E && SuccToSinkTo == nullptr; ++I) {
+  for (auto I = DTN->begin(), E = DTN->end(); I != E && SuccToSinkTo == nullptr;
+       ++I) {
     BasicBlock *Candidate = (*I)->getBlock();
     // A node always immediate-dominates its children on the dominator
     // tree.

diff  --git a/llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h b/llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
index 19f5d2c00c60..a42ebc9ee955 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
@@ -30,7 +30,8 @@ using VPDomTreeNode = DomTreeNodeBase;
 /// Template specializations of GraphTraits for VPDomTreeNode.
 template <>
 struct GraphTraits
-    : public DomTreeGraphTraitsBase {};
+    : public DomTreeGraphTraitsBase {};
 
 template <>
 struct GraphTraits

diff  --git a/mlir/include/mlir/IR/Dominance.h b/mlir/include/mlir/IR/Dominance.h
index 97ec99007708..9d9a19996765 100644
--- a/mlir/include/mlir/IR/Dominance.h
+++ b/mlir/include/mlir/IR/Dominance.h
@@ -141,7 +141,7 @@ namespace llvm {
 /// DominatorTree GraphTraits specialization so the DominatorTree can be
 /// iterated by generic graph iterators.
 template <> struct GraphTraits {
-  using ChildIteratorType = mlir::DominanceInfoNode::iterator;
+  using ChildIteratorType = mlir::DominanceInfoNode::const_iterator;
   using NodeRef = mlir::DominanceInfoNode *;
 
   static NodeRef getEntryNode(NodeRef N) { return N; }

diff  --git a/mlir/lib/Transforms/CSE.cpp b/mlir/lib/Transforms/CSE.cpp
index eb31fd207d79..5f4791450c7b 100644
--- a/mlir/lib/Transforms/CSE.cpp
+++ b/mlir/lib/Transforms/CSE.cpp
@@ -64,7 +64,7 @@ struct CSE : public CSEBase {
     ScopedMapTy::ScopeTy scope;
 
     DominanceInfoNode *node;
-    DominanceInfoNode::iterator childIterator;
+    DominanceInfoNode::const_iterator childIterator;
 
     /// If this node has been fully processed yet or not.
     bool processed;


        

From cfe-commits at lists.llvm.org  Wed Jul  8 09:19:05 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits)
Date: Wed, 08 Jul 2020 16:19:05 +0000 (UTC)
Subject: [PATCH] D83087: DomTree: remove explicit use of
 DomTreeNodeBase::iterator
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG3fa989d4fd6b: DomTree: remove explicit use of DomTreeNodeBase::iterator (authored by nhaehnle).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83087/new/

https://reviews.llvm.org/D83087

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/CodeGen/MachineDominators.h
  llvm/include/llvm/IR/Dominators.h
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Transforms/Scalar/EarlyCSE.cpp
  llvm/lib/Transforms/Scalar/Sink.cpp
  llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
  mlir/include/mlir/IR/Dominance.h
  mlir/lib/Transforms/CSE.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83087.276460.patch
Type: text/x-patch
Size: 6404 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 09:31:35 2020
From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:31:35 +0000 (UTC)
Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default
In-Reply-To: 
References: 
Message-ID: 

tra accepted this revision.
tra added a comment.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655




From cfe-commits at lists.llvm.org  Wed Jul  8 09:32:57 2020
From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:32:57 +0000 (UTC)
Subject: [PATCH] D82381: [analyzer] Introduce small improvements to the solver
 infra
In-Reply-To: 
References: 
Message-ID: <10cdc0842e6f7b45c293626d83c9759d@localhost.localdomain>

NoQ accepted this revision.
NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:734
   //        expressions which we currently do not know how to negate.
-  const RangeSet *getRangeForMinusSymbol(ProgramStateRef State, SymbolRef Sym) {
+  Optional getRangeForInvertedSub(SymbolRef Sym) {
     if (const SymSymExpr *SSE = dyn_cast(Sym)) {
----------------
vsavchenko wrote:
> ASDenysPetrov wrote:
> > vsavchenko wrote:
> > > ASDenysPetrov wrote:
> > > > As for me, I'd call this like `getRangeForNegatedSymSymExpr`, since you do Negate operation inside.
> > > I'm not super happy about my name either, but I feel like it describes it better than the previous name and your version.  That function doesn't work for any `SymSymExpr` and it doesn't simply negate whatever we gave it.  It works specifically for symbolic subtractions and this is the information I want to be reflected in the name.
> > Oh, I just assumed //...Sub// at the end as a //subexpression// but you mean //subtraction//. What I'm trying to say is that we can rename it like `getRangeFor...`//the expression which this function can handle//. E.g. `getRangeForNegatedSubtractionSymSymExpr`. My point is in a speaking name.
> > 
> > I think //invertion// is not something appropriate in terms of applying minus operator. I think invertion of zero should be something opposite but not a zero. Because when you would like to implement the function which turns [A, B] into [MIN, A)U(B, MAX], what would be the name of it? I think this is an //invertion//.
> > 
> > But this is not a big deal, it's just my thoughts.
> My thought process here was that we are trying to get range for `A - B` and there is also information on `B - A`, so we can get something for `A - B` based on that.  So, it doesn't really matter what it does under the hood with ranges, it matters what its semantics are.  Here I called `B - A` //an inverted subtraction//.
> I don't really know what would be the best name, but I thought that this one makes more sense.
> Because when you would like to implement the function which turns [A, B] into [MIN, A)U(B, MAX], what would be the name of it? I think this is an //invertion//.

https://en.wikipedia.org/wiki/Complement_(set_theory)
https://en.wikipedia.org/wiki/Inverse_function

"Negated subtraction" is definitely my favorite so far. "Mirrored" might be a good layman term as well.


================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:467-470
+/// Available representations for the arguments are:
+///   * RangeSet
+///   * Optional
+///   * RangeSet *
----------------
vsavchenko wrote:
> xazax.hun wrote:
> > NoQ wrote:
> > > Why do we have these representations in the first place?
> > > 
> > > It sounds like you're treating null pointers / empty optionals equivalently to full ranges (i.e., intersecting with them has no effect). How hard would it be to simply construct an actual full range in all the places in which we currently have empty optionals?
> > +1
> > 
> > I also find this confusing. Should I interpret a None as a full or empty range? Does this depend on the context or a general rule? Is there any reason we need to handle nullable pointers or could we actually make call sites more uniform to get rid of some of the complexity here?
> > It sounds like you're treating null pointers / empty optionals equivalently to full ranges (i.e., intersecting with them has no effect)
> It is not actually true.  Empty optionals is the information that "this range information is not available for this symbol".  It is true that intersecting with them has no effect, but they are semantically different in other aspects.  
> 
> Currently solver RELIES on the information that whether the range is available or not (see my previous comment), and we simply couldn't get rid of this behavior as part of NFC.
> 
> > How hard would it be to simply construct an actual full range in all the places in which we currently have empty optionals?
> It is not hard architecturally, but it WILL make the change functional and possibly impact the performance.
> 
> > Should I interpret a None as a full or empty range?
> Neither of those.  That is the problem right now, that we rely on different sources of information for the ranges and behave differently depending on whether one piece of information is available or not.
> 
> > Does this depend on the context or a general rule?
> Semantics are always the same - this info is not available.
> 
> > Is there any reason we need to handle nullable pointers?
> `State->get(abc)` returns a nullable pointer meaning optional object, it is hard to avoid it especially because we currently behave very differently when this information is not available.
> 
> > ...could we actually make call sites more uniform to get rid of some of the complexity here?
> Yes we can, but later on. See the explanations above and in my other comment.
> it WILL make the change functional and possibly impact the performance

Mmm, yeah, i guess the necessity to construct a full range and then do the possibly O(N) intersection when it'll do nothing most of the time is indeed daunting.

Maybe we should implement full ranges as a special case in the `RangeSet` class? Like, don't actually construct the single range, just remember the type; special-case all operations on such sets to perform trivially in O(1), etc.?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82381/new/

https://reviews.llvm.org/D82381




From cfe-commits at lists.llvm.org  Wed Jul  8 09:34:25 2020
From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:34:25 +0000 (UTC)
Subject: [PATCH] D83374: [analyzer][tests] Fix zip unpacking
In-Reply-To: 
References: 
Message-ID: <7f169c3cc09ef794f1b83eaf53eef90f@localhost.localdomain>

NoQ added a comment.

For my own education, what was wrong with `join`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83374/new/

https://reviews.llvm.org/D83374




From cfe-commits at lists.llvm.org  Wed Jul  8 09:35:54 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:35:54 +0000 (UTC)
Subject: [PATCH] D83405: Factor out EXTRACTOR call
Message-ID: 

dang created this revision.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.

Depends on D83071 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83405

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3934,9 +3934,10 @@
     PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,        \
     HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
     TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)            \
-  if (((FLAGS)&options::CC1Option) &&                                          \
-      (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {            \
-    DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)&options::CC1Option) {                                            \
+    const auto &Extracted = EXTRACTOR(this->KEYPATH);                          \
+    if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE)                             \
+      DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);                \
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(                                       \
@@ -3944,10 +3945,10 @@
     HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
     TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,    \
     NEG_SPELLING)                                                              \
-  if (((FLAGS)&options::CC1Option) &&                                          \
-      (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {            \
-    DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,                \
-                 EXTRACTOR(this->KEYPATH));                                    \
+  if ((FLAGS)&options::CC1Option) {                                            \
+    const auto &Extracted = EXTRACTOR(this->KEYPATH);                          \
+    if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE)                             \
+      DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  \
   }
 
 #include "clang/Driver/Options.inc"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83405.276465.patch
Type: text/x-patch
Size: 2111 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 09:37:07 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:37:07 +0000 (UTC)
Subject: [PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine
In-Reply-To: 
References: 
Message-ID: <49f3cd586d175e2f3c80e46266a2a293@localhost.localdomain>

dang updated this revision to Diff 276466.
dang added a comment.

Rebase on top of latest changes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83211/new/

https://reviews.llvm.org/D83211

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3934,9 +3934,10 @@
     PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,        \
     HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
     TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)            \
-  if (((FLAGS)&options::CC1Option) &&                                          \
-      (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {            \
-    DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)&options::CC1Option) {                                            \
+    const auto &Extracted = EXTRACTOR(this->KEYPATH);                          \
+    if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE)                             \
+      DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);                \
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(                                       \
@@ -3944,10 +3945,10 @@
     HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
     TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,    \
     NEG_SPELLING)                                                              \
-  if (((FLAGS)&options::CC1Option) &&                                          \
-      (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {            \
-    DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,                \
-                 EXTRACTOR(this->KEYPATH));                                    \
+  if ((FLAGS)&options::CC1Option) {                                            \
+    const auto &Extracted = EXTRACTOR(this->KEYPATH);                          \
+    if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE)                             \
+      DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  \
   }
 
 #include "clang/Driver/Options.inc"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83211.276466.patch
Type: text/x-patch
Size: 2111 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 09:38:46 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:38:46 +0000 (UTC)
Subject: [PATCH] D83374: [analyzer][tests] Fix zip unpacking
In-Reply-To: 
References: 
Message-ID: 

vsavchenko added a comment.

I think that the problem is actually with the second '/', but I decided to retreat back to the form consistent to the rest `glob.glob` invocations in this file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83374/new/

https://reviews.llvm.org/D83374




From cfe-commits at lists.llvm.org  Wed Jul  8 09:38:55 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:38:55 +0000 (UTC)
Subject: [PATCH] D83406: Remove NormalizerRetTy and use the decltype of the
 KeyPath instead
Message-ID: 

dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

Depends on D83315 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83406

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83406.276467.patch
Type: text/x-patch
Size: 8594 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 09:46:17 2020
From: cfe-commits at lists.llvm.org (Sander de Smalen via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:46:17 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: 

sdesmalen added inline comments.


================
Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:369
+  if (llvm::is_contained(Features, "+v8.6a")) {
+    if (!llvm::is_contained(Features, "-i8mm") &&
+        !llvm::is_contained(Features, "+noi8mm"))
----------------
fpetrogalli wrote:
> sdesmalen wrote:
> > Is this correct and/or necessary? I would expect LLVM to just handle features in the order they're passed, and the architecture version is always processed first, e.g. `-march=armv8.6-a+noi8mm` will always first process `armv8.6a` before processing features like `noi8mm`.
> I was expecting that too, but in in this place the `+i8mm` is added after whatever the user have passed to -march, which means that without this extra check the user input `-mattr=armv8.6a+sve+noimm8` becomes broken because we are adding `-target-feature=+i8mm` after `-i8mm`.  This behavior is guarded by a regression tests that starts failing if I don't use these extra checks. This was not needed in the original place were I added the functionality because the `+i8mm` was being added right after `+v8.6a` and before splitting up the `+sve+noi8mm`, so that the user input was the one (un)setting the feature.
As you said, we end up with a Feature list as follows:

  parsing(-march=armv8.6-a+noi8mm)
  => Features = [ v8.6a ]

  parsing(+noi8mm)
  => Features = [ v8.6a, -i8mm ]

  Then going through the feature list again:
  => Features = [ v8.6a, -i8mm, +i8mm ]
                  ^^^^^          ^^^^
                    \_____________/
                       adds +i8mm

To fix that, you can insert these features into the list straight after "+v8.6a", instead of appending at the end of the Features list. Either that, or calling `llvm::AArch64::getDefaultExtensions() + llvm::AArch64::getExtensionFeatures()` in `getAArch64ArchFeaturesFromMarch` like is done in `DecodeAArch64Mcpu`, which should do all this for free. That seems like a more invasive change though that you shouldn't try to do in this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079




From cfe-commits at lists.llvm.org  Wed Jul  8 09:53:42 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 16:53:42 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
Message-ID: 

martong created this revision.
martong added reviewers: gamesh411, Szelethus, NoQ.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.

Adding networking functions from the POSIX standard (2017). This includes
functions that deal with sockets from socket.h, netdb.h.

In 'socket.h' of some libc implementations (e.g. glibc) with C99, sockaddr
parameter is a transparent union of the underlying sockaddr_ family of pointers
instead of being a pointer to struct sockaddr. In these cases, the standardized
signature will not match, thus we try to match with another signature that has
the joker Irrelevant type. In the case of transparent unions, we also not add
those constraints which require pointer types for the sockaddr param.

Interestingly, in 'netdb.h' sockaddr is not handled as a transparent union.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83407.276469.patch
Type: text/x-patch
Size: 24246 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 10:01:29 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:01:29 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: 

martong marked an inline comment as done.
martong added inline comments.


================
Comment at: clang/test/Analysis/std-c-library-functions-POSIX.c:200
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {
----------------
Remove redundant duplicated line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Wed Jul  8 10:07:28 2020
From: cfe-commits at lists.llvm.org (via cfe-commits)
Date: Wed, 08 Jul 2020 10:07:28 -0700 (PDT)
Subject: [clang] 63b0f8c - [RecordLayout] Fix ItaniumRecordLayoutBuilder so
 that is grabs the correct bases class offsets from the external source
Message-ID: <5f05fd50.1c69fb81.4a405.1267@mx.google.com>


Author: shafik
Date: 2020-07-08T10:07:15-07:00
New Revision: 63b0f8c788d8c6978feb099fd6db8fe219c4d166

URL: https://github.com/llvm/llvm-project/commit/63b0f8c788d8c6978feb099fd6db8fe219c4d166
DIFF: https://github.com/llvm/llvm-project/commit/63b0f8c788d8c6978feb099fd6db8fe219c4d166.diff

LOG: [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source

Currently the ItaniumRecordLayoutBuilder when laying out base classes has the virtual
and non-virtual bases mixed up when pulling the base class layouts from the external source.

This came up in an LLDB bug where on arm64 because of differences in how it deals with
tail padding would layout the bases differently without the correct layout from the
external source (LLDB). This would result in some fields being off by 4 bytes.

Differential Revision: https://reviews.llvm.org/D83008

Added: 
    lldb/test/API/lang/cpp/alignas_base_class/Makefile
    lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
    lldb/test/API/lang/cpp/alignas_base_class/main.cpp

Modified: 
    clang/lib/AST/RecordLayoutBuilder.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index b44957a35279..d56c7e2ab8c0 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@ ItaniumRecordLayoutBuilder::LayoutBase(const BaseSubobjectInfo *Base) {
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-    // FIXME: This appears to be reversed.
     if (Base->IsVirtual)
-      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-    else
       HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+    else
+      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/Makefile b/lldb/test/API/lang/cpp/alignas_base_class/Makefile
new file mode 100644
index 000000000000..99998b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
new file mode 100644
index 000000000000..25f37ab7fe5f
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @no_debug_info_test
+    def test(self):
+        self.build()
+        self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+        # The offset of f2 should be 8 because of `alignas(8)`.
+        self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8")

diff  --git a/lldb/test/API/lang/cpp/alignas_base_class/main.cpp b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
new file mode 100644
index 000000000000..8dfced6c784e
--- /dev/null
+++ b/lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}


        

From cfe-commits at lists.llvm.org  Wed Jul  8 10:07:30 2020
From: cfe-commits at lists.llvm.org (Shafik Yaghmour via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:07:30 +0000 (UTC)
Subject: [PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the
 correct bases class offsets from the external source
In-Reply-To: 
References: 
Message-ID: <5126cdf56bae02b7149afd488d3c3984@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG63b0f8c788d8: [RecordLayout] Fix ItaniumRecordLayoutBuilder so that is grabs the correct… (authored by shafik).
Herald added projects: clang, LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83008/new/

https://reviews.llvm.org/D83008

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  lldb/test/API/lang/cpp/alignas_base_class/Makefile
  lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
  lldb/test/API/lang/cpp/alignas_base_class/main.cpp


Index: lldb/test/API/lang/cpp/alignas_base_class/main.cpp
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/main.cpp
@@ -0,0 +1,13 @@
+struct B1 {
+  char f1;
+};
+
+struct alignas(8) B2 {
+  char f2;
+};
+
+struct D : B1, B2 {};
+
+D d3g;
+
+int main() {}
Index: lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/TestAlignAsBaseClass.py
@@ -0,0 +1,16 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @no_debug_info_test
+    def test(self):
+        self.build()
+        self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+
+        # The offset of f2 should be 8 because of `alignas(8)`.
+        self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8")
Index: lldb/test/API/lang/cpp/alignas_base_class/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/lang/cpp/alignas_base_class/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1187,11 +1187,10 @@
   // Query the external layout to see if it provides an offset.
   bool HasExternalLayout = false;
   if (UseExternalLayout) {
-    // FIXME: This appears to be reversed.
     if (Base->IsVirtual)
-      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
-    else
       HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset);
+    else
+      HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset);
   }
 
   // Clang <= 6 incorrectly applied the 'packed' attribute to base classes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83008.276475.patch
Type: text/x-patch
Size: 2096 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 10:10:59 2020
From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:10:59 +0000 (UTC)
Subject: [PATCH] D83374: [analyzer][tests] Fix zip unpacking
In-Reply-To: 
References: 
Message-ID: 

NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

> I think that the problem is actually with the second '/'

I thought the OS always ignores those? Ok anyway fair enough!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83374/new/

https://reviews.llvm.org/D83374




From cfe-commits at lists.llvm.org  Wed Jul  8 10:11:07 2020
From: cfe-commits at lists.llvm.org (Yaxun Liu via cfe-commits)
Date: Wed, 08 Jul 2020 10:11:07 -0700 (PDT)
Subject: [clang] 1eaad01 - [CUDA][HIP] Let lambda be host device by default
Message-ID: <5f05fe2b.1c69fb81.a6e67.0f41@mx.google.com>


Author: Yaxun (Sam) Liu
Date: 2020-07-08T13:10:26-04:00
New Revision: 1eaad01046c88be6bf65265a2bcc53db5a5b48d0

URL: https://github.com/llvm/llvm-project/commit/1eaad01046c88be6bf65265a2bcc53db5a5b48d0
DIFF: https://github.com/llvm/llvm-project/commit/1eaad01046c88be6bf65265a2bcc53db5a5b48d0.diff

LOG: [CUDA][HIP] Let lambda be host device by default

This patch let lambda be host device by default and adds diagnostics for
capturing host variable by reference in device lambda.

Differential Revision: https://reviews.llvm.org/D78655

Added: 
    clang/test/CodeGenCUDA/lambda.cu
    clang/test/SemaCUDA/lambda.cu

Modified: 
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/include/clang/Sema/Sema.h
    clang/lib/Sema/SemaCUDA.cpp
    clang/lib/Sema/SemaLambda.cpp
    clang/test/SemaCUDA/Inputs/cuda.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e99fd3d1f105..c0d0acccb181 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7999,6 +7999,10 @@ def err_ref_bad_target : Error<
 def err_ref_bad_target_global_initializer : Error<
   "reference to %select{__device__|__global__|__host__|__host__ __device__}0 "
   "function %1 in global initializer">;
+def err_capture_bad_target : Error<
+  "capture host variable %0 by reference in device or host device lambda function">;
+def err_capture_bad_target_this_ptr : Error<
+  "capture host side class data member by this pointer in device or host device lambda function">;
 def warn_kern_is_method : Extension<
   "kernel function %0 is a member function; this may not be accepted by nvcc">,
   InGroup;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8ee7dd74712d..a540d788f4d8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11828,12 +11828,13 @@ class Sema final {
   /// - Otherwise, returns true without emitting any diagnostics.
   bool CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee);
 
+  void CUDACheckLambdaCapture(CXXMethodDecl *D, const sema::Capture &Capture);
+
   /// Set __device__ or __host__ __device__ attributes on the given lambda
   /// operator() method.
   ///
-  /// CUDA lambdas declared inside __device__ or __global__ functions inherit
-  /// the __device__ attribute.  Similarly, lambdas inside __host__ __device__
-  /// functions become __host__ __device__ themselves.
+  /// CUDA lambdas by default is host device function unless it has explicit
+  /// host or device attribute.
   void CUDASetLambdaAttrs(CXXMethodDecl *Method);
 
   /// Finds a function in \p Matches with highest calling priority

diff  --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp
index f54d97a2a319..283a04683a32 100644
--- a/clang/lib/Sema/SemaCUDA.cpp
+++ b/clang/lib/Sema/SemaCUDA.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Sema/SemaInternal.h"
@@ -746,20 +747,58 @@ bool Sema::CheckCUDACall(SourceLocation Loc, FunctionDecl *Callee) {
          DiagKind != DeviceDiagBuilder::K_ImmediateWithCallStack;
 }
 
+// Check the wrong-sided reference capture of lambda for CUDA/HIP.
+// A lambda function may capture a stack variable by reference when it is
+// defined and uses the capture by reference when the lambda is called. When
+// the capture and use happen on 
diff erent sides, the capture is invalid and
+// should be diagnosed.
+void Sema::CUDACheckLambdaCapture(CXXMethodDecl *Callee,
+                                  const sema::Capture &Capture) {
+  // In host compilation we only need to check lambda functions emitted on host
+  // side. In such lambda functions, a reference capture is invalid only
+  // if the lambda structure is populated by a device function or kernel then
+  // is passed to and called by a host function. However that is impossible,
+  // since a device function or kernel can only call a device function, also a
+  // kernel cannot pass a lambda back to a host function since we cannot
+  // define a kernel argument type which can hold the lambda before the lambda
+  // itself is defined.
+  if (!LangOpts.CUDAIsDevice)
+    return;
+
+  // File-scope lambda can only do init captures for global variables, which
+  // results in passing by value for these global variables.
+  FunctionDecl *Caller = dyn_cast(CurContext);
+  if (!Caller)
+    return;
+
+  // In device compilation, we only need to check lambda functions which are
+  // emitted on device side. For such lambdas, a reference capture is invalid
+  // only if the lambda structure is populated by a host function then passed
+  // to and called in a device function or kernel.
+  bool CalleeIsDevice = Callee->hasAttr();
+  bool CallerIsHost =
+      !Caller->hasAttr() && !Caller->hasAttr();
+  bool ShouldCheck = CalleeIsDevice && CallerIsHost;
+  if (!ShouldCheck || !Capture.isReferenceCapture())
+    return;
+  auto DiagKind = DeviceDiagBuilder::K_Deferred;
+  if (Capture.isVariableCapture()) {
+    DeviceDiagBuilder(DiagKind, Capture.getLocation(),
+                      diag::err_capture_bad_target, Callee, *this)
+        << Capture.getVariable();
+  } else if (Capture.isThisCapture()) {
+    DeviceDiagBuilder(DiagKind, Capture.getLocation(),
+                      diag::err_capture_bad_target_this_ptr, Callee, *this);
+  }
+  return;
+}
+
 void Sema::CUDASetLambdaAttrs(CXXMethodDecl *Method) {
   assert(getLangOpts().CUDA && "Should only be called during CUDA compilation");
   if (Method->hasAttr() || Method->hasAttr())
     return;
-  FunctionDecl *CurFn = dyn_cast(CurContext);
-  if (!CurFn)
-    return;
-  CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
-  if (Target == CFT_Global || Target == CFT_Device) {
-    Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
-  } else if (Target == CFT_HostDevice) {
-    Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
-    Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
-  }
+  Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+  Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
 }
 
 void Sema::checkCUDATargetOverload(FunctionDecl *NewFD,

diff  --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index e751a73957d0..657ed13f207a 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -990,8 +990,7 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
   // Attributes on the lambda apply to the method.
   ProcessDeclAttributes(CurScope, Method, ParamInfo);
 
-  // CUDA lambdas get implicit attributes based on the scope in which they're
-  // declared.
+  // CUDA lambdas get implicit host and device attributes.
   if (getLangOpts().CUDA)
     CUDASetLambdaAttrs(Method);
 
@@ -1780,6 +1779,9 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
       BuildCaptureField(Class, From);
       Captures.push_back(Capture);
       CaptureInits.push_back(Init.get());
+
+      if (LangOpts.CUDA)
+        CUDACheckLambdaCapture(CallOperator, From);
     }
 
     Class->setCaptures(Captures);

diff  --git a/clang/test/CodeGenCUDA/lambda.cu b/clang/test/CodeGenCUDA/lambda.cu
new file mode 100644
index 000000000000..8a639c90f266
--- /dev/null
+++ b/clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,85 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu \
+// RUN:   | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN_CAPTURE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_capturevEUlvE_EvT_\00"
+// HOST: @[[KERN_RESOLVE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_resolvevEUlvE_EvT_\00"
+
+// Check functions emitted for test_capture in host compilation.
+// Check lambda is not emitted in host compilation.
+// HOST-LABEL: define void @_Z12test_capturev
+// HOST:  call void @_Z19test_capture_helperIZ12test_capturevEUlvE_EvT_
+// HOST-LABEL: define internal void @_Z19test_capture_helperIZ12test_capturevEUlvE_EvT_
+// HOST:  call void @_Z16__device_stub__gIZ12test_capturevEUlvE_EvT_
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+
+// Check functions emitted for test_resolve in host compilation.
+// Check host version of template function 'overloaded' is emitted and called
+// by the lambda function.
+// HOST-LABEL: define void @_Z12test_resolvev
+// HOST:  call void @_Z19test_resolve_helperIZ12test_resolvevEUlvE_EvT_()
+// HOST-LABEL: define internal void @_Z19test_resolve_helperIZ12test_resolvevEUlvE_EvT_
+// HOST:  call void @_Z16__device_stub__gIZ12test_resolvevEUlvE_EvT_
+// HOST:  call void @_ZZ12test_resolvevENKUlvE_clEv
+// HOST-LABEL: define internal void @_ZZ12test_resolvevENKUlvE_clEv
+// HOST:  call i32 @_Z10overloadedIiET_v
+// HOST-LABEL: define linkonce_odr i32 @_Z10overloadedIiET_v
+// HOST:  ret i32 2
+
+// Check kernel is registered with correct device side kernel name.
+// HOST: @__hipRegisterFunction({{.*}}@[[KERN_CAPTURE]]
+// HOST: @__hipRegisterFunction({{.*}}@[[KERN_RESOLVE]]
+
+// DEV: @a = addrspace(1) externally_initialized global i32 0
+
+// Check functions emitted for test_capture in device compilation.
+// Check lambda is emitted in device compilation and accessing device variable.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ12test_capturevEUlvE_EvT_
+// DEV:  call void @_ZZ12test_capturevENKUlvE_clEv
+// DEV-LABEL: define internal void @_ZZ12test_capturevENKUlvE_clEv
+// DEV:  store i32 1, i32* addrspacecast (i32 addrspace(1)* @a to i32*)
+
+// Check functions emitted for test_resolve in device compilation.
+// Check device version of template function 'overloaded' is emitted and called
+// by the lambda function.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ12test_resolvevEUlvE_EvT_
+// DEV:  call void @_ZZ12test_resolvevENKUlvE_clEv
+// DEV-LABEL: define internal void @_ZZ12test_resolvevENKUlvE_clEv
+// DEV:  call i32 @_Z10overloadedIiET_v
+// DEV-LABEL: define linkonce_odr i32 @_Z10overloadedIiET_v
+// DEV:  ret i32 1
+
+__device__ int a;
+
+template
+__device__ T overloaded() { return 1; }
+
+template
+__host__ T overloaded() { return 2; }
+
+template
+__global__ void g(F f) { f(); }
+
+template
+void test_capture_helper(F f) { g<<<1,1>>>(f); }
+
+template
+void test_resolve_helper(F f) { g<<<1,1>>>(f); f(); }
+
+// Test capture of device variable in lambda function.
+void test_capture(void) {
+  test_capture_helper([](){ a = 1;});
+}
+
+// Test resolving host/device function in lambda function.
+// Callee should resolve to correct host/device function based on where
+// the lambda function is called, not where it is defined.
+void test_resolve(void) {
+  test_resolve_helper([](){ overloaded();});
+}

diff  --git a/clang/test/SemaCUDA/Inputs/cuda.h b/clang/test/SemaCUDA/Inputs/cuda.h
index 2600bfa9c470..901f8e0c17cf 100644
--- a/clang/test/SemaCUDA/Inputs/cuda.h
+++ b/clang/test/SemaCUDA/Inputs/cuda.h
@@ -17,6 +17,19 @@ struct dim3 {
   __host__ __device__ dim3(unsigned x, unsigned y = 1, unsigned z = 1) : x(x), y(y), z(z) {}
 };
 
+#ifdef __HIP__
+typedef struct hipStream *hipStream_t;
+typedef enum hipError {} hipError_t;
+int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
+                     hipStream_t stream = 0);
+extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+                                                 size_t sharedSize = 0,
+                                                 hipStream_t stream = 0);
+extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
+                                      dim3 blockDim, void **args,
+                                      size_t sharedMem,
+                                      hipStream_t stream);
+#else
 typedef struct cudaStream *cudaStream_t;
 typedef enum cudaError {} cudaError_t;
 
@@ -29,6 +42,7 @@ extern "C" int __cudaPushCallConfiguration(dim3 gridSize, dim3 blockSize,
 extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
                                         dim3 blockDim, void **args,
                                         size_t sharedMem, cudaStream_t stream);
+#endif
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }

diff  --git a/clang/test/SemaCUDA/lambda.cu b/clang/test/SemaCUDA/lambda.cu
new file mode 100644
index 000000000000..6f305a683c00
--- /dev/null
+++ b/clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify=com %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcuda-is-device -verify=com,dev %s
+
+#include "Inputs/cuda.h"
+
+auto global_lambda = [] () { return 123; };
+
+template
+__global__ void kernel(F f) { f(); }
+// dev-note at -1 7{{called by 'kernel<(lambda}}
+
+__host__ __device__ void hd(int x);
+
+class A {
+  int b;
+public:
+  void test() {
+    [=](){ hd(b); }();
+
+    [&](){ hd(b); }();
+
+    kernel<<<1,1>>>([](){ hd(0); });
+
+    kernel<<<1,1>>>([=](){ hd(b); });
+    // dev-error at -1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+    kernel<<<1,1>>>([&](){ hd(b); });
+    // dev-error at -1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+    kernel<<<1,1>>>([&] __device__ (){ hd(b); });
+    // dev-error at -1 {{capture host side class data member by this pointer in device or host device lambda function}}
+
+    kernel<<<1,1>>>([&](){
+      auto f = [&]{ hd(b); };
+      // dev-error at -1 {{capture host side class data member by this pointer in device or host device lambda function}}
+      f();
+    });
+  }
+};
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){};
+  // com-error at -1 {{kernel function 'operator()' must be a free function or static member function}}
+
+  int b;
+  [&](){ hd(b); }();
+
+  [=, &b](){ hd(b); }();
+
+  kernel<<<1,1>>>(global_lambda);
+
+  kernel<<<1,1>>>([](){ hd(0); });
+
+  kernel<<<1,1>>>([=](){ hd(b); });
+
+  kernel<<<1,1>>>([b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){ hd(b); });
+  // dev-error at -1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([=, &b](){ hd(b); });
+  // dev-error at -1 {{capture host variable 'b' by reference in device or host device lambda function}}
+
+  kernel<<<1,1>>>([&, b](){ hd(b); });
+
+  kernel<<<1,1>>>([&](){
+      auto f = [&]{ hd(b); };
+      // dev-error at -1 {{capture host variable 'b' by reference in device or host device lambda function}}
+      f();
+  });
+
+  return 0;
+}


        

From cfe-commits at lists.llvm.org  Wed Jul  8 10:11:12 2020
From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:11:12 +0000 (UTC)
Subject: [PATCH] D78655: [CUDA][HIP] Let lambda be host device by default
In-Reply-To: 
References: 
Message-ID: <3c93c1cce06d81eeef9946c348ccd99f@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rG1eaad01046c8: [CUDA][HIP] Let lambda be host device by default (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78655/new/

https://reviews.llvm.org/D78655

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/lambda.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78655.276476.patch
Type: text/x-patch
Size: 13788 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 10:20:38 2020
From: cfe-commits at lists.llvm.org (Greg Clayton via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:20:38 +0000 (UTC)
Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event
In-Reply-To: 
References: 
Message-ID: 

clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Looks good!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82477/new/

https://reviews.llvm.org/D82477




From cfe-commits at lists.llvm.org  Wed Jul  8 10:23:50 2020
From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:23:50 +0000 (UTC)
Subject: [PATCH] D82646: [MSP430] Align the _Complex ABI with current
 msp430-gcc
In-Reply-To: 
References: 
Message-ID: <4735dbd2e3270057d1f250b5c0528ffe@localhost.localdomain>

atrosinenko updated this revision to Diff 276480.
atrosinenko added a comment.

Support int/long/long long `_Complex` types (GCC extension). According to msp430-gcc v9.2.0, they behave identically.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82646/new/

https://reviews.llvm.org/D82646

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/msp430-abi-complex.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82646.276480.patch
Type: text/x-patch
Size: 7982 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 10:37:17 2020
From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits)
Date: Wed, 08 Jul 2020 10:37:17 -0700 (PDT)
Subject: [clang] 01d5cc5 - hwasan: Don't pass the tagged-globals
 target-feature to non-aarch64 backends.
Message-ID: <5f06044d.1c69fb81.daa83.11a2@mx.google.com>


Author: Craig Topper
Date: 2020-07-08T10:36:48-07:00
New Revision: 01d5cc5386affeda878e7e21b57c2a7e050d7b0a

URL: https://github.com/llvm/llvm-project/commit/01d5cc5386affeda878e7e21b57c2a7e050d7b0a
DIFF: https://github.com/llvm/llvm-project/commit/01d5cc5386affeda878e7e21b57c2a7e050d7b0a.diff

LOG: hwasan: Don't pass the tagged-globals target-feature to non-aarch64 backends.

The other backends don't know what this feature is and print a
message to stderr.

I recently tried to rework some target feature stuff in X86 and
this unknown feature tripped an assert I added.

Differential Revision: https://reviews.llvm.org/D83369

Added: 
    

Modified: 
    clang/lib/Driver/SanitizerArgs.cpp
    clang/test/Driver/fsanitize.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 9d307e8097cb..0b81152d57f6 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
     CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
     CmdArgs.push_back("-target-feature");
     CmdArgs.push_back("+tagged-globals");
   }

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 9ff2bdf58d6c..7340bfb35e40 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in '-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POINTER-ALL


        

From cfe-commits at lists.llvm.org  Wed Jul  8 10:37:28 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:37:28 +0000 (UTC)
Subject: [PATCH] D83369: hwasan: Don't pass the tagged-globals target-feature
 to non-aarch64 backends.
In-Reply-To: 
References: 
Message-ID: <0eae3bc82ff5b720ae7362bfcd219031@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG01d5cc5386af: hwasan: Don't pass the tagged-globals target-feature to non-aarch64 backends. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83369/new/

https://reviews.llvm.org/D83369

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===================================================================
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -868,9 +868,7 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=platform %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-PLATFORM-ABI
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-hwaddress-abi=foo %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-FOO-ABI
 // CHECK-HWASAN-INTERCEPTOR-ABI: "-default-function-attr" "hwasan-abi=interceptor"
-// CHECK-HWASAN-INTERCEPTOR-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-PLATFORM-ABI: "-default-function-attr" "hwasan-abi=platform"
-// CHECK-HWASAN-PLATFORM-ABI: "-target-feature" "+tagged-globals"
 // CHECK-HWASAN-FOO-ABI: error: invalid value 'foo' in '-fsanitize-hwaddress-abi=foo'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,pointer-compare,pointer-subtract %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-POINTER-ALL
Index: clang/lib/Driver/SanitizerArgs.cpp
===================================================================
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1068,7 +1068,7 @@
     CmdArgs.push_back(Args.MakeArgString("hwasan-abi=" + HwasanAbi));
   }
 
-  if (Sanitizers.has(SanitizerKind::HWAddress)) {
+  if (Sanitizers.has(SanitizerKind::HWAddress) && TC.getTriple().isAArch64()) {
     CmdArgs.push_back("-target-feature");
     CmdArgs.push_back("+tagged-globals");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83369.276488.patch
Type: text/x-patch
Size: 1566 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 10:46:13 2020
From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits)
Date: Wed, 08 Jul 2020 10:46:13 -0700 (PDT)
Subject: [clang] 82206e7 - [X86] Enabled a bunch of 64-bit Interlocked*
 functions intrinsics on 32-bit Windows to match recent MSVC
Message-ID: <5f060665.1c69fb81.a70fd.11f3@mx.google.com>


Author: Craig Topper
Date: 2020-07-08T10:39:56-07:00
New Revision: 82206e7fb49d9593d946599b107e8a8ad29a7d22

URL: https://github.com/llvm/llvm-project/commit/82206e7fb49d9593d946599b107e8a8ad29a7d22
DIFF: https://github.com/llvm/llvm-project/commit/82206e7fb49d9593d946599b107e8a8ad29a7d22.diff

LOG: [X86] Enabled a bunch of 64-bit Interlocked* functions intrinsics on 32-bit Windows to match recent MSVC

This enables _InterlockedAnd64/_InterlockedOr64/_InterlockedXor64/_InterlockedDecrement64/_InterlockedIncrement64/_InterlockedExchange64/_InterlockedExchangeAdd64/_InterlockedExchangeSub64 on 32-bit Windows

The backend already knows how to expand these to a loop using cmpxchg8b on 32-bit targets.

Fixes PR46595

Differential Revision: https://reviews.llvm.org/D83254

Added: 
    

Modified: 
    clang/include/clang/Basic/BuiltinsX86.def
    clang/include/clang/Basic/BuiltinsX86_64.def
    clang/lib/Headers/intrin.h
    clang/test/CodeGen/ms-intrinsics.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/BuiltinsX86.def b/clang/include/clang/Basic/BuiltinsX86.def
index 7dcbcf086ede..35fb98352ec2 100644
--- a/clang/include/clang/Basic/BuiltinsX86.def
+++ b/clang/include/clang/Basic/BuiltinsX86.def
@@ -1934,6 +1934,15 @@ TARGET_HEADER_BUILTIN(__readgsword,  "UsUNi", "nh", "intrin.h", ALL_MS_LANGUAGES
 TARGET_HEADER_BUILTIN(__readgsdword, "UNiUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__readgsqword, "ULLiUNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 
+TARGET_HEADER_BUILTIN(_InterlockedAnd64,         "WiWiD*Wi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedDecrement64,   "WiWiD*",   "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchange64,    "WiWiD*Wi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64, "WiWiD*Wi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedExchangeSub64, "WiWiD*Wi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedIncrement64,   "WiWiD*",   "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedOr64,          "WiWiD*Wi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+TARGET_HEADER_BUILTIN(_InterlockedXor64,         "WiWiD*Wi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN
 #undef TARGET_HEADER_BUILTIN

diff  --git a/clang/include/clang/Basic/BuiltinsX86_64.def b/clang/include/clang/Basic/BuiltinsX86_64.def
index 7feccd2a81a0..f66ae78f7e81 100644
--- a/clang/include/clang/Basic/BuiltinsX86_64.def
+++ b/clang/include/clang/Basic/BuiltinsX86_64.def
@@ -33,14 +33,6 @@ TARGET_HEADER_BUILTIN(__faststorefence, "v", "nh", "intrin.h", ALL_MS_LANGUAGES,
 TARGET_HEADER_BUILTIN(__shiftleft128, "ULLiULLiULLiUc", "nch", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(__shiftright128, "ULLiULLiULLiUc", "nch", "intrin.h", ALL_MS_LANGUAGES, "")
 
-TARGET_HEADER_BUILTIN(_InterlockedAnd64,         "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedDecrement64,   "LLiLLiD*",    "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedExchange64,    "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedExchangeAdd64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedExchangeSub64, "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedIncrement64,   "LLiLLiD*",    "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedOr64,          "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
-TARGET_HEADER_BUILTIN(_InterlockedXor64,         "LLiLLiD*LLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_InterlockedCompareExchange128, "UcLLiD*LLiLLiLLi*", "nh", "intrin.h", ALL_MS_LANGUAGES, "cx16")
 
 TARGET_BUILTIN(__builtin_ia32_readeflags_u64, "UOi", "n", "")

diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index f85f7a2beb49..871b47ca8267 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -289,6 +289,9 @@ unsigned char _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask);
 static __inline__
 unsigned char _BitScanReverse64(unsigned long *_Index, unsigned __int64 _Mask);
 
+#endif
+
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 static __inline__
 __int64 _InterlockedDecrement64(__int64 volatile *_Addend);
 static __inline__

diff  --git a/clang/test/CodeGen/ms-intrinsics.c b/clang/test/CodeGen/ms-intrinsics.c
index fed789e60d37..5182ae403984 100644
--- a/clang/test/CodeGen/ms-intrinsics.c
+++ b/clang/test/CodeGen/ms-intrinsics.c
@@ -523,72 +523,72 @@ void test_iso_volatile_store64(__int64 volatile *p, __int64 v) { __iso_volatile_
 // CHECK: store volatile i64 %v, i64* %p
 
 
-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
 __int64 test_InterlockedExchange64(__int64 volatile *value, __int64 mask) {
   return _InterlockedExchange64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedExchange64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw xchg i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedExchange64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw xchg i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedExchangeAdd64(__int64 volatile *value, __int64 mask) {
   return _InterlockedExchangeAdd64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedExchangeAdd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw add i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedExchangeAdd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw add i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedExchangeSub64(__int64 volatile *value, __int64 mask) {
   return _InterlockedExchangeSub64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedExchangeSub64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw sub i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedExchangeSub64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw sub i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedOr64(__int64 volatile *value, __int64 mask) {
   return _InterlockedOr64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedOr64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw or i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedOr64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw or i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedXor64(__int64 volatile *value, __int64 mask) {
   return _InterlockedXor64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedXor64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw xor i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedXor64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw xor i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedAnd64(__int64 volatile *value, __int64 mask) {
   return _InterlockedAnd64(value, mask);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedAnd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
-// CHECK-ARM-X64:   [[RESULT:%[0-9]+]] = atomicrmw and i64* %value, i64 %mask seq_cst
-// CHECK-ARM-X64:   ret i64 [[RESULT:%[0-9]+]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedAnd64(i64*{{[a-z_ ]*}}%value, i64{{[a-z_ ]*}}%mask){{.*}}{
+// CHECK:   [[RESULT:%[0-9]+]] = atomicrmw and i64* %value, i64 %mask seq_cst
+// CHECK:   ret i64 [[RESULT:%[0-9]+]]
+// CHECK: }
 
 __int64 test_InterlockedIncrement64(__int64 volatile *Addend) {
   return _InterlockedIncrement64(Addend);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedIncrement64(i64*{{[a-z_ ]*}}%Addend){{.*}}{
-// CHECK-ARM-X64: [[TMP:%[0-9]+]] = atomicrmw add i64* %Addend, i64 1 seq_cst
-// CHECK-ARM-X64: [[RESULT:%[0-9]+]] = add i64 [[TMP]], 1
-// CHECK-ARM-X64: ret i64 [[RESULT]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedIncrement64(i64*{{[a-z_ ]*}}%Addend){{.*}}{
+// CHECK: [[TMP:%[0-9]+]] = atomicrmw add i64* %Addend, i64 1 seq_cst
+// CHECK: [[RESULT:%[0-9]+]] = add i64 [[TMP]], 1
+// CHECK: ret i64 [[RESULT]]
+// CHECK: }
 
 __int64 test_InterlockedDecrement64(__int64 volatile *Addend) {
   return _InterlockedDecrement64(Addend);
 }
-// CHECK-ARM-X64: define{{.*}}i64 @test_InterlockedDecrement64(i64*{{[a-z_ ]*}}%Addend){{.*}}{
-// CHECK-ARM-X64: [[TMP:%[0-9]+]] = atomicrmw sub i64* %Addend, i64 1 seq_cst
-// CHECK-ARM-X64: [[RESULT:%[0-9]+]] = add i64 [[TMP]], -1
-// CHECK-ARM-X64: ret i64 [[RESULT]]
-// CHECK-ARM-X64: }
+// CHECK: define{{.*}}i64 @test_InterlockedDecrement64(i64*{{[a-z_ ]*}}%Addend){{.*}}{
+// CHECK: [[TMP:%[0-9]+]] = atomicrmw sub i64* %Addend, i64 1 seq_cst
+// CHECK: [[RESULT:%[0-9]+]] = add i64 [[TMP]], -1
+// CHECK: ret i64 [[RESULT]]
+// CHECK: }
 
 #endif
 


        

From cfe-commits at lists.llvm.org  Wed Jul  8 10:46:27 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:46:27 +0000 (UTC)
Subject: [PATCH] D83254: [X86] Enabled a bunch of 64-bit Interlocked*
 functions intrinsics on 32-bit Windows to match recent MSVC
In-Reply-To: 
References: 
Message-ID: <49c4ccf5df700f9ec7c3ad698cd39824@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG82206e7fb49d: [X86] Enabled a bunch of 64-bit Interlocked* functions intrinsics on 32-bit… (authored by craig.topper).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83254/new/

https://reviews.llvm.org/D83254

Files:
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/lib/Headers/intrin.h
  clang/test/CodeGen/ms-intrinsics.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83254.276489.patch
Type: text/x-patch
Size: 8795 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 10:32:18 2020
From: cfe-commits at lists.llvm.org (Gui Andrade via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 17:32:18 +0000 (UTC)
Subject: [PATCH] D81678: Introduce noundef attribute at call sites for
 stricter poison analysis
In-Reply-To: 
References: 
Message-ID: 

guiand updated this revision to Diff 276487.
guiand added a comment.

Per @nikic's suggestion, I isolated the LLVM side of the changes to a separate revision D83412 , which should be good to go.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81678/new/

https://reviews.llvm.org/D81678

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/indirect-noundef.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81678.276487.patch
Type: text/x-patch
Size: 5753 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 11:06:26 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 18:06:26 +0000 (UTC)
Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures
In-Reply-To: 
References: 
Message-ID: <43a7c527e05b7b8c030119473408e398@localhost.localdomain>

MaskRay added inline comments.


================
Comment at: clang/test/Driver/program-path-priority.c:117
 // RUN: mv %t/$DEFAULT_TRIPLE-gcc %t/prefix
+// RUN: mv %t/%target_triple-gcc %t/prefix
 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
----------------
If $DEFAULT_TRIPLE == %target_triple, this mv command will fail.

The same applies to the rm below.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055




From cfe-commits at lists.llvm.org  Wed Jul  8 11:32:26 2020
From: cfe-commits at lists.llvm.org (Tyker via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 18:32:26 +0000 (UTC)
Subject: [PATCH] D71739: [AssumeBundles] Use operand bundles to encode
 alignment assumptions
In-Reply-To: 
References: 
Message-ID: <663dd694f8103ddfa8e899cb0326edf2@localhost.localdomain>

Tyker updated this revision to Diff 276498.
Tyker added a comment.

addressed commemt.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71739/new/

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71739.276498.patch
Type: text/x-patch
Size: 105578 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 11:35:54 2020
From: cfe-commits at lists.llvm.org (Galina Kistanova via cfe-commits)
Date: Wed, 8 Jul 2020 11:35:54 -0700
Subject: LLVM buildmaster will be updated and restarted tonight
Message-ID: 

 Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM PST today.

Thanks

Galina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 11:36:08 2020
From: cfe-commits at lists.llvm.org (Tyker via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 18:36:08 +0000 (UTC)
Subject: [PATCH] D71739: [AssumeBundles] Use operand bundles to encode
 alignment assumptions
In-Reply-To: 
References: 
Message-ID: <9d5e447709ee9d1fe0d81d4917153ae2@localhost.localdomain>

Tyker updated this revision to Diff 276500.
Tyker added a comment.

fixed


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71739/new/

https://reviews.llvm.org/D71739

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/non-power-of-2-alignment-assumptions.c
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/simd_metadata.c
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/Transforms/Scalar/AlignmentFromAssumptions.h
  llvm/lib/Analysis/AssumeBundleQueries.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
  llvm/test/Transforms/AlignmentFromAssumptions/simple.ll
  llvm/test/Transforms/AlignmentFromAssumptions/simple32.ll
  llvm/test/Transforms/Inline/align.ll
  llvm/test/Transforms/InstCombine/assume.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
  llvm/test/Verifier/assume-bundles.ll
  llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71739.276500.patch
Type: text/x-patch
Size: 105632 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 11:49:35 2020
From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 18:49:35 +0000 (UTC)
Subject: [PATCH] D83402: ParsedAttrInfo: Change spelling to use StringRef
 instead of const char*
In-Reply-To: 
References: 
Message-ID: 

nikic added a comment.

This change looks reasonable to me in terms of coding style, however I'm not seeing any compile-time changes in terms of instructions retired myself (https://llvm-compile-time-tracker.com/compare.php?from=8691544a276744474ff04b71d7e220069435c7fe&to=75b126ecf7b5a0ce8c04cb46c37b66233854e931&stat=instructions).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83402/new/

https://reviews.llvm.org/D83402




From cfe-commits at lists.llvm.org  Wed Jul  8 11:53:57 2020
From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 18:53:57 +0000 (UTC)
Subject: [PATCH] D83414: Unbreak Clang standalone build.
Message-ID: 

michele.scandale created this revision.
michele.scandale added reviewers: clementval, simon_tatham, chandlerc.
Herald added subscribers: cfe-commits, sstefan1, martong, arphaman, mgorny.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Having the `omp_gen` dependency added unconditionally to Clang libraries
breaks the Clang standalone build. This dependency should be added only
if `CLANG_BUILT_STANDALONE` is false, similarly to the `intrinsics_gen`
case.
Moreover the C++ standard must be set properly as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83414

Files:
  clang/CMakeLists.txt
  clang/lib/ARCMigrate/CMakeLists.txt
  clang/lib/AST/CMakeLists.txt
  clang/lib/ASTMatchers/CMakeLists.txt
  clang/lib/ASTMatchers/Dynamic/CMakeLists.txt
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Frontend/Rewrite/CMakeLists.txt
  clang/lib/Index/CMakeLists.txt
  clang/lib/Parse/CMakeLists.txt
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Serialization/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/lib/Tooling/ASTDiff/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Transformer/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83414.276507.patch
Type: text/x-patch
Size: 6964 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 12:08:24 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:08:24 +0000 (UTC)
Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls.
In-Reply-To: 
References: 
Message-ID: 

efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:94
 /// If it contains any dynamic allocas, returns false.
 static bool canTRE(Function &F) {
   // Because of PR962, we don't TRE dynamic allocas.
----------------
avl wrote:
> efriedma wrote:
> > If we're not going to try to do TRE at all on calls not marked "tail", we can probably drop this check.
> It looks to me that original idea(PR962) was to avoid inefficient code which is generated for dynamic alloca. 
> 
> Currently there would still be generated inefficient code:
> 
> Doing TRE for dynamic alloca requires correct stack adjustment to avoid extra stack usage. 
> i.e. dynamic stack reservation done for alloca should be restored 
> in the end of the current iteration. Current TRE implementation does not do this.
> 
> Please, consider the test case:
> 
> 
> ```
> #include 
> 
> int count;
> __attribute__((noinline)) void globalIncrement(const int* param) { 
> 	count += *param; 
> }
> 
> void test(int recurseCount)
> {
>     if (recurseCount == 0) return;
>     {
>     int *temp = (int*)alloca(100);
>     globalIncrement(temp);
>     }
>     test(recurseCount - 1);
> }
> 
> 
> ```
> Following is the x86 asm generated for the above test case in assumption that dynamic allocas are possible:
> 
> ```
> 
> .LBB1_2:
>         movq    %rsp, %rdi
>         addq    $-112, %rdi   <<<<<<<<<<<<<< dynamic stack reservation, need to be restored before "jne .LBB1_2"
>         movq    %rdi, %rsp
>         callq   _Z15globalIncrementPKi
>         addl    $-1, %ebx
>         jne     .LBB1_2
> ```
> 
> So, it looks like we still have inefficient code here and it was a reason for avoiding TRE.
I guess we can leave this for a later patch.

This isn't really any worse than the stack usage before TRE, assuming we can't emit a sibling call in the backend.  And we could avoid this by making TRE insert stacksave/stackrestore intrinsics.  But better to do one thing at a time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82085/new/

https://reviews.llvm.org/D82085




From cfe-commits at lists.llvm.org  Wed Jul  8 12:10:39 2020
From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:10:39 +0000 (UTC)
Subject: [PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work
 also with precompiled headers
In-Reply-To: 
References: 
Message-ID: <6da714d5f1fdcf27119ba3b3d980b316@localhost.localdomain>

dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds good


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69778/new/

https://reviews.llvm.org/D69778




From cfe-commits at lists.llvm.org  Wed Jul  8 12:15:23 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:15:23 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: <851c91e1c579ff97dddf05d74188c849@localhost.localdomain>

LukeZhuang updated this revision to Diff 276517.
LukeZhuang added a comment.

**updated: 07/08/2020**
(1) improve test case


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===================================================================
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,26 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+    if (__builtin_expect_with_probability(1, 1, 1))
+      bar();
+  } else {
+    return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
+extern void f(int x);
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1); // should not have error here
+}
+
+void foo() {
+  f(constf());
+}
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-    // For __builtin_unpredictable, __builtin_expect, and
-    // __builtin_assume_aligned, just return the value of the subexpression.
+    // For __builtin_unpredictable, __builtin_expect,
+    // __builtin_expect_with_probability and __builtin_assume_aligned,
+    // just return the value of the subexpression.
     // __builtin_addressof is going from a reference to a pointer, but those
     // are represented the same way in the analyzer.
     assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
     return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83362.276517.patch
Type: text/x-patch
Size: 2242 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 12:17:57 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:17:57 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: <0341a7aa95ec31e5e9205cc52eb0b401@localhost.localdomain>

LukeZhuang marked an inline comment as done.
LukeZhuang added a comment.

@erichkeane Thank you very much for the comments. I have added test case to make sure it is evaluated during compile time. Previous code could not pass these test cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Wed Jul  8 12:18:07 2020
From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:18:07 +0000 (UTC)
Subject: [PATCH] D82659: Fix missing build dependency on omp_gen.
In-Reply-To: 
References: 
Message-ID: <449c2aac74b03fd0cf2e1a7be36f8851@localhost.localdomain>

michele.scandale added a comment.

Uhm.. it looks like it is not needed anymore. In the `LLVMConfig.cmake` that will be installed a `intrinsics_gen` and `omp_gen` custom targets are created for exactly the purpose of allowing out-of-tree or standalone builds to freely depend on them.
The Clang code where `intrinsics_gen` is conditionally added as a dependency is from 2014, while the change in `LLVMConfig.cmake.in` is from 2017.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82659/new/

https://reviews.llvm.org/D82659




From cfe-commits at lists.llvm.org  Wed Jul  8 12:18:43 2020
From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:18:43 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <1c922386520c6d9d6bbbf33d11ef236a@localhost.localdomain>

Xiangling_L marked 9 inline comments as done.
Xiangling_L added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+      DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+      !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;
----------------
hubert.reinterpretcast wrote:
> The condition is still more complex than I think it should be.
> 
> If we have found a "first" other-than-overlapping-empty-field, then we should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases.
> 
> If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for `FieldOffset == CharUnits::Zero()` to be true, then I think the correction would be to set `HandledFirstNonOverlappingEmptyField` in more places.
> 
> I would like to remove the check on `FieldOffset == CharUnits::Zero()` from here and instead have an assertion that `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == CharUnits::Zero()`.
> 
> Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to `FoundFirstNonOverlappingEmptyField`.
> Also, since we're managing HandledFirstNonOverlappingEmptyField in non-AIX cases, we should remove the DefaultsToAIXPowerAlignment condition for what is currently named FoundFirstNonOverlappingEmptyFieldToHandle 

I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` condition and bother with maintaining correct status of `HandledFirstNonOverlappingEmptyField` for other targets.

We are actually claiming `HandledFirstNonOverlappingEmptyField` is an auxiliary flag used for AIX only in its definition comments.

Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in non-AIX cases, I noticed that we have to set this flag to `true` somewhere for objective-C++ cases. 


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1834
+    TypeInfo TI = Context.getTypeInfo(D->getType());
+    FieldAlign = Context.toCharUnitsFromBits(TI.Align);
+    AlignIsRequired = TI.AlignIsRequired;
----------------
hubert.reinterpretcast wrote:
> I guess this works (we have a test for it), but the previous code made a point to use the element type and not the array type (and the comment above says we can't directly query `getTypeInfo` with the array type). @Xiangling_L, can you confirm if the comment is out-of-date and update it?
I am sure `getTypeInfo` can recognize the element type for `IncompleteArray`. I will update the comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Wed Jul  8 12:21:50 2020
From: cfe-commits at lists.llvm.org (Erich Keane via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:21:50 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: 

erichkeane added inline comments.


================
Comment at: clang/test/Sema/builtin-expect-with-probability.cpp:17
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1); // should not have error here
+}
----------------
I mean something more like:

    template
    void foo() { static_assert(!b,""); } // expected-error {{....}}

    void bar() {
      foo<__builtin_expect_with_probability(1,1,1)>();
    }


This example doesn't require that constf is executed at compile time.  You'd need to either send the result of constf to a template, or assign it to a constexpr variable in order to make it work.

So something like:

    void foo() {
       constexpr int f = constf();
       static_assert(f == 1, "");
    }



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Wed Jul  8 12:24:10 2020
From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:24:10 +0000 (UTC)
Subject: [PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply
 High/Divide Extended Builtins in LLVM/Clang
In-Reply-To: 
References: 
Message-ID: <29cbd3b309a27c2b936bfa4a4a4b461f@localhost.localdomain>

lei added inline comments.


================
Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:79
+vector signed int test_vec_dive_si(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesw(<4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
----------------
why does the ck stops matching at the first param?  Shouldn't we check the remaining param type and number of param are correct as well?


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:854
+                         [(set v4i32:$vD,
+                         (int_ppc_altivec_vdivesw v4i32:$vA, v4i32:$vB))]>;
   def VDIVEUW : VXForm_1<651, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
----------------
nit: indent to match up with `v4i32` on the previous line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82609/new/

https://reviews.llvm.org/D82609




From cfe-commits at lists.llvm.org  Wed Jul  8 12:30:27 2020
From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:30:27 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: 

rjmccall added a comment.

I agree with Eli that this should be considered a bugfix in the implementation of a recent language change and should just be rolled out consistently for all targets.

If this were a five-year-old feature, the ABI considerations would be different, but it's not.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Wed Jul  8 12:31:23 2020
From: cfe-commits at lists.llvm.org (Leonard Chan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:31:23 +0000 (UTC)
Subject: [PATCH] D76389: [NewPM] Run the Speculative Execution Pass only if
 the target has divergent branches
In-Reply-To: 
References: 
Message-ID: <158684e87d894a73b6f83eabecbe320a@localhost.localdomain>

leonardchan abandoned this revision.
leonardchan added a comment.

In D76389#2120868 , @arsenm wrote:

> This seems like it covers a different case than D82735 ?


I haven't rebased in a while, but D82735  covers this. Abandoning since this is addressed in that patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76389/new/

https://reviews.llvm.org/D76389




From cfe-commits at lists.llvm.org  Wed Jul  8 12:33:20 2020
From: cfe-commits at lists.llvm.org (Jason Liu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:33:20 +0000 (UTC)
Subject: [PATCH] D82476: [Clang][Driver] Recognize the AIX OBJECT_MODE
 environment setting
In-Reply-To: 
References: 
Message-ID: <16cfeec5bd53025417dac14de89db2c5@localhost.localdomain>

jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82476/new/

https://reviews.llvm.org/D82476




From cfe-commits at lists.llvm.org  Wed Jul  8 12:36:28 2020
From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:36:28 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: 

zequanwu updated this revision to Diff 276526.
zequanwu added a comment.

- Remove "enable-call-graph-profile" option and enable CGProfilePass by default, unless `-no-integrated-as` is given in clang.
- Use `LazyBlockFrequencyInfoPass` instead of `BlockFrequencyInfoWrapperPass` and check `F.getEntryCount` before get `BFI` to reduce cost.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/IPO.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/include/llvm/Transforms/Instrumentation/CGProfile.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Instrumentation/CGProfile.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
  llvm/test/Instrumentation/cgprofile.ll
  llvm/test/Other/new-pm-cgprofile.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83013.276526.patch
Type: text/x-patch
Size: 17743 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 12:41:53 2020
From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:41:53 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: 

zequanwu marked an inline comment as done.
zequanwu added a comment.

> The alternative of using LazyBlockFrequencyInfoPass and checking PSI->hasProfileSummary() first would also work I guess. If you think that's cleaner, maybe that's the better way to go.

Since `PSI->hasProfileSummary()` is not necessary for this pass, it relies on function entry count. So, I check for `F.getEntryCount()` before getting BFI.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Wed Jul  8 12:42:52 2020
From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:42:52 +0000 (UTC)
Subject: [PATCH] D82609: [PowerPC][Power10] Implement Vector Multiply
 High/Divide Extended Builtins in LLVM/Clang
In-Reply-To: 
References: 
Message-ID: 

amyk marked 2 inline comments as done.
amyk added inline comments.


================
Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:79
+vector signed int test_vec_dive_si(void) {
+  // CHECK: @llvm.ppc.altivec.vdivesw(<4 x i32>
+  // CHECK-NEXT: ret <4 x i32>
----------------
lei wrote:
> why does the ck stops matching at the first param?  Shouldn't we check the remaining param type and number of param are correct as well?
Yes, thanks for pointing that out. Will be fixing the CHECKs.


================
Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:854
+                         [(set v4i32:$vD,
+                         (int_ppc_altivec_vdivesw v4i32:$vA, v4i32:$vB))]>;
   def VDIVEUW : VXForm_1<651, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
----------------
lei wrote:
> nit: indent to match up with `v4i32` on the previous line.
I will update with the proper indentation. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82609/new/

https://reviews.llvm.org/D82609




From cfe-commits at lists.llvm.org  Wed Jul  8 12:47:42 2020
From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:47:42 +0000 (UTC)
Subject: [PATCH] D83402: ParsedAttrInfo: Change spelling to use StringRef
 instead of const char*
In-Reply-To: 
References: 
Message-ID: 

aaron.ballman added a comment.

I think the change is safe to make, but I'm slightly uncomfortable with it because storing a `StringRef` is a somewhat questionable practice given that it's non-owning and it has converting constructors from dangerous types like `std::string`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83402/new/

https://reviews.llvm.org/D83402




From cfe-commits at lists.llvm.org  Wed Jul  8 12:53:54 2020
From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits)
Date: Wed, 08 Jul 2020 12:53:54 -0700 (PDT)
Subject: [clang] 9b1e953 - [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X transforms
Message-ID: <5f062452.1c69fb81.ea50e.1b94@mx.google.com>


Author: Craig Topper
Date: 2020-07-08T12:53:05-07:00
New Revision: 9b1e95329af7bb005275f18225b2c130ec3ea98d

URL: https://github.com/llvm/llvm-project/commit/9b1e95329af7bb005275f18225b2c130ec3ea98d
DIFF: https://github.com/llvm/llvm-project/commit/9b1e95329af7bb005275f18225b2c130ec3ea98d.diff

LOG: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X transforms

As noted here https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html and by alive2, this transform isn't valid. If X is poison this potentially propagates poison when it shouldn't.

This same transform still exists in DAGCombiner.

Differential Revision: https://reviews.llvm.org/D83360

Added: 
    

Modified: 
    clang/test/CodeGen/arm-mve-intrinsics/dup.c
    llvm/lib/Analysis/InstructionSimplify.cpp
    llvm/test/Transforms/InstCombine/select.ll
    llvm/test/Transforms/InstSimplify/select.ll

Removed: 
    


################################################################################
diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/dup.c b/clang/test/CodeGen/arm-mve-intrinsics/dup.c
index 283c08257005..b443917cb258 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/dup.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/dup.c
@@ -242,7 +242,8 @@ uint32x4_t test_vdupq_m_n_u32(uint32x4_t inactive, uint32_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x half> undef, half [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x half> [[DOTSPLATINSERT]], <8 x half> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:    ret <8 x half> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x half> [[DOTSPLAT]], <8 x half> undef
+// CHECK-NEXT:    ret <8 x half> [[TMP2]]
 //
 float16x8_t test_vdupq_x_n_f16(float16_t a, mve_pred16_t p)
 {
@@ -255,7 +256,8 @@ float16x8_t test_vdupq_x_n_f16(float16_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x float> undef, float [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x float> [[DOTSPLATINSERT]], <4 x float> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:    ret <4 x float> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x float> [[DOTSPLAT]], <4 x float> undef
+// CHECK-NEXT:    ret <4 x float> [[TMP2]]
 //
 float32x4_t test_vdupq_x_n_f32(float32_t a, mve_pred16_t p)
 {
@@ -268,7 +270,8 @@ float32x4_t test_vdupq_x_n_f32(float32_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> undef, i8 [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <16 x i8> [[DOTSPLATINSERT]], <16 x i8> undef, <16 x i32> zeroinitializer
-// CHECK-NEXT:    ret <16 x i8> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <16 x i1> [[TMP1]], <16 x i8> [[DOTSPLAT]], <16 x i8> undef
+// CHECK-NEXT:    ret <16 x i8> [[TMP2]]
 //
 int8x16_t test_vdupq_x_n_s8(int8_t a, mve_pred16_t p)
 {
@@ -281,7 +284,8 @@ int8x16_t test_vdupq_x_n_s8(int8_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> undef, i16 [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:    ret <8 x i16> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i16> [[DOTSPLAT]], <8 x i16> undef
+// CHECK-NEXT:    ret <8 x i16> [[TMP2]]
 //
 int16x8_t test_vdupq_x_n_s16(int16_t a, mve_pred16_t p)
 {
@@ -294,7 +298,8 @@ int16x8_t test_vdupq_x_n_s16(int16_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:    ret <4 x i32> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[DOTSPLAT]], <4 x i32> undef
+// CHECK-NEXT:    ret <4 x i32> [[TMP2]]
 //
 int32x4_t test_vdupq_x_n_s32(int32_t a, mve_pred16_t p)
 {
@@ -307,7 +312,8 @@ int32x4_t test_vdupq_x_n_s32(int32_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <16 x i8> undef, i8 [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <16 x i8> [[DOTSPLATINSERT]], <16 x i8> undef, <16 x i32> zeroinitializer
-// CHECK-NEXT:    ret <16 x i8> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <16 x i1> [[TMP1]], <16 x i8> [[DOTSPLAT]], <16 x i8> undef
+// CHECK-NEXT:    ret <16 x i8> [[TMP2]]
 //
 uint8x16_t test_vdupq_x_n_u8(uint8_t a, mve_pred16_t p)
 {
@@ -320,7 +326,8 @@ uint8x16_t test_vdupq_x_n_u8(uint8_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <8 x i16> undef, i16 [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <8 x i16> [[DOTSPLATINSERT]], <8 x i16> undef, <8 x i32> zeroinitializer
-// CHECK-NEXT:    ret <8 x i16> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <8 x i1> [[TMP1]], <8 x i16> [[DOTSPLAT]], <8 x i16> undef
+// CHECK-NEXT:    ret <8 x i16> [[TMP2]]
 //
 uint16x8_t test_vdupq_x_n_u16(uint16_t a, mve_pred16_t p)
 {
@@ -333,7 +340,8 @@ uint16x8_t test_vdupq_x_n_u16(uint16_t a, mve_pred16_t p)
 // CHECK-NEXT:    [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 [[TMP0]])
 // CHECK-NEXT:    [[DOTSPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 [[A:%.*]], i32 0
 // CHECK-NEXT:    [[DOTSPLAT:%.*]] = shufflevector <4 x i32> [[DOTSPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer
-// CHECK-NEXT:    ret <4 x i32> [[DOTSPLAT]]
+// CHECK-NEXT:    [[TMP2:%.*]] = select <4 x i1> [[TMP1]], <4 x i32> [[DOTSPLAT]], <4 x i32> undef
+// CHECK-NEXT:    ret <4 x i32> [[TMP2]]
 //
 uint32x4_t test_vdupq_x_n_u32(uint32_t a, mve_pred16_t p)
 {

diff  --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index d3bdf9d6aafd..8cd5d2034586 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4118,11 +4118,6 @@ static Value *SimplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
   if (TrueVal == FalseVal)
     return TrueVal;
 
-  if (isa(TrueVal))   // select ?, undef, X -> X
-    return FalseVal;
-  if (isa(FalseVal))   // select ?, X, undef -> X
-    return TrueVal;
-
   // Deal with partial undef vector constants: select ?, VecC, VecC' --> VecC''
   Constant *TrueC, *FalseC;
   if (TrueVal->getType()->isVectorTy() && match(TrueVal, m_Constant(TrueC)) &&

diff  --git a/llvm/test/Transforms/InstCombine/select.ll b/llvm/test/Transforms/InstCombine/select.ll
index 381a77bb8d78..f990a58f984c 100644
--- a/llvm/test/Transforms/InstCombine/select.ll
+++ b/llvm/test/Transforms/InstCombine/select.ll
@@ -2273,3 +2273,43 @@ exit:
   %sel = select i1 %cond, i32 %phi, i32 %A
   ret i32 %sel
 }
+
+; Negative tests to ensure we don't remove selects with undef true/false values.
+; See https://bugs.llvm.org/show_bug.cgi?id=31633
+; https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html
+; https://reviews.llvm.org/D83360
+define i32 @false_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @false_undef(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], i32 [[X:%.*]], i32 undef
+; CHECK-NEXT:    ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 %x, i32 undef
+  ret i32 %s
+}
+
+define i32 @true_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @true_undef(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], i32 undef, i32 [[X:%.*]]
+; CHECK-NEXT:    ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 undef, i32 %x
+  ret i32 %s
+}
+
+define <2 x i32> @false_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @false_undef_vec(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> [[X:%.*]], <2 x i32> undef
+; CHECK-NEXT:    ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> %x, <2 x i32> undef
+  ret <2 x i32> %s
+}
+
+define <2 x i32> @true_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @true_undef_vec(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> undef, <2 x i32> [[X:%.*]]
+; CHECK-NEXT:    ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> undef, <2 x i32> %x
+  ret <2 x i32> %s
+}

diff  --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll
index 139f5e3c3c23..81fc3ff186cd 100644
--- a/llvm/test/Transforms/InstSimplify/select.ll
+++ b/llvm/test/Transforms/InstSimplify/select.ll
@@ -750,3 +750,43 @@ define i1 @y_might_be_poison(float %x, float %y) {
   %c3 = select i1 %c1, i1 %c2, i1 false
   ret i1 %c3
 }
+
+; Negative tests to ensure we don't remove selects with undef true/false values.
+; See https://bugs.llvm.org/show_bug.cgi?id=31633
+; https://lists.llvm.org/pipermail/llvm-dev/2016-October/106182.html
+; https://reviews.llvm.org/D83360
+define i32 @false_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @false_undef(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], i32 [[X:%.*]], i32 undef
+; CHECK-NEXT:    ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 %x, i32 undef
+  ret i32 %s
+}
+
+define i32 @true_undef(i1 %cond, i32 %x) {
+; CHECK-LABEL: @true_undef(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], i32 undef, i32 [[X:%.*]]
+; CHECK-NEXT:    ret i32 [[S]]
+;
+  %s = select i1 %cond, i32 undef, i32 %x
+  ret i32 %s
+}
+
+define <2 x i32> @false_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @false_undef_vec(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> [[X:%.*]], <2 x i32> undef
+; CHECK-NEXT:    ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> %x, <2 x i32> undef
+  ret <2 x i32> %s
+}
+
+define <2 x i32> @true_undef_vec(i1 %cond, <2 x i32> %x) {
+; CHECK-LABEL: @true_undef_vec(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[COND:%.*]], <2 x i32> undef, <2 x i32> [[X:%.*]]
+; CHECK-NEXT:    ret <2 x i32> [[S]]
+;
+  %s = select i1 %cond, <2 x i32> undef, <2 x i32> %x
+  ret <2 x i32> %s
+}


        

From cfe-commits at lists.llvm.org  Wed Jul  8 12:54:00 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:54:00 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b1e95329af7: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X… (authored by craig.topper).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360

Files:
  clang/test/CodeGen/arm-mve-intrinsics/dup.c
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstSimplify/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83360.276527.patch
Type: text/x-patch
Size: 8854 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 12:56:55 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:56:55 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
Message-ID: 

sammccall created this revision.
sammccall added reviewers: kbobyrev, hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, javed.absar, ilya-biryukov, mgorny.
Herald added a project: clang.

This is considerably terser than the makeStringError and friends, and
avoids verbosity cliffs that discourage adding log information.

It follows the syntax used in log/elog/vlog/dlog that have been successful.

The main caveats are:

- it's strictly out-of-place in logger.h, though kind of fits thematically and in implementation
- it claims the "error" identifier, which seems a bit too opinionated to put higher up in llvm

I've updated some users of StringError mostly at random - there are lots
more mechanical changes but I'd like to get this reviewed before making
them all.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83419

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/RIFF.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/support/Logger.cpp
  clang-tools-extra/clangd/support/Logger.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/LoggerTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83419.276529.patch
Type: text/x-patch
Size: 21933 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 12:58:08 2020
From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:58:08 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <9b3c124fdcbf58e6187bf0885dd672d8@localhost.localdomain>

Xiangling_L updated this revision to Diff 276528.
Xiangling_L marked 2 inline comments as done.
Xiangling_L added a comment.

Fixed a -Wpacked related case and added the case to the tests;
Fixed the base class related code issue;
Addressed other comments;


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-Wpacked.cpp
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-pack-attr-on-base.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79719.276528.patch
Type: text/x-patch
Size: 68103 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 12:58:09 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:58:09 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: <0524d8b5f1970a68e661e865e624699c@localhost.localdomain>

efriedma added a comment.

In D81583#2139002 , @uweigand wrote:

> In D81583#2137277 , @efriedma wrote:
>
> > I'm tempted to say this is a bugfix for the implementation of no_unique_address, and just fix it globally for all ABIs.  We're never going to get anything done here if we require a separate patch for each ABI variant clang supports.
>
>
> Well, I can certainly do that.  Would you prefer me to completely remove the AllowNoUniqueAddress parameter, or keep it but default to true (so ABIs can still override if necessary)?


Just drop it; I don't expect any ABI would want to override it.



================
Comment at: clang/lib/CodeGen/TargetInfo.cpp:7245
       // do count.  So do anonymous bitfields that aren't zero-sized.
-      if (getContext().getLangOpts().CPlusPlus &&
-          FD->isZeroLengthBitField(getContext()))
-        continue;
+      if (getContext().getLangOpts().CPlusPlus) {
+        if (FD->isZeroLengthBitField(getContext()))
----------------
uweigand wrote:
> efriedma wrote:
> > Only loosely relevant to this patch, but checking getLangOpts().CPlusPlus here seems weird; doesn't that break calling functions defined in C from C++ code?
> I agree that this difference between C and C++ is weird, but it does match the behavior of GCC.  (Which is itself weird, but a long-standing accident that we probably cannot fix without breaking existing code at this point.)
> 
> Now, you bring up an interesting point: When C++ code calls a function defined in C code, the C++ part would have to refer to an `extern "C"` declaration.  The correct thing to do would probably be to handle those according to the C ABI rules, not the C++ rules, in this case where the two differ.  But currently GCC doesn't do that either.  (But since that would be broken anyway, I think we **can** fix that.)  In any case, I agree that this is really a separate problem, distinct from this patch.
Okay.

Please move the check for NoUniqueAddressAttr out of the CPlusPlus check; I don't think it's currently possible to use from C, but better to be on the safe side.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Wed Jul  8 12:59:59 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 19:59:59 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <6be1dc3cea55fe5cdc1ef7c36b76926e@localhost.localdomain>

hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+      DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+      !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;
----------------
Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > The condition is still more complex than I think it should be.
> > 
> > If we have found a "first" other-than-overlapping-empty-field, then we should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases.
> > 
> > If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for `FieldOffset == CharUnits::Zero()` to be true, then I think the correction would be to set `HandledFirstNonOverlappingEmptyField` in more places.
> > 
> > I would like to remove the check on `FieldOffset == CharUnits::Zero()` from here and instead have an assertion that `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == CharUnits::Zero()`.
> > 
> > Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to `FoundFirstNonOverlappingEmptyField`.
> > Also, since we're managing HandledFirstNonOverlappingEmptyField in non-AIX cases, we should remove the DefaultsToAIXPowerAlignment condition for what is currently named FoundFirstNonOverlappingEmptyFieldToHandle 
> 
> I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` condition and bother with maintaining correct status of `HandledFirstNonOverlappingEmptyField` for other targets.
> 
> We are actually claiming `HandledFirstNonOverlappingEmptyField` is an auxiliary flag used for AIX only in its definition comments.
> 
> Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in non-AIX cases, I noticed that we have to set this flag to `true` somewhere for objective-C++ cases. 
Okay, the other option I'm open is setting `HandledFirstNonOverlappingEmptyField` to `true` up front when not dealing with AIX `power` alignment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Wed Jul  8 13:00:40 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 20:00:40 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: 

sammccall updated this revision to Diff 276531.
sammccall added a comment.

Move a few comments around.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/PathMapping.cpp
  clang-tools-extra/clangd/RIFF.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/support/Logger.cpp
  clang-tools-extra/clangd/support/Logger.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/LoggerTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83419.276531.patch
Type: text/x-patch
Size: 21988 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 13:03:48 2020
From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 20:03:48 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <342c5f92fc2f788ac3f24c5190f0432f@localhost.localdomain>

Xiangling_L marked an inline comment as done.
Xiangling_L added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796
+  bool FoundFirstNonOverlappingEmptyFieldToHandle =
+      DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+      !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField;
----------------
hubert.reinterpretcast wrote:
> Xiangling_L wrote:
> > hubert.reinterpretcast wrote:
> > > The condition is still more complex than I think it should be.
> > > 
> > > If we have found a "first" other-than-overlapping-empty-field, then we should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases.
> > > 
> > > If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for `FieldOffset == CharUnits::Zero()` to be true, then I think the correction would be to set `HandledFirstNonOverlappingEmptyField` in more places.
> > > 
> > > I would like to remove the check on `FieldOffset == CharUnits::Zero()` from here and instead have an assertion that `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == CharUnits::Zero()`.
> > > 
> > > Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to `FoundFirstNonOverlappingEmptyField`.
> > > Also, since we're managing HandledFirstNonOverlappingEmptyField in non-AIX cases, we should remove the DefaultsToAIXPowerAlignment condition for what is currently named FoundFirstNonOverlappingEmptyFieldToHandle 
> > 
> > I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` condition and bother with maintaining correct status of `HandledFirstNonOverlappingEmptyField` for other targets.
> > 
> > We are actually claiming `HandledFirstNonOverlappingEmptyField` is an auxiliary flag used for AIX only in its definition comments.
> > 
> > Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in non-AIX cases, I noticed that we have to set this flag to `true` somewhere for objective-C++ cases. 
> Okay, the other option I'm open is setting `HandledFirstNonOverlappingEmptyField` to `true` up front when not dealing with AIX `power` alignment.
Thanks, that works too. I will address it in the next commit.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Wed Jul  8 13:08:51 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 20:08:51 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <57a7070f1ecb984b35ccb1360091907e@localhost.localdomain>

efriedma added a comment.

Please also add testcases with select constant expressions, to test constant folding.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 13:08:54 2020
From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits)
Date: Wed, 08 Jul 2020 13:08:54 -0700 (PDT)
Subject: [clang] 4544c2d - Recover more gracefully from stack exhaustion
 during template argument
Message-ID: <5f0627d6.1c69fb81.95a14.12c2@mx.google.com>


Author: Richard Smith
Date: 2020-07-08T13:08:38-07:00
New Revision: 4544c2d95ad0217e1f28ddd84253cd09a91148c0

URL: https://github.com/llvm/llvm-project/commit/4544c2d95ad0217e1f28ddd84253cd09a91148c0
DIFF: https://github.com/llvm/llvm-project/commit/4544c2d95ad0217e1f28ddd84253cd09a91148c0.diff

LOG: Recover more gracefully from stack exhaustion during template argument
deduction.

Template argument deduction can trigger substitution, both with
explicitly-specified template arguments and with deduced template
arguments in various ways. We previously had no check for stack
exhaustion along some of those codepaths, making it fairly easy to crash
clang with a template resulting in a substitution that referred back to
that same template. We should now produce a proper diagnostic for such
cases rather than crashing.

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateDeduction.cpp
    clang/test/SemaTemplate/stack-exhaustion.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index e6569d4a784f..f3641afbbf8a 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3041,8 +3041,13 @@ Sema::DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
   if (Trap.hasErrorOccurred())
     return Sema::TDK_SubstitutionFailure;
 
-  return ::FinishTemplateArgumentDeduction(
-      *this, Partial, /*IsPartialOrdering=*/false, TemplateArgs, Deduced, Info);
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+    Result = ::FinishTemplateArgumentDeduction(*this, Partial,
+                                               /*IsPartialOrdering=*/false,
+                                               TemplateArgs, Deduced, Info);
+  });
+  return Result;
 }
 
 /// Perform template argument deduction to determine whether
@@ -3082,8 +3087,13 @@ Sema::DeduceTemplateArguments(VarTemplatePartialSpecializationDecl *Partial,
   if (Trap.hasErrorOccurred())
     return Sema::TDK_SubstitutionFailure;
 
-  return ::FinishTemplateArgumentDeduction(
-      *this, Partial, /*IsPartialOrdering=*/false, TemplateArgs, Deduced, Info);
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+    Result = ::FinishTemplateArgumentDeduction(*this, Partial,
+                                               /*IsPartialOrdering=*/false,
+                                               TemplateArgs, Deduced, Info);
+  });
+  return Result;
 }
 
 /// Determine whether the given type T is a simple-template-id type.
@@ -4032,13 +4042,12 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
   SmallVector ParamTypes;
   unsigned NumExplicitlySpecified = 0;
   if (ExplicitTemplateArgs) {
-    TemplateDeductionResult Result =
-      SubstituteExplicitTemplateArguments(FunctionTemplate,
-                                          *ExplicitTemplateArgs,
-                                          Deduced,
-                                          ParamTypes,
-                                          nullptr,
-                                          Info);
+    TemplateDeductionResult Result;
+    runWithSufficientStackSpace(Info.getLocation(), [&] {
+      Result = SubstituteExplicitTemplateArguments(
+          FunctionTemplate, *ExplicitTemplateArgs, Deduced, ParamTypes, nullptr,
+          Info);
+    });
     if (Result)
       return Result;
 
@@ -4140,12 +4149,16 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
   // that is needed when the accessibility of template arguments is checked.
   DeclContext *CallingCtx = CurContext;
 
-  return FinishTemplateArgumentDeduction(
-      FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info,
-      &OriginalCallArgs, PartialOverloading, [&, CallingCtx]() {
-        ContextRAII SavedContext(*this, CallingCtx);
-        return CheckNonDependent(ParamTypesForArgChecking);
-      });
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+    Result = FinishTemplateArgumentDeduction(
+        FunctionTemplate, Deduced, NumExplicitlySpecified, Specialization, Info,
+        &OriginalCallArgs, PartialOverloading, [&, CallingCtx]() {
+          ContextRAII SavedContext(*this, CallingCtx);
+          return CheckNonDependent(ParamTypesForArgChecking);
+        });
+  });
+  return Result;
 }
 
 QualType Sema::adjustCCAndNoReturn(QualType ArgFunctionType,
@@ -4231,11 +4244,13 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
   unsigned NumExplicitlySpecified = 0;
   SmallVector ParamTypes;
   if (ExplicitTemplateArgs) {
-    if (TemplateDeductionResult Result
-          = SubstituteExplicitTemplateArguments(FunctionTemplate,
-                                                *ExplicitTemplateArgs,
-                                                Deduced, ParamTypes,
-                                                &FunctionType, Info))
+    TemplateDeductionResult Result;
+    runWithSufficientStackSpace(Info.getLocation(), [&] {
+      Result = SubstituteExplicitTemplateArguments(
+          FunctionTemplate, *ExplicitTemplateArgs, Deduced, ParamTypes,
+          &FunctionType, Info);
+    });
+    if (Result)
       return Result;
 
     NumExplicitlySpecified = Deduced.size();
@@ -4277,10 +4292,13 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
       return Result;
   }
 
-  if (TemplateDeductionResult Result
-        = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
-                                          NumExplicitlySpecified,
-                                          Specialization, Info))
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+    Result = FinishTemplateArgumentDeduction(FunctionTemplate, Deduced,
+                                             NumExplicitlySpecified,
+                                             Specialization, Info);
+  });
+  if (Result)
     return Result;
 
   // If the function has a deduced return type, deduce it now, so we can check
@@ -4437,9 +4455,11 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *ConversionTemplate,
   LocalInstantiationScope InstScope(*this);
   // Finish template argument deduction.
   FunctionDecl *ConversionSpecialized = nullptr;
-  TemplateDeductionResult Result
-      = FinishTemplateArgumentDeduction(ConversionTemplate, Deduced, 0,
-                                        ConversionSpecialized, Info);
+  TemplateDeductionResult Result;
+  runWithSufficientStackSpace(Info.getLocation(), [&] {
+    Result = FinishTemplateArgumentDeduction(ConversionTemplate, Deduced, 0,
+                                             ConversionSpecialized, Info);
+  });
   Specialization = cast_or_null(ConversionSpecialized);
   return Result;
 }
@@ -5379,14 +5399,15 @@ static bool isAtLeastAsSpecializedAs(Sema &S, QualType T1, QualType T2,
   Sema::InstantiatingTemplate Inst(S, Info.getLocation(), P2, DeducedArgs,
                                    Info);
   auto *TST1 = T1->castAs();
-  if (FinishTemplateArgumentDeduction(
-          S, P2, /*IsPartialOrdering=*/true,
-          TemplateArgumentList(TemplateArgumentList::OnStack,
-                               TST1->template_arguments()),
-          Deduced, Info))
-    return false;
-
-  return true;
+  bool AtLeastAsSpecialized;
+  S.runWithSufficientStackSpace(Info.getLocation(), [&] {
+    AtLeastAsSpecialized = !FinishTemplateArgumentDeduction(
+        S, P2, /*IsPartialOrdering=*/true,
+        TemplateArgumentList(TemplateArgumentList::OnStack,
+                             TST1->template_arguments()),
+        Deduced, Info);
+  });
+  return AtLeastAsSpecialized;
 }
 
 /// Returns the more specialized class template partial specialization

diff  --git a/clang/test/SemaTemplate/stack-exhaustion.cpp b/clang/test/SemaTemplate/stack-exhaustion.cpp
index 7f76212d2a49..1eb1b474ffa5 100644
--- a/clang/test/SemaTemplate/stack-exhaustion.cpp
+++ b/clang/test/SemaTemplate/stack-exhaustion.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -verify %s -DTEST=1
+// RUN: %clang_cc1 -verify %s -DTEST=2
+// RUN: %clang_cc1 -verify %s -DTEST=3
 // REQUIRES: thread_support
 
 // FIXME: Detection of, or recovery from, stack exhaustion does not work on
@@ -9,6 +11,8 @@
 // expected-warning@* 0-1{{stack nearly exhausted}}
 // expected-note@* 0+{{}}
 
+#if TEST == 1
+
 template struct X : X {};
 template<> struct X<0> {};
 X<1000> x;
@@ -21,3 +25,38 @@ int f(X<0>);
 template auto f(X) -> f(X());
 
 int k = f(X<1000>());
+
+#elif TEST == 2
+
+namespace template_argument_recursion {
+  struct ostream;
+  template T &&declval();
+
+  namespace mlir {
+    template() << declval())>
+    ostream &operator<<(ostream& os, const T& obj); // expected-error {{exceeded maximum depth}}
+    struct Value;
+  }
+
+  void printFunctionalType(ostream &os, mlir::Value &v) { os << v; }
+}
+
+#elif TEST == 3
+
+namespace template_parameter_type_recursion {
+  struct ostream;
+  template T &&declval();
+  template struct enable_if { using type = T; };
+
+  namespace mlir {
+    template() << declval(), void*>::type = nullptr>
+    ostream &operator<<(ostream& os, const T& obj); // expected-error {{exceeded maximum depth}}
+    struct Value;
+  }
+
+  void printFunctionalType(ostream &os, mlir::Value &v) { os << v; }
+}
+
+#else
+#error unknown test
+#endif


        

From cfe-commits at lists.llvm.org  Wed Jul  8 13:10:27 2020
From: cfe-commits at lists.llvm.org (Jan Korous via cfe-commits)
Date: Wed, 08 Jul 2020 13:10:27 -0700 (PDT)
Subject: [clang] 6e089e9 - [libclang] Fix crash when visiting a captured VLA
Message-ID: <5f062833.1c69fb81.10050.1c7e@mx.google.com>


Author: Christian Kandeler
Date: 2020-07-08T13:10:16-07:00
New Revision: 6e089e98a9d5d7d0dda259f68b8ba7f4556cc5b3

URL: https://github.com/llvm/llvm-project/commit/6e089e98a9d5d7d0dda259f68b8ba7f4556cc5b3
DIFF: https://github.com/llvm/llvm-project/commit/6e089e98a9d5d7d0dda259f68b8ba7f4556cc5b3.diff

LOG: [libclang] Fix crash when visiting a captured VLA

Array returned by LambdaExpr::capture_inits() can contain nullptrs.

Differential Revision: https://reviews.llvm.org/D82629

Added: 
    

Modified: 
    clang/test/Index/evaluate-cursor.cpp
    clang/tools/libclang/CIndex.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/Index/evaluate-cursor.cpp b/clang/test/Index/evaluate-cursor.cpp
index 2bb687a1eb88..901e988bc99e 100644
--- a/clang/test/Index/evaluate-cursor.cpp
+++ b/clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,12 @@ template  class e {
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest() {
+  int msize = 4;
+  float arr[msize];
+  [&arr] {};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:    -evaluate-cursor-at=%s:8:7 \
 // RUN:    -evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +71,7 @@ const auto the_value = calc_val() + sizeof(char);
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:35:5 \
+// RUN:    -std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable

diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 8d33deb468e2..93f9797a965e 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@ bool CursorVisitor::RunVisitorWorkList(VisitorWorkList &WL) {
       }
       // Visit init captures
       for (auto InitExpr : E->capture_inits()) {
-        if (Visit(InitExpr))
+        if (InitExpr && Visit(InitExpr))
           return true;
       }
 


        

From cfe-commits at lists.llvm.org  Wed Jul  8 13:10:29 2020
From: cfe-commits at lists.llvm.org (Jan Korous via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 20:10:29 +0000 (UTC)
Subject: [PATCH] D82629: [libclang] Fix crash when visiting a captured VLA.
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e089e98a9d5: [libclang] Fix crash when visiting a captured VLA (authored by ckandeler, committed by jkorous).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82629/new/

https://reviews.llvm.org/D82629

Files:
  clang/test/Index/evaluate-cursor.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===================================================================
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@
       }
       // Visit init captures
       for (auto InitExpr : E->capture_inits()) {
-        if (Visit(InitExpr))
+        if (InitExpr && Visit(InitExpr))
           return true;
       }
 
Index: clang/test/Index/evaluate-cursor.cpp
===================================================================
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,12 @@
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest() {
+  int msize = 4;
+  float arr[msize];
+  [&arr] {};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:    -evaluate-cursor-at=%s:8:7 \
 // RUN:    -evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +71,7 @@
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:35:5 \
+// RUN:    -std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82629.276534.patch
Type: text/x-patch
Size: 1202 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 13:15:14 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 20:15:14 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <8b5a1f91de3bdce94825cc3deec8dfb5@localhost.localdomain>

craig.topper added a comment.

In D83360#2139933 , @efriedma wrote:

> Please also add testcases with select constant expressions, to test constant folding.


Should we remove the handling from llvm::ConstantFoldSelectInstruction


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 13:32:15 2020
From: cfe-commits at lists.llvm.org (Francesco Petrogalli via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 20:32:15 +0000 (UTC)
Subject: [PATCH] D83079: [clang][aarch64] Generate preprocessor macros for
 -march=armv8.6a+sve.
In-Reply-To: 
References: 
Message-ID: 

fpetrogalli updated this revision to Diff 276542.
fpetrogalli marked an inline comment as done.
fpetrogalli added a comment.

@sdesmalen, I have followed your suggestion to use insert instead of push_back!

Code is much nicer now, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83079/new/

https://reviews.llvm.org/D83079

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===================================================================
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -112,6 +112,60 @@
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE 1
 // CHECK-SVE-F64MM: __ARM_FEATURE_SVE_MATMUL_FP64 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.5-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_5 %s
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_5-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_5: __ARM_FEATURE_SVE 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6 %s
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6: __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MM %s
+// CHECK-SVE-8_6-NOI8MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MM:     __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MM:     __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nobf16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOBF16 %s
+// CHECK-SVE-8_6-NOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16:     __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16:     __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOF32MM %s
+// CHECK-SVE-8_6-NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOF32MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOF32MM:     __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOF32MM:     __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nobf16 -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16 %s
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOBF16:     __ARM_FEATURE_SVE_MATMUL_FP32 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MMNOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOI8MMNOF32MM:     __ARM_FEATURE_SVE_BF16 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOBF16NOF32MM:     __ARM_FEATURE_SVE 1
+// CHECK-SVE-8_6-NOBF16NOF32MM:     __ARM_FEATURE_SVE_MATMUL_INT8 1
+
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.6-a+sve+noi8mm+nobf16+nof32mm -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM %s
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_BF16 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_FP32 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM-NOT: __ARM_FEATURE_SVE_MATMUL_INT8 1
+// CHECK-SVE-8_6-NOI8MMNOBF16NOF32MM:     __ARM_FEATURE_SVE 1
+
 // The following tests may need to be revised in the future since
 // SVE2 is currently still part of Future Architecture Technologies
 // (https://developer.arm.com/docs/ddi0602/latest)
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -365,6 +365,12 @@
     }
   }
 
+  auto V8_6Pos = llvm::find(Features, "+v8.6a");
+  if (V8_6Pos != std::end(Features)) {
+    V8_6Pos = Features.insert(std::next(V8_6Pos), "+i8mm");
+    V8_6Pos = Features.insert(V8_6Pos, "+bf16");
+  }
+
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
                                options::OPT_munaligned_access))
     if (A->getOption().matches(options::OPT_mno_unaligned_access))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83079.276542.patch
Type: text/x-patch
Size: 4697 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 14:01:27 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:01:27 +0000 (UTC)
Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM
In-Reply-To: 
References: 
Message-ID: <2cd7906111de0717a09a16ed7ec47c1b@localhost.localdomain>

MaskRay added a comment.

In D83013#2139882 , @zequanwu wrote:

> > The alternative of using LazyBlockFrequencyInfoPass and checking PSI->hasProfileSummary() first would also work I guess. If you think that's cleaner, maybe that's the better way to go.
>
> Since `PSI->hasProfileSummary()` is not necessary for this pass, it relies on function entry count. So, I check for `F.getEntryCount()` before getting BFI.


Thanks. The last update looks good to me. I'll defer the approval to @nikic and folks who have expressed concerns about deleting legacy PM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83013/new/

https://reviews.llvm.org/D83013




From cfe-commits at lists.llvm.org  Wed Jul  8 14:06:36 2020
From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:06:36 +0000 (UTC)
Subject: [PATCH] D83426: Unbreak Clang standalone build.
Message-ID: 

michele.scandale created this revision.
michele.scandale added a reviewer: chandlerc.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

Add missing C++ language standard setup for Clang standalone build.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83426

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -9,6 +9,10 @@
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   project(Clang)
 
+  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD_REQUIRED YES)
+  set(CMAKE_CXX_EXTENSIONS NO)
+
   # Rely on llvm-config.
   set(CONFIG_OUTPUT)
   if(LLVM_CONFIG)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83426.276548.patch
Type: text/x-patch
Size: 454 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 14:06:52 2020
From: cfe-commits at lists.llvm.org (Steven Wan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:06:52 +0000 (UTC)
Subject: [PATCH] D79842: [clang][Driver] Correct tool search path priority
In-Reply-To: 
References: 
Message-ID: <8cb607dc20684ca29f74a66f2cc627ff@localhost.localdomain>

stevewan added a comment.

In D79842#2138857 , @DavidSpickett wrote:

> Right, I see the issue.
>
> The code that gets the default triple name (https://reviews.llvm.org/D13340?id=36227#inline-108606) looks up the one you have in cmake, not the actual default which you get in --version. We could "fix" this by doing so when we make the tool name as well, but this breaks whatever mips toolchain was using that. (their tools won't be mips-unknown-elf-)
>
> So yes it looks up powerpc64le-linux-gnu but shows powerpc64le-unknown-linux-gnu. Can't go back to using cmake's value because on Mac OS, cmake has x86_64-darwin, clang has x86_64-darwin. Writing to both is a short term option so I will try that and fold it into https://reviews.llvm.org/D83055. (will add you on review once I update it)
>
> (this whole default triple lookup should probably go but I'd really like to do that in its own commit)


Thanks. @DavidSpickett


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79842/new/

https://reviews.llvm.org/D79842




From cfe-commits at lists.llvm.org  Wed Jul  8 14:10:07 2020
From: cfe-commits at lists.llvm.org (Leonard Chan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:10:07 +0000 (UTC)
Subject: [PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts.
In-Reply-To: 
References: 
Message-ID: 

leonardchan added inline comments.


================
Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3603-3604
   auto ResultFixedSema = Ctx.getFixedPointSemantics(ResultTy);
-  auto CommonFixedSema = LHSFixedSema.getCommonSemantics(RHSFixedSema, true);
+  auto CommonFixedSema = LHSFixedSema.getCommonSemantics(
+      IsShift ? LHSFixedSema : RHSFixedSema, true);
 
----------------
Could this instead be:

```
auto CommonFixedSema = IsShift ? LHSFixedSema : LHSFixedSema.getCommonSemantics(RHSFixedSema, true);
```




================
Comment at: clang/test/Frontend/fixed_point_compound.c:384
+  // CHECK-NEXT:    [[TMP4:%.*]] = load i16, i16* @suf, align 2
+  // CHECK-NEXT:    [[TMP5:%.*]] = trunc i32 [[TMP3]] to i16
+  // SIGNED-NEXT:   [[TMP6:%.*]] = call i16 @llvm.ushl.sat.i16(i16 [[TMP4]], i16 [[TMP5]])
----------------
This seems very unlikely, but if `i` in this case was a value at least 2^16, the upper half would be cut off and we'd potentially shift by an improper amount for some values of `i` when we should actually clamp to the max value. We should probably still   find the common semantics for both sides if we're doing a shift.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83294/new/

https://reviews.llvm.org/D83294




From cfe-commits at lists.llvm.org  Wed Jul  8 14:13:48 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:13:48 +0000 (UTC)
Subject: [PATCH] D80391: [Driver] Don't make -gsplit-dwarf imply -g2
In-Reply-To: 
References: 
Message-ID: <471685a62be5edde4bc89ac486b4a021@localhost.localdomain>

MaskRay added a comment.

Received Cary's response and I am authorized to share this

> In retrospect, I regret not naming the option -fsplit-dwarf, which clearly
>  would not have implied -g, and would have fit in with a few other
>  dwarf-related -f options. (I don't know whether Richard's objection to it is
>  because there is already -gsplit-dwarf, or if he would have objected to it as
>  an alternative-universe spelling.)
> 
> At the time, I thought it was fairly common for all/most -g options (except
>  -g0) to imply -g. Perhaps that wasn't true then or is no longer true now. If
>  the rest of the community is OK with changing -gsplit-dwarf to not imply -g,
>  and no one has said it would cause them any hardship, I'm OK with your
>  proposed change.

My remark here: GCC folks think introducing another -fsplit-dwarf will be more confusing at this point.

> I did design it so that you could get the equivalent by simply writing
>  "-gsplit-dwarf -g0" at the front of the compiler options (e.g., via an
>  environment variable), so that a subsequent -g would not only turn on debug
>  but would also enable split-dwarf. We used that fairly regularly at Google.
> 
> Regarding how the build system can discover whether or not split dwarf is in
>  effect, without parsing all the options presented to gcc, and without looking
>  for the side effects (the .dwo files), we dodged that in the Google build
>  system by having a higher-level build flag, --fission, which would tell the
>  build system to pass -gsplit-dwarf to gcc AND look for the .dwo files produced
>  on the side. We simply disallowed having the user pass -gsplit-dwarf directly
>  to the compiler.
> 
> Feel free to share this.

My take of "-gsplit-dwarf implies -g" on cfe-dev is that people don't have strong opinions on updated semantics but they do notice that the implied -g2 is confusing.

@dblaikie I think we can proceed with this patch. I'll follow up on GCC side. Clang 11 will be consistent with GCC 11.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80391/new/

https://reviews.llvm.org/D80391




From cfe-commits at lists.llvm.org  Wed Jul  8 14:14:41 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:14:41 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <9748eaa25044d5f860525fdfc4dce979@localhost.localdomain>

efriedma added a comment.

> Should we remove the handling from llvm::ConstantFoldSelectInstruction

It seems silly to remove the handling from InstSimplify, but not constant folding.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:24:06 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:24:06 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: 

LukeZhuang updated this revision to Diff 276557.
LukeZhuang added a comment.

**updated: 07/08/2020**
(1) improve test case


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/test/Sema/builtin-expect-with-probability.cpp


Index: clang/test/Sema/builtin-expect-with-probability.cpp
===================================================================
--- clang/test/Sema/builtin-expect-with-probability.cpp
+++ clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,30 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+    if (__builtin_expect_with_probability(1, 1, 1))
+      bar();
+  } else {
+    return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
+template  void tempf() {
+  static_assert(b == 1, "should be evaluated as 1"); // should not have error here
+}
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1);
+}
+
+void foo() {
+  tempf<__builtin_expect_with_probability(1, 1, 1)>();
+  constexpr int f = constf();
+  static_assert(f == 1, "should be evaluated as 1"); // should not have error here
+}
+
 extern int global;
 
 struct S {
Index: clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-    // For __builtin_unpredictable, __builtin_expect, and
-    // __builtin_assume_aligned, just return the value of the subexpression.
+    // For __builtin_unpredictable, __builtin_expect,
+    // __builtin_expect_with_probability and __builtin_assume_aligned,
+    // just return the value of the subexpression.
     // __builtin_addressof is going from a reference to a pointer, but those
     // are represented the same way in the analyzer.
     assert (Call.getNumArgs() > 0);
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11200,6 +11200,7 @@
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
     return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83362.276557.patch
Type: text/x-patch
Size: 2464 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 14:24:30 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:24:30 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: <2bdc27a2275ba7d2a68654b7e1bc0ccf@localhost.localdomain>

LukeZhuang marked an inline comment as done.
LukeZhuang added a comment.

Thank you for the new comment. I've modified my test cases


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Wed Jul  8 14:25:11 2020
From: cfe-commits at lists.llvm.org (Anton Korobeynikov via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:25:11 +0000 (UTC)
Subject: [PATCH] D82646: [MSP430] Align the _Complex ABI with current
 msp430-gcc
In-Reply-To: 
References: 
Message-ID: 

asl accepted this revision.
asl added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82646/new/

https://reviews.llvm.org/D82646




From cfe-commits at lists.llvm.org  Wed Jul  8 14:30:47 2020
From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits)
Date: Wed, 08 Jul 2020 14:30:47 -0700 (PDT)
Subject: [clang] 903bda1 - PR46640: Permit the first parameter of a destroying
 'operator delete' to
Message-ID: <5f063b07.1c69fb81.98be8.2148@mx.google.com>


Author: Richard Smith
Date: 2020-07-08T14:29:39-07:00
New Revision: 903bda14c330505ebede522a1f55673d88909c6d

URL: https://github.com/llvm/llvm-project/commit/903bda14c330505ebede522a1f55673d88909c6d
DIFF: https://github.com/llvm/llvm-project/commit/903bda14c330505ebede522a1f55673d88909c6d.diff

LOG: PR46640: Permit the first parameter of a destroying 'operator delete' to
be dependent if it names the right type.

This matches the GCC behavior, but no longer matches the standard
wording. However, the standard wording in this case is not in line with
the intent, which was to require the enclosing class type to be named
directly. I've reported this wording oversight to the committee.

Added: 
    

Modified: 
    clang/lib/Sema/SemaDeclCXX.cpp
    clang/test/SemaCXX/cxx2a-destroying-delete.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index eb001a77518b..9cad6debc600 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15216,12 +15216,6 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
   QualType ResultType =
       FnDecl->getType()->castAs()->getReturnType();
 
-  // Check that the result type is not dependent.
-  if (ResultType->isDependentType())
-    return SemaRef.Diag(FnDecl->getLocation(),
-                        diag::err_operator_new_delete_dependent_result_type)
-    << FnDecl->getDeclName() << ExpectedResultType;
-
   // The operator is valid on any address space for OpenCL.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
     if (auto *PtrTy = ResultType->getAs()) {
@@ -15230,10 +15224,16 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
   }
 
   // Check that the result type is what we expect.
-  if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType)
-    return SemaRef.Diag(FnDecl->getLocation(),
-                        diag::err_operator_new_delete_invalid_result_type)
-    << FnDecl->getDeclName() << ExpectedResultType;
+  if (SemaRef.Context.getCanonicalType(ResultType) != ExpectedResultType) {
+    // Reject even if the type is dependent; an operator delete function is
+    // required to have a non-dependent result type.
+    return SemaRef.Diag(
+               FnDecl->getLocation(),
+               ResultType->isDependentType()
+                   ? diag::err_operator_new_delete_dependent_result_type
+                   : diag::err_operator_new_delete_invalid_result_type)
+           << FnDecl->getDeclName() << ExpectedResultType;
+  }
 
   // A function template must have at least 2 parameters.
   if (FnDecl->getDescribedFunctionTemplate() && FnDecl->getNumParams() < 2)
@@ -15247,13 +15247,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
                         diag::err_operator_new_delete_too_few_parameters)
       << FnDecl->getDeclName();
 
-  // Check the first parameter type is not dependent.
   QualType FirstParamType = FnDecl->getParamDecl(0)->getType();
-  if (FirstParamType->isDependentType())
-    return SemaRef.Diag(FnDecl->getLocation(), DependentParamTypeDiag)
-      << FnDecl->getDeclName() << ExpectedFirstParamType;
-
-  // Check that the first parameter type is what we expect.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
     // The operator is valid on any address space for OpenCL.
     if (auto *PtrTy =
@@ -15261,10 +15255,18 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl,
       FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
     }
   }
+
+  // Check that the first parameter type is what we expect.
   if (SemaRef.Context.getCanonicalType(FirstParamType).getUnqualifiedType() !=
-      ExpectedFirstParamType)
-    return SemaRef.Diag(FnDecl->getLocation(), InvalidParamTypeDiag)
-    << FnDecl->getDeclName() << ExpectedFirstParamType;
+      ExpectedFirstParamType) {
+    // The first parameter type is not allowed to be dependent. As a tentative
+    // DR resolution, we allow a dependent parameter type if it is the right
+    // type anyway, to allow destroying operator delete in class templates.
+    return SemaRef.Diag(FnDecl->getLocation(), FirstParamType->isDependentType()
+                                                   ? DependentParamTypeDiag
+                                                   : InvalidParamTypeDiag)
+           << FnDecl->getDeclName() << ExpectedFirstParamType;
+  }
 
   return false;
 }

diff  --git a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
index 553b7a7080fe..015d11e65526 100644
--- a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
+++ b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -123,3 +123,21 @@ namespace first_param_conversion {
     delete e; // expected-error {{ambiguous conversion from derived class 'first_param_conversion::E' to base class 'first_param_conversion::B':}}
   }
 }
+
+namespace templated {
+  template using id_alias = T;
+  template struct id_struct { using type = T; };
+
+  template struct A {
+    void operator delete(A *, std::destroying_delete_t);
+  };
+  template struct B {
+    void operator delete(B *, std::destroying_delete_t);
+  };
+  template struct C {
+    void operator delete(id_alias *, std::destroying_delete_t);
+  };
+  template struct D {
+    void operator delete(typename id_struct::type *, std::destroying_delete_t); // expected-error {{use 'D *'}}
+  };
+}


        

From cfe-commits at lists.llvm.org  Wed Jul  8 14:31:10 2020
From: cfe-commits at lists.llvm.org (David Majnemer via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:31:10 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <33588ea26985141853527613809a6cbc@localhost.localdomain>

majnemer added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4121-4125
-  if (isa(TrueVal))   // select ?, undef, X -> X
-    return FalseVal;
-  if (isa(FalseVal))   // select ?, X, undef -> X
-    return TrueVal;
-
----------------
Can we still do these optimizations when `X` is a frozen value?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:40:20 2020
From: cfe-commits at lists.llvm.org (John Regehr via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:40:20 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <70f942a0b3520a7e681f620502ebf19d@localhost.localdomain>

regehr added a comment.

@majnemer should work: https://alive2.llvm.org/ce/z/vL4yn4


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:44:02 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:44:02 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <918817a903e8fd373ee5d84a3746815e@localhost.localdomain>

craig.topper added a comment.

Wasn't @majnemer asking about

  define i32 @src(i1 %cond, i32 %x) {
    %xf = freeze i32 %x
    %s = select i1 %cond, i32 %xf, i32 undef
    ret i32 %s
  }

which is legal. I'm going to work on supporting known non-poison cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:47:56 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:47:56 +0000 (UTC)
Subject: [PATCH] D82476: [Clang][Driver] Recognize the AIX OBJECT_MODE
 environment setting
In-Reply-To: 
References: 
Message-ID: <085d1938f90f93393f067378913ad618@localhost.localdomain>

hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast added a comment.

LGTM with minor nit.



================
Comment at: clang/lib/Driver/Driver.cpp:478
+  // On AIX, the env OBJECT_MODE may affect the resulting arch variant.
+  if (Target.isOSAIX()) {
+    if (Optional ObjectModeValue =
----------------
Just a note: I guess having an AIX target is an okay proxy for being on AIX here... I don't think enabling `OBJECT_MODE` for other targets when building on AIX is superior.


================
Comment at: clang/test/Driver/aix-object-mode.c:1
+// Check setting an OBJECT_MODE converts the AIX triple to the right variant.
+// RUN: env OBJECT_MODE=64 \
----------------
Minor nit: Add "that" between "Check" and "setting".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82476/new/

https://reviews.llvm.org/D82476




From cfe-commits at lists.llvm.org  Wed Jul  8 14:48:37 2020
From: cfe-commits at lists.llvm.org (John Regehr via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:48:37 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <3c3ea310eb9a62f90af45ea5db372499@localhost.localdomain>

regehr added a comment.

@craig.topper ok, I agree that should work. alive doesn't like it -- is this an alive bug @nlopes? a freeze should not yield undef.
https://alive2.llvm.org/ce/z/mWAsYv


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:51:37 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:51:37 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: 

efriedma added a comment.

In D83360#2140224 , @regehr wrote:

> @craig.topper ok, I agree that should work. alive doesn't like it -- is this an alive bug @nlopes? a freeze should not yield undef.
>  https://alive2.llvm.org/ce/z/mWAsYv


Did you mean to check something like the following?

  define i32 @src(i1 %cond, i32 %x) {
    %x2 = freeze i32 %x
    %s = select i1 %cond, i32 %x2, i32 undef
    ret i32 %s
  }
  
  define i32 @tgt(i1 %cond, i32 %x) {
    %x2 = freeze i32 %x
    ret i32 %x2
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:52:11 2020
From: cfe-commits at lists.llvm.org (Craig Topper via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:52:11 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: 

craig.topper added a comment.

Alive does like this https://alive2.llvm.org/ce/z/yhibbe which is what I was going to implement.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 14:58:13 2020
From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:58:13 +0000 (UTC)
Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition
 and MC Tests for Load and Store VSX Vector with Zero or Sign Extend
In-Reply-To: 
References: 
Message-ID: <91346f6cc1016a2e27e1753897c2979d@localhost.localdomain>

Conanap updated this revision to Diff 276564.
Conanap added a comment.

Relocated some of the instructions to a more appropriate place.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83364/new/

https://reviews.llvm.org/D83364

Files:
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
  llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s


Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
===================================================================
--- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
+++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s
@@ -405,3 +405,27 @@
 # CHECK-BE: vinsdrx 1, 2, 3                       # encoding: [0x10,0x22,0x1b,0xcf]
 # CHECK-LE: vinsdrx 1, 2, 3                       # encoding: [0xcf,0x1b,0x22,0x10]
             vinsdrx 1, 2, 3
+# CHECK-BE: lxvrbx 32, 1, 2                       # encoding: [0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2                       # encoding: [0x1b,0x10,0x01,0x7c]
+            lxvrbx 32, 1, 2
+# CHECK-BE: lxvrhx 33, 1, 2                       # encoding: [0x7c,0x21,0x10,0x5b]
+# CHECK-LE: lxvrhx 33, 1, 2                       # encoding: [0x5b,0x10,0x21,0x7c]
+            lxvrhx 33, 1, 2
+# CHECK-BE: lxvrdx 34, 1, 2                       # encoding: [0x7c,0x41,0x10,0xdb]
+# CHECK-LE: lxvrdx 34, 1, 2                       # encoding: [0xdb,0x10,0x41,0x7c]
+            lxvrdx 34, 1, 2
+# CHECK-BE: lxvrwx 35, 1, 2                       # encoding: [0x7c,0x61,0x10,0x9b]
+# CHECK-LE: lxvrwx 35, 1, 2                       # encoding: [0x9b,0x10,0x61,0x7c]
+            lxvrwx 35, 1, 2
+# CHECK-BE: stxvrbx 32, 3, 1                      # encoding: [0x7c,0x03,0x09,0x1b]
+# CHECK-LE: stxvrbx 32, 3, 1                      # encoding: [0x1b,0x09,0x03,0x7c]
+            stxvrbx 32, 3, 1
+# CHECK-BE: stxvrhx 33, 3, 1                      # encoding: [0x7c,0x23,0x09,0x5b]
+# CHECK-LE: stxvrhx 33, 3, 1                      # encoding: [0x5b,0x09,0x23,0x7c]
+            stxvrhx 33, 3, 1
+# CHECK-BE: stxvrwx 34, 3, 1                      # encoding: [0x7c,0x43,0x09,0x9b]
+# CHECK-LE: stxvrwx 34, 3, 1                      # encoding: [0x9b,0x09,0x43,0x7c]
+            stxvrwx 34, 3, 1
+# CHECK-BE: stxvrdx 35, 3, 1                      # encoding: [0x7c,0x63,0x09,0xdb]
+# CHECK-LE: stxvrdx 35, 3, 1                      # encoding: [0xdb,0x09,0x63,0x7c]
+            stxvrdx 35, 3, 1
Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
===================================================================
--- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
+++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt
@@ -278,3 +278,27 @@
 
 # CHECK: vinsdrx 1, 2, 3
 0x10 0x22 0x1b 0xcf
+
+# CHECK: lxvrbx 32, 1, 2
+0x7c 0x01 0x10 0x1b
+
+# CHECK: lxvrhx 33, 1, 2
+0x7c 0x21 0x10 0x5b
+
+# CHECK: lxvrdx 34, 1, 2
+0x7c 0x41 0x10 0xdb
+
+# CHECK: lxvrwx 35, 1, 2
+0x7c 0x61 0x10 0x9b
+
+# CHECK: stxvrbx 32, 3, 1
+0x7c 0x03 0x09 0x1b
+
+# CHECK: stxvrhx 33, 3, 1
+0x7c 0x23 0x09 0x5b
+
+# CHECK: stxvrwx 34, 3, 1
+0x7c 0x43 0x09 0x9b
+
+# CHECK: stxvrdx 35, 3, 1
+0x7c 0x63 0x09 0xdb
Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -934,8 +934,25 @@
                          "vclrrb $vD, $vA, $rB", IIC_VecGeneral,
                          [(set v16i8:$vD,
                                (int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>;
+
+  // The XFormMemOp flag for the following 8 insts is set on the instruction format.
+  let mayLoad = 1, mayStore = 1 in {
+    def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>;
+    def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>;
+    def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>;
+    def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>;
+  }
+
+  let mayLoad = 0, mayStore = 1 in {
+    def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>;
+    def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>;
+    def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>;
+    def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>;
+  }
 }
 
+
+
 //---------------------------- Anonymous Patterns ----------------------------//
 let Predicates = [IsISA3_1] in {
   def : Pat<(v16i8 (int_ppc_vsx_xxgenpcvbm v16i8:$VRB, imm:$IMM)),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83364.276564.patch
Type: text/x-patch
Size: 4046 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 14:58:48 2020
From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 21:58:48 +0000 (UTC)
Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition
 and MC Tests for Load and Store VSX Vector with Zero or Sign Extend
In-Reply-To: 
References: 
Message-ID: <03fbe773f5d8615e2a55a97228fc041f@localhost.localdomain>

Conanap marked 2 inline comments as done.
Conanap added a comment.

Relocated the isntr definitions to a more appropriate place.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83364/new/

https://reviews.llvm.org/D83364




From cfe-commits at lists.llvm.org  Wed Jul  8 15:03:33 2020
From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 22:03:33 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: <17d60b54bf0acfd5625bc808c05da536@localhost.localdomain>

njames93 added a comment.

I'm not a huge fan of using `error`, maybe `createError`, its used in many other parts of llvm, typically with static linkage.
Its definitely out of place in Logger, but there is no where else better for it to live short of a new file which seems overkill.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Wed Jul  8 15:14:06 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 22:14:06 +0000 (UTC)
Subject: [PATCH] D83436: [clangd] Fix error handling in config.yaml parsing.
Message-ID: 

sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

A few things were broken:

- use of Document::parseBlockNode() is incorrect and prevents moving to the next doc in error cases. Use getRoot() instead.
- bailing out in the middle of iterating over a list/dict isn't allowed, unless you are going to throw away the parser: the next skip() asserts. Always consume all items.
- There were two concepts of fatal errors: error-diagnostics and drop-fragment. (The latter is the "return false" case in the parser). They didn't coincide. Now, parser errors and explicitly emitted error diagnostics are fatal.

Fixes https://github.com/clangd/clangd/issues/452


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83436

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83436.276574.patch
Type: text/x-patch
Size: 6179 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 15:18:23 2020
From: cfe-commits at lists.llvm.org (Nuno Lopes via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 22:18:23 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: 

nlopes added a comment.

In D83360#2140241 , @craig.topper wrote:

> Alive does like this https://alive2.llvm.org/ce/z/yhibbe which is what I was going to implement.


right. There's a guaranteedNonPoison (or similar name) in ValueTracking that can be used I guess.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 15:31:10 2020
From: cfe-commits at lists.llvm.org (Sam Elliott via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 22:31:10 +0000 (UTC)
Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu
In-Reply-To: 
References: 
Message-ID: <1ab0eb6f9b2630e7a1dc29d1772f241b@localhost.localdomain>

lenary added a comment.

I realise this is almost certainly something we want to land before the LLVM 11 branch date, as we included schedules in LLVM 10 with no way to use them, and would like users to be able to use them. I'll bring it up on the call tomorrow - I hope this PR implements what we agreed from the previous calls.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71124/new/

https://reviews.llvm.org/D71124




From cfe-commits at lists.llvm.org  Wed Jul  8 15:36:14 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits)
Date: Wed, 08 Jul 2020 15:36:14 -0700 (PDT)
Subject: [clang] d999cbc - [OpenMP] Initial support for std::complex in target
 regions
Message-ID: <5f064a5e.1c69fb81.dd215.264a@mx.google.com>


Author: Johannes Doerfert
Date: 2020-07-08T17:33:59-05:00
New Revision: d999cbc98832154e15e786b98281211d5c1b9f5d

URL: https://github.com/llvm/llvm-project/commit/d999cbc98832154e15e786b98281211d5c1b9f5d
DIFF: https://github.com/llvm/llvm-project/commit/d999cbc98832154e15e786b98281211d5c1b9f5d.diff

LOG: [OpenMP] Initial support for std::complex in target regions

This simply follows the scheme we have for other wrappers. It resolves
the current link problem, e.g., `__muldc3 not found`, when std::complex
operations are used on a device.

This will not allow complex make math function calls to work properly,
e.g., sin, but that is more complex (pan intended) anyway.

Reviewed By: tra, JonChesterfield

Differential Revision: https://reviews.llvm.org/D80897

Added: 
    clang/lib/Headers/openmp_wrappers/complex
    clang/lib/Headers/openmp_wrappers/complex.h
    clang/test/Headers/Inputs/include/complex
    clang/test/Headers/nvptx_device_math_complex.cpp

Modified: 
    clang/lib/Headers/CMakeLists.txt
    clang/lib/Headers/__clang_cuda_complex_builtins.h
    clang/lib/Headers/__clang_cuda_math.h
    clang/test/Headers/Inputs/include/cmath
    clang/test/Headers/Inputs/include/cstdlib
    clang/test/Headers/nvptx_device_math_complex.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt
index e7bee192d918..0692fe75a441 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -151,6 +151,8 @@ set(ppc_wrapper_files
 set(openmp_wrapper_files
   openmp_wrappers/math.h
   openmp_wrappers/cmath
+  openmp_wrappers/complex.h
+  openmp_wrappers/complex
   openmp_wrappers/__clang_openmp_device_functions.h
   openmp_wrappers/new
 )

diff  --git a/clang/lib/Headers/__clang_cuda_complex_builtins.h b/clang/lib/Headers/__clang_cuda_complex_builtins.h
index 576a958b16bb..d698be71d011 100644
--- a/clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ b/clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -13,10 +13,61 @@
 // This header defines __muldc3, __mulsc3, __divdc3, and __divsc3.  These are
 // libgcc functions that clang assumes are available when compiling c99 complex
 // operations.  (These implementations come from libc++, and have been modified
-// to work with CUDA.)
+// to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
-extern "C" inline __device__ double _Complex __muldc3(double __a, double __b,
-                                                      double __c, double __d) {
+#pragma push_macro("__DEVICE__")
+#ifdef _OPENMP
+#pragma omp declare target
+#define __DEVICE__ __attribute__((noinline, nothrow, cold))
+#else
+#define __DEVICE__ __device__ inline
+#endif
+
+// Make the algorithms available for C and C++ by selecting the right functions.
+#if defined(__cplusplus)
+// TODO: In OpenMP mode we cannot overload isinf/isnan/isfinite the way we
+// overload all other math functions because old math system headers and not
+// always conformant and return an integer instead of a boolean. Until that has
+// been addressed we need to work around it. For now, we substituate with the
+// calls we would have used to implement those three functions. Note that we
+// could use the C alternatives as well.
+#define _ISNANd ::__isnan
+#define _ISNANf ::__isnanf
+#define _ISINFd ::__isinf
+#define _ISINFf ::__isinff
+#define _ISFINITEd ::__isfinited
+#define _ISFINITEf ::__finitef
+#define _COPYSIGNd std::copysign
+#define _COPYSIGNf std::copysign
+#define _SCALBNd std::scalbn
+#define _SCALBNf std::scalbn
+#define _ABSd std::abs
+#define _ABSf std::abs
+#define _LOGBd std::logb
+#define _LOGBf std::logb
+#else
+#define _ISNANd isnan
+#define _ISNANf isnanf
+#define _ISINFd isinf
+#define _ISINFf isinff
+#define _ISFINITEd isfinite
+#define _ISFINITEf isfinitef
+#define _COPYSIGNd copysign
+#define _COPYSIGNf copysignf
+#define _SCALBNd scalbn
+#define _SCALBNf scalbnf
+#define _ABSd abs
+#define _ABSf absf
+#define _LOGBd logb
+#define _LOGBf logbf
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+__DEVICE__ double _Complex __muldc3(double __a, double __b, double __c,
+                                    double __d) {
   double __ac = __a * __c;
   double __bd = __b * __d;
   double __ad = __a * __d;
@@ -24,50 +75,49 @@ extern "C" inline __device__ double _Complex __muldc3(double __a, double __b,
   double _Complex z;
   __real__(z) = __ac - __bd;
   __imag__(z) = __ad + __bc;
-  if (std::isnan(__real__(z)) && std::isnan(__imag__(z))) {
+  if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
     int __recalc = 0;
-    if (std::isinf(__a) || std::isinf(__b)) {
-      __a = std::copysign(std::isinf(__a) ? 1 : 0, __a);
-      __b = std::copysign(std::isinf(__b) ? 1 : 0, __b);
-      if (std::isnan(__c))
-        __c = std::copysign(0, __c);
-      if (std::isnan(__d))
-        __d = std::copysign(0, __d);
+    if (_ISINFd(__a) || _ISINFd(__b)) {
+      __a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a);
+      __b = _COPYSIGNd(_ISINFd(__b) ? 1 : 0, __b);
+      if (_ISNANd(__c))
+        __c = _COPYSIGNd(0, __c);
+      if (_ISNANd(__d))
+        __d = _COPYSIGNd(0, __d);
       __recalc = 1;
     }
-    if (std::isinf(__c) || std::isinf(__d)) {
-      __c = std::copysign(std::isinf(__c) ? 1 : 0, __c);
-      __d = std::copysign(std::isinf(__d) ? 1 : 0, __d);
-      if (std::isnan(__a))
-        __a = std::copysign(0, __a);
-      if (std::isnan(__b))
-        __b = std::copysign(0, __b);
+    if (_ISINFd(__c) || _ISINFd(__d)) {
+      __c = _COPYSIGNd(_ISINFd(__c) ? 1 : 0, __c);
+      __d = _COPYSIGNd(_ISINFd(__d) ? 1 : 0, __d);
+      if (_ISNANd(__a))
+        __a = _COPYSIGNd(0, __a);
+      if (_ISNANd(__b))
+        __b = _COPYSIGNd(0, __b);
       __recalc = 1;
     }
-    if (!__recalc && (std::isinf(__ac) || std::isinf(__bd) ||
-                      std::isinf(__ad) || std::isinf(__bc))) {
-      if (std::isnan(__a))
-        __a = std::copysign(0, __a);
-      if (std::isnan(__b))
-        __b = std::copysign(0, __b);
-      if (std::isnan(__c))
-        __c = std::copysign(0, __c);
-      if (std::isnan(__d))
-        __d = std::copysign(0, __d);
+    if (!__recalc &&
+        (_ISINFd(__ac) || _ISINFd(__bd) || _ISINFd(__ad) || _ISINFd(__bc))) {
+      if (_ISNANd(__a))
+        __a = _COPYSIGNd(0, __a);
+      if (_ISNANd(__b))
+        __b = _COPYSIGNd(0, __b);
+      if (_ISNANd(__c))
+        __c = _COPYSIGNd(0, __c);
+      if (_ISNANd(__d))
+        __d = _COPYSIGNd(0, __d);
       __recalc = 1;
     }
     if (__recalc) {
       // Can't use std::numeric_limits::infinity() -- that doesn't have
       // a device overload (and isn't constexpr before C++11, naturally).
-      __real__(z) = __builtin_huge_valf() * (__a * __c - __b * __d);
-      __imag__(z) = __builtin_huge_valf() * (__a * __d + __b * __c);
+      __real__(z) = __builtin_huge_val() * (__a * __c - __b * __d);
+      __imag__(z) = __builtin_huge_val() * (__a * __d + __b * __c);
     }
   }
   return z;
 }
 
-extern "C" inline __device__ float _Complex __mulsc3(float __a, float __b,
-                                                     float __c, float __d) {
+__DEVICE__ float _Complex __mulsc3(float __a, float __b, float __c, float __d) {
   float __ac = __a * __c;
   float __bd = __b * __d;
   float __ad = __a * __d;
@@ -75,36 +125,36 @@ extern "C" inline __device__ float _Complex __mulsc3(float __a, float __b,
   float _Complex z;
   __real__(z) = __ac - __bd;
   __imag__(z) = __ad + __bc;
-  if (std::isnan(__real__(z)) && std::isnan(__imag__(z))) {
+  if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) {
     int __recalc = 0;
-    if (std::isinf(__a) || std::isinf(__b)) {
-      __a = std::copysign(std::isinf(__a) ? 1 : 0, __a);
-      __b = std::copysign(std::isinf(__b) ? 1 : 0, __b);
-      if (std::isnan(__c))
-        __c = std::copysign(0, __c);
-      if (std::isnan(__d))
-        __d = std::copysign(0, __d);
+    if (_ISINFf(__a) || _ISINFf(__b)) {
+      __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a);
+      __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b);
+      if (_ISNANf(__c))
+        __c = _COPYSIGNf(0, __c);
+      if (_ISNANf(__d))
+        __d = _COPYSIGNf(0, __d);
       __recalc = 1;
     }
-    if (std::isinf(__c) || std::isinf(__d)) {
-      __c = std::copysign(std::isinf(__c) ? 1 : 0, __c);
-      __d = std::copysign(std::isinf(__d) ? 1 : 0, __d);
-      if (std::isnan(__a))
-        __a = std::copysign(0, __a);
-      if (std::isnan(__b))
-        __b = std::copysign(0, __b);
+    if (_ISINFf(__c) || _ISINFf(__d)) {
+      __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c);
+      __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d);
+      if (_ISNANf(__a))
+        __a = _COPYSIGNf(0, __a);
+      if (_ISNANf(__b))
+        __b = _COPYSIGNf(0, __b);
       __recalc = 1;
     }
-    if (!__recalc && (std::isinf(__ac) || std::isinf(__bd) ||
-                      std::isinf(__ad) || std::isinf(__bc))) {
-      if (std::isnan(__a))
-        __a = std::copysign(0, __a);
-      if (std::isnan(__b))
-        __b = std::copysign(0, __b);
-      if (std::isnan(__c))
-        __c = std::copysign(0, __c);
-      if (std::isnan(__d))
-        __d = std::copysign(0, __d);
+    if (!__recalc &&
+        (_ISINFf(__ac) || _ISINFf(__bd) || _ISINFf(__ad) || _ISINFf(__bc))) {
+      if (_ISNANf(__a))
+        __a = _COPYSIGNf(0, __a);
+      if (_ISNANf(__b))
+        __b = _COPYSIGNf(0, __b);
+      if (_ISNANf(__c))
+        __c = _COPYSIGNf(0, __c);
+      if (_ISNANf(__d))
+        __d = _COPYSIGNf(0, __d);
       __recalc = 1;
     }
     if (__recalc) {
@@ -115,36 +165,36 @@ extern "C" inline __device__ float _Complex __mulsc3(float __a, float __b,
   return z;
 }
 
-extern "C" inline __device__ double _Complex __divdc3(double __a, double __b,
-                                                      double __c, double __d) {
+__DEVICE__ double _Complex __divdc3(double __a, double __b, double __c,
+                                    double __d) {
   int __ilogbw = 0;
   // Can't use std::max, because that's defined in , and we don't
   // want to pull that in for every compile.  The CUDA headers define
   // ::max(float, float) and ::max(double, double), which is sufficient for us.
-  double __logbw = std::logb(max(std::abs(__c), std::abs(__d)));
-  if (std::isfinite(__logbw)) {
+  double __logbw = _LOGBd(max(_ABSd(__c), _ABSd(__d)));
+  if (_ISFINITEd(__logbw)) {
     __ilogbw = (int)__logbw;
-    __c = std::scalbn(__c, -__ilogbw);
-    __d = std::scalbn(__d, -__ilogbw);
+    __c = _SCALBNd(__c, -__ilogbw);
+    __d = _SCALBNd(__d, -__ilogbw);
   }
   double __denom = __c * __c + __d * __d;
   double _Complex z;
-  __real__(z) = std::scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
-  __imag__(z) = std::scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
-  if (std::isnan(__real__(z)) && std::isnan(__imag__(z))) {
-    if ((__denom == 0.0) && (!std::isnan(__a) || !std::isnan(__b))) {
-      __real__(z) = std::copysign(__builtin_huge_valf(), __c) * __a;
-      __imag__(z) = std::copysign(__builtin_huge_valf(), __c) * __b;
-    } else if ((std::isinf(__a) || std::isinf(__b)) && std::isfinite(__c) &&
-               std::isfinite(__d)) {
-      __a = std::copysign(std::isinf(__a) ? 1.0 : 0.0, __a);
-      __b = std::copysign(std::isinf(__b) ? 1.0 : 0.0, __b);
-      __real__(z) = __builtin_huge_valf() * (__a * __c + __b * __d);
-      __imag__(z) = __builtin_huge_valf() * (__b * __c - __a * __d);
-    } else if (std::isinf(__logbw) && __logbw > 0.0 && std::isfinite(__a) &&
-               std::isfinite(__b)) {
-      __c = std::copysign(std::isinf(__c) ? 1.0 : 0.0, __c);
-      __d = std::copysign(std::isinf(__d) ? 1.0 : 0.0, __d);
+  __real__(z) = _SCALBNd((__a * __c + __b * __d) / __denom, -__ilogbw);
+  __imag__(z) = _SCALBNd((__b * __c - __a * __d) / __denom, -__ilogbw);
+  if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
+    if ((__denom == 0.0) && (!_ISNANd(__a) || !_ISNANd(__b))) {
+      __real__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __a;
+      __imag__(z) = _COPYSIGNd(__builtin_huge_val(), __c) * __b;
+    } else if ((_ISINFd(__a) || _ISINFd(__b)) && _ISFINITEd(__c) &&
+               _ISFINITEd(__d)) {
+      __a = _COPYSIGNd(_ISINFd(__a) ? 1.0 : 0.0, __a);
+      __b = _COPYSIGNd(_ISINFd(__b) ? 1.0 : 0.0, __b);
+      __real__(z) = __builtin_huge_val() * (__a * __c + __b * __d);
+      __imag__(z) = __builtin_huge_val() * (__b * __c - __a * __d);
+    } else if (_ISINFd(__logbw) && __logbw > 0.0 && _ISFINITEd(__a) &&
+               _ISFINITEd(__b)) {
+      __c = _COPYSIGNd(_ISINFd(__c) ? 1.0 : 0.0, __c);
+      __d = _COPYSIGNd(_ISINFd(__d) ? 1.0 : 0.0, __d);
       __real__(z) = 0.0 * (__a * __c + __b * __d);
       __imag__(z) = 0.0 * (__b * __c - __a * __d);
     }
@@ -152,33 +202,32 @@ extern "C" inline __device__ double _Complex __divdc3(double __a, double __b,
   return z;
 }
 
-extern "C" inline __device__ float _Complex __divsc3(float __a, float __b,
-                                                     float __c, float __d) {
+__DEVICE__ float _Complex __divsc3(float __a, float __b, float __c, float __d) {
   int __ilogbw = 0;
-  float __logbw = std::logb(max(std::abs(__c), std::abs(__d)));
-  if (std::isfinite(__logbw)) {
+  float __logbw = _LOGBf(max(_ABSf(__c), _ABSf(__d)));
+  if (_ISFINITEf(__logbw)) {
     __ilogbw = (int)__logbw;
-    __c = std::scalbn(__c, -__ilogbw);
-    __d = std::scalbn(__d, -__ilogbw);
+    __c = _SCALBNf(__c, -__ilogbw);
+    __d = _SCALBNf(__d, -__ilogbw);
   }
   float __denom = __c * __c + __d * __d;
   float _Complex z;
-  __real__(z) = std::scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
-  __imag__(z) = std::scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
-  if (std::isnan(__real__(z)) && std::isnan(__imag__(z))) {
-    if ((__denom == 0) && (!std::isnan(__a) || !std::isnan(__b))) {
-      __real__(z) = std::copysign(__builtin_huge_valf(), __c) * __a;
-      __imag__(z) = std::copysign(__builtin_huge_valf(), __c) * __b;
-    } else if ((std::isinf(__a) || std::isinf(__b)) && std::isfinite(__c) &&
-               std::isfinite(__d)) {
-      __a = std::copysign(std::isinf(__a) ? 1 : 0, __a);
-      __b = std::copysign(std::isinf(__b) ? 1 : 0, __b);
+  __real__(z) = _SCALBNf((__a * __c + __b * __d) / __denom, -__ilogbw);
+  __imag__(z) = _SCALBNf((__b * __c - __a * __d) / __denom, -__ilogbw);
+  if (_ISNANf(__real__(z)) && _ISNANf(__imag__(z))) {
+    if ((__denom == 0) && (!_ISNANf(__a) || !_ISNANf(__b))) {
+      __real__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __a;
+      __imag__(z) = _COPYSIGNf(__builtin_huge_valf(), __c) * __b;
+    } else if ((_ISINFf(__a) || _ISINFf(__b)) && _ISFINITEf(__c) &&
+               _ISFINITEf(__d)) {
+      __a = _COPYSIGNf(_ISINFf(__a) ? 1 : 0, __a);
+      __b = _COPYSIGNf(_ISINFf(__b) ? 1 : 0, __b);
       __real__(z) = __builtin_huge_valf() * (__a * __c + __b * __d);
       __imag__(z) = __builtin_huge_valf() * (__b * __c - __a * __d);
-    } else if (std::isinf(__logbw) && __logbw > 0 && std::isfinite(__a) &&
-               std::isfinite(__b)) {
-      __c = std::copysign(std::isinf(__c) ? 1 : 0, __c);
-      __d = std::copysign(std::isinf(__d) ? 1 : 0, __d);
+    } else if (_ISINFf(__logbw) && __logbw > 0 && _ISFINITEf(__a) &&
+               _ISFINITEf(__b)) {
+      __c = _COPYSIGNf(_ISINFf(__c) ? 1 : 0, __c);
+      __d = _COPYSIGNf(_ISINFf(__d) ? 1 : 0, __d);
       __real__(z) = 0 * (__a * __c + __b * __d);
       __imag__(z) = 0 * (__b * __c - __a * __d);
     }
@@ -186,4 +235,29 @@ extern "C" inline __device__ float _Complex __divsc3(float __a, float __b,
   return z;
 }
 
+#if defined(__cplusplus)
+} // extern "C"
+#endif
+
+#undef _ISNANd
+#undef _ISNANf
+#undef _ISINFd
+#undef _ISINFf
+#undef _COPYSIGNd
+#undef _COPYSIGNf
+#undef _ISFINITEd
+#undef _ISFINITEf
+#undef _SCALBNd
+#undef _SCALBNf
+#undef _ABSd
+#undef _ABSf
+#undef _LOGBd
+#undef _LOGBf
+
+#ifdef _OPENMP
+#pragma omp end declare target
+#endif
+
+#pragma pop_macro("__DEVICE__")
+
 #endif // __CLANG_CUDA_COMPLEX_BUILTINS

diff  --git a/clang/lib/Headers/__clang_cuda_math.h b/clang/lib/Headers/__clang_cuda_math.h
index 01db2f29af45..939c71a731e5 100644
--- a/clang/lib/Headers/__clang_cuda_math.h
+++ b/clang/lib/Headers/__clang_cuda_math.h
@@ -340,6 +340,16 @@ __DEVICE__ float y1f(float __a) { return __nv_y1f(__a); }
 __DEVICE__ double yn(int __a, double __b) { return __nv_yn(__a, __b); }
 __DEVICE__ float ynf(int __a, float __b) { return __nv_ynf(__a, __b); }
 
+// In C++ mode OpenMP takes the system versions of these because some math
+// headers provide the wrong return type. This cannot happen in C and we can and
+// want to use the specialized versions right away.
+#if defined(_OPENMP) && !defined(__cplusplus)
+__DEVICE__ int isinff(float __x) { return __nv_isinff(__x); }
+__DEVICE__ int isinf(double __x) { return __nv_isinfd(__x); }
+__DEVICE__ int isnanf(float __x) { return __nv_isnanf(__x); }
+__DEVICE__ int isnan(double __x) { return __nv_isnand(__x); }
+#endif
+
 #pragma pop_macro("__DEVICE__")
 #pragma pop_macro("__DEVICE_VOID__")
 #pragma pop_macro("__FAST_OR_SLOW")

diff  --git a/clang/lib/Headers/openmp_wrappers/complex b/clang/lib/Headers/openmp_wrappers/complex
new file mode 100644
index 000000000000..1ed0b14879ef
--- /dev/null
+++ b/clang/lib/Headers/openmp_wrappers/complex
@@ -0,0 +1,25 @@
+/*===-- complex --- OpenMP complex wrapper for target regions --------- c++ -===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#ifndef __CLANG_OPENMP_COMPLEX__
+#define __CLANG_OPENMP_COMPLEX__
+
+#ifndef _OPENMP
+#error "This file is for OpenMP compilation only."
+#endif
+
+// We require std::math functions in the complex builtins below.
+#include 
+
+#define __CUDA__
+#include <__clang_cuda_complex_builtins.h>
+#endif
+
+// Grab the host header too.
+#include_next 

diff  --git a/clang/lib/Headers/openmp_wrappers/complex.h b/clang/lib/Headers/openmp_wrappers/complex.h
new file mode 100644
index 000000000000..829c7a785725
--- /dev/null
+++ b/clang/lib/Headers/openmp_wrappers/complex.h
@@ -0,0 +1,25 @@
+/*===-- complex --- OpenMP complex wrapper for target regions --------- c++ -===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#ifndef __CLANG_OPENMP_COMPLEX_H__
+#define __CLANG_OPENMP_COMPLEX_H__
+
+#ifndef _OPENMP
+#error "This file is for OpenMP compilation only."
+#endif
+
+// We require math functions in the complex builtins below.
+#include 
+
+#define __CUDA__
+#include <__clang_cuda_complex_builtins.h>
+#endif
+
+// Grab the host header too.
+#include_next 

diff  --git a/clang/test/Headers/Inputs/include/cmath b/clang/test/Headers/Inputs/include/cmath
index 0cadc131d211..5e4e8b67514f 100644
--- a/clang/test/Headers/Inputs/include/cmath
+++ b/clang/test/Headers/Inputs/include/cmath
@@ -49,8 +49,12 @@ double fma(double, double, double);
 float fma(float, float, float);
 double fmax(double, double);
 float fmax(float, float);
+float max(float, float);
+double max(double, double);
 double fmin(double, double);
 float fmin(float, float);
+float min(float, float);
+double min(double, double);
 double fmod(double, double);
 float fmod(float, float);
 int fpclassify(double);

diff  --git a/clang/test/Headers/Inputs/include/complex b/clang/test/Headers/Inputs/include/complex
new file mode 100644
index 000000000000..f3aefab7954b
--- /dev/null
+++ b/clang/test/Headers/Inputs/include/complex
@@ -0,0 +1,301 @@
+#pragma once
+
+#include 
+
+#define INFINITY (__builtin_inff())
+
+namespace std {
+
+// Taken from libc++
+template 
+class complex {
+public:
+  typedef _Tp value_type;
+
+private:
+  value_type __re_;
+  value_type __im_;
+
+public:
+  complex(const value_type &__re = value_type(), const value_type &__im = value_type())
+      : __re_(__re), __im_(__im) {}
+  template 
+  complex(const complex<_Xp> &__c)
+      : __re_(__c.real()), __im_(__c.imag()) {}
+
+  value_type real() const { return __re_; }
+  value_type imag() const { return __im_; }
+
+  void real(value_type __re) { __re_ = __re; }
+  void imag(value_type __im) { __im_ = __im; }
+
+  complex &operator=(const value_type &__re) {
+    __re_ = __re;
+    __im_ = value_type();
+    return *this;
+  }
+  complex &operator+=(const value_type &__re) {
+    __re_ += __re;
+    return *this;
+  }
+  complex &operator-=(const value_type &__re) {
+    __re_ -= __re;
+    return *this;
+  }
+  complex &operator*=(const value_type &__re) {
+    __re_ *= __re;
+    __im_ *= __re;
+    return *this;
+  }
+  complex &operator/=(const value_type &__re) {
+    __re_ /= __re;
+    __im_ /= __re;
+    return *this;
+  }
+
+  template 
+  complex &operator=(const complex<_Xp> &__c) {
+    __re_ = __c.real();
+    __im_ = __c.imag();
+    return *this;
+  }
+  template 
+  complex &operator+=(const complex<_Xp> &__c) {
+    __re_ += __c.real();
+    __im_ += __c.imag();
+    return *this;
+  }
+  template 
+  complex &operator-=(const complex<_Xp> &__c) {
+    __re_ -= __c.real();
+    __im_ -= __c.imag();
+    return *this;
+  }
+  template 
+  complex &operator*=(const complex<_Xp> &__c) {
+    *this = *this * complex(__c.real(), __c.imag());
+    return *this;
+  }
+  template 
+  complex &operator/=(const complex<_Xp> &__c) {
+    *this = *this / complex(__c.real(), __c.imag());
+    return *this;
+  }
+};
+
+template 
+inline complex<_Tp>
+operator+(const complex<_Tp> &__x, const complex<_Tp> &__y) {
+  complex<_Tp> __t(__x);
+  __t += __y;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator+(const complex<_Tp> &__x, const _Tp &__y) {
+  complex<_Tp> __t(__x);
+  __t += __y;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator+(const _Tp &__x, const complex<_Tp> &__y) {
+  complex<_Tp> __t(__y);
+  __t += __x;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator-(const complex<_Tp> &__x, const complex<_Tp> &__y) {
+  complex<_Tp> __t(__x);
+  __t -= __y;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator-(const complex<_Tp> &__x, const _Tp &__y) {
+  complex<_Tp> __t(__x);
+  __t -= __y;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator-(const _Tp &__x, const complex<_Tp> &__y) {
+  complex<_Tp> __t(-__y);
+  __t += __x;
+  return __t;
+}
+
+template 
+complex<_Tp>
+operator*(const complex<_Tp> &__z, const complex<_Tp> &__w) {
+  _Tp __a = __z.real();
+  _Tp __b = __z.imag();
+  _Tp __c = __w.real();
+  _Tp __d = __w.imag();
+  _Tp __ac = __a * __c;
+  _Tp __bd = __b * __d;
+  _Tp __ad = __a * __d;
+  _Tp __bc = __b * __c;
+  _Tp __x = __ac - __bd;
+  _Tp __y = __ad + __bc;
+  if (std::isnan(__x) && std::isnan(__y)) {
+    bool __recalc = false;
+    if (std::isinf(__a) || std::isinf(__b)) {
+      __a = copysign(std::isinf(__a) ? _Tp(1) : _Tp(0), __a);
+      __b = copysign(std::isinf(__b) ? _Tp(1) : _Tp(0), __b);
+      if (std::isnan(__c))
+        __c = copysign(_Tp(0), __c);
+      if (std::isnan(__d))
+        __d = copysign(_Tp(0), __d);
+      __recalc = true;
+    }
+    if (std::isinf(__c) || std::isinf(__d)) {
+      __c = copysign(std::isinf(__c) ? _Tp(1) : _Tp(0), __c);
+      __d = copysign(std::isinf(__d) ? _Tp(1) : _Tp(0), __d);
+      if (std::isnan(__a))
+        __a = copysign(_Tp(0), __a);
+      if (std::isnan(__b))
+        __b = copysign(_Tp(0), __b);
+      __recalc = true;
+    }
+    if (!__recalc && (std::isinf(__ac) || std::isinf(__bd) ||
+                      std::isinf(__ad) || std::isinf(__bc))) {
+      if (std::isnan(__a))
+        __a = copysign(_Tp(0), __a);
+      if (std::isnan(__b))
+        __b = copysign(_Tp(0), __b);
+      if (std::isnan(__c))
+        __c = copysign(_Tp(0), __c);
+      if (std::isnan(__d))
+        __d = copysign(_Tp(0), __d);
+      __recalc = true;
+    }
+    if (__recalc) {
+      __x = _Tp(INFINITY) * (__a * __c - __b * __d);
+      __y = _Tp(INFINITY) * (__a * __d + __b * __c);
+    }
+  }
+  return complex<_Tp>(__x, __y);
+}
+
+template 
+inline complex<_Tp>
+operator*(const complex<_Tp> &__x, const _Tp &__y) {
+  complex<_Tp> __t(__x);
+  __t *= __y;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator*(const _Tp &__x, const complex<_Tp> &__y) {
+  complex<_Tp> __t(__y);
+  __t *= __x;
+  return __t;
+}
+
+template 
+complex<_Tp>
+operator/(const complex<_Tp> &__z, const complex<_Tp> &__w) {
+  int __ilogbw = 0;
+  _Tp __a = __z.real();
+  _Tp __b = __z.imag();
+  _Tp __c = __w.real();
+  _Tp __d = __w.imag();
+  _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
+  if (std::isfinite(__logbw)) {
+    __ilogbw = static_cast(__logbw);
+    __c = scalbn(__c, -__ilogbw);
+    __d = scalbn(__d, -__ilogbw);
+  }
+  _Tp __denom = __c * __c + __d * __d;
+  _Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
+  _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
+  if (std::isnan(__x) && std::isnan(__y)) {
+    if ((__denom == _Tp(0)) && (!std::isnan(__a) || !std::isnan(__b))) {
+      __x = copysign(_Tp(INFINITY), __c) * __a;
+      __y = copysign(_Tp(INFINITY), __c) * __b;
+    } else if ((std::isinf(__a) || std::isinf(__b)) && std::isfinite(__c) && std::isfinite(__d)) {
+      __a = copysign(std::isinf(__a) ? _Tp(1) : _Tp(0), __a);
+      __b = copysign(std::isinf(__b) ? _Tp(1) : _Tp(0), __b);
+      __x = _Tp(INFINITY) * (__a * __c + __b * __d);
+      __y = _Tp(INFINITY) * (__b * __c - __a * __d);
+    } else if (std::isinf(__logbw) && __logbw > _Tp(0) && std::isfinite(__a) && std::isfinite(__b)) {
+      __c = copysign(std::isinf(__c) ? _Tp(1) : _Tp(0), __c);
+      __d = copysign(std::isinf(__d) ? _Tp(1) : _Tp(0), __d);
+      __x = _Tp(0) * (__a * __c + __b * __d);
+      __y = _Tp(0) * (__b * __c - __a * __d);
+    }
+  }
+  return complex<_Tp>(__x, __y);
+}
+
+template 
+inline complex<_Tp>
+operator/(const complex<_Tp> &__x, const _Tp &__y) {
+  return complex<_Tp>(__x.real() / __y, __x.imag() / __y);
+}
+
+template 
+inline complex<_Tp>
+operator/(const _Tp &__x, const complex<_Tp> &__y) {
+  complex<_Tp> __t(__x);
+  __t /= __y;
+  return __t;
+}
+
+template 
+inline complex<_Tp>
+operator+(const complex<_Tp> &__x) {
+  return __x;
+}
+
+template 
+inline complex<_Tp>
+operator-(const complex<_Tp> &__x) {
+  return complex<_Tp>(-__x.real(), -__x.imag());
+}
+
+template 
+inline bool
+operator==(const complex<_Tp> &__x, const complex<_Tp> &__y) {
+  return __x.real() == __y.real() && __x.imag() == __y.imag();
+}
+
+template 
+inline bool
+operator==(const complex<_Tp> &__x, const _Tp &__y) {
+  return __x.real() == __y && __x.imag() == 0;
+}
+
+template 
+inline bool
+operator==(const _Tp &__x, const complex<_Tp> &__y) {
+  return __x == __y.real() && 0 == __y.imag();
+}
+
+template 
+inline bool
+operator!=(const complex<_Tp> &__x, const complex<_Tp> &__y) {
+  return !(__x == __y);
+}
+
+template 
+inline bool
+operator!=(const complex<_Tp> &__x, const _Tp &__y) {
+  return !(__x == __y);
+}
+
+template 
+inline bool
+operator!=(const _Tp &__x, const complex<_Tp> &__y) {
+  return !(__x == __y);
+}
+
+} // namespace std

diff  --git a/clang/test/Headers/Inputs/include/cstdlib b/clang/test/Headers/Inputs/include/cstdlib
index 00e81e8c4a15..1d1864a98976 100644
--- a/clang/test/Headers/Inputs/include/cstdlib
+++ b/clang/test/Headers/Inputs/include/cstdlib
@@ -24,4 +24,8 @@ inline long long
 abs(long long __x) { return __builtin_llabs (__x); }
 
 float fabs(float __x) { return __builtin_fabs(__x); }
+
+float abs(float __x) { return fabs(__x); }
+double abs(double __x) { return fabs(__x); }
+
 }

diff  --git a/clang/test/Headers/nvptx_device_math_complex.c b/clang/test/Headers/nvptx_device_math_complex.c
index 43f4ec6a6b59..9b96b5dd8c22 100644
--- a/clang/test/Headers/nvptx_device_math_complex.c
+++ b/clang/test/Headers/nvptx_device_math_complex.c
@@ -1,10 +1,22 @@
 // REQUIRES: nvptx-registered-target
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
 // expected-no-diagnostics
 
-// CHECK-DAG: call { float, float } @__divsc3(
-// CHECK-DAG: call { float, float } @__mulsc3(
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+// CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(float _Complex a) {
 #pragma omp target
   {
@@ -12,9 +24,7 @@ void test_scmplx(float _Complex a) {
   }
 }
 
-
-// CHECK-DAG: call { double, double } @__divdc3(
-// CHECK-DAG: call { double, double } @__muldc3(
+// CHECK-DAG: call double @__nv_scalbn(
 void test_dcmplx(double _Complex a) {
 #pragma omp target
   {

diff  --git a/clang/test/Headers/nvptx_device_math_complex.cpp b/clang/test/Headers/nvptx_device_math_complex.cpp
new file mode 100644
index 000000000000..15434d907605
--- /dev/null
+++ b/clang/test/Headers/nvptx_device_math_complex.cpp
@@ -0,0 +1,27 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -verify -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -aux-triple powerpc64le-unknown-unknown -o - | FileCheck %s
+// expected-no-diagnostics
+
+#include 
+
+// CHECK-DAG: define {{.*}} @__mulsc3
+// CHECK-DAG: define {{.*}} @__muldc3
+// CHECK-DAG: define {{.*}} @__divsc3
+// CHECK-DAG: define {{.*}} @__divdc3
+
+// CHECK-DAG: call float @__nv_scalbnf(
+void test_scmplx(std::complex a) {
+#pragma omp target
+  {
+    (void)(a * (a / a));
+  }
+}
+
+// CHECK-DAG: call double @__nv_scalbn(
+void test_dcmplx(std::complex a) {
+#pragma omp target
+  {
+    (void)(a * (a / a));
+  }
+}


        

From cfe-commits at lists.llvm.org  Wed Jul  8 15:36:20 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 22:36:20 +0000 (UTC)
Subject: [PATCH] D80897: [OpenMP] Initial support for std::complex in target
 regions
In-Reply-To: 
References: 
Message-ID: <6a7414072b9d768792f92181e7d93e09@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rGd999cbc98832: [OpenMP] Initial support for std::complex in target regions (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D80897?vs=276053&id=276584#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80897/new/

https://reviews.llvm.org/D80897

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/lib/Headers/openmp_wrappers/complex.h
  clang/test/Headers/Inputs/include/cmath
  clang/test/Headers/Inputs/include/complex
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_complex.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80897.276584.patch
Type: text/x-patch
Size: 30118 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 15:59:56 2020
From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 22:59:56 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <12dfabbd79a95114ac2836cd2a90f96f@localhost.localdomain>

cchen updated this revision to Diff 276589.
cchen added a comment.

Fix message and rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ExprOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/target_data_messages.c
  clang/test/OpenMP/target_depend_messages.cpp
  clang/test/OpenMP/target_enter_data_depend_messages.cpp
  clang/test/OpenMP/target_exit_data_depend_messages.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_depend_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_messages.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82800.276589.patch
Type: text/x-patch
Size: 43037 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 16:06:20 2020
From: cfe-commits at lists.llvm.org (Alexey Lapshin via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 23:06:20 +0000 (UTC)
Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls.
In-Reply-To: 
References: 
Message-ID: <06c1cb72cadb32a1027d5c38511dc651@localhost.localdomain>

avl updated this revision to Diff 276591.
avl added a comment.

addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82085/new/

https://reviews.llvm.org/D82085

Files:
  llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp
  llvm/test/Transforms/TailCallElim/basic.ll
  llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82085.276591.patch
Type: text/x-patch
Size: 13610 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 16:17:34 2020
From: cfe-commits at lists.llvm.org (Leonard Chan via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 23:17:34 +0000 (UTC)
Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with
 padding emit signed operations.
In-Reply-To: 
References: 
Message-ID: <53e705c573e997f4a4f6ae009da4e60e@localhost.localdomain>

leonardchan added a comment.

In D82663#2130355 , @ebevhan wrote:

> Well, it's not so much as adding the bit, but adding the information that the bit exists. That means either new intrinsics for all of the operations, or adding flags to the existing ones. That's a fair bit of added complexity. Also,  +  would do virtually the exact same thing as the new unsigned-with-padding operations, so the utility of adding all of it is a bit questionable.


Could the work involved just be adding the flags, then in `llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp` for unsigned operations, choosing between the signed/unsigned underlying `ISD` when lowering intrinsics to DAG? I think you could just pass the padding bit to `FixedPointIntrinsicToOpcode` and handle it from there. This is just off the top of my head so I could be missing other things.

I don't think this is necessarily the same as "legalizing" the intrinsic, but this would at least prevent frontends from second-guessing.



================
Comment at: clang/include/clang/Basic/FixedPoint.h:66
   /// given binary operation.
+  /// Is UnsignedPaddingIsSigned is true, unsigned semantics which would
+  /// otherwise have been unsigned will be signed instead. This is for codegen
----------------
Is -> If


================
Comment at: clang/lib/Basic/FixedPoint.cpp:143-158
+  // For codegen purposes, make unsigned with padding semantics signed instead.
+  // This means that we will generate signed operations. The result from these
+  // operations is defined, since ending up with a negative result is undefined
+  // for nonsaturating semantics, and for saturating semantics we will
+  // perform a clamp-to-zero in the last conversion to result semantics (since
+  // we are going from saturating signed to saturating unsigned).
+  //
----------------
If this is exclusively for codegen purposes with binary operations, would it be clearer to move this to `EmitFixedPointBinOp`? If `UnsignedPaddingIsSigned` doesn't need to be used for stuff like constant evaluation, it might be clearer not to provide it for everyone.


================
Comment at: clang/test/Frontend/fixed_point_add.c:290-294
+  // UNSIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i16 [[USA]] to i40
+  // UNSIGNED-NEXT: [[I_EXT:%[a-z0-9]+]] = zext i32 [[I]] to i40
+  // UNSIGNED-NEXT: [[I:%[a-z0-9]+]] = shl i40 [[I_EXT]], 7
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = add i40 [[USA_EXT]], [[I]]
+  // UNSIGNED-NEXT: [[RES:%[a-z0-9]+]] = trunc i40 [[SUM]] to i16
----------------
If this is a workaround for not being able to convey the padding bit to LLVM intrinsics, I think we should only limit changes to instances we would use intrinsics.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82663/new/

https://reviews.llvm.org/D82663




From cfe-commits at lists.llvm.org  Wed Jul  8 16:20:51 2020
From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 23:20:51 +0000 (UTC)
Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls.
In-Reply-To: 
References: 
Message-ID: 

efriedma added a comment.

I think I'd like to see a testcase where there are multiple recursive calls, but only one is a tail call that can be eliminated.



================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:474
+  // Operand Bundles or not marked as TailCall.
+  if (CI->isNoTailCall() || CI->hasOperandBundles() || !CI->isTailCall())
     return nullptr;
----------------
The hasOperandBundles() check looks completely new; is there some test for it?

The `isNoTailCall()` check is currently redundant; it isn't legal to write "tail notail".  I guess it makes sense to guard against that, though.


================
Comment at: llvm/test/Transforms/TailCallElim/basic.ll:23
+; CHECK: call i32 @test1
+	%X = call i32 @test1()		;  [#uses=1]
 	ret i32 %X
----------------
I'm not sure this is testing what it was originally supposed to.  I guess that's okay, but please fix the comment at least.


================
Comment at: llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll:20
+; Function Attrs: nofree noinline norecurse nounwind uwtable
+define dso_local void @_Z15globalIncrementPKi(i32* nocapture readonly %param) local_unnamed_addr #0 {
+entry:
----------------
For the purpose of this testcase, we don't need the definition of _Z15globalIncrementPKi.


================
Comment at: llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll:37
+; CHECK: br label %tailrecurse
+; CHECK-NOT: call void @_Z4testi
+; CHECK: ret
----------------
I think I'd prefer to just generate this with update_test_checks.py


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82085/new/

https://reviews.llvm.org/D82085




From cfe-commits at lists.llvm.org  Wed Jul  8 16:43:58 2020
From: cfe-commits at lists.llvm.org (Alexey Lapshin via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 23:43:58 +0000 (UTC)
Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls.
In-Reply-To: 
References: 
Message-ID: <2c11f1be9e559eec1ea6ec3efd956ef7@localhost.localdomain>

avl marked an inline comment as done.
avl added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:474
+  // Operand Bundles or not marked as TailCall.
+  if (CI->isNoTailCall() || CI->hasOperandBundles() || !CI->isTailCall())
     return nullptr;
----------------
efriedma wrote:
> The hasOperandBundles() check looks completely new; is there some test for it?
> 
> The `isNoTailCall()` check is currently redundant; it isn't legal to write "tail notail".  I guess it makes sense to guard against that, though.
>The hasOperandBundles() check looks completely new; is there some test for it?

it is not new. it is copied from 245 line. Now, when patch changed from its original state all above conditions could be changed just to :

if (!CI->isTailCall())

the test is Transforms/TailCallElim/deopt-bundle.ll

>The isNoTailCall() check is currently redundant; it isn't legal to write "tail notail". I guess it makes sense to guard against that, though.

would add checking for that.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82085/new/

https://reviews.llvm.org/D82085




From cfe-commits at lists.llvm.org  Wed Jul  8 16:57:55 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Wed, 08 Jul 2020 23:57:55 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: <0d9225676909b3c01682a8bb898942b2@localhost.localdomain>

sammccall added a comment.

In D83419#2140311 , @njames93 wrote:

> I'm not a huge fan of using `error`, maybe `createError`, 
>  Its definitely out of place in Logger, but there is no where else better for it to live short of a new file which seems overkill.


Yeah, the naming is definitely the hardest part to be sure of here.
It's an extremely commonly used function: 75 references to StringError + another 20 or so references to local helpers.
This puts it in the same class as log (95), vlog (50), elog(85).
It's also similar in that it is cross cutting and has the same format string + args shape (so wrapping affects it similarly).

> its used in many other parts of llvm, typically with static linkage.

Yeah, there's some precedent, though not overwhelming consensus. Outside clangd I count 10 `createError`s, 7 `make_string_error`s, 4 `error`s, 1 `makeError`, 1 `makeStringError`, and the canonical `makeStringError` and `make_error`.

But I think this is just a place where wider LLVM is making different tradeoffs:

- for good reasons:  many errors are diagnostics or don't need to be carefully routed back to a specific request
- for bad reasons: e.g. compliance with the "verb phrase" policy that's poorly observed and itself seems like a sad accident of history: http://lists.llvm.org/pipermail/llvm-dev/2018-May/thread.html#123547
- llvm::Error itself seems like a pretty strong argument that existing practice doesn't guarantee good ergonomics


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Wed Jul  8 18:14:39 2020
From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits)
Date: Wed, 08 Jul 2020 18:14:39 -0700 (PDT)
Subject: [clang] 00068c4 - Improve diagnostics for constant evaluation that
 fails because a
Message-ID: <5f066f7f.1c69fb81.a994e.292e@mx.google.com>


Author: Richard Smith
Date: 2020-07-08T18:14:23-07:00
New Revision: 00068c452a599c328986e8afcbb3311331d09d26

URL: https://github.com/llvm/llvm-project/commit/00068c452a599c328986e8afcbb3311331d09d26
DIFF: https://github.com/llvm/llvm-project/commit/00068c452a599c328986e8afcbb3311331d09d26.diff

LOG: Improve diagnostics for constant evaluation that fails because a
variable's initializer is not known.

The hope is that a better diagnostic for this case will reduce the rate
at which duplicates of non-bug PR41093 are reported.

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticASTKinds.td
    clang/lib/AST/ExprConstant.cpp
    clang/test/CXX/expr/expr.const/p2-0x.cpp
    clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
    clang/test/SemaCXX/constant-expression-cxx11.cpp
    clang/test/SemaCXX/constant-expression-cxx1y.cpp
    clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 905e3158cf40..10bedaaf7aba 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -101,8 +101,16 @@ def note_constexpr_null_subobject : Note<
   "access array element of|perform pointer arithmetic on|"
   "access real component of|"
   "access imaginary component of}0 null pointer">;
+def note_constexpr_function_param_value_unknown : Note<
+  "function parameter %0 with unknown value cannot be used in a constant "
+  "expression">;
+def note_constexpr_var_init_unknown : Note<
+  "initializer of %0 is unknown">;
 def note_constexpr_var_init_non_constant : Note<
   "initializer of %0 is not a constant expression">;
+def note_constexpr_var_init_weak : Note<
+  "initializer of weak variable %0 is not considered constant because "
+  "it may be 
diff erent at runtime">;
 def note_constexpr_typeid_polymorphic : Note<
   "typeid applied to expression of polymorphic type %0 is "
   "not allowed in a constant expression in C++ standards before C++20">;
@@ -159,6 +167,9 @@ def note_constexpr_access_mutable : Note<
   "mutable member %1 is not allowed in a constant expression">;
 def note_constexpr_ltor_non_const_int : Note<
   "read of non-const variable %0 is not allowed in a constant expression">;
+def note_constexpr_ltor_non_integral : Note<
+  "read of variable %0 of non-integral, non-enumeration type %1 "
+  "is not allowed in a constant expression">;
 def note_constexpr_ltor_non_constexpr : Note<
   "read of non-constexpr variable %0 is not allowed in a constant expression">;
 def note_constexpr_ltor_incomplete_type : Note<

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 9eba40c44ddc..d6dbfb14e60b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -3025,7 +3025,7 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     if (Info.checkingPotentialConstantExpression())
       return false;
     if (!Frame || !Frame->Arguments) {
-      Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+      Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << VD;
       return false;
     }
     Result = &Frame->Arguments[PVD->getFunctionScopeIndex()];
@@ -3056,12 +3056,34 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
   }
 
   // Dig out the initializer, and use the declaration which it's attached to.
+  // FIXME: We should eventually check whether the variable has a reachable
+  // initializing declaration.
   const Expr *Init = VD->getAnyInitializer(VD);
-  if (!Init || Init->isValueDependent()) {
-    // If we're checking a potential constant expression, the variable could be
-    // initialized later.
-    if (!Info.checkingPotentialConstantExpression())
-      Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+  if (!Init) {
+    // Don't diagnose during potential constant expression checking; an
+    // initializer might be added later.
+    if (!Info.checkingPotentialConstantExpression()) {
+      Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1)
+        << VD;
+      Info.Note(VD->getLocation(), diag::note_declared_at);
+    }
+    return false;
+  }
+
+  if (Init->isValueDependent()) {
+    // The DeclRefExpr is not value-dependent, but the variable it refers to
+    // has a value-dependent initializer. This should only happen in
+    // constant-folding cases, where the variable is not actually of a suitable
+    // type for use in a constant expression (otherwise the DeclRefExpr would
+    // have been value-dependent too), so diagnose that.
+    assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx));
+    if (!Info.checkingPotentialConstantExpression()) {
+      Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
+                         ? diag::note_constexpr_ltor_non_constexpr
+                         : diag::note_constexpr_ltor_non_integral, 1)
+          << VD << VD->getType();
+      Info.Note(VD->getLocation(), diag::note_declared_at);
+    }
     return false;
   }
 
@@ -3072,13 +3094,6 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     return true;
   }
 
-  // Never evaluate the initializer of a weak variable. We can't be sure that
-  // this is the definition which will be used.
-  if (VD->isWeak()) {
-    Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
-    return false;
-  }
-
   // Check that we can fold the initializer. In C++, we will have already done
   // this in the cases where it matters for conformance.
   SmallVector Notes;
@@ -3088,13 +3103,24 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     Info.Note(VD->getLocation(), diag::note_declared_at);
     Info.addNotes(Notes);
     return false;
-  } else if (!VD->checkInitIsICE()) {
+  }
+
+  // Check that the variable is actually usable in constant expressions.
+  if (!VD->checkInitIsICE()) {
     Info.CCEDiag(E, diag::note_constexpr_var_init_non_constant,
                  Notes.size() + 1) << VD;
     Info.Note(VD->getLocation(), diag::note_declared_at);
     Info.addNotes(Notes);
   }
 
+  // Never use the initializer of a weak variable, not even for constant
+  // folding. We can't be sure that this is the definition that will be used.
+  if (VD->isWeak()) {
+    Info.FFDiag(E, diag::note_constexpr_var_init_weak) << VD;
+    Info.Note(VD->getLocation(), diag::note_declared_at);
+    return false;
+  }
+
   Result = VD->getEvaluatedValue();
   return true;
 }
@@ -3797,6 +3823,11 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
       return CompleteObject();
     }
 
+    // In OpenCL if a variable is in constant address space it is a const value.
+    bool IsConstant = BaseType.isConstQualified() ||
+                      (Info.getLangOpts().OpenCL &&
+                       BaseType.getAddressSpace() == LangAS::opencl_constant);
+
     // Unless we're looking at a local variable or argument in a constexpr call,
     // the variable we're reading must be const.
     if (!Frame) {
@@ -3814,9 +3845,7 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
       } else if (BaseType->isIntegralOrEnumerationType()) {
         // In OpenCL if a variable is in constant address space it is a const
         // value.
-        if (!(BaseType.isConstQualified() ||
-              (Info.getLangOpts().OpenCL &&
-               BaseType.getAddressSpace() == LangAS::opencl_constant))) {
+        if (!IsConstant) {
           if (!IsAccess)
             return CompleteObject(LVal.getLValueBase(), nullptr, BaseType);
           if (Info.getLangOpts().CPlusPlus) {
@@ -3829,27 +3858,29 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
         }
       } else if (!IsAccess) {
         return CompleteObject(LVal.getLValueBase(), nullptr, BaseType);
-      } else if (BaseType->isFloatingType() && BaseType.isConstQualified()) {
-        // We support folding of const floating-point types, in order to make
-        // static const data members of such types (supported as an extension)
-        // more useful.
-        if (Info.getLangOpts().CPlusPlus11) {
-          Info.CCEDiag(E, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
+      } else if (IsConstant && Info.checkingPotentialConstantExpression() &&
+                 BaseType->isLiteralType(Info.Ctx) && !VD->hasDefinition()) {
+        // This variable might end up being constexpr. Don't diagnose it yet.
+      } else if (IsConstant) {
+        // Keep evaluating to see what we can do. In particular, we support
+        // folding of const floating-point types, in order to make static const
+        // data members of such types (supported as an extension) more useful.
+        if (Info.getLangOpts().CPlusPlus) {
+          Info.CCEDiag(E, Info.getLangOpts().CPlusPlus11
+                              ? diag::note_constexpr_ltor_non_constexpr
+                              : diag::note_constexpr_ltor_non_integral, 1)
+              << VD << BaseType;
           Info.Note(VD->getLocation(), diag::note_declared_at);
         } else {
           Info.CCEDiag(E);
         }
-      } else if (BaseType.isConstQualified() && VD->hasDefinition(Info.Ctx)) {
-        Info.CCEDiag(E, diag::note_constexpr_ltor_non_constexpr) << VD;
-        // Keep evaluating to see what we can do.
       } else {
-        // FIXME: Allow folding of values of any literal type in all languages.
-        if (Info.checkingPotentialConstantExpression() &&
-            VD->getType().isConstQualified() && !VD->hasDefinition(Info.Ctx)) {
-          // The definition of this variable could be constexpr. We can't
-          // access it right now, but may be able to in future.
-        } else if (Info.getLangOpts().CPlusPlus11) {
-          Info.FFDiag(E, diag::note_constexpr_ltor_non_constexpr, 1) << VD;
+        // Never allow reading a non-const value.
+        if (Info.getLangOpts().CPlusPlus) {
+          Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
+                             ? diag::note_constexpr_ltor_non_constexpr
+                             : diag::note_constexpr_ltor_non_integral, 1)
+              << VD << BaseType;
           Info.Note(VD->getLocation(), diag::note_declared_at);
         } else {
           Info.FFDiag(E);

diff  --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index c418767f8d12..b9235eeeb172 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -376,7 +376,7 @@ namespace References {
   int &d = c;
   constexpr int e = 42;
   int &f = const_cast(e);
-  extern int &g;
+  extern int &g; // expected-note {{here}}
   constexpr int &h(); // expected-note {{here}}
   int &i = h(); // expected-note {{here}}
   constexpr int &j() { return b; }
@@ -390,7 +390,7 @@ namespace References {
     int D2 : &d - &c + 1;
     int E : e / 2;
     int F : f - 11;
-    int G : g; // expected-error {{constant expression}}
+    int G : g; // expected-error {{constant expression}} expected-note {{initializer of 'g' is unknown}}
     int H : h(); // expected-error {{constant expression}} expected-note {{undefined function 'h'}}
     int I : i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}}
     int J : j();

diff  --git a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
index 6c0df1aff231..ecb82372bcb4 100644
--- a/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
+++ b/clang/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -std=c++98 -verify %s
+// RUN: %clang_cc1 -std=c++98 -verify=cxx98 %s
+// RUN: %clang_cc1 -std=c++11 -verify=cxx11 %s
+// cxx11-no-diagnostics
 
 template struct S;
 
@@ -13,9 +15,9 @@ template struct T {
     //  - a constant with literal type and is initialized with an expression
     //  that is value-dependent.
     const int k = n;
-    typename S::T check3; // ok, u is value-dependent
+    typename S::T check3; // ok, k is value-dependent
 
-    const int &i = k;
-    typename S::T check4; // expected-error {{not an integral constant expression}}
+    const int &i = k; // cxx98-note {{declared here}}
+    typename S::T check4; // cxx98-error {{not an integral constant expression}} cxx98-note {{read of variable 'i' of non-integral, non-enumeration type 'const int &'}}
   }
 };

diff  --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index dd6d7ccba19f..78e9fef96c8d 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -682,12 +682,12 @@ template struct S : T {
   }
 };
 
-extern const int n;
+extern const int n; // expected-note {{declared here}}
 template void f() {
   // This is ill-formed, because a hypothetical instantiation at the point of
   // template definition would be ill-formed due to a construct that does not
   // depend on a template parameter.
-  constexpr int k = n; // expected-error {{must be initialized by a constant expression}}
+  constexpr int k = n; // expected-error {{must be initialized by a constant expression}} expected-note {{initializer of 'n' is unknown}}
 }
 // It doesn't matter that the instantiation could later become valid:
 constexpr int n = 4;
@@ -1258,7 +1258,7 @@ constexpr int m1b = const_cast(n1); // expected-error {{constant exp
 constexpr int m2b = const_cast(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}}
 
 struct T { int n; };
-const T t = { 42 };
+const T t = { 42 }; // expected-note {{declared here}}
 
 constexpr int f(volatile int &&r) {
   return r; // expected-note {{read of volatile-qualified type 'volatile int'}}
@@ -1372,7 +1372,7 @@ namespace InstantiateCaseStmt {
 
 namespace ConvertedConstantExpr {
   extern int &m;
-  extern int &n;
+  extern int &n; // expected-note 2{{declared here}}
 
   constexpr int k = 4;
   int &m = const_cast(k);
@@ -1381,9 +1381,9 @@ namespace ConvertedConstantExpr {
   // useless note and instead just point to the non-constant subexpression.
   enum class E {
     em = m,
-    en = n, // expected-error {{not a constant expression}}
-    eo = (m +
-          n // expected-error {{not a constant expression}}
+    en = n, // expected-error {{not a constant expression}} expected-note {{initializer of 'n' is unknown}}
+    eo = (m + // expected-error {{not a constant expression}}
+          n // expected-note {{initializer of 'n' is unknown}}
           ),
     eq = reinterpret_cast((int*)0) // expected-error {{not a constant expression}} expected-note {{reinterpret_cast}}
   };
@@ -2302,3 +2302,23 @@ namespace PR41854 {
   f &d = reinterpret_cast(a);
   unsigned b = d.c;
 }
+
+namespace array_size {
+  template struct array {
+    static constexpr int size() { return N; }
+  };
+  template void f1(T t) {
+    constexpr int k = t.size();
+  }
+  template void f2(const T &t) {
+    constexpr int k = t.size(); // expected-error {{constant}} expected-note {{function parameter 't' with unknown value cannot be used in a constant expression}}
+  }
+  template void f3(const T &t) {
+    constexpr int k = T::size();
+  }
+  void g(array<3> a) {
+    f1(a);
+    f2(a); // expected-note {{instantiation of}}
+    f3(a);
+  }
+}

diff  --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
index 5a414799f755..8bc4f88a63a9 100644
--- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1009,7 +1009,7 @@ constexpr int sum(const char (&Arr)[N]) {
 // As an extension, we support evaluating some things that are `const` as though
 // they were `constexpr` when folding, but it should not be allowed in normal
 // constexpr evaluation.
-const char Cs[] = {'a', 'b'};
+const char Cs[] = {'a', 'b'}; // expected-note 2{{declared here}}
 void foo() __attribute__((enable_if(sum(Cs) == 'a' + 'b', "")));
 void run() { foo(); }
 

diff  --git a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index a16a5b54d8e0..fc49ec88d553 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -5,7 +5,7 @@
 #define CONST const
 
 #ifdef PRECXX11
-#define static_assert(expr, msg) typedef int static_assert[(expr) ? 1 : -1];
+#define static_assert _Static_assert
 #endif
 
 class A {
@@ -237,7 +237,7 @@ namespace in_class_template {
   namespace definition_after_outer_instantiation {
     template struct S {
       template static const int V1;
-      template static const int V2;
+      template static const int V2; // expected-note 3{{here}}
     };
     template struct S;
     template template const int S::V1 = 123;
@@ -250,11 +250,11 @@ namespace in_class_template {
     // is instantiated. This is kind of implied by [temp.class.spec.mfunc]/2,
     // and matches our behavior for member class templates, but it's not clear
     // that this is intentional. See PR17294 and core-24030.
-    static_assert(S::V2 == 456, ""); // FIXME expected-error {{}}
-    static_assert(S::V2 == 789, ""); // expected-error {{}}
+    static_assert(S::V2 == 456, ""); // FIXME expected-error {{}} expected-note {{initializer of 'V2' is unknown}}
+    static_assert(S::V2 == 789, ""); // expected-error {{}} expected-note {{initializer of 'V2' is unknown}}
 
     template template const int S::V2 = 789;
-    static_assert(S::V2 == 789, ""); // FIXME expected-error {{}}
+    static_assert(S::V2 == 789, ""); // FIXME expected-error {{}} expected-note {{initializer of 'V2' is unknown}}
 
     // All is OK if the partial specialization is declared before the implicit
     // instantiation of the class template specialization.


        

From cfe-commits at lists.llvm.org  Wed Jul  8 18:31:28 2020
From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 01:31:28 +0000 (UTC)
Subject: [PATCH] D82999: [CodeGen] Check the cleanup flag before destructing
 lifetime-extended temporaries created in conditional expressions
In-Reply-To: 
References: 
Message-ID: <78b3eb02c7f7e45bfe52b49fde403a38@localhost.localdomain>

ahatanak added a comment.

In D82999#2129855 , @rjmccall wrote:

> In D82999#2129417 , @ahatanak wrote:
>
> > In test case `test13` in clang/test/CodeGenCXX/exceptions.cpp, I think you can turn `invoke void @_ZN6test131AC1Ev` into `call void @_ZN6test131AC1Ev`, no? If the false expression throws, there is nothing to clean up in the false expression and also nothing in the true expression has to be cleaned up.
>
>
> Yes, this is true.  It would be possible to enhance Clang's cleanup stack to support this sort of thing — we'd want to be able to mark a cleanup as "currently known inactive" without potentially popping it off the cleanup stack, and then we could have conditional scopes remember the cleanups that were added, deactivate them this way, and then reactivate them after the merge.  Swift's cleanup manager supports something similar.


OK, I see. Since the enhancement isn't trivial to implement, I think we should do it in a separate patch if it has a large impact on code size. WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82999/new/

https://reviews.llvm.org/D82999




From cfe-commits at lists.llvm.org  Wed Jul  8 18:34:00 2020
From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 01:34:00 +0000 (UTC)
Subject: [PATCH] D78760: Check a class doesn't have a dependent type before
 iterating over its base classes
In-Reply-To: 
References: 
Message-ID: <78288d367d206d1bac3509185e3da8fa@localhost.localdomain>

ahatanak added a comment.

Does the updated patch look okay?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78760/new/

https://reviews.llvm.org/D78760




From cfe-commits at lists.llvm.org  Wed Jul  8 18:42:30 2020
From: cfe-commits at lists.llvm.org (John Regehr via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 01:42:30 +0000 (UTC)
Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and
 select ?, X, undef -> X
In-Reply-To: 
References: 
Message-ID: <15d8647afc7778fd0acb83f50de8b879@localhost.localdomain>

regehr added a comment.

> Did you mean to check something like the following?
> 
>   define i32 @src(i1 %cond, i32 %x) {
>     %x2 = freeze i32 %x
>     %s = select i1 %cond, i32 %x2, i32 undef
>     ret i32 %s
>   }
>   
>   define i32 @tgt(i1 %cond, i32 %x) {
>     %x2 = freeze i32 %x
>     ret i32 %x2
>   }

that's fine but I still don't understand why the counterexample to my version says %x2 in @src can be undef


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83360/new/

https://reviews.llvm.org/D83360




From cfe-commits at lists.llvm.org  Wed Jul  8 18:58:55 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 01:58:55 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: 

hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1263
 
-  // The maximum field alignment overrides base align.
+  assert(!IsUnion && "Unions cannot have base classes.");
+  // AIX `power` alignment does not apply the preferred alignment for non-union
----------------
It seems this is a leftover copy of the code that has been moved above?


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1809
+      Context.getTargetInfo().defaultsToAIXPowerAlignment();
+  bool FoundFirstNonOverlappingEmptyField = false;
+  if (DefaultsToAIXPowerAlignment)
----------------
The rename I suggested in my previous round of review was in coordination with maintaining the value not just for AIX. Since we're only maintaining the value for AIX, I prefer the previous name (or `FoundFirstNonOverlappingEmptyFieldForAIX`).


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1810
+  bool FoundFirstNonOverlappingEmptyField = false;
+  if (DefaultsToAIXPowerAlignment)
+    if (!HandledFirstNonOverlappingEmptyField) {
----------------
Please merge the `if` conditions to reduce nesting:
```
  if (DefaultsToAIXPowerAlignment && !HandledFirstNonOverlappingEmptyField) {
```


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1817
+      // We're going to handle the "first member" based on
+      // `FoundNonOverlappingEmptyFieldToHandle` during the current invocation
+      // of this function; record it as handled for future invocations.
----------------
Keep this reference to the variable up-to-date with its name.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1820
+      if (FoundFirstNonOverlappingEmptyField)
+        // For a union, the current field does not represent all "firsts".
+        HandledFirstNonOverlappingEmptyField = !IsUnion;
----------------
Change the condition of the `if` here to `!IsOverlappingEmptyField` and move the setting of `FoundFirstNonOverlappingEmptyField` to `true` into this `if`.

Move the previous comment and merge it with this one here:
> [ ... ] record it as handled for future invocations (except for unions, because the current field does not represent all "firsts").




================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1928
+      FoundFirstNonOverlappingEmptyField) {
+    auto upgradeAlignment = [&](const BuiltinType *BTy) {
+      if (BTy->getKind() == BuiltinType::Double ||
----------------
Sorry for not seeing this earlier (I only notice some things when I hide the inline comments). I think `performBuiltinTypeAlignmentUpgrade` would read better at the call site (and better capture the checking, which is based on the kind of built-in type, that is within the lambda).


================
Comment at: clang/test/Layout/aix-Wpacked.cpp:9
+
+// CHECK-NOT: warning: packed attribute is unnecessary for 'Q' [-Wpacked]
+// CHECK: warning: packed attribute is unnecessary for 'test2::C' [-Wpacked]
----------------
Clang diagnostics are normally checked using `-verify` (as opposed to `FileCheck`). To use it, I think this needs to be split into the "expecting no diagnostics" and the "expecting diagnostics" cases. As it is, I think the `CHECK-NOT` has a problem because it checks for plain `'Q'`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Wed Jul  8 19:30:56 2020
From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 02:30:56 +0000 (UTC)
Subject: [PATCH] D83448: [CodeGen] Emit destructor calls to destruct
 non-trivial C struct temporaries created by conditional and assignment
 operators
Message-ID: 

ahatanak created this revision.
ahatanak added a reviewer: rjmccall.
ahatanak added a project: clang.
Herald added subscribers: ributzka, dexonsmith, jkorous.

rdar://problem/64989559


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83448

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenObjC/strong-in-c-struct.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83448.276621.patch
Type: text/x-patch
Size: 3967 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 20:51:12 2020
From: cfe-commits at lists.llvm.org (Sameer Sahasrabuddhe via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 03:51:12 +0000 (UTC)
Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot
In-Reply-To: 
References: 
Message-ID: <42c5095ef03fcd35b0630ae71811a695@localhost.localdomain>

sameerds added a comment.

The documentation for HIP __ballot seems to indicate that the user does not have to explicitly specify the warp size. How is that achieved with these new builtins? Can this  be captured in a lit test here?

https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions



================
Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:288
+  if (!IsNullCPU) {
+    // Default to wave32 if available, or wave64 if not
+    if (Features.count("wavefrontsize32") == 0 &&
----------------
So the implication here is that wave32 is the preferred choice on newer architectures, and hence the default when available?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82087/new/

https://reviews.llvm.org/D82087




From cfe-commits at lists.llvm.org  Wed Jul  8 21:20:12 2020
From: cfe-commits at lists.llvm.org (Galina Kistanova via cfe-commits)
Date: Wed, 8 Jul 2020 21:20:12 -0700
Subject: Buildbot numbers for the week of 06/21/2020 - 06/27/2020
Message-ID: 

Hello everyone,

Below are some buildbot numbers for the week of 06/21/2020 - 06/27/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
                   buildername                    | was_red
--------------------------------------------------+---------
 publish-sphinx-docs                              | 68:49:52
 ppc64le-lld-multistage-test                      | 55:55:54
 clang-ppc64le-rhel                               | 55:18:23
 clang-tools-sphinx-docs                          | 51:02:34
 llvm-clang-win-x-armv7l                          | 45:10:32
 clang-cmake-aarch64-lld                          | 32:12:04
 llvm-clang-win-x-aarch64                         | 28:46:30
 fuchsia-x86_64-linux                             | 22:19:45
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 22:07:12
 clang-x86_64-debian-new-pass-manager-fast        | 22:00:02
 llvm-clang-x86_64-win-fast                       | 21:22:05
 clang-x64-windows-msvc                           | 21:13:41
 sanitizer-x86_64-linux-fast                      | 20:15:48
 sanitizer-x86_64-linux-bootstrap-ubsan           | 20:06:52
 llvm-clang-x86_64-expensive-checks-ubuntu        | 20:05:54
 llvm-clang-x86_64-expensive-checks-debian        | 20:05:54
 llvm-clang-x86_64-expensive-checks-win           | 19:41:41
 sanitizer-x86_64-linux-bootstrap                 | 19:38:41
 clang-cmake-aarch64-full                         | 15:48:36
 aosp-O3-polly-before-vectorizer-unprofitable     | 07:16:36
 lldb-x64-windows-ninja                           | 07:08:00
 libc-x86_64-debian-dbg                           | 07:04:21
 polly-x86_64-linux                               | 06:22:52
 polly-arm-linux                                  | 05:52:11
 lld-x86_64-darwin                                | 05:35:39
 libc-x86_64-debian                               | 05:24:19
 libc-x86_64-debian-dbg-asan                      | 05:22:59
 clang-cmake-aarch64-quick                        | 05:15:34
 sanitizer-x86_64-linux-fuzzer                    | 05:12:29
 clang-ppc64le-linux-multistage                   | 05:02:42
 llvm-avr-linux                                   | 04:41:41
 sanitizer-x86_64-linux-bootstrap-msan            | 04:41:11
 clang-cmake-aarch64-global-isel                  | 04:39:28
 clang-ppc64be-linux-lnt                          | 04:21:05
 sanitizer-x86_64-linux-autoconf                  | 04:13:49
 clang-s390x-linux-lnt                            | 03:53:46
 lldb-x86_64-debian                               | 03:50:00
 clang-ppc64le-linux-lnt                          | 03:40:27
 clang-x86_64-linux-abi-test                      | 03:36:43
 sanitizer-windows                                | 03:27:49
 clang-cmake-armv8-lld                            | 03:23:13
 clang-s390x-linux                                | 03:22:57
 sanitizer-x86_64-linux-android                   | 03:19:40
 clang-ppc64le-linux                              | 03:13:01
 sanitizer-x86_64-linux                           | 03:11:56
 clang-ppc64be-linux                              | 03:07:56
 clang-ppc64be-linux-multistage                   | 02:55:08
 sanitizer-ppc64be-linux                          | 02:38:30
 clang-cmake-x86_64-sde-avx512-linux              | 02:30:49
 clang-cmake-x86_64-avx2-linux                    | 02:29:16
 clang-with-thin-lto-ubuntu                       | 02:29:12
 clang-armv7-linux-build-cache                    | 02:27:44
 clang-s390x-linux-multistage                     | 02:26:52
 lldb-arm-ubuntu                                  | 02:20:06
 clang-cmake-armv7-global-isel                    | 02:02:04
 flang-aarch64-ubuntu                             | 01:53:50
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast       | 01:49:54
 openmp-clang-x86_64-linux-debian                 | 01:43:54
 lldb-aarch64-ubuntu                              | 01:36:00
 clang-cmake-armv7-quick                          | 01:35:20
 lld-perf-testsuite                               | 01:32:57
 lld-x86_64-win                                   | 01:23:29
 mlir-nvidia                                      | 01:09:01
 flang-aarch64-ubuntu-clang                       | 00:58:25
 lld-x86_64-ubuntu-fast                           | 00:56:28
 mlir-windows                                     | 00:53:19
 clang-x86_64-debian-fast                         | 00:48:25
(67 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
                       buildername                       | builds | changes
| status_change_ratio
---------------------------------------------------------+--------+---------+--------------------
 clang-cmake-aarch64-full                                |    109 |      42
|                38.5
 clang-ppc64be-linux-lnt                                 |    215 |      50
|                23.3
 clang-cmake-armv8-lld                                   |     94 |      18
|                19.1
 clang-ppc64le-linux-multistage                          |     32 |       6
|                18.8
 clang-x64-windows-msvc                                  |    117 |      19
|                16.2
 clang-ppc64be-linux-multistage                          |    127 |      20
|                15.7
 clang-cmake-aarch64-lld                                 |     82 |      12
|                14.6
 sanitizer-x86_64-linux                                  |    136 |      18
|                13.2
 lldb-aarch64-ubuntu                                     |    362 |      46
|                12.7
 clang-ppc64le-linux-lnt                                 |    109 |      13
|                11.9
 clang-ppc64le-rhel                                      |    238 |      27
|                11.3
 clang-cmake-armv7-global-isel                           |    227 |      22
|                 9.7
 flang-aarch64-ubuntu                                    |    211 |      20
|                 9.5
 aosp-O3-polly-before-vectorizer-unprofitable            |     55 |       5
|                 9.1
 lldb-x64-windows-ninja                                  |    156 |      14
|                 9.0
 sanitizer-x86_64-linux-fuzzer                           |    135 |      12
|                 8.9
 clang-ppc64be-linux                                     |    339 |      30
|                 8.8
 sanitizer-x86_64-linux-bootstrap                        |    113 |      10
|                 8.8
 clang-ppc64le-linux                                     |     94 |       8
|                 8.5
 clang-cmake-aarch64-quick                               |    145 |      12
|                 8.3
 sanitizer-x86_64-linux-bootstrap-ubsan                  |    147 |      12
|                 8.2
 sanitizer-x86_64-linux-bootstrap-msan                   |    151 |      12
|                 7.9
 llvm-clang-win-x-armv7l                                 |    103 |       8
|                 7.8
 clang-s390x-linux-multistage                            |     53 |       4
|                 7.5
 ppc64le-lld-multistage-test                             |    101 |       7
|                 6.9
 clang-cmake-aarch64-global-isel                         |    146 |      10
|                 6.8
 clang-s390x-linux-lnt                                   |    142 |       9
|                 6.3
 clang-cmake-x86_64-avx2-linux                           |     99 |       6
|                 6.1
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast        |    133 |       8
|                 6.0
 sanitizer-x86_64-linux-fast                             |    269 |      16
|                 5.9
 sanitizer-x86_64-linux-android                          |    295 |      16
|                 5.4
 clang-x86_64-debian-new-pass-manager-fast               |    407 |      22
|                 5.4
 clang-with-thin-lto-ubuntu                              |     77 |       4
|                 5.2
 clang-cmake-x86_64-sde-avx512-linux                     |    396 |      20
|                 5.1
 llvm-clang-x86_64-expensive-checks-win                  |    119 |       6
|                 5.0
 clang-cmake-armv7-quick                                 |    325 |      16
|                 4.9
 llvm-avr-linux                                          |    256 |      12
|                 4.7
 sanitizer-ppc64le-linux                                 |     22 |       1
|                 4.5
 fuchsia-x86_64-linux                                    |    382 |      16
|                 4.2
 clang-s390x-linux                                       |    178 |       7
|                 3.9
 llvm-clang-x86_64-expensive-checks-ubuntu               |    214 |       8
|                 3.7
 sanitizer-x86_64-linux-autoconf                         |    270 |      10
|                 3.7
 lldb-arm-ubuntu                                         |    275 |      10
|                 3.6
 llvm-clang-win-x-aarch64                                |    290 |      10
|                 3.4
 clang-x86_64-debian-fast                                |    428 |      14
|                 3.3
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast              |    430 |      14
|                 3.3
 polly-arm-linux                                         |     90 |       3
|                 3.3
 openmp-clang-x86_64-linux-debian                        |    395 |      12
|                 3.0
 lld-x86_64-darwin                                       |    207 |       6
|                 2.9
 mlir-nvidia                                             |    374 |      10
|                 2.7
 publish-sphinx-docs                                     |    219 |       6
|                 2.7
 sanitizer-ppc64be-linux                                 |     76 |       2
|                 2.6
 sanitizer-windows                                       |    391 |      10
|                 2.6
 libc-x86_64-debian-dbg                                  |    404 |      10
|                 2.5
 flang-aarch64-ubuntu-clang                              |     98 |       2
|                 2.0
 polly-x86_64-linux                                      |    161 |       3
|                 1.9
 lldb-x86_64-debian                                      |    448 |       8
|                 1.8
 llvm-clang-x86_64-expensive-checks-debian               |    327 |       6
|                 1.8
 lld-x86_64-win                                          |    121 |       2
|                 1.7
 lld-perf-testsuite                                      |    270 |       4
|                 1.5
 libc-x86_64-debian                                      |    417 |       6
|                 1.4
 lld-x86_64-ubuntu-fast                                  |    336 |       4
|                 1.2
 mlir-windows                                            |    363 |       4
|                 1.1
 libc-x86_64-debian-dbg-asan                             |    417 |       4
|                 1.0
 clang-x86_64-linux-abi-test                             |    437 |       4
|                 0.9
 clang-armv7-linux-build-cache                           |    351 |       2
|                 0.6
 llvm-clang-x86_64-win-fast                              |    407 |       2
|                 0.5
 clang-tools-sphinx-docs                                 |    418 |       1
|                 0.2
 clang-x64-ninja-win7                                    |     58 |       0
|                 0.0
 clang-with-lto-ubuntu                                   |     42 |       0
|                 0.0
 clang-sphinx-docs                                       |    402 |       0
|                 0.0
 llvm-sphinx-docs                                        |    326 |       0
|                 0.0
 openmp-gcc-x86_64-linux-debian                          |    333 |       0
|                 0.0
 clang-native-arm-lnt-perf                               |     33 |       0
|                 0.0
 reverse-iteration                                       |     90 |       0
|                 0.0
 clang-hexagon-elf                                       |     79 |       0
|                 0.0
 clang-cmake-x86_64-avx2-linux-perf                      |    157 |       0
|                 0.0
 clang-cmake-thumbv7-full-sh                             |     86 |       0
|                 0.0
 clang-cmake-armv7-selfhost-neon                         |    399 |       0
|                 0.0
 clang-cmake-armv7-selfhost                              |    403 |       0
|                 0.0
 clang-cmake-armv7-lnt                                   |    185 |       0
|                 0.0
 clang-cmake-armv7-full                                  |    122 |       0
|                 0.0
 lld-sphinx-docs                                         |    336 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-aarch64-linux                |      8 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   |      8 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-armv7-linux                  |      4 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions     |      4 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-armv8-linux                  |      8 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions     |      8 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-x86_64-linux-debian          |     13 |       0
|                 0.0
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu          |     14 |       0
|                 0.0
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian     |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-debian                    |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions       |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit              |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan               |     15 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03              |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11              |     11 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14              |     12 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17              |     11 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a              |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11         |     12 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan               |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan               |     13 |       0
|                 0.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan              |     14 |       0
|                 0.0
 libcxx-sphinx-docs                                      |    338 |       0
|                 0.0
 libunwind-sphinx-docs                                   |    327 |       0
|                 0.0
 lldb-sphinx-docs                                        |    442 |       0
|                 0.0
 lld-x86_64-freebsd                                      |    105 |       0
|                 0.0
(110 rows)


Number of commits by project:
      project      | number_of_commits
-------------------+------------------
 llvm              |               422
 cfe               |               179
 lldb              |                52
 mlir              |                48
 flang             |                17
 compiler-rt       |                16
 clang-tools-extra |                15
 lld               |                14
 libcxx            |                10
 libc              |                10
 libcxxabi         |                 4
 openmp            |                 3
 libunwind         |                 1
 polly             |                 1
-------------------+-------------------
                                   792


Number of completed builds, failed builds and average build time for
successful builds per active builder:
                          name                           | all_builds |
red_builds | average_build_time
---------------------------------------------------------+------------+------------+-------------------
 aosp-O3-polly-before-vectorizer-unprofitable            |         55 |
     6 | 03:13:18
 clang-aarch64-linux-build-cache                         |        300 |
       |
 clang-armv7-linux-build-cache                           |        351 |
     6 | 00:14:53
 clang-cmake-aarch64-full                                |        109 |
    82 | 01:23:22
 clang-cmake-aarch64-global-isel                         |        146 |
    10 | 00:55:43
 clang-cmake-aarch64-lld                                 |         82 |
    76 | 01:43:29
 clang-cmake-aarch64-quick                               |        145 |
    12 | 00:57:23
 clang-cmake-armv7-full                                  |        122 |
   122 |
 clang-cmake-armv7-global-isel                           |        227 |
    14 | 00:31:55
 clang-cmake-armv7-lnt                                   |        185 |
       | 00:41:19
 clang-cmake-armv7-quick                                 |        325 |
    16 | 00:15:24
 clang-cmake-armv7-selfhost                              |        403 |
   403 |
 clang-cmake-armv7-selfhost-neon                         |        399 |
   399 |
 clang-cmake-armv8-lld                                   |         94 |
    10 | 01:35:59
 clang-cmake-thumbv7-full-sh                             |         86 |
    86 |
 clang-cmake-x86_64-avx2-linux                           |         99 |
     6 | 00:05:48
 clang-cmake-x86_64-avx2-linux-perf                      |        157 |
   157 |
 clang-cmake-x86_64-sde-avx512-linux                     |        396 |
    21 | 00:07:10
 clang-hexagon-elf                                       |         79 |
    79 |
 clang-native-arm-lnt-perf                               |         33 |
       | 04:37:21
 clang-ppc64be-linux                                     |        339 |
    45 | 00:13:53
 clang-ppc64be-linux-lnt                                 |        215 |
    42 | 00:31:56
 clang-ppc64be-linux-multistage                          |        127 |
    17 | 01:05:04
 clang-ppc64le-linux                                     |         94 |
     6 | 01:34:30
 clang-ppc64le-linux-lnt                                 |        109 |
    12 | 01:27:30
 clang-ppc64le-linux-multistage                          |         32 |
     3 | 05:18:17
 clang-ppc64le-rhel                                      |        238 |
    19 | 00:20:48
 clang-s390x-linux                                       |        178 |
   101 | 00:40:58
 clang-s390x-linux-lnt                                   |        142 |
    83 | 00:55:32
 clang-s390x-linux-multistage                            |         53 |
    27 | 03:04:01
 clang-sphinx-docs                                       |        402 |
   402 |
 clang-tools-sphinx-docs                                 |        418 |
    53 | 00:00:41
 clang-with-lto-ubuntu                                   |         42 |
       | 04:03:32
 clang-with-thin-lto-ubuntu                              |         77 |
     2 | 02:11:10
 clang-x64-ninja-win7                                    |         60 |
    58 |
 clang-x64-windows-msvc                                  |        117 |
    56 | 02:10:37
 clang-x86_64-debian-fast                                |        428 |
    13 | 00:03:45
 clang-x86_64-debian-new-pass-manager-fast               |        407 |
    71 | 00:03:37
 clang-x86_64-linux-abi-test                             |        437 |
     4 | 00:16:34
 flang-aarch64-ubuntu                                    |        211 |
    18 | 00:37:49
 flang-aarch64-ubuntu-clang                              |         98 |
     1 | 00:56:09
 fuchsia-x86_64-linux                                    |        382 |
    66 | 00:26:26
 libc-x86_64-debian                                      |        417 |
    23 | 00:02:05
 libc-x86_64-debian-dbg                                  |        404 |
    25 | 00:02:48
 libc-x86_64-debian-dbg-asan                             |        417 |
    22 | 00:03:33
 libcxx-libcxxabi-libunwind-aarch64-linux                |          8 |
       | 03:00:28
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   |          8 |
       | 02:49:09
 libcxx-libcxxabi-libunwind-armv7-linux                  |          4 |
       | 01:03:59
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions     |          4 |
       | 01:01:12
 libcxx-libcxxabi-libunwind-armv8-linux                  |          8 |
       | 02:51:16
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions     |          8 |
       | 02:48:44
 libcxx-libcxxabi-libunwind-x86_64-linux-debian          |         13 |
       | 00:04:11
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu          |         14 |
       | 00:08:07
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian     |         13 |
       | 00:03:16
 libcxx-libcxxabi-x86_64-linux-debian                    |         13 |
       | 00:04:11
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions       |         13 |
       | 00:03:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit              |         13 |
       | 00:08:23
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan               |         15 |
       | 00:16:04
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03              |         13 |
       | 00:08:26
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11              |         11 |
       | 00:08:45
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14              |         12 |
       | 00:08:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17              |         11 |
       | 00:10:22
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a              |         13 |
       | 00:09:58
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11         |         12 |
       | 00:07:01
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std |         13 |
       | 00:08:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan               |         13 |
       | 00:19:06
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan               |         13 |
       | 00:15:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan              |         14 |
       | 00:16:51
 libcxx-sphinx-docs                                      |        338 |
       | 00:00:30
 libunwind-sphinx-docs                                   |        327 |
       | 00:00:32
 lldb-aarch64-ubuntu                                     |        362 |
    24 | 00:14:44
 lldb-arm-ubuntu                                         |        280 |
   223 | 00:17:19
 lldb-sphinx-docs                                        |        442 |
       | 00:00:42
 lldb-x64-windows-ninja                                  |        157 |
    16 | 00:58:25
 lldb-x86_64-debian                                      |        448 |
     6 | 00:02:08
 lld-perf-testsuite                                      |        270 |
     2 | 00:18:16
 lld-sphinx-docs                                         |        336 |
   336 |
 lld-x86_64-darwin                                       |        207 |
    12 | 00:33:39
 lld-x86_64-freebsd                                      |        105 |
   105 |
 lld-x86_64-ubuntu-fast                                  |        336 |
     4 | 00:06:53
 lld-x86_64-win                                          |        121 |
     1 | 00:08:28
 llvm-avr-linux                                          |        256 |
    19 | 00:26:14
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast              |        430 |
    17 | 00:03:03
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast        |        133 |
    22 | 00:13:08
 llvm-clang-win-x-aarch64                                |        290 |
    93 | 00:24:52
 llvm-clang-win-x-armv7l                                 |        103 |
    41 | 01:38:37
 llvm-clang-x86_64-expensive-checks-debian               |        327 |
    16 | 00:02:34
 llvm-clang-x86_64-expensive-checks-ubuntu               |        214 |
    16 | 00:18:02
 llvm-clang-x86_64-expensive-checks-win                  |        119 |
    12 | 00:50:45
 llvm-clang-x86_64-win-fast                              |        407 |
    63 | 00:10:56
 llvm-sphinx-docs                                        |        326 |
   326 |
 mlir-nvidia                                             |        374 |
    12 | 00:17:19
 mlir-windows                                            |        363 |
     5 | 00:20:01
 openmp-clang-x86_64-linux-debian                        |        395 |
     6 | 00:02:21
 openmp-gcc-x86_64-linux-debian                          |        333 |
   333 |
 polly-arm-linux                                         |         90 |
     7 | 00:28:01
 polly-x86_64-linux                                      |        161 |
    11 | 00:45:42
 ppc64le-lld-multistage-test                             |        101 |
     6 | 01:05:06
 publish-sphinx-docs                                     |        219 |
     4 | 00:06:16
 reverse-iteration                                       |         90 |
    90 |
 sanitizer-ppc64be-linux                                 |         76 |
     2 | 02:10:15
 sanitizer-ppc64le-linux                                 |         22 |
     1 | 04:38:59
 sanitizer-windows                                       |        391 |
    17 | 00:10:02
 sanitizer-x86_64-linux                                  |        136 |
    13 | 01:05:59
 sanitizer-x86_64-linux-android                          |        295 |
    10 | 00:21:06
 sanitizer-x86_64-linux-autoconf                         |        270 |
     8 | 00:23:44
 sanitizer-x86_64-linux-bootstrap                        |        113 |
    32 | 01:18:55
 sanitizer-x86_64-linux-bootstrap-msan                   |        151 |
    10 | 00:59:46
 sanitizer-x86_64-linux-bootstrap-ubsan                  |        147 |
    21 | 00:56:48
 sanitizer-x86_64-linux-fast                             |        269 |
    78 | 00:24:28
 sanitizer-x86_64-linux-fuzzer                           |        135 |
     9 | 01:07:18
(111 rows)


Average waiting time for a revision to get build result per active builder
(response time):
                      builder_name                       |
average_wait_time
---------------------------------------------------------+------------------
 lld-sphinx-docs                                         | 00:01:01
 lldb-sphinx-docs                                        | 00:01:07
 libcxx-sphinx-docs                                      | 00:01:24
 llvm-sphinx-docs                                        | 00:01:26
 clang-tools-sphinx-docs                                 | 00:02:07
 lldb-x86_64-debian                                      | 00:02:26
 libunwind-sphinx-docs                                   | 00:02:46
 clang-sphinx-docs                                       | 00:02:50
 libc-x86_64-debian                                      | 00:03:05
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast              | 00:03:41
 openmp-clang-x86_64-linux-debian                        | 00:04:23
 llvm-clang-x86_64-expensive-checks-debian               | 00:04:24
 libcxx-libcxxabi-libunwind-x86_64-linux-debian          | 00:05:04
 libc-x86_64-debian-dbg-asan                             | 00:05:05
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions       | 00:05:21
 libc-x86_64-debian-dbg                                  | 00:05:46
 clang-x86_64-debian-new-pass-manager-fast               | 00:06:18
 clang-x86_64-debian-fast                                | 00:07:49
 openmp-gcc-x86_64-linux-debian                          | 00:07:50
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian     | 00:08:07
 clang-cmake-x86_64-sde-avx512-linux                     | 00:08:20
 libcxx-libcxxabi-x86_64-linux-debian                    | 00:09:56
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 00:11:08
 publish-sphinx-docs                                     | 00:11:43
 sanitizer-windows                                       | 00:12:47
 clang-cmake-armv7-selfhost                              | 00:13:16
 clang-cmake-armv7-selfhost-neon                         | 00:15:35
 llvm-clang-x86_64-win-fast                              | 00:17:39
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03              | 00:18:29
 clang-armv7-linux-build-cache                           | 00:19:21
 lldb-aarch64-ubuntu                                     | 00:20:19
 lld-perf-testsuite                                      | 00:24:38
 clang-aarch64-linux-build-cache                         | 00:26:09
 clang-ppc64be-linux                                     | 00:28:08
 fuchsia-x86_64-linux                                    | 00:29:21
 llvm-clang-x86_64-expensive-checks-ubuntu               | 00:29:32
 clang-ppc64le-rhel                                      | 00:29:55
 sanitizer-x86_64-linux-android                          | 00:30:15
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan               | 00:30:42
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan              | 00:31:19
 clang-cmake-armv7-quick                                 | 00:33:09
 llvm-clang-win-x-aarch64                                | 00:33:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan               | 00:36:48
 sanitizer-x86_64-linux-fast                             | 00:37:25
 sanitizer-x86_64-linux-autoconf                         | 00:37:38
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu          | 00:38:41
 lld-x86_64-ubuntu-fast                                  | 00:38:41
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit              | 00:43:23
 llvm-avr-linux                                          | 00:43:48
 lld-x86_64-win                                          | 00:44:10
 lld-x86_64-freebsd                                      | 00:44:13
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11         | 00:44:20
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan               | 00:45:00
 lld-x86_64-darwin                                       | 00:47:36
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast        | 00:49:26
 clang-cmake-x86_64-avx2-linux                           | 00:52:33
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14              | 00:53:07
 flang-aarch64-ubuntu                                    | 00:53:29
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17              | 00:54:02
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a              | 00:54:09
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11              | 00:57:33
 clang-ppc64be-linux-lnt                                 | 00:57:34
 clang-cmake-armv7-global-isel                           | 00:57:41
 clang-cmake-armv7-lnt                                   | 01:16:01
 clang-cmake-x86_64-avx2-linux-perf                      | 01:17:37
 polly-arm-linux                                         | 01:18:40
 lldb-x64-windows-ninja                                  | 01:25:09
 llvm-clang-x86_64-expensive-checks-win                  | 01:26:53
 clang-s390x-linux                                       | 01:27:57
 sanitizer-x86_64-linux-bootstrap-msan                   | 01:28:26
 clang-hexagon-elf                                       | 01:31:01
 clang-x86_64-linux-abi-test                             | 01:32:00
 reverse-iteration                                       | 01:40:16
 clang-cmake-aarch64-quick                               | 01:41:55
 sanitizer-x86_64-linux                                  | 01:41:57
 ppc64le-lld-multistage-test                             | 01:41:57
 sanitizer-x86_64-linux-bootstrap-ubsan                  | 01:43:49
 clang-cmake-aarch64-global-isel                         | 01:47:28
 sanitizer-x86_64-linux-fuzzer                           | 01:47:28
 clang-s390x-linux-lnt                                   | 01:51:57
 flang-aarch64-ubuntu-clang                              | 01:59:05
 clang-ppc64be-linux-multistage                          | 02:01:39
 mlir-windows                                            | 02:06:12
 polly-x86_64-linux                                      | 02:10:03
 mlir-nvidia                                             | 02:10:32
 sanitizer-x86_64-linux-bootstrap                        | 02:18:27
 clang-cmake-aarch64-full                                | 02:19:13
 clang-ppc64le-linux-lnt                                 | 02:20:22
 llvm-clang-win-x-armv7l                                 | 02:23:27
 clang-x64-windows-msvc                                  | 02:40:37
 lldb-arm-ubuntu                                         | 02:46:16
 clang-cmake-armv8-lld                                   | 02:46:36
 clang-ppc64le-linux                                     | 03:09:56
 clang-with-thin-lto-ubuntu                              | 03:14:35
 clang-cmake-aarch64-lld                                 | 03:15:53
 sanitizer-ppc64be-linux                                 | 03:36:24
 aosp-O3-polly-before-vectorizer-unprofitable            | 04:34:03
 libcxx-libcxxabi-libunwind-armv8-linux                  | 04:51:10
 libcxx-libcxxabi-libunwind-aarch64-linux                | 04:56:30
 clang-s390x-linux-multistage                            | 05:17:00
 clang-x64-ninja-win7                                    | 05:53:36
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions     | 05:54:53
 clang-cmake-armv7-full                                  | 06:03:52
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 06:20:30
 sanitizer-ppc64le-linux                                 | 07:01:19
 clang-with-lto-ubuntu                                   | 07:09:51
 clang-ppc64le-linux-multistage                          | 08:11:01
 clang-native-arm-lnt-perf                               | 08:16:33
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions     | 08:24:03
 libcxx-libcxxabi-libunwind-armv7-linux                  | 09:28:02
 clang-cmake-thumbv7-full-sh                             | 09:28:45
(111 rows)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: change_ratio.csv
Type: application/vnd.ms-excel
Size: 4409 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: completed_failed_avr_time.csv
Type: application/vnd.ms-excel
Size: 4887 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: count_commits_by_prj.csv
Type: application/vnd.ms-excel
Size: 170 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: response_time.csv
Type: application/vnd.ms-excel
Size: 4324 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: time_was_red.csv
Type: application/vnd.ms-excel
Size: 2389 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 21:20:17 2020
From: cfe-commits at lists.llvm.org (Galina Kistanova via cfe-commits)
Date: Wed, 8 Jul 2020 21:20:17 -0700
Subject: Buildbot numbers for the week of 06/28/2020 - 07/04/2020
Message-ID: 

Hello everyone,

Below are some buildbot numbers for the last week of 06/28/2020 -
07/04/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from green to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
                   buildername                    | was_red
--------------------------------------------------+---------
 clang-s390x-linux-multistage                     | 81:56:32
 clang-s390x-linux                                | 80:24:20
 clang-s390x-linux-lnt                            | 80:20:51
 llvm-clang-win-x-aarch64                         | 69:41:19
 clang-cmake-aarch64-lld                          | 60:26:11
 llvm-sphinx-docs                                 | 56:14:14
 openmp-gcc-x86_64-linux-debian                   | 50:07:25
 lldb-arm-ubuntu                                  | 49:51:53
 fuchsia-x86_64-linux                             | 32:37:12
 clang-x86_64-debian-new-pass-manager-fast        | 32:32:17
 sanitizer-x86_64-linux-bootstrap                 | 27:16:04
 sanitizer-x86_64-linux-fast                      | 25:36:45
 lldb-x64-windows-ninja                           | 23:03:03
 clang-cmake-aarch64-full                         | 22:50:43
 sanitizer-x86_64-linux-android                   | 19:28:03
 polly-arm-linux                                  | 18:18:56
 aosp-O3-polly-before-vectorizer-unprofitable     | 16:57:06
 clang-ppc64le-linux-multistage                   | 15:05:33
 sanitizer-x86_64-linux                           | 11:40:01
 clang-with-lto-ubuntu                            | 08:54:10
 clang-cmake-armv8-lld                            | 07:51:15
 clang-with-thin-lto-ubuntu                       | 07:40:48
 llvm-clang-win-x-armv7l                          | 06:33:40
 clang-cmake-armv7-global-isel                    | 06:20:07
 clang-ppc64be-linux-multistage                   | 06:10:47
 clang-cmake-aarch64-global-isel                  | 06:09:00
 clang-cmake-armv7-quick                          | 06:07:43
 llvm-avr-linux                                   | 06:07:15
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 06:02:56
 clang-x64-windows-msvc                           | 06:02:15
 clang-ppc64be-linux                              | 06:02:06
 clang-cmake-x86_64-sde-avx512-linux              | 05:59:56
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast       | 05:59:54
 clang-ppc64le-rhel                               | 05:58:46
 lld-x86_64-win                                   | 05:55:14
 flang-aarch64-ubuntu-clang                       | 05:52:53
 clang-ppc64be-linux-lnt                          | 05:49:22
 ppc64le-lld-multistage-test                      | 05:45:38
 flang-aarch64-ubuntu                             | 05:43:05
 clang-cmake-aarch64-quick                        | 05:24:04
 sanitizer-x86_64-linux-bootstrap-msan            | 05:18:10
 polly-x86_64-linux                               | 05:11:52
 sanitizer-x86_64-linux-bootstrap-ubsan           | 04:41:18
 lld-x86_64-darwin                                | 04:36:23
 lld-x86_64-ubuntu-fast                           | 04:10:41
 clang-ppc64le-linux-lnt                          | 04:08:42
 sanitizer-ppc64be-linux                          | 03:54:01
 clang-cmake-x86_64-avx2-linux                    | 03:49:53
 mlir-nvidia                                      | 03:28:53
 clang-x86_64-debian-fast                         | 03:01:37
 mlir-windows                                     | 02:59:58
 clang-armv7-linux-build-cache                    | 02:46:28
 llvm-clang-x86_64-expensive-checks-ubuntu        | 02:37:36
 sanitizer-x86_64-linux-fuzzer                    | 02:10:42
 llvm-clang-x86_64-expensive-checks-win           | 01:37:53
 clang-ppc64le-linux                              | 01:30:19
 sanitizer-x86_64-linux-autoconf                  | 01:09:18
 publish-sphinx-docs                              | 01:07:47
 clang-cmake-armv7-lnt                            | 00:58:40
 clang-x86_64-linux-abi-test                      | 00:49:06
 libc-x86_64-debian-dbg                           | 00:40:25
 sanitizer-windows                                | 00:35:07
 llvm-clang-x86_64-expensive-checks-debian        | 00:33:48
 lldb-aarch64-ubuntu                              | 00:32:34
 llvm-clang-x86_64-win-fast                       | 00:23:43
 openmp-clang-x86_64-linux-debian                 | 00:19:03
 lldb-x86_64-debian                               | 00:15:16
(67 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
                       buildername                       | builds | changes
| status_change_ratio
---------------------------------------------------------+--------+---------+--------------------
 clang-cmake-aarch64-full                                |    102 |      38
|                37.3
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions     |      4 |       1
|                25.0
 libcxx-libcxxabi-libunwind-armv7-linux                  |      4 |       1
|                25.0
 sanitizer-x86_64-linux                                  |    115 |      25
|                21.7
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   |      5 |       1
|                20.0
 clang-x64-windows-msvc                                  |     86 |      17
|                19.8
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions     |      6 |       1
|                16.7
 clang-ppc64be-linux-lnt                                 |    181 |      28
|                15.5
 sanitizer-ppc64be-linux                                 |     52 |       8
|                15.4
 clang-cmake-armv8-lld                                   |     92 |      14
|                15.2
 libcxx-libcxxabi-libunwind-armv8-linux                  |      7 |       1
|                14.3
 clang-ppc64be-linux-multistage                          |    108 |      14
|                13.0
 clang-ppc64le-linux-multistage                          |     31 |       4
|                12.9
 clang-ppc64le-linux-lnt                                 |     70 |       9
|                12.9
 libcxx-libcxxabi-libunwind-aarch64-linux                |      8 |       1
|                12.5
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14              |      8 |       1
|                12.5
 llvm-clang-win-x-armv7l                                 |     89 |      11
|                12.4
 clang-ppc64le-linux                                     |     87 |      10
|                11.5
 clang-with-lto-ubuntu                                   |     54 |       6
|                11.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a              |      9 |       1
|                11.1
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast        |    115 |      12
|                10.4
 clang-ppc64be-linux                                     |    312 |      32
|                10.3
 clang-cmake-aarch64-quick                               |    138 |      14
|                10.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11              |     10 |       1
|                10.0
 clang-cmake-aarch64-global-isel                         |    140 |      14
|                10.0
 lldb-arm-ubuntu                                         |    333 |      31
|                 9.3
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11         |     11 |       1
|                 9.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit              |     11 |       1
|                 9.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17              |     11 |       1
|                 9.1
 clang-s390x-linux-multistage                            |     56 |       5
|                 8.9
 clang-cmake-aarch64-lld                                 |     76 |       6
|                 7.9
 sanitizer-x86_64-linux-bootstrap                        |    102 |       8
|                 7.8
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu          |     13 |       1
|                 7.7
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std |     13 |       1
|                 7.7
 sanitizer-x86_64-linux-fuzzer                           |    118 |       9
|                 7.6
 ppc64le-lld-multistage-test                             |    120 |       9
|                 7.5
 llvm-clang-x86_64-expensive-checks-win                  |     94 |       7
|                 7.4
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan               |     14 |       1
|                 7.1
 clang-ppc64le-rhel                                      |    267 |      19
|                 7.1
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan               |     14 |       1
|                 7.1
 libcxx-libcxxabi-x86_64-linux-debian                    |     14 |       1
|                 7.1
 llvm-avr-linux                                          |    227 |      16
|                 7.0
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan              |     15 |       1
|                 6.7
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan               |     15 |       1
|                 6.7
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions       |     15 |       1
|                 6.7
 libcxx-libcxxabi-libunwind-x86_64-linux-debian          |     15 |       1
|                 6.7
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian     |     15 |       1
|                 6.7
 lld-x86_64-win                                          |     94 |       6
|                 6.4
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03              |     16 |       1
|                 6.3
 llvm-clang-x86_64-expensive-checks-ubuntu               |    197 |      12
|                 6.1
 clang-s390x-linux-lnt                                   |    123 |       7
|                 5.7
 sanitizer-x86_64-linux-bootstrap-msan                   |    120 |       6
|                 5.0
 clang-cmake-armv7-global-isel                           |    209 |      10
|                 4.8
 lld-x86_64-ubuntu-fast                                  |    305 |      14
|                 4.6
 sanitizer-x86_64-linux-bootstrap-ubsan                  |    131 |       6
|                 4.6
 lldb-x64-windows-ninja                                  |    130 |       6
|                 4.6
 clang-s390x-linux                                       |    156 |       7
|                 4.5
 flang-aarch64-ubuntu-clang                              |    114 |       5
|                 4.4
 flang-aarch64-ubuntu                                    |    183 |       8
|                 4.4
 clang-cmake-x86_64-avx2-linux                           |     90 |       4
|                 4.4
 aosp-O3-polly-before-vectorizer-unprofitable            |     48 |       2
|                 4.2
 llvm-clang-win-x-aarch64                                |    238 |      10
|                 4.2
 sanitizer-x86_64-linux-fast                             |    236 |      10
|                 4.2
 clang-cmake-x86_64-sde-avx512-linux                     |    347 |      14
|                 4.0
 fuchsia-x86_64-linux                                    |    348 |      13
|                 3.7
 clang-x86_64-debian-fast                                |    385 |      14
|                 3.6
 llvm-clang-x86_64-expensive-checks-debian               |    295 |      10
|                 3.4
 lldb-aarch64-ubuntu                                     |    304 |      10
|                 3.3
 clang-cmake-armv7-quick                                 |    306 |      10
|                 3.3
 lld-x86_64-darwin                                       |    185 |       6
|                 3.2
 clang-x86_64-debian-new-pass-manager-fast               |    371 |      12
|                 3.2
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast              |    383 |      12
|                 3.1
 polly-arm-linux                                         |     78 |       2
|                 2.6
 sanitizer-x86_64-linux-autoconf                         |    229 |       6
|                 2.6
 clang-with-thin-lto-ubuntu                              |     83 |       2
|                 2.4
 mlir-nvidia                                             |    328 |       8
|                 2.4
 clang-cmake-armv7-lnt                                   |    177 |       4
|                 2.3
 openmp-gcc-x86_64-linux-debian                          |    308 |       7
|                 2.3
 mlir-windows                                            |    321 |       6
|                 1.9
 openmp-clang-x86_64-linux-debian                        |    350 |       6
|                 1.7
 clang-x86_64-linux-abi-test                             |    393 |       6
|                 1.5
 sanitizer-x86_64-linux-android                          |    269 |       4
|                 1.5
 polly-x86_64-linux                                      |    134 |       2
|                 1.5
 publish-sphinx-docs                                     |    416 |       6
|                 1.4
 clang-armv7-linux-build-cache                           |    306 |       4
|                 1.3
 llvm-clang-x86_64-win-fast                              |    354 |       4
|                 1.1
 llvm-sphinx-docs                                        |    292 |       2
|                 0.7
 libc-x86_64-debian-dbg                                  |    360 |       2
|                 0.6
 sanitizer-windows                                       |    351 |       2
|                 0.6
 lldb-x86_64-debian                                      |    391 |       2
|                 0.5
 clang-native-arm-lnt-perf                               |     34 |       0
|                 0.0
 clang-sphinx-docs                                       |    348 |       0
|                 0.0
 clang-tools-sphinx-docs                                 |    369 |       0
|                 0.0
 lld-sphinx-docs                                         |    304 |       0
|                 0.0
 lld-perf-testsuite                                      |    251 |       0
|                 0.0
 clang-cmake-thumbv7-full-sh                             |     83 |       0
|                 0.0
 reverse-iteration                                       |     79 |       0
|                 0.0
 clang-cmake-armv7-selfhost-neon                         |    368 |       0
|                 0.0
 libc-x86_64-debian                                      |    369 |       0
|                 0.0
 clang-cmake-armv7-selfhost                              |    372 |       0
|                 0.0
 clang-x64-ninja-win7                                    |     83 |       0
|                 0.0
 lldb-sphinx-docs                                        |    377 |       0
|                 0.0
 libunwind-sphinx-docs                                   |    294 |       0
|                 0.0
 libcxx-sphinx-docs                                      |    300 |       0
|                 0.0
 clang-cmake-armv7-full                                  |    101 |       0
|                 0.0
 libc-x86_64-debian-dbg-asan                             |    366 |       0
|                 0.0
 clang-hexagon-elf                                       |     74 |       0
|                 0.0
 clang-cmake-x86_64-avx2-linux-perf                      |    134 |       0
|                 0.0
(108 rows)


Number of commits by project:
      project      | number_of_commits
-------------------+------------------
 llvm              |               388
 cfe               |               106
 lldb              |                45
 mlir              |                40
 clang-tools-extra |                37
 flang             |                23
 lld               |                16
 libcxx            |                14
 compiler-rt       |                11
 libcxxabi         |                 5
 openmp            |                 5
 libunwind         |                 2
 polly             |                 2
 libc              |                 1
-------------------+-------------------
                                   695


Number of completed builds, failed builds and average build time for
successful builds per active builder:
                          name                           | all_builds |
red_builds | average_build_time
---------------------------------------------------------+------------+------------+-------------------
 aosp-O3-polly-before-vectorizer-unprofitable            |         48 |
    16 | 03:10:24
 clang-aarch64-linux-build-cache                         |        264 |
       |
 clang-armv7-linux-build-cache                           |        306 |
    10 | 00:14:36
 clang-cmake-aarch64-full                                |        102 |
    79 | 01:22:45
 clang-cmake-aarch64-global-isel                         |        140 |
    14 | 00:53:39
 clang-cmake-aarch64-lld                                 |         76 |
    73 | 02:16:05
 clang-cmake-aarch64-quick                               |        138 |
    12 | 00:55:24
 clang-cmake-armv7-full                                  |        101 |
   101 |
 clang-cmake-armv7-global-isel                           |        209 |
    16 | 00:31:22
 clang-cmake-armv7-lnt                                   |        177 |
     2 | 00:39:17
 clang-cmake-armv7-quick                                 |        306 |
    23 | 00:15:02
 clang-cmake-armv7-selfhost                              |        372 |
   372 |
 clang-cmake-armv7-selfhost-neon                         |        368 |
   368 |
 clang-cmake-armv8-lld                                   |         92 |
    11 | 01:31:56
 clang-cmake-thumbv7-full-sh                             |         83 |
    83 |
 clang-cmake-x86_64-avx2-linux                           |         90 |
     4 | 00:05:36
 clang-cmake-x86_64-avx2-linux-perf                      |        136 |
   134 |
 clang-cmake-x86_64-sde-avx512-linux                     |        347 |
    36 | 00:07:13
 clang-hexagon-elf                                       |         74 |
    74 |
 clang-native-arm-lnt-perf                               |         34 |
       | 04:23:15
 clang-ppc64be-linux                                     |        312 |
    58 | 00:14:00
 clang-ppc64be-linux-lnt                                 |        181 |
    35 | 00:31:50
 clang-ppc64be-linux-multistage                          |        108 |
    15 | 01:08:24
 clang-ppc64le-linux                                     |         87 |
     5 | 01:33:12
 clang-ppc64le-linux-lnt                                 |         70 |
     6 | 01:27:12
 clang-ppc64le-linux-multistage                          |         31 |
     5 | 04:58:26
 clang-ppc64le-rhel                                      |        267 |
    39 | 00:20:58
 clang-s390x-linux                                       |        156 |
    61 | 00:40:29
 clang-s390x-linux-lnt                                   |        123 |
    51 | 00:58:34
 clang-s390x-linux-multistage                            |         56 |
    29 | 03:04:43
 clang-sphinx-docs                                       |        348 |
   348 |
 clang-tools-sphinx-docs                                 |        369 |
       | 00:00:43
 clang-with-lto-ubuntu                                   |         54 |
    17 | 03:56:34
 clang-with-thin-lto-ubuntu                              |         83 |
    18 | 02:10:56
 clang-x64-ninja-win7                                    |         84 |
    83 |
 clang-x64-windows-msvc                                  |         86 |
    30 | 02:15:06
 clang-x86_64-debian-fast                                |        385 |
    20 | 00:03:35
 clang-x86_64-debian-new-pass-manager-fast               |        371 |
    81 | 00:03:37
 clang-x86_64-linux-abi-test                             |        393 |
     3 | 00:15:53
 flang-aarch64-ubuntu                                    |        183 |
    12 | 00:38:32
 flang-aarch64-ubuntu-clang                              |        114 |
     8 | 00:56:29
 fuchsia-x86_64-linux                                    |        348 |
    99 | 00:26:59
 libc-x86_64-debian                                      |        369 |
       | 00:01:45
 libc-x86_64-debian-dbg                                  |        360 |
     1 | 00:02:49
 libc-x86_64-debian-dbg-asan                             |        366 |
       | 00:03:08
 libcxx-libcxxabi-libunwind-aarch64-linux                |          8 |
     1 | 02:53:23
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   |          5 |
     1 | 02:54:17
 libcxx-libcxxabi-libunwind-armv7-linux                  |          4 |
     1 | 01:02:09
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions     |          4 |
     1 | 00:59:41
 libcxx-libcxxabi-libunwind-armv8-linux                  |          7 |
     1 | 02:48:33
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions     |          6 |
     1 | 02:49:53
 libcxx-libcxxabi-libunwind-x86_64-linux-debian          |         15 |
     1 | 00:04:02
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu          |         13 |
     1 | 00:07:49
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian     |         15 |
     1 | 00:03:11
 libcxx-libcxxabi-x86_64-linux-debian                    |         14 |
     1 | 00:04:08
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions       |         15 |
     1 | 00:03:12
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit              |         11 |
     1 | 00:08:28
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan               |         15 |
     1 | 00:14:25
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03              |         16 |
     2 | 00:08:06
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11              |         10 |
     1 | 00:08:47
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14              |          9 |
     1 | 00:09:04
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17              |         11 |
     1 | 00:10:16
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a              |          9 |
     1 | 00:10:23
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11         |         11 |
     4 | 00:08:08
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std |         13 |
     1 | 00:08:57
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan               |         14 |
     1 | 00:18:08
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan               |         14 |
     1 | 00:13:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan              |         15 |
     1 | 00:15:49
 libcxx-sphinx-docs                                      |        300 |
       | 00:00:31
 libunwind-sphinx-docs                                   |        294 |
       | 00:00:31
 lldb-aarch64-ubuntu                                     |        304 |
     5 | 00:15:48
 lldb-arm-ubuntu                                         |        334 |
   308 | 00:17:32
 lldb-sphinx-docs                                        |        377 |
       | 00:00:43
 lldb-x64-windows-ninja                                  |        130 |
    24 | 00:58:14
 lldb-x86_64-debian                                      |        391 |
     2 | 00:02:10
 lld-perf-testsuite                                      |        251 |
       | 00:17:52
 lld-sphinx-docs                                         |        304 |
   304 |
 lld-x86_64-darwin                                       |        185 |
     9 | 00:33:31
 lld-x86_64-ubuntu-fast                                  |        305 |
    16 | 00:06:50
 lld-x86_64-win                                          |         95 |
     7 | 00:08:51
 llvm-avr-linux                                          |        227 |
    28 | 00:27:15
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast              |        383 |
    36 | 00:03:13
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast        |        115 |
    12 | 00:13:28
 llvm-clang-win-x-aarch64                                |        238 |
   101 | 00:24:55
 llvm-clang-win-x-armv7l                                 |         89 |
    13 | 01:38:10
 llvm-clang-x86_64-expensive-checks-debian               |        295 |
     8 | 00:02:31
 llvm-clang-x86_64-expensive-checks-ubuntu               |        197 |
    13 | 00:18:01
 llvm-clang-x86_64-expensive-checks-win                  |         94 |
    13 | 00:50:54
 llvm-clang-x86_64-win-fast                              |        354 |
     2 | 00:11:05
 llvm-sphinx-docs                                        |        292 |
   223 | 00:01:07
 mlir-nvidia                                             |        328 |
    16 | 00:17:05
 mlir-windows                                            |        322 |
    20 | 00:19:54
 openmp-clang-x86_64-linux-debian                        |        350 |
     3 | 00:02:13
 openmp-gcc-x86_64-linux-debian                          |        308 |
    37 | 00:02:17
 polly-arm-linux                                         |         78 |
    25 | 00:27:13
 polly-x86_64-linux                                      |        134 |
    54 | 00:55:19
 ppc64le-lld-multistage-test                             |        120 |
    18 | 01:04:59
 publish-sphinx-docs                                     |        416 |
     3 | 00:04:40
 reverse-iteration                                       |         80 |
    79 |
 sanitizer-ppc64be-linux                                 |         52 |
     4 | 02:41:27
 sanitizer-windows                                       |        351 |
     1 | 00:09:30
 sanitizer-x86_64-linux                                  |        115 |
    21 | 01:08:19
 sanitizer-x86_64-linux-android                          |        269 |
    54 | 00:21:00
 sanitizer-x86_64-linux-autoconf                         |        229 |
     5 | 00:24:23
 sanitizer-x86_64-linux-bootstrap                        |        102 |
    23 | 01:20:38
 sanitizer-x86_64-linux-bootstrap-msan                   |        120 |
     7 | 01:04:11
 sanitizer-x86_64-linux-bootstrap-ubsan                  |        131 |
     7 | 00:58:50
 sanitizer-x86_64-linux-fast                             |        236 |
    54 | 00:26:00
 sanitizer-x86_64-linux-fuzzer                           |        118 |
     5 | 01:06:49
(109 rows)


Average waiting time for a revision to get build result per active builder
(response time):
                      builder_name                       |
average_wait_time
---------------------------------------------------------+------------------
 clang-cmake-armv7-selfhost                              | 00:02:15
 llvm-sphinx-docs                                        | 00:02:20
 lldb-x86_64-debian                                      | 00:02:30
 lldb-sphinx-docs                                        | 00:02:35
 libunwind-sphinx-docs                                   | 00:02:43
 lld-sphinx-docs                                         | 00:03:12
 libcxx-sphinx-docs                                      | 00:03:25
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast              | 00:03:58
 clang-tools-sphinx-docs                                 | 00:04:10
 libc-x86_64-debian                                      | 00:04:13
 llvm-clang-x86_64-expensive-checks-debian               | 00:04:22
 clang-sphinx-docs                                       | 00:04:55
 libcxx-libcxxabi-libunwind-x86_64-linux-debian          | 00:05:00
 publish-sphinx-docs                                     | 00:05:03
 libc-x86_64-debian-dbg-asan                             | 00:05:12
 clang-cmake-armv7-selfhost-neon                         | 00:05:19
 libc-x86_64-debian-dbg                                  | 00:05:21
 openmp-clang-x86_64-linux-debian                        | 00:05:37
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions       | 00:07:01
 clang-x86_64-debian-new-pass-manager-fast               | 00:07:10
 openmp-gcc-x86_64-linux-debian                          | 00:07:20
 clang-cmake-x86_64-sde-avx512-linux                     | 00:08:28
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian     | 00:09:13
 clang-x86_64-debian-fast                                | 00:09:15
 libcxx-libcxxabi-x86_64-linux-debian                    | 00:10:59
 sanitizer-windows                                       | 00:11:47
 llvm-clang-x86_64-win-fast                              | 00:17:16
 clang-armv7-linux-build-cache                           | 00:18:50
 clang-ppc64be-linux                                     | 00:20:01
 clang-cmake-armv7-quick                                 | 00:20:07
 lldb-arm-ubuntu                                         | 00:21:35
 lldb-aarch64-ubuntu                                     | 00:22:31
 lld-perf-testsuite                                      | 00:23:54
 clang-aarch64-linux-build-cache                         | 00:26:22
 sanitizer-x86_64-linux-android                          | 00:28:43
 fuchsia-x86_64-linux                                    | 00:28:58
 clang-ppc64le-rhel                                      | 00:29:08
 llvm-clang-x86_64-expensive-checks-ubuntu               | 00:30:08
 sanitizer-x86_64-linux-fast                             | 00:38:13
 lld-x86_64-ubuntu-fast                                  | 00:38:34
 sanitizer-x86_64-linux-autoconf                         | 00:39:29
 llvm-clang-win-x-aarch64                                | 00:39:51
 llvm-avr-linux                                          | 00:45:45
 clang-cmake-armv7-global-isel                           | 00:45:55
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 00:47:46
 lld-x86_64-darwin                                       | 00:48:36
 clang-cmake-x86_64-avx2-linux                           | 00:52:25
 flang-aarch64-ubuntu                                    | 00:56:37
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan              | 00:58:16
 clang-cmake-armv7-lnt                                   | 00:59:01
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan               | 01:00:33
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan               | 01:01:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03              | 01:03:00
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit              | 01:04:00
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast        | 01:05:32
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu          | 01:06:22
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan               | 01:07:21
 lld-x86_64-win                                          | 01:08:06
 mlir-nvidia                                             | 01:11:02
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11         | 01:12:43
 clang-ppc64be-linux-lnt                                 | 01:13:15
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a              | 01:15:47
 clang-x86_64-linux-abi-test                             | 01:17:10
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14              | 01:19:23
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11              | 01:20:00
 clang-cmake-x86_64-avx2-linux-perf                      | 01:20:17
 polly-arm-linux                                         | 01:20:27
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17              | 01:20:47
 clang-cmake-aarch64-global-isel                         | 01:23:30
 clang-cmake-aarch64-quick                               | 01:25:34
 flang-aarch64-ubuntu-clang                              | 01:27:08
 lldb-x64-windows-ninja                                  | 01:27:54
 sanitizer-x86_64-linux-bootstrap-ubsan                  | 01:29:23
 clang-s390x-linux                                       | 01:30:48
 mlir-windows                                            | 01:34:47
 clang-hexagon-elf                                       | 01:35:40
 sanitizer-x86_64-linux-bootstrap-msan                   | 01:40:18
 llvm-clang-x86_64-expensive-checks-win                  | 01:41:12
 reverse-iteration                                       | 01:41:33
 ppc64le-lld-multistage-test                             | 01:42:04
 sanitizer-x86_64-linux                                  | 01:47:51
 sanitizer-x86_64-linux-fuzzer                           | 01:52:22
 clang-s390x-linux-lnt                                   | 01:57:04
 sanitizer-x86_64-linux-bootstrap                        | 02:03:28
 clang-ppc64be-linux-multistage                          | 02:05:12
 clang-cmake-aarch64-full                                | 02:07:38
 polly-x86_64-linux                                      | 02:17:55
 clang-cmake-armv8-lld                                   | 02:28:18
 llvm-clang-win-x-armv7l                                 | 02:31:14
 clang-cmake-aarch64-lld                                 | 03:00:32
 clang-x64-windows-msvc                                  | 03:01:16
 clang-with-thin-lto-ubuntu                              | 03:05:25
 clang-ppc64le-linux                                     | 03:15:43
 clang-x64-ninja-win7                                    | 04:32:28
 clang-s390x-linux-multistage                            | 04:44:51
 aosp-O3-polly-before-vectorizer-unprofitable            | 04:49:14
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions     | 05:04:06
 clang-cmake-armv7-full                                  | 05:22:26
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 05:31:39
 sanitizer-ppc64be-linux                                 | 05:33:01
 libcxx-libcxxabi-libunwind-armv8-linux                  | 05:38:50
 libcxx-libcxxabi-libunwind-aarch64-linux                | 05:41:34
 clang-with-lto-ubuntu                                   | 06:04:41
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions     | 06:56:19
 clang-native-arm-lnt-perf                               | 07:49:59
 libcxx-libcxxabi-libunwind-armv7-linux                  | 07:58:32
 clang-ppc64le-linux-multistage                          | 08:01:44
 clang-cmake-thumbv7-full-sh                             | 08:51:49
 clang-ppc64le-linux-lnt                                 | 11:25:51
(109 rows)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: change_ratio.csv
Type: application/vnd.ms-excel
Size: 4347 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: completed_failed_avr_time.csv
Type: application/vnd.ms-excel
Size: 4847 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: count_commits_by_prj.csv
Type: application/vnd.ms-excel
Size: 169 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: response_time.csv
Type: application/vnd.ms-excel
Size: 4263 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: time_was_red.csv
Type: application/vnd.ms-excel
Size: 2391 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 21:42:23 2020
From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 04:42:23 +0000 (UTC)
Subject: [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency
 unconditional.
Message-ID: 

michele.scandale created this revision.
michele.scandale added reviewers: chandlerc, beanz, zturner.
Herald added subscribers: lldb-commits, cfe-commits, MaskRay, aheejin, arichardson, sbc100, mgorny, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: MaskRay.
Herald added projects: clang, LLDB.

The `intrinsics_gen` target exists in the CMake exports since r309389
(see LLVMConfig.cmake.in), hence projects can depend on `intrinsics_gen`
even it they are built separately from LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83454

Files:
  clang/CMakeLists.txt
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-import-test/CMakeLists.txt
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-wrapper/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  lld/COFF/CMakeLists.txt
  lld/Common/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lld/MinGW/CMakeLists.txt
  lld/lib/Core/CMakeLists.txt
  lld/wasm/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/source/Expression/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83454.276633.patch
Type: text/x-patch
Size: 9603 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Wed Jul  8 21:52:20 2020
From: cfe-commits at lists.llvm.org (Alex Bradbury via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 04:52:20 +0000 (UTC)
Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu
In-Reply-To: 
References: 
Message-ID: <6ea7dcc9837ea1d188531c6621dbd523@localhost.localdomain>

asb added a comment.

This has been hanging around for a while, but I think we'd basically agreed this is the right logic. The comments have ended up referring to flags that don't exist on Clang making it a little hard to follow, and I've added a request to slightly expand testing. If you make those cleanups I think it should be ready for a final review and merge.

As Sam says, lets flag this in today's RISC-V LLVM call to double-check everyone is happy.



================
Comment at: clang/lib/Driver/ToolChains/Arch/RISCV.cpp:622
+  // 1. Explicit choices using `--with-arch=`
+  // 2. Based on `-mcpu` if target cpu has default isa extension feature
+  // 3. A default based on `--with-abi=`, if provided
----------------
As clang has no with-arch or with-abi, this comment seems inaccurate?


================
Comment at: clang/test/Driver/riscv-cpus.c:2
+// Check target CPUs are correctly passed.
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck -check-prefix=MCPU-ROCKETCHIP32 %s
----------------
I think for completeness this test should be validating the interaction of the ABI choosing logic with CPU selection as well. With the implemented logic I believe it should show that lp64d is selected for -mcpu=sifive-u54 and that -mcpu=sifive-u54 -mabi=lp64 will respect the ABI choice


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71124/new/

https://reviews.llvm.org/D71124




From cfe-commits at lists.llvm.org  Wed Jul  8 22:04:33 2020
From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 05:04:33 +0000 (UTC)
Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about
 double/long double
In-Reply-To: 
References: 
Message-ID: <13df0ab354dcb4f82f1f026ee42deec4@localhost.localdomain>

hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1208
+    // "first (inherited) member".
+    HandledFirstNonOverlappingEmptyField = true;
+
----------------
We need some sort of `IsFirstNonEmptyBase` to record that the current base qualifies for the alignment upgrade:
```
struct A { double x; };
struct B : A {} b;
```


================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1245
+  // space or zero-extent array.
+  if (DefaultsToAIXPowerAlignment && HandledFirstNonOverlappingEmptyField) {
+    UnpackedPreferredBaseAlign = UnpackedBaseAlign;
----------------
Query `!IsFirstNonEmptyBase` instead of `HandledFirstNonOverlappingEmptyField` here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79719/new/

https://reviews.llvm.org/D79719




From cfe-commits at lists.llvm.org  Wed Jul  8 22:19:55 2020
From: cfe-commits at lists.llvm.org (Alex Bradbury via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 05:19:55 +0000 (UTC)
Subject: [PATCH] D80802: [RISCV] Upgrade RVV MC to v0.9.
In-Reply-To: 
References: 
Message-ID: <6a4e8ed0230210c6194995de93626fe1@localhost.localdomain>

asb added a comment.

I've gone through and can't see any obvious issues. I defer to one of the RISC-V Vector extension usual suspects for giving a LGTM on the detail of the altered instructions etc. Once we have that, this looks good to land IMHO.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80802/new/

https://reviews.llvm.org/D80802




From cfe-commits at lists.llvm.org  Wed Jul  8 23:09:12 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits)
Date: Wed, 08 Jul 2020 23:09:12 -0700 (PDT)
Subject: [clang] e3e47e8 - [OpenMP] Make complex soft-float functions on the
 GPU weak definitions
Message-ID: <5f06b488.1c69fb81.3d0d9.4e3b@mx.google.com>


Author: Johannes Doerfert
Date: 2020-07-09T01:06:55-05:00
New Revision: e3e47e80355422df2e730cf97a0c80bb6de3915e

URL: https://github.com/llvm/llvm-project/commit/e3e47e80355422df2e730cf97a0c80bb6de3915e
DIFF: https://github.com/llvm/llvm-project/commit/e3e47e80355422df2e730cf97a0c80bb6de3915e.diff

LOG: [OpenMP] Make complex soft-float functions on the GPU weak definitions

To avoid linkage errors we have to ensure the linkage allows multiple
definitions of these compiler inserted functions. Since they are on the
cold path of complex computations, we want to avoid `inline`. Instead,
we opt for `weak` and `noinline` for now.

Added: 
    

Modified: 
    clang/lib/Headers/__clang_cuda_complex_builtins.h
    clang/test/Headers/nvptx_device_math_complex.c
    clang/test/Headers/nvptx_device_math_complex.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/__clang_cuda_complex_builtins.h b/clang/lib/Headers/__clang_cuda_complex_builtins.h
index d698be71d011..c48c754ed1a4 100644
--- a/clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ b/clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -18,7 +18,7 @@
 #pragma push_macro("__DEVICE__")
 #ifdef _OPENMP
 #pragma omp declare target
-#define __DEVICE__ __attribute__((noinline, nothrow, cold))
+#define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
 #define __DEVICE__ __device__ inline
 #endif

diff  --git a/clang/test/Headers/nvptx_device_math_complex.c b/clang/test/Headers/nvptx_device_math_complex.c
index 9b96b5dd8c22..0e212592dd2b 100644
--- a/clang/test/Headers/nvptx_device_math_complex.c
+++ b/clang/test/Headers/nvptx_device_math_complex.c
@@ -11,10 +11,10 @@
 #include 
 #endif
 
-// CHECK-DAG: define {{.*}} @__mulsc3
-// CHECK-DAG: define {{.*}} @__muldc3
-// CHECK-DAG: define {{.*}} @__divsc3
-// CHECK-DAG: define {{.*}} @__divdc3
+// CHECK-DAG: define weak {{.*}} @__mulsc3
+// CHECK-DAG: define weak {{.*}} @__muldc3
+// CHECK-DAG: define weak {{.*}} @__divsc3
+// CHECK-DAG: define weak {{.*}} @__divdc3
 
 // CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(float _Complex a) {

diff  --git a/clang/test/Headers/nvptx_device_math_complex.cpp b/clang/test/Headers/nvptx_device_math_complex.cpp
index 15434d907605..58ed24b74b0e 100644
--- a/clang/test/Headers/nvptx_device_math_complex.cpp
+++ b/clang/test/Headers/nvptx_device_math_complex.cpp
@@ -5,10 +5,10 @@
 
 #include 
 
-// CHECK-DAG: define {{.*}} @__mulsc3
-// CHECK-DAG: define {{.*}} @__muldc3
-// CHECK-DAG: define {{.*}} @__divsc3
-// CHECK-DAG: define {{.*}} @__divdc3
+// CHECK-DAG: define weak {{.*}} @__mulsc3
+// CHECK-DAG: define weak {{.*}} @__muldc3
+// CHECK-DAG: define weak {{.*}} @__divsc3
+// CHECK-DAG: define weak {{.*}} @__divdc3
 
 // CHECK-DAG: call float @__nv_scalbnf(
 void test_scmplx(std::complex a) {


        

From cfe-commits at lists.llvm.org  Wed Jul  8 23:19:09 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 06:19:09 +0000 (UTC)
Subject: [PATCH] D83436: [clangd] Fix error handling in config.yaml parsing.
In-Reply-To: 
References: 
Message-ID: 

hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks.



================
Comment at: clang-tools-extra/clangd/ConfigYAML.cpp:36
   // meaningfully recover (e.g. YAML syntax error broke the stream).
   // The private parse() helpers follow the same pattern.
   bool parse(Fragment &F, Node &N) {
----------------
nit: the comment is stale. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83436/new/

https://reviews.llvm.org/D83436




From cfe-commits at lists.llvm.org  Wed Jul  8 23:30:30 2020
From: cfe-commits at lists.llvm.org (Douglas Yung via cfe-commits)
Date: Wed, 08 Jul 2020 23:30:30 -0700 (PDT)
Subject: [clang] f988846 - Increase DIAG_SIZE_AST as we have hit it.
Message-ID: <5f06b986.1c69fb81.36916.50b3@mx.google.com>


Author: Douglas Yung
Date: 2020-07-08T23:29:47-07:00
New Revision: f9888462cc76fb486161709d88522bd419a89504

URL: https://github.com/llvm/llvm-project/commit/f9888462cc76fb486161709d88522bd419a89504
DIFF: https://github.com/llvm/llvm-project/commit/f9888462cc76fb486161709d88522bd419a89504.diff

LOG: Increase DIAG_SIZE_AST as we have hit it.

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticIDs.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h b/clang/include/clang/Basic/DiagnosticIDs.h
index 46f0fa423a39..00c939650e54 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -33,7 +33,7 @@ namespace clang {
       DIAG_SIZE_SERIALIZATION =  120,
       DIAG_SIZE_LEX           =  400,
       DIAG_SIZE_PARSE         =  600,
-      DIAG_SIZE_AST           =  200,
+      DIAG_SIZE_AST           =  250,
       DIAG_SIZE_COMMENT       =  100,
       DIAG_SIZE_CROSSTU       =  100,
       DIAG_SIZE_SEMA          = 4000,


        

From cfe-commits at lists.llvm.org  Wed Jul  8 23:38:18 2020
From: cfe-commits at lists.llvm.org (Yonghong Song via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 06:38:18 +0000 (UTC)
Subject: [PATCH] D83242: [RFC][BPF] support expr with typedef type for
 FIELD_EXISTENCE reloc
In-Reply-To: 
References: 
Message-ID: 

yonghong-song added a comment.

Sounds good. Will try to add support for union/struct type as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83242/new/

https://reviews.llvm.org/D83242




From cfe-commits at lists.llvm.org  Wed Jul  8 23:51:34 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 06:51:34 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: 

hokein added a comment.

In D83419#2140573 , @sammccall wrote:

> In D83419#2140311 , @njames93 wrote:
>
> > I'm not a huge fan of using `error`, maybe `createError`, 
> >  Its definitely out of place in Logger, but there is no where else better for it to live short of a new file which seems overkill.
>
>
> Yeah, the naming is definitely the hardest part to be sure of here.
>  It's an extremely commonly used function: 75 references to StringError + another 20 or so references to local helpers.
>  This puts it in the same class as log (95), vlog (50), elog(85).
>  It's also similar in that it is cross cutting and has the same format string + args shape (so wrapping affects it similarly).


while the name `error` aligns well with `elog/vlog`, I'm not in favor of it. I think the key point is that `error` creates an **`Error`** object, and this object must be checked before destructing. `error` name makes it look like a print function, I'd prefer to add a verb to the name,  e.g. `makeError`

>> its used in many other parts of llvm, typically with static linkage.
> 
> Yeah, there's some precedent, though not overwhelming consensus. Outside clangd I count 10 `createError`s, 7 `make_string_error`s, 4 `error`s, 1 `makeError`, 1 `makeStringError`, and the canonical `makeStringError` and `make_error`.
> 
> But I think this is just a place where wider LLVM is making different tradeoffs:
> 
> - for good reasons:  many errors are diagnostics or don't need to be carefully routed back to a specific request
> - for bad reasons: e.g. compliance with the "verb phrase" policy that's poorly observed and itself seems like a sad accident of history: http://lists.llvm.org/pipermail/llvm-dev/2018-May/thread.html#123547
> - llvm::Error itself seems like a pretty strong argument that existing practice doesn't guarantee good ergonomics

it would be nicer if we could offer this across llvm-projects, but agree that logger.cc seems to be the best place to place it so far.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Wed Jul  8 23:58:32 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 06:58:32 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <753d04031d11b1f5507339603b0f86e1@localhost.localdomain>

eduucaldas updated this revision to Diff 276637.
eduucaldas marked 4 inline comments as done.
eduucaldas added a comment.

Add support for {Integer,Float,Char,String}UserDefinedLiteral


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Testing/TestClangConfig.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276637.patch
Type: text/x-patch
Size: 13418 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 00:07:38 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:07:38 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <41a50371fc1fea89f5bb8da5e074e514@localhost.localdomain>

eduucaldas updated this revision to Diff 276638.
eduucaldas added a comment.

workaround size_t


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Testing/TestClangConfig.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276638.patch
Type: text/x-patch
Size: 13350 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 00:14:41 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:14:41 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: 

eduucaldas marked 4 inline comments as done.
eduucaldas added inline comments.


================
Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:347-357
+/// Expression for an unkonwn user-defined literal. C++ [lex.ext]
+class UnknownUserDefinedLiteralExpression final
+    : public UserDefinedLiteralExpression {
+public:
+  UnknownUserDefinedLiteralExpression()
+      : UserDefinedLiteralExpression(
+            NodeKind::UnknownUserDefinedLiteralExpression) {}
----------------
This is gonna be removed once we are able to distinguish between integer and float on raw and template UDL


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:218-219
     auto InitializerEnd = Initializer.getEnd();
-    assert(SM.isBeforeInTranslationUnit(End, InitializerEnd) || End == InitializerEnd);
+    assert(SM.isBeforeInTranslationUnit(End, InitializerEnd) ||
+           End == InitializerEnd);
     End = InitializerEnd;
----------------
I know it adds noise, but this is the only place where the formatting doesn't obey the llvm clang format.


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:732
+    case clang::UserDefinedLiteral::LOK_Template:
+      return syntax::NodeKind::UnknownUserDefinedLiteralExpression;
+    }
----------------
Here we need logic to determine which kind of UDL, if float or integer


================
Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1309-1310
     |-ExpressionStatement
-    | |-IntegerLiteralExpression
-    | | `-12ul
+    | |-UnknownUserDefinedLiteralExpression
+    | | `-12_r
     | `-;
----------------
For raw and template UDL, we don't know yet how to get the information about integer of float


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157




From cfe-commits at lists.llvm.org  Thu Jul  9 00:17:45 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:17:45 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: 

sammccall added a comment.

Honestly, I really dislike names in the style of makeError/createError.
My favorite name for this would be Error (i.e. a constructor) but that would involve redesigning it (which is a good idea, but an impossible yak-shave).
I guess makeError is still better than the status quo, but not enough to feel motivated to clean this up right now. Maybe someone else wants to pick this up?

> I think the key point is that error creates an Error object, and this object must be checked before destructing. error name makes it look like a print function, I'd prefer to add a verb to the name, e.g. makeError

This is exactly backwards IMO - a function used for its value (like this one) doesn't need a verb, a function used for its side-effects (like log) does.
https://swift.org/documentation/api-design-guidelines/#strive-for-fluent-usage seems pretty well-thought-out to me.
LLVM guidelines don't reflect this, but I haven't been able to find anyone making a positive case for them beyond legacy and inertia.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Thu Jul  9 00:23:04 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:23:04 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: 

sammccall added a comment.

In D83419#2140889 , @sammccall wrote:

> Honestly, I really dislike names in the style of makeError/createError.


Sorry, I should give some reasons here:

- not discoverable (`error` is marginally better)
- emphasis on allocation rather than how you're using the error (`error` is much better)
- forms part of a cluster of hard to remember names createX vs makeX vs make_x (`error` is much better)
- longer, both in characters and words (`error` is better)

It's just an aesthetic irritation but really this is just an aesthetic cleanup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Thu Jul  9 00:35:51 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:35:51 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <260213ccb6d18350d8a70864740851d8@localhost.localdomain>

kbobyrev updated this revision to Diff 276642.
kbobyrev added a comment.

Fix formatting on one line.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276642.patch
Type: text/x-patch
Size: 39324 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 00:40:32 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:40:32 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <66c7c4333ac49fe376ff1cd6416bcefc@localhost.localdomain>

kbobyrev updated this revision to Diff 276646.
kbobyrev added a comment.

Rebase on top of master


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276646.patch
Type: text/x-patch
Size: 39442 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 00:43:46 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:43:46 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: 

kbobyrev updated this revision to Diff 276647.
kbobyrev added a comment.

Replace Sym in Client response with a more generic name (it can be a reference).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276647.patch
Type: text/x-patch
Size: 39601 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 00:50:39 2020
From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 07:50:39 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: <452fda1abbd701dab918806b58db1a49@localhost.localdomain>

uweigand updated this revision to Diff 276650.
uweigand added a comment.

Drop AllowNoUniqueAddress parameter; address review comment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/systemz-abi.cpp


Index: clang/test/CodeGen/systemz-abi.cpp
===================================================================
--- clang/test/CodeGen/systemz-abi.cpp
+++ clang/test/CodeGen/systemz-abi.cpp
@@ -23,3 +23,37 @@
 // CHECK-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, float %{{.*}})
 // SOFT-FLOAT-LABEL:  define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}})
 
+
+// A field member of empty class type in C++ makes the record nonhomogeneous,
+// unless it is marked as [[no_unique_address]].  This does not apply to arrays.
+struct empty { };
+struct agg_nofloat_empty { float a; empty dummy; };
+struct agg_nofloat_empty pass_agg_nofloat_empty(struct agg_nofloat_empty arg) { return arg; }
+// CHECK-LABEL: define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+struct agg_float_empty { float a; [[no_unique_address]] empty dummy; };
+struct agg_float_empty pass_agg_float_empty(struct agg_float_empty arg) { return arg; }
+// CHECK-LABEL: define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+struct agg_nofloat_emptyarray { float a; [[no_unique_address]] empty dummy[3]; };
+struct agg_nofloat_emptyarray pass_agg_nofloat_emptyarray(struct agg_nofloat_emptyarray arg) { return arg; }
+// CHECK-LABEL: define void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+
+// And likewise for members of base classes.
+struct noemptybase { empty dummy; };
+struct agg_nofloat_emptybase : noemptybase { float a; };
+struct agg_nofloat_emptybase pass_agg_nofloat_emptybase(struct agg_nofloat_emptybase arg) { return arg; }
+// CHECK-LABEL: define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+struct emptybase { [[no_unique_address]] empty dummy; };
+struct agg_float_emptybase : emptybase { float a; };
+struct agg_float_emptybase pass_agg_float_emptybase(struct agg_float_emptybase arg) { return arg; }
+// CHECK-LABEL: define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, float %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, i32 %{{.*}})
+struct noemptybasearray { [[no_unique_address]] empty dummy[3]; };
+struct agg_nofloat_emptybasearray : noemptybasearray { float a; };
+struct agg_nofloat_emptybasearray pass_agg_nofloat_emptybasearray(struct agg_nofloat_emptybasearray arg) { return arg; }
+// CHECK-LABEL: define void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret align 4 %{{.*}}, i64 %{{.*}})
+
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -499,11 +499,15 @@
 
   // Constant arrays of empty records count as empty, strip them off.
   // Constant arrays of zero length always count as empty.
+  bool WasArray = false;
   if (AllowArrays)
     while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) {
       if (AT->getSize() == 0)
         return true;
       FT = AT->getElementType();
+      // The [[no_unique_address]] special case below does not apply to
+      // arrays of C++ empty records, so we need to remember this fact.
+      WasArray = true;
     }
 
   const RecordType *RT = FT->getAs();
@@ -514,7 +518,14 @@
   //
   // FIXME: We should use a predicate for whether this behavior is true in the
   // current ABI.
-  if (isa(RT->getDecl()))
+  //
+  // The exception to the above rule are fields marked with the
+  // [[no_unique_address]] attribute (since C++20).  Those do count as empty
+  // according to the Itanium ABI.  The exception applies only to records,
+  // not arrays of records, so we must also check whether we stripped off an
+  // array type above.
+  if (isa(RT->getDecl()) &&
+      (WasArray || !FD->hasAttr()))
     return false;
 
   return isEmptyRecord(Context, FT, AllowArrays);
@@ -7236,6 +7247,10 @@
       if (getContext().getLangOpts().CPlusPlus &&
           FD->isZeroLengthBitField(getContext()))
         continue;
+      // Like isSingleElementStruct(), ignore C++20 empty data members.
+      if (FD->hasAttr() &&
+          isEmptyRecord(getContext(), FD->getType(), true))
+        continue;
 
       // Unlike isSingleElementStruct(), arrays do not count.
       // Nested structures still do though.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81583.276650.patch
Type: text/x-patch
Size: 5699 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 01:13:08 2020
From: cfe-commits at lists.llvm.org (Whisperity via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:13:08 +0000 (UTC)
Subject: [PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check
In-Reply-To: 
References: 
Message-ID: <20f99f8097fc6802beb23103288b0936@localhost.localdomain>

whisperity added a comment.

In general, the test files should be cleaned up.



================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std::thread.cpp:1
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t \
+// RUN: -config='{CheckOptions: \
----------------
Please rename this file to something that doesn't conatain `:` in the name. Windows peoples' computers will explode if it's merged like this...


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std::thread.cpp:5-6
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
----------------
Are these definitions needed for C++ test?


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std::thread.cpp:32
+
+int main(void) {
+  signal(SIGUSR1, handler);
----------------
As far as I know, `int main(void)` is **not** valid C++ code. Only `int main()` and `int main(int, char**)` are valid, see `[basic.start.main]`/2.

If we are writing C++ test code, let's make it appear as if it was C++ code.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std::thread.cpp:1
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
----------------
Same rename here.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.cpp:1
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
----------------
thrd_create is a C standard function, and this file looks like a C file to me, so why is the extension `.cpp`?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75229/new/

https://reviews.llvm.org/D75229




From cfe-commits at lists.llvm.org  Thu Jul  9 01:20:23 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 08:20:23 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: 

balazske added a comment.

Are not some functions missing from the list (`shutdown`, `sockatmark`, `socket`) (these come from ////)? And `getnameinfo` comes from //// with many other functions that are not added.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1722
+          ACtx.getPointerType(StructSockaddrTy->withConst());
+      StructSockaddrPtrRestrictTy =
+          ACtx.getLangOpts().C99 ? ACtx.getRestrictType(*StructSockaddrPtrTy)
----------------
There could be a generic form of getting the restrict type for a type so something like this can be done (this is used relatively often):
`getRestrictTypeIfApplicable(ACtx, StructSockaddrPtrTy)`



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Thu Jul  9 01:20:27 2020
From: cfe-commits at lists.llvm.org (Sam McCall via cfe-commits)
Date: Thu, 09 Jul 2020 01:20:27 -0700 (PDT)
Subject: [clang-tools-extra] f365186 - [clangd] Fix error handling in
 config.yaml parsing.
Message-ID: <5f06d34b.1c69fb81.1b7e.b094@mx.google.com>


Author: Sam McCall
Date: 2020-07-09T10:20:18+02:00
New Revision: f36518637d7dfe5f8e619db1bd65dc90c92b5afa

URL: https://github.com/llvm/llvm-project/commit/f36518637d7dfe5f8e619db1bd65dc90c92b5afa
DIFF: https://github.com/llvm/llvm-project/commit/f36518637d7dfe5f8e619db1bd65dc90c92b5afa.diff

LOG: [clangd] Fix error handling in config.yaml parsing.

Summary:
A few things were broken:
 - use of Document::parseBlockNode() is incorrect and prevents moving to the
   next doc in error cases. Use getRoot() instead.
 - bailing out in the middle of iterating over a list/dict isn't allowed,
   unless you are going to throw away the parser: the next skip() asserts.
   Always consume all items.
 - There were two concepts of fatal errors: error-diagnostics and drop-fragment.
   (The latter is the "return false" case in the parser). They didn't coincide.
   Now, parser errors and explicitly emitted error diagnostics are fatal.

Fixes https://github.com/clangd/clangd/issues/452

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83436

Added: 
    

Modified: 
    clang-tools-extra/clangd/ConfigYAML.cpp
    clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp
index 1201c9a5d523..0674c6030903 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -26,49 +26,47 @@ using llvm::yaml::SequenceNode;
 
 class Parser {
   llvm::SourceMgr &SM;
+  bool HadError = false;
 
 public:
   Parser(llvm::SourceMgr &SM) : SM(SM) {}
 
   // Tries to parse N into F, returning false if it failed and we couldn't
-  // meaningfully recover (e.g. YAML syntax error broke the stream).
-  // The private parse() helpers follow the same pattern.
+  // meaningfully recover (YAML syntax error, or hard semantic error).
   bool parse(Fragment &F, Node &N) {
     DictParser Dict("Config", this);
-    Dict.handle("If", [&](Node &N) { return parse(F.If, N); });
-    Dict.handle("CompileFlags",
-                [&](Node &N) { return parse(F.CompileFlags, N); });
-    return Dict.parse(N);
+    Dict.handle("If", [&](Node &N) { parse(F.If, N); });
+    Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+    Dict.parse(N);
+    return !(N.failed() || HadError);
   }
 
 private:
-  bool parse(Fragment::IfBlock &F, Node &N) {
+  void parse(Fragment::IfBlock &F, Node &N) {
     DictParser Dict("If", this);
     Dict.unrecognized(
         [&](llvm::StringRef) { F.HasUnrecognizedCondition = true; });
     Dict.handle("PathMatch", [&](Node &N) {
       if (auto Values = scalarValues(N))
         F.PathMatch = std::move(*Values);
-      return !N.failed();
     });
-    return Dict.parse(N);
+    Dict.parse(N);
   }
 
-  bool parse(Fragment::CompileFlagsBlock &F, Node &N) {
+  void parse(Fragment::CompileFlagsBlock &F, Node &N) {
     DictParser Dict("CompileFlags", this);
     Dict.handle("Add", [&](Node &N) {
       if (auto Values = scalarValues(N))
         F.Add = std::move(*Values);
-      return !N.failed();
     });
-    return Dict.parse(N);
+    Dict.parse(N);
   }
 
   // Helper for parsing mapping nodes (dictionaries).
   // We don't use YamlIO as we want to control over unknown keys.
   class DictParser {
     llvm::StringRef Description;
-    std::vector>> Keys;
+    std::vector>> Keys;
     std::function Unknown;
     Parser *Outer;
 
@@ -79,7 +77,7 @@ class Parser {
     // Parse is called when Key is encountered, and passed the associated value.
     // It should emit diagnostics if the value is invalid (e.g. wrong type).
     // If Key is seen twice, Parse runs only once and an error is reported.
-    void handle(llvm::StringLiteral Key, std::function Parse) {
+    void handle(llvm::StringLiteral Key, std::function Parse) {
       for (const auto &Entry : Keys) {
         (void) Entry;
         assert(Entry.first != Key && "duplicate key handler");
@@ -94,16 +92,17 @@ class Parser {
     }
 
     // Process a mapping node and call handlers for each key/value pair.
-    bool parse(Node &N) const {
+    void parse(Node &N) const {
       if (N.getType() != Node::NK_Mapping) {
         Outer->error(Description + " should be a dictionary", N);
-        return false;
+        return;
       }
       llvm::SmallSet Seen;
+      // We *must* consume all items, even on error, or the parser will assert.
       for (auto &KV : llvm::cast(N)) {
         auto *K = KV.getKey();
         if (!K) // YAMLParser emitted an error.
-          return false;
+          continue;
         auto Key = Outer->scalarValue(*K, "Dictionary key");
         if (!Key)
           continue;
@@ -113,13 +112,12 @@ class Parser {
         }
         auto *Value = KV.getValue();
         if (!Value) // YAMLParser emitted an error.
-          return false;
+          continue;
         bool Matched = false;
         for (const auto &Handler : Keys) {
           if (Handler.first == **Key) {
-            if (!Handler.second(*Value))
-              return false;
             Matched = true;
+            Handler.second(*Value);
             break;
           }
         }
@@ -129,7 +127,6 @@ class Parser {
             Unknown(**Key);
         }
       }
-      return true;
     }
   };
 
@@ -154,6 +151,7 @@ class Parser {
     } else if (auto *S = llvm::dyn_cast(&N)) {
       Result.emplace_back(S->getValue().str(), N.getSourceRange());
     } else if (auto *S = llvm::dyn_cast(&N)) {
+      // We *must* consume all items, even on error, or the parser will assert.
       for (auto &Child : *S) {
         if (auto Value = scalarValue(Child, "List item"))
           Result.push_back(std::move(*Value));
@@ -167,6 +165,7 @@ class Parser {
 
   // Report a "hard" error, reflecting a config file that can never be valid.
   void error(const llvm::Twine &Msg, const Node &N) {
+    HadError = true;
     SM.PrintMessage(N.getSourceRange().Start, llvm::SourceMgr::DK_Error, Msg,
                     N.getSourceRange());
   }
@@ -196,7 +195,7 @@ std::vector Fragment::parseYAML(llvm::StringRef YAML,
       &Diags);
   std::vector Result;
   for (auto &Doc : llvm::yaml::Stream(*Buf, *SM)) {
-    if (Node *N = Doc.parseBlockNode()) {
+    if (Node *N = Doc.getRoot()) {
       Fragment Fragment;
       Fragment.Source.Manager = SM;
       Fragment.Source.Location = N->getSourceRange().Start;

diff  --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
index 3ad8b2e7c1c8..a9526ce2367c 100644
--- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -98,10 +98,25 @@ CompileFlags: {^
                         DiagKind(llvm::SourceMgr::DK_Error),
                         DiagPos(YAML.point()), DiagRange(llvm::None))));
 
-  ASSERT_EQ(Results.size(), 2u);
+  ASSERT_EQ(Results.size(), 1u); // invalid fragment discarded.
   EXPECT_THAT(Results.front().CompileFlags.Add, ElementsAre(Val("first")));
   EXPECT_TRUE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.back().CompileFlags.Add, IsEmpty());
+}
+
+TEST(ParseYAML, Invalid) {
+  CapturedDiags Diags;
+  const char *YAML = R"yaml(
+If:
+
+horrible
+---
+- 1
+  )yaml";
+  auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+              ElementsAre(DiagMessage("If should be a dictionary"),
+                          DiagMessage("Config should be a dictionary")));
+  ASSERT_THAT(Results, IsEmpty());
 }
 
 } // namespace


        

From cfe-commits at lists.llvm.org  Thu Jul  9 01:20:40 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:20:40 +0000 (UTC)
Subject: [PATCH] D83436: [clangd] Fix error handling in config.yaml parsing.
In-Reply-To: 
References: 
Message-ID: <7ce413c674a94fb3bc463dba8175f530@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rGf36518637d7d: [clangd] Fix error handling in config.yaml parsing. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D83436?vs=276574&id=276660#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83436/new/

https://reviews.llvm.org/D83436

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83436.276660.patch
Type: text/x-patch
Size: 6381 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 01:32:06 2020
From: cfe-commits at lists.llvm.org (Whisperity via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:32:06 +0000 (UTC)
Subject: [PATCH] D77493: [clang-tidy] Add do-not-refer-atomic-twice check
In-Reply-To: 
References: 
Message-ID: <5da1f88ce0683fb306993090278185cc@localhost.localdomain>

whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/DoNotReferAtomicTwiceCheck.cpp:38
+  diag(MatchedRef->getExprLoc(),
+       "Do not refer to '%0' atomic variable twice in an expression")
+      << MatchedVar->getName();
----------------
atomic variable '%0'


================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:82
+
+  Finds atomic variable which is referred twice in an expression.
+
----------------
atomic variable**s** which **are**


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77493/new/

https://reviews.llvm.org/D77493




From cfe-commits at lists.llvm.org  Thu Jul  9 01:53:36 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:53:36 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <9b6f657b028a8615d6e8169d99309258@localhost.localdomain>

sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Rest is just nits, thanks!



================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:38
+/// provided by the client.
+llvm::Optional relativePathToURI(llvm::StringRef RelativePath,
+                                              llvm::StringRef IndexRoot) {
----------------
these functions are nice. It might be clearer to expose them and test them directly, particularly for error cases. Up to you.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:39
+llvm::Optional relativePathToURI(llvm::StringRef RelativePath,
+                                              llvm::StringRef IndexRoot) {
+  assert(RelativePath == llvm::sys::path::convert_to_slash(
----------------
can we add an assert that the index root is valid? (ends with a platform-appropriate slash)


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:45
+  if (llvm::sys::path::is_absolute(RelativePath)) {
+    elog("{0} is not relative path", RelativePath);
+    return llvm::None;
----------------
message needs a bit more context. `Remote index client got absolute path from server: {0}`?


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:50
+  llvm::sys::path::append(FullPath, RelativePath);
+  const auto Result = URI::createFile(FullPath);
+  return Result.toString();
----------------
nit: lots of `const auto` throughout - we tend not to use `const` for local values (as opposed to references or pointers) so this is a bit confusing, particularly when combined with auto. Up to you though.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:57
+llvm::Optional uriToRelativePath(llvm::StringRef URI,
+                                              llvm::StringRef IndexRoot) {
+  auto ParsedURI = URI::parse(URI);
----------------
can we add an assert that IndexRoot is valid?


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:60
+  if (!ParsedURI) {
+    elog("Can not parse URI {0}: {1}", URI, ParsedURI.takeError());
+    return llvm::None;
----------------
Similarly: `Remote index got bad URI from client: ...`


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:64
+  if (ParsedURI->scheme() != "file") {
+    elog("Can not parse URI with scheme other than \"file\" {0}", URI);
+    return llvm::None;
----------------
I think it's fine to fold this into the previous check: "bad URI" covers it


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:68
+  llvm::SmallString<256> Result = ParsedURI->body();
+  if (IndexRoot.empty())
+    return std::string(Result);
----------------
This isn't a valid IndexRoot, we should assert rather than handle this case I think.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:131
+  if (!RelativePath)
+    return Result;
+  *Result.mutable_file_path() = *RelativePath;
----------------
shouldn't this return llvm::None, too? a SymbolLocation isn't valid without a path.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:145
+  // If header starts with < or " it is not a URI: do not attempt to parse it.
+  if (Header.front() == '<' || Header.front() == '"') {
+    Result.set_header(Header);
----------------
nit: isLiteralInclude in Headers.h (sorry, had forgotten about this func).
Calling that function probably avoids the need for the comment too.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:149
+  }
+  auto URI = URI::parse(Header);
+  if (!URI) {
----------------
isn't the rest of this uriToRelativePath?


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:210
   if (!ID) {
-    elog("Cannot convert parse SymbolID {} from Protobuf: {}", ID.takeError(),
+    elog("Cannot parse SymbolID {} given Protobuf: {}", ID.takeError(),
          Message.ShortDebugString());
----------------
{} with no index is a nice idea but I think not actually supported


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h:19
+// path and passes paths relative to the project root over the wire
+// ("include/HelloWorld.h" in this example). The indexed project root is passed
+// passed to the remote server. It contains absolute path to the project root
----------------
nit "is passed passed to the remote server".


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h:20
+// ("include/HelloWorld.h" in this example). The indexed project root is passed
+// passed to the remote server. It contains absolute path to the project root
+// and includes a trailing slash. Relative path passed over the wire has unix
----------------
"It contains absolute path to the project root... relative path has unix slashes" 

can we pull this out into a separate paragraph at the end? The rest is describing the flow, and this describes an API detail.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h:20
+// ("include/HelloWorld.h" in this example). The indexed project root is passed
+// passed to the remote server. It contains absolute path to the project root
+// and includes a trailing slash. Relative path passed over the wire has unix
----------------
sammccall wrote:
> "It contains absolute path to the project root... relative path has unix slashes" 
> 
> can we pull this out into a separate paragraph at the end? The rest is describing the flow, and this describes an API detail.
nit: "*the* absolute path", "*the* relative path" etc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938




From cfe-commits at lists.llvm.org  Thu Jul  9 01:54:08 2020
From: cfe-commits at lists.llvm.org (MyDeveloperDay via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:54:08 +0000 (UTC)
Subject: [PATCH] D79773: [clang-format] Improve clang-formats handling of
 concepts
In-Reply-To: 
References: 
Message-ID: <89e7ec0f82110432ad26adb6c0a00db2@localhost.localdomain>

MyDeveloperDay added a subscriber: klimek.
MyDeveloperDay added a comment.

This issue is caused by the presence of the `;` in the requires clause (`0)>;`) inside the template declaration

  template 
      requires std::invocable...>
  struct [[nodiscard]] constant : std::bool_constant < requires
  {
      typename _require_constant_<(std::invoke(F{}, Args{}()...), 0)>;
  } > {};

These below may not be legal C++ examples but show the same behaviour

  struct constant : Foo < typename {
      Foo;
  } > {};
  
  struct constant : Foo { };

This is actually failing in the handling of parsing the `<>`  in (`parseAngle()` actually `parseBrace()` inside of that), it is not really concepts specific except it may be seen now because of the presence of the `;`

The problem comes about I think because the line is broken by the ";" during the `parseBrace` at some point the `Next` token is null, I assume that's because the lines are broken by the ';' as such ultimately the < and > rather than being seen as TT_TemplateOpener and TT_TemplateCloser are seen as TT_BinaryOperators (by default when parseAngle fails)

I'm not sure how I could solve this, I might need help from a higher power @klimek


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79773/new/

https://reviews.llvm.org/D79773




From cfe-commits at lists.llvm.org  Thu Jul  9 01:57:55 2020
From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via cfe-commits)
Date: Thu, 09 Jul 2020 01:57:55 -0700 (PDT)
Subject: [clang-tools-extra] 1c7c501 - [clangd] Enable async preambles by
 default
Message-ID: <5f06dc13.1c69fb81.bae4c.5496@mx.google.com>


Author: Kadir Cetinkaya
Date: 2020-07-09T10:57:45+02:00
New Revision: 1c7c5019a7adfb16e0449ffb1d0e10631998d854

URL: https://github.com/llvm/llvm-project/commit/1c7c5019a7adfb16e0449ffb1d0e10631998d854
DIFF: https://github.com/llvm/llvm-project/commit/1c7c5019a7adfb16e0449ffb1d0e10631998d854.diff

LOG: [clangd] Enable async preambles by default

Summary:
We've been testing this internally for a couple weeks now and it seems
to be stable enough. Let's flip the flag before branch cut to increase testing
coverage and have enough time to revert if need be.

Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83290

Added: 
    

Modified: 
    clang-tools-extra/clangd/ClangdServer.h
    clang-tools-extra/clangd/TUScheduler.h

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ClangdServer.h b/clang-tools-extra/clangd/ClangdServer.h
index faeec2e88848..ea82081f2440 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -100,7 +100,7 @@ class ClangdServer {
     bool StorePreamblesInMemory = true;
     /// Reuse even stale preambles, and rebuild them in the background.
     /// This improves latency at the cost of accuracy.
-    bool AsyncPreambleBuilds = false;
+    bool AsyncPreambleBuilds = true;
 
     /// If true, ClangdServer builds a dynamic in-memory index for symbols in
     /// opened files and uses the index to augment code completion results.

diff  --git a/clang-tools-extra/clangd/TUScheduler.h b/clang-tools-extra/clangd/TUScheduler.h
index f33470f4e894..05c06da13380 100644
--- a/clang-tools-extra/clangd/TUScheduler.h
+++ b/clang-tools-extra/clangd/TUScheduler.h
@@ -194,7 +194,7 @@ class TUScheduler {
 
     /// Whether to run PreamblePeer asynchronously.
     /// No-op if AsyncThreadsCount is 0.
-    bool AsyncPreambleBuilds = false;
+    bool AsyncPreambleBuilds = true;
 
     /// Used to create a context that wraps each single operation.
     /// Typically to inject per-file configuration.


        

From cfe-commits at lists.llvm.org  Thu Jul  9 01:58:08 2020
From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:58:08 +0000 (UTC)
Subject: [PATCH] D83290: [clangd] Enable async preambles by default
In-Reply-To: 
References: 
Message-ID: <48440468294fdfcd5f9637fca66e112d@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c7c5019a7ad: [clangd] Enable async preambles by default (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83290/new/

https://reviews.llvm.org/D83290

Files:
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.h


Index: clang-tools-extra/clangd/TUScheduler.h
===================================================================
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -194,7 +194,7 @@
 
     /// Whether to run PreamblePeer asynchronously.
     /// No-op if AsyncThreadsCount is 0.
-    bool AsyncPreambleBuilds = false;
+    bool AsyncPreambleBuilds = true;
 
     /// Used to create a context that wraps each single operation.
     /// Typically to inject per-file configuration.
Index: clang-tools-extra/clangd/ClangdServer.h
===================================================================
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -100,7 +100,7 @@
     bool StorePreamblesInMemory = true;
     /// Reuse even stale preambles, and rebuild them in the background.
     /// This improves latency at the cost of accuracy.
-    bool AsyncPreambleBuilds = false;
+    bool AsyncPreambleBuilds = true;
 
     /// If true, ClangdServer builds a dynamic in-memory index for symbols in
     /// opened files and uses the index to augment code completion results.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83290.276667.patch
Type: text/x-patch
Size: 1145 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 01:58:39 2020
From: cfe-commits at lists.llvm.org (Whisperity via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 08:58:39 +0000 (UTC)
Subject: [PATCH] D79437: [clang-tidy] Add fsetpos argument checker
In-Reply-To: 
References: 
Message-ID: 

whisperity added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-fsetpos-argument-check.cpp:1
+// RUN: %check_clang_tidy %s bugprone-fsetpos-argument-check %t
+
----------------
This is a C, not a C++ file, the extension should show it. In addition, a similar test should be added that uses `std::fgetpos()` and `std::fsetpos()`, and shows the matching still works.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79437/new/

https://reviews.llvm.org/D79437




From cfe-commits at lists.llvm.org  Thu Jul  9 02:19:59 2020
From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:19:59 +0000 (UTC)
Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures
In-Reply-To: 
References: 
Message-ID: 

DavidSpickett updated this revision to Diff 276671.
DavidSpickett added a comment.

- Updated rm/mv command lines to account for $DEFAULT_TRIPLE being the same as %target_triple.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83055/new/

https://reviews.llvm.org/D83055

Files:
  clang/test/Driver/program-path-priority.c
  clang/test/lit.cfg.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83055.276671.patch
Type: text/x-patch
Size: 7823 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 02:21:20 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:21:20 +0000 (UTC)
Subject: [PATCH] D82756: Port some floating point options to new option
 marshalling infrastructure
In-Reply-To: 
References: 
Message-ID: <14735891e78898afb9744092d97794b7@localhost.localdomain>

dang added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:1176
+defm reciprocal_math : OptInFFlag< "reciprocal-math", "Allow division operations to be reassociated", "", "", [], "LangOpts->AllowRecip">;
+def fapprox_func : Flag<["-"], "fapprox-func">, Group, Flags<[CC1Option, NoDriverOption]>,
+  MarshallingInfoFlag<"LangOpts->ApproxFunc", "false">;
----------------
Anastasia wrote:
> could this also be OptInFFlag?
The aim was to keep the driver semantics the same as before and this was not something you could control with the driver, so I left it as just a CC1 flag. However if it makes sense to be able to control this from the driver then we can definitely make this `OptInFFLag`.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2805
     CmdArgs.push_back("-menable-unsafe-fp-math");
+    ApproxFunc = true;
+  }
----------------
Anastasia wrote:
> Is this a bug fix ?
No, in current trunk approximating floating point functions was something that was implied by other optimization flags, i.e. disabling math errno, enabling associative/reciprocal math, disabling signed zeros and disabling trapping math and -ffast-math which does all the previously mentioned things. This patch moves this logic in the driver by introducing a new CC1 flag for this so that parsing CC1 options can be more easily automated. This just reflects the logic that was previously inside cc1.


================
Comment at: clang/test/CodeGen/fp-function-attrs.cpp:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffinite-math-only -menable-unsafe-fp-math \
+// RUN:   -menable-no-infs -menable-no-nans -fno-signed-zeros -freciprocal-math \
+// RUN:   -fapprox-func -mreassociate -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s
----------------
Anastasia wrote:
> Not clear why do you need to pass these extra flags now?
Previously passing -ffast-math to CC1 implied all these other flags. I am trying to make CC1 option parsing as simple as possible, so that we can then make it easy to generate a command line from a CompilerInvocation instance. You can refer to [[ http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html | http://lists.llvm.org/pipermail/cfe-dev/2020-May/065421.html ]] for more details on why we want to be able to do this


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82756/new/

https://reviews.llvm.org/D82756




From cfe-commits at lists.llvm.org  Thu Jul  9 02:39:45 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:39:45 +0000 (UTC)
Subject: [PATCH] D83374: [analyzer][tests] Fix zip unpacking
In-Reply-To: 
References: 
Message-ID: <097ff504026b25aaec42dc5188ead77d@localhost.localdomain>

vsavchenko added a comment.

In D83374#2139505 , @NoQ wrote:

> I thought the OS always ignores those? Ok anyway fair enough!


I thought so too, but it looks like `glob` works in mysterious ways


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83374/new/

https://reviews.llvm.org/D83374




From cfe-commits at lists.llvm.org  Thu Jul  9 02:41:23 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:41:23 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: 

eduucaldas updated this revision to Diff 276678.
eduucaldas added a comment.

Polishing patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276678.patch
Type: text/x-patch
Size: 13265 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 02:41:51 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:41:51 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <91267014b8b18811e084f177d26835d6@localhost.localdomain>

eduucaldas added inline comments.


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:634
+    // `SourceLocation`s. As a result one of these nodes has a valid
+    // `SourceLocation` that doesn't point to a token.
+    //
----------------
gribozavr2 wrote:
> "The semantic AST node for has child nodes that reference two source locations, the location of the beginning of the token (`1`), and the location of the beginning of the UDL suffix (`_`). The UDL suffix location does not point to the beginning of a token, so we can't represent the UDL suffix as a separate syntax tree node."
I changed your comment slightly, WDYT


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157




From cfe-commits at lists.llvm.org  Thu Jul  9 02:42:21 2020
From: cfe-commits at lists.llvm.org (Dmitry Polukhin via cfe-commits)
Date: Thu, 09 Jul 2020 02:42:21 -0700 (PDT)
Subject: [clang] 9e7fddb - [yaml][clang-tidy] Fix multiline YAML serialization
Message-ID: <5f06e67d.1c69fb81.96cc2.647e@mx.google.com>


Author: Dmitry Polukhin
Date: 2020-07-09T02:41:58-07:00
New Revision: 9e7fddbd36f567217255c1df1cb816b79f0250af

URL: https://github.com/llvm/llvm-project/commit/9e7fddbd36f567217255c1df1cb816b79f0250af
DIFF: https://github.com/llvm/llvm-project/commit/9e7fddbd36f567217255c1df1cb816b79f0250af.diff

LOG: [yaml][clang-tidy] Fix multiline YAML serialization

Summary:
New line duplication logic introduced in https://reviews.llvm.org/D63482
has two issues: (1) there is no logic that removes duplicate newlines
when clang-apply-replacment reads YAML and (2) in general such logic
should be applied to all strings and should happen on string
serialization level instead in YAML parser.

This diff changes multiline strings quotation from single quote `'` to
double `"`. It solves problems with internal newlines because now they are
escaped. Also double quotation solves the problem with leading whitespace after
newline. In case of single quotation YAML parsers should remove leading
whitespace according to specification. In case of double quotation these
leading are internal space and they are preserved. There is no way to
instruct YAML parsers to preserve leading whitespaces after newline so
double quotation is the only viable option that solves all problems at
once.

Test Plan: check-all

Reviewers: gribozavr, mgehre, yvvan

Subscribers: xazax.hun, hiraditya, cfe-commits, llvm-commits

Tags: #clang-tools-extra, #clang, #llvm

Differential Revision: https://reviews.llvm.org/D80301

Added: 
    

Modified: 
    clang/include/clang/Tooling/ReplacementsYaml.h
    clang/unittests/Tooling/ReplacementsYamlTest.cpp
    llvm/include/llvm/Support/YAMLTraits.h
    llvm/lib/Support/YAMLTraits.cpp
    llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
    llvm/unittests/Support/YAMLIOTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Tooling/ReplacementsYaml.h b/clang/include/clang/Tooling/ReplacementsYaml.h
index 2e3e401652e2..83e35d623255 100644
--- a/clang/include/clang/Tooling/ReplacementsYaml.h
+++ b/clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@ template <> struct MappingTraits {
 
     NormalizedReplacement(const IO &, const clang::tooling::Replacement &R)
         : FilePath(R.getFilePath()), Offset(R.getOffset()),
-          Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-      size_t lineBreakPos = ReplacementText.find('\n');
-      while (lineBreakPos != std::string::npos) {
-        ReplacementText.replace(lineBreakPos, 1, "\n\n");
-        lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
-      }
-    }
+          Length(R.getLength()), ReplacementText(R.getReplacementText()) {}
 
     clang::tooling::Replacement denormalize(const IO &) {
       return clang::tooling::Replacement(FilePath, Offset, Length,

diff  --git a/clang/unittests/Tooling/ReplacementsYamlTest.cpp b/clang/unittests/Tooling/ReplacementsYamlTest.cpp
index c8fe9c4db412..3328d9bad55c 100644
--- a/clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ b/clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -65,7 +65,7 @@ TEST(ReplacementsYamlTest, serializesNewLines) {
                "  - FilePath:        '/path/to/file1.h'\n"
                "    Offset:          0\n"
                "    Length:          0\n"
-               "    ReplacementText: '#include \n\n'\n"
+               "    ReplacementText: \"#include \\n\"\n"
                "...\n",
                YamlContentStream.str().c_str());
 }

diff  --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index f93f36037679..44e34a4a09b4 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -649,24 +649,25 @@ inline bool isBool(StringRef S) {
 inline QuotingType needsQuotes(StringRef S) {
   if (S.empty())
     return QuotingType::Single;
+
+  QuotingType MaxQuotingNeeded = QuotingType::None;
   if (isSpace(static_cast(S.front())) ||
       isSpace(static_cast(S.back())))
-    return QuotingType::Single;
+    MaxQuotingNeeded = QuotingType::Single;
   if (isNull(S))
-    return QuotingType::Single;
+    MaxQuotingNeeded = QuotingType::Single;
   if (isBool(S))
-    return QuotingType::Single;
+    MaxQuotingNeeded = QuotingType::Single;
   if (isNumeric(S))
-    return QuotingType::Single;
+    MaxQuotingNeeded = QuotingType::Single;
 
   // 7.3.3 Plain Style
   // Plain scalars must not begin with most indicators, as this would cause
   // ambiguity with other YAML constructs.
   static constexpr char Indicators[] = R"(-?:\,[]{}#&*!|>'"%@`)";
   if (S.find_first_of(Indicators) == 0)
-    return QuotingType::Single;
+    MaxQuotingNeeded = QuotingType::Single;
 
-  QuotingType MaxQuotingNeeded = QuotingType::None;
   for (unsigned char C : S) {
     // Alphanum is safe.
     if (isAlnum(C))
@@ -684,11 +685,11 @@ inline QuotingType needsQuotes(StringRef S) {
     case 0x9:
       continue;
     // LF(0xA) and CR(0xD) may delimit values and so require at least single
-    // quotes.
+    // quotes. LLVM YAML parser cannot handle single quoted multiline so use
+    // double quoting to produce valid YAML.
     case 0xA:
     case 0xD:
-      MaxQuotingNeeded = QuotingType::Single;
-      continue;
+      return QuotingType::Double;
     // DEL (0x7F) are excluded from the allowed character range.
     case 0x7F:
       return QuotingType::Double;

diff  --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index 752fab2be9b3..9ac7c65e19f7 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -878,12 +878,12 @@ StringRef ScalarTraits::input(StringRef Scalar, void *,
 }
 
 void ScalarTraits::output(const std::string &Val, void *,
-                                     raw_ostream &Out) {
+                                       raw_ostream &Out) {
   Out << Val;
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
-                                         std::string &Val) {
+                                           std::string &Val) {
   Val = Scalar.str();
   return StringRef();
 }

diff  --git a/llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll b/llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
index e92733f9a81a..2846889bf239 100644
--- a/llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
+++ b/llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
@@ -18,8 +18,7 @@
 ; YAML-NEXT:    - String:          ' loads, '
 ; YAML-NEXT:    - NumComputeOps:   '0'
 ; YAML-NEXT:    - String:          ' compute ops'
-; YAML-NEXT:    - String:          ',
-; YAML-NEXT:  additionally '
+; YAML-NEXT:    - String:          ",\nadditionally "
 ; YAML-NEXT:    - NumStores:       '0'
 ; YAML-NEXT:    - String:          ' stores, '
 ; YAML-NEXT:    - NumLoads:        '4'
@@ -47,8 +46,7 @@
 ; YAML-NEXT:    - String:          ' loads, '
 ; YAML-NEXT:    - NumComputeOps:   '120'
 ; YAML-NEXT:    - String:          ' compute ops'
-; YAML-NEXT:    - String:          ',
-; YAML-NEXT:  additionally '
+; YAML-NEXT:    - String:          ",\nadditionally "
 ; YAML-NEXT:    - NumStores:       '0'
 ; YAML-NEXT:    - String:          ' stores, '
 ; YAML-NEXT:    - NumLoads:        '4'

diff  --git a/llvm/unittests/Support/YAMLIOTest.cpp b/llvm/unittests/Support/YAMLIOTest.cpp
index d86489cf7560..492d854ef812 100644
--- a/llvm/unittests/Support/YAMLIOTest.cpp
+++ b/llvm/unittests/Support/YAMLIOTest.cpp
@@ -285,10 +285,8 @@ TEST(YAMLIO, MultilineStrings) {
     YOut << Original;
   }
   auto Expected = "---\n"
-                  "str1:            'a multiline string\n"
-                  "foobarbaz'\n"
-                  "str2:            'another one\r"
-                  "foobarbaz'\n"
+                  "str1:            \"a multiline string\\nfoobarbaz\"\n"
+                  "str2:            \"another one\\rfoobarbaz\"\n"
                   "str3:            a one-line string\n"
                   "...\n";
   ASSERT_EQ(Serialized, Expected);


        

From cfe-commits at lists.llvm.org  Thu Jul  9 02:42:27 2020
From: cfe-commits at lists.llvm.org (Dmitry Polukhin via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:42:27 +0000 (UTC)
Subject: [PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization
In-Reply-To: 
References: 
Message-ID: <5cc6df654594d2d6d4a58ae71c2b1e82@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e7fddbd36f5: [yaml][clang-tidy] Fix multiline YAML serialization (authored by DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80301/new/

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/unittests/Tooling/ReplacementsYamlTest.cpp
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/test/Transforms/LowerMatrixIntrinsics/remarks-shared-subtrees.ll
  llvm/unittests/Support/YAMLIOTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80301.276679.patch
Type: text/x-patch
Size: 5853 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 02:43:32 2020
From: cfe-commits at lists.llvm.org (Dmitry Polukhin via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:43:32 +0000 (UTC)
Subject: [PATCH] D80301: [yaml][clang-tidy] Fix multiline YAML serialization
In-Reply-To: 
References: 
Message-ID: <8c1f2b616e468bd2a3dc9395b93ce0ca@localhost.localdomain>

DmitryPolukhin added a comment.

@aaron.ballman - thank you for the review!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80301/new/

https://reviews.llvm.org/D80301




From cfe-commits at lists.llvm.org  Thu Jul  9 02:46:18 2020
From: cfe-commits at lists.llvm.org (Vaibhav Garg via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:46:18 +0000 (UTC)
Subject: [PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr
 attribute
In-Reply-To: 
References: 
Message-ID: <5de4eed8539609910b2a460f3cdac056@localhost.localdomain>

gargvaibhav64 updated this revision to Diff 276680.
gargvaibhav64 marked 3 inline comments as done.
gargvaibhav64 added a comment.

Added a new attribute instead of using the previous one


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83174/new/

https://reviews.llvm.org/D83174

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/inherit-attribute/a.h
  clang/test/Modules/Inputs/inherit-attribute/b.h
  clang/test/Modules/Inputs/inherit-attribute/c.h
  clang/test/Modules/Inputs/inherit-attribute/module.modulemap
  clang/test/Modules/inherit-attribute.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83174.276680.patch
Type: text/x-patch
Size: 3838 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 02:58:10 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:58:10 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: 

gribozavr2 added inline comments.


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:634
+    // `SourceLocation`s. As a result one of these nodes has a valid
+    // `SourceLocation` that doesn't point to a token.
+    //
----------------
eduucaldas wrote:
> gribozavr2 wrote:
> > "The semantic AST node for has child nodes that reference two source locations, the location of the beginning of the token (`1`), and the location of the beginning of the UDL suffix (`_`). The UDL suffix location does not point to the beginning of a token, so we can't represent the UDL suffix as a separate syntax tree node."
> I changed your comment slightly, WDYT
LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157




From cfe-commits at lists.llvm.org  Thu Jul  9 02:59:02 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 09:59:02 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: 

eduucaldas updated this revision to Diff 276681.
eduucaldas added a comment.

Document proposed solution for treating raw literal operators and numeric template operators


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276681.patch
Type: text/x-patch
Size: 13534 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:06:27 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 10:06:27 +0000 (UTC)
Subject: [PATCH] D69318: [analyzer] Add SufficientSizeArrayIndexingChecker
In-Reply-To: 
References: 
Message-ID: <4b23aeacc98b64bf78ee9875163ac8ef@localhost.localdomain>

balazske added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:27
+    : public Checker> {
+  mutable std::unique_ptr BT;
+
----------------
gamesh411 wrote:
> balazske wrote:
> > The bug type can be initialized here:
> > `BT{this, "...", "..."}`
> > How did this compile with only one text argument to constructor? I think the first is a short name of the bug, second is a category that is not omittable. The text that is used here should be passed to the `BugReport`. `BugType::getDescription` returns the "name" of the bug that is the first argument. But I am not sure what matters from these texts, the code design looks confusing.
> I think because it is initialized with a `BuiltinBug`, which must be a subclass of BugType. I don't really know what should be preferable nowadays, as this code was actually written more than a year ago. Thanks for pointing out that it can be initialized there, I think lazy initialization seems not that important with this particular checker.
I had even a plan to remove the `BuiltinBug` because it looks confusing and does not add real value. New checkers should use `BugType`.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/SufficientSizeArrayIndexingChecker.cpp:50
+  if (isa(Index->IgnoreParenCasts()))
+    return;
+
----------------
gamesh411 wrote:
> balazske wrote:
> > `if (isa(Index))` should be used. `IntegerLiteral` is a subclass of `Expr`, not a `QualType`.
> The way I have structured the code is very misleading, sorry for that, I will move the type extraction if lower, where it is actually used.
Probably function `SVB.getConstantVal` can be used to test if there is a (compile-time) constant passed to the index. But it may be value of a (const) variable.


================
Comment at: clang/test/Analysis/sufficient-size-array-indexing-32bit.c:37
+const short two_byte_signed_index = 1; // sizeof(short) == 2
+const int four_byte_signed_index = 1;  // sizeof(int) == 4
+
----------------
gamesh411 wrote:
> balazske wrote:
> > I do not know if it is safe to make such assumptions about `sizeof`.
> You are definitely right! However it is common as per:
> https://en.cppreference.com/w/cpp/language/types#Data_models
> ```
> Data models
> 
> The choices made by each implementation about the sizes of the fundamental types are collectively known as data model. Four data models found wide acceptance:
> 
> 32 bit systems:
> 
>         LP32 or 2/4/4 (int is 16-bit, long and pointer are 32-bit) 
> 
>             Win16 API 
> 
>         ILP32 or 4/4/4 (int, long, and pointer are 32-bit); 
> 
>             Win32 API
>             Unix and Unix-like systems (Linux, macOS) 
> 
> 64 bit systems:
> 
>         LLP64 or 4/4/8 (int and long are 32-bit, pointer is 64-bit) 
> 
>             Win64 API 
> 
>         LP64 or 4/8/8 (int is 32-bit, long and pointer are 64-bit) 
> 
>             Unix and Unix-like systems (Linux, macOS) 
> 
> Other models are very rare. For example, ILP64 (8/8/8: int, long, and pointer are 64-bit) only appeared in some early 64-bit Unix systems (e.g. Unicos on Cray). 
> ```
> Only ILP32 has 16 bit ints.
> Next idea would be to use fixed-width integer types from `cstdint`. But tests should not use system headers, and there are mentions in test files to `int32_t`, howevery they are just typedefs for int. And I think we maintaining a whole standard library headers is a bit too much a hassle.
Still it would be good to check if the test passes on all the buildbots.


================
Comment at: clang/test/Analysis/sufficient-size-array-indexing-32bit.c:48
+void ignore_literal_indexing_with_parens() {
+  char a = exactly_4byte_signed_range[(32)]; // nowarning
+}
----------------
Does this work in `[32 + 1]` case?


================
Comment at: clang/test/Analysis/sufficient-size-array-indexing-32bit.c:106
+    if (choice >= 1) {
+      c = f(choice)[four_byte_signed_index]; // nowarnining // the value is one or two, f returns an array that is correct in size
+    }
----------------
`choice` can be here only 1. If it could be 1 or 2 we should get no warning because the array size may be good or bad. But to test that it is enough that `choice` can have any value, like in `test_symbolic_index_handling4`.


================
Comment at: clang/test/Analysis/sufficient-size-array-indexing-32bit.c:120
+
+void test_symbolic_index_handling4(int choice) {
+  char c;
----------------
Here "is a chance that indexing is correct". So no warning should occur?


================
Comment at: clang/test/Analysis/sufficient-size-array-indexing-64bit.c:1
+// RUN: %clang_analyze_cc1 -triple x86_64 -analyzer-checker=core,alpha.core.SufficientSizeArrayIndexing %s -verify
+
----------------
I could not find difference between this and the previous test file (except the multi-dimensional arrays are omitted). It would be better to have a single test file without repetition. (Multiple RUN lines in a single file should work).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69318/new/

https://reviews.llvm.org/D69318




From cfe-commits at lists.llvm.org  Thu Jul  9 03:12:47 2020
From: cfe-commits at lists.llvm.org (Simon Pilgrim via cfe-commits)
Date: Thu, 09 Jul 2020 03:12:47 -0700 (PDT)
Subject: [clang] 397c682 - Fix MSVC "not all control paths return a value"
 warning. NFC.
Message-ID: <5f06ed9f.1c69fb81.b1f24.65a7@mx.google.com>


Author: Simon Pilgrim
Date: 2020-07-09T11:06:39+01:00
New Revision: 397c68202a990c80a71de2816cee413cd5b5865e

URL: https://github.com/llvm/llvm-project/commit/397c68202a990c80a71de2816cee413cd5b5865e
DIFF: https://github.com/llvm/llvm-project/commit/397c68202a990c80a71de2816cee413cd5b5865e.diff

LOG: Fix MSVC "not all control paths return a value" warning. NFC.

Added: 
    

Modified: 
    clang/lib/Tooling/Syntax/BuildTree.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 361455e69f5a..f9fdf47bff26 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -192,6 +192,7 @@ static syntax::NodeKind getOperatorNodeKind(const CXXOperatorCallExpr &E) {
   case OO_None:
     llvm_unreachable("Not an overloadable operator");
   }
+  llvm_unreachable("Unknown OverloadedOperatorKind enum");
 }
 
 /// Gets the range of declarator as defined by the C++ grammar. E.g.


        

From cfe-commits at lists.llvm.org  Thu Jul  9 03:13:30 2020
From: cfe-commits at lists.llvm.org (=?utf-8?b?QmFsb2doLCDDgWTDoW0gdmlhIFBoYWJyaWNhdG9y?= via cfe-commits)
Date: Thu, 09 Jul 2020 10:13:30 +0000 (UTC)
Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator
 checkers
In-Reply-To: 
References: 
Message-ID: <612a69ad3e06249840f8c97241900e36@localhost.localdomain>

baloghadamsoftware updated this revision to Diff 276684.
baloghadamsoftware edited the summary of this revision.
baloghadamsoftware added a comment.

Test added for the third fix in this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83295/new/

https://reviews.llvm.org/D83295

Files:
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/iterator-range.cpp


Index: clang/test/Analysis/iterator-range.cpp
===================================================================
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -935,3 +935,7 @@
           // expected-note at -1{{Iterator decremented ahead of its valid range}}
 }
 
+void ptr_iter_diff(cont_with_ptr_iterator &c) {
+  auto i0 = c.begin(), i1 = c.end();
+  ptrdiff_t len = i1 - i0; // no-crash
+}
Index: clang/test/Analysis/iterator-modeling.cpp
===================================================================
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1972,6 +1972,17 @@
   clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$c.end() - 2}}
 }
 
+void ptr_iter_diff(cont_with_ptr_iterator &c) {
+  auto i0 = c.begin(), i1 = c.end();
+  ptrdiff_t len = i1 - i0; // no-crash
+}
+
+void ptr_iter_cmp_nullptr(cont_with_ptr_iterator &c) {
+  auto i0 = c.begin();
+  if (i0 != nullptr) // no-crash
+    ++i0;
+}
+
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
Index: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -169,6 +169,8 @@
     verifyDereference(C, LVal);
   } else if (isRandomIncrOrDecrOperator(OK)) {
     SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     verifyRandomIncrOrDecr(C, BinaryOperator::getOverloadedOperator(OK), LVal,
                            RVal);
   }
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -272,6 +272,8 @@
     handleComparison(C, BO, Result, LVal, RVal,
                      BinaryOperator::getOverloadedOperator(OK));
   } else if (isRandomIncrOrDecrOperator(OK)) {
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     handlePtrIncrOrDecr(C, BO->getLHS(),
                         BinaryOperator::getOverloadedOperator(OK), RVal);
   }
@@ -461,6 +463,12 @@
     RPos = getIteratorPosition(State, RVal);
   }
 
+  // If the value for which we just tried to set a new iterator position is
+  // an `SVal`for which no iterator position can be set then the setting was
+  // unsuccessful. We cannot handle the comparison in this case.
+  if (!LPos || !RPos)
+    return;
+
   // We cannot make assumptions on `UnknownVal`. Let us conjure a symbol
   // instead.
   if (RetVal.isUnknown()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83295.276684.patch
Type: text/x-patch
Size: 2844 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:15:35 2020
From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:15:35 +0000 (UTC)
Subject: [PATCH] D81676: [MSP430] Align the toolchain definition with the TI's
 msp430-gcc v9.2.0
In-Reply-To: 
References: 
Message-ID: <4c963a520570e29a998d6034b2a8af94@localhost.localdomain>

atrosinenko updated this revision to Diff 276686.
atrosinenko added a comment.

Just add the test on `-rtlib=compiler-rt` handling as everything other is ready for basic clang_rt.builtins support.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81676/new/

https://reviews.llvm.org/D81676

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include-fixed/limits.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include/stddef.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/include/stdio.h
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o
  clang/test/Driver/msp430-toolchain.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81676.276686.patch
Type: text/x-patch
Size: 33945 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:30:03 2020
From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits)
Date: Thu, 09 Jul 2020 03:30:03 -0700 (PDT)
Subject: [clang-tools-extra] 6a3b10e - [change-namespace][NFC] Clean up
 joinNamespaces
Message-ID: <5f06f1ab.1c69fb81.8d274.6755@mx.google.com>


Author: Nathan James
Date: 2020-07-09T11:29:49+01:00
New Revision: 6a3b10e294feceb94064f32450de5c068a13dd03

URL: https://github.com/llvm/llvm-project/commit/6a3b10e294feceb94064f32450de5c068a13dd03
DIFF: https://github.com/llvm/llvm-project/commit/6a3b10e294feceb94064f32450de5c068a13dd03.diff

LOG: [change-namespace][NFC] Clean up joinNamespaces

Added: 
    

Modified: 
    clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
index e2a70db4102b..61ae7c4cc703 100644
--- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
+++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
@@ -19,14 +19,8 @@ namespace change_namespace {
 
 namespace {
 
-inline std::string
-joinNamespaces(const llvm::SmallVectorImpl &Namespaces) {
-  if (Namespaces.empty())
-    return "";
-  std::string Result(Namespaces.front());
-  for (auto I = Namespaces.begin() + 1, E = Namespaces.end(); I != E; ++I)
-    Result += ("::" + *I).str();
-  return Result;
+inline std::string joinNamespaces(ArrayRef Namespaces) {
+  return llvm::join(Namespaces, "::");
 }
 
 // Given "a::b::c", returns {"a", "b", "c"}.


        

From cfe-commits at lists.llvm.org  Thu Jul  9 03:44:48 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:44:48 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <34654c7883a4fc253511202324da6a3c@localhost.localdomain>

kbobyrev updated this revision to Diff 276692.
kbobyrev marked 15 inline comments as done.
kbobyrev added a comment.

Address post-LGTM round of comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276692.patch
Type: text/x-patch
Size: 41748 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:45:57 2020
From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:45:57 +0000 (UTC)
Subject: [PATCH] D81676: [MSP430] Align the toolchain definition with the TI's
 msp430-gcc v9.2.0
In-Reply-To: 
References: 
Message-ID: <10abf0e842d39ff540b8108b0b33df84@localhost.localdomain>

atrosinenko updated this revision to Diff 276693.
atrosinenko added a comment.

Just an automatic rebase to (possibly) fix failing "Apply patch" step.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81676/new/

https://reviews.llvm.org/D81676

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include-fixed/limits.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/include/stddef.h
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/include/stdio.h
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/crtn.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/430/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/exceptions/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/crt0.o
  clang/test/Driver/Inputs/basic_msp430_tree/msp430-elf/lib/large/full-memory-range/exceptions/crt0.o
  clang/test/Driver/msp430-toolchain.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81676.276693.patch
Type: text/x-patch
Size: 33940 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:54:50 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via cfe-commits)
Date: Thu, 09 Jul 2020 03:54:50 -0700 (PDT)
Subject: [clang-tools-extra] 93bb994 - [clangd] Implement path and URI
 translation for remote index
Message-ID: <5f06f77a.1c69fb81.cd384.73e4@mx.google.com>


Author: Kirill Bobyrev
Date: 2020-07-09T12:52:55+02:00
New Revision: 93bb9944cb577f0529636dc5acfba16026740962

URL: https://github.com/llvm/llvm-project/commit/93bb9944cb577f0529636dc5acfba16026740962
DIFF: https://github.com/llvm/llvm-project/commit/93bb9944cb577f0529636dc5acfba16026740962.diff

LOG: [clangd] Implement path and URI translation for remote index

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ormris, ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82938

Added: 
    

Modified: 
    clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
    clang-tools-extra/clangd/index/remote/Client.cpp
    clang-tools-extra/clangd/index/remote/Client.h
    clang-tools-extra/clangd/index/remote/Index.proto
    clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
    clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
    clang-tools-extra/clangd/index/remote/server/Server.cpp
    clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
    clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 3e25da385d7a..6fc844c18931 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -32,6 +32,9 @@ llvm::cl::opt IndexLocation(
 llvm::cl::opt
     ExecCommand("c", llvm::cl::desc("Command to execute and then exit"));
 
+llvm::cl::opt ProjectRoot("project-root",
+                                       llvm::cl::desc("Path to the project"));
+
 static constexpr char Overview[] = R"(
 This is an **experimental** interactive tool to process user-provided search
 queries over given symbol collection obtained via clangd-indexer. The
@@ -326,7 +329,8 @@ struct {
 
 std::unique_ptr openIndex(llvm::StringRef Index) {
   return Index.startswith("remote:")
-             ? remote::getClient(Index.drop_front(strlen("remote:")))
+             ? remote::getClient(Index.drop_front(strlen("remote:")),
+                                 ProjectRoot)
              : loadIndex(Index, /*UseDex=*/true);
 }
 

diff  --git a/clang-tools-extra/clangd/index/remote/Client.cpp b/clang-tools-extra/clangd/index/remote/Client.cpp
index c43afd2573a9..b46883193076 100644
--- a/clang-tools-extra/clangd/index/remote/Client.cpp
+++ b/clang-tools-extra/clangd/index/remote/Client.cpp
@@ -10,10 +10,12 @@
 
 #include "Client.h"
 #include "Index.grpc.pb.h"
+#include "index/Index.h"
 #include "index/Serialization.h"
 #include "marshalling/Marshalling.h"
 #include "support/Logger.h"
 #include "support/Trace.h"
+#include "llvm/ADT/StringRef.h"
 
 #include 
 
@@ -27,6 +29,16 @@ class IndexClient : public clangd::SymbolIndex {
   using StreamingCall = std::unique_ptr> (
       remote::SymbolIndex::Stub::*)(grpc::ClientContext *, const RequestT &);
 
+  template 
+  RequestT serializeRequest(ClangdRequestT Request) const {
+    return toProtobuf(Request);
+  }
+
+  template <>
+  FuzzyFindRequest serializeRequest(clangd::FuzzyFindRequest Request) const {
+    return toProtobuf(Request, ProjectRoot);
+  }
+
   template 
   bool streamRPC(ClangdRequestT Request,
@@ -34,7 +46,7 @@ class IndexClient : public clangd::SymbolIndex {
                  CallbackT Callback) const {
     bool FinalResult = false;
     trace::Span Tracer(RequestT::descriptor()->name());
-    const auto RPCRequest = toProtobuf(Request);
+    const auto RPCRequest = serializeRequest(Request);
     grpc::ClientContext Context;
     std::chrono::system_clock::time_point Deadline =
         std::chrono::system_clock::now() + DeadlineWaitingTime;
@@ -48,10 +60,11 @@ class IndexClient : public clangd::SymbolIndex {
         FinalResult = Reply.final_result();
         continue;
       }
-      auto Sym = fromProtobuf(Reply.stream_result(), &Strings);
-      if (!Sym)
+      auto Response =
+          fromProtobuf(Reply.stream_result(), &Strings, ProjectRoot);
+      if (!Response)
         elog("Received invalid {0}", ReplyT::descriptor()->name());
-      Callback(*Sym);
+      Callback(*Response);
     }
     SPAN_ATTACH(Tracer, "status", Reader->Finish().ok());
     return FinalResult;
@@ -59,9 +72,9 @@ class IndexClient : public clangd::SymbolIndex {
 
 public:
   IndexClient(
-      std::shared_ptr Channel,
+      std::shared_ptr Channel, llvm::StringRef ProjectRoot,
       std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
-      : Stub(remote::SymbolIndex::NewStub(Channel)),
+      : Stub(remote::SymbolIndex::NewStub(Channel)), ProjectRoot(ProjectRoot),
         DeadlineWaitingTime(DeadlineTime) {}
 
   void lookup(const clangd::LookupRequest &Request,
@@ -86,22 +99,26 @@ class IndexClient : public clangd::SymbolIndex {
             llvm::function_ref)
       const {}
 
-  // IndexClient does not take any space since the data is stored on the server.
+  // IndexClient does not take any space since the data is stored on the
+  // server.
   size_t estimateMemoryUsage() const { return 0; }
 
 private:
   std::unique_ptr Stub;
+  std::string ProjectRoot;
   // Each request will be terminated if it takes too long.
   std::chrono::milliseconds DeadlineWaitingTime;
 };
 
 } // namespace
 
-std::unique_ptr getClient(llvm::StringRef Address) {
+std::unique_ptr getClient(llvm::StringRef Address,
+                                               llvm::StringRef ProjectRoot) {
   const auto Channel =
       grpc::CreateChannel(Address.str(), grpc::InsecureChannelCredentials());
   Channel->GetState(true);
-  return std::unique_ptr(new IndexClient(Channel));
+  return std::unique_ptr(
+      new IndexClient(Channel, ProjectRoot));
 }
 
 } // namespace remote

diff  --git a/clang-tools-extra/clangd/index/remote/Client.h b/clang-tools-extra/clangd/index/remote/Client.h
index 9708fdbe851a..7b4173af6cfa 100644
--- a/clang-tools-extra/clangd/index/remote/Client.h
+++ b/clang-tools-extra/clangd/index/remote/Client.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REMOTE_INDEX_H
 
 #include "index/Index.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace clang {
 namespace clangd {
@@ -17,12 +18,16 @@ namespace remote {
 
 /// Returns an SymbolIndex client that passes requests to remote index located
 /// at \p Address. The client allows synchronous RPC calls.
+/// \p IndexRoot is an absolute path on the local machine to the source tree
+/// described by the remote index. Paths returned by the index will be treated
+/// as relative to this directory.
 ///
 /// This method attempts to resolve the address and establish the connection.
 ///
 /// \returns nullptr if the address is not resolved during the function call or
 /// if the project was compiled without Remote Index support.
-std::unique_ptr getClient(llvm::StringRef Address);
+std::unique_ptr getClient(llvm::StringRef Address,
+                                               llvm::StringRef IndexRoot);
 
 } // namespace remote
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto
index f3af29dcd588..99c4e3329d67 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -71,7 +71,7 @@ message Symbol {
   string name = 3;
   SymbolLocation definition = 4;
   string scope = 5;
-  SymbolLocation canonical_declarattion = 6;
+  SymbolLocation canonical_declaration = 6;
   int32 references = 7;
   uint32 origin = 8;
   string signature = 9;
@@ -99,7 +99,10 @@ message SymbolInfo {
 message SymbolLocation {
   Position start = 1;
   Position end = 2;
-  string file_uri = 3;
+  // clangd::SymbolLocation stores FileURI, but the protocol transmits a the
+  // relative path. Because paths are 
diff erent on the remote and local machines
+  // they will be translated in the marshalling layer.
+  string file_path = 3;
 }
 
 message Position {

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index e95132d000ec..db895bf039ba 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "Marshalling.h"
+#include "Headers.h"
 #include "Index.pb.h"
 #include "Protocol.h"
 #include "index/Serialization.h"
@@ -16,7 +17,13 @@
 #include "index/SymbolOrigin.h"
 #include "support/Logger.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
 
 namespace clang {
@@ -58,40 +65,66 @@ SymbolInfo toProtobuf(const clang::index::SymbolInfo &Info) {
   return Result;
 }
 
-clangd::SymbolLocation fromProtobuf(const SymbolLocation &Message,
-                                    llvm::UniqueStringSaver *Strings) {
+llvm::Optional
+fromProtobuf(const SymbolLocation &Message, llvm::UniqueStringSaver *Strings,
+             llvm::StringRef IndexRoot) {
   clangd::SymbolLocation Location;
+  auto URIString = relativePathToURI(Message.file_path(), IndexRoot);
+  if (!URIString)
+    return llvm::None;
+  Location.FileURI = Strings->save(*URIString).begin();
   Location.Start = fromProtobuf(Message.start());
   Location.End = fromProtobuf(Message.end());
-  Location.FileURI = Strings->save(Message.file_uri()).begin();
   return Location;
 }
 
-SymbolLocation toProtobuf(const clangd::SymbolLocation &Location) {
+llvm::Optional
+toProtobuf(const clangd::SymbolLocation &Location, llvm::StringRef IndexRoot) {
   remote::SymbolLocation Result;
+  auto RelativePath = uriToRelativePath(Location.FileURI, IndexRoot);
+  if (!RelativePath)
+    return llvm::None;
+  *Result.mutable_file_path() = *RelativePath;
   *Result.mutable_start() = toProtobuf(Location.Start);
   *Result.mutable_end() = toProtobuf(Location.End);
-  *Result.mutable_file_uri() = Location.FileURI;
   return Result;
 }
 
-HeaderWithReferences
-toProtobuf(const clangd::Symbol::IncludeHeaderWithReferences &IncludeHeader) {
+llvm::Optional
+toProtobuf(const clangd::Symbol::IncludeHeaderWithReferences &IncludeHeader,
+           llvm::StringRef IndexRoot) {
   HeaderWithReferences Result;
-  Result.set_header(IncludeHeader.IncludeHeader.str());
   Result.set_references(IncludeHeader.References);
+  const std::string Header = IncludeHeader.IncludeHeader.str();
+  if (isLiteralInclude(Header)) {
+    Result.set_header(Header);
+    return Result;
+  }
+  auto RelativePath = uriToRelativePath(Header, IndexRoot);
+  if (!RelativePath)
+    return llvm::None;
+  Result.set_header(*RelativePath);
   return Result;
 }
 
-clangd::Symbol::IncludeHeaderWithReferences
-fromProtobuf(const HeaderWithReferences &Message) {
-  return clangd::Symbol::IncludeHeaderWithReferences{Message.header(),
+llvm::Optional
+fromProtobuf(const HeaderWithReferences &Message,
+             llvm::UniqueStringSaver *Strings, llvm::StringRef IndexRoot) {
+  std::string Header = Message.header();
+  if (Header.front() != '<' && Header.front() != '"') {
+    auto URIString = relativePathToURI(Header, IndexRoot);
+    if (!URIString)
+      return llvm::None;
+    Header = *URIString;
+  }
+  return clangd::Symbol::IncludeHeaderWithReferences{Strings->save(Header),
                                                      Message.references()};
 }
 
 } // namespace
 
-clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request) {
+clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request,
+                                      llvm::StringRef IndexRoot) {
   clangd::FuzzyFindRequest Result;
   Result.Query = Request->query();
   for (const auto &Scope : Request->scopes())
@@ -100,24 +133,29 @@ clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request) {
   if (Request->limit())
     Result.Limit = Request->limit();
   Result.RestrictForCodeCompletion = Request->restricted_for_code_completion();
-  for (const auto &Path : Request->proximity_paths())
-    Result.ProximityPaths.push_back(Path);
+  for (const auto &Path : Request->proximity_paths()) {
+    llvm::SmallString<256> LocalPath = llvm::StringRef(IndexRoot);
+    llvm::sys::path::append(LocalPath, Path);
+    Result.ProximityPaths.push_back(std::string(LocalPath));
+  }
   for (const auto &Type : Request->preferred_types())
     Result.ProximityPaths.push_back(Type);
   return Result;
 }
 
 llvm::Optional fromProtobuf(const Symbol &Message,
-                                            llvm::UniqueStringSaver *Strings) {
+                                            llvm::UniqueStringSaver *Strings,
+                                            llvm::StringRef IndexRoot) {
   if (!Message.has_info() || !Message.has_definition() ||
-      !Message.has_canonical_declarattion()) {
-    elog("Cannot convert Symbol from Protobuf: {}", Message.ShortDebugString());
+      !Message.has_canonical_declaration()) {
+    elog("Cannot convert Symbol from Protobuf: {0}",
+         Message.ShortDebugString());
     return llvm::None;
   }
   clangd::Symbol Result;
   auto ID = SymbolID::fromStr(Message.id());
   if (!ID) {
-    elog("Cannot convert parse SymbolID {} from Protobuf: {}", ID.takeError(),
+    elog("Cannot parse SymbolID {0} given Protobuf: {1}", ID.takeError(),
          Message.ShortDebugString());
     return llvm::None;
   }
@@ -125,9 +163,15 @@ llvm::Optional fromProtobuf(const Symbol &Message,
   Result.SymInfo = fromProtobuf(Message.info());
   Result.Name = Message.name();
   Result.Scope = Message.scope();
-  Result.Definition = fromProtobuf(Message.definition(), Strings);
-  Result.CanonicalDeclaration =
-      fromProtobuf(Message.canonical_declarattion(), Strings);
+  auto Definition = fromProtobuf(Message.definition(), Strings, IndexRoot);
+  if (!Definition)
+    return llvm::None;
+  Result.Definition = *Definition;
+  auto Declaration =
+      fromProtobuf(Message.canonical_declaration(), Strings, IndexRoot);
+  if (!Declaration)
+    return llvm::None;
+  Result.CanonicalDeclaration = *Declaration;
   Result.References = Message.references();
   Result.Origin = static_cast(Message.origin());
   Result.Signature = Message.signature();
@@ -137,20 +181,26 @@ llvm::Optional fromProtobuf(const Symbol &Message,
   Result.ReturnType = Message.return_type();
   Result.Type = Message.type();
   for (const auto &Header : Message.headers()) {
-    Result.IncludeHeaders.push_back(fromProtobuf(Header));
+    auto SerializedHeader = fromProtobuf(Header, Strings, IndexRoot);
+    if (SerializedHeader)
+      Result.IncludeHeaders.push_back(*SerializedHeader);
   }
   Result.Flags = static_cast(Message.flags());
   return Result;
 }
 
 llvm::Optional fromProtobuf(const Ref &Message,
-                                         llvm::UniqueStringSaver *Strings) {
+                                         llvm::UniqueStringSaver *Strings,
+                                         llvm::StringRef IndexRoot) {
   if (!Message.has_location()) {
     elog("Cannot convert Ref from Protobuf: {}", Message.ShortDebugString());
     return llvm::None;
   }
   clangd::Ref Result;
-  Result.Location = fromProtobuf(Message.location(), Strings);
+  auto Location = fromProtobuf(Message.location(), Strings, IndexRoot);
+  if (!Location)
+    return llvm::None;
+  Result.Location = *Location;
   Result.Kind = static_cast(Message.kind());
   return Result;
 }
@@ -162,7 +212,8 @@ LookupRequest toProtobuf(const clangd::LookupRequest &From) {
   return RPCRequest;
 }
 
-FuzzyFindRequest toProtobuf(const clangd::FuzzyFindRequest &From) {
+FuzzyFindRequest toProtobuf(const clangd::FuzzyFindRequest &From,
+                            llvm::StringRef IndexRoot) {
   FuzzyFindRequest RPCRequest;
   RPCRequest.set_query(From.Query);
   for (const auto &Scope : From.Scopes)
@@ -171,8 +222,12 @@ FuzzyFindRequest toProtobuf(const clangd::FuzzyFindRequest &From) {
   if (From.Limit)
     RPCRequest.set_limit(*From.Limit);
   RPCRequest.set_restricted_for_code_completion(From.RestrictForCodeCompletion);
-  for (const auto &Path : From.ProximityPaths)
-    RPCRequest.add_proximity_paths(Path);
+  for (const auto &Path : From.ProximityPaths) {
+    llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
+    if (llvm::sys::path::replace_path_prefix(RelativePath, IndexRoot, ""))
+      RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
+          RelativePath, llvm::sys::path::Style::posix));
+  }
   for (const auto &Type : From.PreferredTypes)
     RPCRequest.add_preferred_types(Type);
   return RPCRequest;
@@ -188,15 +243,18 @@ RefsRequest toProtobuf(const clangd::RefsRequest &From) {
   return RPCRequest;
 }
 
-Symbol toProtobuf(const clangd::Symbol &From) {
+Symbol toProtobuf(const clangd::Symbol &From, llvm::StringRef IndexRoot) {
   Symbol Result;
   Result.set_id(From.ID.str());
   *Result.mutable_info() = toProtobuf(From.SymInfo);
   Result.set_name(From.Name.str());
-  *Result.mutable_definition() = toProtobuf(From.Definition);
+  auto Definition = toProtobuf(From.Definition, IndexRoot);
+  if (Definition)
+    *Result.mutable_definition() = *Definition;
   Result.set_scope(From.Scope.str());
-  *Result.mutable_canonical_declarattion() =
-      toProtobuf(From.CanonicalDeclaration);
+  auto Declaration = toProtobuf(From.CanonicalDeclaration, IndexRoot);
+  if (Declaration)
+    *Result.mutable_canonical_declaration() = *Declaration;
   Result.set_references(From.References);
   Result.set_origin(static_cast(From.Origin));
   Result.set_signature(From.Signature.str());
@@ -207,20 +265,82 @@ Symbol toProtobuf(const clangd::Symbol &From) {
   Result.set_return_type(From.ReturnType.str());
   Result.set_type(From.Type.str());
   for (const auto &Header : From.IncludeHeaders) {
+    auto Serialized = toProtobuf(Header, IndexRoot);
+    if (!Serialized)
+      continue;
     auto *NextHeader = Result.add_headers();
-    *NextHeader = toProtobuf(Header);
+    *NextHeader = *Serialized;
   }
   Result.set_flags(static_cast(From.Flags));
   return Result;
 }
 
-Ref toProtobuf(const clangd::Ref &From) {
+// FIXME(kirillbobyrev): A reference without location is invalid.
+// llvm::Optional here and on the server side?
+Ref toProtobuf(const clangd::Ref &From, llvm::StringRef IndexRoot) {
   Ref Result;
   Result.set_kind(static_cast(From.Kind));
-  *Result.mutable_location() = toProtobuf(From.Location);
+  auto Location = toProtobuf(From.Location, IndexRoot);
+  if (Location)
+    *Result.mutable_location() = *Location;
   return Result;
 }
 
+llvm::Optional relativePathToURI(llvm::StringRef RelativePath,
+                                              llvm::StringRef IndexRoot) {
+  assert(RelativePath == llvm::sys::path::convert_to_slash(
+                             RelativePath, llvm::sys::path::Style::posix));
+  assert(IndexRoot == llvm::sys::path::convert_to_slash(IndexRoot));
+  assert(IndexRoot.endswith(llvm::sys::path::get_separator()));
+  if (RelativePath.empty())
+    return std::string();
+  if (llvm::sys::path::is_absolute(RelativePath)) {
+    elog("Remote index client got absolute path from server: {0}",
+         RelativePath);
+    return llvm::None;
+  }
+  if (llvm::sys::path::is_relative(IndexRoot)) {
+    elog("Remote index client got a relative path as index root: {0}",
+         IndexRoot);
+    return llvm::None;
+  }
+  llvm::SmallString<256> FullPath = IndexRoot;
+  llvm::sys::path::append(FullPath, RelativePath);
+  auto Result = URI::createFile(FullPath);
+  return Result.toString();
+}
+
+llvm::Optional uriToRelativePath(llvm::StringRef URI,
+                                              llvm::StringRef IndexRoot) {
+  assert(IndexRoot.endswith(llvm::sys::path::get_separator()));
+  assert(IndexRoot == llvm::sys::path::convert_to_slash(IndexRoot));
+  assert(!IndexRoot.empty());
+  if (llvm::sys::path::is_relative(IndexRoot)) {
+    elog("Index root {0} is not absolute path", IndexRoot);
+    return llvm::None;
+  }
+  auto ParsedURI = URI::parse(URI);
+  if (!ParsedURI) {
+    elog("Remote index got bad URI from client {0}: {1}", URI,
+         ParsedURI.takeError());
+    return llvm::None;
+  }
+  if (ParsedURI->scheme() != "file") {
+    elog("Remote index got URI with scheme other than \"file\" {0}: {1}", URI,
+         ParsedURI->scheme());
+    return llvm::None;
+  }
+  llvm::SmallString<256> Result = ParsedURI->body();
+  if (!llvm::sys::path::replace_path_prefix(Result, IndexRoot, "")) {
+    elog("Can not get relative path from the URI {0} given the index root {1}",
+         URI, IndexRoot);
+    return llvm::None;
+  }
+  // Make sure the result has UNIX slashes.
+  return llvm::sys::path::convert_to_slash(Result,
+                                           llvm::sys::path::Style::posix);
+}
+
 } // namespace remote
 } // namespace clangd
 } // namespace clang

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
index 1bc25bf5a9de..86cc8fa272fc 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
@@ -6,7 +6,28 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// Transformations between native Clangd types and Protobuf-generated classes.
+// Marshalling provides translation between native clangd types into the
+// Protobuf-generated classes. Most translations are 1-to-1 and wrap variables
+// into appropriate Protobuf types.
+//
+// A notable exception is URI translation. Because paths to files are 
diff erent
+// on indexing machine and client machine
+// ("/remote/machine/projects/llvm-project/llvm/include/HelloWorld.h" versus
+// "/usr/local/username/llvm-project/llvm/include/HelloWorld.h"), they need to
+// be converted appropriately. Remote machine strips the prefix from the
+// absolute path and passes paths relative to the project root over the wire
+// ("include/HelloWorld.h" in this example). The indexed project root is passed
+// to the remote server. Client receives this relative path and constructs a URI
+// that points to the relevant file in the filesystem. The relative path is
+// appended to IndexRoot to construct the full path and build the final URI.
+//
+// Index root is the absolute path to the project and includes a trailing slash.
+// The relative path passed over the wire has unix slashes.
+//
+// toProtobuf() functions serialize native clangd types and strip IndexRoot from
+// the file paths specific to indexing machine. fromProtobuf() functions
+// deserialize clangd types and translate relative paths into machine-native
+// URIs.
 //
 //===----------------------------------------------------------------------===//
 
@@ -15,24 +36,40 @@
 
 #include "Index.pb.h"
 #include "index/Index.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/StringSaver.h"
 
 namespace clang {
 namespace clangd {
 namespace remote {
 
-clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request);
+clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request,
+                                      llvm::StringRef IndexRoot);
 llvm::Optional fromProtobuf(const Symbol &Message,
-                                            llvm::UniqueStringSaver *Strings);
+                                            llvm::UniqueStringSaver *Strings,
+                                            llvm::StringRef IndexRoot);
 llvm::Optional fromProtobuf(const Ref &Message,
-                                         llvm::UniqueStringSaver *Strings);
+                                         llvm::UniqueStringSaver *Strings,
+                                         llvm::StringRef IndexRoot);
 
 LookupRequest toProtobuf(const clangd::LookupRequest &From);
-FuzzyFindRequest toProtobuf(const clangd::FuzzyFindRequest &From);
+FuzzyFindRequest toProtobuf(const clangd::FuzzyFindRequest &From,
+                            llvm::StringRef IndexRoot);
 RefsRequest toProtobuf(const clangd::RefsRequest &From);
 
-Ref toProtobuf(const clangd::Ref &From);
-Symbol toProtobuf(const clangd::Symbol &From);
+Ref toProtobuf(const clangd::Ref &From, llvm::StringRef IndexRoot);
+Symbol toProtobuf(const clangd::Symbol &From, llvm::StringRef IndexRoot);
+
+/// Translates \p RelativePath into the absolute path and builds URI for the
+/// user machine. This translation happens on the client side with the
+/// \p RelativePath received from remote index server and \p IndexRoot is
+/// provided by the client.
+llvm::Optional relativePathToURI(llvm::StringRef RelativePath,
+                                              llvm::StringRef IndexRoot);
+/// Translates a URI from the server's backing index to a relative path suitable
+/// to send over the wire to the client.
+llvm::Optional uriToRelativePath(llvm::StringRef URI,
+                                              llvm::StringRef IndexRoot);
 
 } // namespace remote
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index 4d84eb17210e..718d623a4845 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -11,6 +11,7 @@
 #include "index/remote/marshalling/Marshalling.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
 
 #include 
@@ -31,6 +32,9 @@ awaits gRPC lookup requests from the client.
 llvm::cl::opt IndexPath(llvm::cl::desc(""),
                                      llvm::cl::Positional, llvm::cl::Required);
 
+llvm::cl::opt IndexRoot(llvm::cl::desc(""),
+                                     llvm::cl::Positional, llvm::cl::Required);
+
 llvm::cl::opt ServerAddress(
     "server-address", llvm::cl::init("0.0.0.0:50051"),
     llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
@@ -41,8 +45,13 @@ std::unique_ptr openIndex(llvm::StringRef Index) {
 
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index)
-      : Index(std::move(Index)) {}
+  RemoteIndexServer(std::unique_ptr Index,
+                    llvm::StringRef IndexRoot)
+      : Index(std::move(Index)) {
+    llvm::SmallString<256> NativePath = IndexRoot;
+    llvm::sys::path::native(NativePath);
+    IndexedProjectRoot = std::string(NativePath);
+  }
 
 private:
   grpc::Status Lookup(grpc::ServerContext *Context,
@@ -57,7 +66,8 @@ class RemoteIndexServer final : public SymbolIndex::Service {
     }
     Index->lookup(Req, [&](const clangd::Symbol &Sym) {
       LookupReply NextMessage;
-      *NextMessage.mutable_stream_result() = toProtobuf(Sym);
+      *NextMessage.mutable_stream_result() =
+          toProtobuf(Sym, IndexedProjectRoot);
       Reply->Write(NextMessage);
     });
     LookupReply LastMessage;
@@ -69,10 +79,11 @@ class RemoteIndexServer final : public SymbolIndex::Service {
   grpc::Status FuzzyFind(grpc::ServerContext *Context,
                          const FuzzyFindRequest *Request,
                          grpc::ServerWriter *Reply) override {
-    const auto Req = fromProtobuf(Request);
+    const auto Req = fromProtobuf(Request, IndexedProjectRoot);
     bool HasMore = Index->fuzzyFind(Req, [&](const clangd::Symbol &Sym) {
       FuzzyFindReply NextMessage;
-      *NextMessage.mutable_stream_result() = toProtobuf(Sym);
+      *NextMessage.mutable_stream_result() =
+          toProtobuf(Sym, IndexedProjectRoot);
       Reply->Write(NextMessage);
     });
     FuzzyFindReply LastMessage;
@@ -92,7 +103,7 @@ class RemoteIndexServer final : public SymbolIndex::Service {
     }
     bool HasMore = Index->refs(Req, [&](const clangd::Ref &Reference) {
       RefsReply NextMessage;
-      *NextMessage.mutable_stream_result() = toProtobuf(Reference);
+      *NextMessage.mutable_stream_result() = toProtobuf(Reference, IndexRoot);
       Reply->Write(NextMessage);
     });
     RefsReply LastMessage;
@@ -102,11 +113,12 @@ class RemoteIndexServer final : public SymbolIndex::Service {
   }
 
   std::unique_ptr Index;
+  std::string IndexedProjectRoot;
 };
 
 void runServer(std::unique_ptr Index,
                const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index));
+  RemoteIndexServer Service(std::move(Index), IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
   grpc::ServerBuilder Builder;
@@ -128,6 +140,11 @@ int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 
+  if (!llvm::sys::path::is_absolute(IndexRoot)) {
+    llvm::outs() << "Index root should be an absolute path.\n";
+    return -1;
+  }
+
   std::unique_ptr Index = openIndex(IndexPath);
 
   if (!Index) {

diff  --git a/clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp b/clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
index f0fb612f6332..a4d3127e0455 100644
--- a/clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
+++ b/clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
@@ -8,12 +8,14 @@
 
 #include "index/remote/Client.h"
 #include "support/Logger.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace clang {
 namespace clangd {
 namespace remote {
 
-std::unique_ptr getClient(llvm::StringRef Address) {
+std::unique_ptr getClient(llvm::StringRef Address,
+                                               llvm::StringRef IndexRoot) {
   elog("Can't create SymbolIndex client without Remote Index support.");
   return nullptr;
 }

diff  --git a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
index 8e68cfbdbeee..a14ff13150d3 100644
--- a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -7,85 +7,286 @@
 //===----------------------------------------------------------------------===//
 
 #include "../TestTU.h"
+#include "TestFS.h"
+#include "index/Index.h"
+#include "index/Ref.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
+#include "index/SymbolID.h"
 #include "index/remote/marshalling/Marshalling.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace clangd {
 namespace remote {
 namespace {
 
+using llvm::sys::path::convert_to_slash;
+
+const char *testPathURI(llvm::StringRef Path,
+                        llvm::UniqueStringSaver &Strings) {
+  auto URI = URI::createFile(testPath(Path));
+  return Strings.save(URI.toString()).begin();
+}
+
+TEST(RemoteMarshallingTest, URITranslation) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+  clangd::Ref Original;
+  Original.Location.FileURI =
+      testPathURI("remote/machine/projects/llvm-project/clang-tools-extra/"
+                  "clangd/unittests/remote/MarshallingTests.cpp",
+                  Strings);
+  auto Serialized =
+      toProtobuf(Original, testPath("remote/machine/projects/llvm-project/"));
+  EXPECT_EQ(Serialized.location().file_path(),
+            "clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp");
+  const std::string LocalIndexPrefix = testPath("local/machine/project/");
+  auto Deserialized = fromProtobuf(Serialized, &Strings,
+                                   testPath("home/my-projects/llvm-project/"));
+  EXPECT_TRUE(Deserialized);
+  EXPECT_EQ(Deserialized->Location.FileURI,
+            testPathURI("home/my-projects/llvm-project/clang-tools-extra/"
+                        "clangd/unittests/remote/MarshallingTests.cpp",
+                        Strings));
+
+  clangd::Ref WithInvalidURI;
+  // Invalid URI results in empty path.
+  WithInvalidURI.Location.FileURI = "This is not a URI";
+  Serialized = toProtobuf(WithInvalidURI, testPath("home/"));
+  EXPECT_EQ(Serialized.location().file_path(), "");
+
+  // Can not use URIs with scheme 
diff erent from "file".
+  auto UnittestURI =
+      URI::create(testPath("project/lib/HelloWorld.cpp"), "unittest");
+  EXPECT_TRUE(bool(UnittestURI));
+  WithInvalidURI.Location.FileURI =
+      Strings.save(UnittestURI->toString()).begin();
+  Serialized = toProtobuf(WithInvalidURI, testPath("project/lib/"));
+  EXPECT_EQ(Serialized.location().file_path(), "");
+
+  Ref WithAbsolutePath;
+  *WithAbsolutePath.mutable_location()->mutable_file_path() =
+      "/usr/local/user/home/HelloWorld.cpp";
+  Deserialized = fromProtobuf(WithAbsolutePath, &Strings, LocalIndexPrefix);
+  // Paths transmitted over the wire can not be absolute, they have to be
+  // relative.
+  EXPECT_FALSE(Deserialized);
+}
+
 TEST(RemoteMarshallingTest, SymbolSerialization) {
-  const auto *Header = R"(
-  // This is a class.
-  class Foo {
-  public:
-    Foo();
-
-    int Bar;
-  private:
-    double Number;
-  };
-  /// This is a function.
-  char baz();
-  template 
-  T getT ();
-  )";
-  const auto TU = TestTU::withHeaderCode(Header);
-  const auto Symbols = TU.headerSymbols();
-  // Sanity check: there are more than 5 symbols available.
-  EXPECT_GE(Symbols.size(), 5UL);
+  clangd::Symbol Sym;
+
+  auto ID = SymbolID::fromStr("057557CEBF6E6B2D");
+  EXPECT_TRUE(bool(ID));
+  Sym.ID = *ID;
+
+  index::SymbolInfo Info;
+  Info.Kind = index::SymbolKind::Function;
+  Info.SubKind = index::SymbolSubKind::AccessorGetter;
+  Info.Lang = index::SymbolLanguage::CXX;
+  Info.Properties = static_cast(
+      index::SymbolProperty::TemplateSpecialization);
+  Sym.SymInfo = Info;
+
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
-  for (auto &Sym : Symbols) {
-    const auto ProtobufMeessage = toProtobuf(Sym);
-    const auto SymToProtobufAndBack = fromProtobuf(ProtobufMeessage, &Strings);
-    EXPECT_TRUE(SymToProtobufAndBack.hasValue());
-    EXPECT_EQ(toYAML(Sym), toYAML(*SymToProtobufAndBack));
-  }
+
+  Sym.Name = Strings.save("Foo");
+  Sym.Scope = Strings.save("llvm::foo::bar::");
+
+  clangd::SymbolLocation Location;
+  Location.Start.setLine(1);
+  Location.Start.setColumn(15);
+  Location.End.setLine(3);
+  Location.End.setColumn(121);
+  Location.FileURI = testPathURI("home/Definition.cpp", Strings);
+  Sym.Definition = Location;
+
+  Location.Start.setLine(42);
+  Location.Start.setColumn(31);
+  Location.End.setLine(20);
+  Location.End.setColumn(400);
+  Location.FileURI = testPathURI("home/Declaration.h", Strings);
+  Sym.CanonicalDeclaration = Location;
+
+  Sym.References = 9000;
+  Sym.Origin = clangd::SymbolOrigin::Static;
+  Sym.Signature = Strings.save("(int X, char Y, Type T)");
+  Sym.TemplateSpecializationArgs = Strings.save("");
+  Sym.CompletionSnippetSuffix =
+      Strings.save("({1: int X}, {2: char Y}, {3: Type T})");
+  Sym.Documentation = Strings.save("This is my amazing Foo constructor!");
+  Sym.ReturnType = Strings.save("Foo");
+
+  Sym.Flags = clangd::Symbol::SymbolFlag::IndexedForCodeCompletion;
+
+  // Check that symbols are exactly the same if the path to indexed project is
+  // the same on indexing machine and the client.
+  auto Serialized = toProtobuf(Sym, testPath("home/"));
+  auto Deserialized = fromProtobuf(Serialized, &Strings, testPath("home/"));
+  EXPECT_TRUE(Deserialized);
+  EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
+  // Serialized paths are relative and have UNIX slashes.
+  EXPECT_EQ(convert_to_slash(Serialized.definition().file_path(),
+                             llvm::sys::path::Style::posix),
+            Serialized.definition().file_path());
+  EXPECT_TRUE(
+      llvm::sys::path::is_relative(Serialized.definition().file_path()));
+
+  // Fail with an invalid URI.
+  Location.FileURI = "Not A URI";
+  Sym.Definition = Location;
+  Serialized = toProtobuf(Sym, testPath("home/"));
+  Deserialized = fromProtobuf(Serialized, &Strings, testPath("home/"));
+  EXPECT_FALSE(Deserialized);
+
+  // Schemes other than "file" can not be used.
+  auto UnittestURI = URI::create(testPath("home/SomePath.h"), "unittest");
+  EXPECT_TRUE(bool(UnittestURI));
+  Location.FileURI = Strings.save(UnittestURI->toString()).begin();
+  Sym.Definition = Location;
+  Serialized = toProtobuf(Sym, testPath("home/"));
+  Deserialized = fromProtobuf(Serialized, &Strings, testPath("home/"));
+  EXPECT_FALSE(Deserialized);
+
+  // Passing root that is not prefix of the original file path.
+  Location.FileURI = testPathURI("home/File.h", Strings);
+  Sym.Definition = Location;
+  // Check that the symbol is valid and passing the correct path works.
+  Serialized = toProtobuf(Sym, testPath("home/"));
+  Deserialized = fromProtobuf(Serialized, &Strings, testPath("home/"));
+  EXPECT_TRUE(Deserialized);
+  EXPECT_EQ(Deserialized->Definition.FileURI,
+            testPathURI("home/File.h", Strings));
+  // Fail with a wrong root.
+  Serialized = toProtobuf(Sym, testPath("nothome/"));
+  Deserialized = fromProtobuf(Serialized, &Strings, testPath("home/"));
+  EXPECT_FALSE(Deserialized);
 }
 
-TEST(RemoteMarshallingTest, ReferenceSerialization) {
-  TestTU TU;
-  TU.HeaderCode = R"(
-  int foo();
-  int GlobalVariable = 42;
-  class Foo {
-  public:
-    Foo();
-
-    char Symbol = 'S';
-  };
-  template 
-  T getT() { return T(); }
-  )";
-  TU.Code = R"(
-  int foo() {
-    ++GlobalVariable;
-
-    Foo foo = Foo();
-    if (foo.Symbol - 'a' == 42) {
-      foo.Symbol = 'b';
-    }
-
-    const auto bar = getT();
-  }
-  )";
-  const auto References = TU.headerRefs();
+TEST(RemoteMarshallingTest, RefSerialization) {
+  clangd::Ref Ref;
+  Ref.Kind = clangd::RefKind::Spelled | clangd::RefKind::Declaration;
+
   llvm::BumpPtrAllocator Arena;
   llvm::UniqueStringSaver Strings(Arena);
-  // Sanity check: there are more than 5 references available.
-  EXPECT_GE(References.numRefs(), 5UL);
-  for (const auto &SymbolWithRefs : References) {
-    for (const auto &Ref : SymbolWithRefs.second) {
-      const auto RefToProtobufAndBack = fromProtobuf(toProtobuf(Ref), &Strings);
-      EXPECT_TRUE(RefToProtobufAndBack.hasValue());
-      EXPECT_EQ(toYAML(Ref), toYAML(*RefToProtobufAndBack));
-    }
-  }
-} // namespace
+
+  clangd::SymbolLocation Location;
+  Location.Start.setLine(124);
+  Location.Start.setColumn(21);
+  Location.End.setLine(3213);
+  Location.End.setColumn(541);
+  Location.FileURI = testPathURI(
+      "llvm-project/llvm/clang-tools-extra/clangd/Protocol.h", Strings);
+  Ref.Location = Location;
+
+  auto Serialized = toProtobuf(Ref, testPath("llvm-project/"));
+  auto Deserialized =
+      fromProtobuf(Serialized, &Strings, testPath("llvm-project/"));
+  EXPECT_TRUE(Deserialized);
+  EXPECT_EQ(toYAML(Ref), toYAML(*Deserialized));
+}
+
+TEST(RemoteMarshallingTest, IncludeHeaderURIs) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+
+  llvm::SmallVector
+      ValidHeaders;
+  clangd::Symbol::IncludeHeaderWithReferences Header;
+  Header.IncludeHeader = Strings.save(
+      URI::createFile("/usr/local/user/home/project/Header.h").toString());
+  Header.References = 21;
+  ValidHeaders.push_back(Header);
+  Header.IncludeHeader = Strings.save("");
+  Header.References = 100;
+  ValidHeaders.push_back(Header);
+  Header.IncludeHeader = Strings.save("\"cstdio\"");
+  Header.References = 200;
+  ValidHeaders.push_back(Header);
+
+  llvm::SmallVector
+      InvalidHeaders;
+  // This is an absolute path to a header: can not be transmitted over the wire.
+  Header.IncludeHeader = Strings.save(testPath("project/include/Common.h"));
+  Header.References = 42;
+  InvalidHeaders.push_back(Header);
+  // This is not a valid header: can not be transmitted over the wire;
+  Header.IncludeHeader = Strings.save("NotAHeader");
+  Header.References = 5;
+  InvalidHeaders.push_back(Header);
+
+  clangd::Symbol Sym;
+  // Fill in definition and declaration, Symbool will be invalid otherwise.
+  clangd::SymbolLocation Location;
+  Location.Start.setLine(1);
+  Location.Start.setColumn(2);
+  Location.End.setLine(3);
+  Location.End.setColumn(4);
+  Location.FileURI = testPathURI("File.h", Strings);
+  Sym.Definition = Location;
+  Sym.CanonicalDeclaration = Location;
+
+  // Try to serialize all headers but only valid ones will end up in Protobuf
+  // message.
+  auto AllHeaders = ValidHeaders;
+  AllHeaders.insert(AllHeaders.end(), InvalidHeaders.begin(),
+                    InvalidHeaders.end());
+  Sym.IncludeHeaders = AllHeaders;
+
+  auto Serialized = toProtobuf(Sym, convert_to_slash("/"));
+  EXPECT_EQ(static_cast(Serialized.headers_size()),
+            ValidHeaders.size());
+  auto Deserialized = fromProtobuf(Serialized, &Strings, convert_to_slash("/"));
+  EXPECT_TRUE(Deserialized);
+
+  Sym.IncludeHeaders = ValidHeaders;
+  EXPECT_EQ(toYAML(Sym), toYAML(*Deserialized));
+}
+
+TEST(RemoteMarshallingTest, FuzzyFindRequestSerialization) {
+  clangd::FuzzyFindRequest Request;
+  Request.ProximityPaths = {testPath("remote/Header.h"),
+                            testPath("remote/subdir/OtherHeader.h"),
+                            testPath("notremote/File.h"), "Not a Path."};
+  auto Serialized = toProtobuf(Request, testPath("remote/"));
+  EXPECT_EQ(Serialized.proximity_paths_size(), 2);
+  auto Deserialized = fromProtobuf(&Serialized, testPath("home/"));
+  EXPECT_THAT(Deserialized.ProximityPaths,
+              testing::ElementsAre(testPath("home/Header.h"),
+                                   testPath("home/subdir/OtherHeader.h")));
+}
+
+TEST(RemoteMarshallingTest, RelativePathToURITranslation) {
+  EXPECT_TRUE(relativePathToURI("lib/File.cpp", testPath("home/project/")));
+  // RelativePath can not be absolute.
+  EXPECT_FALSE(relativePathToURI("/lib/File.cpp", testPath("home/project/")));
+  // IndexRoot has to be absolute path.
+  EXPECT_FALSE(relativePathToURI("lib/File.cpp", "home/project/"));
+}
+
+TEST(RemoteMarshallingTest, URIToRelativePathTranslation) {
+  llvm::BumpPtrAllocator Arena;
+  llvm::UniqueStringSaver Strings(Arena);
+  EXPECT_TRUE(
+      uriToRelativePath(testPathURI("home/project/lib/File.cpp", Strings),
+                        testPath("home/project/")));
+  // IndexRoot has to be absolute path.
+  EXPECT_FALSE(uriToRelativePath(
+      testPathURI("home/project/lib/File.cpp", Strings), "home/project/"));
+  // IndexRoot has to be be a prefix of the file path.
+  EXPECT_FALSE(
+      uriToRelativePath(testPathURI("home/project/lib/File.cpp", Strings),
+                        testPath("home/other/project/")));
+}
 
 } // namespace
 } // namespace remote


        

From cfe-commits at lists.llvm.org  Thu Jul  9 03:54:52 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:54:52 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG93bb9944cb57: [clangd] Implement path and URI translation for remote index (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Client.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.h
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82938.276698.patch
Type: text/x-patch
Size: 41748 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:55:41 2020
From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:55:41 +0000 (UTC)
Subject: [PATCH] D82938: [clangd] Implement path and URI translation for
 remote index
In-Reply-To: 
References: 
Message-ID: <7a48c7730f96d87ee6550f151f5b6d46@localhost.localdomain>

kbobyrev marked an inline comment as done.
kbobyrev added inline comments.


================
Comment at: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp:64
+  if (ParsedURI->scheme() != "file") {
+    elog("Can not parse URI with scheme other than \"file\" {0}", URI);
+    return llvm::None;
----------------
sammccall wrote:
> I think it's fine to fold this into the previous check: "bad URI" covers it
But it has different message :( `ParsedURI.takeError` wouldn't make sense here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82938/new/

https://reviews.llvm.org/D82938




From cfe-commits at lists.llvm.org  Thu Jul  9 03:57:46 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:57:46 +0000 (UTC)
Subject: [PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of
 RecoveryExpr.
In-Reply-To: 
References: 
Message-ID: <177b5e1fcb9ef2fa7bee13f958ae35a5@localhost.localdomain>

hokein updated this revision to Diff 276700.
hokein marked 4 inline comments as done.
hokein added a comment.

refine the doc based on the review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83215/new/

https://reviews.llvm.org/D83215

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19210,9 +19210,6 @@
 
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
                                     ArrayRef SubExprs, QualType T) {
-  // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
-  // bogus diagnostics and this trick does not work in C.
-  // FIXME: use containsErrors() to suppress unwanted diags in C.
   if (!Context.getLangOpts().RecoveryAST)
     return ExprError();
 
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -495,11 +495,21 @@
 }
 
 ExprDependence clang::computeDependence(RecoveryExpr *E) {
-  // Mark the expression as value- and instantiation- dependent to reuse
-  // existing suppressions for dependent code, e.g. avoiding
-  // constant-evaluation.
-  // FIXME: drop type+value+instantiation once Error is sufficient to suppress
-  // bogus dianostics.
+  // A dependent expression (typically in template context) can behave
+  // differently from one instantiation to another. The dependence-bits describe
+  // how an expression depends on a template parameter.
+  //
+  // We generalize the "dependent" to mean "depends on a template parameter, or
+  // an error".
+  //
+  // RecoveryExpression is
+  //  - always contains-errors: the expression depends on an error;
+  //  - always value-dependent: we never know the value, the value can be
+  //    different or unknown depending on how the error is resolved;
+  //  - always instantiation-dependent: historically, this bit is used to
+  //    determine whether an expression is dependent;
+  //  - type dependent if we don't know the type (fallback to an opequa
+  //    dependent type), or the type is known and dependent;
   auto D = toExprDependence(E->getType()->getDependence()) |
            ExprDependence::ValueInstantiation | ExprDependence::Error;
   for (auto *S : E->subExpressions())
Index: clang/include/clang/AST/Expr.h
===================================================================
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -6212,19 +6212,22 @@
 /// subexpressions of some expression that we could not construct and source
 /// range covered by the expression.
 ///
-/// By default, RecoveryExpr is type-, value- and instantiation-dependent to
-/// take advantage of existing machinery to deal with dependent code in C++,
-/// e.g. RecoveryExpr is preserved in `decltype()` as part of the
-/// `DependentDecltypeType`. In addition to that, clang does not report most
-/// errors on dependent expressions, so we get rid of bogus errors for free.
-/// However, note that unlike other dependent expressions, RecoveryExpr can be
-/// produced in non-template contexts.
-/// In addition, we will preserve the type in RecoveryExpr when the type is
-/// known, e.g. preserving the return type for a broken non-overloaded function
-/// call, a overloaded call where all candidates have the same return type.
+/// By default, RecoveryExpr uses dependence-bits to take advantage of existing
+/// machinery to deal with dependent code in C++, e.g. RecoveryExpr is preserved
+/// in `decltype()` as part of the `DependentDecltypeType`. In
+/// addition to that, clang does not report most errors on dependent
+/// expressions, so we get rid of bogus errors for free. However, note that
+/// unlike other dependent expressions, RecoveryExpr can be produced in
+/// non-template contexts. In addition, we will preserve the type in
+/// RecoveryExpr when the type is known, e.g. preserving the return type for a
+/// broken non-overloaded function call, a overloaded call where all candidates
+/// have the same return type.
 ///
 /// One can also reliably suppress all bogus errors on expressions containing
 /// recovery expressions by examining results of Expr::containsErrors().
+///
+/// FIXME: RecoveryExpr is currently generated by default in C++ mode only, as
+/// dependence isn't handled properly on several C-only codepaths.
 class RecoveryExpr final : public Expr,
                            private llvm::TrailingObjects {
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83215.276700.patch
Type: text/x-patch
Size: 4401 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 03:58:29 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 10:58:29 +0000 (UTC)
Subject: [PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of
 RecoveryExpr.
In-Reply-To: 
References: 
Message-ID: <0720ee73cf9196f58601ad13342e3a0b@localhost.localdomain>

hokein added inline comments.


================
Comment at: clang/lib/AST/ComputeDependence.cpp:498
 ExprDependence clang::computeDependence(RecoveryExpr *E) {
-  // Mark the expression as value- and instantiation- dependent to reuse
-  // existing suppressions for dependent code, e.g. avoiding
-  // constant-evaluation.
-  // FIXME: drop type+value+instantiation once Error is sufficient to suppress
-  // bogus dianostics.
+  // RecoveryExpr dependence-bits setting:
+  //   - type-dep is set if we don't know about the type (fallback to an opaque
----------------
sammccall wrote:
> I can't really follow this explanation.
> - The first bullet  says when, the other two bullets say why
> - the reasons given don't seem to be very principled ones (e.g. suppressing constant-evaluation is indeed a nice effect of value-dependency, but I don't think it's the *reason* for the value-dependency, rather that the value depends on how the error is resolved)
> - I don't understand the connection between the "setting" list and the "explanations" one.
> 
> 
sorry for the confusion. I have refined the doc, hope it is clearer now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83215/new/

https://reviews.llvm.org/D83215




From cfe-commits at lists.llvm.org  Thu Jul  9 04:03:09 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 11:03:09 +0000 (UTC)
Subject: [PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts.
In-Reply-To: 
References: 
Message-ID: 

ebevhan marked an inline comment as done.
ebevhan added inline comments.


================
Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3603-3604
   auto ResultFixedSema = Ctx.getFixedPointSemantics(ResultTy);
-  auto CommonFixedSema = LHSFixedSema.getCommonSemantics(RHSFixedSema, true);
+  auto CommonFixedSema = LHSFixedSema.getCommonSemantics(
+      IsShift ? LHSFixedSema : RHSFixedSema, true);
 
----------------
leonardchan wrote:
> Could this instead be:
> 
> ```
> auto CommonFixedSema = IsShift ? LHSFixedSema : LHSFixedSema.getCommonSemantics(RHSFixedSema, true);
> ```
> 
> 
In theory, yes, but I'm sort of piggybacking off of D82663, and for the signedness to be correct we need to get the 'common' semantic even in the shift case.


================
Comment at: clang/test/Frontend/fixed_point_compound.c:384
+  // CHECK-NEXT:    [[TMP4:%.*]] = load i16, i16* @suf, align 2
+  // CHECK-NEXT:    [[TMP5:%.*]] = trunc i32 [[TMP3]] to i16
+  // SIGNED-NEXT:   [[TMP6:%.*]] = call i16 @llvm.ushl.sat.i16(i16 [[TMP4]], i16 [[TMP5]])
----------------
leonardchan wrote:
> This seems very unlikely, but if `i` in this case was a value at least 2^16, the upper half would be cut off and we'd potentially shift by an improper amount for some values of `i` when we should actually clamp to the max value. We should probably still   find the common semantics for both sides if we're doing a shift.
If the value is so large to be cut off by that truncation then the value is greater than the bitwidth, which is UB. So I don't think it's an issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83294/new/

https://reviews.llvm.org/D83294




From cfe-commits at lists.llvm.org  Thu Jul  9 04:08:48 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 11:08:48 +0000 (UTC)
Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.
In-Reply-To: 
References: 
Message-ID: <45c0a8d0cdc78453cb21ebee7f1513ed@localhost.localdomain>

hokein added a comment.

I think this depends on how we interpret the instantiation-dependent bit. In clang, it currently has two semantics:

1. an expression (somehow) depends on a template parameter;
2. an expression is dependent;

Prior to RecoveryExpression being added, 1 and 2 are equal, so we use `isInstantiationDependent` to check whether the code is dependent. This is fine.

However since we now generalize the "dependent" concept to mean "depends on a template parameter, or an error", checking `isInstantiationDependent()` is incomplete to determine the code is dependent.

what we could do?

**Option 1** (what this patch does):

instantiation-dependence still  implies the expression involves a template parameter -- if a recovery expression doesn't involves a template parameter, we don't set this flag

pros:

- avoid unnecessary instantiations if an AST node doesn't depend on template parameters but contain errorss;
- more precise semantics (maybe for better error-tracking, diagnostics), we can express a recovery-expr involves a template parameter (`contains-errors` + `instantiation-dep`), or not (`contains-erros` + `no instantiation-dep`)

cons:

- as you mentioned above, we violate the "nothing can be dependent if it is not instantiation dependent" assumption, which may leads us to fix a long tail of bugs (high effort), and the fix is basically adding `containsErrors` to where `isInstantiaionDependent` is used.

This makes me feel like we're going back to "use containsErrors everywhere" solution. Not sure what pros would buy us, maybe it is not worth the effort.

**Option 2**:

Keep it as it-is now, always set it, then the `instantiation-dependent` would mean "an expression depends on a template parameter or an error".

pros:

- everything would work without changing anything!

cons:

- keep using the instantiation name is confusing; we could do clarify the document of isInstantiation

While writing this, I'm starting to like the option2, any other thoughts?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83213/new/

https://reviews.llvm.org/D83213




From cfe-commits at lists.llvm.org  Thu Jul  9 04:32:42 2020
From: cfe-commits at lists.llvm.org (Manuel Klimek via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 11:32:42 +0000 (UTC)
Subject: [PATCH] D79773: [clang-format] Improve clang-formats handling of
 concepts
In-Reply-To: 
References: 
Message-ID: <6d195e1155ce32dfa70c75b46f19b7f0@localhost.localdomain>

klimek added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:631-636
+  else if (FormatTok->is(tok::arrow)) {
+    // Following the } we can find a trailing return type arrow
+    // as part of an implicit conversion constraint.
+    nextToken();
+    parseStructuralElement();
+  }
----------------
I'd have expected this to be just in front of line 629 (if... tok::semi) - does that break something? Don't we want to munch the semi after this?


================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2314
+      nextToken();
+      if (FormatTok->Tok.is(tok::less)) {
+        while (!FormatTok->Tok.is(tok::greater)) {
----------------
MyDeveloperDay wrote:
> miscco wrote:
> > miscco wrote:
> > > I guess you could use `parseBracedList(/*ContinueOnSemicolons=*/false, /*IsEnum=*/false,/*ClosingBraceKind=*/tok::greater);` here?
> > To be more specific, I am concerned what happens if you have multiple template arguments where a linebreak should occur. Is this still happening here?
> > 
> > 
> > ```
> > template 
> > concept someVeryLongConceptName = someVeryLongConstraintName1;
> > ```
> This is formatted as
> 
> ```
> template 
> concept someVeryLongConceptName =
>     someVeryLongConstraintName1;
> ```
This seems like a very detailed way to parse them; generally, we try to only parse rough structure here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79773/new/

https://reviews.llvm.org/D79773




From cfe-commits at lists.llvm.org  Thu Jul  9 04:40:58 2020
From: cfe-commits at lists.llvm.org (Alex Bradbury via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 11:40:58 +0000 (UTC)
Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20
 [[no_unique_address]] attribute
In-Reply-To: 
References: 
Message-ID: <3ff8cb25ba83d4b7ca0972c52fd91659@localhost.localdomain>

asb added a comment.

This LGTM from a RISC-V perspective. I'll likely follow up with a RISC-V test case similar to the SystemZ one post-commit, but given this is really fixing a cross-platform ABI issue this seems non-urgent. Thanks for spotting and addressing this issue.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81583/new/

https://reviews.llvm.org/D81583




From cfe-commits at lists.llvm.org  Thu Jul  9 04:52:10 2020
From: cfe-commits at lists.llvm.org (Benjamin Kramer via cfe-commits)
Date: Thu, 09 Jul 2020 04:52:10 -0700 (PDT)
Subject: [clang] b444705 - Make helpers static. NFC.
Message-ID: <5f0704ea.1c69fb81.bc5dc.6de0@mx.google.com>


Author: Benjamin Kramer
Date: 2020-07-09T13:48:56+02:00
New Revision: b44470547e2ec8a52abb67c3f538ecc49ee27970

URL: https://github.com/llvm/llvm-project/commit/b44470547e2ec8a52abb67c3f538ecc49ee27970
DIFF: https://github.com/llvm/llvm-project/commit/b44470547e2ec8a52abb67c3f538ecc49ee27970.diff

LOG: Make helpers static. NFC.

Added: 
    

Modified: 
    clang/lib/AST/ASTImporter.cpp
    clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
    llvm/lib/IR/AutoUpgrade.cpp
    llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
    llvm/lib/Target/X86/X86ISelLowering.cpp
    llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
    llvm/lib/Transforms/Vectorize/VectorCombine.cpp
    mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
    mlir/lib/Dialect/Affine/IR/AffineOps.cpp
    mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
    mlir/test/lib/Transforms/TestLinalgTransforms.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 8ec6db622f0a..fa2421ee826e 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3655,9 +3655,9 @@ struct FriendCountAndPosition {
 };
 
 template 
-FriendCountAndPosition getFriendCountAndPosition(
+static FriendCountAndPosition getFriendCountAndPosition(
     const FriendDecl *FD,
-    std::function GetCanTypeOrDecl) {
+    llvm::function_ref GetCanTypeOrDecl) {
   unsigned int FriendCount = 0;
   llvm::Optional FriendPosition;
   const auto *RD = cast(FD->getLexicalDeclContext());
@@ -3679,7 +3679,7 @@ FriendCountAndPosition getFriendCountAndPosition(
   return {FriendCount, *FriendPosition};
 }
 
-FriendCountAndPosition getFriendCountAndPosition(const FriendDecl *FD) {
+static FriendCountAndPosition getFriendCountAndPosition(const FriendDecl *FD) {
   if (FD->getFriendType())
     return getFriendCountAndPosition(FD, [](const FriendDecl *F) {
       if (TypeSourceInfo *TSI = F->getFriendType())

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 29393c2ca02b..8b575f4f4759 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -726,7 +726,8 @@ StdLibraryFunctionsChecker::findFunctionSummary(const CallEvent &Call,
   return findFunctionSummary(FD, C);
 }
 
-llvm::Optional lookupType(StringRef Name, const ASTContext &ACtx) {
+static llvm::Optional lookupType(StringRef Name,
+                                           const ASTContext &ACtx) {
   IdentifierInfo &II = ACtx.Idents.get(Name);
   auto LookupRes = ACtx.getTranslationUnitDecl()->lookup(&II);
   if (LookupRes.size() == 0)

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 3179cb5b4e36..1e8fdb506619 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4167,7 +4167,7 @@ void llvm::UpgradeSectionAttributes(Module &M) {
   }
 }
 
-
+namespace {
 // Prior to LLVM 10.0, the strictfp attribute could be used on individual
 // callsites within a function that did not also have the strictfp attribute.
 // Since 10.0, if strict FP semantics are needed within a function, the
@@ -4185,7 +4185,7 @@ struct StrictFPUpgradeVisitor : public InstVisitor {
   void visitCallBase(CallBase &Call) {
     if (!Call.isStrictFP())
       return;
-    if (dyn_cast(&Call))
+    if (isa(&Call))
       return;
     // If we get here, the caller doesn't have the strictfp attribute
     // but this callsite does. Replace the strictfp attribute with nobuiltin.
@@ -4193,6 +4193,7 @@ struct StrictFPUpgradeVisitor : public InstVisitor {
     Call.addAttribute(AttributeList::FunctionIndex, Attribute::NoBuiltin);
   }
 };
+} // namespace
 
 void llvm::UpgradeFunctionAttributes(Function &F) {
   // If a function definition doesn't have the strictfp attribute,

diff  --git a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
index 9cdacb64c4f4..a58e8f6d9bcc 100644
--- a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp
@@ -47,7 +47,7 @@ void MCDisassembler::setSymbolizer(std::unique_ptr Symzer) {
   case XCOFF::XMC_##A:                                                         \
     return P;
 
-uint8_t getSMCPriority(XCOFF::StorageMappingClass SMC) {
+static uint8_t getSMCPriority(XCOFF::StorageMappingClass SMC) {
   switch (SMC) {
     SMC_PCASE(PR, 1)
     SMC_PCASE(RO, 1)

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 017bfba94b61..9f3321922d6a 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -42429,7 +42429,7 @@ static SDValue PromoteMaskArithmetic(SDNode *N, SelectionDAG &DAG,
   }
 }
 
-unsigned convertIntLogicToFPLogicOpcode(unsigned Opcode) {
+static unsigned convertIntLogicToFPLogicOpcode(unsigned Opcode) {
   unsigned FPOpcode;
   switch (Opcode) {
   default: llvm_unreachable("Unexpected input node for FP logic conversion");

diff  --git a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
index 05db70c787bb..0fe7dd9cfb39 100644
--- a/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
@@ -55,8 +55,8 @@ static cl::opt UnlikelyBranchWeight(
     "unlikely-branch-weight", cl::Hidden, cl::init(1),
     cl::desc("Weight of the branch unlikely to be taken (default = 1)"));
 
-std::tuple getBranchWeight(Intrinsic::ID IntrinsicID,
-                                               CallInst *CI, int BranchCount) {
+static std::tuple
+getBranchWeight(Intrinsic::ID IntrinsicID, CallInst *CI, int BranchCount) {
   if (IntrinsicID == Intrinsic::expect) {
     // __builtin_expect
     return std::make_tuple(LikelyBranchWeight.getValue(),

diff  --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 32332ed5b02d..64b41bf9cefa 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -50,6 +50,7 @@ static cl::opt DisableBinopExtractShuffle(
 
 static const unsigned InvalidIndex = std::numeric_limits::max();
 
+namespace {
 class VectorCombine {
 public:
   VectorCombine(Function &F, const TargetTransformInfo &TTI,
@@ -80,6 +81,7 @@ class VectorCombine {
   bool scalarizeBinopOrCmp(Instruction &I);
   bool foldExtractedCmps(Instruction &I);
 };
+} // namespace
 
 static void replaceValue(Value &Old, Value &New) {
   Old.replaceAllUsesWith(&New);

diff  --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
index 52fa2091389e..6d0028b38ec2 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp
@@ -71,7 +71,7 @@ static unsigned getLLVMTypeBitWidth(LLVM::LLVMType type) {
 }
 
 /// Creates `IntegerAttribute` with all bits set for given type
-IntegerAttr minusOneIntegerAttribute(Type type, Builder builder) {
+static IntegerAttr minusOneIntegerAttribute(Type type, Builder builder) {
   if (auto vecType = type.dyn_cast()) {
     auto integerType = vecType.getElementType().cast();
     return builder.getIntegerAttr(integerType, -1);

diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index 3f10e744f419..4367fa39789c 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -1690,7 +1690,7 @@ void mlir::extractForInductionVars(ArrayRef forInsts,
 /// Builds an affine loop nest, using "loopCreatorFn" to create individual loop
 /// operations.
 template 
-void buildAffineLoopNestImpl(
+static void buildAffineLoopNestImpl(
     OpBuilder &builder, Location loc, BoundListTy lbs, BoundListTy ubs,
     ArrayRef steps,
     function_ref bodyBuilderFn,

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index 6cbe947657a0..6a1d00fe620c 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -609,8 +609,8 @@ mlir::createConvertLinalgToAffineLoopsPass() {
 
 // TODO: gradually remove this layer as more ops become "named".
 template 
-Optional linalgOpToLoopsImplSwitch(Operation *op,
-                                                OpBuilder &builder) {
+static Optional linalgOpToLoopsImplSwitch(Operation *op,
+                                                       OpBuilder &builder) {
   assert(isa(op) && "LinalgOp expected");
   if (isa(op))
     return linalgOpToLoopsImpl(op, builder);

diff  --git a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
index 44a0e8cbdb14..f93cd9faa504 100644
--- a/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgTransforms.cpp
@@ -244,8 +244,8 @@ static LogicalResult copyCallBackFn(OpBuilder &b, Value src, Value dst,
   return success();
 }
 
-void fillPromotionCallBackPatterns(MLIRContext *ctx,
-                                   OwningRewritePatternList &patterns) {
+static void fillPromotionCallBackPatterns(MLIRContext *ctx,
+                                          OwningRewritePatternList &patterns) {
   patterns.insert>(
       ctx, LinalgTilingOptions().setTileSizes({16, 16, 16}),
       LinalgMarker(Identifier::get("START", ctx),


        

From cfe-commits at lists.llvm.org  Thu Jul  9 04:56:40 2020
From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 11:56:40 +0000 (UTC)
Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with
 padding emit signed operations.
In-Reply-To: 
References: 
Message-ID: <3fd9772ecf51fab9396e7e50edffb0a6@localhost.localdomain>

ebevhan added a comment.

In D82663#2140507 , @leonardchan wrote:

> In D82663#2130355 , @ebevhan wrote:
>
> > Well, it's not so much as adding the bit, but adding the information that the bit exists. That means either new intrinsics for all of the operations, or adding flags to the existing ones. That's a fair bit of added complexity. Also,  +  would do virtually the exact same thing as the new unsigned-with-padding operations, so the utility of adding all of it is a bit questionable.
>
>
> Could the work involved just be adding the flags, then in `llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp` for unsigned operations, choosing between the signed/unsigned underlying `ISD` when lowering intrinsics to DAG? I think you could just pass the padding bit to `FixedPointIntrinsicToOpcode` and handle it from there. This is just off the top of my head so I could be missing other things.


It wouldn't just be restricted to fixed-point intrinsics, though. It would have to be added to intrinsics like uadd.sat and usub.sat as well, which aren't really tied to fixed-point at all. Changing the semantics of those intrinsics would be unfortunate for targets that have started using them for their own instructions. I don't really think it's an option to move the padding semantic info into the IR; the intrinsic interface is fairly lean, and I think keeping it that way is a good idea.

I could change the emission to not be so heavy-handed and only use signed operations for the intrinsics, rather than everything. That makes EmitFixedPointBinOp a bit messier, though.



================
Comment at: clang/lib/Basic/FixedPoint.cpp:143-158
+  // For codegen purposes, make unsigned with padding semantics signed instead.
+  // This means that we will generate signed operations. The result from these
+  // operations is defined, since ending up with a negative result is undefined
+  // for nonsaturating semantics, and for saturating semantics we will
+  // perform a clamp-to-zero in the last conversion to result semantics (since
+  // we are going from saturating signed to saturating unsigned).
+  //
----------------
leonardchan wrote:
> If this is exclusively for codegen purposes with binary operations, would it be clearer to move this to `EmitFixedPointBinOp`? If `UnsignedPaddingIsSigned` doesn't need to be used for stuff like constant evaluation, it might be clearer not to provide it for everyone.
FixedPointSemantics is immutable except for saturation, unfortunately. I'd end up having to reconstruct the semantics object from scratch immediately after calling getCommonSemantics.


================
Comment at: clang/test/Frontend/fixed_point_add.c:290-294
+  // UNSIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i16 [[USA]] to i40
+  // UNSIGNED-NEXT: [[I_EXT:%[a-z0-9]+]] = zext i32 [[I]] to i40
+  // UNSIGNED-NEXT: [[I:%[a-z0-9]+]] = shl i40 [[I_EXT]], 7
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = add i40 [[USA_EXT]], [[I]]
+  // UNSIGNED-NEXT: [[RES:%[a-z0-9]+]] = trunc i40 [[SUM]] to i16
----------------
leonardchan wrote:
> If this is a workaround for not being able to convey the padding bit to LLVM intrinsics, I think we should only limit changes to instances we would use intrinsics.
I suppose this makes sense, but the logic will be a bit more convoluted in that case.

It is true that in most cases, the clamp-to-zero resulting from the signed->unsigned conversion at the end isn't even necessary. For addition, multiplication, division and shift, the result of positive operands can never become negative, so there's no point to the clamp.

It just felt more general to do it for all of them instead of littering EmitFixedPointBinOp with special cases. But perhaps it would be better to deal with each case individually instead. Still feels like that would make the implementation less clean.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82663/new/

https://reviews.llvm.org/D82663




From cfe-commits at lists.llvm.org  Thu Jul  9 04:57:47 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 11:57:47 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: 

hokein added a comment.

> Sorry, I should give some reasons here:

These are sensible reasons. My only (not a strong) concern is that "error" is quite special, we need to be careful to choose it -- note that there is an `error` function in glibc which is used for error-reporting.

maybe there are other better names (`stringError`?) other than `createError`/`makeError`.

> I guess makeError is still better than the status quo, but not enough to feel motivated to clean this up right now. Maybe someone else wants to pick this up?

unless you strongly insist on `error` name, I'm happy to help with (looks like it's just a low-hanging rename fruit). I think this is a nice cleanup, we should make it happen (either using `error` or other names).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Thu Jul  9 05:05:13 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 12:05:13 +0000 (UTC)
Subject: [PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.
In-Reply-To: 
References: 
Message-ID: <06f1e802568e3d3ddaecc9aba4dfca2a@localhost.localdomain>

Szelethus added a comment.

After reading @martong's comment D72705#2035844  and @balazske's comment D72705#2086994 , I think there is a need to argue across all paths of execution within the function, and as such this is a dataflow problem.

In D72705#2086994 , @balazske wrote:

>   c = fgetc(fd);
>   if (c == '+' || c == '*' || c == '|' || c == '>' || c == '@' || c == EOF || c == '\n') { ... }
>  
>
>
> The first `c == '+'` is found by the checker and reported as false positive (the later `c == EOF` is not found). Such a case can be found if the checker can collect expressions that are separated by `||` or `&&` and the symbol to check occurs in these and there is only a simple comparison.


Our current dataflow analyses definitely have to make judgement of which block (and in that, which `CFGStmt`s) **reads** or **writes** a variable/expression. You can actually register an observer for expression writes (or in other terms, //kills//), so I don't think it'd be too challenging to do this with reads.

`DeadStoresChecker` is a great example for a checker that utilizes dataflow and pathsensitive analyses.

In D72705#1863381 , @Szelethus wrote:

> In D72705#1859711 , @balazske wrote:
>
> > Generally, is it a problem if there are multiple checkers that may detect same defects but with different approach?
>
>
> If avoidable, yes. If not, I think its an acceptable sacrifice.


Mind that since D80905  landed, the tone has shifted, if a more checker detects a specific bug (like double free) but a more general checker does as well (as passing garbage value to a function) we're okay with that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72705/new/

https://reviews.llvm.org/D72705




From cfe-commits at lists.llvm.org  Thu Jul  9 05:13:51 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:13:51 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <466d7b475d66876e4413b17025cb6ec9@localhost.localdomain>

ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Thu Jul  9 05:18:17 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:18:17 +0000 (UTC)
Subject: [PATCH] D83474: Add support for specifying only a denormalizer
Message-ID: 

dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith.
Herald added projects: clang, LLVM.

This commit adds a denormalyzer for optimization level.
Depends on D83406 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83474

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83474.276710.patch
Type: text/x-patch
Size: 13327 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 05:30:16 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:30:16 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
Message-ID: 

martong created this revision.
martong added reviewers: gamesh411, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.

The default CTUImportThreshold (8) seems to be too conservative with C projects.
We increase this value to 24 and we introduce another threshold for C++ source
files (defaulted to 8) because their AST is way more compilcated than C source
files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83475

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-import-threshold.c


Index: clang/test/Analysis/ctu-import-threshold.c
===================================================================
--- clang/test/Analysis/ctu-import-threshold.c
+++ clang/test/Analysis/ctu-import-threshold.c
@@ -1,5 +1,6 @@
 // Ensure analyzer option 'ctu-import-threshold' is a recognized option.
 //
 // RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-cpp-threshold=30 -verify %s
 //
 // expected-no-diagnostics
Index: clang/test/Analysis/analyzer-config.c
===================================================================
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -42,7 +42,8 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 8
+// CHECK-NEXT: ctu-import-cpp-threshold = 8
+// CHECK-NEXT: ctu-import-threshold = 24
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -367,7 +367,9 @@
     CompilerInstance &CI)
     : Loader(CI, CI.getAnalyzerOpts()->CTUDir,
              CI.getAnalyzerOpts()->CTUInvocationList),
-      LoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+      LoadGuard(CI.getASTContext().getLangOpts().CPlusPlus
+                    ? CI.getAnalyzerOpts()->CTUImportCppThreshold
+                    : CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 llvm::Expected
 CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -321,9 +321,16 @@
 ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
                 "The maximal amount of translation units that is considered "
                 "for import when inlining functions during CTU analysis. "
-                "Lowering this threshold can alleviate the memory burder of "
+                "Lowering this threshold can alleviate the memory burden of "
                 "analysis with many interdependent definitions located in "
-                "various translation units.",
+                "various translation units. This is valid only for non C++ "
+                "source files.",
+                24u)
+
+ANALYZER_OPTION(unsigned, CTUImportCppThreshold, "ctu-import-cpp-threshold",
+                "The maximal amount of translation units that is considered "
+                "for import when inlining functions during CTU analysis of C++ "
+                "source files. ",
                 8u)
 
 ANALYZER_OPTION(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83475.276711.patch
Type: text/x-patch
Size: 3094 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 05:45:15 2020
From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:45:15 +0000 (UTC)
Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot
In-Reply-To: 
References: 
Message-ID: <97a36203075225e0b52ff4c0fab055f8@localhost.localdomain>

yaxunl added inline comments.


================
Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:293
+        "wavefrontsize32" : "wavefrontsize64";
+      Features.insert(std::make_pair(DefaultWaveSizeFeature, true));
+    }
----------------
what's the default wave front size in backend for gfx10* before this change?


================
Comment at: clang/test/CodeGenOpenCL/amdgpu-features.cl:7
+// RUN: %clang_cc1 -triple amdgcn -S -emit-llvm -o - %s | FileCheck --check-prefix=NOCPU %s
+// RUN: %clang_cc1 -triple amdgcn -target-feature +wavefrontsize32 -S -emit-llvm -o - %s | FileCheck --check-prefix=NOCPU-WAVE32 %s
+// RUN: %clang_cc1 -triple amdgcn -target-feature +wavefrontsize64 -S -emit-llvm -o - %s | FileCheck --check-prefix=NOCPU-WAVE64 %s
----------------
what happens if both +wavefrontsize32 and +wavefrontsize64 are specified?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82087/new/

https://reviews.llvm.org/D82087




From cfe-commits at lists.llvm.org  Thu Jul  9 05:50:48 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:50:48 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <300abd0ed47145854c438bda212b913d@localhost.localdomain>

martong updated this revision to Diff 276715.
martong added a comment.

- Add getRestrictTy


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83407.276715.patch
Type: text/x-patch
Size: 26860 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 05:52:40 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:52:40 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <10f952e272f4d572e126b17cd3b3dad2@localhost.localdomain>

martong updated this revision to Diff 276716.
martong marked 2 inline comments as done and an inline comment as not done.
martong added a comment.

- Remove redundant line from test code


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83407.276716.patch
Type: text/x-patch
Size: 26788 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 05:55:19 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:55:19 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <417915d119819108c28bb8a488789d95@localhost.localdomain>

martong added a comment.

In D83407#2141075 , @balazske wrote:

> Are not some functions missing from the list (`shutdown`, `sockatmark`, `socket`) (these come from ////)? And `getnameinfo` comes from //// with many other functions that are not added.


Yes, there are missing functions, this is not a comprehensive list. I try to be careful in the sense that I am adding only those functions that have a summary in Cppcheck because those constraints are already validated by their community. Of course, the list can be extended anytime, contributions are welcome from anybody.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1722
+          ACtx.getPointerType(StructSockaddrTy->withConst());
+      StructSockaddrPtrRestrictTy =
+          ACtx.getLangOpts().C99 ? ACtx.getRestrictType(*StructSockaddrPtrTy)
----------------
balazske wrote:
> There could be a generic form of getting the restrict type for a type so something like this can be done (this is used relatively often):
> `getRestrictTypeIfApplicable(ACtx, StructSockaddrPtrTy)`
> 
Yes, absolutely, good idea!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Thu Jul  9 05:57:50 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 12:57:50 +0000 (UTC)
Subject: [PATCH] D83478: [OPENMP]Fix compiler crash for target data directive
 without actual target codegen.
Message-ID: 

ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Need to privatize addresses of the captured variables when trying to
emit the body of the target data directive in no target codegen mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83478

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_data_codegen.cpp


Index: clang/test/OpenMP/target_data_codegen.cpp
===================================================================
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -491,4 +491,23 @@
   {++arg;}
 }
 #endif
+///==========================================================================///
+// RUN: %clang_cc1 -DCK7 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK7 --check-prefix CK7-64
+// RUN: %clang_cc1 -DCK7 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK7 --check-prefix CK7-64
+
+// RUN: %clang_cc1 -DCK7 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY7 %s
+// RUN: %clang_cc1 -DCK7 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY7 %s
+// SIMD-ONLY7-NOT: {{__kmpc|__tgt}}
+#ifdef CK7
+// CK7: test_device_ptr_addr
+void test_device_ptr_addr(int arg) {
+  int *p;
+  // CK7: add nsw i32
+  // CK7: add nsw i32
+  #pragma omp target data use_device_ptr(p) use_device_addr(arg)
+  { ++arg, ++(*p); }
+}
+#endif
 #endif
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6077,6 +6077,7 @@
         (void)PrivateScope.Privatize();
         RCG(CGF);
       } else {
+        OMPLexicalScope Scope(CGF, S, OMPD_unknown);
         RCG(CGF);
       }
     };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83478.276720.patch
Type: text/x-patch
Size: 1882 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 05:59:01 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 12:59:01 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
In-Reply-To: 
References: 
Message-ID: <38384087b8445aa403390ab248fb962c@localhost.localdomain>

gamesh411 accepted this revision.
gamesh411 added a comment.
This revision is now accepted and ready to land.

It will be interesting to see how different C and C++ projects will prove in terms of AST complexity, and Decl-size, but I understand that for now, these two options are necessary to not penalize C project analysis because of C++ AST complexity.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83475/new/

https://reviews.llvm.org/D83475




From cfe-commits at lists.llvm.org  Thu Jul  9 06:00:20 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 13:00:20 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
In-Reply-To: 
References: 
Message-ID: <00003507b2fd84b163658bfc76cae882@localhost.localdomain>

gamesh411 added inline comments.


================
Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:333
+                "for import when inlining functions during CTU analysis of C++ "
+                "source files. ",
                 8u)
----------------
extra whitespace at the end


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83475/new/

https://reviews.llvm.org/D83475




From cfe-commits at lists.llvm.org  Thu Jul  9 06:01:04 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 13:01:04 +0000 (UTC)
Subject: [PATCH] D83480: Refactored NumericLiteralParser to not require a
 Preprocessor
Message-ID: 

gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We would like to use NumericLiteralParser in the implementation of the
syntax tree builder, and plumbing a preprocessor there seems
inconvenient and superfluous.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83480

Files:
  clang/include/clang/Lex/LiteralSupport.h
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaExpr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83480.276721.patch
Type: text/x-patch
Size: 12954 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 06:02:55 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 13:02:55 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
In-Reply-To: 
References: 
Message-ID: <9f1b2d488033f2e7dba34ddce35e2a2f@localhost.localdomain>

martong updated this revision to Diff 276722.
martong marked an inline comment as done.
martong added a comment.

- Remove extra whitespace


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83475/new/

https://reviews.llvm.org/D83475

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-import-threshold.c


Index: clang/test/Analysis/ctu-import-threshold.c
===================================================================
--- clang/test/Analysis/ctu-import-threshold.c
+++ clang/test/Analysis/ctu-import-threshold.c
@@ -1,5 +1,6 @@
 // Ensure analyzer option 'ctu-import-threshold' is a recognized option.
 //
 // RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-cpp-threshold=30 -verify %s
 //
 // expected-no-diagnostics
Index: clang/test/Analysis/analyzer-config.c
===================================================================
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -42,7 +42,8 @@
 // CHECK-NEXT: cplusplus.Move:WarnOn = KnownsAndLocals
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 8
+// CHECK-NEXT: ctu-import-cpp-threshold = 8
+// CHECK-NEXT: ctu-import-threshold = 24
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -367,7 +367,9 @@
     CompilerInstance &CI)
     : Loader(CI, CI.getAnalyzerOpts()->CTUDir,
              CI.getAnalyzerOpts()->CTUInvocationList),
-      LoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+      LoadGuard(CI.getASTContext().getLangOpts().CPlusPlus
+                    ? CI.getAnalyzerOpts()->CTUImportCppThreshold
+                    : CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 llvm::Expected
 CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -321,9 +321,16 @@
 ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
                 "The maximal amount of translation units that is considered "
                 "for import when inlining functions during CTU analysis. "
-                "Lowering this threshold can alleviate the memory burder of "
+                "Lowering this threshold can alleviate the memory burden of "
                 "analysis with many interdependent definitions located in "
-                "various translation units.",
+                "various translation units. This is valid only for non C++ "
+                "source files.",
+                24u)
+
+ANALYZER_OPTION(unsigned, CTUImportCppThreshold, "ctu-import-cpp-threshold",
+                "The maximal amount of translation units that is considered "
+                "for import when inlining functions during CTU analysis of C++ "
+                "source files.",
                 8u)
 
 ANALYZER_OPTION(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83475.276722.patch
Type: text/x-patch
Size: 3093 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 06:22:52 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 13:22:52 +0000 (UTC)
Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator
 checkers
In-Reply-To: 
References: 
Message-ID: 

Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:275-276
   } else if (isRandomIncrOrDecrOperator(OK)) {
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     handlePtrIncrOrDecr(C, BO->getLHS(),
----------------
This doesn't look symmetrical. How does this patch interact with D83190?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83295/new/

https://reviews.llvm.org/D83295




From cfe-commits at lists.llvm.org  Thu Jul  9 06:23:42 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Lubo=C5=A1_Lu=C5=88=C3=A1k_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 13:23:42 +0000 (UTC)
Subject: [PATCH] D69778: Make -fmodules-codegen and -fmodules-debuginfo work
 also with precompiled headers
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG31b05692cd33: make -fmodules-codegen and -fmodules-debuginfo work also with PCHs (authored by llunak).

Changed prior to commit:
  https://reviews.llvm.org/D69778?vs=263839&id=276726#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69778/new/

https://reviews.llvm.org/D69778

Files:
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/Inputs/codegen-flags/foo.h
  clang/test/PCH/codegen.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69778.276726.patch
Type: text/x-patch
Size: 7630 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 06:23:42 2020
From: cfe-commits at lists.llvm.org (=?UTF-8?B?THVib8WhIEx1xYjDoWs=?= via cfe-commits)
Date: Thu, 09 Jul 2020 06:23:42 -0700 (PDT)
Subject: [clang] 31b0569 - make -fmodules-codegen and -fmodules-debuginfo work
 also with PCHs
Message-ID: <5f071a5e.1c69fb81.c43a4.75f4@mx.google.com>


Author: Luboš Luňák
Date: 2020-07-09T15:22:26+02:00
New Revision: 31b05692cd33b6dcc39402169b36d895e1aa87f4

URL: https://github.com/llvm/llvm-project/commit/31b05692cd33b6dcc39402169b36d895e1aa87f4
DIFF: https://github.com/llvm/llvm-project/commit/31b05692cd33b6dcc39402169b36d895e1aa87f4.diff

LOG: make -fmodules-codegen and -fmodules-debuginfo work also with PCHs

Allow to build PCH's (with -building-pch-with-obj and the extra .o file)
with -fmodules-codegen -fmodules-debuginfo to allow emitting shared code
into the extra .o file, similarly to how it works with modules. A bit of
a misnomer, but the underlying functionality is the same. This saves up
to 20% of build time here. The patch is fairly simple, it basically just
duplicates -fmodules checks to also alternatively check
-building-pch-with-obj.

This already got committed as cbc9d22e49b434b6ceb2eb94b67079d02e0a7b74,
but then got reverted in 7ea9a6e0220da36ff2fd1fbc29c2755be23e5166
because of PR44953, as discussed in D74846. This is a corrected version
which does not include two places for the PCH case that aren't included
in the modules -fmodules-codegen path either.

Differential Revision: https://reviews.llvm.org/D69778

Added: 
    clang/test/PCH/codegen.cpp

Modified: 
    clang/lib/Serialization/ASTReader.cpp
    clang/lib/Serialization/ASTReaderDecl.cpp
    clang/lib/Serialization/ASTWriter.cpp
    clang/lib/Serialization/ASTWriterDecl.cpp
    clang/test/Modules/Inputs/codegen-flags/foo.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 74aaf0f9c56e..4a1a995204e5 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3234,7 +3234,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
     case MODULAR_CODEGEN_DECLS:
       // FIXME: Skip reading this record if our ASTConsumer doesn't care about
       // them (ie: if we're not codegenerating this module).
-      if (F.Kind == MK_MainFile)
+      if (F.Kind == MK_MainFile ||
+          getContext().getLangOpts().BuildingPCHWithObjectFile)
         for (unsigned I = 0, N = Record.size(); I != N; ++I)
           EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
       break;

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 359d5e567e67..eef4ab16ec15 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -503,8 +503,12 @@ uint64_t ASTDeclReader::GetCurrentCursorOffset() {
 }
 
 void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) {
-  if (Record.readInt())
+  if (Record.readInt()) {
     Reader.DefinitionSource[FD] = Loc.F->Kind == ModuleKind::MK_MainFile;
+    if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
+        Reader.DeclIsFromPCHWithObjectFile(FD))
+      Reader.DefinitionSource[FD] = true;
+  }
   if (auto *CD = dyn_cast(FD)) {
     CD->setNumCtorInitializers(Record.readInt());
     if (CD->getNumCtorInitializers())
@@ -1431,8 +1435,12 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
       Reader.getContext().setBlockVarCopyInit(VD, CopyExpr, Record.readInt());
   }
 
-  if (VD->getStorageDuration() == SD_Static && Record.readInt())
+  if (VD->getStorageDuration() == SD_Static && Record.readInt()) {
     Reader.DefinitionSource[VD] = Loc.F->Kind == ModuleKind::MK_MainFile;
+    if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
+        Reader.DeclIsFromPCHWithObjectFile(VD))
+      Reader.DefinitionSource[VD] = true;
+  }
 
   enum VarKind {
     VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
@@ -1691,8 +1699,12 @@ void ASTDeclReader::ReadCXXDefinitionData(
   Data.ODRHash = Record.readInt();
   Data.HasODRHash = true;
 
-  if (Record.readInt())
+  if (Record.readInt()) {
     Reader.DefinitionSource[D] = Loc.F->Kind == ModuleKind::MK_MainFile;
+    if (Reader.getContext().getLangOpts().BuildingPCHWithObjectFile &&
+        Reader.DeclIsFromPCHWithObjectFile(D))
+      Reader.DefinitionSource[D] = true;
+  }
 
   Data.NumBases = Record.readInt();
   if (Data.NumBases)

diff  --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 6f364df80f32..2345a12caeb2 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5688,8 +5688,8 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
 
   // getODRHash will compute the ODRHash if it has not been previously computed.
   Record->push_back(D->getODRHash());
-  bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
-                          Writer->WritingModule && !D->isDependentType();
+  bool ModulesDebugInfo =
+      Writer->Context->getLangOpts().ModulesDebugInfo && !D->isDependentType();
   Record->push_back(ModulesDebugInfo);
   if (ModulesDebugInfo)
     Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));

diff  --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 19608c869613..eecdf89c791a 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2458,9 +2458,10 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
 
   assert(FD->doesThisDeclarationHaveABody());
   bool ModulesCodegen = false;
-  if (Writer->WritingModule && !FD->isDependentContext()) {
+  if (!FD->isDependentContext()) {
     Optional Linkage;
-    if (Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
+    if (Writer->WritingModule &&
+        Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
       // When building a C++ Modules TS module interface unit, a strong
       // definition in the module interface is provided by the compilation of
       // that module interface unit, not by its users. (Inline functions are

diff  --git a/clang/test/Modules/Inputs/codegen-flags/foo.h b/clang/test/Modules/Inputs/codegen-flags/foo.h
index 7b9c1cd8e086..74cfab1771f6 100644
--- a/clang/test/Modules/Inputs/codegen-flags/foo.h
+++ b/clang/test/Modules/Inputs/codegen-flags/foo.h
@@ -1,4 +1,7 @@
+#ifndef FOO_H
+#define FOO_H
 struct foo {
 };
 inline void f1() {
 }
+#endif

diff  --git a/clang/test/PCH/codegen.cpp b/clang/test/PCH/codegen.cpp
new file mode 100644
index 000000000000..49ed30aeaf05
--- /dev/null
+++ b/clang/test/PCH/codegen.cpp
@@ -0,0 +1,42 @@
+// This test is the PCH version of Modules/codegen-flags.test . It uses its inputs.
+// The purpose of this test is just verify that the codegen options work with PCH as well.
+// All the codegen functionality should be tested in Modules/.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
+
+// Test with template instantiation in the pch.
+
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-cg.pch
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++-header -building-pch-with-obj -emit-pch -fpch-instantiate-templates %S/../Modules/Inputs/codegen-flags/foo.h -o %t/foo-di.pch
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-cg.pch -building-pch-with-obj -fmodules-codegen | FileCheck --check-prefix=CG %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %s -include-pch %t/foo-di.pch -building-pch-with-obj -fmodules-debuginfo | FileCheck --check-prefix=DI %s
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-cg.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -include-pch %t/foo-di.pch %S/../Modules/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
+
+
+// CG: define weak_odr void @_Z2f1v
+// CG: DICompileUnit
+// CG-NOT: DICompositeType
+
+// CG-USE: declare void @_Z2f1v
+// CG-USE: DICompileUnit
+// CG-USE: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+
+// DI-NOT: define
+// DI: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+
+// DI-USE: define linkonce_odr void @_Z2f1v
+// DI-USE: = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", {{.*}}, flags: DIFlagFwdDecl


        

From cfe-commits at lists.llvm.org  Thu Jul  9 06:36:59 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via cfe-commits)
Date: Thu, 09 Jul 2020 06:36:59 -0700 (PDT)
Subject: [clang] d12d0b7 - [analyzer] Add CTUImportCppThreshold for C++ files
Message-ID: <5f071d7b.1c69fb81.537ee.7274@mx.google.com>


Author: Gabor Marton
Date: 2020-07-09T15:36:33+02:00
New Revision: d12d0b73f1c9c3a711c5cc15266a2b493cd712e9

URL: https://github.com/llvm/llvm-project/commit/d12d0b73f1c9c3a711c5cc15266a2b493cd712e9
DIFF: https://github.com/llvm/llvm-project/commit/d12d0b73f1c9c3a711c5cc15266a2b493cd712e9.diff

LOG: [analyzer] Add CTUImportCppThreshold for C++ files

Summary:
The default CTUImportThreshold (8) seems to be too conservative with C projects.
We increase this value to 24 and we introduce another threshold for C++ source
files (defaulted to 8) because their AST is way more compilcated than C source
files.

Differential Revision: https://reviews.llvm.org/D83475

Added: 
    

Modified: 
    clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
    clang/lib/CrossTU/CrossTranslationUnit.cpp
    clang/test/Analysis/analyzer-config.c
    clang/test/Analysis/ctu-import-threshold.c
    clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
index 9ee113c0dcaf..f0359d2dbb3c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -321,9 +321,16 @@ ANALYZER_OPTION(bool, ShouldDisplayCheckerNameForText, "display-checker-name",
 ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
                 "The maximal amount of translation units that is considered "
                 "for import when inlining functions during CTU analysis. "
-                "Lowering this threshold can alleviate the memory burder of "
+                "Lowering this threshold can alleviate the memory burden of "
                 "analysis with many interdependent definitions located in "
-                "various translation units.",
+                "various translation units. This is valid only for non C++ "
+                "source files.",
+                24u)
+
+ANALYZER_OPTION(unsigned, CTUImportCppThreshold, "ctu-import-cpp-threshold",
+                "The maximal amount of translation units that is considered "
+                "for import when inlining functions during CTU analysis of C++ "
+                "source files.",
                 8u)
 
 ANALYZER_OPTION(

diff  --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 11cc2afbc36d..80465c41d151 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -367,7 +367,9 @@ CrossTranslationUnitContext::ASTUnitStorage::ASTUnitStorage(
     CompilerInstance &CI)
     : Loader(CI, CI.getAnalyzerOpts()->CTUDir,
              CI.getAnalyzerOpts()->CTUInvocationList),
-      LoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+      LoadGuard(CI.getASTContext().getLangOpts().CPlusPlus
+                    ? CI.getAnalyzerOpts()->CTUImportCppThreshold
+                    : CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 llvm::Expected
 CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(

diff  --git a/clang/test/Analysis/analyzer-config.c b/clang/test/Analysis/analyzer-config.c
index 7599cb052d44..d286f1258c21 100644
--- a/clang/test/Analysis/analyzer-config.c
+++ b/clang/test/Analysis/analyzer-config.c
@@ -43,7 +43,8 @@
 // CHECK-NEXT: cplusplus.SmartPtrModeling:ModelSmartPtrDereference = false
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 8
+// CHECK-NEXT: ctu-import-cpp-threshold = 8
+// CHECK-NEXT: ctu-import-threshold = 24
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false

diff  --git a/clang/test/Analysis/ctu-import-threshold.c b/clang/test/Analysis/ctu-import-threshold.c
index 82711b873d10..62bbeda20d5b 100644
--- a/clang/test/Analysis/ctu-import-threshold.c
+++ b/clang/test/Analysis/ctu-import-threshold.c
@@ -1,5 +1,6 @@
 // Ensure analyzer option 'ctu-import-threshold' is a recognized option.
 //
 // RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-cpp-threshold=30 -verify %s
 //
 // expected-no-diagnostics

diff  --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
index ceb1437f2520..5495f27f5b32 100644
--- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -147,6 +147,7 @@ class CTUAction : public clang::ASTFrontendAction {
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
     CI.getAnalyzerOpts()->CTUImportThreshold = OverrideLimit;
+    CI.getAnalyzerOpts()->CTUImportCppThreshold = OverrideLimit;
     return std::make_unique(CI, Success);
   }
 


        

From cfe-commits at lists.llvm.org  Thu Jul  9 06:37:02 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 13:37:02 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
In-Reply-To: 
References: 
Message-ID: <98bc54575d3bf7775fea2f906a942ae3@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rGd12d0b73f1c9: [analyzer] Add CTUImportCppThreshold for C++ files (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D83475?vs=276722&id=276727#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83475/new/

https://reviews.llvm.org/D83475

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-import-threshold.c
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp


Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===================================================================
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -147,6 +147,7 @@
   std::unique_ptr
   CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
     CI.getAnalyzerOpts()->CTUImportThreshold = OverrideLimit;
+    CI.getAnalyzerOpts()->CTUImportCppThreshold = OverrideLimit;
     return std::make_unique(CI, Success);
   }
 
Index: clang/test/Analysis/ctu-import-threshold.c
===================================================================
--- clang/test/Analysis/ctu-import-threshold.c
+++ clang/test/Analysis/ctu-import-threshold.c
@@ -1,5 +1,6 @@
 // Ensure analyzer option 'ctu-import-threshold' is a recognized option.
 //
 // RUN: %clang_cc1 -analyze -analyzer-config ctu-import-threshold=30 -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-config ctu-import-cpp-threshold=30 -verify %s
 //
 // expected-no-diagnostics
Index: clang/test/Analysis/analyzer-config.c
===================================================================
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -43,7 +43,8 @@
 // CHECK-NEXT: cplusplus.SmartPtrModeling:ModelSmartPtrDereference = false
 // CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: ctu-dir = ""
-// CHECK-NEXT: ctu-import-threshold = 8
+// CHECK-NEXT: ctu-import-cpp-threshold = 8
+// CHECK-NEXT: ctu-import-threshold = 24
 // CHECK-NEXT: ctu-index-name = externalDefMap.txt
 // CHECK-NEXT: ctu-invocation-list = invocations.yaml
 // CHECK-NEXT: deadcode.DeadStores:ShowFixIts = false
Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===================================================================
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -367,7 +367,9 @@
     CompilerInstance &CI)
     : Loader(CI, CI.getAnalyzerOpts()->CTUDir,
              CI.getAnalyzerOpts()->CTUInvocationList),
-      LoadGuard(CI.getAnalyzerOpts()->CTUImportThreshold) {}
+      LoadGuard(CI.getASTContext().getLangOpts().CPlusPlus
+                    ? CI.getAnalyzerOpts()->CTUImportCppThreshold
+                    : CI.getAnalyzerOpts()->CTUImportThreshold) {}
 
 llvm::Expected
 CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
===================================================================
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
@@ -321,9 +321,16 @@
 ANALYZER_OPTION(unsigned, CTUImportThreshold, "ctu-import-threshold",
                 "The maximal amount of translation units that is considered "
                 "for import when inlining functions during CTU analysis. "
-                "Lowering this threshold can alleviate the memory burder of "
+                "Lowering this threshold can alleviate the memory burden of "
                 "analysis with many interdependent definitions located in "
-                "various translation units.",
+                "various translation units. This is valid only for non C++ "
+                "source files.",
+                24u)
+
+ANALYZER_OPTION(unsigned, CTUImportCppThreshold, "ctu-import-cpp-threshold",
+                "The maximal amount of translation units that is considered "
+                "for import when inlining functions during CTU analysis of C++ "
+                "source files.",
                 8u)
 
 ANALYZER_OPTION(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83475.276727.patch
Type: text/x-patch
Size: 3681 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 06:38:29 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 13:38:29 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
In-Reply-To: 
References: 
Message-ID: 

Szelethus added inline comments.


================
Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:48-50
 #ifndef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 /// Create a new analyzer option, but dont generate a method for it in
 /// AnalyzerOptions. It's value depends on the option "user-mode".
----------------
This reminds me of some options having different default values depending on `-analyzer-config user-mode`. I think that solution, and the one proposed in this patch is subpar, but the best solution, turning this entire thing into a TableGen file, would be a chore.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83475/new/

https://reviews.llvm.org/D83475




From cfe-commits at lists.llvm.org  Thu Jul  9 06:40:50 2020
From: cfe-commits at lists.llvm.org (Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 13:40:50 +0000 (UTC)
Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu
In-Reply-To: 
References: 
Message-ID: <2c0f390008a7180c1b57cf4e0d4bf808@localhost.localdomain>

khchen planned changes to this revision.
khchen marked an inline comment as done.
khchen added a comment.

BTW, this patch depends on D77030 , which aim to avoid the forcing of any ProcessorModel to have `FeatureRVCHints` feature.
But if we decide to keep the `FeatureRVCHints`, I need to change implementation a little.



================
Comment at: clang/test/Driver/riscv-cpus.c:2
+// Check target CPUs are correctly passed.
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck -check-prefix=MCPU-ROCKETCHIP32 %s
----------------
asb wrote:
> I think for completeness this test should be validating the interaction of the ABI choosing logic with CPU selection as well. With the implemented logic I believe it should show that lp64d is selected for -mcpu=sifive-u54 and that -mcpu=sifive-u54 -mabi=lp64 will respect the ABI choice
okay, it makes sense to me, I will update this patch soon.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71124/new/

https://reviews.llvm.org/D71124




From cfe-commits at lists.llvm.org  Thu Jul  9 06:42:52 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 13:42:52 +0000 (UTC)
Subject: [PATCH] D83475: [analyzer] Add CTUImportCppThreshold for C++ files
In-Reply-To: 
References: 
Message-ID: <5d3ca8d3a1a60270409963eea88538c6@localhost.localdomain>

Szelethus added a comment.

I don't like this solution toooo much, but I respect the urgency, and since we don't introduce a compatibility issue, I trust we can remove this if we decide to change to TableGen. Post-commit LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83475/new/

https://reviews.llvm.org/D83475




From cfe-commits at lists.llvm.org  Thu Jul  9 06:59:01 2020
From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 13:59:01 +0000 (UTC)
Subject: [PATCH] D83286: [analyzer][solver] Track symbol disequalities
In-Reply-To: 
References: 
Message-ID: <1c745482e115fb6dd296872459a8d797@localhost.localdomain>

vsavchenko updated this revision to Diff 276729.
vsavchenko added a comment.

Fix review remarks


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83286/new/

https://reviews.llvm.org/D83286

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/equality_tracking.c
  clang/test/Analysis/mutually_exclusive_null_fp.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83286.276729.patch
Type: text/x-patch
Size: 25118 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 06:59:42 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 13:59:42 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <31d257995ebd60363df6f97541ffaf3a@localhost.localdomain>

Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1735-1747
+      if (!addToFunctionSummaryMap(
+              "accept", Summary(ArgTypes{IntTy, *StructSockaddrPtrRestrictTy,
+                                         *Socklen_tPtrRestrictTy},
+                                RetType{IntTy}, NoEvalCall)
+                            .ArgConstraint(ArgumentCondition(
+                                0, WithinRange, Range(0, IntMax)))))
+        // Do not add constraints on sockaddr.
----------------
This is quite a bit of code duplication -- if we failed to match the precise `accept`, we just try again with the middle argument type being unspecified? Whats the difference between this and trying to match with `Irrelevant` straight away?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Thu Jul  9 07:02:04 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 14:02:04 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: <4d6aad76bb37dda61745616dc4a98a5e@localhost.localdomain>

LukeZhuang added a comment.

Hi, could you please help me commit this change? Thank you very much!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Thu Jul  9 07:17:08 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 14:17:08 +0000 (UTC)
Subject: [PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for
 recovery expression.
In-Reply-To: 
References: 
Message-ID: 

hokein updated this revision to Diff 276733.
hokein added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82657/new/

https://reviews.llvm.org/D82657

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
  clang/test/SemaTemplate/dependent-names.cpp


Index: clang/test/SemaTemplate/dependent-names.cpp
===================================================================
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -173,7 +173,7 @@
 
 
   namespace O {
-    void f(char&); // expected-note {{candidate function not viable}}
+    int f(char&); // expected-note {{candidate function not viable}}
 
     template struct C {
       static const int n = f(T()); // expected-error {{no matching function}}
Index: clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
===================================================================
--- clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -123,7 +123,10 @@
   template struct S {};
   template using U = S; // expected-note 2{{template parameter is declared here}}
   template U &f(U, Ts...); // expected-error 2{{pack expansion used as argument for non-pack parameter of alias template}}
-  S &s1 = f({}, 0, 0.0); // expected-error {{no matching function}}
+  // The return type of f is invalid during instantiation, and int is the fallback.
+  // FIXME: would be nice to suppress the secondard "cannot bind to a value of unrelated type 'int'" diagnostic.
+  S &s1 = f({}, 0, 0.0); // expected-error {{no matching function}} \
+                                              expected-error {{non-const lvalue reference to type 'S' cannot bind to a value of unrelated type 'int'}}
 }
 
 namespace PR18401 {
Index: clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
===================================================================
--- clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -67,7 +67,8 @@
 // expected-note at -1 {{candidate function [with T = long long, U = int]}}
 
 static_assert(sizeof(f()));
-// expected-error at -1 {{call to 'f' is ambiguous}}
+// expected-error at -1 {{call to 'f' is ambiguous}} \
+   expected-error at -1 {{invalid application of 'sizeof' to an incomplete type 'void'}}
 
 template
 concept C3 = true;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2929,8 +2929,8 @@
   // Recovery AST still heavily relies on dependent-type machinery.
   Opts.RecoveryAST =
       Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType =
-      Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+  Opts.RecoveryASTType = Args.hasFlag(
+      OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82657.276733.patch
Type: text/x-patch
Size: 3207 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 07:21:09 2020
From: cfe-commits at lists.llvm.org (=?utf-8?b?QmFsb2doLCDDgWTDoW0gdmlhIFBoYWJyaWNhdG9y?= via cfe-commits)
Date: Thu, 09 Jul 2020 14:21:09 +0000 (UTC)
Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator
 checkers
In-Reply-To: 
References: 
Message-ID: 

baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:275-276
   } else if (isRandomIncrOrDecrOperator(OK)) {
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     handlePtrIncrOrDecr(C, BO->getLHS(),
----------------
Szelethus wrote:
> This doesn't look symmetrical. How does this patch interact with D83190?
This //is// not symmetrical. Since this patch is a hotfix for three bugs, all of them cause crashes it is more urgent to land. The other patch should be rebased on it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83295/new/

https://reviews.llvm.org/D83295




From cfe-commits at lists.llvm.org  Thu Jul  9 07:22:03 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 14:22:03 +0000 (UTC)
Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator
 checkers
In-Reply-To: 
References: 
Message-ID: <46c630d56376205336611fcc459b2291@localhost.localdomain>

gamesh411 accepted this revision.
gamesh411 added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:275-276
   } else if (isRandomIncrOrDecrOperator(OK)) {
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     handlePtrIncrOrDecr(C, BO->getLHS(),
----------------
Szelethus wrote:
> This doesn't look symmetrical. How does this patch interact with D83190?
I see that patch D83190 will need not only to be rebased, but modified slightly to take this early checking into account. I will refer to this review over there.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83295/new/

https://reviews.llvm.org/D83295




From cfe-commits at lists.llvm.org  Thu Jul  9 07:25:15 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Endre_F=C3=BCl=C3=B6p_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 14:25:15 +0000 (UTC)
Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator
 checkers
In-Reply-To: 
References: 
Message-ID: 

gamesh411 added a comment.

@Szelethus thanks for being watchful, appreciated c:


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83295/new/

https://reviews.llvm.org/D83295




From cfe-commits at lists.llvm.org  Thu Jul  9 07:36:35 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 14:36:35 +0000 (UTC)
Subject: [PATCH] D83295: [Analyzer] Hotfix for various crashes in iterator
 checkers
In-Reply-To: 
References: 
Message-ID: 

Szelethus accepted this revision.
Szelethus added a comment.

LGTM, but if we knowingly a subpar solution, we should make that clear in the surrounding code. I know the followup patch is around the corner, but just to be sure.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:275-276
   } else if (isRandomIncrOrDecrOperator(OK)) {
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     handlePtrIncrOrDecr(C, BO->getLHS(),
----------------
baloghadamsoftware wrote:
> gamesh411 wrote:
> > Szelethus wrote:
> > > This doesn't look symmetrical. How does this patch interact with D83190?
> > I see that patch D83190 will need not only to be rebased, but modified slightly to take this early checking into account. I will refer to this review over there.
> This //is// not symmetrical. Since this patch is a hotfix for three bugs, all of them cause crashes it is more urgent to land. The other patch should be rebased on it.
Please add a FIXME before commiting, if we knowingly add a hack.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:466-470
+  // If the value for which we just tried to set a new iterator position is
+  // an `SVal`for which no iterator position can be set then the setting was
+  // unsuccessful. We cannot handle the comparison in this case.
+  if (!LPos || !RPos)
+    return;
----------------
Is this always okay? Shouldn't we check what the reason was behind the failure to retrieve the position? Is a `TODO: ` at the very least appropriate?


================
Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp:172-173
     SVal RVal = State->getSVal(BO->getRHS(), C.getLocationContext());
+    if (!BO->getRHS()->getType()->isIntegralOrEnumerationType())
+      return;
     verifyRandomIncrOrDecr(C, BinaryOperator::getOverloadedOperator(OK), LVal,
----------------
FIXME:


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83295/new/

https://reviews.llvm.org/D83295




From cfe-commits at lists.llvm.org  Thu Jul  9 07:36:59 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 14:36:59 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <9c6c2770b318898f292112b519f5c97f@localhost.localdomain>

martong marked an inline comment as done.
martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1735-1747
+      if (!addToFunctionSummaryMap(
+              "accept", Summary(ArgTypes{IntTy, *StructSockaddrPtrRestrictTy,
+                                         *Socklen_tPtrRestrictTy},
+                                RetType{IntTy}, NoEvalCall)
+                            .ArgConstraint(ArgumentCondition(
+                                0, WithinRange, Range(0, IntMax)))))
+        // Do not add constraints on sockaddr.
----------------
Szelethus wrote:
> This is quite a bit of code duplication -- if we failed to match the precise `accept`, we just try again with the middle argument type being unspecified? Whats the difference between this and trying to match with `Irrelevant` straight away?
>  if we failed to match the precise accept, we just try again with the middle argument type being unspecified?
Yes. And that will be a successful match in the case where `sockaddr` is a transparent union.

> Whats the difference between this and trying to match with Irrelevant straight away?
Yeah, it's a good catch. There is no difference with `accept` because we don't have any constraints on `sockaddr` anyway. But, the other functions have fewer constraints with the transparent union.
Perhaps we should separate the body of the `Summary` from the `Signature` and in this case we could reuse that for both signatures. Or as you suggested we could just match by default with the `Irrelevant`. What do you think?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Thu Jul  9 07:38:41 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 14:38:41 +0000 (UTC)
Subject: [PATCH] D83480: Refactored NumericLiteralParser to not require a
 Preprocessor
In-Reply-To: 
References: 
Message-ID: <671a103f3d9efaf3b129e1a76a99e375@localhost.localdomain>

eduucaldas accepted this revision.
eduucaldas added a comment.
This revision is now accepted and ready to land.

Additionally, consider applying a similar change to `CharLiteralParser`, for consistency.

All the comments are just suggestions. Feel free to land this without answering them.



================
Comment at: clang/include/clang/Lex/LiteralSupport.h:57-59
-  NumericLiteralParser(StringRef TokSpelling,
-                       SourceLocation TokLoc,
-                       Preprocessor &PP);
----------------
We don't need to remove this constructor, we can keep the same signature and make it call the new constructor. The same is done for `StringLiteralParser`.

That would allow some callers that don't care much about the implementation details to just use the simpler to write version.


================
Comment at: clang/lib/Lex/LiteralSupport.cpp:766
+      !isValidUDSuffix(LangOpts, StringRef(s, ThisTokEnd - s))) {
+    Diags.Report(AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
+                 diag::err_invalid_digit)
----------------
How about just using `Lexer::AdvanceToTokenCharacter`? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83480/new/

https://reviews.llvm.org/D83480




From cfe-commits at lists.llvm.org  Thu Jul  9 07:42:05 2020
From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits)
Date: Thu, 09 Jul 2020 14:42:05 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <64607b9f24e66a89877f2dd4576591d6@localhost.localdomain>

Szelethus added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1735-1747
+      if (!addToFunctionSummaryMap(
+              "accept", Summary(ArgTypes{IntTy, *StructSockaddrPtrRestrictTy,
+                                         *Socklen_tPtrRestrictTy},
+                                RetType{IntTy}, NoEvalCall)
+                            .ArgConstraint(ArgumentCondition(
+                                0, WithinRange, Range(0, IntMax)))))
+        // Do not add constraints on sockaddr.
----------------
martong wrote:
> Szelethus wrote:
> > This is quite a bit of code duplication -- if we failed to match the precise `accept`, we just try again with the middle argument type being unspecified? Whats the difference between this and trying to match with `Irrelevant` straight away?
> >  if we failed to match the precise accept, we just try again with the middle argument type being unspecified?
> Yes. And that will be a successful match in the case where `sockaddr` is a transparent union.
> 
> > Whats the difference between this and trying to match with Irrelevant straight away?
> Yeah, it's a good catch. There is no difference with `accept` because we don't have any constraints on `sockaddr` anyway. But, the other functions have fewer constraints with the transparent union.
> Perhaps we should separate the body of the `Summary` from the `Signature` and in this case we could reuse that for both signatures. Or as you suggested we could just match by default with the `Irrelevant`. What do you think?
> Perhaps we should separate the body of the Summary from the Signature and in this case we could reuse that for both signatures. Or as you suggested we could just match by default with the Irrelevant. What do you think?

Separating the summary and the signature sounds great! But, that also adds sufficiently complex code that would definitely warrant individual tests, so we should add that as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Thu Jul  9 08:01:46 2020
From: cfe-commits at lists.llvm.org (Erich Keane via cfe-commits)
Date: Thu, 09 Jul 2020 08:01:46 -0700 (PDT)
Subject: [clang] 4d4d903 - Fix warning caused by
 __builtin_expect_with_probability was not handled
Message-ID: <5f07315a.1c69fb81.fd83a.7ab6@mx.google.com>


Author: Zhi Zhuang
Date: 2020-07-09T08:01:33-07:00
New Revision: 4d4d9037670a3537c14092807a717284ea0c4f92

URL: https://github.com/llvm/llvm-project/commit/4d4d9037670a3537c14092807a717284ea0c4f92
DIFF: https://github.com/llvm/llvm-project/commit/4d4d9037670a3537c14092807a717284ea0c4f92.diff

LOG: Fix warning caused by __builtin_expect_with_probability was not handled
in places such as constant folding

Previously some places that should have handled
__builtin_expect_with_probability is missing, so in some case it acts
differently than __builtin_expect.
For example it was not handled in constant folding, thus in the
following program, the "if" condition should be constantly true and
folded, but previously it was not handled and cause warning "control may
reach end of non-void function" (while __builtin_expect does not):

__attribute__((noreturn)) extern void bar();
int foo(int x, int y) {
  if (y) {
    if (__builtin_expect_with_probability(1, 1, 1))
      bar();
  }
  else
    return 0;
}

Now it's fixed.

Differential Revisions: https://reviews.llvm.org/D83362

Added: 
    

Modified: 
    clang/lib/AST/ExprConstant.cpp
    clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
    clang/test/Sema/builtin-expect-with-probability.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d6dbfb14e60b..a4dc0ccad1e0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -11231,6 +11231,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
   }
 
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
     return Visit(E->getArg(0));
 
   case Builtin::BI__builtin_ffs:

diff  --git a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
index 3eeb1e9a3502..233ce57c3ac9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
@@ -64,10 +64,12 @@ bool BuiltinFunctionChecker::evalCall(const CallEvent &Call,
 
   case Builtin::BI__builtin_unpredictable:
   case Builtin::BI__builtin_expect:
+  case Builtin::BI__builtin_expect_with_probability:
   case Builtin::BI__builtin_assume_aligned:
   case Builtin::BI__builtin_addressof: {
-    // For __builtin_unpredictable, __builtin_expect, and
-    // __builtin_assume_aligned, just return the value of the subexpression.
+    // For __builtin_unpredictable, __builtin_expect,
+    // __builtin_expect_with_probability and __builtin_assume_aligned,
+    // just return the value of the subexpression.
     // __builtin_addressof is going from a reference to a pointer, but those
     // are represented the same way in the analyzer.
     assert (Call.getNumArgs() > 0);

diff  --git a/clang/test/Sema/builtin-expect-with-probability.cpp b/clang/test/Sema/builtin-expect-with-probability.cpp
index 4a5b62a55bbc..3aa20cb0e6dd 100644
--- a/clang/test/Sema/builtin-expect-with-probability.cpp
+++ b/clang/test/Sema/builtin-expect-with-probability.cpp
@@ -1,4 +1,30 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((noreturn)) extern void bar();
+
+int test_no_warn(int x) {
+  if (x) {
+    if (__builtin_expect_with_probability(1, 1, 1))
+      bar();
+  } else {
+    return 0;
+  }
+} // should not emit warn "control may reach end of non-void function" here since expr is constantly true, so the "if(__bui..)" should be constantly true condition and be ignored
+
+template  void tempf() {
+  static_assert(b == 1, "should be evaluated as 1"); // should not have error here
+}
+
+constexpr int constf() {
+  return __builtin_expect_with_probability(1, 1, 1);
+}
+
+void foo() {
+  tempf<__builtin_expect_with_probability(1, 1, 1)>();
+  constexpr int f = constf();
+  static_assert(f == 1, "should be evaluated as 1"); // should not have error here
+}
+
 extern int global;
 
 struct S {


        

From cfe-commits at lists.llvm.org  Thu Jul  9 08:03:47 2020
From: cfe-commits at lists.llvm.org (Erich Keane via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:03:47 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: <8837f73624a8745ba03ceb2104920c92@localhost.localdomain>

erichkeane closed this revision.
erichkeane added a comment.

Gah, misspelled differential revision.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Thu Jul  9 08:04:19 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:04:19 +0000 (UTC)
Subject: [PATCH] D83480: Refactored NumericLiteralParser to not require a
 Preprocessor
In-Reply-To: 
References: 
Message-ID: <0f9947122fb2256d47d872252bc29c5c@localhost.localdomain>

gribozavr updated this revision to Diff 276740.
gribozavr added a comment.

Addressed code review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83480/new/

https://reviews.llvm.org/D83480

Files:
  clang/include/clang/Lex/LiteralSupport.h
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaExpr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83480.276740.patch
Type: text/x-patch
Size: 12737 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 08:04:36 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:04:36 +0000 (UTC)
Subject: [PATCH] D83480: Refactored NumericLiteralParser to not require a
 Preprocessor
In-Reply-To: 
References: 
Message-ID: <31159c81872cbfc28a7067fa706c8fc5@localhost.localdomain>

gribozavr2 added inline comments.


================
Comment at: clang/include/clang/Lex/LiteralSupport.h:57-59
-  NumericLiteralParser(StringRef TokSpelling,
-                       SourceLocation TokLoc,
-                       Preprocessor &PP);
----------------
eduucaldas wrote:
> We don't need to remove this constructor, we can keep the same signature and make it call the new constructor. The same is done for `StringLiteralParser`.
> 
> That would allow some callers that don't care much about the implementation details to just use the simpler to write version.
I'd prefer a simpler public API over convenience.


================
Comment at: clang/lib/Lex/LiteralSupport.cpp:766
+      !isValidUDSuffix(LangOpts, StringRef(s, ThisTokEnd - s))) {
+    Diags.Report(AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
+                 diag::err_invalid_digit)
----------------
eduucaldas wrote:
> How about just using `Lexer::AdvanceToTokenCharacter`? 
Done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83480/new/

https://reviews.llvm.org/D83480




From cfe-commits at lists.llvm.org  Thu Jul  9 08:08:44 2020
From: cfe-commits at lists.llvm.org (Zhi Zhuang via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:08:44 +0000 (UTC)
Subject: [PATCH] D83362: Fix warning caused by
 __builtin_expect_with_probability was not handled in places such as constant
 folding
In-Reply-To: 
References: 
Message-ID: 

LukeZhuang added a comment.

Thank you very much!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83362/new/

https://reviews.llvm.org/D83362




From cfe-commits at lists.llvm.org  Thu Jul  9 08:10:56 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:10:56 +0000 (UTC)
Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.
In-Reply-To: 
References: 
Message-ID: <38958b9169bdc96beefb270e85e9dc69@localhost.localdomain>

sammccall added a comment.

In D83213#2141387 , @hokein wrote:

> I think this depends on how we interpret the instantiation-dependent bit. In clang, it currently has two semantics:
>
> 1. an expression (somehow) depends on a template parameter;
> 2. an expression is dependent;


Not trying to be difficult, but I'm not sure what you mean by "dependent" in #2. Informally, it means the same thing as #1. Formally, C++ defines type-dependence and value-dependence for expressions, and the ABI defines instantiation-dependence for expressions - AFAIK "dependent" doesn't have a formal meaning.

So I'd rather say it has two definitions:

- informally, it (somehow) depends on a template parameter.
- formally (from the C++ABI), an expression is instantiation-dependent if it is type-dependent or value-dependent, or it has a subexpression that is type-dependent or value-dependent.

To preserve the linkage between these two, **IMO** we need to extend the formal definition to errors if and only if we extend the informal definition to errors. Accidentally unlinking the two is almost certain to result in subtle bugs as either the implementation subtly differs from the spec, or it subtly differs from the mental model.
That is, we need to decide whether to make all of these changes:

- (informal) instantiation-dependent means it (somehow) depends on a template parameter or error
- (formal) value-dependent means that (informally) an expressions's value depends on a tparam or err
- (formal) type-dependent means that (informally) an expression's type depends on a tparam or err

The approach so far has been **YES**. This looks like:

- all RecoveryExprs are value-dependent, instantiation-dependent, and contains-errors
- RecoveryExprs are type-dependent if we didn't guess the type, or we guessed it was a dependent type

Here we make use of existing codepaths that turn off checking in the presence of dependent code. We mostly need to check contains-errors to prevent a bad-recovery cascade.

The alternate approach is **NO**. This looks like:

- all RecoveryExpr are contains-errors
- a RecoveryExpr are instantiation-dependent if a subexpression is (i.e. refers to a template param)
- a RecoveryExpr is value-dependent if one of its direct subexpressions is, or if the broken code is likely to yield different values in different template instantiations due to the context
- a RecoveryExpr is type-dependent if its type is known to be dependent, or if the broken code is likely to yield different types in different template instantiations due to the context

Here codepaths that turn off checking need to turn it off for errors explicitly.
There's subtlety in the value-depnedent and type-dependent bits, which probably needs to be resolved on a case-by-case basis.
And there's more machinery needed: when an expression's type is not known but isn't believed to be dependent, what is it? I think we end up needing to define RecoveryType here (the fundamental contains-errors type).

So this is doable and maybe even a good idea (not obvious to me what the practical differences are). But it's a large change, not a small one like this patch.

> **Option 1** (what this patch does):
> 
> instantiation-dependence still  implies the expression involves a template parameter -- if a recovery expression doesn't involves a template parameter, we don't set this flag

It doesn't make sense IMO to make this change without also saying "value-dependence implies the value dependds on a template parameter". It's too surprising and hard to reason about, and I don't see a principled reason for this distinction.

> Not sure what pros would buy us

That's the thing that surprises me, it's a richer model, it's principled and correct... but I have no intuition what we can use it for.

> **Option 2**:
> cons:
> 
> - keep using the instantiation name is confusing; we could do clarify the document of isInstantiation

Yeah. I don't think actually renaming it would be appropriate, but we should be really explicit about its non-template meaning, and also give a generalized intuitive definition that makes sense. ("Depends in any way on a template parameter or error. In a template context, this implies that the resolution of this expr may cause instantiation to fail")

> While writing this, I'm starting to like the option2, any other thoughts?

Yeah, I think we'd have to have some concrete benefits to pursue option 1. Doing it right is a lot of work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83213/new/

https://reviews.llvm.org/D83213




From cfe-commits at lists.llvm.org  Thu Jul  9 08:31:23 2020
From: cfe-commits at lists.llvm.org (JF Bastien via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:31:23 +0000 (UTC)
Subject: [PATCH] D77493: [clang-tidy] Add do-not-refer-atomic-twice check
In-Reply-To: 
References: 
Message-ID: <4aa608cf9298c438b32a62a1d26be763@localhost.localdomain>

jfb added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp:10
+_Atomic int n2 = ATOMIC_VAR_INIT(0);
+_Atomic(int) n3 = ATOMIC_VAR_INIT(0);
+
----------------
Can you cover `std::atomic` as well?


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp:10
+_Atomic int n2 = ATOMIC_VAR_INIT(0);
+_Atomic(int) n3 = ATOMIC_VAR_INIT(0);
+
----------------
jfb wrote:
> Can you cover `std::atomic` as well?
We deprecated `ATOMIC_VAR_INIT` in C++20 and C17, I wouldn't use it here (even if it's just your own macro).


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp:77
+  n3++;
+}
----------------
Can you check that non-atomic-accesses to the variable also work, for example taking the atomic's address, using it in unevaluated `sizeof` / `offsetof`, etc.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77493/new/

https://reviews.llvm.org/D77493




From cfe-commits at lists.llvm.org  Thu Jul  9 08:32:07 2020
From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via cfe-commits)
Date: Thu, 09 Jul 2020 08:32:07 -0700 (PDT)
Subject: [clang] 67422e4 - [MSP430] Align the _Complex ABI with current
 msp430-gcc
Message-ID: <5f073877.1c69fb81.e3e56.7544@mx.google.com>


Author: Anatoly Trosinenko
Date: 2020-07-09T18:28:48+03:00
New Revision: 67422e4294754e08f277b1ba22820487eb76b918

URL: https://github.com/llvm/llvm-project/commit/67422e4294754e08f277b1ba22820487eb76b918
DIFF: https://github.com/llvm/llvm-project/commit/67422e4294754e08f277b1ba22820487eb76b918.diff

LOG: [MSP430] Align the _Complex ABI with current msp430-gcc

Assembler output is checked against msp430-gcc 9.2.0.50 from TI.

Reviewed By: asl

Differential Revision: https://reviews.llvm.org/D82646

Added: 
    clang/test/CodeGen/msp430-abi-complex.c

Modified: 
    clang/lib/CodeGen/TargetInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 801adc29acd1..b83267dec6f0 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -7475,10 +7475,49 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {
 
 namespace {
 
+class MSP430ABIInfo : public DefaultABIInfo {
+  static ABIArgInfo complexArgInfo() {
+    ABIArgInfo Info = ABIArgInfo::getDirect();
+    Info.setCanBeFlattened(false);
+    return Info;
+  }
+
+public:
+  MSP430ABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType RetTy) const {
+    if (RetTy->isAnyComplexType())
+      return complexArgInfo();
+
+    return DefaultABIInfo::classifyReturnType(RetTy);
+  }
+
+  ABIArgInfo classifyArgumentType(QualType RetTy) const {
+    if (RetTy->isAnyComplexType())
+      return complexArgInfo();
+
+    return DefaultABIInfo::classifyArgumentType(RetTy);
+  }
+
+  // Just copy the original implementations because
+  // DefaultABIInfo::classify{Return,Argument}Type() are not virtual
+  void computeInfo(CGFunctionInfo &FI) const override {
+    if (!getCXXABI().classifyReturnType(FI))
+      FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+    for (auto &I : FI.arguments())
+      I.info = classifyArgumentType(I.type);
+  }
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+                    QualType Ty) const override {
+    return EmitVAArgInstr(CGF, VAListAddr, Ty, classifyArgumentType(Ty));
+  }
+};
+
 class MSP430TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   MSP430TargetCodeGenInfo(CodeGenTypes &CGT)
-      : TargetCodeGenInfo(std::make_unique(CGT)) {}
+      : TargetCodeGenInfo(std::make_unique(CGT)) {}
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
                            CodeGen::CodeGenModule &M) const override;
 };

diff  --git a/clang/test/CodeGen/msp430-abi-complex.c b/clang/test/CodeGen/msp430-abi-complex.c
new file mode 100644
index 000000000000..faafcd2cde3f
--- /dev/null
+++ b/clang/test/CodeGen/msp430-abi-complex.c
@@ -0,0 +1,226 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -Os -S -o- %s | FileCheck %s
+
+volatile int N;
+volatile int i16_1, i16_2;
+volatile long i32_1, i32_2;
+volatile long long i64_1, i64_2;
+volatile float f1, f2;
+volatile double d1, d2;
+
+_Static_assert(sizeof(int) == 2, "Assumption failed");
+_Static_assert(sizeof(long) == 4, "Assumption failed");
+_Static_assert(sizeof(long long) == 8, "Assumption failed");
+
+void complex_i16_arg_first(int _Complex x, int n) {
+// CHECK-LABEL: @complex_i16_arg_first
+  i16_1 = __real__ x;
+// CHECK-DAG: mov r12, &i16_1
+  i16_2 = __imag__ x;
+// CHECK-DAG: mov r13, &i16_2
+  N = n;
+// CHECK-DAG: mov r14, &N
+// CHECK:     ret
+}
+
+void complex_i16_arg_second(int n, int _Complex x) {
+// CHECK-LABEL: @complex_i16_arg_second
+  N = n;
+// CHECK-DAG: mov r12, &N
+  i16_1 = __real__ x;
+// CHECK-DAG: mov r13, &i16_1
+  i16_2 = __imag__ x;
+// CHECK-DAG: mov r14, &i16_2
+// CHECK:     ret
+}
+
+void complex_i32_arg_first(long _Complex x, int n) {
+// CHECK-LABEL: @complex_i32_arg_first
+  i32_1 = __real__ x;
+// CHECK-DAG: mov r12, &i32_1
+// CHECK-DAG: mov r13, &i32_1+2
+  i32_2 = __imag__ x;
+// CHECK-DAG: mov r14, &i32_2
+// CHECK-DAG: mov r15, &i32_2+2
+  N = n;
+// CHECK-DAG: mov 2(r1), &N
+// CHECK:     ret
+}
+
+void complex_i32_arg_second(int n, long _Complex x) {
+// CHECK-LABEL: @complex_i32_arg_second
+  N = n;
+// CHECK-DAG: mov r12, &N
+  i32_1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &i32_1
+// CHECK-DAG: mov 4(r1), &i32_1+2
+  i32_2 = __imag__ x;
+// CHECK-DAG: mov 6(r1), &i32_2
+// CHECK-DAG: mov 8(r1), &i32_2+2
+// CHECK:     ret
+}
+
+void complex_i64_arg_first(long long _Complex x, int n) {
+// CHECK-LABEL: @complex_i64_arg_first
+  i64_1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &i64_1
+// CHECK-DAG: mov 4(r1), &i64_1+2
+// CHECK-DAG: mov 6(r1), &i64_1+4
+// CHECK-DAG: mov 8(r1), &i64_1+6
+  i64_2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), &i64_2
+// CHECK-DAG: mov 12(r1), &i64_2+2
+// CHECK-DAG: mov 14(r1), &i64_2+4
+// CHECK-DAG: mov 16(r1), &i64_2+6
+  N = n;
+// CHECK-DAG: mov r12, &N
+// CHECK:     ret
+}
+
+void complex_i64_arg_second(int n, long long _Complex x) {
+// CHECK-LABEL: @complex_i64_arg_second
+  N = n;
+// CHECK-DAG: mov r12, &N
+  i64_1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &i64_1
+// CHECK-DAG: mov 4(r1), &i64_1+2
+// CHECK-DAG: mov 6(r1), &i64_1+4
+// CHECK-DAG: mov 8(r1), &i64_1+6
+  i64_2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), &i64_2
+// CHECK-DAG: mov 12(r1), &i64_2+2
+// CHECK-DAG: mov 14(r1), &i64_2+4
+// CHECK-DAG: mov 16(r1), &i64_2+6
+// CHECK:     ret
+}
+
+void complex_float_arg_first(float _Complex x, int n) {
+// CHECK-LABEL: @complex_float_arg_first
+  f1 = __real__ x;
+// CHECK-DAG: mov r12, &f1
+// CHECK-DAG: mov r13, &f1+2
+  f2 = __imag__ x;
+// CHECK-DAG: mov r14, &f2
+// CHECK-DAG: mov r15, &f2+2
+  N = n;
+// CHECK-DAG: mov 2(r1), &N
+// CHECK:     ret
+}
+
+void complex_float_arg_second(int n, float _Complex x) {
+// CHECK-LABEL: @complex_float_arg_second
+  N = n;
+// CHECK-DAG: mov r12, &N
+  f1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &f1
+// CHECK-DAG: mov 4(r1), &f1+2
+  f2 = __imag__ x;
+// CHECK-DAG: mov 6(r1), &f2
+// CHECK-DAG: mov 8(r1), &f2+2
+// CHECK:     ret
+}
+
+void complex_double_arg_first(double _Complex x, int n) {
+// CHECK-LABEL: @complex_double_arg_first
+  d1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &d1
+// CHECK-DAG: mov 4(r1), &d1+2
+// CHECK-DAG: mov 6(r1), &d1+4
+// CHECK-DAG: mov 8(r1), &d1+6
+  d2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), &d2
+// CHECK-DAG: mov 12(r1), &d2+2
+// CHECK-DAG: mov 14(r1), &d2+4
+// CHECK-DAG: mov 16(r1), &d2+6
+  N = n;
+// CHECK-DAG: mov r12, &N
+// CHECK:     ret
+}
+
+void complex_double_arg_second(int n, double _Complex x) {
+// CHECK-LABEL: @complex_double_arg_second
+  d1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &d1
+// CHECK-DAG: mov 4(r1), &d1+2
+// CHECK-DAG: mov 6(r1), &d1+4
+// CHECK-DAG: mov 8(r1), &d1+6
+  d2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), &d2
+// CHECK-DAG: mov 12(r1), &d2+2
+// CHECK-DAG: mov 14(r1), &d2+4
+// CHECK-DAG: mov 16(r1), &d2+6
+  N = n;
+// CHECK-DAG: mov r12, &N
+// CHECK:     ret
+}
+
+int _Complex complex_i16_res(void) {
+// CHECK-LABEL: @complex_i16_res
+  int _Complex res;
+  __real__ res = 0x1122;
+// CHECK-DAG: mov #4386, r12
+  __imag__ res = 0x3344;
+// CHECK-DAG: mov #13124, r13
+  return res;
+// CHECK:     ret
+}
+
+long _Complex complex_i32_res(void) {
+// CHECK-LABEL: @complex_i32_res
+  long _Complex res;
+  __real__ res = 0x11223344;
+// CHECK-DAG: mov #13124, r12
+// CHECK-DAG: mov #4386,  r13
+  __imag__ res = 0x55667788;
+// CHECK-DAG: mov #30600, r14
+// CHECK-DAG: mov #21862, r15
+  return res;
+// CHECK:     ret
+}
+
+long long _Complex complex_i64_res(void) {
+// CHECK-LABEL: @complex_i64_res
+  long long _Complex res;
+  __real__ res = 0x1122334455667788;
+// CHECK-DAG: mov #30600,  0(r12)
+// CHECK-DAG: mov #21862,  2(r12)
+// CHECK-DAG: mov #13124,  4(r12)
+// CHECK-DAG: mov #4386,   6(r12)
+  __imag__ res = 0x99aabbccddeeff00;
+// CHECK-DAG: mov #-256,   8(r12)
+// CHECK-DAG: mov #-8722,  10(r12)
+// CHECK-DAG: mov #-17460, 12(r12)
+// CHECK-DAG: mov #-26198, 14(r12)
+  return res;
+// CHECK:     ret
+}
+
+float _Complex complex_float_res(void) {
+// CHECK-LABEL: @complex_float_res
+  float _Complex res;
+  __real__ res = 1;
+// CHECK-DAG: clr r12
+// CHECK-DAG: mov #16256, r13
+  __imag__ res = -1;
+// CHECK-DAG: clr r14
+// CHECK-DAG: mov #-16512, r15
+  return res;
+// CHECK:     ret
+}
+
+double _Complex complex_double_res(void) {
+// CHECK-LABEL: @complex_double_res
+  double _Complex res;
+  __real__ res = 1;
+// CHECK-DAG: clr 0(r12)
+// CHECK-DAG: clr 2(r12)
+// CHECK-DAG: clr 4(r12)
+// CHECK-DAG: mov #16368, 6(r12)
+  __imag__ res = -1;
+// CHECK-DAG: clr 8(r12)
+// CHECK-DAG: clr 10(r12)
+// CHECK-DAG: clr 12(r12)
+// CHECK-DAG: mov #-16400, 14(r12)
+  return res;
+// CHECK:     ret
+}


        

From cfe-commits at lists.llvm.org  Thu Jul  9 08:32:09 2020
From: cfe-commits at lists.llvm.org (Anatoly Trosinenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:32:09 +0000 (UTC)
Subject: [PATCH] D82646: [MSP430] Align the _Complex ABI with current
 msp430-gcc
In-Reply-To: 
References: 
Message-ID: <1290dc3b7e80d7e6968a416ca821661f@localhost.localdomain>

This revision was automatically updated to reflect the committed changes.
Closed by commit rG67422e429475: [MSP430] Align the _Complex ABI with current msp430-gcc (authored by atrosinenko).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82646/new/

https://reviews.llvm.org/D82646

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/msp430-abi-complex.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82646.276745.patch
Type: text/x-patch
Size: 7982 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 08:34:46 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:34:46 +0000 (UTC)
Subject: [PATCH] D83419: [clangd] Add error() function for creating
 formatv-style llvm::Errors. NFC
In-Reply-To: 
References: 
Message-ID: <746358d5ae8434e48ef2c3c6d556fdb2@localhost.localdomain>

sammccall added a comment.

In D83419#2141433 , @hokein wrote:

> > Sorry, I should give some reasons here:
>
> These are sensible reasons. My only (not a strong) concern is that "error" is quite special, we need to be careful to choose it -- note that there is an `error` function in glibc which is used for error-reporting.


Yeah. This is also true of `log` which is is a c standard library function. I've seen slightly funny diagnostics when the header is missing, but no worse than that. It's not possible to actually call the wrong function here - neither of the first two parameters of glibc `error()` can be a string.

> maybe there are other better names (`stringError`?) other than `createError`/`makeError`.

Maybe, it's hard to know what's important enough to include in the name. Neither the fact that the implementation stores a string, or that we're allocating an object seem to qualify to me.
Maybe something to do with the formatting like `errorV` or `fmtError` or something but they seem pretty ugly. The difficulty of being part of the `log` family, which doesn't have suffixes...

>> I guess makeError is still better than the status quo, but not enough to feel motivated to clean this up right now. Maybe someone else wants to pick this up?
> 
> unless you strongly insist on `error` name, I'm happy to help with (looks like it's just a low-hanging rename fruit). I think this is a nice cleanup, we should make it happen (either using `error` or other names).

Sure. I'm probably letting the perfect be the enemy of the good here, still sad about the json::Value::asInt() -> json::Value::getAsInt() thing...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83419/new/

https://reviews.llvm.org/D83419




From cfe-commits at lists.llvm.org  Thu Jul  9 08:34:52 2020
From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:34:52 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <32d909c9f2c420c8808ab5483f473109@localhost.localdomain>

cchen added a comment.

@ABataev , can you commit this patch for me when you have time? Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Thu Jul  9 08:35:59 2020
From: cfe-commits at lists.llvm.org (Alexey Bataev via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:35:59 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <7408a2dd204e996e15e60f8436a071a0@localhost.localdomain>

ABataev added a comment.

In D82800#2141818 , @cchen wrote:

> @ABataev , can you commit this patch for me when you have time? Thanks.


I think you can request commit access from Chris Lattner and commit it yourself.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Thu Jul  9 08:36:11 2020
From: cfe-commits at lists.llvm.org (JF Bastien via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:36:11 +0000 (UTC)
Subject: [PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check
In-Reply-To: 
References: 
Message-ID: <3800abc89a858b59ecda4785ddef5737@localhost.localdomain>

jfb added a comment.

It seems like you don't want this check to trigger on POSIX platforms, given:

> Exceptions CON37-C-EX1: Implementations such as POSIX that provide defined behavior when multithreaded programs use custom signal handlers are exempt from this rule [IEEE Std 1003.1-2013].


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75229/new/

https://reviews.llvm.org/D75229




From cfe-commits at lists.llvm.org  Thu Jul  9 08:44:51 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via cfe-commits)
Date: Thu, 09 Jul 2020 08:44:51 -0700 (PDT)
Subject: [clang] 3cca818 - Refactored NumericLiteralParser to not require a
 Preprocessor
Message-ID: <5f073b73.1c69fb81.1ff27.890c@mx.google.com>


Author: Dmitri Gribenko
Date: 2020-07-09T17:33:58+02:00
New Revision: 3cca818efabbccdde36b06609cf75ee7caa8e012

URL: https://github.com/llvm/llvm-project/commit/3cca818efabbccdde36b06609cf75ee7caa8e012
DIFF: https://github.com/llvm/llvm-project/commit/3cca818efabbccdde36b06609cf75ee7caa8e012.diff

LOG: Refactored NumericLiteralParser to not require a Preprocessor

Summary:
We would like to use NumericLiteralParser in the implementation of the
syntax tree builder, and plumbing a preprocessor there seems
inconvenient and superfluous.

Reviewers: eduucaldas

Reviewed By: eduucaldas

Subscribers: gribozavr2, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D83480

Added: 
    

Modified: 
    clang/include/clang/Lex/LiteralSupport.h
    clang/lib/Lex/LiteralSupport.cpp
    clang/lib/Lex/PPExpressions.cpp
    clang/lib/Lex/Preprocessor.cpp
    clang/lib/Sema/SemaExpr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Lex/LiteralSupport.h b/clang/include/clang/Lex/LiteralSupport.h
index 6829771b2830..0c4f0fe277b7 100644
--- a/clang/include/clang/Lex/LiteralSupport.h
+++ b/clang/include/clang/Lex/LiteralSupport.h
@@ -40,7 +40,9 @@ void expandUCNs(SmallVectorImpl &Buf, StringRef Input);
 /// of a ppnumber, classifying it as either integer, floating, or erroneous,
 /// determines the radix of the value and can convert it to a useful value.
 class NumericLiteralParser {
-  Preprocessor &PP; // needed for diagnostics
+  const SourceManager &SM;
+  const LangOptions &LangOpts;
+  DiagnosticsEngine &Diags;
 
   const char *const ThisTokBegin;
   const char *const ThisTokEnd;
@@ -54,9 +56,9 @@ class NumericLiteralParser {
   SmallString<32> UDSuffixBuf;
 
 public:
-  NumericLiteralParser(StringRef TokSpelling,
-                       SourceLocation TokLoc,
-                       Preprocessor &PP);
+  NumericLiteralParser(StringRef TokSpelling, SourceLocation TokLoc,
+                       const SourceManager &SM, const LangOptions &LangOpts,
+                       const TargetInfo &Target, DiagnosticsEngine &Diags);
   bool hadError : 1;
   bool isUnsigned : 1;
   bool isLong : 1;          // This is *not* set for long long.

diff  --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index f44614b4bec4..eb16bc8c7da2 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -525,8 +525,12 @@ static void EncodeUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf,
 ///
 NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
                                            SourceLocation TokLoc,
-                                           Preprocessor &PP)
-  : PP(PP), ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
+                                           const SourceManager &SM,
+                                           const LangOptions &LangOpts,
+                                           const TargetInfo &Target,
+                                           DiagnosticsEngine &Diags)
+    : SM(SM), LangOpts(LangOpts), Diags(Diags),
+      ThisTokBegin(TokSpelling.begin()), ThisTokEnd(TokSpelling.end()) {
 
   // This routine assumes that the range begin/end matches the regex for integer
   // and FP constants (specifically, the 'pp-number' regex), and assumes that
@@ -572,7 +576,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
   checkSeparator(TokLoc, s, CSK_AfterDigits);
 
   // Initial scan to lookahead for fixed point suffix.
-  if (PP.getLangOpts().FixedPoint) {
+  if (LangOpts.FixedPoint) {
     for (const char *c = s; c != ThisTokEnd; ++c) {
       if (*c == 'r' || *c == 'k' || *c == 'R' || *c == 'K') {
         saw_fixed_point_suffix = true;
@@ -592,14 +596,16 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
     switch (*s) {
     case 'R':
     case 'r':
-      if (!PP.getLangOpts().FixedPoint) break;
+      if (!LangOpts.FixedPoint)
+        break;
       if (isFract || isAccum) break;
       if (!(saw_period || saw_exponent)) break;
       isFract = true;
       continue;
     case 'K':
     case 'k':
-      if (!PP.getLangOpts().FixedPoint) break;
+      if (!LangOpts.FixedPoint)
+        break;
       if (isFract || isAccum) break;
       if (!(saw_period || saw_exponent)) break;
       isAccum = true;
@@ -607,7 +613,8 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
     case 'h':      // FP Suffix for "half".
     case 'H':
       // OpenCL Extension v1.2 s9.5 - h or H suffix for half type.
-      if (!(PP.getLangOpts().Half || PP.getLangOpts().FixedPoint)) break;
+      if (!(LangOpts.Half || LangOpts.FixedPoint))
+        break;
       if (isIntegerLiteral()) break;  // Error for integer constant.
       if (isHalf || isFloat || isLong) break; // HH, FH, LH invalid.
       isHalf = true;
@@ -621,8 +628,8 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
       // CUDA host and device may have 
diff erent _Float16 support, therefore
       // allows f16 literals to avoid false alarm.
       // ToDo: more precise check for CUDA.
-      if ((PP.getTargetInfo().hasFloat16Type() || PP.getLangOpts().CUDA) &&
-          s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
+      if ((Target.hasFloat16Type() || LangOpts.CUDA) && s + 2 < ThisTokEnd &&
+          s[1] == '1' && s[2] == '6') {
         s += 2; // success, eat up 2 characters.
         isFloat16 = true;
         continue;
@@ -657,10 +664,10 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
       } else {
         isLong = true;
       }
-      continue;  // Success.
+      continue; // Success.
     case 'i':
     case 'I':
-      if (PP.getLangOpts().MicrosoftExt) {
+      if (LangOpts.MicrosoftExt) {
         if (isLong || isLongLong || MicrosoftInteger)
           break;
 
@@ -713,7 +720,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
   if (s != ThisTokEnd || isImaginary) {
     // FIXME: Don't bother expanding UCNs if !tok.hasUCN().
     expandUCNs(UDSuffixBuf, StringRef(SuffixBegin, ThisTokEnd - SuffixBegin));
-    if (isValidUDSuffix(PP.getLangOpts(), UDSuffixBuf)) {
+    if (isValidUDSuffix(LangOpts, UDSuffixBuf)) {
       if (!isImaginary) {
         // Any suffix pieces we might have parsed are actually part of the
         // ud-suffix.
@@ -736,8 +743,9 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
 
     if (s != ThisTokEnd) {
       // Report an error if there are any.
-      PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, SuffixBegin - ThisTokBegin),
-              diag::err_invalid_suffix_constant)
+      Diags.Report(Lexer::AdvanceToTokenCharacter(
+                       TokLoc, SuffixBegin - ThisTokBegin, SM, LangOpts),
+                   diag::err_invalid_suffix_constant)
           << StringRef(SuffixBegin, ThisTokEnd - SuffixBegin)
           << (isFixedPointConstant ? 2 : isFPConstant);
       hadError = true;
@@ -758,9 +766,11 @@ void NumericLiteralParser::ParseDecimalOrOctalCommon(SourceLocation TokLoc){
   // If we have a hex digit other than 'e' (which denotes a FP exponent) then
   // the code is using an incorrect base.
   if (isHexDigit(*s) && *s != 'e' && *s != 'E' &&
-      !isValidUDSuffix(PP.getLangOpts(), StringRef(s, ThisTokEnd - s))) {
-    PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
-            diag::err_invalid_digit) << StringRef(s, 1) << (radix == 8 ? 1 : 0);
+      !isValidUDSuffix(LangOpts, StringRef(s, ThisTokEnd - s))) {
+    Diags.Report(
+        Lexer::AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin, SM, LangOpts),
+        diag::err_invalid_digit)
+        << StringRef(s, 1) << (radix == 8 ? 1 : 0);
     hadError = true;
     return;
   }
@@ -786,8 +796,9 @@ void NumericLiteralParser::ParseDecimalOrOctalCommon(SourceLocation TokLoc){
       s = first_non_digit;
     } else {
       if (!hadError) {
-        PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
-                diag::err_exponent_has_no_digits);
+        Diags.Report(Lexer::AdvanceToTokenCharacter(
+                         TokLoc, Exponent - ThisTokBegin, SM, LangOpts),
+                     diag::err_exponent_has_no_digits);
         hadError = true;
       }
       return;
@@ -833,9 +844,10 @@ void NumericLiteralParser::checkSeparator(SourceLocation TokLoc,
     return;
 
   if (isDigitSeparator(*Pos)) {
-    PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Pos - ThisTokBegin),
-            diag::err_digit_separator_not_between_digits)
-      << IsAfterDigits;
+    Diags.Report(Lexer::AdvanceToTokenCharacter(TokLoc, Pos - ThisTokBegin, SM,
+                                                LangOpts),
+                 diag::err_digit_separator_not_between_digits)
+        << IsAfterDigits;
     hadError = true;
   }
 }
@@ -873,9 +885,10 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
     }
 
     if (!HasSignificandDigits) {
-      PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
-              diag::err_hex_constant_requires)
-          << PP.getLangOpts().CPlusPlus << 1;
+      Diags.Report(Lexer::AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin, SM,
+                                                  LangOpts),
+                   diag::err_hex_constant_requires)
+          << LangOpts.CPlusPlus << 1;
       hadError = true;
       return;
     }
@@ -891,8 +904,9 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
       const char *first_non_digit = SkipDigits(s);
       if (!containsDigits(s, first_non_digit)) {
         if (!hadError) {
-          PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Exponent-ThisTokBegin),
-                  diag::err_exponent_has_no_digits);
+          Diags.Report(Lexer::AdvanceToTokenCharacter(
+                           TokLoc, Exponent - ThisTokBegin, SM, LangOpts),
+                       diag::err_exponent_has_no_digits);
           hadError = true;
         }
         return;
@@ -900,16 +914,17 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
       checkSeparator(TokLoc, s, CSK_BeforeDigits);
       s = first_non_digit;
 
-      if (!PP.getLangOpts().HexFloats)
-        PP.Diag(TokLoc, PP.getLangOpts().CPlusPlus
-                            ? diag::ext_hex_literal_invalid
-                            : diag::ext_hex_constant_invalid);
-      else if (PP.getLangOpts().CPlusPlus17)
-        PP.Diag(TokLoc, diag::warn_cxx17_hex_literal);
+      if (!LangOpts.HexFloats)
+        Diags.Report(TokLoc, LangOpts.CPlusPlus
+                                 ? diag::ext_hex_literal_invalid
+                                 : diag::ext_hex_constant_invalid);
+      else if (LangOpts.CPlusPlus17)
+        Diags.Report(TokLoc, diag::warn_cxx17_hex_literal);
     } else if (saw_period) {
-      PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin),
-              diag::err_hex_constant_requires)
-          << PP.getLangOpts().CPlusPlus << 0;
+      Diags.Report(Lexer::AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin, SM,
+                                                  LangOpts),
+                   diag::err_hex_constant_requires)
+          << LangOpts.CPlusPlus << 0;
       hadError = true;
     }
     return;
@@ -918,12 +933,10 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
   // Handle simple binary numbers 0b01010
   if ((c1 == 'b' || c1 == 'B') && (s[1] == '0' || s[1] == '1')) {
     // 0b101010 is a C++1y / GCC extension.
-    PP.Diag(TokLoc,
-            PP.getLangOpts().CPlusPlus14
-              ? diag::warn_cxx11_compat_binary_literal
-              : PP.getLangOpts().CPlusPlus
-                ? diag::ext_binary_literal_cxx14
-                : diag::ext_binary_literal);
+    Diags.Report(TokLoc, LangOpts.CPlusPlus14
+                             ? diag::warn_cxx11_compat_binary_literal
+                         : LangOpts.CPlusPlus ? diag::ext_binary_literal_cxx14
+                                              : diag::ext_binary_literal);
     ++s;
     assert(s < ThisTokEnd && "didn't maximally munch?");
     radix = 2;
@@ -932,10 +945,11 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
     if (s == ThisTokEnd) {
       // Done.
     } else if (isHexDigit(*s) &&
-               !isValidUDSuffix(PP.getLangOpts(),
-                                StringRef(s, ThisTokEnd - s))) {
-      PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-ThisTokBegin),
-              diag::err_invalid_digit) << StringRef(s, 1) << 2;
+               !isValidUDSuffix(LangOpts, StringRef(s, ThisTokEnd - s))) {
+      Diags.Report(Lexer::AdvanceToTokenCharacter(TokLoc, s - ThisTokBegin, SM,
+                                                  LangOpts),
+                   diag::err_invalid_digit)
+          << StringRef(s, 1) << 2;
       hadError = true;
     }
     // Other suffixes will be diagnosed by the caller.

diff  --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 7a158a31490d..8c120c13d7d2 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -295,7 +295,9 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
     if (NumberInvalid)
       return true; // a diagnostic was already reported
 
-    NumericLiteralParser Literal(Spelling, PeekTok.getLocation(), PP);
+    NumericLiteralParser Literal(Spelling, PeekTok.getLocation(),
+                                 PP.getSourceManager(), PP.getLangOpts(),
+                                 PP.getTargetInfo(), PP.getDiagnostics());
     if (Literal.hadError)
       return true; // a diagnostic was already reported.
 

diff  --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 105aa6683c8b..160e2b6ed884 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1370,7 +1370,9 @@ bool Preprocessor::parseSimpleIntegerLiteral(Token &Tok, uint64_t &Value) {
   StringRef Spelling = getSpelling(Tok, IntegerBuffer, &NumberInvalid);
   if (NumberInvalid)
     return false;
-  NumericLiteralParser Literal(Spelling, Tok.getLocation(), *this);
+  NumericLiteralParser Literal(Spelling, Tok.getLocation(), getSourceManager(),
+                               getLangOpts(), getTargetInfo(),
+                               getDiagnostics());
   if (Literal.hadError || !Literal.isIntegerLiteral() || Literal.hasUDSuffix())
     return false;
   llvm::APInt APVal(64, 0);

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e1433d293286..986c03bb872b 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3634,7 +3634,9 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
   if (Invalid)
     return ExprError();
 
-  NumericLiteralParser Literal(TokSpelling, Tok.getLocation(), PP);
+  NumericLiteralParser Literal(TokSpelling, Tok.getLocation(),
+                               PP.getSourceManager(), PP.getLangOpts(),
+                               PP.getTargetInfo(), PP.getDiagnostics());
   if (Literal.hadError)
     return ExprError();
 


        

From cfe-commits at lists.llvm.org  Thu Jul  9 08:44:54 2020
From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:44:54 +0000 (UTC)
Subject: [PATCH] D83480: Refactored NumericLiteralParser to not require a
 Preprocessor
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG3cca818efabb: Refactored NumericLiteralParser to not require a Preprocessor (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83480/new/

https://reviews.llvm.org/D83480

Files:
  clang/include/clang/Lex/LiteralSupport.h
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaExpr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83480.276750.patch
Type: text/x-patch
Size: 12737 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 08:52:45 2020
From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 15:52:45 +0000 (UTC)
Subject: [PATCH] D82800: [OPENMP50] extend array section for stride
 (Parsing/Sema/AST)
In-Reply-To: 
References: 
Message-ID: <73f66251d77aa8ad92f5780014804de8@localhost.localdomain>

cchen added a comment.

In D82800#2141819 , @ABataev wrote:

> In D82800#2141818 , @cchen wrote:
>
> > @ABataev , can you commit this patch for me when you have time? Thanks.
>
>
> I think you can request commit access from Chris Lattner and commit it yourself.


I'll do that, thanks for telling!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82800/new/

https://reviews.llvm.org/D82800




From cfe-commits at lists.llvm.org  Thu Jul  9 09:06:42 2020
From: cfe-commits at lists.llvm.org (Sergej Jaskiewicz via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:06:42 +0000 (UTC)
Subject: [PATCH] D83490: [cmake] Support running compiler-rt tests in
 CrossWinToARMLinux.cmake
Message-ID: 

broadwaylamb created this revision.
broadwaylamb added a reviewer: vvereschaka.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls, mgorny, dberris.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83490

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===================================================================
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -72,6 +72,7 @@
 set(COMPILER_RT_BUILD_LIBFUZZER             OFF CACHE BOOL "")
 set(COMPILER_RT_BUILD_PROFILE               OFF CACHE BOOL "")
 set(COMPILER_RT_DEFAULT_TARGET_ONLY         ON CACHE BOOL "")
+set(COMPILER_RT_INCLUDE_TESTS               ON CACHE BOOL "")
 
 set(LIBUNWIND_USE_COMPILER_RT               ON CACHE BOOL "")
 set(LIBUNWIND_TARGET_TRIPLE                 "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
@@ -108,6 +109,10 @@
   set(DEFAULT_TEST_TARGET_INFO              "libcxx.test.target_info.LinuxRemoteTI")
 
   # Allow override with the custom values.
+  if(NOT DEFINED COMPILER_RT_EMULATOR)
+    set(COMPILER_RT_EMULATOR                "\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/libcxx/utils/ssh.py\\\" --execdir %%T --test-executable %%t --host ${REMOTE_TEST_USER}@${REMOTE_TEST_HOST} --" CACHE STRING "")
+  endif()
+  
   if(NOT DEFINED LIBUNWIND_TARGET_INFO)
     set(LIBUNWIND_TARGET_INFO               "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
   endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83490.276756.patch
Type: text/x-patch
Size: 1223 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 09:10:09 2020
From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:10:09 +0000 (UTC)
Subject: [PATCH] D82436: [clangd] Implement textDocument/foldingRange
In-Reply-To: 
References: 
Message-ID: 

sammccall added a comment.

Tests :-)



================
Comment at: clang-tools-extra/clangd/Protocol.h:1522
+struct FoldingRange {
+  unsigned startLine;
+  llvm::Optional startCharacter;
----------------
nit: =0 (and on endLine)


================
Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:107
+  // FIXME(kirillbobyrev): getDocumentSymbols() is conveniently available but
+  // limited (e.g. doesn't yield blocks inside functions). Replace this with a
+  // more general RecursiveASTVisitor implementation instead.
----------------
I think this should mention the contents-of-blocks vs whole-nodes issue too.


================
Comment at: clang-tools-extra/clangd/SemanticSelection.h:28
 
+/// Retrieves folding ranges in the "main file" section of given AST.
+llvm::Expected> getFoldingRanges(ParsedAST &AST);
----------------
I think "main file" section is just a for-now implementation detail, I'd leave this out.


================
Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:300
+opt FoldingRanges{
+    "folding-rangees",
+    cat(Features),
----------------
rangees -> ranges


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82436/new/

https://reviews.llvm.org/D82436




From cfe-commits at lists.llvm.org  Thu Jul  9 09:15:30 2020
From: cfe-commits at lists.llvm.org (serge via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:15:30 +0000 (UTC)
Subject: [PATCH] D82767: clang-format: Explicitly use python3
In-Reply-To: 
References: 
Message-ID: <924f4a03ccb93730b5c2e59d46a1cb2b@localhost.localdomain>

serge-sans-paille added a comment.

In D82767#2132903 , @MyDeveloperDay wrote:

> We may not be consistent across all of LLVM
>
>   $ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort | uniq -c
>         6 #! /usr/bin/env python
>         2 #! /usr/bin/env python3
>         2 #! /usr/bin/python
>         1 #!/bin/env python
>       133 #!/usr/bin/env python
>        13 #!/usr/bin/env python3
>        49 #!/usr/bin/python
>


My understanding is that explicitly requiring python3 may make sense if the script is not backward-compatible with python2, while requiring python means the version is not important.
At the end-of-year, we should be able to harmonize shebangs to #!/usr/bin/env python3 or #!/usr/bin/env python


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82767/new/

https://reviews.llvm.org/D82767




From cfe-commits at lists.llvm.org  Thu Jul  9 09:18:31 2020
From: cfe-commits at lists.llvm.org (Saleem Abdulrasool via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:18:31 +0000 (UTC)
Subject: [PATCH] D83426: Unbreak Clang standalone build.
In-Reply-To: 
References: 
Message-ID: 

compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Seems reasonable to me, this seems like it would be useful to downstream packagers for Linux distros.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83426/new/

https://reviews.llvm.org/D83426




From cfe-commits at lists.llvm.org  Thu Jul  9 09:38:03 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:38:03 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: <2d903d28da0c2e2e2bedef648ecf5bd2@localhost.localdomain>

martong updated this revision to Diff 276759.
martong added a comment.

- Reuse summaries with accept and other functions when sockaddr is a union of pointers


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83407.276759.patch
Type: text/x-patch
Size: 28047 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 09:41:48 2020
From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:41:48 +0000 (UTC)
Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX
 networking functions
In-Reply-To: 
References: 
Message-ID: 

martong marked 2 inline comments as done.
martong added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1735-1747
+      if (!addToFunctionSummaryMap(
+              "accept", Summary(ArgTypes{IntTy, *StructSockaddrPtrRestrictTy,
+                                         *Socklen_tPtrRestrictTy},
+                                RetType{IntTy}, NoEvalCall)
+                            .ArgConstraint(ArgumentCondition(
+                                0, WithinRange, Range(0, IntMax)))))
+        // Do not add constraints on sockaddr.
----------------
Szelethus wrote:
> martong wrote:
> > Szelethus wrote:
> > > This is quite a bit of code duplication -- if we failed to match the precise `accept`, we just try again with the middle argument type being unspecified? Whats the difference between this and trying to match with `Irrelevant` straight away?
> > >  if we failed to match the precise accept, we just try again with the middle argument type being unspecified?
> > Yes. And that will be a successful match in the case where `sockaddr` is a transparent union.
> > 
> > > Whats the difference between this and trying to match with Irrelevant straight away?
> > Yeah, it's a good catch. There is no difference with `accept` because we don't have any constraints on `sockaddr` anyway. But, the other functions have fewer constraints with the transparent union.
> > Perhaps we should separate the body of the `Summary` from the `Signature` and in this case we could reuse that for both signatures. Or as you suggested we could just match by default with the `Irrelevant`. What do you think?
> > Perhaps we should separate the body of the Summary from the Signature and in this case we could reuse that for both signatures. Or as you suggested we could just match by default with the Irrelevant. What do you think?
> 
> Separating the summary and the signature sounds great! But, that also adds sufficiently complex code that would definitely warrant individual tests, so we should add that as well.
Ok, so I added a new overload to `addToFunctionSummaryMap` that can take a `Signature`. This signature is set to the given Summary, this way we can avoid the code duplication. Note, this change involved that the Signature is no longer a const member of the Summary, plus the Args and Ret cannot be a const member anymore of the Signature (we have to overwrite the signature of the given summary and that involves the copy assignment op).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83407/new/

https://reviews.llvm.org/D83407




From cfe-commits at lists.llvm.org  Thu Jul  9 09:56:04 2020
From: cfe-commits at lists.llvm.org (Saiyedul Islam via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 16:56:04 +0000 (UTC)
Subject: [PATCH] D83492: [OpenMP] Use common interface to access GPU Grid
 Values
Message-ID: 

saiislam created this revision.
saiislam added reviewers: jdoerfert, ABataev, JonChesterfield.
Herald added subscribers: cfe-commits, sstefan1, guansong, yaxunl, jholewinski.
Herald added a project: clang.

Use common interface for accessing target specific GPU grid values in NVPTX
OpenMP codegen as proposed in https://reviews.llvm.org/D80917

Originally authored by Greg Rodgers (@gregrodgers).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83492

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp


Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===================================================================
--- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Cuda.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/IR/IntrinsicsNVPTX.h"
 
 using namespace clang;
@@ -196,11 +197,10 @@
 /// code.  For all practical purposes this is fine because the configuration
 /// is the same for all known NVPTX architectures.
 enum MachineConfiguration : unsigned {
-  WarpSize = 32,
-  /// Number of bits required to represent a lane identifier, which is
-  /// computed as log_2(WarpSize).
+  /// Number of bits required to represent a lane identifier
+  /// See "llvm/Frontend/OpenMP/OMPGridValues.h" for various related target
+  /// specific Grid Values like GV_Warp_Size
   LaneIDBits = 5,
-  LaneIDMask = WarpSize - 1,
 
   /// Global memory alignment for performance.
   GlobalMemoryAlignment = 128,
@@ -436,6 +436,7 @@
       EscapedDeclsForTeams = EscapedDecls.getArrayRef();
     else
       EscapedDeclsForParallel = EscapedDecls.getArrayRef();
+    unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
     GlobalizedRD = ::buildRecordForGlobalizedVars(
         CGF.getContext(), EscapedDeclsForParallel, EscapedDeclsForTeams,
         MappedDeclsFields, WarpSize);
@@ -624,6 +625,12 @@
 
 /// Get the GPU warp size.
 static llvm::Value *getNVPTXWarpSize(CodeGenFunction &CGF) {
+  if (CGF.getTarget().getTriple().isAMDGCN()) {
+    CGBuilderTy &Bld = CGF.Builder;
+    // return constant compile-time target-specific warp size
+    unsigned WarpSize = CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
+    return Bld.getInt32(WarpSize);
+  }
   return CGF.EmitRuntimeCall(
       llvm::Intrinsic::getDeclaration(
           &CGF.CGM.getModule(), llvm::Intrinsic::nvvm_read_ptx_sreg_warpsize),
@@ -643,6 +650,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXWarpID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDBits =
+      CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2);
   return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id");
 }
 
@@ -651,6 +660,8 @@
 /// on the NVPTX device, to generate more efficient code.
 static llvm::Value *getNVPTXLaneID(CodeGenFunction &CGF) {
   CGBuilderTy &Bld = CGF.Builder;
+  unsigned LaneIDMask = CGF.getContext().getTargetInfo().getGridValue(
+      llvm::omp::GV_Warp_Size_Log2_Mask);
   return Bld.CreateAnd(getNVPTXThreadID(CGF), Bld.getInt32(LaneIDMask),
                        "nvptx_lane_id");
 }
@@ -2073,6 +2084,7 @@
     getTeamsReductionVars(CGM.getContext(), D, LastPrivatesReductions);
   if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD) {
     getDistributeLastprivateVars(CGM.getContext(), D, LastPrivatesReductions);
+    unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
     if (!LastPrivatesReductions.empty()) {
       GlobalizedRD = ::buildRecordForGlobalizedVars(
           CGM.getContext(), llvm::None, LastPrivatesReductions,
@@ -3243,6 +3255,7 @@
       "__openmp_nvptx_data_transfer_temporary_storage";
   llvm::GlobalVariable *TransferMedium =
       M.getGlobalVariable(TransferMediumName);
+  unsigned WarpSize = CGM.getTarget().getGridValue(llvm::omp::GV_Warp_Size);
   if (!TransferMedium) {
     auto *Ty = llvm::ArrayType::get(CGM.Int32Ty, WarpSize);
     unsigned SharedAddressSpace = C.getTargetAddressSpace(LangAS::cuda_shared);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83492.276767.patch
Type: text/x-patch
Size: 3658 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 10:04:54 2020
From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:04:54 +0000 (UTC)
Subject: [PATCH] D82728: [clang] Add -Wsuggest-override
In-Reply-To: 
References: 
Message-ID: <4c620732b5a1b9258ba35cb27cf40bfe@localhost.localdomain>

logan-5 added a comment.

Feels like a dumb question, but I'm not sure if and how those build failures are related to this patch? They seem to involve completely separate parts of the LLVM project (and `.c` files to boot). Was it that the build was failing for an unrelated reason at the moment the bots happened to build this patch? Or am I misunderstanding something more obvious?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82728/new/

https://reviews.llvm.org/D82728




From cfe-commits at lists.llvm.org  Thu Jul  9 10:15:58 2020
From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:15:58 +0000 (UTC)
Subject: [PATCH] D83492: [OpenMP] Use common interface to access GPU Grid
 Values
In-Reply-To: 
References: 
Message-ID: 

JonChesterfield added a comment.

Changing to getGridValue would be useful for sharing parts of this with amdgcn.

The aomp toolchain handles codegen for amdgcn by adding if (isAMDGCN) to this file. Until such time as tregions obsoletes this code, I think we should go with layers instead of scattered conditionals.

I.e. rename CGOpenMPRuntimeNVPTX to CGOpenMPRuntimeGPU which contains code that is common to nvptx and amdgcn. That probably uses getGridValue() as a way to abstract over minor differences. Derive CGOpenMPRuntimeAMDGCN and CGOpenMPRuntimeNVPTX from CGOpenMPRuntimeGPU to implement (virtual) functions which are different between the two.



================
Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:628
 static llvm::Value *getNVPTXWarpSize(CodeGenFunction &CGF) {
+  if (CGF.getTarget().getTriple().isAMDGCN()) {
+    CGBuilderTy &Bld = CGF.Builder;
----------------
This looks unrelated to using the constants. Amdgcn doesn't have an nvvm_read_ptx_sreg_warpsize so does need a different means of accessing the wave size, but that's not directly related to using OMPGridValues


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83492/new/

https://reviews.llvm.org/D83492




From cfe-commits at lists.llvm.org  Thu Jul  9 10:19:29 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:19:29 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <49aca8bbc4954f62501c8d2231cfee3d@localhost.localdomain>

eduucaldas updated this revision to Diff 276770.
eduucaldas added a comment.

Add support for integer and floating UDL even for raw literal operator and 
numeric literal operator template


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276770.patch
Type: text/x-patch
Size: 6625 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 10:21:11 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:21:11 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <1e28ede796780c3e3b97c646fb59789e@localhost.localdomain>

eduucaldas updated this revision to Diff 276771.
eduucaldas added a comment.

nothing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276771.patch
Type: text/x-patch
Size: 6113 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 10:24:15 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:24:15 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <1a5430293810c3051730096f3e1d4bed@localhost.localdomain>

eduucaldas marked an inline comment as done.
eduucaldas added inline comments.


================
Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:736
+      auto TokSpelling =
+          Builder.findToken(TokLoc)->text(Context.getSourceManager());
+      auto Literal = NumericLiteralParser{TokSpelling,
----------------
Not sure if text is the right thing to get a `TokenSpelling` from a `syntax::Token`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157




From cfe-commits at lists.llvm.org  Thu Jul  9 10:25:20 2020
From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:25:20 +0000 (UTC)
Subject: [PATCH] D82157: Fix crash on `user defined literals`
In-Reply-To: 
References: 
Message-ID: <7e00b905e45249e3919d672604bf95e1@localhost.localdomain>

eduucaldas updated this revision to Diff 276772.
eduucaldas added a comment.

Nothing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82157/new/

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82157.276772.patch
Type: text/x-patch
Size: 13912 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Thu Jul  9 10:28:09 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Thu, 09 Jul 2020 17:28:09 +0000 (UTC)
Subject: [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency
 unconditional.
In-Reply-To: 
References: 
Message-ID: <5640fd4d0432d74594bcf36bfc60706b@localhost.localdomain>

MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Looks like a good cleanup. Hope someone with more CMake-fu to confirm.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83454/new/

https://reviews.llvm.org/D83454




From cfe-commits at lists.llvm.org  Thu Jul  9 10:29:50 2020
From: cfe-commits at lists.llvm.org (Daniel Grumberg via cfe-commits)
Date: Thu, 09 Jul 2020 10:29:50 -0700 (PDT)
Subject: [clang] fccd29d - Merge TableGen files used for clang options
Message-ID: <5f07540e.1c69fb81.bfdf5.81ea@mx.google.com>


Author: Daniel Grumberg
Date: 2020-07-09T18:28:51+01:00
New Revision: fccd29dddee92ffa7cd8a9adec6e626760538dae

URL: https://github.com/llvm/llvm-project/commit/fccd29dddee92ffa7cd8a9adec6e626760538dae
DIFF: https://github.com/llvm/llvm-project/commit/fccd29dddee92ffa7cd8a9adec6e626760538dae.diff

LOG: Merge TableGen files used for clang options

Summary:
Putting all the options in the same file is needed so they can be
ordered based on the dependencies between them.

Reviewers: Bigcheese, jdoerfert

Subscribers: dexonsmith, sstefan1, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82574

Added: 
    

Modified: 
    clang/include/clang/Driver/Options.td

Removed: 
    clang/include/clang/Driver/CLCompatOptions.td


################################################################################
diff  --git a/clang/include/clang/Driver/CLCompatOptions.td b/clang/include/clang/Driver/CLCompatOptions.td
deleted file mode 100644
index 17d248a3c5ad..000000000000
--- a/clang/include/clang/Driver/CLCompatOptions.td
+++ /dev/null
@@ -1,470 +0,0 @@
-//===--- CLCompatOptions.td - Options for clang-cl ------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file defines the options accepted by clang-cl.
-//
-//===----------------------------------------------------------------------===//
-
-def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
-  HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
-
-def cl_compile_Group : OptionGroup<"">,
-  Group;
-
-def cl_ignored_Group : OptionGroup<"">,
-  Group;
-
-class CLFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[CLOption, DriverOption]>;
-
-class CLCompileFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[CLOption, DriverOption]>;
-
-class CLIgnoredFlag : Option<["/", "-"], name, KIND_FLAG>,
-  Group, Flags<[CLOption, DriverOption]>;
-
-class CLJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[CLOption, DriverOption]>;
-
-class CLCompileJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[CLOption, DriverOption]>;
-
-class CLIgnoredJoined : Option<["/", "-"], name, KIND_JOINED>,
-  Group, Flags<[CLOption, DriverOption, HelpHidden]>;
-
-class CLJoinedOrSeparate : Option<["/", "-"], name,
-  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, DriverOption]>;
-
-class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
-  KIND_JOINED_OR_SEPARATE>, Group,
-  Flags<[CLOption, DriverOption]>;
-
-class CLRemainingArgsJoined : Option<["/", "-"], name,
-  KIND_REMAINING_ARGS_JOINED>, Group, Flags<[CLOption, DriverOption]>;
-
-// Aliases:
-// (We don't put any of these in cl_compile_Group as the options they alias are
-// already in the right group.)
-
-def _SLASH_Brepro : CLFlag<"Brepro">,
-  HelpText<"Do not write current time into COFF output (breaks link.exe /incremental)">,
-  Alias;
-def _SLASH_Brepro_ : CLFlag<"Brepro-">,
-  HelpText<"Write current time into COFF output (default)">,
-  Alias;
-def _SLASH_C : CLFlag<"C">,
-  HelpText<"Do not discard comments when preprocessing">, Alias;
-def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias;
-def _SLASH_d1PP : CLFlag<"d1PP">,
-  HelpText<"Retain macro definitions in /E mode">, Alias
; -def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">, - HelpText<"Dump record layout information">, - Alias, AliasArgs<["-fdump-record-layouts"]>; -def _SLASH_diagnostics_caret : CLFlag<"diagnostics:caret">, - HelpText<"Enable caret and column diagnostics (default)">; -def _SLASH_diagnostics_column : CLFlag<"diagnostics:column">, - HelpText<"Disable caret diagnostics but keep column info">; -def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">, - HelpText<"Disable column and caret diagnostics">; -def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">, - MetaVarName<"">, Alias; -def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias; -def _SLASH_fp_except : CLFlag<"fp:except">, HelpText<"">, Alias; -def _SLASH_fp_except_ : CLFlag<"fp:except-">, - HelpText<"">, Alias; -def _SLASH_fp_fast : CLFlag<"fp:fast">, HelpText<"">, Alias; -def _SLASH_fp_precise : CLFlag<"fp:precise">, - HelpText<"">, Alias; -def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias; -def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>, - HelpText<"Assume thread-local variables are defined in the executable">; -def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">; -def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Do not emit RTTI data">; -def _SLASH_GF : CLIgnoredFlag<"GF">, - HelpText<"Enable string pooling (default)">; -def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">, - Alias; -def _SLASH_GS : CLFlag<"GS">, - HelpText<"Enable buffer security check (default)">; -def _SLASH_GS_ : CLFlag<"GS-">, HelpText<"Disable buffer security check">; -def : CLFlag<"Gs">, HelpText<"Use stack probes (default)">, - Alias, AliasArgs<["4096"]>; -def _SLASH_Gs : CLJoined<"Gs">, - HelpText<"Set stack probe size (default 4096)">, Alias; -def _SLASH_Gy : CLFlag<"Gy">, HelpText<"Put each function in its own section">, - Alias; -def _SLASH_Gy_ : CLFlag<"Gy-">, - HelpText<"Do not put each function in its own section (default)">, - Alias; -def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data item in its own section">, - Alias; -def _SLASH_Gw_ : CLFlag<"Gw-">, - HelpText<"Do not put each data item in its own section (default)">, - Alias; -def _SLASH_help : CLFlag<"help">, Alias, - HelpText<"Display available options">; -def _SLASH_HELP : CLFlag<"HELP">, Alias; -def _SLASH_I : CLJoinedOrSeparate<"I">, - HelpText<"Add directory to include search path">, MetaVarName<"">, - Alias; -def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">, - Alias; - -// The _SLASH_O option handles all the /O flags, but we also provide separate -// aliased options to provide separate help messages. -def _SLASH_O : CLJoined<"O">, - HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">, - MetaVarName<"">; -def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>, - HelpText<"Optimize for size (like /Og /Os /Oy /Ob2 /GF /Gy)">; -def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>, - HelpText<"Optimize for speed (like /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">; -def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>, - HelpText<"Disable function inlining">; -def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>, - HelpText<"Only inline functions explicitly or implicitly marked inline">; -def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>, - HelpText<"Inline functions as deemed beneficial by the compiler">; -def : CLFlag<"Od">, Alias<_SLASH_O>, AliasArgs<["d"]>, - HelpText<"Disable optimization">; -def : CLFlag<"Og">, Alias<_SLASH_O>, AliasArgs<["g"]>, - HelpText<"No effect">; -def : CLFlag<"Oi">, Alias<_SLASH_O>, AliasArgs<["i"]>, - HelpText<"Enable use of builtin functions">; -def : CLFlag<"Oi-">, Alias<_SLASH_O>, AliasArgs<["i-"]>, - HelpText<"Disable use of builtin functions">; -def : CLFlag<"Os">, Alias<_SLASH_O>, AliasArgs<["s"]>, - HelpText<"Optimize for size">; -def : CLFlag<"Ot">, Alias<_SLASH_O>, AliasArgs<["t"]>, - HelpText<"Optimize for speed">; -def : CLFlag<"Ox">, Alias<_SLASH_O>, AliasArgs<["x"]>, - HelpText<"Deprecated (like /Og /Oi /Ot /Oy /Ob2); use /O2">; -def : CLFlag<"Oy">, Alias<_SLASH_O>, AliasArgs<["y"]>, - HelpText<"Enable frame pointer omission (x86 only)">; -def : CLFlag<"Oy-">, Alias<_SLASH_O>, AliasArgs<["y-"]>, - HelpText<"Disable frame pointer omission (x86 only, default)">; - -def _SLASH_QUESTION : CLFlag<"?">, Alias, - HelpText<"Display available options">; -def _SLASH_Qvec : CLFlag<"Qvec">, - HelpText<"Enable the loop vectorization passes">, Alias; -def _SLASH_Qvec_ : CLFlag<"Qvec-">, - HelpText<"Disable the loop vectorization passes">, Alias; -def _SLASH_showIncludes : CLFlag<"showIncludes">, - HelpText<"Print info about included files to stderr">; -def _SLASH_showIncludes_user : CLFlag<"showIncludes:user">, - HelpText<"Like /showIncludes but omit system headers">; -def _SLASH_showFilenames : CLFlag<"showFilenames">, - HelpText<"Print the name of each compiled file">; -def _SLASH_showFilenames_ : CLFlag<"showFilenames-">, - HelpText<"Do not print the name of each compiled file (default)">; -def _SLASH_source_charset : CLCompileJoined<"source-charset:">, - HelpText<"Set source encoding, supports only UTF-8">, - Alias; -def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, - HelpText<"Set runtime encoding, supports only UTF-8">, - Alias; -def _SLASH_std : CLCompileJoined<"std:">, - HelpText<"Set C++ version (c++14,c++17,c++latest)">; -def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">, - MetaVarName<"">, Alias; -def _SLASH_validate_charset : CLFlag<"validate-charset">, - Alias, AliasArgs<["invalid-source-encoding"]>; -def _SLASH_validate_charset_ : CLFlag<"validate-charset-">, - Alias, AliasArgs<["no-invalid-source-encoding"]>; -def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias; -def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias; -def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias; -def _SLASH_W3 : CLFlag<"W3">, HelpText<"Enable -Wall">, Alias; -def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall and -Wextra">, Alias; -def _SLASH_Wall : CLFlag<"Wall">, HelpText<"Enable -Weverything">, - Alias, AliasArgs<["everything"]>; -def _SLASH_WX : CLFlag<"WX">, HelpText<"Treat warnings as errors">, - Alias, AliasArgs<["error"]>; -def _SLASH_WX_ : CLFlag<"WX-">, - HelpText<"Do not treat warnings as errors (default)">, - Alias, AliasArgs<["no-error"]>; -def _SLASH_w_flag : CLFlag<"w">, HelpText<"Disable all warnings">, Alias; -def _SLASH_wd4005 : CLFlag<"wd4005">, Alias, - AliasArgs<["no-macro-redefined"]>; -def _SLASH_wd4018 : CLFlag<"wd4018">, Alias, - AliasArgs<["no-sign-compare"]>; -def _SLASH_wd4100 : CLFlag<"wd4100">, Alias, - AliasArgs<["no-unused-parameter"]>; -def _SLASH_wd4910 : CLFlag<"wd4910">, Alias, - AliasArgs<["no-dllexport-explicit-instantiation-decl"]>; -def _SLASH_wd4996 : CLFlag<"wd4996">, Alias, - AliasArgs<["no-deprecated-declarations"]>; -def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">, - Alias; -def _SLASH_X : CLFlag<"X">, - HelpText<"Do not add %INCLUDE% to include search path">, Alias; -def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">, - HelpText<"Enable C++14 sized global deallocation functions">, - Alias; -def _SLASH_Zc_sizedDealloc_ : CLFlag<"Zc:sizedDealloc-">, - HelpText<"Disable C++14 sized global deallocation functions">, - Alias; -def _SLASH_Zc_alignedNew : CLFlag<"Zc:alignedNew">, - HelpText<"Enable C++17 aligned allocation functions">, - Alias; -def _SLASH_Zc_alignedNew_ : CLFlag<"Zc:alignedNew-">, - HelpText<"Disable C++17 aligned allocation functions">, - Alias; -def _SLASH_Zc_char8_t : CLFlag<"Zc:char8_t">, - HelpText<"Enable char8_t from C++2a">, - Alias; -def _SLASH_Zc_char8_t_ : CLFlag<"Zc:char8_t-">, - HelpText<"Disable char8_t from c++2a">, - Alias; -def _SLASH_Zc_strictStrings : CLFlag<"Zc:strictStrings">, - HelpText<"Treat string literals as const">, Alias, - AliasArgs<["error=c++11-compat-deprecated-writable-strings"]>; -def _SLASH_Zc_threadSafeInit : CLFlag<"Zc:threadSafeInit">, - HelpText<"Enable thread-safe initialization of static variables">, - Alias; -def _SLASH_Zc_threadSafeInit_ : CLFlag<"Zc:threadSafeInit-">, - HelpText<"Disable thread-safe initialization of static variables">, - Alias; -def _SLASH_Zc_trigraphs : CLFlag<"Zc:trigraphs">, - HelpText<"Enable trigraphs">, Alias; -def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">, - HelpText<"Disable trigraphs (default)">, Alias; -def _SLASH_Zc_twoPhase : CLFlag<"Zc:twoPhase">, - HelpText<"Enable two-phase name lookup in templates">, - Alias; -def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">, - HelpText<"Disable two-phase name lookup in templates (default)">, - Alias; -def _SLASH_Z7 : CLFlag<"Z7">, - HelpText<"Enable CodeView debug information in object files">; -def _SLASH_Zd : CLFlag<"Zd">, - HelpText<"Emit debug line number tables only">; -def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>, - HelpText<"Like /Z7">; -def _SLASH_Zp : CLJoined<"Zp">, - HelpText<"Set default maximum struct packing alignment">, - Alias; -def _SLASH_Zp_flag : CLFlag<"Zp">, - HelpText<"Set default maximum struct packing alignment to 1">, - Alias, AliasArgs<["1"]>; -def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">, - Alias; -def _SLASH_openmp_ : CLFlag<"openmp-">, - HelpText<"Disable OpenMP support">, Alias; -def _SLASH_openmp : CLFlag<"openmp">, HelpText<"Enable OpenMP support">, - Alias; -def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">, - HelpText<"Enable OpenMP support with experimental SIMD support">, - Alias; - -// Non-aliases: - -def _SLASH_arch : CLCompileJoined<"arch:">, - HelpText<"Set architecture for code generation">; - -def _SLASH_M_Group : OptionGroup<"">, Group; -def _SLASH_volatile_Group : OptionGroup<"">, - Group; - -def _SLASH_EH : CLJoined<"EH">, HelpText<"Set exception handling model">; -def _SLASH_EP : CLFlag<"EP">, - HelpText<"Disable linemarker output and preprocess to stdout">; -def _SLASH_FA : CLFlag<"FA">, - HelpText<"Output assembly code file during compilation">; -def _SLASH_Fa : CLJoined<"Fa">, - HelpText<"Set assembly output file name (with /FA)">, - MetaVarName<"">; -def _SLASH_fallback : CLCompileFlag<"fallback">, - HelpText<"Fall back to cl.exe if clang-cl fails to compile">; -def _SLASH_FI : CLJoinedOrSeparate<"FI">, - HelpText<"Include file before parsing">, Alias; -def _SLASH_Fe : CLJoined<"Fe">, - HelpText<"Set output executable file name">, - MetaVarName<"">; -def _SLASH_Fi : CLCompileJoined<"Fi">, - HelpText<"Set preprocess output file name (with /P)">, - MetaVarName<"">; -def _SLASH_Fo : CLCompileJoined<"Fo">, - HelpText<"Set output object file (with /c)">, - MetaVarName<"">; -def _SLASH_guard : CLJoined<"guard:">, - HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks">; -def _SLASH_GX : CLFlag<"GX">, - HelpText<"Deprecated; use /EHsc">; -def _SLASH_GX_ : CLFlag<"GX-">, - HelpText<"Deprecated (like not passing /EH)">; -def _SLASH_imsvc : CLJoinedOrSeparate<"imsvc">, - HelpText<"Add to system include search path, as if in %INCLUDE%">, - MetaVarName<"">; -def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">; -def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">; -def _SLASH_link : CLRemainingArgsJoined<"link">, - HelpText<"Forward options to the linker">, MetaVarName<"">; -def _SLASH_MD : Option<["/", "-"], "MD", KIND_FLAG>, Group<_SLASH_M_Group>, - Flags<[CLOption, DriverOption]>, HelpText<"Use DLL run-time">; -def _SLASH_MDd : Option<["/", "-"], "MDd", KIND_FLAG>, Group<_SLASH_M_Group>, - Flags<[CLOption, DriverOption]>, HelpText<"Use DLL debug run-time">; -def _SLASH_MT : Option<["/", "-"], "MT", KIND_FLAG>, Group<_SLASH_M_Group>, - Flags<[CLOption, DriverOption]>, HelpText<"Use static run-time">; -def _SLASH_MTd : Option<["/", "-"], "MTd", KIND_FLAG>, Group<_SLASH_M_Group>, - Flags<[CLOption, DriverOption]>, HelpText<"Use static debug run-time">; -def _SLASH_o : CLJoinedOrSeparate<"o">, - HelpText<"Deprecated (set output file name); use /Fe or /Fe">, - MetaVarName<"">; -def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">; -def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">, - HelpText<"Treat as C source file">, MetaVarName<"">; -def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">; -def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">, - HelpText<"Treat as C++ source file">, MetaVarName<"">; -def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">; -def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>, - Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>, - HelpText<"Volatile loads and stores have standard semantics">; -def _SLASH_vmb : CLFlag<"vmb">, - HelpText<"Use a best-case representation method for member pointers">; -def _SLASH_vmg : CLFlag<"vmg">, - HelpText<"Use a most-general representation for member pointers">; -def _SLASH_vms : CLFlag<"vms">, - HelpText<"Set the default most-general representation to single inheritance">; -def _SLASH_vmm : CLFlag<"vmm">, - HelpText<"Set the default most-general representation to " - "multiple inheritance">; -def _SLASH_vmv : CLFlag<"vmv">, - HelpText<"Set the default most-general representation to " - "virtual inheritance">; -def _SLASH_volatile_ms : Option<["/", "-"], "volatile:ms", KIND_FLAG>, - Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>, - HelpText<"Volatile loads and stores have acquire and release semantics">; -def _SLASH_clang : CLJoined<"clang:">, - HelpText<"Pass to the clang driver">, MetaVarName<"">; -def _SLASH_Zl : CLFlag<"Zl">, - HelpText<"Do not let object file auto-link default libraries">; - -def _SLASH_Yc : CLJoined<"Yc">, - HelpText<"Generate a pch file for all code up to and including ">, - MetaVarName<"">; -def _SLASH_Yu : CLJoined<"Yu">, - HelpText<"Load a pch file and use it instead of all code up to " - "and including ">, - MetaVarName<"">; -def _SLASH_Y_ : CLFlag<"Y-">, - HelpText<"Disable precompiled headers, overrides /Yc and /Yu">; -def _SLASH_Zc_dllexportInlines : CLFlag<"Zc:dllexportInlines">, - HelpText<"dllexport/dllimport inline member functions of dllexport/import classes (default)">; -def _SLASH_Zc_dllexportInlines_ : CLFlag<"Zc:dllexportInlines-">, - HelpText<"Do not dllexport/dllimport inline member functions of dllexport/import classes">; -def _SLASH_Fp : CLJoined<"Fp">, - HelpText<"Set pch file name (with /Yc and /Yu)">, MetaVarName<"">; - -def _SLASH_Gd : CLFlag<"Gd">, - HelpText<"Set __cdecl as a default calling convention">; -def _SLASH_Gr : CLFlag<"Gr">, - HelpText<"Set __fastcall as a default calling convention">; -def _SLASH_Gz : CLFlag<"Gz">, - HelpText<"Set __stdcall as a default calling convention">; -def _SLASH_Gv : CLFlag<"Gv">, - HelpText<"Set __vectorcall as a default calling convention">; -def _SLASH_Gregcall : CLFlag<"Gregcall">, - HelpText<"Set __regcall as a default calling convention">; - -// Ignored: - -def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">; -def _SLASH_bigobj : CLIgnoredFlag<"bigobj">; -def _SLASH_cgthreads : CLIgnoredJoined<"cgthreads">; -def _SLASH_d2FastFail : CLIgnoredFlag<"d2FastFail">; -def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">; -def _SLASH_errorReport : CLIgnoredJoined<"errorReport">; -def _SLASH_FC : CLIgnoredFlag<"FC">; -def _SLASH_Fd : CLIgnoredJoined<"Fd">; -def _SLASH_FS : CLIgnoredFlag<"FS">; -def _SLASH_JMC : CLIgnoredFlag<"JMC">; -def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">; -def _SLASH_nologo : CLIgnoredFlag<"nologo">; -def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">; -def _SLASH_RTC : CLIgnoredJoined<"RTC">; -def _SLASH_sdl : CLIgnoredFlag<"sdl">; -def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">; -def _SLASH_utf8 : CLIgnoredFlag<"utf-8">, - HelpText<"Set source and runtime encoding to UTF-8 (default)">; -def _SLASH_w : CLIgnoredJoined<"w">; -def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">; -def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">; -def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">; -def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; -def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; -def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; -def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; -def _SLASH_ZH_MD5 : CLIgnoredFlag<"ZH:MD5">; -def _SLASH_ZH_SHA1 : CLIgnoredFlag<"ZH:SHA1">; -def _SLASH_ZH_SHA_256 : CLIgnoredFlag<"ZH:SHA_256">; -def _SLASH_Zm : CLIgnoredJoined<"Zm">; -def _SLASH_Zo : CLIgnoredFlag<"Zo">; -def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; - - -// Unsupported: - -def _SLASH_await : CLFlag<"await">; -def _SLASH_constexpr : CLJoined<"constexpr:">; -def _SLASH_AI : CLJoinedOrSeparate<"AI">; -def _SLASH_Bt : CLFlag<"Bt">; -def _SLASH_Bt_plus : CLFlag<"Bt+">; -def _SLASH_clr : CLJoined<"clr">; -def _SLASH_d2 : CLJoined<"d2">; -def _SLASH_doc : CLJoined<"doc">; -def _SLASH_FA_joined : CLJoined<"FA">; -def _SLASH_favor : CLJoined<"favor">; -def _SLASH_F : CLJoinedOrSeparate<"F">; -def _SLASH_Fm : CLJoined<"Fm">; -def _SLASH_Fr : CLJoined<"Fr">; -def _SLASH_FR : CLJoined<"FR">; -def _SLASH_FU : CLJoinedOrSeparate<"FU">; -def _SLASH_Fx : CLFlag<"Fx">; -def _SLASH_G1 : CLFlag<"G1">; -def _SLASH_G2 : CLFlag<"G2">; -def _SLASH_Ge : CLFlag<"Ge">; -def _SLASH_Gh : CLFlag<"Gh">; -def _SLASH_GH : CLFlag<"GH">; -def _SLASH_GL : CLFlag<"GL">; -def _SLASH_GL_ : CLFlag<"GL-">; -def _SLASH_Gm : CLFlag<"Gm">; -def _SLASH_Gm_ : CLFlag<"Gm-">; -def _SLASH_GT : CLFlag<"GT">; -def _SLASH_GZ : CLFlag<"GZ">; -def _SLASH_H : CLFlag<"H">; -def _SLASH_homeparams : CLFlag<"homeparams">; -def _SLASH_hotpatch : CLFlag<"hotpatch">; -def _SLASH_kernel : CLFlag<"kernel">; -def _SLASH_LN : CLFlag<"LN">; -def _SLASH_MP : CLJoined<"MP">; -def _SLASH_Qfast_transcendentals : CLFlag<"Qfast_transcendentals">; -def _SLASH_QIfist : CLFlag<"QIfist">; -def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">; -def _SLASH_Qimprecise_fwaits : CLFlag<"Qimprecise_fwaits">; -def _SLASH_Qpar : CLFlag<"Qpar">; -def _SLASH_Qpar_report : CLJoined<"Qpar-report">; -def _SLASH_Qsafe_fp_loads : CLFlag<"Qsafe_fp_loads">; -def _SLASH_Qspectre : CLFlag<"Qspectre">; -def _SLASH_Qspectre_load : CLFlag<"Qspectre-load">; -def _SLASH_Qspectre_load_cf : CLFlag<"Qspectre-load-cf">; -def _SLASH_Qvec_report : CLJoined<"Qvec-report">; -def _SLASH_u : CLFlag<"u">; -def _SLASH_V : CLFlag<"V">; -def _SLASH_WL : CLFlag<"WL">; -def _SLASH_Wp64 : CLFlag<"Wp64">; -def _SLASH_Yd : CLFlag<"Yd">; -def _SLASH_Yl : CLJoined<"Yl">; -def _SLASH_Za : CLFlag<"Za">; -def _SLASH_Zc : CLJoined<"Zc:">; -def _SLASH_Ze : CLFlag<"Ze">; -def _SLASH_Zg : CLFlag<"Zg">; -def _SLASH_ZI : CLFlag<"ZI">; -def _SLASH_ZW : CLJoined<"ZW">; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c95d427da267..113696aeec7f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3434,6 +3434,1409 @@ def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>, def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">; -include "CC1Options.td" +//===----------------------------------------------------------------------===// +// CC1 Options +//===----------------------------------------------------------------------===// + +let Flags = [CC1Option, NoDriverOption] in { + +//===----------------------------------------------------------------------===// +// Target Options +//===----------------------------------------------------------------------===// + +let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { + +def target_cpu : Separate<["-"], "target-cpu">, + HelpText<"Target a specific cpu type">; +def target_feature : Separate<["-"], "target-feature">, + HelpText<"Target specific attributes">; +def triple : Separate<["-"], "triple">, + HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, + MarshallingInfoString<"TargetOpts->Triple", "llvm::sys::getDefaultTargetTriple()", "std::string">, + AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; +def target_abi : Separate<["-"], "target-abi">, + HelpText<"Target a particular ABI type">; +def target_sdk_version_EQ : Joined<["-"], "target-sdk-version=">, + HelpText<"The version of target SDK used for compilation">; + +} + +def target_linker_version : Separate<["-"], "target-linker-version">, + HelpText<"Target linker version">; +def triple_EQ : Joined<["-"], "triple=">, Alias; +def mfpmath : Separate<["-"], "mfpmath">, + HelpText<"Which unit to use for fp math">; + +def fpadding_on_unsigned_fixed_point : Flag<["-"], "fpadding-on-unsigned-fixed-point">, + HelpText<"Force each unsigned fixed point type to have an extra bit of padding to align their scales with those of signed fixed point types">; +def fno_padding_on_unsigned_fixed_point : Flag<["-"], "fno-padding-on-unsigned-fixed-point">; + +//===----------------------------------------------------------------------===// +// Analyzer Options +//===----------------------------------------------------------------------===// + +def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">, + HelpText<"Generate unoptimized CFGs for all analyses">; +def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">, + HelpText<"Add C++ implicit destructors to CFGs for all analyses">; + +def analyzer_store : Separate<["-"], "analyzer-store">, + HelpText<"Source Code Analysis - Abstract Memory Store Models">; +def analyzer_store_EQ : Joined<["-"], "analyzer-store=">, Alias; + +def analyzer_constraints : Separate<["-"], "analyzer-constraints">, + HelpText<"Source Code Analysis - Symbolic Constraint Engines">; +def analyzer_constraints_EQ : Joined<["-"], "analyzer-constraints=">, + Alias; + +def analyzer_output : Separate<["-"], "analyzer-output">, + HelpText<"Source Code Analysis - Output Options">; +def analyzer_output_EQ : Joined<["-"], "analyzer-output=">, + Alias; + +def analyzer_purge : Separate<["-"], "analyzer-purge">, + HelpText<"Source Code Analysis - Dead Symbol Removal Frequency">; +def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, Alias; + +def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">, + HelpText<"Force the static analyzer to analyze functions defined in header files">; +def analyzer_opt_analyze_nested_blocks : Flag<["-"], "analyzer-opt-analyze-nested-blocks">, + HelpText<"Analyze the definitions of blocks in addition to functions">; +def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">, + HelpText<"Emit verbose output about the analyzer's progress">; +def analyze_function : Separate<["-"], "analyze-function">, + HelpText<"Run analysis on specific function (for C++ include parameters in name)">; +def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias; +def trim_egraph : Flag<["-"], "trim-egraph">, + HelpText<"Only show error-related paths in the analysis graph">; +def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">, + HelpText<"Display exploded graph using GraphViz">; +def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">, + HelpText<"Dump exploded graph to the specified file">; +def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias; + +def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">, + HelpText<"Bound on stack depth while inlining (4 by default)">; +def analyzer_inline_max_stack_depth_EQ : Joined<["-"], "analyzer-inline-max-stack-depth=">, + Alias; + +def analyzer_inlining_mode : Separate<["-"], "analyzer-inlining-mode">, + HelpText<"Specify the function selection heuristic used during inlining">; +def analyzer_inlining_mode_EQ : Joined<["-"], "analyzer-inlining-mode=">, Alias; + +def analyzer_disable_retry_exhausted : Flag<["-"], "analyzer-disable-retry-exhausted">, + HelpText<"Do not re-analyze paths leading to exhausted nodes with a diff erent strategy (may decrease code coverage)">; + +def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">, + HelpText<"The maximum number of times the analyzer will go through a loop">; +def analyzer_stats : Flag<["-"], "analyzer-stats">, + HelpText<"Print internal analyzer statistics.">; + +def analyzer_checker : Separate<["-"], "analyzer-checker">, + HelpText<"Choose analyzer checkers to enable">, + ValuesCode<[{ + const char *Values = + #define GET_CHECKERS + #define CHECKER(FULLNAME, CLASS, HT, DOC_URI, IS_HIDDEN) FULLNAME "," + #include "clang/StaticAnalyzer/Checkers/Checkers.inc" + #undef GET_CHECKERS + #define GET_PACKAGES + #define PACKAGE(FULLNAME) FULLNAME "," + #include "clang/StaticAnalyzer/Checkers/Checkers.inc" + #undef GET_PACKAGES + ; + }]>; +def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">, + Alias; + +def analyzer_disable_checker : Separate<["-"], "analyzer-disable-checker">, + HelpText<"Choose analyzer checkers to disable">; +def analyzer_disable_checker_EQ : Joined<["-"], "analyzer-disable-checker=">, + Alias; + +def analyzer_disable_all_checks : Flag<["-"], "analyzer-disable-all-checks">, + HelpText<"Disable all static analyzer checks">; + +def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">, + HelpText<"Display the list of analyzer checkers that are available">; + +def analyzer_checker_help_alpha : Flag<["-"], "analyzer-checker-help-alpha">, + HelpText<"Display the list of in development analyzer checkers. These " + "are NOT considered safe, they are unstable and will emit incorrect " + "reports. Enable ONLY FOR DEVELOPMENT purposes">; + +def analyzer_checker_help_developer : Flag<["-"], "analyzer-checker-help-developer">, + HelpText<"Display the list of developer-only checkers such as modeling " + "and debug checkers">; + +def analyzer_config_help : Flag<["-"], "analyzer-config-help">, + HelpText<"Display the list of -analyzer-config options. These are meant for " + "development purposes only!">; + +def analyzer_list_enabled_checkers : Flag<["-"], "analyzer-list-enabled-checkers">, + HelpText<"Display the list of enabled analyzer checkers">; + +def analyzer_config : Separate<["-"], "analyzer-config">, + HelpText<"Choose analyzer options to enable">; + +def analyzer_checker_option_help : Flag<["-"], "analyzer-checker-option-help">, + HelpText<"Display the list of checker and package options">; + +def analyzer_checker_option_help_alpha : Flag<["-"], "analyzer-checker-option-help-alpha">, + HelpText<"Display the list of in development checker and package options. " + "These are NOT considered safe, they are unstable and will emit " + "incorrect reports. Enable ONLY FOR DEVELOPMENT purposes">; + +def analyzer_checker_option_help_developer : Flag<["-"], "analyzer-checker-option-help-developer">, + HelpText<"Display the list of checker and package options meant for " + "development purposes only">; + +def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">, + HelpText<"Don't emit errors on invalid analyzer-config inputs">; + +def analyzer_config_compatibility_mode_EQ : Joined<["-"], "analyzer-config-compatibility-mode=">, + Alias; + +def analyzer_werror : Flag<["-"], "analyzer-werror">, + HelpText<"Emit analyzer results as errors rather than warnings">; + +//===----------------------------------------------------------------------===// +// Migrator Options +//===----------------------------------------------------------------------===// +def migrator_no_nsalloc_error : Flag<["-"], "no-ns-alloc-error">, + HelpText<"Do not error on use of NSAllocateCollectable/NSReallocateCollectable">; + +def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">, + HelpText<"Do not remove finalize method in gc mode">; + +//===----------------------------------------------------------------------===// +// CodeGen Options +//===----------------------------------------------------------------------===// + +let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { +def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">; +def debug_info_macro : Flag<["-"], "debug-info-macro">, + HelpText<"Emit macro debug information">; +def default_function_attr : Separate<["-"], "default-function-attr">, + HelpText<"Apply given attribute to all functions">; +def dwarf_version_EQ : Joined<["-"], "dwarf-version=">; +def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">; +def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">, + HelpText<"The string to embed in the Dwarf debug flags record.">; +def record_command_line : Separate<["-"], "record-command-line">, + HelpText<"The string to embed in the .LLVM.command.line section.">; +def compress_debug_sections : Flag<["-", "--"], "compress-debug-sections">, + HelpText<"DWARF debug sections compression">; +def compress_debug_sections_EQ : Joined<["-", "--"], "compress-debug-sections=">, + HelpText<"DWARF debug sections compression type">; +def mno_exec_stack : Flag<["-"], "mnoexecstack">, + HelpText<"Mark the file as not needing an executable stack">; +def massembler_no_warn : Flag<["-"], "massembler-no-warn">, + HelpText<"Make assembler not emit warnings">; +def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">, + HelpText<"Make assembler warnings fatal">; +def mrelax_relocations : Flag<["--"], "mrelax-relocations">, + HelpText<"Use relaxable elf relocations">; +def msave_temp_labels : Flag<["-"], "msave-temp-labels">, + HelpText<"Save temporary labels in the symbol table. " + "Note this may change .s semantics and shouldn't generally be used " + "on compiler-generated code.">; +def mrelocation_model : Separate<["-"], "mrelocation-model">, + HelpText<"The relocation model to use">, Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">, + NormalizedValuesScope<"llvm::Reloc">, + NormalizedValues<["Static", "PIC_", "ROPI", "RWPI", "ROPI_RWPI", "DynamicNoPIC"]>, + MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_", "Model">, + AutoNormalizeEnum; +def fno_math_builtin : Flag<["-"], "fno-math-builtin">, + HelpText<"Disable implicit builtin knowledge of math functions">; +} + +def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">, + HelpText<"Don't run the LLVM IR verifier pass">; +def disable_llvm_passes : Flag<["-"], "disable-llvm-passes">, + HelpText<"Use together with -emit-llvm to get pristine LLVM IR from the " + "frontend by not running any LLVM passes at all">; +def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">, + Alias; +def disable_lifetimemarkers : Flag<["-"], "disable-lifetime-markers">, + HelpText<"Disable lifetime-markers emission even when optimizations are " + "enabled">; +def disable_O0_optnone : Flag<["-"], "disable-O0-optnone">, + HelpText<"Disable adding the optnone attribute to functions at O0">; +def disable_red_zone : Flag<["-"], "disable-red-zone">, + HelpText<"Do not emit code that uses the red zone.">; +def dwarf_column_info : Flag<["-"], "dwarf-column-info">, + HelpText<"Turn on column location information.">; +def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">, + HelpText<"Generate debug info with external references to clang modules" + " or precompiled headers">; +def dwarf_explicit_import : Flag<["-"], "dwarf-explicit-import">, + HelpText<"Generate explicit import from anonymous namespace to containing" + " scope">; +def debug_forward_template_params : Flag<["-"], "debug-forward-template-params">, + HelpText<"Emit complete descriptions of template parameters in forward" + " declarations">; +def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">, + HelpText<"Emit an error if a C++ static local initializer would need a guard variable">; +def no_implicit_float : Flag<["-"], "no-implicit-float">, + HelpText<"Don't generate implicit floating point instructions">; +def fdump_vtable_layouts : Flag<["-"], "fdump-vtable-layouts">, + HelpText<"Dump the layouts of all vtables that will be emitted in a translation unit">; +def fmerge_functions : Flag<["-"], "fmerge-functions">, + HelpText<"Permit merging of identical functions when optimizing.">; +def femit_coverage_notes : Flag<["-"], "femit-coverage-notes">, + HelpText<"Emit a gcov coverage notes file when compiling.">; +def femit_coverage_data: Flag<["-"], "femit-coverage-data">, + HelpText<"Instrument the program to emit gcov coverage data when run.">; +def coverage_data_file : Separate<["-"], "coverage-data-file">, + HelpText<"Emit coverage data to this filename.">; +def coverage_data_file_EQ : Joined<["-"], "coverage-data-file=">, + Alias; +def coverage_notes_file : Separate<["-"], "coverage-notes-file">, + HelpText<"Emit coverage notes to this filename.">; +def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">, + Alias; +def coverage_version_EQ : Joined<["-"], "coverage-version=">, + HelpText<"Four-byte version string for gcov files.">; +def test_coverage : Flag<["-"], "test-coverage">, + HelpText<"Do not generate coverage files or remove coverage changes from IR">; +def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">, + HelpText<"Dump the coverage mapping records, for testing">; +def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfield-access">, + HelpText<"Use register sized accesses to bit-fields, when possible.">; +def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">, + HelpText<"Turn off Type Based Alias Analysis">; +def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">, + HelpText<"Turn off struct-path aware Type Based Alias Analysis">; +def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">, + HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">; +def mdebug_pass : Separate<["-"], "mdebug-pass">, + HelpText<"Enable additional debug output">; +def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">, + HelpText<"Specify which frame pointers to retain (all, non-leaf, none).">, Values<"all,non-leaf,none">; +def mdisable_tail_calls : Flag<["-"], "mdisable-tail-calls">, + HelpText<"Disable tail call optimization, keeping the call stack accurate">; +def menable_no_infinities : Flag<["-"], "menable-no-infs">, + HelpText<"Allow optimization to assume there are no infinities.">; +def menable_no_nans : Flag<["-"], "menable-no-nans">, + HelpText<"Allow optimization to assume there are no NaNs.">; +def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, + HelpText<"Allow unsafe floating-point math optimizations which may decrease " + "precision">; +def mreassociate : Flag<["-"], "mreassociate">, + HelpText<"Allow reassociation transformations for floating-point instructions">; +def mabi_EQ_ieeelongdouble : Flag<["-"], "mabi=ieeelongdouble">, + HelpText<"Use IEEE 754 quadruple-precision for long double">; +def mfloat_abi : Separate<["-"], "mfloat-abi">, + HelpText<"The float ABI to use">; +def mtp : Separate<["-"], "mtp">, + HelpText<"Mode for reading thread pointer">; +def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, + HelpText<"Limit float precision to the given value">; +def split_stacks : Flag<["-"], "split-stacks">, + HelpText<"Try to use a split stack if possible.">; +def mno_zero_initialized_in_bss : Flag<["-"], "mno-zero-initialized-in-bss">, + HelpText<"Do not put zero initialized data in the BSS">; +def mregparm : Separate<["-"], "mregparm">, + HelpText<"Limit the number of registers available for integer arguments">; +def msmall_data_limit : Separate<["-"], "msmall-data-limit">, + HelpText<"Put global and static data smaller than the limit into a special section">; +def munwind_tables : Flag<["-"], "munwind-tables">, + HelpText<"Generate unwinding tables for all functions">; +def mconstructor_aliases : Flag<["-"], "mconstructor-aliases">, + HelpText<"Emit complete constructors and destructors as aliases when possible">; +def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">, + HelpText<"Link the given bitcode file before performing optimizations.">; +def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">, + HelpText<"Link and internalize needed symbols from the given bitcode file " + "before performing optimizations.">; +def mlink_cuda_bitcode : Separate<["-"], "mlink-cuda-bitcode">, + Alias; +def vectorize_loops : Flag<["-"], "vectorize-loops">, + HelpText<"Run the Loop vectorization passes">; +def vectorize_slp : Flag<["-"], "vectorize-slp">, + HelpText<"Run the SLP vectorization passes">; +def dependent_lib : Joined<["--"], "dependent-lib=">, + HelpText<"Add dependent library">; +def linker_option : Joined<["--"], "linker-option=">, + HelpText<"Add linker option">; +def fsanitize_coverage_type : Joined<["-"], "fsanitize-coverage-type=">, + HelpText<"Sanitizer coverage type">; +def fsanitize_coverage_indirect_calls + : Flag<["-"], "fsanitize-coverage-indirect-calls">, + HelpText<"Enable sanitizer coverage for indirect calls">; +def fsanitize_coverage_trace_bb + : Flag<["-"], "fsanitize-coverage-trace-bb">, + HelpText<"Enable basic block tracing in sanitizer coverage">; +def fsanitize_coverage_trace_cmp + : Flag<["-"], "fsanitize-coverage-trace-cmp">, + HelpText<"Enable cmp instruction tracing in sanitizer coverage">; +def fsanitize_coverage_trace_div + : Flag<["-"], "fsanitize-coverage-trace-div">, + HelpText<"Enable div instruction tracing in sanitizer coverage">; +def fsanitize_coverage_trace_gep + : Flag<["-"], "fsanitize-coverage-trace-gep">, + HelpText<"Enable gep instruction tracing in sanitizer coverage">; +def fsanitize_coverage_8bit_counters + : Flag<["-"], "fsanitize-coverage-8bit-counters">, + HelpText<"Enable frequency counters in sanitizer coverage">; +def fsanitize_coverage_inline_8bit_counters + : Flag<["-"], "fsanitize-coverage-inline-8bit-counters">, + HelpText<"Enable inline 8-bit counters in sanitizer coverage">; +def fsanitize_coverage_inline_bool_flag + : Flag<["-"], "fsanitize-coverage-inline-bool-flag">, + HelpText<"Enable inline bool flag in sanitizer coverage">; +def fsanitize_coverage_pc_table + : Flag<["-"], "fsanitize-coverage-pc-table">, + HelpText<"Create a table of coverage-instrumented PCs">; +def fsanitize_coverage_trace_pc + : Flag<["-"], "fsanitize-coverage-trace-pc">, + HelpText<"Enable PC tracing in sanitizer coverage">; +def fsanitize_coverage_trace_pc_guard + : Flag<["-"], "fsanitize-coverage-trace-pc-guard">, + HelpText<"Enable PC tracing with guard in sanitizer coverage">; +def fsanitize_coverage_no_prune + : Flag<["-"], "fsanitize-coverage-no-prune">, + HelpText<"Disable coverage pruning (i.e. instrument all blocks/edges)">; +def fsanitize_coverage_stack_depth + : Flag<["-"], "fsanitize-coverage-stack-depth">, + HelpText<"Enable max stack depth tracing">; +def fpatchable_function_entry_offset_EQ + : Joined<["-"], "fpatchable-function-entry-offset=">, MetaVarName<"">, + HelpText<"Generate M NOPs before function entry">; +def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">, + HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, " + "or none">, Values<"none,clang,llvm">; +def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">, + HelpText<"Generate instrumented code to collect execution counts into " + " (overridden by LLVM_PROFILE_FILE env var)">; +def fprofile_instrument_use_path_EQ : + Joined<["-"], "fprofile-instrument-use-path=">, + HelpText<"Specify the profile path in PGO use compilation">; +def flto_visibility_public_std: + Flag<["-"], "flto-visibility-public-std">, + HelpText<"Use public LTO visibility for classes in std and stdext namespaces">; +def flto_unit: Flag<["-"], "flto-unit">, + HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable opt)">; +def fno_lto_unit: Flag<["-"], "fno-lto-unit">; +def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">, + HelpText<"Prints debug information for the new pass manager">; +def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">, + HelpText<"Disables debug printing for the new pass manager">; +// The driver option takes the key as a parameter to the -msign-return-address= +// and -mbranch-protection= options, but CC1 has a separate option so we +// don't have to parse the parameter twice. +def msign_return_address_key_EQ : Joined<["-"], "msign-return-address-key=">, + Values<"a_key,b_key">; +def mbranch_target_enforce : Flag<["-"], "mbranch-target-enforce">; +def fno_dllexport_inlines : Flag<["-"], "fno-dllexport-inlines">; +def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">, + HelpText<"Emit Windows Control Flow Guard tables only (no checks)">; +def cfguard : Flag<["-"], "cfguard">, + HelpText<"Emit Windows Control Flow Guard tables and checks">; + +def fdenormal_fp_math_f32_EQ : Joined<["-"], "fdenormal-fp-math-f32=">, + Group; + +//===----------------------------------------------------------------------===// +// Dependency Output Options +//===----------------------------------------------------------------------===// + +def sys_header_deps : Flag<["-"], "sys-header-deps">, + HelpText<"Include system headers in dependency output">; +def module_file_deps : Flag<["-"], "module-file-deps">, + HelpText<"Include module files in dependency output">; +def header_include_file : Separate<["-"], "header-include-file">, + HelpText<"Filename (or -) to write header include output to">; +def show_includes : Flag<["--"], "show-includes">, + HelpText<"Print cl.exe style /showIncludes to stdout">; + +//===----------------------------------------------------------------------===// +// Diagnostic Options +//===----------------------------------------------------------------------===// + +def diagnostic_log_file : Separate<["-"], "diagnostic-log-file">, + HelpText<"Filename (or -) to log diagnostics to">; +def diagnostic_serialized_file : Separate<["-"], "serialize-diagnostic-file">, + MetaVarName<"">, + HelpText<"File for serializing diagnostics in a binary format">; + +def fdiagnostics_format : Separate<["-"], "fdiagnostics-format">, + HelpText<"Change diagnostic formatting to match IDE and command line tools">, Values<"clang,msvc,msvc-fallback,vi">; +def fdiagnostics_show_category : Separate<["-"], "fdiagnostics-show-category">, + HelpText<"Print diagnostic category">, Values<"none,id,name">; +def fno_diagnostics_use_presumed_location : Flag<["-"], "fno-diagnostics-use-presumed-location">, + HelpText<"Ignore #line directives when displaying diagnostic locations">; +def ftabstop : Separate<["-"], "ftabstop">, MetaVarName<"">, + HelpText<"Set the tab stop distance.">; +def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"">, + HelpText<"Set the maximum number of errors to emit before stopping (0 = no limit).">; +def fmacro_backtrace_limit : Separate<["-"], "fmacro-backtrace-limit">, MetaVarName<"">, + HelpText<"Set the maximum number of entries to print in a macro expansion backtrace (0 = no limit).">; +def ftemplate_backtrace_limit : Separate<["-"], "ftemplate-backtrace-limit">, MetaVarName<"">, + HelpText<"Set the maximum number of entries to print in a template instantiation backtrace (0 = no limit).">; +def fconstexpr_backtrace_limit : Separate<["-"], "fconstexpr-backtrace-limit">, MetaVarName<"">, + HelpText<"Set the maximum number of entries to print in a constexpr evaluation backtrace (0 = no limit).">; +def fspell_checking_limit : Separate<["-"], "fspell-checking-limit">, MetaVarName<"">, + HelpText<"Set the maximum number of times to perform spell checking on unrecognized identifiers (0 = no limit).">; +def fcaret_diagnostics_max_lines : + Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"">, + HelpText<"Set the maximum number of source lines to show in a caret diagnostic">; +def verify_EQ : CommaJoined<["-"], "verify=">, + MetaVarName<"">, + HelpText<"Verify diagnostic output using comment directives that start with" + " prefixes in the comma-separated sequence ">; +def verify : Flag<["-"], "verify">, + HelpText<"Equivalent to -verify=expected">; +def verify_ignore_unexpected : Flag<["-"], "verify-ignore-unexpected">, + HelpText<"Ignore unexpected diagnostic messages">; +def verify_ignore_unexpected_EQ : CommaJoined<["-"], "verify-ignore-unexpected=">, + HelpText<"Ignore unexpected diagnostic messages">; +def Wno_rewrite_macros : Flag<["-"], "Wno-rewrite-macros">, + HelpText<"Silence ObjC rewriting warnings">; + +//===----------------------------------------------------------------------===// +// Frontend Options +//===----------------------------------------------------------------------===// + +// This isn't normally used, it is just here so we can parse a +// CompilerInvocation out of a driver-derived argument vector. +def cc1 : Flag<["-"], "cc1">; +def cc1as : Flag<["-"], "cc1as">; + +def ast_merge : Separate<["-"], "ast-merge">, + MetaVarName<"">, + HelpText<"Merge the given AST file into the translation unit being compiled.">; +def aux_target_cpu : Separate<["-"], "aux-target-cpu">, + HelpText<"Target a specific auxiliary cpu type">; +def aux_target_feature : Separate<["-"], "aux-target-feature">, + HelpText<"Target specific auxiliary attributes">; +def aux_triple : Separate<["-"], "aux-triple">, + HelpText<"Auxiliary target triple.">; +def code_completion_at : Separate<["-"], "code-completion-at">, + MetaVarName<"::">, + HelpText<"Dump code-completion information at a location">; +def remap_file : Separate<["-"], "remap-file">, + MetaVarName<";">, + HelpText<"Replace the contents of the file with the contents of the file">; +def code_completion_at_EQ : Joined<["-"], "code-completion-at=">, + Alias; +def code_completion_macros : Flag<["-"], "code-completion-macros">, + HelpText<"Include macros in code-completion results">; +def code_completion_patterns : Flag<["-"], "code-completion-patterns">, + HelpText<"Include code patterns in code-completion results">; +def no_code_completion_globals : Flag<["-"], "no-code-completion-globals">, + HelpText<"Do not include global declarations in code-completion results.">; +def no_code_completion_ns_level_decls : Flag<["-"], "no-code-completion-ns-level-decls">, + HelpText<"Do not include declarations inside namespaces (incl. global namespace) in the code-completion results.">; +def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments">, + HelpText<"Include brief documentation comments in code-completion results.">; +def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, + HelpText<"Include code completion results which require small fix-its.">; +def disable_free : Flag<["-"], "disable-free">, + HelpText<"Disable freeing of memory on exit">; +def discard_value_names : Flag<["-"], "discard-value-names">, + HelpText<"Discard value names in LLVM IR">; +def load : Separate<["-"], "load">, MetaVarName<"">, + HelpText<"Load the named plugin (dynamic shared object)">; +def plugin : Separate<["-"], "plugin">, MetaVarName<"">, + HelpText<"Use the named plugin action instead of the default action (use \"help\" to list available options)">; +def plugin_arg : JoinedAndSeparate<["-"], "plugin-arg-">, + MetaVarName<" ">, + HelpText<"Pass to plugin ">; +def add_plugin : Separate<["-"], "add-plugin">, MetaVarName<"">, + HelpText<"Use the named plugin action in addition to the default action">; +def ast_dump_filter : Separate<["-"], "ast-dump-filter">, + MetaVarName<"">, + HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration" + " nodes having a certain substring in a qualified name. Use" + " -ast-list to list all filterable declaration node names.">; +def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">, + HelpText<"Do not automatically generate or update the global module index">; +def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">, + HelpText<"Do not automatically import modules for error recovery">; +def fmodule_map_file_home_is_cwd : Flag<["-"], "fmodule-map-file-home-is-cwd">, + HelpText<"Use the current working directory as the home directory of " + "module maps specified by -fmodule-map-file=">; +def fmodule_feature : Separate<["-"], "fmodule-feature">, + MetaVarName<"">, + HelpText<"Enable in module map requires declarations">; +def fmodules_embed_file_EQ : Joined<["-"], "fmodules-embed-file=">, + MetaVarName<"">, + HelpText<"Embed the contents of the specified file into the module file " + "being compiled.">; +def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">, + HelpText<"Embed the contents of all files read by this compilation into " + "the produced module file.">; +def fmodules_local_submodule_visibility : + Flag<["-"], "fmodules-local-submodule-visibility">, + HelpText<"Enforce name visibility rules across submodules of the same " + "top-level module.">; +def fmodules_codegen : + Flag<["-"], "fmodules-codegen">, + HelpText<"Generate code for uses of this module that assumes an explicit " + "object file will be built for the module">; +def fmodules_debuginfo : + Flag<["-"], "fmodules-debuginfo">, + HelpText<"Generate debug info for types in an object file built from this " + "module and do not generate them elsewhere">; +def fmodule_format_EQ : Joined<["-"], "fmodule-format=">, + HelpText<"Select the container format for clang modules and PCH. " + "Supported options are 'raw' and 'obj'.">; +def ftest_module_file_extension_EQ : + Joined<["-"], "ftest-module-file-extension=">, + HelpText<"introduce a module file extension for testing purposes. " + "The argument is parsed as blockname:major:minor:hashed:user info">; +def fconcepts_ts : Flag<["-"], "fconcepts-ts">, + HelpText<"Enable C++ Extensions for Concepts. (deprecated - use -std=c++2a)">; +def fno_concept_satisfaction_caching : Flag<["-"], + "fno-concept-satisfaction-caching">, + HelpText<"Disable satisfaction caching for C++2a Concepts.">; + +def frecovery_ast : Flag<["-"], "frecovery-ast">, + HelpText<"Preserve expressions in AST rather than dropping them when " + "encountering semantic errors">; +def fno_recovery_ast : Flag<["-"], "fno-recovery-ast">; +def frecovery_ast_type : Flag<["-"], "frecovery-ast-type">, + HelpText<"Preserve the type for recovery expressions when possible " + "(experimental)">; +def fno_recovery_ast_type : Flag<["-"], "fno-recovery-ast-type">; + +let Group = Action_Group in { + +def Eonly : Flag<["-"], "Eonly">, + HelpText<"Just run preprocessor, no output (for timings)">; +def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">, + HelpText<"Lex file in raw mode and dump raw tokens">; +def analyze : Flag<["-"], "analyze">, + HelpText<"Run static analysis engine">; +def dump_tokens : Flag<["-"], "dump-tokens">, + HelpText<"Run preprocessor, dump internal rep of tokens">; +def init_only : Flag<["-"], "init-only">, + HelpText<"Only execute frontend initialization">; +def fixit : Flag<["-"], "fixit">, + HelpText<"Apply fix-it advice to the input source">; +def fixit_EQ : Joined<["-"], "fixit=">, + HelpText<"Apply fix-it advice creating a file with the given suffix">; +def print_preamble : Flag<["-"], "print-preamble">, + HelpText<"Print the \"preamble\" of a file, which is a candidate for implicit" + " precompiled headers.">; +def emit_html : Flag<["-"], "emit-html">, + HelpText<"Output input source as HTML">; +def ast_print : Flag<["-"], "ast-print">, + HelpText<"Build ASTs and then pretty-print them">; +def ast_list : Flag<["-"], "ast-list">, + HelpText<"Build ASTs and print the list of declaration node qualified names">; +def ast_dump : Flag<["-"], "ast-dump">, + HelpText<"Build ASTs and then debug dump them">; +def ast_dump_EQ : Joined<["-"], "ast-dump=">, + HelpText<"Build ASTs and then debug dump them in the specified format. " + "Supported formats include: default, json">; +def ast_dump_all : Flag<["-"], "ast-dump-all">, + HelpText<"Build ASTs and then debug dump them, forcing deserialization">; +def ast_dump_all_EQ : Joined<["-"], "ast-dump-all=">, + HelpText<"Build ASTs and then debug dump them in the specified format, " + "forcing deserialization. Supported formats include: default, json">; +def ast_dump_decl_types : Flag<["-"], "ast-dump-decl-types">, + HelpText<"Include declaration types in AST dumps">; +def templight_dump : Flag<["-"], "templight-dump">, + HelpText<"Dump templight information to stdout">; +def ast_dump_lookups : Flag<["-"], "ast-dump-lookups">, + HelpText<"Build ASTs and then debug dump their name lookup tables">; +def ast_view : Flag<["-"], "ast-view">, + HelpText<"Build ASTs and view them with GraphViz">; +def emit_module : Flag<["-"], "emit-module">, + HelpText<"Generate pre-compiled module file from a module map">; +def emit_module_interface : Flag<["-"], "emit-module-interface">, + HelpText<"Generate pre-compiled module file from a C++ module interface">; +def emit_header_module : Flag<["-"], "emit-header-module">, + HelpText<"Generate pre-compiled module file from a set of header files">; +def emit_pch : Flag<["-"], "emit-pch">, + HelpText<"Generate pre-compiled header file">; +def emit_llvm_bc : Flag<["-"], "emit-llvm-bc">, + HelpText<"Build ASTs then convert to LLVM, emit .bc file">; +def emit_llvm_only : Flag<["-"], "emit-llvm-only">, + HelpText<"Build ASTs and convert to LLVM, discarding output">; +def emit_codegen_only : Flag<["-"], "emit-codegen-only">, + HelpText<"Generate machine code, but discard output">; +def emit_obj : Flag<["-"], "emit-obj">, + HelpText<"Emit native object files">; +def rewrite_test : Flag<["-"], "rewrite-test">, + HelpText<"Rewriter playground">; +def rewrite_macros : Flag<["-"], "rewrite-macros">, + HelpText<"Expand macros without full preprocessing">; +def migrate : Flag<["-"], "migrate">, + HelpText<"Migrate source code">; +def compiler_options_dump : Flag<["-"], "compiler-options-dump">, + HelpText<"Dump the compiler configuration options">; +def print_dependency_directives_minimized_source : Flag<["-"], + "print-dependency-directives-minimized-source">, + HelpText<"Print the output of the dependency directives source minimizer">; +} + +def emit_llvm_uselists : Flag<["-"], "emit-llvm-uselists">, + HelpText<"Preserve order of LLVM use-lists when serializing">; +def no_emit_llvm_uselists : Flag<["-"], "no-emit-llvm-uselists">, + HelpText<"Don't preserve order of LLVM use-lists when serializing">; + +def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">, + HelpText<"Directory for temporary files produced during ARC or ObjC migration">; +def arcmt_check : Flag<["-"], "arcmt-check">, + HelpText<"Check for ARC migration issues that need manual handling">; +def arcmt_modify : Flag<["-"], "arcmt-modify">, + HelpText<"Apply modifications to files to conform to ARC">; +def arcmt_migrate : Flag<["-"], "arcmt-migrate">, + HelpText<"Apply modifications and produces temporary files that conform to ARC">; + +def opt_record_file : Separate<["-"], "opt-record-file">, + HelpText<"File name to use for YAML optimization record output">; +def opt_record_passes : Separate<["-"], "opt-record-passes">, + HelpText<"Only record remark information for passes whose names match the given regular expression">; +def opt_record_format : Separate<["-"], "opt-record-format">, + HelpText<"The format used for serializing remarks (default: YAML)">; + +def print_stats : Flag<["-"], "print-stats">, + HelpText<"Print performance metrics and statistics">; +def stats_file : Joined<["-"], "stats-file=">, + HelpText<"Filename to write statistics to">; +def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">, + HelpText<"Dump record layout information">; +def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">, + HelpText<"Dump record layout information in a simple form used for testing">; +def fix_what_you_can : Flag<["-"], "fix-what-you-can">, + HelpText<"Apply fix-it advice even in the presence of unfixable errors">; +def fix_only_warnings : Flag<["-"], "fix-only-warnings">, + HelpText<"Apply fix-it advice only for warnings, not errors">; +def fixit_recompile : Flag<["-"], "fixit-recompile">, + HelpText<"Apply fix-it changes and recompile">; +def fixit_to_temp : Flag<["-"], "fixit-to-temporary">, + HelpText<"Apply fix-it changes to temporary files">; + +def foverride_record_layout_EQ : Joined<["-"], "foverride-record-layout=">, + HelpText<"Override record layouts with those in the given file">; +def pch_through_header_EQ : Joined<["-"], "pch-through-header=">, + HelpText<"Stop PCH generation after including this file. When using a PCH, " + "skip tokens until after this file is included.">; +def pch_through_hdrstop_create : Flag<["-"], "pch-through-hdrstop-create">, + HelpText<"When creating a PCH, stop PCH generation after #pragma hdrstop.">; +def pch_through_hdrstop_use : Flag<["-"], "pch-through-hdrstop-use">, + HelpText<"When using a PCH, skip tokens until after a #pragma hdrstop.">; +def fno_pch_timestamp : Flag<["-"], "fno-pch-timestamp">, + HelpText<"Disable inclusion of timestamp in precompiled headers">; +def building_pch_with_obj : Flag<["-"], "building-pch-with-obj">, + HelpText<"This compilation is part of building a PCH with corresponding object file.">; + +def aligned_alloc_unavailable : Flag<["-"], "faligned-alloc-unavailable">, + HelpText<"Aligned allocation/deallocation functions are unavailable">; + +//===----------------------------------------------------------------------===// +// Language Options +//===----------------------------------------------------------------------===// + +let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { + +def version : Flag<["-"], "version">, + HelpText<"Print the compiler version">; +def main_file_name : Separate<["-"], "main-file-name">, + HelpText<"Main file name to use for debug info and source if missing">; +def split_dwarf_output : Separate<["-"], "split-dwarf-output">, + HelpText<"File name to use for split dwarf debug info output">; + +} + +def fblocks_runtime_optional : Flag<["-"], "fblocks-runtime-optional">, + HelpText<"Weakly link in the blocks runtime">; +def fexternc_nounwind : Flag<["-"], "fexternc-nounwind">, + HelpText<"Assume all functions with C linkage do not unwind">; +def split_dwarf_file : Separate<["-"], "split-dwarf-file">, + HelpText<"Name of the split dwarf debug info file to encode in the object file">; +def fno_wchar : Flag<["-"], "fno-wchar">, + HelpText<"Disable C++ builtin type wchar_t">; +def fconstant_string_class : Separate<["-"], "fconstant-string-class">, + MetaVarName<"">, + HelpText<"Specify the class to use for constant Objective-C string objects.">; +def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, + HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">; +def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, + HelpText<"The target Objective-C runtime supports ARC weak operations">; +def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">, + HelpText<"Objective-C dispatch method to use">, Values<"legacy,non-legacy,mixed">; +def disable_objc_default_synthesize_properties : Flag<["-"], "disable-objc-default-synthesize-properties">, + HelpText<"disable the default synthesis of Objective-C properties">; +def fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signature">, + HelpText<"enable extended encoding of block type signature">; +def function_alignment : Separate<["-"], "function-alignment">, + HelpText<"default alignment for functions">; +def pic_level : Separate<["-"], "pic-level">, + HelpText<"Value for __PIC__">; +def pic_is_pie : Flag<["-"], "pic-is-pie">, + HelpText<"File is for a position independent executable">; +def fno_validate_pch : Flag<["-"], "fno-validate-pch">, + HelpText<"Disable validation of precompiled headers">; +def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">, + HelpText<"Accept a PCH file that was created with compiler errors">; +def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">, + HelpText<"Dump declarations that are deserialized from PCH, for testing">; +def error_on_deserialized_pch_decl : Separate<["-"], "error-on-deserialized-decl">, + HelpText<"Emit error if a specific declaration is deserialized from PCH, for testing">; +def error_on_deserialized_pch_decl_EQ : Joined<["-"], "error-on-deserialized-decl=">, + Alias; +def static_define : Flag<["-"], "static-define">, + HelpText<"Should __STATIC__ be defined">; +def stack_protector : Separate<["-"], "stack-protector">, + HelpText<"Enable stack protectors">; +def stack_protector_buffer_size : Separate<["-"], "stack-protector-buffer-size">, + HelpText<"Lower bound for a buffer to be considered for stack protection">; +def fvisibility : Separate<["-"], "fvisibility">, + HelpText<"Default type and symbol visibility">; +def ftype_visibility : Separate<["-"], "ftype-visibility">, + HelpText<"Default type visibility">; +def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility-to-externs">, + HelpText<"Apply global symbol visibility to external declarations without an explicit visibility">; +def ftemplate_depth : Separate<["-"], "ftemplate-depth">, + HelpText<"Maximum depth of recursive template instantiation">; +def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">, + HelpText<"Maximum number of 'operator->'s to call for a member access">; +def fconstexpr_depth : Separate<["-"], "fconstexpr-depth">, + HelpText<"Maximum depth of recursive constexpr function calls">; +def fconstexpr_steps : Separate<["-"], "fconstexpr-steps">, + HelpText<"Maximum number of steps in constexpr function evaluation">; +def fbracket_depth : Separate<["-"], "fbracket-depth">, + HelpText<"Maximum nesting level for parentheses, brackets, and braces">; +def fconst_strings : Flag<["-"], "fconst-strings">, + HelpText<"Use a const qualified type for string literals in C and ObjC">; +def fno_const_strings : Flag<["-"], "fno-const-strings">, + HelpText<"Don't use a const qualified type for string literals in C and ObjC">; +def fno_bitfield_type_align : Flag<["-"], "fno-bitfield-type-align">, + HelpText<"Ignore bit-field types when aligning structures">; +def ffake_address_space_map : Flag<["-"], "ffake-address-space-map">, + HelpText<"Use a fake address space map; OpenCL testing purposes only">; +def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling=">, MetaVarName<"">, + HelpText<"Set the mode for address space map based mangling; OpenCL testing purposes only">; +def funknown_anytype : Flag<["-"], "funknown-anytype">, + HelpText<"Enable parser support for the __unknown_anytype type; for testing purposes only">; +def fdebugger_support : Flag<["-"], "fdebugger-support">, + HelpText<"Enable special debugger support behavior">; +def fdebugger_cast_result_to_id : Flag<["-"], "fdebugger-cast-result-to-id">, + HelpText<"Enable casting unknown expression results to id">; +def fdebugger_objc_literal : Flag<["-"], "fdebugger-objc-literal">, + HelpText<"Enable special debugger support for Objective-C subscripting and literals">; +def fdeprecated_macro : Flag<["-"], "fdeprecated-macro">, + HelpText<"Defines the __DEPRECATED macro">; +def fno_deprecated_macro : Flag<["-"], "fno-deprecated-macro">, + HelpText<"Undefines the __DEPRECATED macro">; +def fobjc_subscripting_legacy_runtime : Flag<["-"], "fobjc-subscripting-legacy-runtime">, + HelpText<"Allow Objective-C array and dictionary subscripting in legacy runtime">; +def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">, + HelpText<"Control vtordisp placement on win32 targets">; +def fnative_half_type: Flag<["-"], "fnative-half-type">, + HelpText<"Use the native half type for __fp16 instead of promoting to float">; +def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and-returns">, + HelpText<"Use the native __fp16 type for arguments and returns (and skip ABI-specific lowering)">; +def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, + HelpText<"Allow function arguments and returns of type half">; +def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, + HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">; +def finclude_default_header : Flag<["-"], "finclude-default-header">, + HelpText<"Include default header file for OpenCL">; +def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">, + HelpText<"Add OpenCL builtin function declarations (experimental)">; +def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, + HelpText<"Preserve 3-component vector type">; +def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, + HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">; +def fsigned_wchar : Flag<["-"], "fsigned-wchar">, + HelpText<"Use a signed type for wchar_t">; +def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">, + HelpText<"Use an unsigned type for wchar_t">; +def fcompatibility_qualified_id_block_param_type_checking : Flag<["-"], "fcompatibility-qualified-id-block-type-checking">, + HelpText<"Allow using blocks with parameters of more specific type than " + "the type system guarantees when a parameter is qualified id">; + +// FIXME: Remove these entirely once functionality/tests have been excised. +def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group, + HelpText<"Use GC exclusively for Objective-C related memory management">; +def fobjc_gc : Flag<["-"], "fobjc-gc">, Group, + HelpText<"Enable Objective-C garbage collection">; + +//===----------------------------------------------------------------------===// +// Header Search Options +//===----------------------------------------------------------------------===// + +def nostdsysteminc : Flag<["-"], "nostdsysteminc">, + HelpText<"Disable standard system #include directories">; +def fdisable_module_hash : Flag<["-"], "fdisable-module-hash">, + HelpText<"Disable the module hash">; +def fmodules_hash_content : Flag<["-"], "fmodules-hash-content">, + HelpText<"Enable hashing the content of a module file">; +def fmodules_strict_context_hash : Flag<["-"], "fmodules-strict-context-hash">, + HelpText<"Enable hashing of all compiler options that could impact the " + "semantics of a module in an implicit build">, + MarshallingInfoFlag<"HeaderSearchOpts->ModulesStrictContextHash", "false">; +def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, MetaVarName<"">, + HelpText<"Add directory to the C SYSTEM include search path">; +def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">, + MetaVarName<"">, + HelpText<"Add directory to the ObjC SYSTEM include search path">; +def objcxx_isystem : JoinedOrSeparate<["-"], "objcxx-isystem">, + MetaVarName<"">, + HelpText<"Add directory to the ObjC++ SYSTEM include search path">; +def internal_isystem : JoinedOrSeparate<["-"], "internal-isystem">, + MetaVarName<"">, + HelpText<"Add directory to the internal system include search path; these " + "are assumed to not be user-provided and are used to model system " + "and standard headers' paths.">; +def internal_externc_isystem : JoinedOrSeparate<["-"], "internal-externc-isystem">, + MetaVarName<"">, + HelpText<"Add directory to the internal system include search path with " + "implicit extern \"C\" semantics; these are assumed to not be " + "user-provided and are used to model system and standard headers' " + "paths.">; + +//===----------------------------------------------------------------------===// +// Preprocessor Options +//===----------------------------------------------------------------------===// + +def chain_include : Separate<["-"], "chain-include">, MetaVarName<"">, + HelpText<"Include and chain a header file after turning it into PCH">; +def preamble_bytes_EQ : Joined<["-"], "preamble-bytes=">, + HelpText<"Assume that the precompiled header is a precompiled preamble " + "covering the first N bytes of the main file">; +def detailed_preprocessing_record : Flag<["-"], "detailed-preprocessing-record">, + HelpText<"include a detailed record of preprocessing actions">; +def setup_static_analyzer : Flag<["-"], "setup-static-analyzer">, + HelpText<"Set up preprocessor for static analyzer (done automatically when static analyzer is run).">; +def disable_pragma_debug_crash : Flag<["-"], "disable-pragma-debug-crash">, + HelpText<"Disable any #pragma clang __debug that can lead to crashing behavior. This is meant for testing.">; + +//===----------------------------------------------------------------------===// +// OpenCL Options +//===----------------------------------------------------------------------===// + +def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, + HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">; -include "CLCompatOptions.td" +//===----------------------------------------------------------------------===// +// CUDA Options +//===----------------------------------------------------------------------===// + +def fcuda_is_device : Flag<["-"], "fcuda-is-device">, + HelpText<"Generate code for CUDA device">; +def fcuda_include_gpubinary : Separate<["-"], "fcuda-include-gpubinary">, + HelpText<"Incorporate CUDA device-side binary into host object file.">; +def fcuda_allow_variadic_functions : Flag<["-"], "fcuda-allow-variadic-functions">, + HelpText<"Allow variadic functions in CUDA device code.">; +def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr">, + HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">; + +//===----------------------------------------------------------------------===// +// OpenMP Options +//===----------------------------------------------------------------------===// + +def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">, + HelpText<"Generate code only for an OpenMP target device.">; +def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, + HelpText<"Path to the IR file produced by the frontend for the host.">; + +//===----------------------------------------------------------------------===// +// SYCL Options +//===----------------------------------------------------------------------===// + +def fsycl_is_device : Flag<["-"], "fsycl-is-device">, + HelpText<"Generate code for SYCL device.">; + +} // let Flags = [CC1Option] + +//===----------------------------------------------------------------------===// +// cc1as-only Options +//===----------------------------------------------------------------------===// + +let Flags = [CC1AsOption, NoDriverOption] in { + +// Language Options +def n : Flag<["-"], "n">, + HelpText<"Don't automatically start assembly file with a text section">; + +// Frontend Options +def filetype : Separate<["-"], "filetype">, + HelpText<"Specify the output file type ('asm', 'null', or 'obj')">; + +// Transliterate Options +def output_asm_variant : Separate<["-"], "output-asm-variant">, + HelpText<"Select the asm variant index to use for output">; +def show_encoding : Flag<["-"], "show-encoding">, + HelpText<"Show instruction encoding information in transliterate mode">; +def show_inst : Flag<["-"], "show-inst">, + HelpText<"Show internal instruction representation in transliterate mode">; + +// Assemble Options +def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">, + HelpText<"The string to embed in the Dwarf debug AT_producer record.">; + +def defsym : Separate<["-"], "defsym">, + HelpText<"Define a value for a symbol">; + +} // let Flags = [CC1AsOption] + +//===----------------------------------------------------------------------===// +// clang-cl Options +//===----------------------------------------------------------------------===// + +def cl_Group : OptionGroup<"">, Flags<[CLOption]>, + HelpText<"CL.EXE COMPATIBILITY OPTIONS">; + +def cl_compile_Group : OptionGroup<"">, + Group; + +def cl_ignored_Group : OptionGroup<"">, + Group; + +class CLFlag : Option<["/", "-"], name, KIND_FLAG>, + Group, Flags<[CLOption, DriverOption]>; + +class CLCompileFlag : Option<["/", "-"], name, KIND_FLAG>, + Group, Flags<[CLOption, DriverOption]>; + +class CLIgnoredFlag : Option<["/", "-"], name, KIND_FLAG>, + Group, Flags<[CLOption, DriverOption]>; + +class CLJoined : Option<["/", "-"], name, KIND_JOINED>, + Group, Flags<[CLOption, DriverOption]>; + +class CLCompileJoined : Option<["/", "-"], name, KIND_JOINED>, + Group, Flags<[CLOption, DriverOption]>; + +class CLIgnoredJoined : Option<["/", "-"], name, KIND_JOINED>, + Group, Flags<[CLOption, DriverOption, HelpHidden]>; + +class CLJoinedOrSeparate : Option<["/", "-"], name, + KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, DriverOption]>; + +class CLCompileJoinedOrSeparate : Option<["/", "-"], name, + KIND_JOINED_OR_SEPARATE>, Group, + Flags<[CLOption, DriverOption]>; + +class CLRemainingArgsJoined : Option<["/", "-"], name, + KIND_REMAINING_ARGS_JOINED>, Group, Flags<[CLOption, DriverOption]>; + +// Aliases: +// (We don't put any of these in cl_compile_Group as the options they alias are +// already in the right group.) + +def _SLASH_Brepro : CLFlag<"Brepro">, + HelpText<"Do not write current time into COFF output (breaks link.exe /incremental)">, + Alias; +def _SLASH_Brepro_ : CLFlag<"Brepro-">, + HelpText<"Write current time into COFF output (default)">, + Alias; +def _SLASH_C : CLFlag<"C">, + HelpText<"Do not discard comments when preprocessing">, Alias; +def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias; +def _SLASH_d1PP : CLFlag<"d1PP">, + HelpText<"Retain macro definitions in /E mode">, Alias
; +def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">, + HelpText<"Dump record layout information">, + Alias, AliasArgs<["-fdump-record-layouts"]>; +def _SLASH_diagnostics_caret : CLFlag<"diagnostics:caret">, + HelpText<"Enable caret and column diagnostics (default)">; +def _SLASH_diagnostics_column : CLFlag<"diagnostics:column">, + HelpText<"Disable caret diagnostics but keep column info">; +def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">, + HelpText<"Disable column and caret diagnostics">; +def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">, + MetaVarName<"">, Alias; +def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias; +def _SLASH_fp_except : CLFlag<"fp:except">, HelpText<"">, Alias; +def _SLASH_fp_except_ : CLFlag<"fp:except-">, + HelpText<"">, Alias; +def _SLASH_fp_fast : CLFlag<"fp:fast">, HelpText<"">, Alias; +def _SLASH_fp_precise : CLFlag<"fp:precise">, + HelpText<"">, Alias; +def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias; +def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>, + HelpText<"Assume thread-local variables are defined in the executable">; +def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">; +def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Do not emit RTTI data">; +def _SLASH_GF : CLIgnoredFlag<"GF">, + HelpText<"Enable string pooling (default)">; +def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">, + Alias; +def _SLASH_GS : CLFlag<"GS">, + HelpText<"Enable buffer security check (default)">; +def _SLASH_GS_ : CLFlag<"GS-">, HelpText<"Disable buffer security check">; +def : CLFlag<"Gs">, HelpText<"Use stack probes (default)">, + Alias, AliasArgs<["4096"]>; +def _SLASH_Gs : CLJoined<"Gs">, + HelpText<"Set stack probe size (default 4096)">, Alias; +def _SLASH_Gy : CLFlag<"Gy">, HelpText<"Put each function in its own section">, + Alias; +def _SLASH_Gy_ : CLFlag<"Gy-">, + HelpText<"Do not put each function in its own section (default)">, + Alias; +def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data item in its own section">, + Alias; +def _SLASH_Gw_ : CLFlag<"Gw-">, + HelpText<"Do not put each data item in its own section (default)">, + Alias; +def _SLASH_help : CLFlag<"help">, Alias, + HelpText<"Display available options">; +def _SLASH_HELP : CLFlag<"HELP">, Alias; +def _SLASH_I : CLJoinedOrSeparate<"I">, + HelpText<"Add directory to include search path">, MetaVarName<"">, + Alias; +def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">, + Alias; + +// The _SLASH_O option handles all the /O flags, but we also provide separate +// aliased options to provide separate help messages. +def _SLASH_O : CLJoined<"O">, + HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">, + MetaVarName<"">; +def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>, + HelpText<"Optimize for size (like /Og /Os /Oy /Ob2 /GF /Gy)">; +def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>, + HelpText<"Optimize for speed (like /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">; +def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>, + HelpText<"Disable function inlining">; +def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>, + HelpText<"Only inline functions explicitly or implicitly marked inline">; +def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>, + HelpText<"Inline functions as deemed beneficial by the compiler">; +def : CLFlag<"Od">, Alias<_SLASH_O>, AliasArgs<["d"]>, + HelpText<"Disable optimization">; +def : CLFlag<"Og">, Alias<_SLASH_O>, AliasArgs<["g"]>, + HelpText<"No effect">; +def : CLFlag<"Oi">, Alias<_SLASH_O>, AliasArgs<["i"]>, + HelpText<"Enable use of builtin functions">; +def : CLFlag<"Oi-">, Alias<_SLASH_O>, AliasArgs<["i-"]>, + HelpText<"Disable use of builtin functions">; +def : CLFlag<"Os">, Alias<_SLASH_O>, AliasArgs<["s"]>, + HelpText<"Optimize for size">; +def : CLFlag<"Ot">, Alias<_SLASH_O>, AliasArgs<["t"]>, + HelpText<"Optimize for speed">; +def : CLFlag<"Ox">, Alias<_SLASH_O>, AliasArgs<["x"]>, + HelpText<"Deprecated (like /Og /Oi /Ot /Oy /Ob2); use /O2">; +def : CLFlag<"Oy">, Alias<_SLASH_O>, AliasArgs<["y"]>, + HelpText<"Enable frame pointer omission (x86 only)">; +def : CLFlag<"Oy-">, Alias<_SLASH_O>, AliasArgs<["y-"]>, + HelpText<"Disable frame pointer omission (x86 only, default)">; + +def _SLASH_QUESTION : CLFlag<"?">, Alias, + HelpText<"Display available options">; +def _SLASH_Qvec : CLFlag<"Qvec">, + HelpText<"Enable the loop vectorization passes">, Alias; +def _SLASH_Qvec_ : CLFlag<"Qvec-">, + HelpText<"Disable the loop vectorization passes">, Alias; +def _SLASH_showIncludes : CLFlag<"showIncludes">, + HelpText<"Print info about included files to stderr">; +def _SLASH_showIncludes_user : CLFlag<"showIncludes:user">, + HelpText<"Like /showIncludes but omit system headers">; +def _SLASH_showFilenames : CLFlag<"showFilenames">, + HelpText<"Print the name of each compiled file">; +def _SLASH_showFilenames_ : CLFlag<"showFilenames-">, + HelpText<"Do not print the name of each compiled file (default)">; +def _SLASH_source_charset : CLCompileJoined<"source-charset:">, + HelpText<"Set source encoding, supports only UTF-8">, + Alias; +def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">, + HelpText<"Set runtime encoding, supports only UTF-8">, + Alias; +def _SLASH_std : CLCompileJoined<"std:">, + HelpText<"Set C++ version (c++14,c++17,c++latest)">; +def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">, + MetaVarName<"">, Alias; +def _SLASH_validate_charset : CLFlag<"validate-charset">, + Alias, AliasArgs<["invalid-source-encoding"]>; +def _SLASH_validate_charset_ : CLFlag<"validate-charset-">, + Alias, AliasArgs<["no-invalid-source-encoding"]>; +def _SLASH_W0 : CLFlag<"W0">, HelpText<"Disable all warnings">, Alias; +def _SLASH_W1 : CLFlag<"W1">, HelpText<"Enable -Wall">, Alias; +def _SLASH_W2 : CLFlag<"W2">, HelpText<"Enable -Wall">, Alias; +def _SLASH_W3 : CLFlag<"W3">, HelpText<"Enable -Wall">, Alias; +def _SLASH_W4 : CLFlag<"W4">, HelpText<"Enable -Wall and -Wextra">, Alias; +def _SLASH_Wall : CLFlag<"Wall">, HelpText<"Enable -Weverything">, + Alias, AliasArgs<["everything"]>; +def _SLASH_WX : CLFlag<"WX">, HelpText<"Treat warnings as errors">, + Alias, AliasArgs<["error"]>; +def _SLASH_WX_ : CLFlag<"WX-">, + HelpText<"Do not treat warnings as errors (default)">, + Alias, AliasArgs<["no-error"]>; +def _SLASH_w_flag : CLFlag<"w">, HelpText<"Disable all warnings">, Alias; +def _SLASH_wd4005 : CLFlag<"wd4005">, Alias, + AliasArgs<["no-macro-redefined"]>; +def _SLASH_wd4018 : CLFlag<"wd4018">, Alias, + AliasArgs<["no-sign-compare"]>; +def _SLASH_wd4100 : CLFlag<"wd4100">, Alias, + AliasArgs<["no-unused-parameter"]>; +def _SLASH_wd4910 : CLFlag<"wd4910">, Alias, + AliasArgs<["no-dllexport-explicit-instantiation-decl"]>; +def _SLASH_wd4996 : CLFlag<"wd4996">, Alias, + AliasArgs<["no-deprecated-declarations"]>; +def _SLASH_vd : CLJoined<"vd">, HelpText<"Control vtordisp placement">, + Alias; +def _SLASH_X : CLFlag<"X">, + HelpText<"Do not add %INCLUDE% to include search path">, Alias; +def _SLASH_Zc_sizedDealloc : CLFlag<"Zc:sizedDealloc">, + HelpText<"Enable C++14 sized global deallocation functions">, + Alias; +def _SLASH_Zc_sizedDealloc_ : CLFlag<"Zc:sizedDealloc-">, + HelpText<"Disable C++14 sized global deallocation functions">, + Alias; +def _SLASH_Zc_alignedNew : CLFlag<"Zc:alignedNew">, + HelpText<"Enable C++17 aligned allocation functions">, + Alias; +def _SLASH_Zc_alignedNew_ : CLFlag<"Zc:alignedNew-">, + HelpText<"Disable C++17 aligned allocation functions">, + Alias; +def _SLASH_Zc_char8_t : CLFlag<"Zc:char8_t">, + HelpText<"Enable char8_t from C++2a">, + Alias; +def _SLASH_Zc_char8_t_ : CLFlag<"Zc:char8_t-">, + HelpText<"Disable char8_t from c++2a">, + Alias; +def _SLASH_Zc_strictStrings : CLFlag<"Zc:strictStrings">, + HelpText<"Treat string literals as const">, Alias, + AliasArgs<["error=c++11-compat-deprecated-writable-strings"]>; +def _SLASH_Zc_threadSafeInit : CLFlag<"Zc:threadSafeInit">, + HelpText<"Enable thread-safe initialization of static variables">, + Alias; +def _SLASH_Zc_threadSafeInit_ : CLFlag<"Zc:threadSafeInit-">, + HelpText<"Disable thread-safe initialization of static variables">, + Alias; +def _SLASH_Zc_trigraphs : CLFlag<"Zc:trigraphs">, + HelpText<"Enable trigraphs">, Alias; +def _SLASH_Zc_trigraphs_off : CLFlag<"Zc:trigraphs-">, + HelpText<"Disable trigraphs (default)">, Alias; +def _SLASH_Zc_twoPhase : CLFlag<"Zc:twoPhase">, + HelpText<"Enable two-phase name lookup in templates">, + Alias; +def _SLASH_Zc_twoPhase_ : CLFlag<"Zc:twoPhase-">, + HelpText<"Disable two-phase name lookup in templates (default)">, + Alias; +def _SLASH_Z7 : CLFlag<"Z7">, + HelpText<"Enable CodeView debug information in object files">; +def _SLASH_Zd : CLFlag<"Zd">, + HelpText<"Emit debug line number tables only">; +def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>, + HelpText<"Like /Z7">; +def _SLASH_Zp : CLJoined<"Zp">, + HelpText<"Set default maximum struct packing alignment">, + Alias; +def _SLASH_Zp_flag : CLFlag<"Zp">, + HelpText<"Set default maximum struct packing alignment to 1">, + Alias, AliasArgs<["1"]>; +def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">, + Alias; +def _SLASH_openmp_ : CLFlag<"openmp-">, + HelpText<"Disable OpenMP support">, Alias; +def _SLASH_openmp : CLFlag<"openmp">, HelpText<"Enable OpenMP support">, + Alias; +def _SLASH_openmp_experimental : CLFlag<"openmp:experimental">, + HelpText<"Enable OpenMP support with experimental SIMD support">, + Alias; + +// Non-aliases: + +def _SLASH_arch : CLCompileJoined<"arch:">, + HelpText<"Set architecture for code generation">; + +def _SLASH_M_Group : OptionGroup<"">, Group; +def _SLASH_volatile_Group : OptionGroup<"">, + Group; + +def _SLASH_EH : CLJoined<"EH">, HelpText<"Set exception handling model">; +def _SLASH_EP : CLFlag<"EP">, + HelpText<"Disable linemarker output and preprocess to stdout">; +def _SLASH_FA : CLFlag<"FA">, + HelpText<"Output assembly code file during compilation">; +def _SLASH_Fa : CLJoined<"Fa">, + HelpText<"Set assembly output file name (with /FA)">, + MetaVarName<"">; +def _SLASH_fallback : CLCompileFlag<"fallback">, + HelpText<"Fall back to cl.exe if clang-cl fails to compile">; +def _SLASH_FI : CLJoinedOrSeparate<"FI">, + HelpText<"Include file before parsing">, Alias; +def _SLASH_Fe : CLJoined<"Fe">, + HelpText<"Set output executable file name">, + MetaVarName<"">; +def _SLASH_Fi : CLCompileJoined<"Fi">, + HelpText<"Set preprocess output file name (with /P)">, + MetaVarName<"">; +def _SLASH_Fo : CLCompileJoined<"Fo">, + HelpText<"Set output object file (with /c)">, + MetaVarName<"">; +def _SLASH_guard : CLJoined<"guard:">, + HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks">; +def _SLASH_GX : CLFlag<"GX">, + HelpText<"Deprecated; use /EHsc">; +def _SLASH_GX_ : CLFlag<"GX-">, + HelpText<"Deprecated (like not passing /EH)">; +def _SLASH_imsvc : CLJoinedOrSeparate<"imsvc">, + HelpText<"Add to system include search path, as if in %INCLUDE%">, + MetaVarName<"">; +def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">; +def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">; +def _SLASH_link : CLRemainingArgsJoined<"link">, + HelpText<"Forward options to the linker">, MetaVarName<"">; +def _SLASH_MD : Option<["/", "-"], "MD", KIND_FLAG>, Group<_SLASH_M_Group>, + Flags<[CLOption, DriverOption]>, HelpText<"Use DLL run-time">; +def _SLASH_MDd : Option<["/", "-"], "MDd", KIND_FLAG>, Group<_SLASH_M_Group>, + Flags<[CLOption, DriverOption]>, HelpText<"Use DLL debug run-time">; +def _SLASH_MT : Option<["/", "-"], "MT", KIND_FLAG>, Group<_SLASH_M_Group>, + Flags<[CLOption, DriverOption]>, HelpText<"Use static run-time">; +def _SLASH_MTd : Option<["/", "-"], "MTd", KIND_FLAG>, Group<_SLASH_M_Group>, + Flags<[CLOption, DriverOption]>, HelpText<"Use static debug run-time">; +def _SLASH_o : CLJoinedOrSeparate<"o">, + HelpText<"Deprecated (set output file name); use /Fe or /Fe">, + MetaVarName<"">; +def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">; +def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">, + HelpText<"Treat as C source file">, MetaVarName<"">; +def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as C">; +def _SLASH_Tp : CLCompileJoinedOrSeparate<"Tp">, + HelpText<"Treat as C++ source file">, MetaVarName<"">; +def _SLASH_TP : CLCompileFlag<"TP">, HelpText<"Treat all source files as C++">; +def _SLASH_volatile_iso : Option<["/", "-"], "volatile:iso", KIND_FLAG>, + Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>, + HelpText<"Volatile loads and stores have standard semantics">; +def _SLASH_vmb : CLFlag<"vmb">, + HelpText<"Use a best-case representation method for member pointers">; +def _SLASH_vmg : CLFlag<"vmg">, + HelpText<"Use a most-general representation for member pointers">; +def _SLASH_vms : CLFlag<"vms">, + HelpText<"Set the default most-general representation to single inheritance">; +def _SLASH_vmm : CLFlag<"vmm">, + HelpText<"Set the default most-general representation to " + "multiple inheritance">; +def _SLASH_vmv : CLFlag<"vmv">, + HelpText<"Set the default most-general representation to " + "virtual inheritance">; +def _SLASH_volatile_ms : Option<["/", "-"], "volatile:ms", KIND_FLAG>, + Group<_SLASH_volatile_Group>, Flags<[CLOption, DriverOption]>, + HelpText<"Volatile loads and stores have acquire and release semantics">; +def _SLASH_clang : CLJoined<"clang:">, + HelpText<"Pass to the clang driver">, MetaVarName<"">; +def _SLASH_Zl : CLFlag<"Zl">, + HelpText<"Do not let object file auto-link default libraries">; + +def _SLASH_Yc : CLJoined<"Yc">, + HelpText<"Generate a pch file for all code up to and including ">, + MetaVarName<"">; +def _SLASH_Yu : CLJoined<"Yu">, + HelpText<"Load a pch file and use it instead of all code up to " + "and including ">, + MetaVarName<"">; +def _SLASH_Y_ : CLFlag<"Y-">, + HelpText<"Disable precompiled headers, overrides /Yc and /Yu">; +def _SLASH_Zc_dllexportInlines : CLFlag<"Zc:dllexportInlines">, + HelpText<"dllexport/dllimport inline member functions of dllexport/import classes (default)">; +def _SLASH_Zc_dllexportInlines_ : CLFlag<"Zc:dllexportInlines-">, + HelpText<"Do not dllexport/dllimport inline member functions of dllexport/import classes">; +def _SLASH_Fp : CLJoined<"Fp">, + HelpText<"Set pch file name (with /Yc and /Yu)">, MetaVarName<"">; + +def _SLASH_Gd : CLFlag<"Gd">, + HelpText<"Set __cdecl as a default calling convention">; +def _SLASH_Gr : CLFlag<"Gr">, + HelpText<"Set __fastcall as a default calling convention">; +def _SLASH_Gz : CLFlag<"Gz">, + HelpText<"Set __stdcall as a default calling convention">; +def _SLASH_Gv : CLFlag<"Gv">, + HelpText<"Set __vectorcall as a default calling convention">; +def _SLASH_Gregcall : CLFlag<"Gregcall">, + HelpText<"Set __regcall as a default calling convention">; + +// Ignored: + +def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">; +def _SLASH_bigobj : CLIgnoredFlag<"bigobj">; +def _SLASH_cgthreads : CLIgnoredJoined<"cgthreads">; +def _SLASH_d2FastFail : CLIgnoredFlag<"d2FastFail">; +def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">; +def _SLASH_errorReport : CLIgnoredJoined<"errorReport">; +def _SLASH_FC : CLIgnoredFlag<"FC">; +def _SLASH_Fd : CLIgnoredJoined<"Fd">; +def _SLASH_FS : CLIgnoredFlag<"FS">; +def _SLASH_JMC : CLIgnoredFlag<"JMC">; +def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">; +def _SLASH_nologo : CLIgnoredFlag<"nologo">; +def _SLASH_permissive_ : CLIgnoredFlag<"permissive-">; +def _SLASH_RTC : CLIgnoredJoined<"RTC">; +def _SLASH_sdl : CLIgnoredFlag<"sdl">; +def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">; +def _SLASH_utf8 : CLIgnoredFlag<"utf-8">, + HelpText<"Set source and runtime encoding to UTF-8 (default)">; +def _SLASH_w : CLIgnoredJoined<"w">; +def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">; +def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">; +def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">; +def _SLASH_Zc_inline : CLIgnoredFlag<"Zc:inline">; +def _SLASH_Zc_rvalueCast : CLIgnoredFlag<"Zc:rvalueCast">; +def _SLASH_Zc_ternary : CLIgnoredFlag<"Zc:ternary">; +def _SLASH_Zc_wchar_t : CLIgnoredFlag<"Zc:wchar_t">; +def _SLASH_ZH_MD5 : CLIgnoredFlag<"ZH:MD5">; +def _SLASH_ZH_SHA1 : CLIgnoredFlag<"ZH:SHA1">; +def _SLASH_ZH_SHA_256 : CLIgnoredFlag<"ZH:SHA_256">; +def _SLASH_Zm : CLIgnoredJoined<"Zm">; +def _SLASH_Zo : CLIgnoredFlag<"Zo">; +def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">; + + +// Unsupported: + +def _SLASH_await : CLFlag<"await">; +def _SLASH_constexpr : CLJoined<"constexpr:">; +def _SLASH_AI : CLJoinedOrSeparate<"AI">; +def _SLASH_Bt : CLFlag<"Bt">; +def _SLASH_Bt_plus : CLFlag<"Bt+">; +def _SLASH_clr : CLJoined<"clr">; +def _SLASH_d2 : CLJoined<"d2">; +def _SLASH_doc : CLJoined<"doc">; +def _SLASH_FA_joined : CLJoined<"FA">; +def _SLASH_favor : CLJoined<"favor">; +def _SLASH_F : CLJoinedOrSeparate<"F">; +def _SLASH_Fm : CLJoined<"Fm">; +def _SLASH_Fr : CLJoined<"Fr">; +def _SLASH_FR : CLJoined<"FR">; +def _SLASH_FU : CLJoinedOrSeparate<"FU">; +def _SLASH_Fx : CLFlag<"Fx">; +def _SLASH_G1 : CLFlag<"G1">; +def _SLASH_G2 : CLFlag<"G2">; +def _SLASH_Ge : CLFlag<"Ge">; +def _SLASH_Gh : CLFlag<"Gh">; +def _SLASH_GH : CLFlag<"GH">; +def _SLASH_GL : CLFlag<"GL">; +def _SLASH_GL_ : CLFlag<"GL-">; +def _SLASH_Gm : CLFlag<"Gm">; +def _SLASH_Gm_ : CLFlag<"Gm-">; +def _SLASH_GT : CLFlag<"GT">; +def _SLASH_GZ : CLFlag<"GZ">; +def _SLASH_H : CLFlag<"H">; +def _SLASH_homeparams : CLFlag<"homeparams">; +def _SLASH_hotpatch : CLFlag<"hotpatch">; +def _SLASH_kernel : CLFlag<"kernel">; +def _SLASH_LN : CLFlag<"LN">; +def _SLASH_MP : CLJoined<"MP">; +def _SLASH_Qfast_transcendentals : CLFlag<"Qfast_transcendentals">; +def _SLASH_QIfist : CLFlag<"QIfist">; +def _SLASH_QIntel_jcc_erratum : CLFlag<"QIntel-jcc-erratum">; +def _SLASH_Qimprecise_fwaits : CLFlag<"Qimprecise_fwaits">; +def _SLASH_Qpar : CLFlag<"Qpar">; +def _SLASH_Qpar_report : CLJoined<"Qpar-report">; +def _SLASH_Qsafe_fp_loads : CLFlag<"Qsafe_fp_loads">; +def _SLASH_Qspectre : CLFlag<"Qspectre">; +def _SLASH_Qspectre_load : CLFlag<"Qspectre-load">; +def _SLASH_Qspectre_load_cf : CLFlag<"Qspectre-load-cf">; +def _SLASH_Qvec_report : CLJoined<"Qvec-report">; +def _SLASH_u : CLFlag<"u">; +def _SLASH_V : CLFlag<"V">; +def _SLASH_WL : CLFlag<"WL">; +def _SLASH_Wp64 : CLFlag<"Wp64">; +def _SLASH_Yd : CLFlag<"Yd">; +def _SLASH_Yl : CLJoined<"Yl">; +def _SLASH_Za : CLFlag<"Za">; +def _SLASH_Zc : CLJoined<"Zc:">; +def _SLASH_Ze : CLFlag<"Ze">; +def _SLASH_Zg : CLFlag<"Zg">; +def _SLASH_ZI : CLFlag<"ZI">; +def _SLASH_ZW : CLJoined<"ZW">; From cfe-commits at lists.llvm.org Thu Jul 9 10:30:06 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 17:30:06 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: <8b6733fea9900bb65ca700ab4a3a856a@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGfccd29dddee9: Merge TableGen files used for clang options (authored by dang). Changed prior to commit: https://reviews.llvm.org/D82574?vs=273407&id=276775#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 Files: clang/include/clang/Driver/CLCompatOptions.td clang/include/clang/Driver/Options.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D82574.276775.patch Type: text/x-patch Size: 99765 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 10:34:10 2020 From: cfe-commits at lists.llvm.org (Dokyung Song via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 17:34:10 +0000 (UTC) Subject: [PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked. Message-ID: dokyungs created this revision. Herald added subscribers: Sanitizers, cfe-commits, mgorny. Herald added projects: clang, Sanitizers. libFuzzer intercepts certain library functions such as memcmp/strcmp by defining weak hooks. Weak hooks, however, are called only when other runtimes such as ASan is linked. This patch defines libFuzzer's own interceptors, which is linked into the libFuzzer executable when other runtimes are not linked, i.e., when -fsanitize=fuzzer is given, but not others. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83494 Files: clang/include/clang/Driver/SanitizerArgs.h clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp compiler-rt/lib/fuzzer/CMakeLists.txt compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83494.276776.patch Type: text/x-patch Size: 5936 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 10:38:18 2020 From: cfe-commits at lists.llvm.org (Amy Huang via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 17:38:18 +0000 (UTC) Subject: [PATCH] D79147: Switch to using -debug-info-kind=constructor as default (from =limited) In-Reply-To: References: Message-ID: akhuang updated this revision to Diff 276778. akhuang added a comment. fix one more test case Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79147/new/ https://reviews.llvm.org/D79147 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-options.c clang/test/Driver/clang-g-opts.c clang/test/Driver/cuda-dwarf-2.cu clang/test/Driver/debug-options-as.c clang/test/Driver/debug-options.c clang/test/Driver/integrated-as.s clang/test/Driver/myriad-toolchain.c clang/test/Driver/openmp-offload-gpu.c clang/test/Driver/split-debug.c lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D79147.276778.patch Type: text/x-patch Size: 12383 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 10:52:56 2020 From: cfe-commits at lists.llvm.org (Puyan Lotfi via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 17:52:56 +0000 (UTC) Subject: [PATCH] D79730: [NFCi] Switch ordering of ParseLangArgs and ParseCodeGenArgs. In-Reply-To: References: Message-ID: <12688a04ecd3c809044b342228f8e932@localhost.localdomain> plotfi added a subscriber: dexonsmith. plotfi added a comment. In D79730#2030530 , @rjmccall wrote: > I think it makes sense; if nothing else, we're trying to upstream all that work. @rjmccall Should I still try to land this or should this stuff get pushed in as part of the apple/master upstreaming effort @dexonsmith mentioned on the llvm list? I can abandon this diff if thats the plan. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79730/new/ https://reviews.llvm.org/D79730 From cfe-commits at lists.llvm.org Thu Jul 9 10:54:50 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 17:54:50 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: <59a6b5dce19dfca10d5721b5acf9f0f8@localhost.localdomain> gribozavr2 added inline comments. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:737 + Builder.findToken(TokLoc)->text(Context.getSourceManager()); + auto Literal = NumericLiteralParser{TokSpelling, + TokLoc, ---------------- Please use parentheses to call the constructor. Braces are correct, but not idiomatic in LLVM. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:754 + new (allocator()) syntax::UserDefinedLiteralExpression( + getUserDefinedLiteralKind(S)), + S); ---------------- Please allocate an instance of the correct derived type. It is undefined behavior to downcast an object allocated as `UserDefinedLiteralExpression` to any of its subtypes. ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1197 + +unsigned operator "" _r(const char*); // raw-literal operator + ---------------- No need to explain the language. ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1200 +template +unsigned operator "" _t(); // numeric literal operator template + ---------------- No need to explain the language. ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1210 + 12_t; // call: operator<'1', '2'> "" _x() | kind: integer + 1.2_t; // call: operator<'1', '2'> "" _x() | kind: float } ---------------- call -> calls? (as in, "this expression calls ...") ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1333 + R"cpp( +typedef decltype(sizeof(void *)) size_t; +unsigned operator "" _s(const char*, size_t); ---------------- I don't understand why this test is separate from the previous one -- why not merge them all into one, or split all of them into one call per test? ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1336 +void test() { + "12"_s;// call: operator "" _s("12") | kind: string +} ---------------- ditto, "calls" Also please add a space before "//". Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 From cfe-commits at lists.llvm.org Thu Jul 9 11:15:06 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:15:06 +0000 (UTC) Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend In-Reply-To: References: Message-ID: lei accepted this revision. lei added a comment. LGTM thx. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83364/new/ https://reviews.llvm.org/D83364 From cfe-commits at lists.llvm.org Thu Jul 9 11:17:12 2020 From: cfe-commits at lists.llvm.org (Dave Green via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:17:12 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: <5e021e076deb34eadf8f2b67810c89aa@localhost.localdomain> dmgreen added a comment. Hello Did you mean to remove CC1Options.td too? Otherwise it does not appear to be used any more or this has duplicated the contents. Also can you make sure the new content of Options.td reflects the latest version of CC1Options.td, and that no extra changes have been made since this was created. Thanks Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Thu Jul 9 11:25:26 2020 From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:25:26 +0000 (UTC) Subject: [PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend In-Reply-To: References: Message-ID: Conanap updated this revision to Diff 276785. Conanap marked 3 inline comments as done. Conanap added a comment. Now depends on D83364 . Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82502/new/ https://reviews.llvm.org/D82502 Files: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c llvm/lib/Target/PowerPC/PPCISelLowering.cpp llvm/lib/Target/PowerPC/PPCISelLowering.h llvm/lib/Target/PowerPC/PPCInstrPrefix.td llvm/test/CodeGen/PowerPC/ISA31-vsx-builtins.ll llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s -------------- next part -------------- A non-text attachment was scrubbed... Name: D82502.276785.patch Type: text/x-patch Size: 13415 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 11:25:54 2020 From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:25:54 +0000 (UTC) Subject: [PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend In-Reply-To: References: Message-ID: <8d8a4a8fdb7ddaaf5fc8a535d8bdeef1@localhost.localdomain> Conanap added a comment. Also removed unnecessary brackets and comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82502/new/ https://reviews.llvm.org/D82502 From cfe-commits at lists.llvm.org Thu Jul 9 11:34:43 2020 From: cfe-commits at lists.llvm.org (via cfe-commits) Date: Thu, 09 Jul 2020 11:34:43 -0700 (PDT) Subject: [clang] 2da9572 - [OPENMP50] extend array section for stride (Parsing/Sema/AST) Message-ID: <5f076343.1c69fb81.7e178.8e09@mx.google.com> Author: cchen Date: 2020-07-09T13:28:51-05:00 New Revision: 2da9572a9b10c8e4d0db2f3267f1a2c0ea31c896 URL: https://github.com/llvm/llvm-project/commit/2da9572a9b10c8e4d0db2f3267f1a2c0ea31c896 DIFF: https://github.com/llvm/llvm-project/commit/2da9572a9b10c8e4d0db2f3267f1a2c0ea31c896.diff LOG: [OPENMP50] extend array section for stride (Parsing/Sema/AST) Reviewers: ABataev, jdoerfert Reviewed By: ABataev Subscribers: yaxunl, guansong, arphaman, sstefan1, cfe-commits, sandoval, dreachem Tags: #clang Differential Revision: https://reviews.llvm.org/D82800 Added: Modified: clang/include/clang-c/Index.h clang/include/clang/AST/ExprOpenMP.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/StmtPrinter.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/OpenMP/target_data_messages.c clang/test/OpenMP/target_depend_messages.cpp clang/test/OpenMP/target_enter_data_depend_messages.cpp clang/test/OpenMP/target_exit_data_depend_messages.cpp clang/test/OpenMP/target_map_messages.cpp clang/test/OpenMP/target_parallel_depend_messages.cpp clang/test/OpenMP/target_parallel_for_depend_messages.cpp clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_simd_depend_messages.cpp clang/test/OpenMP/target_teams_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp clang/test/OpenMP/target_update_ast_print.cpp clang/test/OpenMP/target_update_messages.cpp Removed: ################################################################################ diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index cfb8e58bfb7e..5fa728d6d66c 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -2167,7 +2167,7 @@ enum CXCursorKind { */ CXCursor_ObjCSelfExpr = 147, - /** OpenMP 4.0 [2.4, Array Section]. + /** OpenMP 5.0 [2.1.5, Array Section]. */ CXCursor_OMPArraySectionExpr = 148, diff --git a/clang/include/clang/AST/ExprOpenMP.h b/clang/include/clang/AST/ExprOpenMP.h index a2b59a6f2696..be5dda992334 100644 --- a/clang/include/clang/AST/ExprOpenMP.h +++ b/clang/include/clang/AST/ExprOpenMP.h @@ -17,46 +17,61 @@ #include "clang/AST/Expr.h" namespace clang { -/// OpenMP 4.0 [2.4, Array Sections]. +/// OpenMP 5.0 [2.1.5, Array Sections]. /// To specify an array section in an OpenMP construct, array subscript /// expressions are extended with the following syntax: /// \code +/// [ lower-bound : length : stride ] +/// [ lower-bound : length : ] /// [ lower-bound : length ] +/// [ lower-bound : : stride ] +/// [ lower-bound : : ] /// [ lower-bound : ] +/// [ : length : stride ] +/// [ : length : ] /// [ : length ] +/// [ : : stride ] +/// [ : : ] /// [ : ] /// \endcode /// The array section must be a subset of the original array. /// Array sections are allowed on multidimensional arrays. Base language array /// subscript expressions can be used to specify length-one dimensions of /// multidimensional array sections. -/// The lower-bound and length are integral type expressions. When evaluated +/// Each of the lower-bound, length, and stride expressions if specified must be +/// an integral type expressions of the base language. When evaluated /// they represent a set of integer values as follows: /// \code -/// { lower-bound, lower-bound + 1, lower-bound + 2,... , lower-bound + length - -/// 1 } +/// { lower-bound, lower-bound + stride, lower-bound + 2 * stride,... , +/// lower-bound + ((length - 1) * stride) } /// \endcode /// The lower-bound and length must evaluate to non-negative integers. +/// The stride must evaluate to a positive integer. /// When the size of the array dimension is not known, the length must be /// specified explicitly. -/// When the length is absent, it defaults to the size of the array dimension -/// minus the lower-bound. -/// When the lower-bound is absent it defaults to 0. +/// When the stride is absent it defaults to 1. +/// When the length is absent it defaults to ⌈(size − lower-bound)/stride⌉, +/// where size is the size of the array dimension. When the lower-bound is +/// absent it defaults to 0. class OMPArraySectionExpr : public Expr { - enum { BASE, LOWER_BOUND, LENGTH, END_EXPR }; + enum { BASE, LOWER_BOUND, LENGTH, STRIDE, END_EXPR }; Stmt *SubExprs[END_EXPR]; - SourceLocation ColonLoc; + SourceLocation ColonLocFirst; + SourceLocation ColonLocSecond; SourceLocation RBracketLoc; public: - OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, QualType Type, - ExprValueKind VK, ExprObjectKind OK, - SourceLocation ColonLoc, SourceLocation RBracketLoc) - : Expr(OMPArraySectionExprClass, Type, VK, OK), ColonLoc(ColonLoc), + OMPArraySectionExpr(Expr *Base, Expr *LowerBound, Expr *Length, Expr *Stride, + QualType Type, ExprValueKind VK, ExprObjectKind OK, + SourceLocation ColonLocFirst, + SourceLocation ColonLocSecond, SourceLocation RBracketLoc) + : Expr(OMPArraySectionExprClass, Type, VK, OK), + ColonLocFirst(ColonLocFirst), ColonLocSecond(ColonLocSecond), RBracketLoc(RBracketLoc) { SubExprs[BASE] = Base; SubExprs[LOWER_BOUND] = LowerBound; SubExprs[LENGTH] = Length; + SubExprs[STRIDE] = Stride; setDependence(computeDependence(this)); } @@ -89,13 +104,22 @@ class OMPArraySectionExpr : public Expr { /// Set length of the array section. void setLength(Expr *E) { SubExprs[LENGTH] = E; } + /// Get stride of array section. + Expr *getStride() { return cast_or_null(SubExprs[STRIDE]); } + const Expr *getStride() const { return cast_or_null(SubExprs[STRIDE]); } + /// Set length of the array section. + void setStride(Expr *E) { SubExprs[STRIDE] = E; } + SourceLocation getBeginLoc() const LLVM_READONLY { return getBase()->getBeginLoc(); } SourceLocation getEndLoc() const LLVM_READONLY { return RBracketLoc; } - SourceLocation getColonLoc() const { return ColonLoc; } - void setColonLoc(SourceLocation L) { ColonLoc = L; } + SourceLocation getColonLocFirst() const { return ColonLocFirst; } + void setColonLocFirst(SourceLocation L) { ColonLocFirst = L; } + + SourceLocation getColonLocSecond() const { return ColonLocSecond; } + void setColonLocSecond(SourceLocation L) { ColonLocSecond = L; } SourceLocation getRBracketLoc() const { return RBracketLoc; } void setRBracketLoc(SourceLocation L) { RBracketLoc = L; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index c0d0acccb181..29408be6881f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10064,6 +10064,8 @@ def err_omp_section_not_subset_of_array : Error< "array section must be a subset of the original array">; def err_omp_section_length_negative : Error< "section length is evaluated to a negative value %0">; +def err_omp_section_stride_non_positive : Error< + "section stride is evaluated to a non-positive value %0">; def err_omp_section_length_undefined : Error< "section length is unspecified and cannot be inferred because subscripted value is %select{not an array|an array of unknown bound}0">; def err_omp_wrong_linear_modifier : Error< diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index dda6db131240..1d75515d494e 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -241,6 +241,9 @@ class Parser : public CodeCompletionHandler { /// The "depth" of the template parameters currently being parsed. unsigned TemplateParameterDepth; + /// Current kind of OpenMP clause + OpenMPClauseKind OMPClauseKind = llvm::omp::OMPC_unknown; + /// RAII class that manages the template parameter depth. class TemplateParameterDepthRAII { unsigned &Depth; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index a540d788f4d8..7535849144d0 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4971,8 +4971,11 @@ class Sema final { SourceLocation RBLoc); ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, - Expr *LowerBound, SourceLocation ColonLoc, - Expr *Length, SourceLocation RBLoc); + Expr *LowerBound, + SourceLocation ColonLocFirst, + SourceLocation ColonLocSecond, + Expr *Length, Expr *Stride, + SourceLocation RBLoc); ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef Dims, diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp index 11e222f95176..f797f5fe8e6d 100644 --- a/clang/lib/AST/StmtPrinter.cpp +++ b/clang/lib/AST/StmtPrinter.cpp @@ -1343,11 +1343,16 @@ void StmtPrinter::VisitOMPArraySectionExpr(OMPArraySectionExpr *Node) { OS << "["; if (Node->getLowerBound()) PrintExpr(Node->getLowerBound()); - if (Node->getColonLoc().isValid()) { + if (Node->getColonLocFirst().isValid()) { OS << ":"; if (Node->getLength()) PrintExpr(Node->getLength()); } + if (Node->getColonLocSecond().isValid()) { + OS << ":"; + if (Node->getStride()) + PrintExpr(Node->getStride()); + } OS << "]"; } diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index be5d976f346c..9e8770573d70 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3849,7 +3849,7 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, else ResultExprTy = BaseTy->getPointeeType(); llvm::Value *Idx = nullptr; - if (IsLowerBound || E->getColonLoc().isInvalid()) { + if (IsLowerBound || E->getColonLocFirst().isInvalid()) { // Requesting lower bound or upper bound, but without provided length and // without ':' symbol for the default length -> length = 1. // Idx = LowerBound ?: 0; diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index fb2ce60f2e41..43cbe9c720ea 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -7175,7 +7175,7 @@ class MappableExprsHandler { // If there is no length associated with the expression and lower bound is // not specified too, that means we are using the whole length of the // base. - if (!OAE->getLength() && OAE->getColonLoc().isValid() && + if (!OAE->getLength() && OAE->getColonLocFirst().isValid() && !OAE->getLowerBound()) return CGF.getTypeSize(BaseTy); @@ -7190,7 +7190,7 @@ class MappableExprsHandler { // If we don't have a length at this point, that is because we have an // array section with a single element. - if (!OAE->getLength() && OAE->getColonLoc().isInvalid()) + if (!OAE->getLength() && OAE->getColonLocFirst().isInvalid()) return ElemSize; if (const Expr *LenExpr = OAE->getLength()) { @@ -7200,7 +7200,7 @@ class MappableExprsHandler { LenExpr->getExprLoc()); return CGF.Builder.CreateNUWMul(LengthVal, ElemSize); } - assert(!OAE->getLength() && OAE->getColonLoc().isValid() && + assert(!OAE->getLength() && OAE->getColonLocFirst().isValid() && OAE->getLowerBound() && "expected array_section[lb:]."); // Size = sizetype - lb * elemtype; llvm::Value *LengthVal = CGF.getTypeSize(BaseTy); @@ -7273,7 +7273,7 @@ class MappableExprsHandler { return false; // An array section with no colon always refer to a single element. - if (OASE->getColonLoc().isInvalid()) + if (OASE->getColonLocFirst().isInvalid()) return false; const Expr *Length = OASE->getLength(); diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index bfc465f89628..81e87582c6ad 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1909,8 +1909,8 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { BalancedDelimiterTracker T(*this, tok::l_square); T.consumeOpen(); Loc = T.getOpenLocation(); - ExprResult Idx, Length; - SourceLocation ColonLoc; + ExprResult Idx, Length, Stride; + SourceLocation ColonLocFirst, ColonLocSecond; PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.get()); if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) { Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); @@ -1924,10 +1924,22 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { } if (Tok.is(tok::colon)) { // Consume ':' - ColonLoc = ConsumeToken(); - if (Tok.isNot(tok::r_square)) + ColonLocFirst = ConsumeToken(); + if (Tok.isNot(tok::r_square) && + (getLangOpts().OpenMP < 50 || + ((Tok.isNot(tok::colon) && getLangOpts().OpenMP >= 50)))) Length = ParseExpression(); } + if (getLangOpts().OpenMP >= 50 && + (OMPClauseKind == llvm::omp::Clause::OMPC_to || + OMPClauseKind == llvm::omp::Clause::OMPC_from) && + Tok.is(tok::colon)) { + // Consume ':' + ColonLocSecond = ConsumeToken(); + if (Tok.isNot(tok::r_square)) { + Stride = ParseExpression(); + } + } } else Idx = ParseExpression(); @@ -1937,10 +1949,11 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { Idx = Actions.CorrectDelayedTyposInExpr(Idx); Length = Actions.CorrectDelayedTyposInExpr(Length); if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() && - Tok.is(tok::r_square)) { - if (ColonLoc.isValid()) { - LHS = Actions.ActOnOMPArraySectionExpr(LHS.get(), Loc, Idx.get(), - ColonLoc, Length.get(), RLoc); + !Stride.isInvalid() && Tok.is(tok::r_square)) { + if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) { + LHS = Actions.ActOnOMPArraySectionExpr( + LHS.get(), Loc, Idx.get(), ColonLocFirst, ColonLocSecond, + Length.get(), Stride.get(), RLoc); } else { LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc, Idx.get(), RLoc); diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index dc1283070c43..afcef3043843 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2498,6 +2498,7 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { /// OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind, OpenMPClauseKind CKind, bool FirstClause) { + OMPClauseKind = CKind; OMPClause *Clause = nullptr; bool ErrorFound = false; bool WrongDirective = false; diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 986c03bb872b..0a7604d9f399 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4562,7 +4562,8 @@ Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc, if (base && !base->getType().isNull() && base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection)) return ActOnOMPArraySectionExpr(base, lbLoc, idx, SourceLocation(), - /*Length=*/nullptr, rbLoc); + SourceLocation(), /*Length*/ nullptr, + /*Stride=*/nullptr, rbLoc); // Since this might be a postfix expression, get rid of ParenListExprs. if (isa(base)) { @@ -4812,7 +4813,9 @@ void Sema::CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E) { ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, - SourceLocation ColonLoc, Expr *Length, + SourceLocation ColonLocFirst, + SourceLocation ColonLocSecond, + Expr *Length, Expr *Stride, SourceLocation RBLoc) { if (Base->getType()->isPlaceholderType() && !Base->getType()->isSpecificPlaceholderType( @@ -4840,15 +4843,25 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, return ExprError(); Length = Result.get(); } + if (Stride && Stride->getType()->isNonOverloadPlaceholderType()) { + ExprResult Result = CheckPlaceholderExpr(Stride); + if (Result.isInvalid()) + return ExprError(); + Result = DefaultLvalueConversion(Result.get()); + if (Result.isInvalid()) + return ExprError(); + Stride = Result.get(); + } // Build an unanalyzed expression if either operand is type-dependent. if (Base->isTypeDependent() || (LowerBound && (LowerBound->isTypeDependent() || LowerBound->isValueDependent())) || - (Length && (Length->isTypeDependent() || Length->isValueDependent()))) { - return new (Context) - OMPArraySectionExpr(Base, LowerBound, Length, Context.DependentTy, - VK_LValue, OK_Ordinary, ColonLoc, RBLoc); + (Length && (Length->isTypeDependent() || Length->isValueDependent())) || + (Stride && (Stride->isTypeDependent() || Stride->isValueDependent()))) { + return new (Context) OMPArraySectionExpr( + Base, LowerBound, Length, Stride, Context.DependentTy, VK_LValue, + OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc); } // Perform default conversions. @@ -4892,6 +4905,20 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Diag(Length->getExprLoc(), diag::warn_omp_section_is_char) << 1 << Length->getSourceRange(); } + if (Stride) { + ExprResult Res = + PerformOpenMPImplicitIntegerConversion(Stride->getExprLoc(), Stride); + if (Res.isInvalid()) + return ExprError(Diag(Stride->getExprLoc(), + diag::err_omp_typecheck_section_not_integer) + << 1 << Stride->getSourceRange()); + Stride = Res.get(); + + if (Stride->getType()->isSpecificBuiltinType(BuiltinType::Char_S) || + Stride->getType()->isSpecificBuiltinType(BuiltinType::Char_U)) + Diag(Stride->getExprLoc(), diag::warn_omp_section_is_char) + << 1 << Stride->getSourceRange(); + } // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly, // C++ [expr.sub]p1: The type "T" shall be a completely-defined object @@ -4910,7 +4937,7 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, if (LowerBound && !OriginalTy->isAnyPointerType()) { Expr::EvalResult Result; if (LowerBound->EvaluateAsInt(Result, Context)) { - // OpenMP 4.5, [2.4 Array Sections] + // OpenMP 5.0, [2.1.5 Array Sections] // The array section must be a subset of the original array. llvm::APSInt LowerBoundValue = Result.Val.getInt(); if (LowerBoundValue.isNegative()) { @@ -4924,7 +4951,7 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, if (Length) { Expr::EvalResult Result; if (Length->EvaluateAsInt(Result, Context)) { - // OpenMP 4.5, [2.4 Array Sections] + // OpenMP 5.0, [2.1.5 Array Sections] // The length must evaluate to non-negative integers. llvm::APSInt LengthValue = Result.Val.getInt(); if (LengthValue.isNegative()) { @@ -4934,17 +4961,32 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, return ExprError(); } } - } else if (ColonLoc.isValid() && + } else if (ColonLocFirst.isValid() && (OriginalTy.isNull() || (!OriginalTy->isConstantArrayType() && !OriginalTy->isVariableArrayType()))) { - // OpenMP 4.5, [2.4 Array Sections] + // OpenMP 5.0, [2.1.5 Array Sections] // When the size of the array dimension is not known, the length must be // specified explicitly. - Diag(ColonLoc, diag::err_omp_section_length_undefined) + Diag(ColonLocFirst, diag::err_omp_section_length_undefined) << (!OriginalTy.isNull() && OriginalTy->isArrayType()); return ExprError(); } + if (Stride) { + Expr::EvalResult Result; + if (Stride->EvaluateAsInt(Result, Context)) { + // OpenMP 5.0, [2.1.5 Array Sections] + // The stride must evaluate to a positive integer. + llvm::APSInt StrideValue = Result.Val.getInt(); + if (!StrideValue.isStrictlyPositive()) { + Diag(Stride->getExprLoc(), diag::err_omp_section_stride_non_positive) + << StrideValue.toString(/*Radix=*/10, /*Signed=*/true) + << Stride->getSourceRange(); + return ExprError(); + } + } + } + if (!Base->getType()->isSpecificPlaceholderType( BuiltinType::OMPArraySection)) { ExprResult Result = DefaultFunctionArrayLvalueConversion(Base); @@ -4952,9 +4994,9 @@ ExprResult Sema::ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, return ExprError(); Base = Result.get(); } - return new (Context) - OMPArraySectionExpr(Base, LowerBound, Length, Context.OMPArraySectionTy, - VK_LValue, OK_Ordinary, ColonLoc, RBLoc); + return new (Context) OMPArraySectionExpr( + Base, LowerBound, Length, Stride, Context.OMPArraySectionTy, VK_LValue, + OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc); } ExprResult Sema::ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 3aa74c87a1b0..b27abb54c170 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -14692,7 +14692,7 @@ static bool checkOMPArraySectionConstantForReduction( if (Length == nullptr) { // For array sections of the form [1:] or [:], we would need to analyze // the lower bound... - if (OASE->getColonLoc().isValid()) + if (OASE->getColonLocFirst().isValid()) return false; // This is an array subscript which has implicit length 1! @@ -14718,7 +14718,7 @@ static bool checkOMPArraySectionConstantForReduction( if (Length == nullptr) { // For array sections of the form [1:] or [:], we would need to analyze // the lower bound... - if (OASE->getColonLoc().isValid()) + if (OASE->getColonLocFirst().isValid()) return false; // This is an array subscript which has implicit length 1! @@ -16475,7 +16475,8 @@ static bool checkArrayExpressionDoesNotReferToWholeSize(Sema &SemaRef, // If this is an array subscript, it refers to the whole size if the size of // the dimension is constant and equals 1. Also, an array section assumes the // format of an array subscript if no colon is used. - if (isa(E) || (OASE && OASE->getColonLoc().isInvalid())) { + if (isa(E) || + (OASE && OASE->getColonLocFirst().isInvalid())) { if (const auto *ATy = dyn_cast(BaseQTy.getTypePtr())) return ATy->getSize().getSExtValue() != 1; // Size can't be evaluated statically. @@ -16531,7 +16532,8 @@ static bool checkArrayExpressionDoesNotReferToUnitySize(Sema &SemaRef, // An array subscript always refer to a single element. Also, an array section // assumes the format of an array subscript if no colon is used. - if (isa(E) || (OASE && OASE->getColonLoc().isInvalid())) + if (isa(E) || + (OASE && OASE->getColonLocFirst().isInvalid())) return false; assert(OASE && "Expecting array section if not an array subscript."); @@ -16575,7 +16577,7 @@ static bool checkArrayExpressionDoesNotReferToUnitySize(Sema &SemaRef, // // We want to retrieve the member expression 'this->S'; -// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, p.2] +// OpenMP 5.0 [2.19.7.1, map Clause, Restrictions, p.2] // If a list item is an array section, it must specify contiguous storage. // // For this restriction it is sufficient that we make sure only references diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 65d1182cc5d8..1b7c22f0901b 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -2436,10 +2436,13 @@ class TreeTransform { /// Subclasses may override this routine to provide diff erent behavior. ExprResult RebuildOMPArraySectionExpr(Expr *Base, SourceLocation LBracketLoc, Expr *LowerBound, - SourceLocation ColonLoc, Expr *Length, + SourceLocation ColonLocFirst, + SourceLocation ColonLocSecond, + Expr *Length, Expr *Stride, SourceLocation RBracketLoc) { return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound, - ColonLoc, Length, RBracketLoc); + ColonLocFirst, ColonLocSecond, + Length, Stride, RBracketLoc); } /// Build a new array shaping expression. @@ -10337,13 +10340,21 @@ TreeTransform::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) { return ExprError(); } + ExprResult Stride; + if (Expr *Str = E->getStride()) { + Stride = getDerived().TransformExpr(Str); + if (Stride.isInvalid()) + return ExprError(); + } + if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() && LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength()) return E; return getDerived().RebuildOMPArraySectionExpr( - Base.get(), E->getBase()->getEndLoc(), LowerBound.get(), E->getColonLoc(), - Length.get(), E->getRBracketLoc()); + Base.get(), E->getBase()->getEndLoc(), LowerBound.get(), + E->getColonLocFirst(), E->getColonLocSecond(), Length.get(), Stride.get(), + E->getRBracketLoc()); } template diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index 9a73ce1f9b2e..e3bac703f9f7 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -937,7 +937,9 @@ void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) { E->setBase(Record.readSubExpr()); E->setLowerBound(Record.readSubExpr()); E->setLength(Record.readSubExpr()); - E->setColonLoc(readSourceLocation()); + E->setStride(Record.readSubExpr()); + E->setColonLocFirst(readSourceLocation()); + E->setColonLocSecond(readSourceLocation()); E->setRBracketLoc(readSourceLocation()); } diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 71c2e9e29757..941665ff0cba 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -797,7 +797,9 @@ void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) { Record.AddStmt(E->getBase()); Record.AddStmt(E->getLowerBound()); Record.AddStmt(E->getLength()); - Record.AddSourceLocation(E->getColonLoc()); + Record.AddStmt(E->getStride()); + Record.AddSourceLocation(E->getColonLocFirst()); + Record.AddSourceLocation(E->getColonLocSecond()); Record.AddSourceLocation(E->getRBracketLoc()); Code = serialization::EXPR_OMP_ARRAY_SECTION; } diff --git a/clang/test/OpenMP/target_data_messages.c b/clang/test/OpenMP/target_data_messages.c index 7a7fc0012af2..bc164c3f1796 100644 --- a/clang/test/OpenMP/target_data_messages.c +++ b/clang/test/OpenMP/target_data_messages.c @@ -45,5 +45,12 @@ int main(int argc, char **argv) { { foo(); } + + const int b = 5; + int marr[10][10], iarr[5]; +#pragma omp target data map(to: marr[10][0:2:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + {} +#pragma omp target data map(alloc: iarr[:2:b]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + {} return 0; } diff --git a/clang/test/OpenMP/target_depend_messages.cpp b/clang/test/OpenMP/target_depend_messages.cpp index 6fb9bb170c49..9e5f28c04f9e 100644 --- a/clang/test/OpenMP/target_depend_messages.cpp +++ b/clang/test/OpenMP/target_depend_messages.cpp @@ -80,7 +80,7 @@ int main(int argc, char **argv, char *env[]) { foo(); #pragma omp target depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); - #pragma omp target depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); diff --git a/clang/test/OpenMP/target_enter_data_depend_messages.cpp b/clang/test/OpenMP/target_enter_data_depend_messages.cpp index a1d97230c7a1..4b28067b8eb3 100644 --- a/clang/test/OpenMP/target_enter_data_depend_messages.cpp +++ b/clang/test/OpenMP/target_enter_data_depend_messages.cpp @@ -76,7 +76,7 @@ int tmain(T argc, S **argv, R *env[]) { foo(); #pragma omp target enter data map(to: i) depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); - #pragma omp target enter data map(to: i) depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} +#pragma omp target enter data map(to : i) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target enter data map(to: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); @@ -149,9 +149,9 @@ int main(int argc, char **argv, char *env[]) { foo(); #pragma omp target enter data map(to: i) depend (in : argv[-1:0]) // expected-error {{zero-length array section is not allowed in 'depend' clause}} foo(); - #pragma omp target enter data map(to: i) depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} + #pragma omp target enter data map(to: i) depend(in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); - #pragma omp target enter data map(to: i) depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target enter data map(to : i) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target enter data map(to: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); diff --git a/clang/test/OpenMP/target_exit_data_depend_messages.cpp b/clang/test/OpenMP/target_exit_data_depend_messages.cpp index ba3d203cd47d..a1bcdb0f9206 100644 --- a/clang/test/OpenMP/target_exit_data_depend_messages.cpp +++ b/clang/test/OpenMP/target_exit_data_depend_messages.cpp @@ -76,7 +76,7 @@ int tmain(T argc, S **argv, R *env[]) { foo(); #pragma omp target exit data map(from: i) depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); - #pragma omp target exit data map(from: i) depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target exit data map(from : i) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target exit data map(from: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); @@ -151,7 +151,7 @@ int main(int argc, char **argv, char *env[]) { foo(); #pragma omp target exit data map(from: i) depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); - #pragma omp target exit data map(from: i) depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target exit data map(from : i) depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target exit data map(from: i) depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); diff --git a/clang/test/OpenMP/target_map_messages.cpp b/clang/test/OpenMP/target_map_messages.cpp index 646cebe21850..833f509cd7f0 100644 --- a/clang/test/OpenMP/target_map_messages.cpp +++ b/clang/test/OpenMP/target_map_messages.cpp @@ -550,6 +550,12 @@ T tmain(T argc) { #pragma omp target data map(tofrom, close: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} #pragma omp target data map(close, tofrom: close, tofrom, x) foo(); + + T marr[10][10], iarr[5]; +#pragma omp target data map(marr[10][0:2:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + {} +#pragma omp target data map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + {} return 0; } @@ -737,6 +743,13 @@ int main(int argc, char **argv) { #pragma omp target map(release: a) // expected-error {{map type 'release' is not allowed for '#pragma omp target'}} {} + int marr[10][10], iarr[5]; + +#pragma omp target map(marr[10][0:2:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + {} +#pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + {} + return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } #endif diff --git a/clang/test/OpenMP/target_parallel_depend_messages.cpp b/clang/test/OpenMP/target_parallel_depend_messages.cpp index 552b20f4f56a..997669922d36 100644 --- a/clang/test/OpenMP/target_parallel_depend_messages.cpp +++ b/clang/test/OpenMP/target_parallel_depend_messages.cpp @@ -74,7 +74,7 @@ int main(int argc, char **argv, char *env[]) { foo(); #pragma omp target parallel depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); - #pragma omp target parallel depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target parallel depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target parallel depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); diff --git a/clang/test/OpenMP/target_parallel_for_depend_messages.cpp b/clang/test/OpenMP/target_parallel_for_depend_messages.cpp index 19b00278dbf3..bb8a282fb9b0 100644 --- a/clang/test/OpenMP/target_parallel_for_depend_messages.cpp +++ b/clang/test/OpenMP/target_parallel_for_depend_messages.cpp @@ -82,7 +82,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target parallel for depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); - #pragma omp target parallel for depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target parallel for depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target parallel for depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp index cd5f44f6261c..64e4c05ab5f0 100644 --- a/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp +++ b/clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp @@ -82,7 +82,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target parallel for simd depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); - #pragma omp target parallel for simd depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target parallel for simd depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target parallel for simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_simd_depend_messages.cpp b/clang/test/OpenMP/target_simd_depend_messages.cpp index 6dbdd8013718..a4f6e535194a 100644 --- a/clang/test/OpenMP/target_simd_depend_messages.cpp +++ b/clang/test/OpenMP/target_simd_depend_messages.cpp @@ -82,7 +82,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target simd depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); - #pragma omp target simd depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} + #pragma omp target simd depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_teams_depend_messages.cpp b/clang/test/OpenMP/target_teams_depend_messages.cpp index c3772c169bd1..5baf73a9ba5e 100644 --- a/clang/test/OpenMP/target_teams_depend_messages.cpp +++ b/clang/test/OpenMP/target_teams_depend_messages.cpp @@ -74,7 +74,7 @@ int main(int argc, char **argv, char *env[]) { foo(); #pragma omp target teams depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} foo(); -#pragma omp target teams depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} +#pragma omp target teams depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} foo(); #pragma omp target teams depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} foo(); diff --git a/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp index 0c02b2d6b422..fab61b34126e 100644 --- a/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_depend_messages.cpp @@ -78,7 +78,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); -#pragma omp target teams distribute depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} +#pragma omp target teams distribute depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp index acbb0cf68bee..c8adbe53b742 100644 --- a/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp @@ -79,7 +79,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); -#pragma omp target teams distribute parallel for depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} +#pragma omp target teams distribute parallel for depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp index f5c7d67062a3..dc584508e7b5 100644 --- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp @@ -79,7 +79,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for simd depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); -#pragma omp target teams distribute parallel for simd depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} +#pragma omp target teams distribute parallel for simd depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp b/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp index f635d9e4061c..a864e21a6968 100644 --- a/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp @@ -78,7 +78,7 @@ int main(int argc, char **argv, char *env[]) { for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute simd depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} for (i = 0; i < argc; ++i) foo(); -#pragma omp target teams distribute simd depend (in : argv[3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} +#pragma omp target teams distribute simd depend(in : argv [3:4:1]) // expected-error {{expected ']'}} expected-note {{to match this '['}} for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute simd depend(in:a[0:1]) // expected-error {{subscripted value is not an array or pointer}} for (i = 0; i < argc; ++i) foo(); diff --git a/clang/test/OpenMP/target_update_ast_print.cpp b/clang/test/OpenMP/target_update_ast_print.cpp index fb6440b87cea..0111432fde8f 100644 --- a/clang/test/OpenMP/target_update_ast_print.cpp +++ b/clang/test/OpenMP/target_update_ast_print.cpp @@ -20,6 +20,11 @@ T foo(T targ, U uarg) { #pragma omp target update to(([a][targ])p, a) if(l>5) device(l) nowait depend(inout:l) #pragma omp target update from(b, ([a][targ])p) if(l<5) device(l-1) nowait depend(inout:l) + + int arr[100][100]; +#pragma omp target update to(arr[2][0:1:2]) + +#pragma omp target update from(arr[2][0:1:2]) return a + targ + (T)b; } // CHECK: static T a, *p; @@ -37,6 +42,9 @@ T foo(T targ, U uarg) { // CHECK-NEXT: int l; // CHECK-NEXT: #pragma omp target update to(([a][targ])p,a) if(l > 5) device(l) nowait depend(inout : l) // CHECK-NEXT: #pragma omp target update from(b,([a][targ])p) if(l < 5) device(l - 1) nowait depend(inout : l) +// CHECK: int arr[100][100]; +// CHECK-NEXT: #pragma omp target update to(arr[2][0:1:2]) +// CHECK-NEXT: #pragma omp target update from(arr[2][0:1:2]) int main(int argc, char **argv) { static int a; @@ -50,6 +58,11 @@ int main(int argc, char **argv) { // CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n) nowait depend(in : n) #pragma omp target update from(f) if(f<0.0) device(n+1) nowait depend(in:n) // CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1) nowait depend(in : n) +#pragma omp target update to(argv[2][0:1:2]) +// CHECK-NEXT: #pragma omp target update to(argv[2][0:1:2]) +#pragma omp target update from(argv[2][0:1:2]) +// CHECK-NEXT: #pragma omp target update from(argv[2][0:1:2]) + return foo(argc, f) + foo(argv[0][0], f) + a; } diff --git a/clang/test/OpenMP/target_update_messages.cpp b/clang/test/OpenMP/target_update_messages.cpp index 581fdd8e0a9b..4092b623bdc9 100644 --- a/clang/test/OpenMP/target_update_messages.cpp +++ b/clang/test/OpenMP/target_update_messages.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized +// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized +// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized -// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized +// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized +// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -o - -std=c++11 %s -Wuninitialized void xxx(int argc) { int x; // expected-note {{initialize the variable 'x' to silence this warning}} @@ -36,5 +38,11 @@ int main(int argc, char **argv) { { foo(); } + + int iarr[5][5]; +#pragma omp target update to(iarr[0:][1:2:-1]) // omp50-error {{section stride is evaluated to a non-positive value -1}} omp45-error {{expected ']'}} omp45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} + {} +#pragma omp target update from(iarr[0:][1:2:-1]) // omp50-error {{section stride is evaluated to a non-positive value -1}} omp45-error {{expected ']'}} omp45-note {{to match this '['}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}} + return tmain(argc, argv); } From cfe-commits at lists.llvm.org Thu Jul 9 11:34:54 2020 From: cfe-commits at lists.llvm.org (Chi Chun Chen via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:34:54 +0000 (UTC) Subject: [PATCH] D82800: [OPENMP50] extend array section for stride (Parsing/Sema/AST) In-Reply-To: References: Message-ID: <6d1ec1619f5bf7ed1013012198519fbb@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG2da9572a9b10: [OPENMP50] extend array section for stride (Parsing/Sema/AST) (authored by cchen). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82800/new/ https://reviews.llvm.org/D82800 Files: clang/include/clang-c/Index.h clang/include/clang/AST/ExprOpenMP.h clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/StmtPrinter.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Parse/ParseExpr.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/test/OpenMP/target_data_messages.c clang/test/OpenMP/target_depend_messages.cpp clang/test/OpenMP/target_enter_data_depend_messages.cpp clang/test/OpenMP/target_exit_data_depend_messages.cpp clang/test/OpenMP/target_map_messages.cpp clang/test/OpenMP/target_parallel_depend_messages.cpp clang/test/OpenMP/target_parallel_for_depend_messages.cpp clang/test/OpenMP/target_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_simd_depend_messages.cpp clang/test/OpenMP/target_teams_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp clang/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp clang/test/OpenMP/target_update_ast_print.cpp clang/test/OpenMP/target_update_messages.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82800.276788.patch Type: text/x-patch Size: 43037 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 11:42:45 2020 From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:42:45 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <6cded06ee50af2a216d3531ad192f735@localhost.localdomain> nikic accepted this revision. nikic added a comment. LG from my side. New compile-time numbers: https://llvm-compile-time-tracker.com/compare.php?from=0b39d2d75275b80994dac06b7ad05031cbd09393&to=fd070b79e063fff2fad3cd4a467f64dfca83eb90&stat=instructions It's nearly neutral now. ================ Comment at: llvm/test/CodeGen/AMDGPU/opt-pipeline.ll:285 +; GCN-O1-NEXT: Branch Probability Analysis +; GCN-O1-NEXT: Block Frequency Analysis ; GCN-O1-NEXT: FunctionPass Manager ---------------- This test is out of date. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Thu Jul 9 11:46:11 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:46:11 +0000 (UTC) Subject: [PATCH] D82767: clang-format: Explicitly use python3 In-Reply-To: References: Message-ID: <93a1ed257b338fb86e0b40d78d8619ab@localhost.localdomain> arsenm added a comment. In D82767#2141962 , @serge-sans-paille wrote: > In D82767#2132903 , @MyDeveloperDay wrote: > > > We may not be consistent across all of LLVM > > > > $ find . -name '*.py' -print -exec /usr/bin/head -2 {} \; | grep "#!" | sort | uniq -c > > 6 #! /usr/bin/env python > > 2 #! /usr/bin/env python3 > > 2 #! /usr/bin/python > > 1 #!/bin/env python > > 133 #!/usr/bin/env python > > 13 #!/usr/bin/env python3 > > 49 #!/usr/bin/python > > > > > My understanding is that explicitly requiring python3 may make sense if the script is not backward-compatible with python2, while requiring python means the version is not important. > At the end-of-year, we should be able to harmonize shebangs to #!/usr/bin/env python3 or #!/usr/bin/env python Fixing this to be consistent would be an improvement CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82767/new/ https://reviews.llvm.org/D82767 From cfe-commits at lists.llvm.org Thu Jul 9 11:55:13 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 18:55:13 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. Message-ID: amyk created this revision. amyk added reviewers: PowerPC, power-llvm-team, nemanjai, lei. amyk added projects: LLVM, PowerPC, clang. Herald added a subscriber: shchenz. This patch implements custom codegen for the `vec_replace_elt` and `vec_replace_unaligned` builtins. These builtins map to the `@llvm.ppc.altivec.vinsw` and `@llvm.ppc.altivec.vinsd` intrinsics depending on the arguments. The main motivation for doing custom codegen for these intrinsics is because there are float and double versions of the builtin. Normally, the converting the float to an integer would be done via `fptoui` in the IR, however it is more preferable to use `bitcast`. The original patch that implemented the front end done this adding unions to altivec.h (https://reviews.llvm.org/D82359) but this patch uses custom codegen to use `bitcast` instead for the float conversion instead. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83500 Files: clang/include/clang/Basic/BuiltinsPPC.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83500.276794.patch Type: text/x-patch Size: 12113 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 12:01:28 2020 From: cfe-commits at lists.llvm.org (Volodymyr Sapsai via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:01:28 +0000 (UTC) Subject: [PATCH] D80263: [HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled. In-Reply-To: References: Message-ID: <31a1d3f4dbf2ab2373f71a3ca49352d8@localhost.localdomain> vsapsai added a comment. Ping. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80263/new/ https://reviews.llvm.org/D80263 From cfe-commits at lists.llvm.org Thu Jul 9 12:01:45 2020 From: cfe-commits at lists.llvm.org (Alexey Lapshin via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:01:45 +0000 (UTC) Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls. In-Reply-To: References: Message-ID: <716538b21f33b96041c9ebc6af0dcbce@localhost.localdomain> avl updated this revision to Diff 276799. avl added a comment. addressed comments: added test for multiple recursive calls, removed duplicated check for operand bundles, simplified and commented tests. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82085/new/ https://reviews.llvm.org/D82085 Files: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp llvm/test/Transforms/TailCallElim/basic.ll llvm/test/Transforms/TailCallElim/tre-multiple-exits.ll llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82085.276799.patch Type: text/x-patch Size: 19838 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 12:02:00 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:02:00 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes Message-ID: dgoldman created this revision. dgoldman added a reviewer: sammccall. Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. Previously clangd would jump to forward declarations for protocols and classes instead of their definition/implementation. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/XRefs.cpp clang-tools-extra/clangd/unittests/XRefsTests.cpp Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -674,7 +674,37 @@ enum class E { [[A]], B }; E e = E::A^; }; - )cpp"}; + )cpp", + + R"objc(//objc + @protocol $decl[[Dog]]; + @protocol $def[[Dog]] + - (void)bark; + @end + id getDoggo() { + return 0; + } + )objc", + + R"objc(//objc + @class $decl[[Foo]]; + @interface $def[[Foo]] + @end + Fo^o * getFoo() { + return 0; + } + )objc", + + R"objc(//objc + @class $decl[[Foo]]; + @interface Foo + @end + @implementation $def[[Foo]] + @end + Fo^o * getFoo() { + return 0; + } + )objc"}; for (const char *Test : Tests) { Annotations T(Test); llvm::Optional WantDecl; @@ -689,6 +719,11 @@ TestTU TU; TU.Code = std::string(T.code()); + std::string ObjcPrefix = "//objc"; + if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) { + TU.Filename = "TestTU.m"; + } + // FIXME: Auto-completion in a template requires disabling delayed template // parsing. TU.ExtraArgs.push_back("-fno-delayed-template-parsing"); Index: clang-tools-extra/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/clangd/XRefs.cpp +++ clang-tools-extra/clangd/XRefs.cpp @@ -78,6 +78,18 @@ return VD->getDefinition(); if (const auto *FD = dyn_cast(D)) return FD->getDefinition(); + if (const auto *PD = dyn_cast(D)) + return PD->getDefinition(); + // Objective-C classes can have three types of declarations: + // + // - forward declaration: @class MyClass; + // - definition declaration: @interface MyClass ... @end + // - implementation: @implementation MyClass ... @end + if (const auto *ID = dyn_cast(D)) { + if (const auto *IMD = ID->getImplementation()) + return IMD; + return ID->getDefinition(); + } // Only a single declaration is allowed. if (isa(D) || isa(D) || isa(D)) // except cases above -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.276800.patch Type: text/x-patch Size: 2415 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 12:03:43 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:03:43 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. In-Reply-To: References: Message-ID: <6f957a841d62bec4f7de16acb22b0b70@localhost.localdomain> amyk marked 2 inline comments as done. amyk added inline comments. ================ Comment at: clang/include/clang/Basic/BuiltinsPPC.def:339 +BUILTIN(__builtin_altivec_vec_replace_elt, "V4UiV4UiULLiIi", "t") +BUILTIN(__builtin_altivec_vec_replace_unaligned, "V4UiV4UiULLiIi", "t") ---------------- I originally intended to implement this like the `xxpermdi` builtin: ``` BUILTIN(__builtin_vsx_xxpermdi, "v.", "t") ``` to use `v.` but I am not able to declare these builtins as void. For now, they're more or less an arbitrary signature that would match `vinsw`. ================ Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:606 +vector float test_vec_replace_elt_f(void) { + // CHECK-BE: bitcast float %{{.+}} to i32 + // CHECK-BE-NEXT: @llvm.ppc.altivec.vinsw(<4 x i32> %{{.+}}, i32 %{{.+}}, i32 8 ---------------- I've utilized tests that were from Biplob's original patch (https://reviews.llvm.org/D82359), but added the `bitcasts` to the float/double cases. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83500/new/ https://reviews.llvm.org/D83500 From cfe-commits at lists.llvm.org Thu Jul 9 12:04:06 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:04:06 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: <2dc9fd5e43af6e81fa726a462025f024@localhost.localdomain> dgoldman added inline comments. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92 + if (const auto *ID = dyn_cast(D)) { + if (const auto *IMD = ID->getImplementation()) + return IMD; + return ID->getDefinition(); + } ---------------- Let me know if there's a better way to handle this multi-"definition" support ================ Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:722 + std::string ObjcPrefix = "//objc"; + if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) { ---------------- Figured this would be easier than copy + paste, LMK Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Thu Jul 9 12:05:29 2020 From: cfe-commits at lists.llvm.org (Baptiste Saleil via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:05:29 +0000 (UTC) Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend In-Reply-To: References: Message-ID: <68b538ab32311d9362ed0d3f0a2b48f3@localhost.localdomain> bsaleil added inline comments. ================ Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:939 + // The XFormMemOp flag for the following 8 insts is set on the instruction format. + let mayLoad = 1, mayStore = 1 in { + def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>; ---------------- Shouldn't `mayStore` be 0 instead of 1 here ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83364/new/ https://reviews.llvm.org/D83364 From cfe-commits at lists.llvm.org Thu Jul 9 12:11:17 2020 From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:11:17 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: hans accepted this revision. hans added a comment. In D83013#2142271 , @nikic wrote: > New compile-time numbers: https://llvm-compile-time-tracker.com/compare.php?from=0b39d2d75275b80994dac06b7ad05031cbd09393&to=fd070b79e063fff2fad3cd4a467f64dfca83eb90&stat=instructions It's nearly neutral now. Sounds great! lgtm2 (with the test update Nikita mentioned) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Thu Jul 9 12:11:27 2020 From: cfe-commits at lists.llvm.org (Jan Korous via cfe-commits) Date: Thu, 09 Jul 2020 12:11:27 -0700 (PDT) Subject: [clang] e81f9cd - [AST][test] Add regression test forPointerExprEvaluator::VisitCXXNewExpr Message-ID: <5f076bdf.1c69fb81.ca6ef.8990@mx.google.com> Author: Jan Korous Date: 2020-07-09T12:11:08-07:00 New Revision: e81f9cd2137f258fd1ec6a169db836387bcca84a URL: https://github.com/llvm/llvm-project/commit/e81f9cd2137f258fd1ec6a169db836387bcca84a DIFF: https://github.com/llvm/llvm-project/commit/e81f9cd2137f258fd1ec6a169db836387bcca84a.diff LOG: [AST][test] Add regression test forPointerExprEvaluator::VisitCXXNewExpr This assert was failing: assert(CAT && "unexpected type for array initializer"); until this patch landed: 9a7eda1bece887ca9af085d79fe6e4fb8826dcda PR45350: Handle unsized array CXXConstructExprs in constant evaluation Added: clang/test/AST/regression-new-expr-crash.cpp Modified: Removed: ################################################################################ diff --git a/clang/test/AST/regression-new-expr-crash.cpp b/clang/test/AST/regression-new-expr-crash.cpp new file mode 100644 index 000000000000..81dd193b93e8 --- /dev/null +++ b/clang/test/AST/regression-new-expr-crash.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only %s + +struct Bar {int a;}; +const Bar arr[2] = {{1}}; + +struct Foo {}; + +const int b = 2; + +void foo(int a) { + Foo *foo_array; + foo_array = new Foo[arr[0].a]; +} From cfe-commits at lists.llvm.org Thu Jul 9 12:11:48 2020 From: cfe-commits at lists.llvm.org (Leonard Chan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:11:48 +0000 (UTC) Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations. In-Reply-To: References: Message-ID: leonardchan added a comment. > It wouldn't just be restricted to fixed-point intrinsics, though. It would have to be added to intrinsics like uadd.sat and usub.sat as well, which aren't really tied to fixed-point at all. Oh wait, sorry. I think I'm starting to understand now. You're saying that if you're using the padding bit in the first place, ISel shouldn't need to perform the underlying shift during integral promotions, but we do it anyway still. Yeah it seems a lot of this could be addressed simply by just using the corresponding signed intrinsics. I guess I'd be ok with purely making this a clang change for now, but if other frontends see interest in the unsigned padding bit then we could migrate this to LLVM down the line. ================ Comment at: clang/lib/Basic/FixedPoint.cpp:143-158 + // For codegen purposes, make unsigned with padding semantics signed instead. + // This means that we will generate signed operations. The result from these + // operations is defined, since ending up with a negative result is undefined + // for nonsaturating semantics, and for saturating semantics we will + // perform a clamp-to-zero in the last conversion to result semantics (since + // we are going from saturating signed to saturating unsigned). + // ---------------- ebevhan wrote: > leonardchan wrote: > > If this is exclusively for codegen purposes with binary operations, would it be clearer to move this to `EmitFixedPointBinOp`? If `UnsignedPaddingIsSigned` doesn't need to be used for stuff like constant evaluation, it might be clearer not to provide it for everyone. > FixedPointSemantics is immutable except for saturation, unfortunately. I'd end up having to reconstruct the semantics object from scratch immediately after calling getCommonSemantics. Fair. Minor nit: Could you rename the parameter to `UnsignedPaddingIsSignedForCG`? Just want to make it clearer that this should specifically be used for codegen only. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82663/new/ https://reviews.llvm.org/D82663 From cfe-commits at lists.llvm.org Thu Jul 9 12:14:17 2020 From: cfe-commits at lists.llvm.org (Baptiste Saleil via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:14:17 +0000 (UTC) Subject: [PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins In-Reply-To: References: Message-ID: bsaleil added a comment. Shouldn't we have test cases to test `vec_sl`, `vec_sr` and `vec_sra` ? ================ Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:800 def int_ppc_altivec_vsrw : PowerPC_Vec_WWW_Intrinsic<"vsrw">; +def int_ppc_altivec_vsrq : PowerPC_Vec_QQQ_Intrinsic<"vsrq">; def int_ppc_altivec_vsrab : PowerPC_Vec_BBB_Intrinsic<"vsrab">; ---------------- nit: indentation issue ================ Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:919 + + def VSLQ : VX1_Int_Ty< 261, "vslq", int_ppc_altivec_vslq, v1i128>; + def VSRAQ : VX1_Int_Ty< 773, "vsraq", int_ppc_altivec_vsraq, v1i128>; ---------------- nit: extra spaces before `:` here and in the next two lines Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83338/new/ https://reviews.llvm.org/D83338 From cfe-commits at lists.llvm.org Thu Jul 9 12:15:37 2020 From: cfe-commits at lists.llvm.org (David Tenty via cfe-commits) Date: Thu, 09 Jul 2020 12:15:37 -0700 (PDT) Subject: [clang] 25ec96d - [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting Message-ID: <5f076cd9.1c69fb81.1108.8693@mx.google.com> Author: David Tenty Date: 2020-07-09T15:15:30-04:00 New Revision: 25ec96d91a3a5326a403496fa5532ff0bdb6a15b URL: https://github.com/llvm/llvm-project/commit/25ec96d91a3a5326a403496fa5532ff0bdb6a15b DIFF: https://github.com/llvm/llvm-project/commit/25ec96d91a3a5326a403496fa5532ff0bdb6a15b.diff LOG: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting Summary: AIX uses an environment variable called OBJECT_MODE to indicate to utilities in the toolchain whether they should be operating in 32-bit or 64-bit mode. This patch makes the clang driver recognize the current OBJECT_MODE setting when we are operating with an AIX target and adds a custom diagnostic for invalid settings. For more details about OBJECT_MODE on AIX see: https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.3/com.ibm.xlc1313.aix.doc/compiler_ref/tusetenv1.html https://www.ibm.com/support/knowledgecenter/SSGH2K_13.1.3/com.ibm.xlc1313.aix.doc/compiler_ref/opt_3264.html Reviewers: stevewan, hubert.reinterpretcast, ShuhongL, jasonliu Reviewed By: hubert.reinterpretcast, jasonliu Subscribers: jasonliu, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82476 Added: clang/test/Driver/aix-object-mode.c Modified: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/lib/Driver/Driver.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index dcb3b96cd057..baf01d853233 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -509,4 +509,6 @@ def warn_drv_libstdcxx_not_found : Warning< InGroup>; def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">; + +def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">; } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 596e694760d0..ece8222dcf24 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -475,6 +475,26 @@ static llvm::Triple computeTargetTriple(const Driver &D, Target.getOS() == llvm::Triple::Minix) return Target; + // On AIX, the env OBJECT_MODE may affect the resulting arch variant. + if (Target.isOSAIX()) { + if (Optional ObjectModeValue = + llvm::sys::Process::GetEnv("OBJECT_MODE")) { + StringRef ObjectMode = *ObjectModeValue; + llvm::Triple::ArchType AT = llvm::Triple::UnknownArch; + + if (ObjectMode.equals("64")) { + AT = Target.get64BitArchVariant().getArch(); + } else if (ObjectMode.equals("32")) { + AT = Target.get32BitArchVariant().getArch(); + } else { + D.Diag(diag::err_drv_invalid_object_mode) << ObjectMode; + } + + if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) + Target.setArch(AT); + } + } + // Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'. Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32, options::OPT_m32, options::OPT_m16); diff --git a/clang/test/Driver/aix-object-mode.c b/clang/test/Driver/aix-object-mode.c new file mode 100644 index 000000000000..a4bc79a4b41d --- /dev/null +++ b/clang/test/Driver/aix-object-mode.c @@ -0,0 +1,22 @@ +// Check that setting an OBJECT_MODE converts the AIX triple to the right variant. +// RUN: env OBJECT_MODE=64 \ +// RUN: %clang -target powerpc-ibm-aix -print-target-triple | FileCheck -check-prefix=CHECK64 %s + +// RUN: env OBJECT_MODE=32 \ +// RUN: %clang -target powerpc64-ibm-aix -print-target-triple | FileCheck -check-prefix=CHECK32 %s + +// Command-line options win. +// RUN: env OBJECT_MODE=64 \ +// RUN: %clang -target powerpc64-ibm-aix -print-target-triple -m32 | FileCheck -check-prefix=CHECK32 %s + +// RUN: env OBJECT_MODE=32 \ +// RUN: %clang -target powerpc-ibm-aix -print-target-triple -m64 | FileCheck -check-prefix=CHECK64 %s + +// CHECK32: powerpc-ibm-aix +// CHECK64: powerpc64-ibm-aix + +// Emit a diagnostic if there is an invalid mode. +// RUN: env OBJECT_MODE=31 \ +// RUN: not %clang -target powerpc-ibm-aix 2>&1 | FileCheck -check-prefix=DIAG %s + +// DIAG: error: OBJECT_MODE setting 31 is not recognized and is not a valid setting. From cfe-commits at lists.llvm.org Thu Jul 9 12:15:39 2020 From: cfe-commits at lists.llvm.org (David Tenty via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:15:39 +0000 (UTC) Subject: [PATCH] D82476: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting In-Reply-To: References: Message-ID: <1b59dfa1c3cc5d17bae9da8f71f3fc55@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG25ec96d91a3a: [Clang][Driver] Recognize the AIX OBJECT_MODE environment setting (authored by daltenty). Changed prior to commit: https://reviews.llvm.org/D82476?vs=273071&id=276803#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82476/new/ https://reviews.llvm.org/D82476 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/lib/Driver/Driver.cpp clang/test/Driver/aix-object-mode.c Index: clang/test/Driver/aix-object-mode.c =================================================================== --- /dev/null +++ clang/test/Driver/aix-object-mode.c @@ -0,0 +1,22 @@ +// Check that setting an OBJECT_MODE converts the AIX triple to the right variant. +// RUN: env OBJECT_MODE=64 \ +// RUN: %clang -target powerpc-ibm-aix -print-target-triple | FileCheck -check-prefix=CHECK64 %s + +// RUN: env OBJECT_MODE=32 \ +// RUN: %clang -target powerpc64-ibm-aix -print-target-triple | FileCheck -check-prefix=CHECK32 %s + +// Command-line options win. +// RUN: env OBJECT_MODE=64 \ +// RUN: %clang -target powerpc64-ibm-aix -print-target-triple -m32 | FileCheck -check-prefix=CHECK32 %s + +// RUN: env OBJECT_MODE=32 \ +// RUN: %clang -target powerpc-ibm-aix -print-target-triple -m64 | FileCheck -check-prefix=CHECK64 %s + +// CHECK32: powerpc-ibm-aix +// CHECK64: powerpc64-ibm-aix + +// Emit a diagnostic if there is an invalid mode. +// RUN: env OBJECT_MODE=31 \ +// RUN: not %clang -target powerpc-ibm-aix 2>&1 | FileCheck -check-prefix=DIAG %s + +// DIAG: error: OBJECT_MODE setting 31 is not recognized and is not a valid setting. Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -475,6 +475,26 @@ Target.getOS() == llvm::Triple::Minix) return Target; + // On AIX, the env OBJECT_MODE may affect the resulting arch variant. + if (Target.isOSAIX()) { + if (Optional ObjectModeValue = + llvm::sys::Process::GetEnv("OBJECT_MODE")) { + StringRef ObjectMode = *ObjectModeValue; + llvm::Triple::ArchType AT = llvm::Triple::UnknownArch; + + if (ObjectMode.equals("64")) { + AT = Target.get64BitArchVariant().getArch(); + } else if (ObjectMode.equals("32")) { + AT = Target.get32BitArchVariant().getArch(); + } else { + D.Diag(diag::err_drv_invalid_object_mode) << ObjectMode; + } + + if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) + Target.setArch(AT); + } + } + // Handle pseudo-target flags '-m64', '-mx32', '-m32' and '-m16'. Arg *A = Args.getLastArg(options::OPT_m64, options::OPT_mx32, options::OPT_m32, options::OPT_m16); Index: clang/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -509,4 +509,6 @@ InGroup>; def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">; + +def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">; } -------------- next part -------------- A non-text attachment was scrubbed... Name: D82476.276803.patch Type: text/x-patch Size: 2818 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 12:19:09 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:19:09 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. In-Reply-To: References: Message-ID: <812091e7dfb97a8eb59764190bd37543@localhost.localdomain> amyk updated this revision to Diff 276804. amyk added a comment. Updated for clang format changes. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83500/new/ https://reviews.llvm.org/D83500 Files: clang/include/clang/Basic/BuiltinsPPC.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83500.276804.patch Type: text/x-patch Size: 12237 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 12:25:22 2020 From: cfe-commits at lists.llvm.org (Leonard Chan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:25:22 +0000 (UTC) Subject: [PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts. In-Reply-To: References: Message-ID: leonardchan added inline comments. ================ Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3857 + + // TODO: This misses out on the sanitizer check below. + if (Ops.isFixedPointOp()) ---------------- I don't suppose you could file a bug for this and CC me on it so we can remember to do this sometime after this lands? ================ Comment at: clang/test/Frontend/fixed_point_compound.c:384 + // CHECK-NEXT: [[TMP4:%.*]] = load i16, i16* @suf, align 2 + // CHECK-NEXT: [[TMP5:%.*]] = trunc i32 [[TMP3]] to i16 + // SIGNED-NEXT: [[TMP6:%.*]] = call i16 @llvm.ushl.sat.i16(i16 [[TMP4]], i16 [[TMP5]]) ---------------- ebevhan wrote: > leonardchan wrote: > > This seems very unlikely, but if `i` in this case was a value at least 2^16, the upper half would be cut off and we'd potentially shift by an improper amount for some values of `i` when we should actually clamp to the max value. We should probably still find the common semantics for both sides if we're doing a shift. > If the value is so large to be cut off by that truncation then the value is greater than the bitwidth, which is UB. So I don't think it's an issue. Ah right I forgot that. ================ Comment at: clang/test/Frontend/fixed_point_compound.c:388-390 + // UNSIGNED-NEXT: [[TMP7:%.*]] = icmp slt i16 [[TMP6]], 0 + // UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP7]], i16 0, i16 [[TMP6]] + // UNSIGNED-NEXT: store i16 [[SATMIN]], i16* @suf, align 2 ---------------- I'm assuming these checks are also a result of D82663? I don't think for the padding case, we should need to do the compare and select if we're already using the signed sat intrinsic. But I'm guessing it might make the implementation more complicated by having to check for this. If this codegen comes from the `EmitFixedPointConversion` at the end of `EmitFixedPointBinOp`, perhaps it might be worthwhile adding a parameter in `EmitFixedPointConversion` to indicate that we shouldn't emit this. I think there's some cases in D82663 also where we might not need to do these checks afterwards with other operations like with: ``` // UNSIGNED-NEXT: [[TMP25:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP22]], i16 32767) // UNSIGNED-NEXT: [[TMP26:%.*]] = icmp slt i16 [[TMP25]], 0 // UNSIGNED-NEXT: [[SATMIN2:%.*]] = select i1 [[TMP26]], i16 0, i16 [[TMP25]] // UNSIGNED-NEXT: store i16 [[SATMIN2]], i16* @suf, align 2 ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83294/new/ https://reviews.llvm.org/D83294 From cfe-commits at lists.llvm.org Thu Jul 9 12:31:48 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:31:48 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman added inline comments. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:276 getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) { // Special case: void foo() ^override: jump to the overridden method. if (const auto *CMD = llvm::dyn_cast(D)) { ---------------- Think it would make sense to special case ObjCInterfaceDecl here to get at both the interface definition + implementation if available? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Thu Jul 9 12:40:27 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:40:27 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: zequanwu updated this revision to Diff 276808. zequanwu added a comment. Update test case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 Files: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/new-pm-cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83013.276808.patch Type: text/x-patch Size: 17602 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 12:40:35 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:40:35 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. In-Reply-To: References: Message-ID: <58cd335bdccb4fceb4ce9beaf5fe9591@localhost.localdomain> lei added inline comments. ================ Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14273 + // The third argument to vec_replace_elt will be emitted to either + // the vinsw or vinsd instruction. It must be a compile time constant. + ConstantInt *ArgCI = dyn_cast(Ops[2]); ---------------- Do you mean? ``` // The third argument of vec_replace_elt must be a compile time constant and will be emitted either // to the vinsw or vinsd instruction. ``` ================ Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14289 + else + ConstArg = (ConstArg * 4); + Ops[2] = ConstantInt::getSigned(Int32Ty, ConstArg); ---------------- ``` ConstArg *= 4; // Fix the constant according to endianess. if (getTarget().isLittleEndian()) ConstArg = 12 - ConstArg; ``` ================ Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14320 + Call = Builder.CreateCall(F, Ops); + } + return Call; ---------------- What are the chances of reaching to the end of this if/else-if section and `Call` is null? ie `getPrimitiveSizeInBits() != [32|64]` I feel like it would be better if we can structure it so that we are not doing all these nesting of `if`s and just do returns within the diff if-conditions. Have you tried to pull out the diff handling of 32/64bit arg and consolidating the code a bit? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83500/new/ https://reviews.llvm.org/D83500 From cfe-commits at lists.llvm.org Thu Jul 9 12:53:32 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:53:32 +0000 (UTC) Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations. In-Reply-To: References: Message-ID: <3b9c6fa878abc46c212a06afd9ca5d72@localhost.localdomain> rjmccall added a comment. Would it be sensible to use a technical design more like what the matrix folks are doing, where LLVM provides a small interface for emitting operations with various semantics? FixedPointSemantics would move to that header, and Clang would just call into it. That way you get a lot more flexibility in how you generate code, and the Clang IRGen logic is still transparently correct. If you want to add intrinsics or otherwise change the IR patterns used for various operations, you don't have to rewrite a bunch of Clang IRGen logic every time, you just have to update the tests. It'd then be pretty straightforward to have internal helper functions in that interface for computing things like whether you should use signed or unsigned intrinsics given the desired FixedPointSemantics. My interest here is mainly in (1) keeping IRGen's logic as obviously correct as possible, (2) not hard-coding a bunch of things that really feel like workarounds for backend limitations, and (3) not complicating core abstractions like FixedPointSemantics with unnecessary extra rules for appropriate use, like having to pass an extra "for codegen" flag to get optimal codegen. If IRGen can just pass down the high-level semantics it wants to some library that will make intelligent decisions about how to emit IR, that seems best. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82663/new/ https://reviews.llvm.org/D82663 From cfe-commits at lists.llvm.org Thu Jul 9 12:54:55 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:54:55 +0000 (UTC) Subject: [PATCH] D79730: [NFCi] Switch ordering of ParseLangArgs and ParseCodeGenArgs. In-Reply-To: References: Message-ID: rjmccall added a comment. Either way, I think. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79730/new/ https://reviews.llvm.org/D79730 From cfe-commits at lists.llvm.org Thu Jul 9 12:55:26 2020 From: cfe-commits at lists.llvm.org (Jonas Devlieghere via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 19:55:26 +0000 (UTC) Subject: [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional. In-Reply-To: References: Message-ID: <644d8fdfe5810b64480ddba8c61788d8@localhost.localdomain> JDevlieghere added a comment. LGTM. I verified this works for the build-tree standalone build of LLDB, but please still keep an eye on http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-standalone/ after you land this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83454/new/ https://reviews.llvm.org/D83454 From cfe-commits at lists.llvm.org Thu Jul 9 13:00:18 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:00:18 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents Message-ID: aaron.ballman created this revision. aaron.ballman added reviewers: rsmith, echristo, dblaikie, rjmccall. Currently, Clang diagnoses this code by default: `void f(int a[static 0]);` saying that "static has no effect on zero-length arrays" and this diagnostic is accurate for our implementation. However, static array extents require that the caller of the function pass a nonnull pointer to an array of *at least* that number of elements, but it can pass more (see C17 6.7.6.3p6). Given that we allow zero-sized arrays as a GNU extension and that it's valid to pass more elements than specified by the static array extent, I think we should support zero-sized static array extents with the usual semantics because it can be useful, as pointed out to me on Twitter (https://twitter.com/rep_stosq_void/status/1280892279998291973): void my_bzero(char p[static 0], int n); my_bzero(&c+1, 0); //ok my_bzero(t+k,n-k); //ok, pattern from actual code https://reviews.llvm.org/D83502 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/CodeGen/CGCall.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/vla.c clang/test/Sema/static-array.c Index: clang/test/Sema/static-array.c =================================================================== --- clang/test/Sema/static-array.c +++ clang/test/Sema/static-array.c @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -pedantic -verify %s -void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}} +void cat0(int a[static 0]) {} // expected-warning {{zero size arrays are an extension}} \ + // expected-note {{callee declares array parameter as static here}} void cat(int a[static 3]) {} // expected-note 4 {{callee declares array parameter as static here}} expected-note 2 {{passing argument to parameter 'a' here}} @@ -9,7 +10,7 @@ void f(int *p) { int a[2], b[3], c[4]; - cat0(0); + cat0(0); // expected-warning {{null passed to a callee that requires a non-null argument}} cat(0); // expected-warning {{null passed to a callee that requires a non-null argument}} cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}} Index: clang/test/CodeGen/vla.c =================================================================== --- clang/test/CodeGen/vla.c +++ clang/test/CodeGen/vla.c @@ -206,3 +206,6 @@ // NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a) // NULL-VALID: define void @test9(i32 %n, i32* %a) +// Make sure a zero-sized static array extent is still required to be nonnull. +void test10(int a[static 0]) {} +// CHECK: define void @test10(i32* nonnull %a) Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -2393,13 +2393,6 @@ ? diag::err_typecheck_zero_array_size : diag::ext_typecheck_zero_array_size) << ArraySize->getSourceRange(); - - if (ASM == ArrayType::Static) { - Diag(ArraySize->getBeginLoc(), - diag::warn_typecheck_zero_static_array_size) - << ArraySize->getSourceRange(); - ASM = ArrayType::Normal; - } } else if (!T->isDependentType() && !T->isVariablyModifiedType() && !T->isIncompleteType() && !T->isUndeducedType()) { // Is the array too large? Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -2500,12 +2500,20 @@ if (ArrTy->getSizeModifier() == ArrayType::Static) { QualType ETy = ArrTy->getElementType(); uint64_t ArrSize = ArrTy->getSize().getZExtValue(); - if (!ETy->isIncompleteType() && ETy->isConstantSizeType() && - ArrSize) { - llvm::AttrBuilder Attrs; - Attrs.addDereferenceableAttr( - getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize); - AI->addAttrs(Attrs); + if (!ETy->isIncompleteType() && ETy->isConstantSizeType()) { + // If the type is complete and we know the array size is non- + // zero, then we know the dereferencable range of memory. + // Otherwise, if the array size is zero, we only know that the + // memory must be nonnull. + if (ArrSize) { + llvm::AttrBuilder Attrs; + Attrs.addDereferenceableAttr( + getContext().getTypeSizeInChars(ETy).getQuantity() * + ArrSize); + AI->addAttrs(Attrs); + } else { + AI->addAttr(llvm::Attribute::NonNull); + } } else if (getContext().getTargetAddressSpace(ETy) == 0 && !CGM.getCodeGenOpts().NullPointerIsValid) { AI->addAttr(llvm::Attribute::NonNull); Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5395,9 +5395,6 @@ "zero size arrays are an extension">, InGroup; def err_typecheck_zero_array_size : Error< "zero-length arrays are not permitted in C++">; -def warn_typecheck_zero_static_array_size : Warning< - "'static' has no effect on zero-length arrays">, - InGroup; def err_array_size_non_int : Error<"size of array has non-integer type %0">; def err_init_element_not_constant : Error< "initializer element is not a compile-time constant">; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83502.276809.patch Type: text/x-patch Size: 4812 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 13:03:32 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:03:32 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: zequanwu updated this revision to Diff 276813. zequanwu added a comment. rebase. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 Files: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/new-pm-cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83013.276813.patch Type: text/x-patch Size: 17602 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 13:03:51 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via cfe-commits) Date: Thu, 09 Jul 2020 13:03:51 -0700 (PDT) Subject: [clang] c92a8c0 - [LPM] Port CGProfilePass from NPM to LPM Message-ID: <5f077827.1c69fb81.77d8f.9280@mx.google.com> Author: Zequan Wu Date: 2020-07-09T13:03:42-07:00 New Revision: c92a8c0a0f68fbbb23e3fdde071007e63a552e82 URL: https://github.com/llvm/llvm-project/commit/c92a8c0a0f68fbbb23e3fdde071007e63a552e82 DIFF: https://github.com/llvm/llvm-project/commit/c92a8c0a0f68fbbb23e3fdde071007e63a552e82.diff LOG: [LPM] Port CGProfilePass from NPM to LPM Reviewers: hans, chandlerc!, asbirlea, nikic Reviewed By: hans, nikic Subscribers: steven_wu, dexonsmith, nikic, echristo, void, zhizhouy, cfe-commits, aeubanks, MaskRay, jvesely, nhaehnle, hiraditya, kerbowa, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D83013 Added: Modified: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll Removed: llvm/test/Other/new-pm-cgprofile.ll ################################################################################ diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index d465e00d4c70..f3e43919eeca 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -252,7 +252,6 @@ CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables. CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer. CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer. CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate. -CODEGENOPT(CallGraphProfile , 1, 0) ///< Run call graph profile. /// Attempt to use register sized accesses to bit-fields in structures, when /// possible. diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 9e6d5e4593d3..3ada1aaa4ed8 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -620,6 +620,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize; PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP; PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop; + PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; // Loop interleaving in the loop vectorizer has historically been set to be @@ -1144,7 +1145,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; PTO.LoopVectorization = CodeGenOpts.VectorizeLoop; PTO.SLPVectorization = CodeGenOpts.VectorizeSLP; - PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile; + PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PTO.Coroutines = LangOpts.Coroutines; PassInstrumentationCallbacks PIC; @@ -1562,7 +1563,7 @@ static void runThinLTOBackend( Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops; Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop; Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP; - Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile; + Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS; // Context sensitive profile. if (CGOpts.hasProfileCSIRInstr()) { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 6f6af917e3a3..fd34c6b8a955 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -860,7 +860,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.RerollLoops = Args.hasArg(OPT_freroll_loops); Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as); - Opts.CallGraphProfile = !Opts.DisableIntegratedAS; Opts.Autolink = !Args.hasArg(OPT_fno_autolink); Opts.SampleProfileFile = std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ)); diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index f0d5accf13c5..06e8507036ac 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -103,6 +103,7 @@ void initializeCFGViewerLegacyPassPass(PassRegistry&); void initializeCFIInstrInserterPass(PassRegistry&); void initializeCFLAndersAAWrapperPassPass(PassRegistry&); void initializeCFLSteensAAWrapperPassPass(PassRegistry&); +void initializeCGProfileLegacyPassPass(PassRegistry &); void initializeCallGraphDOTPrinterPass(PassRegistry&); void initializeCallGraphPrinterLegacyPassPass(PassRegistry&); void initializeCallGraphViewerPass(PassRegistry&); diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h index 28e454d3b0fc..d1b9f269d5d4 100644 --- a/llvm/include/llvm/Transforms/IPO.h +++ b/llvm/include/llvm/Transforms/IPO.h @@ -282,6 +282,8 @@ ModulePass *createSampleProfileLoaderPass(StringRef Name); ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str, raw_ostream *ThinLinkOS = nullptr); +ModulePass *createCGProfileLegacyPass(); + } // End llvm namespace #endif diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h index 8b03bcba10e4..a9928c3f5a40 100644 --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -156,6 +156,7 @@ class PassManagerBuilder { bool DisableTailCalls; bool DisableUnrollLoops; + bool CallGraphProfile; bool SLPVectorize; bool LoopVectorize; bool LoopsInterleaved; diff --git a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h index 28fd3804dec9..4cb45fd42f80 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h +++ b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h @@ -19,11 +19,6 @@ namespace llvm { class CGProfilePass : public PassInfoMixin { public: PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); - -private: - void addModuleFlags( - Module &M, - MapVector, uint64_t> &Counts) const; }; } // end namespace llvm diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 58510609cf5e..4d6c30b87a99 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -248,10 +248,6 @@ static cl::opt EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)")); -static cl::opt EnableCallGraphProfile( - "enable-npm-call-graph-profile", cl::init(true), cl::Hidden, - cl::desc("Enable call graph profile pass for the new PM (default = on)")); - /// Flag to enable inline deferral during PGO. static cl::opt EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true), @@ -267,7 +263,7 @@ PipelineTuningOptions::PipelineTuningOptions() { Coroutines = false; LicmMssaOptCap = SetLicmMssaOptCap; LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap; - CallGraphProfile = EnableCallGraphProfile; + CallGraphProfile = true; } extern cl::opt EnableHotColdSplit; diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 9534fb874107..b65eb469a492 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -195,6 +195,7 @@ PassManagerBuilder::PassManagerBuilder() { PrepareForThinLTO = EnablePrepareForThinLTO; PerformThinLTO = EnablePerformThinLTO; DivergentTarget = false; + CallGraphProfile = true; } PassManagerBuilder::~PassManagerBuilder() { @@ -834,6 +835,10 @@ void PassManagerBuilder::populateModulePassManager( if (MergeFunctions) MPM.add(createMergeFunctionsPass()); + // Add Module flag "CG Profile" based on Branch Frequency Information. + if (CallGraphProfile) + MPM.add(createCGProfileLegacyPass()); + // LoopSink pass sinks instructions hoisted by LICM, which serves as a // canonicalization pass that enables other optimizations. As a result, // LoopSink pass needs to be a very late IR pass to avoid undoing LICM diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp index 2d5bd9570940..e95731a2117b 100644 --- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp +++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp @@ -10,22 +10,48 @@ #include "llvm/ADT/MapVector.h" #include "llvm/Analysis/BlockFrequencyInfo.h" +#include "llvm/Analysis/LazyBlockFrequencyInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/PassManager.h" +#include "llvm/InitializePasses.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Instrumentation.h" #include using namespace llvm; -PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { +static bool +addModuleFlags(Module &M, + MapVector, uint64_t> &Counts) { + if (Counts.empty()) + return false; + + LLVMContext &Context = M.getContext(); + MDBuilder MDB(Context); + std::vector Nodes; + + for (auto E : Counts) { + Metadata *Vals[] = {ValueAsMetadata::get(E.first.first), + ValueAsMetadata::get(E.first.second), + MDB.createConstant(ConstantInt::get( + Type::getInt64Ty(Context), E.second))}; + Nodes.push_back(MDNode::get(Context, Vals)); + } + + M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); + return true; +} + +static bool +runCGProfilePass(Module &M, + function_ref GetBFI, + function_ref GetTTI) { MapVector, uint64_t> Counts; - FunctionAnalysisManager &FAM = - MAM.getResult(M).getManager(); InstrProfSymtab Symtab; auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F, Function *CalledF, uint64_t NewCount) { @@ -35,14 +61,14 @@ PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { Count = SaturatingAdd(Count, NewCount); }; // Ignore error here. Indirect calls are ignored if this fails. - (void)(bool)Symtab.create(M); + (void)(bool) Symtab.create(M); for (auto &F : M) { - if (F.isDeclaration()) + if (F.isDeclaration() || !F.getEntryCount()) continue; - auto &BFI = FAM.getResult(F); + auto &BFI = GetBFI(F); if (BFI.getEntryFreq() == 0) continue; - TargetTransformInfo &TTI = FAM.getResult(F); + TargetTransformInfo &TTI = GetTTI(F); for (auto &BB : F) { Optional BBCount = BFI.getBlockProfileCount(&BB); if (!BBCount) @@ -69,28 +95,56 @@ PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { } } - addModuleFlags(M, Counts); - - return PreservedAnalyses::all(); + return addModuleFlags(M, Counts); } -void CGProfilePass::addModuleFlags( - Module &M, - MapVector, uint64_t> &Counts) const { - if (Counts.empty()) - return; +namespace { +struct CGProfileLegacyPass final : public ModulePass { + static char ID; + CGProfileLegacyPass() : ModulePass(ID) { + initializeCGProfileLegacyPassPass(*PassRegistry::getPassRegistry()); + } - LLVMContext &Context = M.getContext(); - MDBuilder MDB(Context); - std::vector Nodes; + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesCFG(); + AU.addRequired(); + AU.addRequired(); + } - for (auto E : Counts) { - Metadata *Vals[] = {ValueAsMetadata::get(E.first.first), - ValueAsMetadata::get(E.first.second), - MDB.createConstant(ConstantInt::get( - Type::getInt64Ty(Context), E.second))}; - Nodes.push_back(MDNode::get(Context, Vals)); + bool runOnModule(Module &M) override { + auto GetBFI = [this](Function &F) -> BlockFrequencyInfo & { + return this->getAnalysis(F).getBFI(); + }; + auto GetTTI = [this](Function &F) -> TargetTransformInfo & { + return this->getAnalysis().getTTI(F); + }; + + return runCGProfilePass(M, GetBFI, GetTTI); } +}; - M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); +} // namespace + +char CGProfileLegacyPass::ID = 0; + +INITIALIZE_PASS(CGProfileLegacyPass, "cg-profile", "Call Graph Profile", false, + false) + +ModulePass *llvm::createCGProfileLegacyPass() { + return new CGProfileLegacyPass(); +} + +PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { + FunctionAnalysisManager &FAM = + MAM.getResult(M).getManager(); + auto GetBFI = [&FAM](Function &F) -> BlockFrequencyInfo & { + return FAM.getResult(F); + }; + auto GetTTI = [&FAM](Function &F) -> TargetTransformInfo & { + return FAM.getResult(F); + }; + + runCGProfilePass(M, GetBFI, GetTTI); + + return PreservedAnalyses::all(); } diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp index 64626225f23f..ad238f1357c6 100644 --- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -112,6 +112,7 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) { initializePGOInstrumentationUseLegacyPassPass(Registry); initializePGOIndirectCallPromotionLegacyPassPass(Registry); initializePGOMemOPSizeOptLegacyPassPass(Registry); + initializeCGProfileLegacyPassPass(Registry); initializeInstrOrderFileLegacyPassPass(Registry); initializeInstrProfilingLegacyPassPass(Registry); initializeMemorySanitizerLegacyPassPass(Registry); diff --git a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll index 32d36f4e7280..85f9d8c867bf 100644 --- a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll +++ b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll @@ -276,6 +276,12 @@ ; GCN-O1-NEXT: Warn about non-applied transformations ; GCN-O1-NEXT: Alignment from assumptions ; GCN-O1-NEXT: Strip Unused Function Prototypes +; GCN-O1-NEXT: Call Graph Profile +; GCN-O1-NEXT: FunctionPass Manager +; GCN-O1-NEXT: Dominator Tree Construction +; GCN-O1-NEXT: Natural Loop Information +; GCN-O1-NEXT: Lazy Branch Probability Analysis +; GCN-O1-NEXT: Lazy Block Frequency Analysis ; GCN-O1-NEXT: FunctionPass Manager ; GCN-O1-NEXT: Dominator Tree Construction ; GCN-O1-NEXT: Natural Loop Information @@ -623,6 +629,12 @@ ; GCN-O2-NEXT: Strip Unused Function Prototypes ; GCN-O2-NEXT: Dead Global Elimination ; GCN-O2-NEXT: Merge Duplicate Global Constants +; GCN-O2-NEXT: Call Graph Profile +; GCN-O2-NEXT: FunctionPass Manager +; GCN-O2-NEXT: Dominator Tree Construction +; GCN-O2-NEXT: Natural Loop Information +; GCN-O2-NEXT: Lazy Branch Probability Analysis +; GCN-O2-NEXT: Lazy Block Frequency Analysis ; GCN-O2-NEXT: FunctionPass Manager ; GCN-O2-NEXT: Dominator Tree Construction ; GCN-O2-NEXT: Natural Loop Information @@ -975,6 +987,12 @@ ; GCN-O3-NEXT: Strip Unused Function Prototypes ; GCN-O3-NEXT: Dead Global Elimination ; GCN-O3-NEXT: Merge Duplicate Global Constants +; GCN-O3-NEXT: Call Graph Profile +; GCN-O3-NEXT: FunctionPass Manager +; GCN-O3-NEXT: Dominator Tree Construction +; GCN-O3-NEXT: Natural Loop Information +; GCN-O3-NEXT: Lazy Branch Probability Analysis +; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: FunctionPass Manager ; GCN-O3-NEXT: Dominator Tree Construction ; GCN-O3-NEXT: Natural Loop Information diff --git a/llvm/test/Instrumentation/cgprofile.ll b/llvm/test/Instrumentation/cgprofile.ll index 1edf3b6ec518..70a1f81aa53e 100644 --- a/llvm/test/Instrumentation/cgprofile.ll +++ b/llvm/test/Instrumentation/cgprofile.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -passes cg-profile -S | FileCheck %s +; RUN: opt < %s -cg-profile -S | FileCheck %s declare void @b() diff --git a/llvm/test/Other/new-pm-cgprofile.ll b/llvm/test/Other/new-pm-cgprofile.ll deleted file mode 100644 index c7fe31ab570f..000000000000 --- a/llvm/test/Other/new-pm-cgprofile.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT -; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF -; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON -; -; DEFAULT: Running pass: CGProfilePass -; OFF-NOT: Running pass: CGProfilePass -; ON: Running pass: CGProfilePass - -define void @foo() { - ret void -} diff --git a/llvm/test/Other/opt-O2-pipeline.ll b/llvm/test/Other/opt-O2-pipeline.ll index ca72ec1f7567..56f85d0fb9a8 100644 --- a/llvm/test/Other/opt-O2-pipeline.ll +++ b/llvm/test/Other/opt-O2-pipeline.ll @@ -280,6 +280,12 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: Call Graph Profile +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/Other/opt-O3-pipeline.ll b/llvm/test/Other/opt-O3-pipeline.ll index f629bfc3444b..942f7d9dfead 100644 --- a/llvm/test/Other/opt-O3-pipeline.ll +++ b/llvm/test/Other/opt-O3-pipeline.ll @@ -285,6 +285,12 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: Call Graph Profile +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/Other/opt-Os-pipeline.ll b/llvm/test/Other/opt-Os-pipeline.ll index dde9fbeb9950..d975cc48b629 100644 --- a/llvm/test/Other/opt-Os-pipeline.ll +++ b/llvm/test/Other/opt-Os-pipeline.ll @@ -266,6 +266,12 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: Call Graph Profile +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information From cfe-commits at lists.llvm.org Thu Jul 9 13:04:02 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:04:02 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <1499635f61bf6b379c79ea0be082e0bf@localhost.localdomain> This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rGc92a8c0a0f68: [LPM] Port CGProfilePass from NPM to LPM (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 Files: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/new-pm-cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83013.276814.patch Type: text/x-patch Size: 17602 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 13:05:38 2020 From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:05:38 +0000 (UTC) Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X In-Reply-To: References: Message-ID: <089e563fe2b0ce0dabbbf2aa97f285b0@localhost.localdomain> efriedma added a subscriber: tgt. efriedma added a comment. > that's fine but I still don't understand why the counterexample to my version says %x2 in @src can be undef If I'm understanding correctly, this reduces to something like the following: define i32 @src() { %x2 = freeze i32 undef ret i32 %x2 } define i32 @tgt() { ret i32 undef } This seems a little suspect, yes. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83360/new/ https://reviews.llvm.org/D83360 From cfe-commits at lists.llvm.org Thu Jul 9 13:08:04 2020 From: cfe-commits at lists.llvm.org (Eric Christopher via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:08:04 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: echristo added a comment. Some inline nits. I see you've already committed and that's fine - I still don't think we should do it, but we can delete it again soon :) ================ Comment at: clang/lib/CodeGen/BackendUtil.cpp:623 PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop; + PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; ---------------- Comment here as to why. ================ Comment at: clang/lib/CodeGen/BackendUtil.cpp:1148 PTO.SLPVectorization = CodeGenOpts.VectorizeSLP; - PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile; + PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PTO.Coroutines = LangOpts.Coroutines; ---------------- Comment here as to why. ================ Comment at: clang/lib/CodeGen/BackendUtil.cpp:1566 Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP; - Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile; + Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS; ---------------- Ditto :) ================ Comment at: llvm/lib/Transforms/Instrumentation/CGProfile.cpp:64 // Ignore error here. Indirect calls are ignored if this fails. - (void)(bool)Symtab.create(M); + (void)(bool) Symtab.create(M); for (auto &F : M) { ---------------- Extra space? Did clang-format put this in? ================ Comment at: llvm/lib/Transforms/Instrumentation/CGProfile.cpp:66 for (auto &F : M) { - if (F.isDeclaration()) + if (F.isDeclaration() || !F.getEntryCount()) continue; ---------------- Comment? What's the change for? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Thu Jul 9 13:08:20 2020 From: cfe-commits at lists.llvm.org (Petr Hosek via cfe-commits) Date: Thu, 09 Jul 2020 13:08:20 -0700 (PDT) Subject: [clang] 53e38c8 - [CMake][Fuchsia] Support for building with MSVC Message-ID: <5f077934.1c69fb81.2cb63.9426@mx.google.com> Author: Petr Hosek Date: 2020-07-09T13:07:12-07:00 New Revision: 53e38c85a8a6cdcf7776b936d72fb94ec737dc84 URL: https://github.com/llvm/llvm-project/commit/53e38c85a8a6cdcf7776b936d72fb94ec737dc84 DIFF: https://github.com/llvm/llvm-project/commit/53e38c85a8a6cdcf7776b936d72fb94ec737dc84.diff LOG: [CMake][Fuchsia] Support for building with MSVC This change adds the necessary flags for building the full Fuchsia toolchain on Windows with MSVC. Differential Revision: https://reviews.llvm.org/D73810 Added: Modified: clang/cmake/caches/Fuchsia-stage2.cmake clang/cmake/caches/Fuchsia.cmake Removed: ################################################################################ diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index 9ecf8f300e75..4d9b8526d0c4 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -5,7 +5,6 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "") set(PACKAGE_VENDOR Fuchsia CACHE STRING "") set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "") -set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") if(NOT APPLE) @@ -22,6 +21,10 @@ set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "") set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "") set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "") +if(MSVC) + set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "") +endif() + set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") if(NOT APPLE) set(CLANG_DEFAULT_LINKER lld CACHE STRING "") @@ -39,6 +42,8 @@ set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") set(CMAKE_BUILD_TYPE Release CACHE STRING "") if (APPLE) set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "") +elseif(MSVC) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "") endif() if(APPLE) @@ -65,6 +70,26 @@ if(APPLE) set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "") set(DARWIN_osx_ARCHS x86_64 CACHE STRING "") set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "") + set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") +endif() + +if(WIN32) + set(target "x86_64-pc-windows-msvc") + + list(APPEND BUILTIN_TARGETS "${target}") + set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "") + set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") + + list(APPEND RUNTIME_TARGETS "${target}") + set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") + set(RUNTIMES_${target}_LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "") + set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "") endif() foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unknown-linux-gnu;x86_64-unknown-linux-gnu) @@ -73,6 +98,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn list(APPEND BUILTIN_TARGETS "${target}") set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") + set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "") + set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "") + set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "") set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -82,6 +110,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn list(APPEND RUNTIME_TARGETS "${target}") set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "") set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING "") + set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING "") set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "") set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -100,9 +131,9 @@ foreach(target aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") set(RUNTIMES_${target}_LIBCXX_ABI_VERSION 2 CACHE STRING "") set(RUNTIMES_${target}_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") - set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(RUNTIMES_${target}_SANITIZER_CXX_ABI "libc++" CACHE STRING "") set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "") + set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") # Use .build-id link. list(APPEND RUNTIME_BUILD_ID_LINK "${target}") @@ -115,7 +146,7 @@ if(FUCHSIA_SDK) set(FUCHSIA_x86_64_NAME x64) set(FUCHSIA_riscv64_NAME riscv64) foreach(target i386;x86_64;aarch64;riscv64) - set(FUCHSIA_${target}_COMPILER_FLAGS "-I${FUCHSIA_SDK}/pkg/fdio/include") + set(FUCHSIA_${target}_COMPILER_FLAGS "--target=${target}-unknown-fuchsia -I${FUCHSIA_SDK}/pkg/fdio/include") set(FUCHSIA_${target}_LINKER_FLAGS "-L${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/lib") set(FUCHSIA_${target}_SYSROOT "${FUCHSIA_SDK}/arch/${FUCHSIA_${target}_NAME}/sysroot") endforeach() diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake index bb22a00fa5c7..8688b71ecc75 100644 --- a/clang/cmake/caches/Fuchsia.cmake +++ b/clang/cmake/caches/Fuchsia.cmake @@ -5,7 +5,6 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "") set(PACKAGE_VENDOR Fuchsia CACHE STRING "") set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "") -set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "") @@ -16,6 +15,10 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "") +if(MSVC) + set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "") +endif() + set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "") if(NOT APPLE) set(CLANG_DEFAULT_LINKER lld CACHE STRING "") @@ -32,8 +35,10 @@ set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "") set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") set(CMAKE_BUILD_TYPE Release CACHE STRING "") -if (APPLE) +if(APPLE) set(MACOSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "") +elseif(MSVC) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "") endif() if(APPLE) @@ -52,8 +57,19 @@ set(LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "") set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") set(LIBCXX_ABI_VERSION 2 CACHE STRING "") set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") -set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") -set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") +if(WIN32) + set(LIBCXX_HAS_WIN32_THREAD_API ON CACHE BOOL "") + set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") + set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") + set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "") + set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY OFF CACHE BOOL "") + set(BUILTINS_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "") + set(RUNTIMES_CMAKE_ARGS -DCMAKE_SYSTEM_NAME=Windows CACHE STRING "") + set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "") +else() + set(LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "") + set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") +endif() if(BOOTSTRAP_CMAKE_SYSTEM_NAME) set(target "${BOOTSTRAP_CMAKE_CXX_COMPILER_TARGET}") From cfe-commits at lists.llvm.org Thu Jul 9 13:08:33 2020 From: cfe-commits at lists.llvm.org (Petr Hosek via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:08:33 +0000 (UTC) Subject: [PATCH] D73810: [CMake][Fuchsia] Support for building on Windows In-Reply-To: References: Message-ID: <580bd3300811d9caf93e5b49e21a8e9f@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG53e38c85a8a6: [CMake][Fuchsia] Support for building with MSVC (authored by phosek). Changed prior to commit: https://reviews.llvm.org/D73810?vs=241822&id=276815#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D73810/new/ https://reviews.llvm.org/D73810 Files: clang/cmake/caches/Fuchsia-stage2.cmake clang/cmake/caches/Fuchsia.cmake -------------- next part -------------- A non-text attachment was scrubbed... Name: D73810.276815.patch Type: text/x-patch Size: 7144 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 13:28:43 2020 From: cfe-commits at lists.llvm.org (Roman Lebedev via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:28:43 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <46b6b909600c0a46616df89961214d39@localhost.localdomain> lebedev.ri added a comment. This seems to have broken the build http://45.33.8.238/linux/22500/step_7.txt Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Thu Jul 9 13:33:37 2020 From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:33:37 +0000 (UTC) Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend In-Reply-To: References: Message-ID: Conanap marked an inline comment as done. Conanap added inline comments. ================ Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:939 + // The XFormMemOp flag for the following 8 insts is set on the instruction format. + let mayLoad = 1, mayStore = 1 in { + def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>; ---------------- bsaleil wrote: > Shouldn't `mayStore` be 0 instead of 1 here ? yes, thanks; will fix on the commit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83364/new/ https://reviews.llvm.org/D83364 From cfe-commits at lists.llvm.org Thu Jul 9 13:36:06 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via cfe-commits) Date: Thu, 09 Jul 2020 13:36:06 -0700 (PDT) Subject: [clang] c025bdf - Revert D83013 "[LPM] Port CGProfilePass from NPM to LPM" Message-ID: <5f077fb6.1c69fb81.acd8d.8db6@mx.google.com> Author: Fangrui Song Date: 2020-07-09T13:34:04-07:00 New Revision: c025bdf25a59a79d60a2e99962c8653547a825d8 URL: https://github.com/llvm/llvm-project/commit/c025bdf25a59a79d60a2e99962c8653547a825d8 DIFF: https://github.com/llvm/llvm-project/commit/c025bdf25a59a79d60a2e99962c8653547a825d8.diff LOG: Revert D83013 "[LPM] Port CGProfilePass from NPM to LPM" This reverts commit c92a8c0a0f68fbbb23e3fdde071007e63a552e82. It breaks builds and has unaddressed review comments. Added: llvm/test/Other/new-pm-cgprofile.ll Modified: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll Removed: ################################################################################ diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index f3e43919eeca..d465e00d4c70 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -252,6 +252,7 @@ CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables. CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer. CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer. CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate. +CODEGENOPT(CallGraphProfile , 1, 0) ///< Run call graph profile. /// Attempt to use register sized accesses to bit-fields in structures, when /// possible. diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 3ada1aaa4ed8..9e6d5e4593d3 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -620,7 +620,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize; PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP; PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop; - PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; // Loop interleaving in the loop vectorizer has historically been set to be @@ -1145,7 +1144,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; PTO.LoopVectorization = CodeGenOpts.VectorizeLoop; PTO.SLPVectorization = CodeGenOpts.VectorizeSLP; - PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; + PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile; PTO.Coroutines = LangOpts.Coroutines; PassInstrumentationCallbacks PIC; @@ -1563,7 +1562,7 @@ static void runThinLTOBackend( Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops; Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop; Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP; - Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS; + Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile; // Context sensitive profile. if (CGOpts.hasProfileCSIRInstr()) { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index fd34c6b8a955..6f6af917e3a3 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -860,6 +860,7 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.RerollLoops = Args.hasArg(OPT_freroll_loops); Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as); + Opts.CallGraphProfile = !Opts.DisableIntegratedAS; Opts.Autolink = !Args.hasArg(OPT_fno_autolink); Opts.SampleProfileFile = std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ)); diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index 06e8507036ac..f0d5accf13c5 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -103,7 +103,6 @@ void initializeCFGViewerLegacyPassPass(PassRegistry&); void initializeCFIInstrInserterPass(PassRegistry&); void initializeCFLAndersAAWrapperPassPass(PassRegistry&); void initializeCFLSteensAAWrapperPassPass(PassRegistry&); -void initializeCGProfileLegacyPassPass(PassRegistry &); void initializeCallGraphDOTPrinterPass(PassRegistry&); void initializeCallGraphPrinterLegacyPassPass(PassRegistry&); void initializeCallGraphViewerPass(PassRegistry&); diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h index d1b9f269d5d4..28e454d3b0fc 100644 --- a/llvm/include/llvm/Transforms/IPO.h +++ b/llvm/include/llvm/Transforms/IPO.h @@ -282,8 +282,6 @@ ModulePass *createSampleProfileLoaderPass(StringRef Name); ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str, raw_ostream *ThinLinkOS = nullptr); -ModulePass *createCGProfileLegacyPass(); - } // End llvm namespace #endif diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h index a9928c3f5a40..8b03bcba10e4 100644 --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -156,7 +156,6 @@ class PassManagerBuilder { bool DisableTailCalls; bool DisableUnrollLoops; - bool CallGraphProfile; bool SLPVectorize; bool LoopVectorize; bool LoopsInterleaved; diff --git a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h index 4cb45fd42f80..28fd3804dec9 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h +++ b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h @@ -19,6 +19,11 @@ namespace llvm { class CGProfilePass : public PassInfoMixin { public: PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); + +private: + void addModuleFlags( + Module &M, + MapVector, uint64_t> &Counts) const; }; } // end namespace llvm diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 4d6c30b87a99..58510609cf5e 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -248,6 +248,10 @@ static cl::opt EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)")); +static cl::opt EnableCallGraphProfile( + "enable-npm-call-graph-profile", cl::init(true), cl::Hidden, + cl::desc("Enable call graph profile pass for the new PM (default = on)")); + /// Flag to enable inline deferral during PGO. static cl::opt EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true), @@ -263,7 +267,7 @@ PipelineTuningOptions::PipelineTuningOptions() { Coroutines = false; LicmMssaOptCap = SetLicmMssaOptCap; LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap; - CallGraphProfile = true; + CallGraphProfile = EnableCallGraphProfile; } extern cl::opt EnableHotColdSplit; diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index b65eb469a492..9534fb874107 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -195,7 +195,6 @@ PassManagerBuilder::PassManagerBuilder() { PrepareForThinLTO = EnablePrepareForThinLTO; PerformThinLTO = EnablePerformThinLTO; DivergentTarget = false; - CallGraphProfile = true; } PassManagerBuilder::~PassManagerBuilder() { @@ -835,10 +834,6 @@ void PassManagerBuilder::populateModulePassManager( if (MergeFunctions) MPM.add(createMergeFunctionsPass()); - // Add Module flag "CG Profile" based on Branch Frequency Information. - if (CallGraphProfile) - MPM.add(createCGProfileLegacyPass()); - // LoopSink pass sinks instructions hoisted by LICM, which serves as a // canonicalization pass that enables other optimizations. As a result, // LoopSink pass needs to be a very late IR pass to avoid undoing LICM diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp index e95731a2117b..2d5bd9570940 100644 --- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp +++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp @@ -10,48 +10,22 @@ #include "llvm/ADT/MapVector.h" #include "llvm/Analysis/BlockFrequencyInfo.h" -#include "llvm/Analysis/LazyBlockFrequencyInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/PassManager.h" -#include "llvm/InitializePasses.h" #include "llvm/ProfileData/InstrProf.h" -#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Instrumentation.h" #include using namespace llvm; -static bool -addModuleFlags(Module &M, - MapVector, uint64_t> &Counts) { - if (Counts.empty()) - return false; - - LLVMContext &Context = M.getContext(); - MDBuilder MDB(Context); - std::vector Nodes; - - for (auto E : Counts) { - Metadata *Vals[] = {ValueAsMetadata::get(E.first.first), - ValueAsMetadata::get(E.first.second), - MDB.createConstant(ConstantInt::get( - Type::getInt64Ty(Context), E.second))}; - Nodes.push_back(MDNode::get(Context, Vals)); - } - - M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); - return true; -} - -static bool -runCGProfilePass(Module &M, - function_ref GetBFI, - function_ref GetTTI) { +PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { MapVector, uint64_t> Counts; + FunctionAnalysisManager &FAM = + MAM.getResult(M).getManager(); InstrProfSymtab Symtab; auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F, Function *CalledF, uint64_t NewCount) { @@ -61,14 +35,14 @@ runCGProfilePass(Module &M, Count = SaturatingAdd(Count, NewCount); }; // Ignore error here. Indirect calls are ignored if this fails. - (void)(bool) Symtab.create(M); + (void)(bool)Symtab.create(M); for (auto &F : M) { - if (F.isDeclaration() || !F.getEntryCount()) + if (F.isDeclaration()) continue; - auto &BFI = GetBFI(F); + auto &BFI = FAM.getResult(F); if (BFI.getEntryFreq() == 0) continue; - TargetTransformInfo &TTI = GetTTI(F); + TargetTransformInfo &TTI = FAM.getResult(F); for (auto &BB : F) { Optional BBCount = BFI.getBlockProfileCount(&BB); if (!BBCount) @@ -95,56 +69,28 @@ runCGProfilePass(Module &M, } } - return addModuleFlags(M, Counts); -} + addModuleFlags(M, Counts); -namespace { -struct CGProfileLegacyPass final : public ModulePass { - static char ID; - CGProfileLegacyPass() : ModulePass(ID) { - initializeCGProfileLegacyPassPass(*PassRegistry::getPassRegistry()); - } + return PreservedAnalyses::all(); +} - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesCFG(); - AU.addRequired(); - AU.addRequired(); - } +void CGProfilePass::addModuleFlags( + Module &M, + MapVector, uint64_t> &Counts) const { + if (Counts.empty()) + return; - bool runOnModule(Module &M) override { - auto GetBFI = [this](Function &F) -> BlockFrequencyInfo & { - return this->getAnalysis(F).getBFI(); - }; - auto GetTTI = [this](Function &F) -> TargetTransformInfo & { - return this->getAnalysis().getTTI(F); - }; + LLVMContext &Context = M.getContext(); + MDBuilder MDB(Context); + std::vector Nodes; - return runCGProfilePass(M, GetBFI, GetTTI); + for (auto E : Counts) { + Metadata *Vals[] = {ValueAsMetadata::get(E.first.first), + ValueAsMetadata::get(E.first.second), + MDB.createConstant(ConstantInt::get( + Type::getInt64Ty(Context), E.second))}; + Nodes.push_back(MDNode::get(Context, Vals)); } -}; - -} // namespace - -char CGProfileLegacyPass::ID = 0; -INITIALIZE_PASS(CGProfileLegacyPass, "cg-profile", "Call Graph Profile", false, - false) - -ModulePass *llvm::createCGProfileLegacyPass() { - return new CGProfileLegacyPass(); -} - -PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { - FunctionAnalysisManager &FAM = - MAM.getResult(M).getManager(); - auto GetBFI = [&FAM](Function &F) -> BlockFrequencyInfo & { - return FAM.getResult(F); - }; - auto GetTTI = [&FAM](Function &F) -> TargetTransformInfo & { - return FAM.getResult(F); - }; - - runCGProfilePass(M, GetBFI, GetTTI); - - return PreservedAnalyses::all(); + M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); } diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp index ad238f1357c6..64626225f23f 100644 --- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -112,7 +112,6 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) { initializePGOInstrumentationUseLegacyPassPass(Registry); initializePGOIndirectCallPromotionLegacyPassPass(Registry); initializePGOMemOPSizeOptLegacyPassPass(Registry); - initializeCGProfileLegacyPassPass(Registry); initializeInstrOrderFileLegacyPassPass(Registry); initializeInstrProfilingLegacyPassPass(Registry); initializeMemorySanitizerLegacyPassPass(Registry); diff --git a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll index 85f9d8c867bf..32d36f4e7280 100644 --- a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll +++ b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll @@ -276,12 +276,6 @@ ; GCN-O1-NEXT: Warn about non-applied transformations ; GCN-O1-NEXT: Alignment from assumptions ; GCN-O1-NEXT: Strip Unused Function Prototypes -; GCN-O1-NEXT: Call Graph Profile -; GCN-O1-NEXT: FunctionPass Manager -; GCN-O1-NEXT: Dominator Tree Construction -; GCN-O1-NEXT: Natural Loop Information -; GCN-O1-NEXT: Lazy Branch Probability Analysis -; GCN-O1-NEXT: Lazy Block Frequency Analysis ; GCN-O1-NEXT: FunctionPass Manager ; GCN-O1-NEXT: Dominator Tree Construction ; GCN-O1-NEXT: Natural Loop Information @@ -629,12 +623,6 @@ ; GCN-O2-NEXT: Strip Unused Function Prototypes ; GCN-O2-NEXT: Dead Global Elimination ; GCN-O2-NEXT: Merge Duplicate Global Constants -; GCN-O2-NEXT: Call Graph Profile -; GCN-O2-NEXT: FunctionPass Manager -; GCN-O2-NEXT: Dominator Tree Construction -; GCN-O2-NEXT: Natural Loop Information -; GCN-O2-NEXT: Lazy Branch Probability Analysis -; GCN-O2-NEXT: Lazy Block Frequency Analysis ; GCN-O2-NEXT: FunctionPass Manager ; GCN-O2-NEXT: Dominator Tree Construction ; GCN-O2-NEXT: Natural Loop Information @@ -987,12 +975,6 @@ ; GCN-O3-NEXT: Strip Unused Function Prototypes ; GCN-O3-NEXT: Dead Global Elimination ; GCN-O3-NEXT: Merge Duplicate Global Constants -; GCN-O3-NEXT: Call Graph Profile -; GCN-O3-NEXT: FunctionPass Manager -; GCN-O3-NEXT: Dominator Tree Construction -; GCN-O3-NEXT: Natural Loop Information -; GCN-O3-NEXT: Lazy Branch Probability Analysis -; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: FunctionPass Manager ; GCN-O3-NEXT: Dominator Tree Construction ; GCN-O3-NEXT: Natural Loop Information diff --git a/llvm/test/Instrumentation/cgprofile.ll b/llvm/test/Instrumentation/cgprofile.ll index 70a1f81aa53e..1edf3b6ec518 100644 --- a/llvm/test/Instrumentation/cgprofile.ll +++ b/llvm/test/Instrumentation/cgprofile.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -passes cg-profile -S | FileCheck %s -; RUN: opt < %s -cg-profile -S | FileCheck %s declare void @b() diff --git a/llvm/test/Other/new-pm-cgprofile.ll b/llvm/test/Other/new-pm-cgprofile.ll new file mode 100644 index 000000000000..c7fe31ab570f --- /dev/null +++ b/llvm/test/Other/new-pm-cgprofile.ll @@ -0,0 +1,11 @@ +; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT +; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF +; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON +; +; DEFAULT: Running pass: CGProfilePass +; OFF-NOT: Running pass: CGProfilePass +; ON: Running pass: CGProfilePass + +define void @foo() { + ret void +} diff --git a/llvm/test/Other/opt-O2-pipeline.ll b/llvm/test/Other/opt-O2-pipeline.ll index 56f85d0fb9a8..ca72ec1f7567 100644 --- a/llvm/test/Other/opt-O2-pipeline.ll +++ b/llvm/test/Other/opt-O2-pipeline.ll @@ -280,12 +280,6 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants -; CHECK-NEXT: Call Graph Profile -; CHECK-NEXT: FunctionPass Manager -; CHECK-NEXT: Dominator Tree Construction -; CHECK-NEXT: Natural Loop Information -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/Other/opt-O3-pipeline.ll b/llvm/test/Other/opt-O3-pipeline.ll index 942f7d9dfead..f629bfc3444b 100644 --- a/llvm/test/Other/opt-O3-pipeline.ll +++ b/llvm/test/Other/opt-O3-pipeline.ll @@ -285,12 +285,6 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants -; CHECK-NEXT: Call Graph Profile -; CHECK-NEXT: FunctionPass Manager -; CHECK-NEXT: Dominator Tree Construction -; CHECK-NEXT: Natural Loop Information -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/Other/opt-Os-pipeline.ll b/llvm/test/Other/opt-Os-pipeline.ll index d975cc48b629..dde9fbeb9950 100644 --- a/llvm/test/Other/opt-Os-pipeline.ll +++ b/llvm/test/Other/opt-Os-pipeline.ll @@ -266,12 +266,6 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants -; CHECK-NEXT: Call Graph Profile -; CHECK-NEXT: FunctionPass Manager -; CHECK-NEXT: Dominator Tree Construction -; CHECK-NEXT: Natural Loop Information -; CHECK-NEXT: Lazy Branch Probability Analysis -; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information From cfe-commits at lists.llvm.org Thu Jul 9 13:42:21 2020 From: cfe-commits at lists.llvm.org (Matt Morehouse via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:42:21 +0000 (UTC) Subject: [PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked. In-Reply-To: References: Message-ID: <0cf7b4ccf7dcee7c7c1fe86d29052faf@localhost.localdomain> morehouse added a comment. Seems like the general approach we want. Could you: - Fix the lint warnings - Find out why the unit tests failed - Add strcmp - Modify the memcmp/strcmp unit tests to show that we can solve them with/without ASan After that I'll take a closer look. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83494/new/ https://reviews.llvm.org/D83494 From cfe-commits at lists.llvm.org Thu Jul 9 13:43:00 2020 From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 20:43:00 +0000 (UTC) Subject: [PATCH] D83426: Unbreak Clang standalone build. In-Reply-To: References: Message-ID: michele.scandale added a comment. Thanks. Would you be able to land this on my behalf? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83426/new/ https://reviews.llvm.org/D83426 From cfe-commits at lists.llvm.org Thu Jul 9 14:00:59 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:00:59 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: <14be37c4d427f6c83797f0033b7382e4@localhost.localdomain> rjmccall added a comment. This seems fine. I do wonder if the "real" bug is that this ought to be handled properly in EmitReturnFromThunk, but regardless, the fix seems acceptable. Is there a similar bug with trivial_abi? Should we have a test case for that? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 From cfe-commits at lists.llvm.org Thu Jul 9 14:05:24 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:05:24 +0000 (UTC) Subject: [PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: rjmccall added inline comments. ================ Comment at: clang/lib/AST/ASTContext.cpp:10068 + isa(D) && cast(D)->isFileVarDecl() && + cast(D)->getStorageClass() == SC_Static) { + return GVA_StrongExternal; ---------------- JonChesterfield wrote: > yaxunl wrote: > > rjmccall wrote: > > > Are you sure this doesn't apply to e.g. local statics? Can't you have kernel lambdas, or am I confusing HIP with another language? > > function-scope static var in a device function is only visible to the device function. Host code cannot access it, therefore no need to externalize it. > This doesn't sound right. An inline function can return a pointer to a function scope static variable, e.g. to implement a singleton in a header file. I think host code can then access said variable. Right, and IIRC you can declare __host__ __device__ functions as well, which ought to agree on the variable if they agree on globals. ================ Comment at: clang/lib/Driver/Action.cpp:170 + if (!Id) + Id = llvm::sys::Process::GetRandomNumber(); +} ---------------- yaxunl wrote: > rjmccall wrote: > > I'm sure GetRandomNumber can return 0, so this logic is faulty. > > > > This also seems like an unfortunate intrusion of HIP-specific semantics on the rest of the driver. Maybe HIP can generate the shared id when it's setting up and cloning the job. > Changed type of ID to string. Now empty ID means disabled. 0 is now allowed as a usual ID. > > Moved initialization of ID to HIP action builder. Thanks, that works. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 From cfe-commits at lists.llvm.org Thu Jul 9 14:06:04 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:06:04 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: <92f83cd567d96d0b59c357fcebccc143@localhost.localdomain> sammccall marked an inline comment as done. sammccall added inline comments. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:83 + return PD->getDefinition(); + // Objective-C classes can have three types of declarations: + // ---------------- This is a really useful comment, thanks! ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92 + if (const auto *ID = dyn_cast(D)) { + if (const auto *IMD = ID->getImplementation()) + return IMD; + return ID->getDefinition(); + } ---------------- dgoldman wrote: > Let me know if there's a better way to handle this multi-"definition" support I think there might be (what you've done seems reasonable in isolation but I'm not sure it'll yield the best behavior). Consider this code: ``` int foo(); // A int foo(); // B int foo(){} // C ``` We have 3 declarations. A will be chosen as the canonical declaration (because it's first, though things get more complicated when the index is involved). C is the definition. So go-to-definition will land on C, and then triggering it again will take you to A, and then back to C. go-to-declaration is the opposite. B is basically just a reference for our purposes, we won't navigate you there (except by find-refs). Now let's look at your example again: ``` @class MyClass; // A @interface MyClass ... @end // B @implementation MyClass ... @end // C ``` Thinking about where you might want to navigate to, A is certainly the least important of these, right? It seems clear we want B to be considered the canonical declaration and C the definition. So I think: - we should only return the implementation here if it exists, and otherwise nullptr rather than the inferface. - getCanonicalDecl in AddResultDecl should special case ObjCInterfaceDecl to get the definition (i.e. @interface) if possible - we need to convince other parts of clangd that these are the same symbol: - targetDecl should resolve any reference to an ObjCImplDecl to the corresponding ObjCInterfaceDecl instead - the indexer (`SymbolCollector`) also needs to handle this (the ObjCImplDecl should end up being the stored Definition under the ObjCInterfaceDecl's SymbolID) Some code will only see the forward declaration and that's OK. The index's merge rules are that a candidate "canonical declaration" which has an associated definition is preferred over one that doesn't. Since the implementation can always see the interface, the interface will end up being the canonical declaration after merge. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:276 getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) { // Special case: void foo() ^override: jump to the overridden method. if (const auto *CMD = llvm::dyn_cast(D)) { ---------------- dgoldman wrote: > Think it would make sense to special case ObjCInterfaceDecl here to get at both the interface definition + implementation if available? Rather than returning both results, I think it's more consistent to return them as a declaration/definition pair. (This means special-casing ObjCImplDecl in namedDecl or at least getDeclAsPosition, so you always end up with the ObjCInterfaceDecl instead) ================ Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:723 + std::string ObjcPrefix = "//objc"; + if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) { + TU.Filename = "TestTU.m"; ---------------- Hm, I quite like this. You can probably also just do TU.ExtraArgs.push_back("-xobjective-c++") though, it probably won't break anything. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Thu Jul 9 14:12:50 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:12:50 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: <1afe149242f97126b90e408ab8b321e9@localhost.localdomain> rjmccall added inline comments. ================ Comment at: clang/lib/CodeGen/CGCall.cpp:2515 + } else { + AI->addAttr(llvm::Attribute::NonNull); + } ---------------- Isn't the old logic still correct? If the element size is static and the element count is positive, the argument is dereferenceable out to their product; otherwise it's nonnull if null is the zero value and we aren't semantically allowing that to be a valid pointer. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 From cfe-commits at lists.llvm.org Thu Jul 9 14:14:30 2020 From: cfe-commits at lists.llvm.org (Kirill Bobyrev via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:14:30 +0000 (UTC) Subject: [PATCH] D82436: [clangd] Implement textDocument/foldingRange In-Reply-To: References: Message-ID: kbobyrev marked an inline comment as done. kbobyrev added a comment. In D82436#2141953 , @sammccall wrote: > Tests :-) I was hoping glorious DocumentSymbols super tested API would shield me from that :P Didn't think of reasonable testing strategy but fair enough, will do! ================ Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:300 +opt FoldingRanges{ + "folding-rangees", + cat(Features), ---------------- sammccall wrote: > rangees -> ranges My broken keyboard puts multiple symbols all over the place :( Catching them all is hard, sorry, the other patch also had a couple of those. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82436/new/ https://reviews.llvm.org/D82436 From cfe-commits at lists.llvm.org Thu Jul 9 14:15:33 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:15:33 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: zequanwu updated this revision to Diff 276834. zequanwu added a comment. Add comments and fix test failure in http://45.33.8.238/linux/22500/step_7.txt. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 Files: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/new-pm-cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83013.276834.patch Type: text/x-patch Size: 18322 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:16:25 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:16:25 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <6884af0d21a3b98f5730e55e4ca4e729@localhost.localdomain> zequanwu marked 5 inline comments as done. zequanwu added inline comments. ================ Comment at: llvm/lib/Transforms/Instrumentation/CGProfile.cpp:64 // Ignore error here. Indirect calls are ignored if this fails. - (void)(bool)Symtab.create(M); + (void)(bool) Symtab.create(M); for (auto &F : M) { ---------------- echristo wrote: > Extra space? Did clang-format put this in? Yes, `clang-format` put this in. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Thu Jul 9 14:18:26 2020 From: cfe-commits at lists.llvm.org (Nuno Lopes via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:18:26 +0000 (UTC) Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X In-Reply-To: References: Message-ID: <2434b323bab909f54e78abf9712899fc@localhost.localdomain> nlopes added a subscriber: tgt. nlopes added a comment. In D83360#2142457 , @efriedma wrote: > > that's fine but I still don't understand why the counterexample to my version says %x2 in @src can be undef > > If I'm understanding correctly, this reduces to something like the following: > > define i32 @src() { > > %x2 = freeze i32 undef > ret i32 %x2 > > } > > define i32 @tgt() { > > ret i32 undef > > } > > This seems a little suspect, yes. This is a known bug: https://github.com/AliveToolkit/alive2/issues/3 gotta fix this soon. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83360/new/ https://reviews.llvm.org/D83360 From cfe-commits at lists.llvm.org Thu Jul 9 14:22:59 2020 From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:22:59 +0000 (UTC) Subject: [PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor. Message-ID: ArcsinX created this revision. Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. This patch fixes redundant hover with information about Decl which is not under cursor. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83508 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -942,6 +942,13 @@ template void foo() { (void)[[size^of]](T); })cpp", + R"cpp(// No Decl for token under cursor. + namespace ns { + #define FOO B^AR; + })cpp", + R"cpp(//error-ok + unknown f(i^nt); + )cpp", // literals "auto x = t^rue;", "auto x = '^A';", Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -820,6 +820,18 @@ SelectionTree::createRight(AST.getASTContext(), TB, Offset, Offset); std::vector Result; if (const SelectionTree::Node *N = ST.commonAncestor()) { + // Don't allow Decls which are not related with tokens under cursor. + if (const auto *D = N->ASTNode.get()) { + bool IsDeclTouchingCursor = false; + for (const auto &Tok : TokensTouchingCursor) { + if (D->getLocation() == Tok.location()) { + IsDeclTouchingCursor = true; + break; + } + } + if (!IsDeclTouchingCursor) + return llvm::None; + } // FIXME: Fill in HighlightRange with range coming from N->ASTNode. auto Decls = explicitReferenceTargets(N->ASTNode, DeclRelation::Alias); if (!Decls.empty()) { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83508.276836.patch Type: text/x-patch Size: 1627 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:24:23 2020 From: cfe-commits at lists.llvm.org (Oliver Hunt via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:24:23 +0000 (UTC) Subject: [PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock Message-ID: ojhunt created this revision. ojhunt added a reviewer: jfb. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang. Add a guard for re-entering an SDiagsWriter's HandleDiagnostics method after we've started finalizing. This is a generic catch all for unexpected fatal errors so we don't recursive crash inside the generic llvm error handler. We also add logic to handle the actual error case in llvm::~raw_fd_ostream caused by failing to clear errors before it is destroyed. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83509 Files: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/lib/Frontend/SerializedDiagnosticPrinter.cpp Index: clang/lib/Frontend/SerializedDiagnosticPrinter.cpp =================================================================== --- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -239,6 +239,9 @@ /// generated from child processes. bool MergeChildRecords; + /// Whether we've started finishing and tearing down this instance. + bool IsFinishing = false; + /// State that is shared among the various clones of this diagnostic /// consumer. struct SharedState { @@ -568,6 +571,17 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) { + assert(!IsFinishing && + "Received a diagnostic after we've already started teardown."); + if (IsFinishing) { + SmallString<256> diagnostic; + Info.FormatDiagnostic(diagnostic); + getMetaDiags()->Report( + diag::warn_fe_serialized_diag_failure_during_finalisation) + << diagnostic; + return; + } + // Enter the block for a non-note diagnostic immediately, rather than waiting // for beginDiagnostic, in case associated notes are emitted before we get // there. @@ -761,6 +775,9 @@ } void SDiagsWriter::finish() { + assert(!IsFinishing); + IsFinishing = true; + // The original instance is responsible for writing the file. if (!OriginalInstance) return; @@ -786,12 +803,20 @@ if (EC) { getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure) << State->OutputFile << EC.message(); + OS->clear_error(); return; } // Write the generated bitstream to "Out". OS->write((char *)&State->Buffer.front(), State->Buffer.size()); OS->flush(); + + assert(!OS->has_error()); + if (OS->has_error()) { + getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure) + << State->OutputFile << OS->error().message(); + OS->clear_error(); + } } std::error_code SDiagsMerger::visitStartOfDiagnostic() { Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -119,6 +119,9 @@ def warn_fe_serialized_diag_failure : Warning< "unable to open file %0 for serializing diagnostics (%1)">, InGroup; +def warn_fe_serialized_diag_failure_during_finalisation : Warning< + "Received warning after diagnostic serialisation teardown was underway: %0">, + InGroup; def err_verify_missing_line : Error< "missing or invalid line number following '@' in expected %0">; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83509.276835.patch Type: text/x-patch Size: 2721 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:26:56 2020 From: cfe-commits at lists.llvm.org (JF Bastien via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:26:56 +0000 (UTC) Subject: [PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock In-Reply-To: References: Message-ID: jfb accepted this revision. jfb added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:123 +def warn_fe_serialized_diag_failure_during_finalisation : Warning< + "Received warning after diagnostic serialisation teardown was underway: %0">, + InGroup; ---------------- ``` $ git grep -i "serializ" | wc -l 6053 $ git grep -i "serialis" | wc -l 5 ``` **Z** it is 😉 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83509/new/ https://reviews.llvm.org/D83509 From cfe-commits at lists.llvm.org Thu Jul 9 14:30:25 2020 From: cfe-commits at lists.llvm.org (Oliver Hunt via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:30:25 +0000 (UTC) Subject: [PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock In-Reply-To: References: Message-ID: <10be6e359d7b0d18f41abf6ca4bf9ad1@localhost.localdomain> ojhunt updated this revision to Diff 276837. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83509/new/ https://reviews.llvm.org/D83509 Files: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/lib/Frontend/SerializedDiagnosticPrinter.cpp Index: clang/lib/Frontend/SerializedDiagnosticPrinter.cpp =================================================================== --- clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -239,6 +239,9 @@ /// generated from child processes. bool MergeChildRecords; + /// Whether we've started finishing and tearing down this instance. + bool IsFinishing = false; + /// State that is shared among the various clones of this diagnostic /// consumer. struct SharedState { @@ -568,6 +571,17 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) { + assert(!IsFinishing && + "Received a diagnostic after we've already started teardown."); + if (IsFinishing) { + SmallString<256> diagnostic; + Info.FormatDiagnostic(diagnostic); + getMetaDiags()->Report( + diag::warn_fe_serialized_diag_failure_during_finalisation) + << diagnostic; + return; + } + // Enter the block for a non-note diagnostic immediately, rather than waiting // for beginDiagnostic, in case associated notes are emitted before we get // there. @@ -761,6 +775,9 @@ } void SDiagsWriter::finish() { + assert(!IsFinishing); + IsFinishing = true; + // The original instance is responsible for writing the file. if (!OriginalInstance) return; @@ -786,12 +803,20 @@ if (EC) { getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure) << State->OutputFile << EC.message(); + OS->clear_error(); return; } // Write the generated bitstream to "Out". OS->write((char *)&State->Buffer.front(), State->Buffer.size()); OS->flush(); + + assert(!OS->has_error()); + if (OS->has_error()) { + getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure) + << State->OutputFile << OS->error().message(); + OS->clear_error(); + } } std::error_code SDiagsMerger::visitStartOfDiagnostic() { Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -119,6 +119,9 @@ def warn_fe_serialized_diag_failure : Warning< "unable to open file %0 for serializing diagnostics (%1)">, InGroup; +def warn_fe_serialized_diag_failure_during_finalisation : Warning< + "Received warning after diagnostic serialization teardown was underway: %0">, + InGroup; def err_verify_missing_line : Error< "missing or invalid line number following '@' in expected %0">; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83509.276837.patch Type: text/x-patch Size: 2721 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:33:57 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:33:57 +0000 (UTC) Subject: [PATCH] D83511: [clangd] Config: If.PathExclude Message-ID: sammccall created this revision. sammccall added a reviewer: hokein. Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83511 Files: clang-tools-extra/clangd/ConfigCompile.cpp clang-tools-extra/clangd/ConfigFragment.h clang-tools-extra/clangd/ConfigYAML.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -67,6 +67,13 @@ EXPECT_TRUE(compileAndApply()); EXPECT_THAT(Diags.Diagnostics, IsEmpty()); + // Excluded regex. + Frag = {}; + Frag.If.PathMatch.emplace_back("b.*"); + Frag.If.PathExclude.emplace_back(".*r"); + EXPECT_FALSE(compileAndApply()); + EXPECT_THAT(Diags.Diagnostics, IsEmpty()); + // Invalid regex. Frag = {}; Frag.If.PathMatch.emplace_back("**]@theu"); Index: clang-tools-extra/clangd/ConfigYAML.cpp =================================================================== --- clang-tools-extra/clangd/ConfigYAML.cpp +++ clang-tools-extra/clangd/ConfigYAML.cpp @@ -50,6 +50,10 @@ if (auto Values = scalarValues(N)) F.PathMatch = std::move(*Values); }); + Dict.handle("PathExclude", [&](Node &N) { + if (auto Values = scalarValues(N)) + F.PathExclude = std::move(*Values); + }); Dict.parse(N); } Index: clang-tools-extra/clangd/ConfigFragment.h =================================================================== --- clang-tools-extra/clangd/ConfigFragment.h +++ clang-tools-extra/clangd/ConfigFragment.h @@ -108,6 +108,9 @@ struct IfBlock { /// The file being processed must fully match a regular expression. std::vector> PathMatch; + /// The file being processed must *not* fully match a regular expression. + std::vector> PathExclude; + /// An unrecognized key was found while parsing the condition. /// The condition will evaluate to false. bool HasUnrecognizedCondition = false; Index: clang-tools-extra/clangd/ConfigCompile.cpp =================================================================== --- clang-tools-extra/clangd/ConfigCompile.cpp +++ clang-tools-extra/clangd/ConfigCompile.cpp @@ -103,6 +103,22 @@ }); }); } + + auto PathExclude = std::make_unique>(); + for (auto &Entry : F.PathExclude) { + if (auto RE = compileRegex(Entry)) + PathExclude->push_back(std::move(*RE)); + } + if (!PathExclude->empty()) { + Out.Conditions.push_back( + [PathExclude(std::move(PathExclude))](const Params &P) { + if (P.Path.empty()) + return false; + return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) { + return RE.match(P.Path); + }); + }); + } } void compile(Fragment::CompileFlagsBlock &&F) { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83511.276839.patch Type: text/x-patch Size: 2691 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:37:27 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:37:27 +0000 (UTC) Subject: [PATCH] D83513: [AST][ObjC] Fix crash when printing invalid objc categories Message-ID: dgoldman created this revision. dgoldman added reviewers: sammccall, gribozavr. Herald added a project: clang. Herald added a subscriber: cfe-commits. If no valid interface definition was found previously we would crash. With this change instead we just print `<>` in place of the NULL interface. In the future this could be improved by saving the invalid interface's name and using that. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83513 Files: clang/lib/AST/DeclPrinter.cpp clang/unittests/AST/DeclPrinterTest.cpp Index: clang/unittests/AST/DeclPrinterTest.cpp =================================================================== --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -76,14 +76,16 @@ PrintedDeclMatches(StringRef Code, const std::vector &Args, const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted, StringRef FileName, - PrintingPolicyModifier PolicyModifier = nullptr) { + PrintingPolicyModifier PolicyModifier = nullptr, + bool AllowError = false) { PrintMatch Printer(PolicyModifier); MatchFinder Finder; Finder.addMatcher(NodeMatch, &Printer); std::unique_ptr Factory( newFrontendActionFactory(&Finder)); - if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName) && + !AllowError) return testing::AssertionFailure() << "Parsing error in \"" << Code.str() << "\""; @@ -170,16 +172,12 @@ "input.cc"); } -::testing::AssertionResult PrintedDeclObjCMatches( - StringRef Code, - const DeclarationMatcher &NodeMatch, - StringRef ExpectedPrinted) { +::testing::AssertionResult +PrintedDeclObjCMatches(StringRef Code, const DeclarationMatcher &NodeMatch, + StringRef ExpectedPrinted, bool AllowError = false) { std::vector Args(1, ""); - return PrintedDeclMatches(Code, - Args, - NodeMatch, - ExpectedPrinted, - "input.m"); + return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, "input.m", + /*PolicyModifier*/ nullptr, AllowError); } } // unnamed namespace @@ -1321,3 +1319,17 @@ namedDecl(hasName("P1")).bind("id"), "@protocol P1\n at end")); } + +TEST(DeclPrinter, TestObjCCategoryInvalidInterface) { + ASSERT_TRUE(PrintedDeclObjCMatches( + "@interface I (Extension) @end", + namedDecl(hasName("Extension")).bind("id"), + "@interface <>(Extension)\n at end", /*AllowError*/ true)); +} + +TEST(DeclPrinter, TestObjCCategoryImplInvalidInterface) { + ASSERT_TRUE(PrintedDeclObjCMatches( + "@implementation I (Extension) @end", + namedDecl(hasName("Extension")).bind("id"), + "@implementation <>(Extension)\n at end", /*AllowError*/ true)); +} Index: clang/lib/AST/DeclPrinter.cpp =================================================================== --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -1374,7 +1374,12 @@ } void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { - Out << "@implementation " << *PID->getClassInterface() << '(' << *PID <<")\n"; + Out << "@implementation "; + if (const auto *CID = PID->getClassInterface()) + Out << *CID; + else + Out << "<>"; + Out << '(' << *PID << ")\n"; VisitDeclContext(PID, false); Out << "@end"; @@ -1382,7 +1387,11 @@ } void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) { - Out << "@interface " << *PID->getClassInterface(); + Out << "@interface "; + if (const auto *CID = PID->getClassInterface()) + Out << *CID; + else + Out << "<>"; if (auto TypeParams = PID->getTypeParamList()) { PrintObjCTypeParams(TypeParams); } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83513.276841.patch Type: text/x-patch Size: 3581 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:41:34 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:41:34 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. In-Reply-To: References: Message-ID: amyk marked 3 inline comments as done. amyk added inline comments. ================ Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14273 + // The third argument to vec_replace_elt will be emitted to either + // the vinsw or vinsd instruction. It must be a compile time constant. + ConstantInt *ArgCI = dyn_cast(Ops[2]); ---------------- lei wrote: > Do you mean? > ``` > // The third argument of vec_replace_elt must be a compile time constant and will be emitted either > // to the vinsw or vinsd instruction. > ``` Yes. Thank you - I will update the wording here and in the other builtin. ================ Comment at: clang/lib/CodeGen/CGBuiltin.cpp:14320 + Call = Builder.CreateCall(F, Ops); + } + return Call; ---------------- lei wrote: > What are the chances of reaching to the end of this if/else-if section and `Call` is null? ie `getPrimitiveSizeInBits() != [32|64]` > I feel like it would be better if we can structure it so that we are not doing all these nesting of `if`s and just do returns within the diff if-conditions. > > Have you tried to pull out the diff handling of 32/64bit arg and consolidating the code a bit? Thanks - I realize that I should probably pull the `Call` out. I'll update this. I've actually consolidated the code quite a bit already, but I'll see if I can make any further improvements on this. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83500/new/ https://reviews.llvm.org/D83500 From cfe-commits at lists.llvm.org Thu Jul 9 14:42:20 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:42:20 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. In-Reply-To: References: Message-ID: <257f42a44fb80db7ce07976b9eb15032@localhost.localdomain> amyk updated this revision to Diff 276844. amyk added a comment. Address review comments - update comments - pull out common code Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83500/new/ https://reviews.llvm.org/D83500 Files: clang/include/clang/Basic/BuiltinsPPC.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83500.276844.patch Type: text/x-patch Size: 12137 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 14:45:37 2020 From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:45:37 +0000 (UTC) Subject: [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional. In-Reply-To: References: Message-ID: michele.scandale added a comment. I tested locally the standalone build of Clang with D83426 . I just want to make sure that we all agree this is right way moving forward. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83454/new/ https://reviews.llvm.org/D83454 From cfe-commits at lists.llvm.org Thu Jul 9 14:55:11 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:55:11 +0000 (UTC) Subject: [PATCH] D82436: [clangd] Implement textDocument/foldingRange In-Reply-To: References: Message-ID: <21d57586c8da9566a16841593f02ddd8@localhost.localdomain> sammccall added a comment. In D82436#2142631 , @kbobyrev wrote: > In D82436#2141953 , @sammccall wrote: > > > Tests :-) > > > I was hoping glorious DocumentSymbols super tested API would shield me from that :P While the implementation is shared, a very small set of tests is fine. We should at least include some of the ranges that are "incorrect" that we want to fix. > Didn't think of reasonable testing strategy but fair enough, will do! I think you can literally just use an `Annotations` marked with all the ranges you expect. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82436/new/ https://reviews.llvm.org/D82436 From cfe-commits at lists.llvm.org Thu Jul 9 14:56:11 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:56:11 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <1827586b486402f8abe14fbcd68c79c5@localhost.localdomain> MaskRay accepted this revision. MaskRay added a comment. LG with some nits ================ Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3287 + if (Args.hasArg(OPT_fexperimental_strict_floating_point)) { + Opts.ExpStrictFP = true; + } ---------------- Delete redundant braces ================ Comment at: clang/test/CodeGen/fp-strictfp.cpp:12 +float fp_precise_1(float a, float b, float c) { +// CHECK: _Z12fp_precise_1fff +// CHECK: %[[M:.+]] = fmul float{{.*}} ---------------- Append a punctuation, i.e. `_Z12fp_precise_1fff:` ================ Comment at: clang/test/CodeGen/fp-strictfp.cpp:17 +} + + ---------------- Delete trailing empty lines CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Thu Jul 9 14:57:58 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 21:57:58 +0000 (UTC) Subject: [PATCH] D83514: [Lexer] Fix missing coverage line after #endif Message-ID: zequanwu created this revision. zequanwu added reviewers: vsk, efriedma, arphaman. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang. bug reported here: https://bugs.llvm.org/show_bug.cgi?id=46660 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83514 Files: clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83514.276846.patch Type: text/x-patch Size: 3479 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:06:28 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:06:28 +0000 (UTC) Subject: [PATCH] D83364: [PowerPC][Power10] Implement Instruction definition and MC Tests for Load and Store VSX Vector with Zero or Sign Extend In-Reply-To: References: Message-ID: <03a5a5fc2cf660838a6b56764042e2e0@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG5ffec4672028: [PowerPC][Power10] Add Instruction definition/MC Tests for Load/Store Rightmost… (authored by Conanap, committed by amyk). Changed prior to commit: https://reviews.llvm.org/D83364?vs=276564&id=276850#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83364/new/ https://reviews.llvm.org/D83364 Files: llvm/lib/Target/PowerPC/PPCInstrPrefix.td llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s Index: llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s =================================================================== --- llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s +++ llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s @@ -405,3 +405,27 @@ # CHECK-BE: vinsdrx 1, 2, 3 # encoding: [0x10,0x22,0x1b,0xcf] # CHECK-LE: vinsdrx 1, 2, 3 # encoding: [0xcf,0x1b,0x22,0x10] vinsdrx 1, 2, 3 +# CHECK-BE: lxvrbx 32, 1, 2 # encoding: [0x7c,0x01,0x10,0x1b] +# CHECK-LE: lxvrbx 32, 1, 2 # encoding: [0x1b,0x10,0x01,0x7c] + lxvrbx 32, 1, 2 +# CHECK-BE: lxvrhx 33, 1, 2 # encoding: [0x7c,0x21,0x10,0x5b] +# CHECK-LE: lxvrhx 33, 1, 2 # encoding: [0x5b,0x10,0x21,0x7c] + lxvrhx 33, 1, 2 +# CHECK-BE: lxvrdx 34, 1, 2 # encoding: [0x7c,0x41,0x10,0xdb] +# CHECK-LE: lxvrdx 34, 1, 2 # encoding: [0xdb,0x10,0x41,0x7c] + lxvrdx 34, 1, 2 +# CHECK-BE: lxvrwx 35, 1, 2 # encoding: [0x7c,0x61,0x10,0x9b] +# CHECK-LE: lxvrwx 35, 1, 2 # encoding: [0x9b,0x10,0x61,0x7c] + lxvrwx 35, 1, 2 +# CHECK-BE: stxvrbx 32, 3, 1 # encoding: [0x7c,0x03,0x09,0x1b] +# CHECK-LE: stxvrbx 32, 3, 1 # encoding: [0x1b,0x09,0x03,0x7c] + stxvrbx 32, 3, 1 +# CHECK-BE: stxvrhx 33, 3, 1 # encoding: [0x7c,0x23,0x09,0x5b] +# CHECK-LE: stxvrhx 33, 3, 1 # encoding: [0x5b,0x09,0x23,0x7c] + stxvrhx 33, 3, 1 +# CHECK-BE: stxvrwx 34, 3, 1 # encoding: [0x7c,0x43,0x09,0x9b] +# CHECK-LE: stxvrwx 34, 3, 1 # encoding: [0x9b,0x09,0x43,0x7c] + stxvrwx 34, 3, 1 +# CHECK-BE: stxvrdx 35, 3, 1 # encoding: [0x7c,0x63,0x09,0xdb] +# CHECK-LE: stxvrdx 35, 3, 1 # encoding: [0xdb,0x09,0x63,0x7c] + stxvrdx 35, 3, 1 Index: llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt =================================================================== --- llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt +++ llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt @@ -278,3 +278,27 @@ # CHECK: vinsdrx 1, 2, 3 0x10 0x22 0x1b 0xcf + +# CHECK: lxvrbx 32, 1, 2 +0x7c 0x01 0x10 0x1b + +# CHECK: lxvrhx 33, 1, 2 +0x7c 0x21 0x10 0x5b + +# CHECK: lxvrdx 34, 1, 2 +0x7c 0x41 0x10 0xdb + +# CHECK: lxvrwx 35, 1, 2 +0x7c 0x61 0x10 0x9b + +# CHECK: stxvrbx 32, 3, 1 +0x7c 0x03 0x09 0x1b + +# CHECK: stxvrhx 33, 3, 1 +0x7c 0x23 0x09 0x5b + +# CHECK: stxvrwx 34, 3, 1 +0x7c 0x43 0x09 0x9b + +# CHECK: stxvrdx 35, 3, 1 +0x7c 0x63 0x09 0xdb Index: llvm/lib/Target/PowerPC/PPCInstrPrefix.td =================================================================== --- llvm/lib/Target/PowerPC/PPCInstrPrefix.td +++ llvm/lib/Target/PowerPC/PPCInstrPrefix.td @@ -942,8 +942,26 @@ "vclrrb $vD, $vA, $rB", IIC_VecGeneral, [(set v16i8:$vD, (int_ppc_altivec_vclrrb v16i8:$vA, i32:$rB))]>; + + // The XFormMemOp flag for the following 8 instructions is set on + // the instruction format. + let mayLoad = 1, mayStore = 0 in { + def LXVRBX : X_XT6_RA5_RB5<31, 13, "lxvrbx", vsrc, []>; + def LXVRHX : X_XT6_RA5_RB5<31, 45, "lxvrhx", vsrc, []>; + def LXVRWX : X_XT6_RA5_RB5<31, 77, "lxvrwx", vsrc, []>; + def LXVRDX : X_XT6_RA5_RB5<31, 109, "lxvrdx", vsrc, []>; + } + + let mayLoad = 0, mayStore = 1 in { + def STXVRBX : X_XS6_RA5_RB5<31, 141, "stxvrbx", vsrc, []>; + def STXVRHX : X_XS6_RA5_RB5<31, 173, "stxvrhx", vsrc, []>; + def STXVRWX : X_XS6_RA5_RB5<31, 205, "stxvrwx", vsrc, []>; + def STXVRDX : X_XS6_RA5_RB5<31, 237, "stxvrdx", vsrc, []>; + } } + + //---------------------------- Anonymous Patterns ----------------------------// let Predicates = [IsISA3_1] in { def : Pat<(v16i8 (int_ppc_vsx_xxgenpcvbm v16i8:$VRB, imm:$IMM)), -------------- next part -------------- A non-text attachment was scrubbed... Name: D83364.276850.patch Type: text/x-patch Size: 4059 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:06:46 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:06:46 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <182116802b3b78a995269d34e85fb8f7@localhost.localdomain> kpn marked 3 inline comments as done. kpn added a comment. Thanks for the reviews and the fast turnaround! I do appreciate it! CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Thu Jul 9 15:07:02 2020 From: cfe-commits at lists.llvm.org (Vedant Kumar via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:07:02 +0000 (UTC) Subject: [PATCH] D83514: [Lexer] Fix missing coverage line after #endif In-Reply-To: References: Message-ID: <8503ad6edee50d9d7845fcdd3ae75bfe@localhost.localdomain> vsk accepted this revision. vsk added a comment. This revision is now accepted and ready to land. Lgtm, thanks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83514/new/ https://reviews.llvm.org/D83514 From cfe-commits at lists.llvm.org Thu Jul 9 15:15:46 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via cfe-commits) Date: Thu, 09 Jul 2020 15:15:46 -0700 (PDT) Subject: [clang] 672ae62 - [Lexer] Fix missing coverage line after #endif Message-ID: <5f079712.1c69fb81.d73af.9c40@mx.google.com> Author: Zequan Wu Date: 2020-07-09T15:15:40-07:00 New Revision: 672ae621e91ff5cdefb2535bdd530641536685ea URL: https://github.com/llvm/llvm-project/commit/672ae621e91ff5cdefb2535bdd530641536685ea DIFF: https://github.com/llvm/llvm-project/commit/672ae621e91ff5cdefb2535bdd530641536685ea.diff LOG: [Lexer] Fix missing coverage line after #endif Summary: bug reported here: https://bugs.llvm.org/show_bug.cgi?id=46660 Reviewers: vsk, efriedma, arphaman Reviewed By: vsk Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83514 Added: Modified: clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c Removed: ################################################################################ diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 396ba529fc9a..17dc64b93a99 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -432,6 +432,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Skip to the next '#endif' / '#else' / '#elif'. CurLexer->skipOver(*SkipLength); } + SourceLocation endifLoc; while (true) { CurLexer->Lex(Tok); @@ -538,7 +539,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Restore the value of LexingRawMode so that trailing comments // are handled correctly, if we've reached the outermost block. CurPPLexer->LexingRawMode = false; - CheckEndOfDirective("endif"); + endifLoc = CheckEndOfDirective("endif"); CurPPLexer->LexingRawMode = true; if (Callbacks) Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc); @@ -621,7 +622,9 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // by the end of the preamble; we'll resume parsing after the preamble. if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble())) Callbacks->SourceRangeSkipped( - SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()), + SourceRange(HashTokenLoc, endifLoc.isValid() + ? endifLoc + : CurPPLexer->getSourceLocation()), Tok.getLocation()); } diff --git a/clang/test/CoverageMapping/preprocessor.c b/clang/test/CoverageMapping/preprocessor.c index b3ebc7bd4ec0..9225c9f162a2 100644 --- a/clang/test/CoverageMapping/preprocessor.c +++ b/clang/test/CoverageMapping/preprocessor.c @@ -3,7 +3,7 @@ // CHECK: func void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 int i = 0; -#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0 +#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0 int x = i; #endif } @@ -11,7 +11,7 @@ void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 // CHECK: main int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; -# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0 +# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0 if(i == 0) { i = 1; } @@ -22,44 +22,44 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 if(i == 0) { // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1 i = 1; } -#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0 +#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0 if(i == 1) { i = 0; } } #endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24 #\ if 0 #\ endif // also skipped #if 1 - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7 #\ elif 0 #endif #if 1 - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7 #\ else #endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8 #\ ifdef NOT_DEFINED #\ endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8 #\ ifndef __FILE__ #\ endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26 #\ ifdef NOT_DEFINED #\ From cfe-commits at lists.llvm.org Thu Jul 9 15:16:00 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:16:00 +0000 (UTC) Subject: [PATCH] D83514: [Lexer] Fix missing coverage line after #endif In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG672ae621e91f: [Lexer] Fix missing coverage line after #endif (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83514/new/ https://reviews.llvm.org/D83514 Files: clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83514.276851.patch Type: text/x-patch Size: 3479 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:20:28 2020 From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:20:28 +0000 (UTC) Subject: [PATCH] D83516: [PowerPC][Power10] RFC 2608 Instruction definitions and MC Tests Message-ID: Conanap created this revision. Conanap added reviewers: power-llvm-team, PowerPC, saghir, nemanjai, hfinkel. Conanap added projects: LLVM, clang, PowerPC. This implements instruction definitions and MC tests for RFC2608. Please note that some instrs have classes that will need to be changed later as their classes have not been implemented yet - they will be implemented in their respective patches. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83516 Files: llvm/lib/Target/PowerPC/PPCInstrPrefix.td llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s -------------- next part -------------- A non-text attachment was scrubbed... Name: D83516.276849.patch Type: text/x-patch Size: 11994 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:27:04 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:27:04 +0000 (UTC) Subject: [PATCH] D83500: [PowerPC][Power10] Implement custom codegen for the vec_replace_elt and vec_replace_unaligned builtins. In-Reply-To: References: Message-ID: <14f48b7d22bdcda2fae56bca63c89cd7@localhost.localdomain> amyk updated this revision to Diff 276853. amyk added a comment. Fix assignment of variable. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83500/new/ https://reviews.llvm.org/D83500 Files: clang/include/clang/Basic/BuiltinsPPC.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83500.276853.patch Type: text/x-patch Size: 12110 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:36:29 2020 From: cfe-commits at lists.llvm.org (Amy Huang via cfe-commits) Date: Thu, 09 Jul 2020 15:36:29 -0700 (PDT) Subject: [clang] 227db86 - Switch to using -debug-info-kind=constructor as default (from =limited) Message-ID: <5f079bed.1c69fb81.436ee.9313@mx.google.com> Author: Amy Huang Date: 2020-07-09T15:26:46-07:00 New Revision: 227db86a1b7dd6f96f7df14890fcd071bc4fe1f5 URL: https://github.com/llvm/llvm-project/commit/227db86a1b7dd6f96f7df14890fcd071bc4fe1f5 DIFF: https://github.com/llvm/llvm-project/commit/227db86a1b7dd6f96f7df14890fcd071bc4fe1f5.diff LOG: Switch to using -debug-info-kind=constructor as default (from =limited) Summary: -debug-info-kind=constructor reduces the amount of class debug info that is emitted; this patch switches to using this as the default. Constructor homing emits the complete type info for a class only when the constructor is emitted, so it is expected that there will be some classes that are not defined in the debug info anymore because they are never constructed, and we shouldn't need debug info for these classes. I compared the PDB files for clang, and there are 273 class types that are defined with `=limited` but not with `=constructor` (out of ~60,000 total class types). We've looked at a number of the types that are no longer defined with =constructor. The vast majority of cases are something like class A is used as a parameter in a member function of some other class B, which is emitted. But the function that uses class A is never called, and class A is never constructed, and therefore isn't emitted in the debug info. Bug: https://bugs.llvm.org/show_bug.cgi?id=46537 Subscribers: aprantl, cfe-commits, lldb-commits Tags: #clang, #lldb Differential Revision: https://reviews.llvm.org/D79147 Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-options.c clang/test/Driver/clang-g-opts.c clang/test/Driver/cuda-dwarf-2.cu clang/test/Driver/debug-options-as.c clang/test/Driver/debug-options.c clang/test/Driver/integrated-as.s clang/test/Driver/myriad-toolchain.c clang/test/Driver/openmp-offload-gpu.c clang/test/Driver/split-debug.c lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index ed365c608387..9b424beec428 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -498,7 +498,7 @@ static codegenoptions::DebugInfoKind DebugLevelToInfoKind(const Arg &A) { return codegenoptions::DebugLineTablesOnly; if (A.getOption().matches(options::OPT_gline_directives_only)) return codegenoptions::DebugDirectivesOnly; - return codegenoptions::LimitedDebugInfo; + return codegenoptions::DebugInfoConstructor; } static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) { @@ -2380,7 +2380,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, CmdArgs.push_back(Value.data()); } else { RenderDebugEnablingArgs(Args, CmdArgs, - codegenoptions::LimitedDebugInfo, + codegenoptions::DebugInfoConstructor, DwarfVersion, llvm::DebuggerKind::Default); } } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") || @@ -3653,7 +3653,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, if (const Arg *A = Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf, options::OPT_gsplit_dwarf_EQ)) { - DebugInfoKind = codegenoptions::LimitedDebugInfo; + DebugInfoKind = codegenoptions::DebugInfoConstructor; // If the last option explicitly specified a debug-info level, use it. if (checkDebugInfoOption(A, Args, D, TC) && @@ -3758,7 +3758,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, if (checkDebugInfoOption(A, Args, D, TC)) { if (DebugInfoKind != codegenoptions::DebugLineTablesOnly && DebugInfoKind != codegenoptions::DebugDirectivesOnly) { - DebugInfoKind = codegenoptions::LimitedDebugInfo; + DebugInfoKind = codegenoptions::DebugInfoConstructor; CmdArgs.push_back("-dwarf-ext-refs"); CmdArgs.push_back("-fmodule-format=obj"); } @@ -3778,7 +3778,9 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, TC.GetDefaultStandaloneDebug()); if (const Arg *A = Args.getLastArg(options::OPT_fstandalone_debug)) (void)checkDebugInfoOption(A, Args, D, TC); - if (DebugInfoKind == codegenoptions::LimitedDebugInfo && NeedFullDebug) + if ((DebugInfoKind == codegenoptions::LimitedDebugInfo || + DebugInfoKind == codegenoptions::DebugInfoConstructor) && + NeedFullDebug) DebugInfoKind = codegenoptions::FullDebugInfo; if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source, @@ -6552,7 +6554,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, options::OPT_gline_tables_only)) { *EmitCodeView = true; if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7)) - *DebugInfoKind = codegenoptions::LimitedDebugInfo; + *DebugInfoKind = codegenoptions::DebugInfoConstructor; else *DebugInfoKind = codegenoptions::DebugLineTablesOnly; } else { @@ -6849,7 +6851,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, // the guard for source type, however there is a test which asserts // that some assembler invocation receives no -debug-info-kind, // and it's not clear whether that test is just overly restrictive. - DebugInfoKind = (WantDebug ? codegenoptions::LimitedDebugInfo + DebugInfoKind = (WantDebug ? codegenoptions::DebugInfoConstructor : codegenoptions::NoDebugInfo); // Add the -fdebug-compilation-dir flag if needed. addDebugCompDirArg(Args, CmdArgs, C.getDriver().getVFS()); diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index d0c48ae41d9a..0dcaf6108806 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -524,11 +524,11 @@ // RUN: %clang_cl /Zi /c -### -- %s 2>&1 | FileCheck -check-prefix=Zi %s // Zi: "-gcodeview" -// Zi: "-debug-info-kind=limited" +// Zi: "-debug-info-kind=constructor" // RUN: %clang_cl /Z7 /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7 %s // Z7: "-gcodeview" -// Z7: "-debug-info-kind=limited" +// Z7: "-debug-info-kind=constructor" // RUN: %clang_cl /Zd /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7GMLT %s // Z7GMLT: "-gcodeview" @@ -557,7 +557,7 @@ // which made it "win". This test could not detect that bug. // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s // Z7_gdwarf: "-gcodeview" -// Z7_gdwarf: "-debug-info-kind=limited" +// Z7_gdwarf: "-debug-info-kind=constructor" // Z7_gdwarf: "-dwarf-version=4" // RUN: %clang_cl -fmsc-version=1800 -TP -### -- %s 2>&1 | FileCheck -check-prefix=CXX11 %s diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c index bc714b6c9379..60c97790b7da 100644 --- a/clang/test/Driver/clang-g-opts.c +++ b/clang/test/Driver/clang-g-opts.c @@ -31,7 +31,7 @@ // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s // CHECK-WITHOUT-G-NOT: -debug-info-kind -// CHECK-WITH-G: "-debug-info-kind=limited" +// CHECK-WITH-G: "-debug-info-kind=constructor" // CHECK-WITH-G: "-dwarf-version=4" // CHECK-WITH-G-DWARF2: "-dwarf-version=2" diff --git a/clang/test/Driver/cuda-dwarf-2.cu b/clang/test/Driver/cuda-dwarf-2.cu index bcfb2444bc51..92b8919729fc 100644 --- a/clang/test/Driver/cuda-dwarf-2.cu +++ b/clang/test/Driver/cuda-dwarf-2.cu @@ -49,7 +49,7 @@ // HAS_DEBUG-NOT: warning: debug // HAS_DEBUG: "-fcuda-is-device" -// HAS_DEBUG-SAME: "-debug-info-kind={{limited|line-tables-only}}" +// HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}" // HAS_DEBUG-SAME: "-dwarf-version=2" // HAS_DEBUG: ptxas // HAS_DEBUG-SAME: "-g" diff --git a/clang/test/Driver/debug-options-as.c b/clang/test/Driver/debug-options-as.c index 51475680e9b1..4808219702e7 100644 --- a/clang/test/Driver/debug-options-as.c +++ b/clang/test/Driver/debug-options-as.c @@ -23,7 +23,7 @@ // RUN: | FileCheck %s // // CHECK: "-cc1as" -// CHECK: "-debug-info-kind=limited" +// CHECK: "-debug-info-kind=constructor" // Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer. // rdar://12955296 diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 189c1f9addeb..2d1a0b2d5cd8 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -274,18 +274,18 @@ // GLIO_ONLY_DWARF2: "-dwarf-version=2" // // G_ONLY: "-cc1" -// G_ONLY: "-debug-info-kind=limited" +// G_ONLY: "-debug-info-kind=constructor" // // These tests assert that "-gline-tables-only" "-g" uses the latter, // but otherwise not caring about the DebugInfoKind. // G_ONLY_DWARF2: "-cc1" -// G_ONLY_DWARF2: "-debug-info-kind={{standalone|limited}}" +// G_ONLY_DWARF2: "-debug-info-kind={{standalone|constructor}}" // G_ONLY_DWARF2: "-dwarf-version=2" // // G_STANDALONE: "-cc1" // G_STANDALONE: "-debug-info-kind=standalone" // G_LIMITED: "-cc1" -// G_LIMITED: "-debug-info-kind=limited" +// G_LIMITED: "-debug-info-kind=constructor" // G_DWARF2: "-dwarf-version=2" // G_DWARF4: "-dwarf-version=4" // @@ -339,7 +339,7 @@ // NOCI: "-gno-column-info" // // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj" -// GEXTREFS: "-debug-info-kind={{standalone|limited}}" +// GEXTREFS: "-debug-info-kind={{standalone|constructor}}" // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind' diff --git a/clang/test/Driver/integrated-as.s b/clang/test/Driver/integrated-as.s index 0194a3d5a438..05999cfe002b 100644 --- a/clang/test/Driver/integrated-as.s +++ b/clang/test/Driver/integrated-as.s @@ -27,19 +27,19 @@ // XA_INCLUDE2: "-Ifoo_dir" // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-4 -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2 %s -// DWARF2: "-debug-info-kind=limited" "-dwarf-version=2" +// DWARF2: "-debug-info-kind=constructor" "-dwarf-version=2" // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-3 2>&1 | FileCheck --check-prefix=DWARF3 %s -// DWARF3: "-debug-info-kind=limited" "-dwarf-version=3" +// DWARF3: "-debug-info-kind=constructor" "-dwarf-version=3" // RUN: %clang -### -target x86_64--- -c -integrated-as %s -gdwarf-4 2>&1 | FileCheck --check-prefix=DWARF4 %s -// DWARF4: "-debug-info-kind=limited" "-dwarf-version=4" +// DWARF4: "-debug-info-kind=constructor" "-dwarf-version=4" // RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2XASSEMBLER %s -// DWARF2XASSEMBLER: "-debug-info-kind=limited" "-dwarf-version=2" +// DWARF2XASSEMBLER: "-debug-info-kind=constructor" "-dwarf-version=2" // RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2WA %s -// DWARF2WA: "-debug-info-kind=limited" "-dwarf-version=2" +// DWARF2WA: "-debug-info-kind=constructor" "-dwarf-version=2" // A dwarf version number that driver can't parse is just stuffed in. // RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-gdwarf-huh 2>&1 | FileCheck --check-prefix=BOGODWARF %s diff --git a/clang/test/Driver/myriad-toolchain.c b/clang/test/Driver/myriad-toolchain.c index 215a02fd0dec..a4bd260a1498 100644 --- a/clang/test/Driver/myriad-toolchain.c +++ b/clang/test/Driver/myriad-toolchain.c @@ -83,7 +83,7 @@ // NOSTDLIB-NOT: "-lc" // RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck -check-prefix=G_SPARC %s -// G_SPARC: "-debug-info-kind=limited" "-dwarf-version=2" +// G_SPARC: "-debug-info-kind=constructor" "-dwarf-version=2" // RUN: %clang -### -c %s -target sparc-myriad-rtems -fuse-init-array 2>&1 \ // RUN: | FileCheck -check-prefix=USE-INIT-ARRAY %s diff --git a/clang/test/Driver/openmp-offload-gpu.c b/clang/test/Driver/openmp-offload-gpu.c index 6415f1d61b72..3ddd6446d117 100644 --- a/clang/test/Driver/openmp-offload-gpu.c +++ b/clang/test/Driver/openmp-offload-gpu.c @@ -241,7 +241,7 @@ // HAS_DEBUG-NOT: warning: debug // HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda" -// HAS_DEBUG-SAME: "-debug-info-kind={{limited|line-tables-only}}" +// HAS_DEBUG-SAME: "-debug-info-kind={{constructor|line-tables-only}}" // HAS_DEBUG-SAME: "-dwarf-version=2" // HAS_DEBUG-SAME: "-fopenmp-is-device" // HAS_DEBUG: ptxas diff --git a/clang/test/Driver/split-debug.c b/clang/test/Driver/split-debug.c index d40207d5ae3b..70f8d91d48e0 100644 --- a/clang/test/Driver/split-debug.c +++ b/clang/test/Driver/split-debug.c @@ -68,18 +68,18 @@ // RUN: FileCheck -check-prefix=CHECK-NOINLINE-WITHOUT-SPLIT < %t %s // // CHECK-NOINLINE-WITHOUT-SPLIT: "-fno-split-dwarf-inlining" -// CHECK-NOINLINE-WITHOUT-SPLIT: "-debug-info-kind=limited" +// CHECK-NOINLINE-WITHOUT-SPLIT: "-debug-info-kind=constructor" // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-GMLT < %t %s // -// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=limited" +// CHECK-SPLIT-WITH-GMLT: "-debug-info-kind=constructor" // CHECK-SPLIT-WITH-GMLT: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -fno-split-dwarf-inlining -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SPLIT-WITH-NOINL < %t %s // -// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=limited" +// CHECK-SPLIT-WITH-NOINL: "-debug-info-kind=constructor" // CHECK-SPLIT-WITH-NOINL: "-split-dwarf-output" // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -gmlt -fsplit-dwarf-inlining -S -### %s 2> %t @@ -92,7 +92,7 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -gmlt -gsplit-dwarf -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-GMLT < %t %s // -// CHECK-SPLIT-OVER-GMLT: "-debug-info-kind=limited" +// CHECK-SPLIT-OVER-GMLT: "-debug-info-kind=constructor" // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-file" // CHECK-SPLIT-OVER-GMLT: "-split-dwarf-output" @@ -117,6 +117,6 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -g0 -gsplit-dwarf=split -S -### %s 2> %t // RUN: FileCheck -check-prefix=CHECK-SPLIT-OVER-G0 < %t %s // -// CHECK-SPLIT-OVER-G0: "-debug-info-kind=limited" +// CHECK-SPLIT-OVER-G0: "-debug-info-kind=constructor" // CHECK-SPLIT-OVER-G0: "-split-dwarf-file" // CHECK-SPLIT-OVER-G0: "-split-dwarf-output" diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp index 3c4b005cdf1b..503939680c50 100644 --- a/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp @@ -106,6 +106,7 @@ class Class : public Base { // Test base class. int main() { MemberTest::Base B1; B1.Get(); + MemberTest::Class C1; MemberTest::Class::StaticMemberFunc(1, 10, 2); return 0; } From cfe-commits at lists.llvm.org Thu Jul 9 15:36:42 2020 From: cfe-commits at lists.llvm.org (Amy Huang via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:36:42 +0000 (UTC) Subject: [PATCH] D79147: Switch to using -debug-info-kind=constructor as default (from =limited) In-Reply-To: References: Message-ID: <5ead4844a6d7050058514ff4e304bc6e@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG227db86a1b7d: Switch to using -debug-info-kind=constructor as default (from =limited) (authored by akhuang). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79147/new/ https://reviews.llvm.org/D79147 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/cl-options.c clang/test/Driver/clang-g-opts.c clang/test/Driver/cuda-dwarf-2.cu clang/test/Driver/debug-options-as.c clang/test/Driver/debug-options.c clang/test/Driver/integrated-as.s clang/test/Driver/myriad-toolchain.c clang/test/Driver/openmp-offload-gpu.c clang/test/Driver/split-debug.c lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D79147.276855.patch Type: text/x-patch Size: 12383 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:43:07 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:43:07 +0000 (UTC) Subject: [PATCH] D83338: [PowerPC][Power10] Implemented Vector Shift Builtins In-Reply-To: References: Message-ID: <0477a55aca3de69040ce49df62fb499e@localhost.localdomain> amyk requested changes to this revision. amyk added a comment. This revision now requires changes to proceed. This will need to be rebased against your 2608 instruction definitions patch. But yes, I believe you are missing the clang and llc test case for this patch. Requesting changes due to missing tests. ================ Comment at: clang/lib/Headers/altivec.h:17099 + +/* vector shifts for quadwords */ +static __inline__ vector unsigned __int128 __ATTRS_o_ai ---------------- `/* vs[l | r | raq] */` (with a new line after the comment) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83338/new/ https://reviews.llvm.org/D83338 From cfe-commits at lists.llvm.org Thu Jul 9 15:44:56 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:44:56 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: <58e332eaba501233ab3598754d8fa12c@localhost.localdomain> ahatanak updated this revision to Diff 276858. ahatanak added a comment. Add test case for `trivial_abi`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 Files: clang/lib/CodeGen/CGVTables.cpp clang/test/CodeGenCXX/trivial_abi.cpp clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm Index: clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm =================================================================== --- clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm +++ clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm @@ -178,3 +178,32 @@ void testCallContainsNonTrivial(ContainsNonTrivial *a) { testParamContainsNonTrivial(*a); } + +namespace testThunk { + +// CHECK-LABEL: define i64 @_ZThn8_N9testThunk2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN9testThunk2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i8* +// CHECK: store i8* %[[COERCE_VAL_IP]], i8** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i8*, i8** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i8* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +struct B0 { + virtual Strong m0(); +}; + +struct B1 { + virtual Strong m0(); +}; + +struct D0 : B0, B1 { + Strong m0() override; +}; + +Strong D0::m0() { return {}; } + +} Index: clang/test/CodeGenCXX/trivial_abi.cpp =================================================================== --- clang/test/CodeGenCXX/trivial_abi.cpp +++ clang/test/CodeGenCXX/trivial_abi.cpp @@ -43,6 +43,31 @@ NonTrivial m; }; +struct B0 { + virtual Small m0(); +}; + +struct B1 { + virtual Small m0(); +}; + +struct D0 : B0, B1 { + Small m0() override; +}; + +// CHECK-LABEL: define i64 @_ZThn8_N2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i32* +// CHECK: store i32* %[[COERCE_VAL_IP]], i32** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i32*, i32** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i32* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +Small D0::m0() { return {}; } + // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]]) // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0 Index: clang/lib/CodeGen/CGVTables.cpp =================================================================== --- clang/lib/CodeGen/CGVTables.cpp +++ clang/lib/CodeGen/CGVTables.cpp @@ -363,7 +363,8 @@ : FPT->getReturnType(); ReturnValueSlot Slot; if (!ResultType->isVoidType() && - CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) + (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect || + hasAggregateEvaluationKind(ResultType))) Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified(), /*IsUnused=*/false, /*IsExternallyDestructed=*/true); -------------- next part -------------- A non-text attachment was scrubbed... Name: D82513.276858.patch Type: text/x-patch Size: 3318 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:51:17 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via cfe-commits) Date: Thu, 09 Jul 2020 15:51:17 -0700 (PDT) Subject: [clang] 8be204f - Revert "[Lexer] Fix missing coverage line after #endif" Message-ID: <5f079f65.1c69fb81.767e.6d9a@mx.google.com> Author: Zequan Wu Date: 2020-07-09T15:51:02-07:00 New Revision: 8be204fe75caac4ce6ed1e2cf5659011476bde79 URL: https://github.com/llvm/llvm-project/commit/8be204fe75caac4ce6ed1e2cf5659011476bde79 DIFF: https://github.com/llvm/llvm-project/commit/8be204fe75caac4ce6ed1e2cf5659011476bde79.diff LOG: Revert "[Lexer] Fix missing coverage line after #endif" This reverts commit 672ae621e91ff5cdefb2535bdd530641536685ea. Added: Modified: clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c Removed: ################################################################################ diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 17dc64b93a99..396ba529fc9a 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -432,7 +432,6 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Skip to the next '#endif' / '#else' / '#elif'. CurLexer->skipOver(*SkipLength); } - SourceLocation endifLoc; while (true) { CurLexer->Lex(Tok); @@ -539,7 +538,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Restore the value of LexingRawMode so that trailing comments // are handled correctly, if we've reached the outermost block. CurPPLexer->LexingRawMode = false; - endifLoc = CheckEndOfDirective("endif"); + CheckEndOfDirective("endif"); CurPPLexer->LexingRawMode = true; if (Callbacks) Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc); @@ -622,9 +621,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // by the end of the preamble; we'll resume parsing after the preamble. if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble())) Callbacks->SourceRangeSkipped( - SourceRange(HashTokenLoc, endifLoc.isValid() - ? endifLoc - : CurPPLexer->getSourceLocation()), + SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()), Tok.getLocation()); } diff --git a/clang/test/CoverageMapping/preprocessor.c b/clang/test/CoverageMapping/preprocessor.c index 9225c9f162a2..b3ebc7bd4ec0 100644 --- a/clang/test/CoverageMapping/preprocessor.c +++ b/clang/test/CoverageMapping/preprocessor.c @@ -3,7 +3,7 @@ // CHECK: func void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 int i = 0; -#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0 +#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0 int x = i; #endif } @@ -11,7 +11,7 @@ void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 // CHECK: main int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; -# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0 +# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0 if(i == 0) { i = 1; } @@ -22,44 +22,44 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 if(i == 0) { // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1 i = 1; } -#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0 +#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0 if(i == 1) { i = 0; } } #endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 #\ if 0 #\ endif // also skipped #if 1 - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 #\ elif 0 #endif #if 1 - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 #\ else #endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 #\ ifdef NOT_DEFINED #\ endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 #\ ifndef __FILE__ #\ endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1 #\ ifdef NOT_DEFINED #\ From cfe-commits at lists.llvm.org Thu Jul 9 15:52:15 2020 From: cfe-commits at lists.llvm.org (Arthur Eubanks via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:52:15 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager Message-ID: aeubanks created this revision. Herald added a reviewer: bollu. Herald added subscribers: llvm-commits, cfe-commits, jfb, dexonsmith, steven_wu, hiraditya. Herald added projects: clang, LLVM. This uses pass instrumentation callbacks to skip optional passes. PassInfoMixin now declares that passes inheriting from it are by default optional. Using RequiredPassInfoMixin overrides the pass to be required. The new OptNoneInstrumentation is part of StandardInstrumentations. The feature of skipping optional passes for optnone functions under NPM is gated on a -enable-npm-optnone flag. Currently it is by default false. That is because we still need to mark all required passes to be required. Otherwise optnone functions will start behaving incorrectly. After that is done in following changes, we can remove the flag and always enable this. All adaptors/managers must be required, since the pass(es) they are wrapping may be required. In the future, opt-bisect will use this same mechanmism of determining which passes are required/optional. Depends on D83498 . Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83519 Files: clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/Analysis/CGSCCPassManager.h llvm/include/llvm/IR/PassInstrumentation.h llvm/include/llvm/IR/PassManager.h llvm/include/llvm/IR/PassManagerInternal.h llvm/include/llvm/Passes/StandardInstrumentations.h llvm/include/llvm/Transforms/Scalar/LoopPassManager.h llvm/lib/IR/PassTimingInfo.cpp llvm/lib/LTO/LTOBackend.cpp llvm/lib/Passes/StandardInstrumentations.cpp llvm/test/Feature/optnone-opt.ll llvm/tools/opt/NewPMDriver.cpp llvm/unittests/IR/PassBuilderCallbacksTest.cpp polly/include/polly/ScopPass.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D83519.276860.patch Type: text/x-patch Size: 23684 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 15:54:37 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:54:37 +0000 (UTC) Subject: [PATCH] D83514: [Lexer] Fix missing coverage line after #endif In-Reply-To: References: Message-ID: <2a50f58896ad631ba5c201915443f9a3@localhost.localdomain> zequanwu reopened this revision. zequanwu added a comment. This revision is now accepted and ready to land. Reverted. It broke unit test SemanticHighlighting.GetsCorrectTokens in clangd. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83514/new/ https://reviews.llvm.org/D83514 From cfe-commits at lists.llvm.org Thu Jul 9 15:55:58 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 22:55:58 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: <5450df4e9d5c901cc8e021b2a594670b@localhost.localdomain> ahatanak added a comment. In D82513#2142596 , @rjmccall wrote: > This seems fine. I do wonder if the "real" bug is that this ought to be handled properly in EmitReturnFromThunk, but regardless, the fix seems acceptable. Since `EmitReturnFromThunk` is used only by `EmitCallAndReturnForThunk`, I think it's better to just avoid the copy in the first place. Perhaps we should teach `EmitReturnOfRValue` to handle aggregates with non-trivial copy or move assignments correctly, but it seems that it won't have any effect once we commit the changes in this patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 From cfe-commits at lists.llvm.org Thu Jul 9 16:13:02 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 23:13:02 +0000 (UTC) Subject: [PATCH] D79147: Switch to using -debug-info-kind=constructor as default (from =limited) In-Reply-To: References: Message-ID: MaskRay added a comment. Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git commit with the following script: arcfilter () { arc amend git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F - } `Reviewed By: ` is considered important by some people. Please keep the tag. (`--date=now` is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time)) `llvm/utils/git/pre-push.py` can validate the message does not include unneeded tags. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79147/new/ https://reviews.llvm.org/D79147 From cfe-commits at lists.llvm.org Thu Jul 9 16:14:36 2020 From: cfe-commits at lists.llvm.org (Steven Wan via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 23:14:36 +0000 (UTC) Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures In-Reply-To: References: Message-ID: <7a239d3486815bdccd45c66a35414e45@localhost.localdomain> stevewan added inline comments. ================ Comment at: clang/test/Driver/program-path-priority.c:117 +/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple +// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \ +// RUN: mv %t/$DEFAULT_TRIPLE-gcc %t/prefix || true ---------------- Maybe I'm not seeing something obvious here, but I'm not aware of the `file -E` usage, and on Linux I got `file: invalid option -- 'E'`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83055/new/ https://reviews.llvm.org/D83055 From cfe-commits at lists.llvm.org Thu Jul 9 16:15:09 2020 From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 23:15:09 +0000 (UTC) Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls. In-Reply-To: References: Message-ID: <88370d3977f0d2e7fe3d5ee0eafbd143@localhost.localdomain> efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82085/new/ https://reviews.llvm.org/D82085 From cfe-commits at lists.llvm.org Thu Jul 9 16:16:30 2020 From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 23:16:30 +0000 (UTC) Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute In-Reply-To: References: Message-ID: <8e4a9a3ec90ed3752f28eb7941e7bc5a@localhost.localdomain> efriedma accepted this revision. efriedma added a comment. This revision is now accepted and ready to land. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81583/new/ https://reviews.llvm.org/D81583 From cfe-commits at lists.llvm.org Thu Jul 9 16:20:57 2020 From: cfe-commits at lists.llvm.org (Alexey Lapshin via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 23:20:57 +0000 (UTC) Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls. In-Reply-To: References: Message-ID: <477e11dfd7c23acd13219bcdbbf89a76@localhost.localdomain> avl added a comment. Thank you, for the review. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82085/new/ https://reviews.llvm.org/D82085 From cfe-commits at lists.llvm.org Thu Jul 9 16:29:06 2020 From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits) Date: Thu, 09 Jul 2020 23:29:06 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: <1565ff58cd8ec6561570e2ecce00b098@localhost.localdomain> Xiangling_L updated this revision to Diff 276866. Xiangling_L marked 9 inline comments as done. Xiangling_L added a comment. Fixed a base class related case by adding `IsFirstNonEmpty` flag; Split the `aix-Wpacked.cpp` testcase into two; Addressed other comments; CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 Files: clang/include/clang/AST/RecordLayout.h clang/include/clang/Basic/TargetInfo.h clang/lib/AST/ASTContext.cpp clang/lib/AST/RecordLayout.cpp clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Basic/Targets/PPC.h clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp clang/test/Layout/aix-Wpacked-no-diagnostics.cpp clang/test/Layout/aix-double-struct-member.cpp clang/test/Layout/aix-no-unique-address-with-double.cpp clang/test/Layout/aix-pack-attr-on-base.cpp clang/test/Layout/aix-power-alignment-typedef.cpp clang/test/Layout/aix-virtual-function-and-base-with-double.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D79719.276866.patch Type: text/x-patch Size: 68296 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 17:11:19 2020 From: cfe-commits at lists.llvm.org (Yuanfang Chen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 00:11:19 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager In-Reply-To: References: Message-ID: <3c797fc8f1f0bc83cf6a4edbf320c4c6@localhost.localdomain> ychen added inline comments. ================ Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150 for (auto &C : Callbacks->BeforePassCallbacks) - ShouldRun &= C(Pass.name(), llvm::Any(&IR)); + ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR)); return ShouldRun; ---------------- Could we do this to not changing the callback API? `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83519/new/ https://reviews.llvm.org/D83519 From cfe-commits at lists.llvm.org Thu Jul 9 17:18:20 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 00:18:20 +0000 (UTC) Subject: [PATCH] D82467: [PowerPC][Power10] Implement Truncate and Store VSX Vector Builtins In-Reply-To: References: Message-ID: <0c2fcdad947011531f92bc3c9dd3e4c2@localhost.localdomain> amyk updated this revision to Diff 276881. amyk added a comment. Rebased patch, and addressed review comments of having a single `CHECK`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82467/new/ https://reviews.llvm.org/D82467 Files: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-p10vector.c llvm/lib/Target/PowerPC/PPCInstrPrefix.td llvm/test/CodeGen/PowerPC/builtins-ppc-p10vsx.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82467.276881.patch Type: text/x-patch Size: 10357 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 17:24:54 2020 From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits) Date: Thu, 09 Jul 2020 17:24:54 -0700 (PDT) Subject: [clang] 7462793 - Move default argument instantiation to SemaTemplateInstantiateDecl.cpp. Message-ID: <5f07b556.1c69fb81.8d64b.a0f2@mx.google.com> Author: Richard Smith Date: 2020-07-09T17:24:19-07:00 New Revision: 7462793be771712092de4c31fef1b04ac365ccea URL: https://github.com/llvm/llvm-project/commit/7462793be771712092de4c31fef1b04ac365ccea DIFF: https://github.com/llvm/llvm-project/commit/7462793be771712092de4c31fef1b04ac365ccea.diff LOG: Move default argument instantiation to SemaTemplateInstantiateDecl.cpp. No functionality change intended. Added: Modified: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 7535849144d0..c3bebea0cccb 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -9101,6 +9101,8 @@ class Sema final { TemplateArgumentListInfo &Result, const MultiLevelTemplateArgumentList &TemplateArgs); + bool InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, + ParmVarDecl *Param); void InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Function); bool CheckInstantiatedFunctionTemplateConstraints( diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 0a7604d9f399..24b9c6777be1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5575,83 +5575,9 @@ bool Sema::CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, return true; } - if (Param->hasUninstantiatedDefaultArg()) { - Expr *UninstExpr = Param->getUninstantiatedDefaultArg(); - - EnterExpressionEvaluationContext EvalContext( - *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param); - - // Instantiate the expression. - // - // FIXME: Pass in a correct Pattern argument, otherwise - // getTemplateInstantiationArgs uses the lexical context of FD, e.g. - // - // template - // struct A { - // static int FooImpl(); - // - // template - // // bug: default argument A::FooImpl() is evaluated with 2-level - // // template argument list [[T], [Tp]], should be [[Tp]]. - // friend A Foo(int a); - // }; - // - // template - // A Foo(int a = A::FooImpl()); - MultiLevelTemplateArgumentList MutiLevelArgList - = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true); - - InstantiatingTemplate Inst(*this, CallLoc, Param, - MutiLevelArgList.getInnermost()); - if (Inst.isInvalid()) - return true; - if (Inst.isAlreadyInstantiating()) { - Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD; - Param->setInvalidDecl(); - return true; - } - - ExprResult Result; - { - // C++ [dcl.fct.default]p5: - // The names in the [default argument] expression are bound, and - // the semantic constraints are checked, at the point where the - // default argument expression appears. - ContextRAII SavedContext(*this, FD); - LocalInstantiationScope Local(*this); - runWithSufficientStackSpace(CallLoc, [&] { - Result = SubstInitializer(UninstExpr, MutiLevelArgList, - /*DirectInit*/false); - }); - } - if (Result.isInvalid()) - return true; - - // Check the expression as an initializer for the parameter. - InitializedEntity Entity - = InitializedEntity::InitializeParameter(Context, Param); - InitializationKind Kind = InitializationKind::CreateCopy( - Param->getLocation(), - /*FIXME:EqualLoc*/ UninstExpr->getBeginLoc()); - Expr *ResultE = Result.getAs(); - - InitializationSequence InitSeq(*this, Entity, Kind, ResultE); - Result = InitSeq.Perform(*this, Entity, Kind, ResultE); - if (Result.isInvalid()) - return true; - - Result = - ActOnFinishFullExpr(Result.getAs(), Param->getOuterLocStart(), - /*DiscardedValue*/ false); - if (Result.isInvalid()) - return true; - - // Remember the instantiated default argument. - Param->setDefaultArg(Result.getAs()); - if (ASTMutationListener *L = getASTMutationListener()) { - L->DefaultArgumentInstantiated(Param); - } - } + if (Param->hasUninstantiatedDefaultArg() && + InstantiateDefaultArgument(CallLoc, FD, Param)) + return true; assert(Param->hasInit() && "default argument but no initializer?"); diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 444fb209e932..1098a9aa782c 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4227,6 +4227,87 @@ static bool addInstantiatedParametersToScope(Sema &S, FunctionDecl *Function, return false; } +bool Sema::InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, + ParmVarDecl *Param) { + assert(Param->hasUninstantiatedDefaultArg()); + Expr *UninstExpr = Param->getUninstantiatedDefaultArg(); + + EnterExpressionEvaluationContext EvalContext( + *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param); + + // Instantiate the expression. + // + // FIXME: Pass in a correct Pattern argument, otherwise + // getTemplateInstantiationArgs uses the lexical context of FD, e.g. + // + // template + // struct A { + // static int FooImpl(); + // + // template + // // bug: default argument A::FooImpl() is evaluated with 2-level + // // template argument list [[T], [Tp]], should be [[Tp]]. + // friend A Foo(int a); + // }; + // + // template + // A Foo(int a = A::FooImpl()); + MultiLevelTemplateArgumentList TemplateArgs + = getTemplateInstantiationArgs(FD, nullptr, /*RelativeToPrimary=*/true); + + InstantiatingTemplate Inst(*this, CallLoc, Param, + TemplateArgs.getInnermost()); + if (Inst.isInvalid()) + return true; + if (Inst.isAlreadyInstantiating()) { + Diag(Param->getBeginLoc(), diag::err_recursive_default_argument) << FD; + Param->setInvalidDecl(); + return true; + } + + ExprResult Result; + { + // C++ [dcl.fct.default]p5: + // The names in the [default argument] expression are bound, and + // the semantic constraints are checked, at the point where the + // default argument expression appears. + ContextRAII SavedContext(*this, FD); + LocalInstantiationScope Local(*this); + runWithSufficientStackSpace(CallLoc, [&] { + Result = SubstInitializer(UninstExpr, TemplateArgs, + /*DirectInit*/false); + }); + } + if (Result.isInvalid()) + return true; + + // Check the expression as an initializer for the parameter. + InitializedEntity Entity + = InitializedEntity::InitializeParameter(Context, Param); + InitializationKind Kind = InitializationKind::CreateCopy( + Param->getLocation(), + /*FIXME:EqualLoc*/ UninstExpr->getBeginLoc()); + Expr *ResultE = Result.getAs(); + + InitializationSequence InitSeq(*this, Entity, Kind, ResultE); + Result = InitSeq.Perform(*this, Entity, Kind, ResultE); + if (Result.isInvalid()) + return true; + + Result = + ActOnFinishFullExpr(Result.getAs(), Param->getOuterLocStart(), + /*DiscardedValue*/ false); + if (Result.isInvalid()) + return true; + + // Remember the instantiated default argument. + Param->setDefaultArg(Result.getAs()); + if (ASTMutationListener *L = getASTMutationListener()) + L->DefaultArgumentInstantiated(Param); + + return false; +} + void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, FunctionDecl *Decl) { const FunctionProtoType *Proto = Decl->getType()->castAs(); From cfe-commits at lists.llvm.org Thu Jul 9 17:24:56 2020 From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits) Date: Thu, 09 Jul 2020 17:24:56 -0700 (PDT) Subject: [clang] a5569f0 - Push parameters into the local instantiation scope before instantiating Message-ID: <5f07b558.1c69fb81.c8cf9.a10a@mx.google.com> Author: Richard Smith Date: 2020-07-09T17:24:20-07:00 New Revision: a5569f089844209dbea2e3241460173d7b6b1420 URL: https://github.com/llvm/llvm-project/commit/a5569f089844209dbea2e3241460173d7b6b1420 DIFF: https://github.com/llvm/llvm-project/commit/a5569f089844209dbea2e3241460173d7b6b1420.diff LOG: Push parameters into the local instantiation scope before instantiating a default argument. Default arguments can (after recent language changes) refer to parameters of the same function. Make sure they're added to the local instantiation scope before transforming a default argument so that we can remap such references to them properly. Added: Modified: clang/include/clang/AST/Decl.h clang/lib/AST/Decl.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/test/SemaTemplate/default-arguments-cxx0x.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 6c39f6aab1b9..28faa2c1fc78 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -2618,7 +2618,13 @@ class FunctionDecl : public DeclaratorDecl, /// Retrieve the function declaration from which this function could /// be instantiated, if it is an instantiation (rather than a non-template /// or a specialization, for example). - FunctionDecl *getTemplateInstantiationPattern() const; + /// + /// If \p ForDefinition is \c false, explicit specializations will be treated + /// as if they were implicit instantiations. This will then find the pattern + /// corresponding to non-definition portions of the declaration, such as + /// default arguments and the exception specification. + FunctionDecl * + getTemplateInstantiationPattern(bool ForDefinition = true) const; /// Retrieve the primary template that this function template /// specialization either specializes or was instantiated from. diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 1676f319394d..5c0a98815dd7 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -3623,7 +3623,8 @@ bool FunctionDecl::isTemplateInstantiation() const { return clang::isTemplateInstantiation(getTemplateSpecializationKind()); } -FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const { +FunctionDecl * +FunctionDecl::getTemplateInstantiationPattern(bool ForDefinition) const { // If this is a generic lambda call operator specialization, its // instantiation pattern is always its primary template's pattern // even if its primary template was instantiated from another @@ -3640,18 +3641,20 @@ FunctionDecl *FunctionDecl::getTemplateInstantiationPattern() const { } if (MemberSpecializationInfo *Info = getMemberSpecializationInfo()) { - if (!clang::isTemplateInstantiation(Info->getTemplateSpecializationKind())) + if (ForDefinition && + !clang::isTemplateInstantiation(Info->getTemplateSpecializationKind())) return nullptr; return getDefinitionOrSelf(cast(Info->getInstantiatedFrom())); } - if (!clang::isTemplateInstantiation(getTemplateSpecializationKind())) + if (ForDefinition && + !clang::isTemplateInstantiation(getTemplateSpecializationKind())) return nullptr; if (FunctionTemplateDecl *Primary = getPrimaryTemplate()) { // If we hit a point where the user provided a specialization of this // template, we're done looking. - while (!Primary->isMemberSpecialization()) { + while (!ForDefinition || !Primary->isMemberSpecialization()) { auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate(); if (!NewPrimary) break; diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 1098a9aa782c..6179d90d54f7 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4273,6 +4273,13 @@ bool Sema::InstantiateDefaultArgument(SourceLocation CallLoc, FunctionDecl *FD, // default argument expression appears. ContextRAII SavedContext(*this, FD); LocalInstantiationScope Local(*this); + + FunctionDecl *Pattern = FD->getTemplateInstantiationPattern( + /*ForDefinition*/ false); + if (addInstantiatedParametersToScope(*this, FD, Pattern, Local, + TemplateArgs)) + return true; + runWithSufficientStackSpace(CallLoc, [&] { Result = SubstInitializer(UninstExpr, TemplateArgs, /*DirectInit*/false); @@ -4338,6 +4345,10 @@ void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation, MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true); + // FIXME: We can't use getTemplateInstantiationPattern(false) in general + // here, because for a non-defining friend declaration in a class template, + // we don't store enough information to map back to the friend declaration in + // the template. FunctionDecl *Template = Proto->getExceptionSpecTemplate(); if (addInstantiatedParametersToScope(*this, Decl, Template, Scope, TemplateArgs)) { diff --git a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp index 2114cc94e6c6..02696a80bc0f 100644 --- a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp +++ b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp @@ -116,6 +116,11 @@ namespace rdar34167492 { }; } +namespace use_of_earlier_param { + template void f(T a, int = decltype(a)()); + void g() { f(0); } +} + #if __cplusplus >= 201402L namespace lambda { // Verify that a default argument in a lambda can refer to the type of a From cfe-commits at lists.llvm.org Thu Jul 9 17:24:58 2020 From: cfe-commits at lists.llvm.org (Richard Smith via cfe-commits) Date: Thu, 09 Jul 2020 17:24:58 -0700 (PDT) Subject: [clang] f721e05 - PR46648: Do not eagerly instantiate default arguments for a generic Message-ID: <5f07b55a.1c69fb81.7e178.a844@mx.google.com> Author: Richard Smith Date: 2020-07-09T17:24:20-07:00 New Revision: f721e0582b158c60c56d2601235b6d60758f4d7a URL: https://github.com/llvm/llvm-project/commit/f721e0582b158c60c56d2601235b6d60758f4d7a DIFF: https://github.com/llvm/llvm-project/commit/f721e0582b158c60c56d2601235b6d60758f4d7a.diff LOG: PR46648: Do not eagerly instantiate default arguments for a generic lambda when instantiating a call operator specialization. We previously incorrectly thought that such substitution was happening in the context of substitution into a local scope, which is a context where we should perform eager default argument instantiation. Added: Modified: clang/include/clang/AST/DeclBase.h clang/lib/AST/DeclBase.cpp clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaTemplateInstantiateDecl.cpp clang/test/SemaTemplate/default-arguments-cxx0x.cpp clang/test/SemaTemplate/dependent-expr.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 5e00be35d8ce..4f33ff104ffd 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -875,15 +875,19 @@ class alignas(8) Decl { return getParentFunctionOrMethod() == nullptr; } - /// Returns true if this declaration is lexically inside a function or inside - /// a variable initializer. It recognizes non-defining declarations as well - /// as members of local classes and lambdas: + /// Determine whether a substitution into this declaration would occur as + /// part of a substitution into a dependent local scope. Such a substitution + /// transitively substitutes into all constructs nested within this + /// declaration. + /// + /// This recognizes non-defining declarations as well as members of local + /// classes and lambdas: /// \code - /// void foo() { void bar(); } - /// void foo2() { class ABC { void bar(); }; } - /// inline int x = [](){ return 0; }(); + /// template void foo() { void bar(); } + /// template void foo2() { class ABC { void bar(); }; } + /// template inline int x = [](){ return 0; }(); /// \endcode - bool isInLocalScope() const; + bool isInLocalScopeForInstantiation() const; /// If this decl is defined inside a function/method/block it returns /// the corresponding DeclContext, otherwise it returns null. diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 3fd27757815e..da1eadd9d931 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -364,8 +364,10 @@ void Decl::setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC, } } -bool Decl::isInLocalScope() const { +bool Decl::isInLocalScopeForInstantiation() const { const DeclContext *LDC = getLexicalDeclContext(); + if (!LDC->isDependentContext()) + return false; while (true) { if (LDC->isFunctionOrMethod()) return true; diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index 8197e7d901e9..11e03c517d01 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -2426,7 +2426,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(ParmVarDecl *OldParm, UnparsedDefaultArgInstantiations[OldParm].push_back(NewParm); } else if (Expr *Arg = OldParm->getDefaultArg()) { FunctionDecl *OwningFunc = cast(OldParm->getDeclContext()); - if (OwningFunc->isInLocalScope()) { + if (OwningFunc->isInLocalScopeForInstantiation()) { // Instantiate default arguments for methods of local classes (DR1484) // and non-defining declarations. Sema::ContextRAII SavedContext(*this, OwningFunc); diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6179d90d54f7..85adc4ef2dbd 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -4458,7 +4458,7 @@ TemplateDeclInstantiator::InitFunctionInstantiation(FunctionDecl *New, EPI.ExceptionSpec.Type != EST_None && EPI.ExceptionSpec.Type != EST_DynamicNone && EPI.ExceptionSpec.Type != EST_BasicNoexcept && - !Tmpl->isInLocalScope()) { + !Tmpl->isInLocalScopeForInstantiation()) { FunctionDecl *ExceptionSpecTemplate = Tmpl; if (EPI.ExceptionSpec.Type == EST_Uninstantiated) ExceptionSpecTemplate = EPI.ExceptionSpec.SourceTemplate; diff --git a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp index 02696a80bc0f..1aa456553599 100644 --- a/clang/test/SemaTemplate/default-arguments-cxx0x.cpp +++ b/clang/test/SemaTemplate/default-arguments-cxx0x.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s // expected-no-diagnostics // Test default template arguments for function templates. @@ -132,5 +133,32 @@ namespace lambda { void foo() { bar(); } + +#if __cplusplus >= 202002L + // PR46648: ensure we don't reject this by triggering default argument + // instantiation spuriously. + auto x = [](T x = 123) {}; + void y() { x(nullptr); } + + template struct X { + template constexpr int f() { + auto l = [](int n = A + B + C) { return n; }; + return l.template operator()<3>(); + } + }; + static_assert(X<100>().f<20>() == 123); + + template<> template constexpr int X<200>::f() { + auto l = [](int n = 300 + B + C) { return n; }; + return l.template operator()<1>(); + } + static_assert(X<200>().f<20>() == 321); + + template<> template<> constexpr int X<300>::f<20>() { + auto l = [](int n = 450 + C) { return n; }; + return l.template operator()<6>(); + } + static_assert(X<300>().f<20>() == 456); +#endif } // namespace lambda #endif diff --git a/clang/test/SemaTemplate/dependent-expr.cpp b/clang/test/SemaTemplate/dependent-expr.cpp index 0ce4cb39d349..abdb8e9c4a9f 100644 --- a/clang/test/SemaTemplate/dependent-expr.cpp +++ b/clang/test/SemaTemplate/dependent-expr.cpp @@ -144,7 +144,7 @@ namespace PR45083 { void h(auto a, void*) {} // expected-error {{redefinition}} void i(auto a) { - [](auto a, int = ({decltype(a) i; i * 2;})){}(a); // expected-error {{no matching function}} expected-note {{substitution failure}} + [](auto a, int = ({decltype(a) i; i * 2;})){}(a); // expected-error {{invalid operands to binary expression ('decltype(a)' (aka 'void *') and 'int')}} expected-note {{in instantiation of}} } void use_i() { i(0); From cfe-commits at lists.llvm.org Thu Jul 9 17:28:11 2020 From: cfe-commits at lists.llvm.org (Arthur Eubanks via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 00:28:11 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager In-Reply-To: References: Message-ID: <07f39f202972dfe3681fe23c5bda2f45@localhost.localdomain> aeubanks marked an inline comment as done. aeubanks added inline comments. ================ Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150 for (auto &C : Callbacks->BeforePassCallbacks) - ShouldRun &= C(Pass.name(), llvm::Any(&IR)); + ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR)); return ShouldRun; ---------------- ychen wrote: > Could we do this to not changing the callback API? > `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();` Each pass instrumentation should decide whether or not to run the pass based on whether or not the pass is required or optional. An optional pass may still be run, (which should be the case for the vast majority of instances). For example, the optnone would only care if a pass is required or not if it sees that a function is marked optnone. Similarly, opt-bisect would only care if a pass is required if it's hit the bisect limit. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83519/new/ https://reviews.llvm.org/D83519 From cfe-commits at lists.llvm.org Thu Jul 9 18:23:45 2020 From: cfe-commits at lists.llvm.org (Alina Sbirlea via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 01:23:45 +0000 (UTC) Subject: [PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff. In-Reply-To: References: Message-ID: <3a92b9b22118466058e74047ad300c70@localhost.localdomain> asbirlea updated this revision to Diff 276890. asbirlea added a comment. This revision is now accepted and ready to land. Updated to include the part of the patch that's moving the Updates to a CFGDiff object. Splitting off from the clean-up work merging the two branches when BUI is null. This patch does not exhibit the compile-time regression which caused it to be reverted previously. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77341/new/ https://reviews.llvm.org/D77341 Files: llvm/include/llvm/IR/Dominators.h llvm/include/llvm/Support/CFGDiff.h llvm/include/llvm/Support/GenericDomTree.h llvm/include/llvm/Support/GenericDomTreeConstruction.h llvm/lib/IR/Dominators.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D77341.276890.patch Type: text/x-patch Size: 19105 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 18:29:43 2020 From: cfe-commits at lists.llvm.org (Alina Sbirlea via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 01:29:43 +0000 (UTC) Subject: [PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff. In-Reply-To: References: Message-ID: <933225f82a44a7a689725887b72382be@localhost.localdomain> asbirlea updated this revision to Diff 276891. asbirlea added a comment. Nit: re-add `const`s Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77341/new/ https://reviews.llvm.org/D77341 Files: llvm/include/llvm/IR/Dominators.h llvm/include/llvm/Support/CFGDiff.h llvm/include/llvm/Support/GenericDomTree.h llvm/include/llvm/Support/GenericDomTreeConstruction.h llvm/lib/IR/Dominators.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D77341.276891.patch Type: text/x-patch Size: 18743 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 18:43:36 2020 From: cfe-commits at lists.llvm.org (Arthur Eubanks via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 01:43:36 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager In-Reply-To: References: Message-ID: <776e29c11c20f65196bb95282b3f6ed3@localhost.localdomain> aeubanks marked an inline comment as done. aeubanks added inline comments. ================ Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150 for (auto &C : Callbacks->BeforePassCallbacks) - ShouldRun &= C(Pass.name(), llvm::Any(&IR)); + ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR)); return ShouldRun; ---------------- aeubanks wrote: > ychen wrote: > > Could we do this to not changing the callback API? > > `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();` > Each pass instrumentation should decide whether or not to run the pass based on whether or not the pass is required or optional. An optional pass may still be run, (which should be the case for the vast majority of instances). > > For example, the optnone would only care if a pass is required or not if it sees that a function is marked optnone. > Similarly, opt-bisect would only care if a pass is required if it's hit the bisect limit. Sorry, now I understand what you mean, the ands and ors confused me. I don't want to rule out the possibility of some future pass instrumentation wanting to skip even a required pass. But I am open to discussion on this point. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83519/new/ https://reviews.llvm.org/D83519 From cfe-commits at lists.llvm.org Thu Jul 9 19:32:41 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 02:32:41 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: rjmccall added a comment. I agree that avoiding the copy is best. However, at the very least, if that function isn't going to handle the aggregate case correctly, it should assert that it isn't in it. Otherwise this LGTM. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 From cfe-commits at lists.llvm.org Thu Jul 9 19:51:42 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 02:51:42 +0000 (UTC) Subject: [PATCH] D83514: [Lexer] Fix missing coverage line after #endif In-Reply-To: References: Message-ID: <0f53f2c36bb906cfabee24571f369bc6@localhost.localdomain> zequanwu updated this revision to Diff 276899. zequanwu added a comment. Herald added subscribers: usaxena95, kadircet, jkorous. Fix clangd unit test. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83514/new/ https://reviews.llvm.org/D83514 Files: clang-tools-extra/clangd/SemanticHighlighting.cpp clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83514.276899.patch Type: text/x-patch Size: 4651 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 20:21:01 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 03:21:01 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. Message-ID: oontvoo created this revision. Herald added subscribers: cfe-commits, martong. Herald added a reviewer: shafik. Herald added a project: clang. This helps avoiding hacks downstream. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83529 Files: clang/include/clang/AST/Stmt.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Stmt.cpp clang/lib/Parse/ParseStmt.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83529.276902.patch Type: text/x-patch Size: 10601 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 20:29:47 2020 From: cfe-commits at lists.llvm.org (JF Bastien via cfe-commits) Date: Thu, 09 Jul 2020 20:29:47 -0700 (PDT) Subject: [clang] 00c9a50 - CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock Message-ID: <5f07e0ab.1c69fb81.fd0df.baac@mx.google.com> Author: Oliver Hunt Date: 2020-07-09T20:27:33-07:00 New Revision: 00c9a504aeed2603bd8bc9b89d753534e929c8e8 URL: https://github.com/llvm/llvm-project/commit/00c9a504aeed2603bd8bc9b89d753534e929c8e8 DIFF: https://github.com/llvm/llvm-project/commit/00c9a504aeed2603bd8bc9b89d753534e929c8e8.diff LOG: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock Add a guard for re-entering an SDiagsWriter's HandleDiagnostics method after we've started finalizing. This is a generic catch all for unexpected fatal errors so we don't recursive crash inside the generic llvm error handler. We also add logic to handle the actual error case in llvm::~raw_fd_ostream caused by failing to clear errors before it is destroyed. Added: Modified: clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/lib/Frontend/SerializedDiagnosticPrinter.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 83c13e0dbbe0..ceb24bce5978 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -119,6 +119,9 @@ def warn_fe_serialized_diag_merge_failure : Warning< def warn_fe_serialized_diag_failure : Warning< "unable to open file %0 for serializing diagnostics (%1)">, InGroup; +def warn_fe_serialized_diag_failure_during_finalisation : Warning< + "Received warning after diagnostic serialization teardown was underway: %0">, + InGroup; def err_verify_missing_line : Error< "missing or invalid line number following '@' in expected %0">; diff --git a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index e3ca8fdec393..462aeda6e027 100644 --- a/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -239,6 +239,9 @@ class SDiagsWriter : public DiagnosticConsumer { /// generated from child processes. bool MergeChildRecords; + /// Whether we've started finishing and tearing down this instance. + bool IsFinishing = false; + /// State that is shared among the various clones of this diagnostic /// consumer. struct SharedState { @@ -568,6 +571,17 @@ unsigned SDiagsWriter::getEmitDiagnosticFlag(StringRef FlagName) { void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) { + assert(!IsFinishing && + "Received a diagnostic after we've already started teardown."); + if (IsFinishing) { + SmallString<256> diagnostic; + Info.FormatDiagnostic(diagnostic); + getMetaDiags()->Report( + diag::warn_fe_serialized_diag_failure_during_finalisation) + << diagnostic; + return; + } + // Enter the block for a non-note diagnostic immediately, rather than waiting // for beginDiagnostic, in case associated notes are emitted before we get // there. @@ -761,6 +775,9 @@ void SDiagsWriter::RemoveOldDiagnostics() { } void SDiagsWriter::finish() { + assert(!IsFinishing); + IsFinishing = true; + // The original instance is responsible for writing the file. if (!OriginalInstance) return; @@ -786,12 +803,20 @@ void SDiagsWriter::finish() { if (EC) { getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure) << State->OutputFile << EC.message(); + OS->clear_error(); return; } // Write the generated bitstream to "Out". OS->write((char *)&State->Buffer.front(), State->Buffer.size()); OS->flush(); + + assert(!OS->has_error()); + if (OS->has_error()) { + getMetaDiags()->Report(diag::warn_fe_serialized_diag_failure) + << State->OutputFile << OS->error().message(); + OS->clear_error(); + } } std::error_code SDiagsMerger::visitStartOfDiagnostic() { From cfe-commits at lists.llvm.org Thu Jul 9 20:33:34 2020 From: cfe-commits at lists.llvm.org (JF Bastien via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 03:33:34 +0000 (UTC) Subject: [PATCH] D83509: CrashTracer: clang at clang: llvm::BitstreamWriter::ExitBlock In-Reply-To: References: Message-ID: <1272221d81ad011b3e271f09fe32abb6@localhost.localdomain> jfb added a comment. I don't remember if this will auto-close, since I forgot to add the Phabricator ID to the commit message. In any case it's in: 00c9a504aeed2603bd8bc9b89d753534e929c8e8 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83509/new/ https://reviews.llvm.org/D83509 From cfe-commits at lists.llvm.org Thu Jul 9 21:09:24 2020 From: cfe-commits at lists.llvm.org (Petr Hosek via cfe-commits) Date: Thu, 09 Jul 2020 21:09:24 -0700 (PDT) Subject: [clang] ceb76d2 - [CMake][Fuchsia] Move runtimes to outer scope Message-ID: <5f07e9f4.1c69fb81.b8be5.b1f2@mx.google.com> Author: Petr Hosek Date: 2020-07-09T21:07:44-07:00 New Revision: ceb76d2fe73d39f2230bf55d47b8fd68849d47d7 URL: https://github.com/llvm/llvm-project/commit/ceb76d2fe73d39f2230bf55d47b8fd68849d47d7 DIFF: https://github.com/llvm/llvm-project/commit/ceb76d2fe73d39f2230bf55d47b8fd68849d47d7.diff LOG: [CMake][Fuchsia] Move runtimes to outer scope This is needed for runtimes to be properly configured, addressing an issue introduced in 53e38c85. Added: Modified: clang/cmake/caches/Fuchsia-stage2.cmake Removed: ################################################################################ diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index 4d9b8526d0c4..259684ff2b0d 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -5,6 +5,7 @@ set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64;RISCV CACHE STRING "") set(PACKAGE_VENDOR Fuchsia CACHE STRING "") set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld;llvm" CACHE STRING "") +set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") if(NOT APPLE) @@ -70,7 +71,6 @@ if(APPLE) set(DARWIN_iossim_ARCHS i386;x86_64 CACHE STRING "") set(DARWIN_osx_ARCHS x86_64 CACHE STRING "") set(SANITIZER_MIN_OSX_VERSION 10.7 CACHE STRING "") - set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "") endif() if(WIN32) From cfe-commits at lists.llvm.org Thu Jul 9 21:25:53 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 04:25:53 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1246 + + // AIX `power` alignment does not apply the preferred alignment for + // non-union classes if the source of the alignment (the current base in ---------------- Move the comment to above the previous `if` and make the following `if` the `else` of the previous `if`. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1796 + bool FoundFirstNonOverlappingEmptyFieldToHandle = + DefaultsToAIXPowerAlignment && FieldOffset == CharUnits::Zero() && + !HandledFirstNonOverlappingEmptyField && !IsOverlappingEmptyField; ---------------- Xiangling_L wrote: > hubert.reinterpretcast wrote: > > Xiangling_L wrote: > > > hubert.reinterpretcast wrote: > > > > The condition is still more complex than I think it should be. > > > > > > > > If we have found a "first" other-than-overlapping-empty-field, then we should set `HandledFirstNonOverlappingEmptyField` to `true` for non-union cases. > > > > > > > > If `HandledFirstNonOverlappingEmptyField` being `false` is not enough for `FieldOffset == CharUnits::Zero()` to be true, then I think the correction would be to set `HandledFirstNonOverlappingEmptyField` in more places. > > > > > > > > I would like to remove the check on `FieldOffset == CharUnits::Zero()` from here and instead have an assertion that `!HandledFirstNonOverlappingEmptyField` implies `FieldOffset == CharUnits::Zero()`. > > > > > > > > Also, since we're managing `HandledFirstNonOverlappingEmptyField` in non-AIX cases, we should remove the `DefaultsToAIXPowerAlignment` condition for what is currently named `FoundFirstNonOverlappingEmptyFieldToHandle` (adjusting uses of it as necessary) and rename `FoundFirstNonOverlappingEmptyFieldToHandle` to `FoundFirstNonOverlappingEmptyField`. > > > > Also, since we're managing HandledFirstNonOverlappingEmptyField in non-AIX cases, we should remove the DefaultsToAIXPowerAlignment condition for what is currently named FoundFirstNonOverlappingEmptyFieldToHandle > > > > > > I am not sure if we want to remove the `DefaultsToAIXPowerAlignment` condition and bother with maintaining correct status of `HandledFirstNonOverlappingEmptyField` for other targets. > > > > > > We are actually claiming `HandledFirstNonOverlappingEmptyField` is an auxiliary flag used for AIX only in its definition comments. > > > > > > Besides, if we do want to manage `HandledFirstNonOverlappingEmptyField` in non-AIX cases, I noticed that we have to set this flag to `true` somewhere for objective-C++ cases. > > Okay, the other option I'm open is setting `HandledFirstNonOverlappingEmptyField` to `true` up front when not dealing with AIX `power` alignment. > Thanks, that works too. I will address it in the next commit. I'm not seeing the change for https://reviews.llvm.org/D79719?id=276143#inline-767942? ================ Comment at: clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp:19 + char x alignas(4)[8]; +} ; + ---------------- Minor nit: Remove the space before the semicolon. ================ Comment at: clang/test/Layout/aix-Wpacked-no-diagnostics.cpp:15 + +int a = sizeof(QQ); ---------------- Is there a reason to drop the `FileCheck` checking for the layout? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Thu Jul 9 22:09:20 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 05:09:20 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: dang added a comment. Yes I committed this a while ago, I duplicated all the functionality in Options.td. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Thu Jul 9 22:26:35 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 05:26:35 +0000 (UTC) Subject: [PATCH] D83371: [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder In-Reply-To: References: Message-ID: <95af38c173bd916138ec05ee71f1c60d@localhost.localdomain> nridge updated this revision to Diff 276911. nridge marked 3 inline comments as done. nridge added a comment. Address review comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83371/new/ https://reviews.llvm.org/D83371 Files: clang-tools-extra/clangd/FindTarget.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83371.276911.patch Type: text/x-patch Size: 4658 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 22:58:51 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via cfe-commits) Date: Thu, 09 Jul 2020 22:58:51 -0700 (PDT) Subject: [clang-tools-extra] 98d763a - [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder Message-ID: <5f08039b.1c69fb81.fe4a7.b54f@mx.google.com> Author: Nathan Ridge Date: 2020-07-10T01:58:34-04:00 New Revision: 98d763ad051f5eab89fa46167516fc8a84f471d0 URL: https://github.com/llvm/llvm-project/commit/98d763ad051f5eab89fa46167516fc8a84f471d0 DIFF: https://github.com/llvm/llvm-project/commit/98d763ad051f5eab89fa46167516fc8a84f471d0.diff LOG: [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder Summary: Two helpers are introduced: * Some of the logic previously in TargetFinder::Visit*() methods is factored out into resolveDependentExprToDecls(). * Some of the logic in getMembersReferencedViaDependentName() is factored out into resolveTypeToRecordDecl(). D82739 will build on this and use these functions in new ways. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83371 Added: Modified: clang-tools-extra/clangd/FindTarget.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index 1d09e8408c83..627f40c85436 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -58,6 +58,24 @@ nodeToString(const ast_type_traits::DynTypedNode &N) { return S; } +// Helper function for getMembersReferencedViaDependentName() +// which takes a dependent type `T` and heuristically +// resolves it to a CXXRecordDecl in which we can try name lookup. +CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) { + assert(T); + if (const auto *ICNT = T->getAs()) { + T = ICNT->getInjectedSpecializationType().getTypePtrOrNull(); + } + const auto *TST = T->getAs(); + if (!TST) + return nullptr; + const ClassTemplateDecl *TD = dyn_cast_or_null( + TST->getTemplateName().getAsTemplateDecl()); + if (!TD) + return nullptr; + return TD->getTemplatedDecl(); +} + // Given a dependent type and a member name, heuristically resolve the // name to one or more declarations. // The current heuristic is simply to look up the name in the primary @@ -82,25 +100,17 @@ std::vector getMembersReferencedViaDependentName( ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext())); return {Result.begin(), Result.end()}; } - if (auto *ICNT = T->getAs()) { - T = ICNT->getInjectedSpecializationType().getTypePtrOrNull(); + if (auto *RD = resolveTypeToRecordDecl(T)) { + if (!RD->hasDefinition()) + return {}; + RD = RD->getDefinition(); + DeclarationName Name = NameFactory(RD->getASTContext()); + return RD->lookupDependentName(Name, [=](const NamedDecl *D) { + return IsNonstaticMember ? D->isCXXInstanceMember() + : !D->isCXXInstanceMember(); + }); } - auto *TST = T->getAs(); - if (!TST) - return {}; - const ClassTemplateDecl *TD = dyn_cast_or_null( - TST->getTemplateName().getAsTemplateDecl()); - if (!TD) - return {}; - CXXRecordDecl *RD = TD->getTemplatedDecl(); - if (!RD->hasDefinition()) - return {}; - RD = RD->getDefinition(); - DeclarationName Name = NameFactory(RD->getASTContext()); - return RD->lookupDependentName(Name, [=](const NamedDecl *D) { - return IsNonstaticMember ? D->isCXXInstanceMember() - : !D->isCXXInstanceMember(); - }); + return {}; } // Given the type T of a dependent expression that appears of the LHS of a "->", @@ -144,6 +154,28 @@ const Type *getPointeeType(const Type *T) { return FirstArg.getAsType().getTypePtrOrNull(); } +// Try to heuristically resolve a dependent expression `E` to one +// or more declarations that it likely references. +std::vector resolveDependentExprToDecls(const Expr *E) { + assert(E->isTypeDependent()); + if (const auto *ME = dyn_cast(E)) { + const Type *BaseType = ME->getBaseType().getTypePtrOrNull(); + if (ME->isArrow()) { + BaseType = getPointeeType(BaseType); + } + return getMembersReferencedViaDependentName( + BaseType, [ME](ASTContext &) { return ME->getMember(); }, + /*IsNonstaticMember=*/true); + } + if (const auto *RE = dyn_cast(E)) { + return getMembersReferencedViaDependentName( + RE->getQualifier()->getAsType(), + [RE](ASTContext &) { return RE->getDeclName(); }, + /*IsNonstaticMember=*/false); + } + return {}; +} + const NamedDecl *getTemplatePattern(const NamedDecl *D) { if (const CXXRecordDecl *CRD = dyn_cast(D)) { if (const auto *Result = CRD->getTemplateInstantiationPattern()) @@ -341,21 +373,12 @@ struct TargetFinder { } void VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) { - const Type *BaseType = E->getBaseType().getTypePtrOrNull(); - if (E->isArrow()) { - BaseType = getPointeeType(BaseType); - } - for (const NamedDecl *D : getMembersReferencedViaDependentName( - BaseType, [E](ASTContext &) { return E->getMember(); }, - /*IsNonstaticMember=*/true)) { + for (const NamedDecl *D : resolveDependentExprToDecls(E)) { Outer.add(D, Flags); } } void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) { - for (const NamedDecl *D : getMembersReferencedViaDependentName( - E->getQualifier()->getAsType(), - [E](ASTContext &) { return E->getDeclName(); }, - /*IsNonstaticMember=*/false)) { + for (const NamedDecl *D : resolveDependentExprToDecls(E)) { Outer.add(D, Flags); } } From cfe-commits at lists.llvm.org Thu Jul 9 22:59:03 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 05:59:03 +0000 (UTC) Subject: [PATCH] D83371: [clangd] Factor out some helper functions related to heuristic resolution in TargetFinder In-Reply-To: References: Message-ID: <65965c88dbbfcb19c2e3f1eaaf6c84c4@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG98d763ad051f: [clangd] Factor out some helper functions related to heuristic resolution in… (authored by nridge). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83371/new/ https://reviews.llvm.org/D83371 Files: clang-tools-extra/clangd/FindTarget.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83371.276913.patch Type: text/x-patch Size: 4658 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 23:11:38 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:11:38 +0000 (UTC) Subject: [PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder In-Reply-To: References: Message-ID: <1b335c549b8ebef282e031a84cf162e1@localhost.localdomain> nridge updated this revision to Diff 276916. nridge marked 4 inline comments as done. nridge added a comment. Address review comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82739/new/ https://reviews.llvm.org/D82739 Files: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/unittests/FindTargetTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82739.276916.patch Type: text/x-patch Size: 33090 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 23:11:50 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:11:50 +0000 (UTC) Subject: [PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder In-Reply-To: References: Message-ID: <03c8d1f47afb2cc93fb33392e18c5a8f@localhost.localdomain> nridge added inline comments. ================ Comment at: clang-tools-extra/clangd/FindTarget.cpp:196 switch (E->getStmtClass()) { case Stmt::CXXDependentScopeMemberExprClass: { const auto *ME = llvm::cast(E); ---------------- hokein wrote: > I'm doubting whether we will miss some other exprs, since we are using it to find the decls for the base expr of `CXXDependentScopeMemberExpr`. > > could you try the following testcase (also add it to the unittest)? > > ``` > struct A { > void foo() {} > }; > struct B { > A getA(); > }; > > template struct C { > C c; > > void bar() { this->c.getA().foo(); } > }; > ``` Thank you for the example! Handling this case required a bit of additional logic, which I've now added. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82739/new/ https://reviews.llvm.org/D82739 From cfe-commits at lists.llvm.org Thu Jul 9 23:14:42 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:14:42 +0000 (UTC) Subject: [PATCH] D83511: [clangd] Config: If.PathExclude In-Reply-To: References: Message-ID: hokein accepted this revision. hokein added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:73 + Frag.If.PathMatch.emplace_back("b.*"); + Frag.If.PathExclude.emplace_back(".*r"); + EXPECT_FALSE(compileAndApply()); ---------------- IIUC the semantic is: we only process the file `if (PathMatch("bar", "b.*") && !PathExclude("bar", ".*r"))`, PathExclude is true here, so we won't process the file. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83511/new/ https://reviews.llvm.org/D83511 From cfe-commits at lists.llvm.org Thu Jul 9 23:23:02 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:23:02 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: <0403a32b19cd31d4c8de34361e3e626c@localhost.localdomain> eduucaldas updated this revision to Diff 276919. eduucaldas marked 9 inline comments as done. eduucaldas added a comment. Use right function to get TokSpelling, answer comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 Files: clang/include/clang/Tooling/Syntax/Nodes.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Syntax/Nodes.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82157.276919.patch Type: text/x-patch Size: 13447 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 23:23:34 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:23:34 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: <429014e9166e4e3f2ab498717c023731@localhost.localdomain> eduucaldas added inline comments. ================ Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:1210 + 12_t; // call: operator<'1', '2'> "" _x() | kind: integer + 1.2_t; // call: operator<'1', '2'> "" _x() | kind: float } ---------------- gribozavr2 wrote: > call -> calls? (as in, "this expression calls ...") it is a noun here, as kind is. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 From cfe-commits at lists.llvm.org Thu Jul 9 23:28:16 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via cfe-commits) Date: Thu, 09 Jul 2020 23:28:16 -0700 (PDT) Subject: [clang] 50f2433 - Add diagnostic option backing field for -fansi-escape-codes Message-ID: <5f080a80.1c69fb81.f0771.b94d@mx.google.com> Author: Daniel Grumberg Date: 2020-07-10T07:26:56+01:00 New Revision: 50f24331fd91e70de6bf6c3efe45272ddfc711fd URL: https://github.com/llvm/llvm-project/commit/50f24331fd91e70de6bf6c3efe45272ddfc711fd DIFF: https://github.com/llvm/llvm-project/commit/50f24331fd91e70de6bf6c3efe45272ddfc711fd.diff LOG: Add diagnostic option backing field for -fansi-escape-codes Summary: Keep track of -fansi-escape-codes in DiagnosticOptions and move the option to the new option parsing system. Depends on D82860 Reviewers: Bigcheese Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82874 Added: Modified: clang/include/clang/Basic/DiagnosticOptions.def clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def index 6d1a1af92821..a946b5c6be8e 100644 --- a/clang/include/clang/Basic/DiagnosticOptions.def +++ b/clang/include/clang/Basic/DiagnosticOptions.def @@ -65,6 +65,7 @@ VALUE_DIAGOPT(ShowCategories, 2, 0) /// Show categories: 0 -> none, 1 -> Number, ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for diagnostics: DIAGOPT(ShowColors, 1, 0) /// Show diagnostics with ANSI color sequences. +DIAGOPT(UseANSIEscapeCodes, 1, 0) ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1, Ovl_All) /// Overload candidates to show. DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 113696aeec7f..c6acd745bfd0 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -849,7 +849,8 @@ def fdiagnostics_color : Flag<["-"], "fdiagnostics-color">, Group, Flags<[CoreOption, DriverOption]>; def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group; def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group, - Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">; + Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">, + MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "false">; def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>, HelpText<"Treat each comma separated argument in as a documentation comment block command">, MetaVarName<"">; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 6f6af917e3a3..64dcfa831824 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1580,8 +1580,6 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args, Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths); Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option); - llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes)); - // Default behavior is to not to show note include stacks. Opts.ShowNoteIncludeStack = false; if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack, @@ -3724,6 +3722,10 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, } Success &= Res.parseSimpleArgs(Args, Diags); + + llvm::sys::Process::UseANSIEscapeCodes( + Res.DiagnosticOpts->UseANSIEscapeCodes); + Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags); Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args); ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args); From cfe-commits at lists.llvm.org Thu Jul 9 23:28:28 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:28:28 +0000 (UTC) Subject: [PATCH] D82874: Add diagnostic option backing field for -fansi-escape-codes In-Reply-To: References: Message-ID: <53eb38ed78b0a62ff651d464bb65363d@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG50f24331fd91: Add diagnostic option backing field for -fansi-escape-codes (authored by dang). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82874/new/ https://reviews.llvm.org/D82874 Files: clang/include/clang/Basic/DiagnosticOptions.def clang/include/clang/Driver/Options.td clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1580,8 +1580,6 @@ Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths); Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option); - llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes)); - // Default behavior is to not to show note include stacks. Opts.ShowNoteIncludeStack = false; if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack, @@ -3724,6 +3722,10 @@ } Success &= Res.parseSimpleArgs(Args, Diags); + + llvm::sys::Process::UseANSIEscapeCodes( + Res.DiagnosticOpts->UseANSIEscapeCodes); + Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags); Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args); ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args); Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -849,7 +849,8 @@ Flags<[CoreOption, DriverOption]>; def fdiagnostics_color_EQ : Joined<["-"], "fdiagnostics-color=">, Group; def fansi_escape_codes : Flag<["-"], "fansi-escape-codes">, Group, - Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">; + Flags<[CoreOption, CC1Option]>, HelpText<"Use ANSI escape codes for diagnostics">, + MarshallingInfoFlag<"DiagnosticOpts->UseANSIEscapeCodes", "false">; def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>, HelpText<"Treat each comma separated argument in as a documentation comment block command">, MetaVarName<"">; Index: clang/include/clang/Basic/DiagnosticOptions.def =================================================================== --- clang/include/clang/Basic/DiagnosticOptions.def +++ clang/include/clang/Basic/DiagnosticOptions.def @@ -65,6 +65,7 @@ ENUM_DIAGOPT(Format, TextDiagnosticFormat, 2, Clang) /// Format for diagnostics: DIAGOPT(ShowColors, 1, 0) /// Show diagnostics with ANSI color sequences. +DIAGOPT(UseANSIEscapeCodes, 1, 0) ENUM_DIAGOPT(ShowOverloads, OverloadsShown, 1, Ovl_All) /// Overload candidates to show. DIAGOPT(VerifyDiagnostics, 1, 0) /// Check that diagnostics match the expected -------------- next part -------------- A non-text attachment was scrubbed... Name: D82874.276920.patch Type: text/x-patch Size: 2541 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Thu Jul 9 23:34:08 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:34:08 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: eduucaldas marked 2 inline comments as done. eduucaldas added inline comments. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:723 + syntax::UserDefinedLiteralExpression * + buildUserDefinedLiteral(UserDefinedLiteral *S) { + switch (S->getLiteralOperatorKind()) { ---------------- b or B? Should I use camelCase or TitleCase? ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:735-751 + auto TokLoc = S->getBeginLoc(); + auto buffer = SmallVector(); + bool invalidSpelling = false; + auto TokSpelling = + Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(), + Context.getLangOpts(), &invalidSpelling); + assert(!invalidSpelling); ---------------- I'll write a comment explaining why this crazyness. Promise not to rant about the lexer that doesn't distinguish between float and integer. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:738-740 + auto TokSpelling = + Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(), + Context.getLangOpts(), &invalidSpelling); ---------------- This is exactly the function used by the parser to get the `TokSpelling`. see: llvm-project/clang/lib/Sema/SemaExpr.cpp:3633 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 From cfe-commits at lists.llvm.org Thu Jul 9 23:56:54 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 06:56:54 +0000 (UTC) Subject: [PATCH] D83419: [clangd] Add error() function for creating formatv-style llvm::Errors. NFC In-Reply-To: References: Message-ID: hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. anyway, I'm fine with this change, feel free to submit it as-is (or do any refinements), don't really want the naming to block this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83419/new/ https://reviews.llvm.org/D83419 From cfe-commits at lists.llvm.org Fri Jul 10 00:03:54 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 07:03:54 +0000 (UTC) Subject: [PATCH] D83536: [clangd] Index refs to main-file symbols as well Message-ID: nridge created this revision. nridge added a reviewer: kadircet. Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. This will be needed to support call hierarchy Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83536 Files: clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83536.276927.patch Type: text/x-patch Size: 6255 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 00:04:54 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 07:04:54 +0000 (UTC) Subject: [PATCH] D83536: [clangd] Index refs to main-file symbols as well In-Reply-To: References: Message-ID: <9c210b48610e40604daba28507bc8d6a@localhost.localdomain> nridge added a comment. (As per discussion in https://github.com/clangd/clangd/issues/162#issuecomment-648923948 onwards.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83536/new/ https://reviews.llvm.org/D83536 From cfe-commits at lists.llvm.org Fri Jul 10 00:08:01 2020 From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 07:08:01 +0000 (UTC) Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions In-Reply-To: References: Message-ID: martong updated this revision to Diff 276928. martong marked an inline comment as done. martong added a comment. - Make Signature to be an Optional member of the Summary Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83407/new/ https://reviews.llvm.org/D83407 Files: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp clang/test/Analysis/std-c-library-functions-POSIX.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83407.276928.patch Type: text/x-patch Size: 28645 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:03:21 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:03:21 +0000 (UTC) Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit. In-Reply-To: References: Message-ID: <49ae8a8c62f0938a5148d006164f126d@localhost.localdomain> hokein added a comment. > Not trying to be difficult, but I'm not sure what you mean by "dependent" in #2. Informally, it means the same thing as #1. Formally, C++ defines type-dependence and value-dependence for expressions, and the ABI defines instantiation-dependence for expressions - AFAIK "dependent" doesn't have a formal meaning. > > So I'd rather say it has two definitions: > > informally, it (somehow) depends on a template parameter. > formally (from the C++ABI), an expression is instantiation-dependent if it is type-dependent or value-dependent, or it has a subexpression that is type-dependent or value-dependent. > To preserve the linkage between these two, IMO we need to extend the formal definition to errors if and only if we extend the informal definition to errors. Accidentally unlinking the two is almost certain to result in subtle bugs as either the implementation subtly differs from the spec, or it subtly differs from the mental model. agree! I think the mental model you described makes more sense. yeah, it is *important* to keep the linkage between the informal and formal definition. It also explains why we should set instantiation-bit. Thanks! ok, we have an agreement on the current approach. The only remaining thing is to clarify comments in clang. I will do it here (rather than D83215 ), so that this discussion thread can be found via the commit message. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83213/new/ https://reviews.llvm.org/D83213 From cfe-commits at lists.llvm.org Fri Jul 10 01:03:26 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 08:03:26 +0000 (UTC) Subject: [PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'. In-Reply-To: References: Message-ID: balazske added a comment. We must check on every execution path that a specific condition on a value is satisfied (or: find one where the condition is not satisfied). This would be the most simple form of this checker. This can be done with the path sensitive check and `checkDeadSymbols`. If the symbol becomes dead with unsatisfied condition a warning is emitted. The "condition" is a syntactic-like check that looks for code like "`X != EOF`". This is probably done best by using `StmtVisitor` if a value is evaluated (at assignment or condition in `if` or other statements), different than the current form. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72705/new/ https://reviews.llvm.org/D72705 From cfe-commits at lists.llvm.org Fri Jul 10 01:15:20 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:15:20 +0000 (UTC) Subject: [PATCH] D82967: [analyzer][tests] Measure peak memory consumption for every project In-Reply-To: References: Message-ID: vsavchenko updated this revision to Diff 276944. vsavchenko added a comment. Add matplotlib and graphviz to requirements.txt Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82967/new/ https://reviews.llvm.org/D82967 Files: clang/utils/analyzer/Dockerfile clang/utils/analyzer/SATestBuild.py clang/utils/analyzer/SATestUtils.py clang/utils/analyzer/requirements.txt -------------- next part -------------- A non-text attachment was scrubbed... Name: D82967.276944.patch Type: text/x-patch Size: 11263 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:16:25 2020 From: cfe-commits at lists.llvm.org (Serge Pavlov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:16:25 +0000 (UTC) Subject: [PATCH] D78899: [Driver] Add callback to Command execution In-Reply-To: References: Message-ID: sepavloff updated this revision to Diff 276945. sepavloff added a comment. Rebased patch Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78899/new/ https://reviews.llvm.org/D78899 Files: clang/include/clang/Driver/Compilation.h clang/lib/Driver/Compilation.cpp clang/unittests/Driver/ToolChainTest.cpp Index: clang/unittests/Driver/ToolChainTest.cpp =================================================================== --- clang/unittests/Driver/ToolChainTest.cpp +++ clang/unittests/Driver/ToolChainTest.cpp @@ -259,4 +259,29 @@ EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl"); EXPECT_FALSE(Res.TargetIsValid); } + +TEST(ToolChainTest, PostCallback) { + IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions(); + IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); + struct TestDiagnosticConsumer : public DiagnosticConsumer {}; + DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); + IntrusiveRefCntPtr InMemoryFileSystem( + new llvm::vfs::InMemoryFileSystem); + + // The executable path must not exist. + Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags, + InMemoryFileSystem); + CCDriver.setCheckInputsExist(false); + std::unique_ptr CC( + CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"})); + bool CallbackHasCalled = false; + CC->setPostCallback( + [&](const Command &C, int Ret) { CallbackHasCalled = true; }); + const JobList &Jobs = CC->getJobs(); + auto &CmdCompile = Jobs.getJobs().front(); + const Command *FailingCmd = nullptr; + CC->ExecuteCommand(*CmdCompile, FailingCmd); + EXPECT_TRUE(CallbackHasCalled); +} + } // end anonymous namespace. Index: clang/lib/Driver/Compilation.cpp =================================================================== --- clang/lib/Driver/Compilation.cpp +++ clang/lib/Driver/Compilation.cpp @@ -193,6 +193,8 @@ std::string Error; bool ExecutionFailed; int Res = C.Execute(Redirects, &Error, &ExecutionFailed); + if (PostCallback) + PostCallback(C, Res); if (!Error.empty()) { assert(Res && "Error string set with 0 result code!"); getDriver().Diag(diag::err_drv_command_failure) << Error; Index: clang/include/clang/Driver/Compilation.h =================================================================== --- clang/include/clang/Driver/Compilation.h +++ clang/include/clang/Driver/Compilation.h @@ -115,6 +115,9 @@ /// Optional redirection for stdin, stdout, stderr. std::vector> Redirects; + /// Callback called after the command has been executed. + std::function PostCallback; + /// Whether we're compiling for diagnostic purposes. bool ForDiagnostics = false; @@ -212,6 +215,10 @@ return FailureResultFiles; } + void setPostCallback(const std::function &CB) { + PostCallback = CB; + } + /// Returns the sysroot path. StringRef getSysRoot() const; -------------- next part -------------- A non-text attachment was scrubbed... Name: D78899.276945.patch Type: text/x-patch Size: 2720 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:22:51 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:22:51 +0000 (UTC) Subject: [PATCH] D83539: [analyzer][tests] Introduce analyzer benchmarking framework Message-ID: vsavchenko created this revision. vsavchenko added reviewers: NoQ, xazax.hun, dcoughlin. Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware. Herald added a project: clang. This commit includes a couple of changes: - Benchmark selected projects by analyzing them multiple times - Compare two benchmarking results and visualizing them on one chart - Organize project build logging, so we can use the same code in benchmarks Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83539 Files: clang/utils/analyzer/SATest.py clang/utils/analyzer/SATestBenchmark.py clang/utils/analyzer/SATestBuild.py clang/utils/analyzer/SATestUpdateDiffs.py clang/utils/analyzer/requirements.txt -------------- next part -------------- A non-text attachment was scrubbed... Name: D83539.276946.patch Type: text/x-patch Size: 19426 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:29:09 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:29:09 +0000 (UTC) Subject: [PATCH] D83536: [clangd] Index refs to main-file symbols as well In-Reply-To: References: Message-ID: kadircet added a comment. Thanks a lot for doing this Nathan and sorry for not replying with a concrete decision on the issue tracker, we were still discussing it internally, as 7% increase for allowing multi-level call hierarchy support (compared to ~10% initial cost for single-level support) seems quite high. Especially right before a new llvm release cut (which is due in 5 days). I can see how this is needed for implementing the full protocol though (we've already cut on the multi-level callees support), so would you be so kind to hide this behind an option to symbol collector (`CollectRefsInMainFile`) and then introduce a flag to clangd for controlling it `--collect-refs-in-main-file` and plumb it to `BackgroundIndex` and `FileIndex` via `ClangdServer`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83536/new/ https://reviews.llvm.org/D83536 From cfe-commits at lists.llvm.org Fri Jul 10 01:33:16 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via cfe-commits) Date: Fri, 10 Jul 2020 01:33:16 -0700 (PDT) Subject: [clang] 21bacc2 - [analyzer][tests] Measure peak memory consumption for every project Message-ID: <5f0827cc.1c69fb81.d4603.d2fd@mx.google.com> Author: Valeriy Savchenko Date: 2020-07-10T11:31:41+03:00 New Revision: 21bacc215413d10df53a4690e9561e9b96698742 URL: https://github.com/llvm/llvm-project/commit/21bacc215413d10df53a4690e9561e9b96698742 DIFF: https://github.com/llvm/llvm-project/commit/21bacc215413d10df53a4690e9561e9b96698742.diff LOG: [analyzer][tests] Measure peak memory consumption for every project Differential Revision: https://reviews.llvm.org/D82967 Added: clang/utils/analyzer/requirements.txt Modified: clang/utils/analyzer/Dockerfile clang/utils/analyzer/SATestBuild.py clang/utils/analyzer/SATestUtils.py Removed: ################################################################################ diff --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile index 30fb67cf93c8..21906011c7dc 100644 --- a/clang/utils/analyzer/Dockerfile +++ b/clang/utils/analyzer/Dockerfile @@ -54,8 +54,7 @@ ENV PATH="/analyzer/bin:${PATH}" ADD entrypoint.py /entrypoint.py -# Uncomment in case of requirements -# ADD requirements.txt /requirements.txt -# RUN pip3 install -r /requirements.txt +ADD requirements.txt /requirements.txt +RUN pip3 install -r /requirements.txt ENTRYPOINT ["python", "/entrypoint.py"] diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py index 7d337632744f..ee510e03cc5a 100644 --- a/clang/utils/analyzer/SATestBuild.py +++ b/clang/utils/analyzer/SATestBuild.py @@ -43,7 +43,7 @@ variable. It should contain a comma separated list. """ import CmpRuns -import SATestUtils +import SATestUtils as utils from ProjectMap import DownloadType, ProjectInfo import glob @@ -63,7 +63,7 @@ # and this is we can shush that false positive from plistlib import InvalidFileException # type:ignore from subprocess import CalledProcessError, check_call -from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING +from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING, Tuple ############################################################################### @@ -115,7 +115,7 @@ def stdout(message: str): if 'CC' in os.environ: cc_candidate: Optional[str] = os.environ['CC'] else: - cc_candidate = SATestUtils.which("clang", os.environ['PATH']) + cc_candidate = utils.which("clang", os.environ['PATH']) if not cc_candidate: stderr("Error: cannot find 'clang' in PATH") sys.exit(1) @@ -194,9 +194,9 @@ def run_cleanup_script(directory: str, build_log_file: IO): cwd = os.path.join(directory, PATCHED_SOURCE_DIR_NAME) script_path = os.path.join(directory, CLEANUP_SCRIPT) - SATestUtils.run_script(script_path, build_log_file, cwd, - out=LOCAL.stdout, err=LOCAL.stderr, - verbose=VERBOSE) + utils.run_script(script_path, build_log_file, cwd, + out=LOCAL.stdout, err=LOCAL.stderr, + verbose=VERBOSE) class TestInfo(NamedTuple): @@ -351,8 +351,6 @@ def get_output_dir(self) -> str: return OUTPUT_DIR_NAME def build(self, directory: str, output_dir: str): - time_start = time.time() - build_log_path = get_build_log_path(output_dir) stdout(f"Log file: {build_log_path}\n") @@ -375,19 +373,23 @@ def build(self, directory: str, output_dir: str): if self.project.mode == 1: self._download_and_patch(directory, build_log_file) run_cleanup_script(directory, build_log_file) - self.scan_build(directory, output_dir, build_log_file) + build_time, memory = self.scan_build(directory, output_dir, + build_log_file) else: - self.analyze_preprocessed(directory, output_dir) + build_time, memory = self.analyze_preprocessed(directory, + output_dir) if self.is_reference_build: run_cleanup_script(directory, build_log_file) normalize_reference_results(directory, output_dir, self.project.mode) - stdout(f"Build complete (time: {time.time() - time_start:.2f}). " + stdout(f"Build complete (time: {utils.time_to_str(build_time)}, " + f"peak memory: {utils.memory_to_str(memory)}). " f"See the log for more details: {build_log_path}\n") - def scan_build(self, directory: str, output_dir: str, build_log_file: IO): + def scan_build(self, directory: str, output_dir: str, + build_log_file: IO) -> Tuple[float, int]: """ Build the project with scan-build by reading in the commands and prefixing them with the scan-build options. @@ -416,6 +418,10 @@ def scan_build(self, directory: str, output_dir: str, build_log_file: IO): options += "--override-compiler " extra_env: Dict[str, str] = {} + + execution_time = 0.0 + peak_memory = 0 + try: command_file = open(build_script_path, "r") command_prefix = "scan-build " + options + " " @@ -451,11 +457,15 @@ def scan_build(self, directory: str, output_dir: str, build_log_file: IO): if VERBOSE >= 1: stdout(f" Executing: {command_to_run}\n") - check_call(command_to_run, cwd=cwd, - stderr=build_log_file, - stdout=build_log_file, - env=dict(os.environ, **extra_env), - shell=True) + time, mem = utils.check_and_measure_call( + command_to_run, cwd=cwd, + stderr=build_log_file, + stdout=build_log_file, + env=dict(os.environ, **extra_env), + shell=True) + + execution_time += time + peak_memory = max(peak_memory, mem) except CalledProcessError: stderr("Error: scan-build failed. Its output was: \n") @@ -463,7 +473,10 @@ def scan_build(self, directory: str, output_dir: str, build_log_file: IO): shutil.copyfileobj(build_log_file, LOCAL.stderr) sys.exit(1) - def analyze_preprocessed(self, directory: str, output_dir: str): + return execution_time, peak_memory + + def analyze_preprocessed(self, directory: str, + output_dir: str) -> Tuple[float, int]: """ Run analysis on a set of preprocessed files. """ @@ -487,14 +500,17 @@ def analyze_preprocessed(self, directory: str, output_dir: str): fail_path = os.path.join(plist_path, "failures") os.makedirs(fail_path) + execution_time = 0.0 + peak_memory = 0 + for full_file_name in glob.glob(directory + "/*"): file_name = os.path.basename(full_file_name) failed = False # Only run the analyzes on supported files. - if SATestUtils.has_no_extension(file_name): + if utils.has_no_extension(file_name): continue - if not SATestUtils.is_valid_single_input_file(file_name): + if not utils.is_valid_single_input_file(file_name): stderr(f"Error: Invalid single input file {full_file_name}.\n") raise Exception() @@ -509,8 +525,12 @@ def analyze_preprocessed(self, directory: str, output_dir: str): if VERBOSE >= 1: stdout(f" Executing: {command}\n") - check_call(command, cwd=directory, stderr=log_file, - stdout=log_file, shell=True) + time, mem = utils.check_and_measure_call( + command, cwd=directory, stderr=log_file, + stdout=log_file, shell=True) + + execution_time += time + peak_memory = max(peak_memory, mem) except CalledProcessError as e: stderr(f"Error: Analyzes of {full_file_name} failed. " @@ -522,6 +542,8 @@ def analyze_preprocessed(self, directory: str, output_dir: str): if not failed: os.remove(log_file.name) + return execution_time, peak_memory + def generate_config(self) -> str: out = "serialize-stats=true,stable-report-filename=true" @@ -598,9 +620,9 @@ def _unpack_zip(self, directory: str, build_log_file: IO): @staticmethod def _run_download_script(directory: str, build_log_file: IO): script_path = os.path.join(directory, DOWNLOAD_SCRIPT) - SATestUtils.run_script(script_path, build_log_file, directory, - out=LOCAL.stdout, err=LOCAL.stderr, - verbose=VERBOSE) + utils.run_script(script_path, build_log_file, directory, + out=LOCAL.stdout, err=LOCAL.stderr, + verbose=VERBOSE) @staticmethod def _apply_patch(directory: str, build_log_file: IO): diff --git a/clang/utils/analyzer/SATestUtils.py b/clang/utils/analyzer/SATestUtils.py index 4e126e66b869..3947e183d82f 100644 --- a/clang/utils/analyzer/SATestUtils.py +++ b/clang/utils/analyzer/SATestUtils.py @@ -1,8 +1,9 @@ import os import sys +import time from subprocess import CalledProcessError, check_call -from typing import List, IO, Optional +from typing import List, IO, Optional, Tuple def which(command: str, paths: Optional[str] = None) -> Optional[str]: @@ -47,6 +48,87 @@ def is_valid_single_input_file(file_name: str) -> bool: return ext in (".i", ".ii", ".c", ".cpp", ".m", "") +def time_to_str(time: float) -> str: + """ + Convert given time in seconds into a human-readable string. + """ + return f"{time:.2f}s" + + +def memory_to_str(memory: int) -> str: + """ + Convert given number of bytes into a human-readable string. + """ + if memory: + try: + import humanize + return humanize.naturalsize(memory, gnu=True) + except ImportError: + # no formatter installed, let's keep it in bytes + return f"{memory}B" + + # If memory is 0, we didn't succeed measuring it. + return "N/A" + + +def check_and_measure_call(*popenargs, **kwargs) -> Tuple[float, int]: + """ + Run command with arguments. Wait for command to complete and measure + execution time and peak memory consumption. + If the exit code was zero then return, otherwise raise + CalledProcessError. The CalledProcessError object will have the + return code in the returncode attribute. + + The arguments are the same as for the call and check_call functions. + + Return a tuple of execution time and peak memory. + """ + peak_mem = 0 + start_time = time.time() + + try: + import psutil as ps + + def get_memory(process: ps.Process) -> int: + mem = 0 + + # we want to gather memory usage from all of the child processes + descendants = list(process.children(recursive=True)) + descendants.append(process) + + for subprocess in descendants: + try: + mem += subprocess.memory_info().rss + except (ps.NoSuchProcess, ps.AccessDenied): + continue + + return mem + + with ps.Popen(*popenargs, **kwargs) as process: + # while the process is running calculate resource utilization. + while (process.is_running() and + process.status() != ps.STATUS_ZOMBIE): + # track the peak utilization of the process + peak_mem = max(peak_mem, get_memory(process)) + time.sleep(.5) + + if process.is_running(): + process.kill() + + if process.returncode != 0: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + raise CalledProcessError(process.returncode, cmd) + + except ImportError: + # back off to subprocess if we don't have psutil installed + peak_mem = 0 + check_call(*popenargs, **kwargs) + + return time.time() - start_time, peak_mem + + def run_script(script_path: str, build_log_file: IO, cwd: str, out=sys.stdout, err=sys.stderr, verbose: int = 0): """ diff --git a/clang/utils/analyzer/requirements.txt b/clang/utils/analyzer/requirements.txt new file mode 100644 index 000000000000..ec4f66929952 --- /dev/null +++ b/clang/utils/analyzer/requirements.txt @@ -0,0 +1,4 @@ +graphviz +humanize +matplotlib +psutil From cfe-commits at lists.llvm.org Fri Jul 10 01:33:19 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via cfe-commits) Date: Fri, 10 Jul 2020 01:33:19 -0700 (PDT) Subject: [clang] 9c7ff0a - [analyzer][tests] Make test interruption safe Message-ID: <5f0827cf.1c69fb81.a59b7.d85b@mx.google.com> Author: Valeriy Savchenko Date: 2020-07-10T11:31:59+03:00 New Revision: 9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9 URL: https://github.com/llvm/llvm-project/commit/9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9 DIFF: https://github.com/llvm/llvm-project/commit/9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9.diff LOG: [analyzer][tests] Make test interruption safe Differential Revision: https://reviews.llvm.org/D83373 Added: Modified: clang/utils/analyzer/SATest.py Removed: ################################################################################ diff --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py index fb2e031c6ab6..16f1dce0c584 100755 --- a/clang/utils/analyzer/SATest.py +++ b/clang/utils/analyzer/SATest.py @@ -132,27 +132,35 @@ def docker_shell(args): pass finally: - print("Please wait for docker to clean up") - call("docker stop satest", shell=True) + docker_cleanup() def docker_run(args, command, docker_args=""): - return call("docker run --rm --name satest " - "-v {llvm}:/llvm-project " - "-v {build}:/build " - "-v {clang}:/analyzer " - "-v {scripts}:/scripts " - "-v {projects}:/projects " - "{docker_args} " - "satest-image:latest {command}" - .format(llvm=args.llvm_project_dir, - build=args.build_dir, - clang=args.clang_dir, - scripts=SCRIPTS_DIR, - projects=PROJECTS_DIR, - docker_args=docker_args, - command=command), - shell=True) + try: + return call("docker run --rm --name satest " + "-v {llvm}:/llvm-project " + "-v {build}:/build " + "-v {clang}:/analyzer " + "-v {scripts}:/scripts " + "-v {projects}:/projects " + "{docker_args} " + "satest-image:latest {command}" + .format(llvm=args.llvm_project_dir, + build=args.build_dir, + clang=args.clang_dir, + scripts=SCRIPTS_DIR, + projects=PROJECTS_DIR, + docker_args=docker_args, + command=command), + shell=True) + + except KeyboardInterrupt: + docker_cleanup() + + +def docker_cleanup(): + print("Please wait for docker to clean up") + call("docker stop satest", shell=True) def main(): From cfe-commits at lists.llvm.org Fri Jul 10 01:33:21 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via cfe-commits) Date: Fri, 10 Jul 2020 01:33:21 -0700 (PDT) Subject: [clang] 00997d1 - [analyzer][tests] Fix zip unpacking Message-ID: <5f0827d1.1c69fb81.c8967.cd96@mx.google.com> Author: Valeriy Savchenko Date: 2020-07-10T11:32:13+03:00 New Revision: 00997d1cad9ecd40c92aeae40269f6bfb9e58d11 URL: https://github.com/llvm/llvm-project/commit/00997d1cad9ecd40c92aeae40269f6bfb9e58d11 DIFF: https://github.com/llvm/llvm-project/commit/00997d1cad9ecd40c92aeae40269f6bfb9e58d11.diff LOG: [analyzer][tests] Fix zip unpacking Differential Revision: https://reviews.llvm.org/D83374 Added: Modified: clang/utils/analyzer/SATestBuild.py Removed: ################################################################################ diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py index ee510e03cc5a..eefab869f6ef 100644 --- a/clang/utils/analyzer/SATestBuild.py +++ b/clang/utils/analyzer/SATestBuild.py @@ -601,7 +601,7 @@ def _download_from_git(self, directory: str, build_log_file: IO): stdout=build_log_file, shell=True) def _unpack_zip(self, directory: str, build_log_file: IO): - zip_files = list(glob.glob(os.path.join(directory, "/*.zip"))) + zip_files = list(glob.glob(directory + "/*.zip")) if len(zip_files) == 0: raise ValueError( From cfe-commits at lists.llvm.org Fri Jul 10 01:33:29 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:33:29 +0000 (UTC) Subject: [PATCH] D82967: [analyzer][tests] Measure peak memory consumption for every project In-Reply-To: References: Message-ID: <17c511d7df03af202bacbc39abfd3b4d@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG21bacc215413: [analyzer][tests] Measure peak memory consumption for every project (authored by vsavchenko). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82967/new/ https://reviews.llvm.org/D82967 Files: clang/utils/analyzer/Dockerfile clang/utils/analyzer/SATestBuild.py clang/utils/analyzer/SATestUtils.py clang/utils/analyzer/requirements.txt -------------- next part -------------- A non-text attachment was scrubbed... Name: D82967.276947.patch Type: text/x-patch Size: 11263 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:33:33 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:33:33 +0000 (UTC) Subject: [PATCH] D83373: [analyzer][tests] Make test interruption safe In-Reply-To: References: Message-ID: <62128479f805bdd9674a907c53ce2e61@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG9c7ff0a4aaef: [analyzer][tests] Make test interruption safe (authored by vsavchenko). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83373/new/ https://reviews.llvm.org/D83373 Files: clang/utils/analyzer/SATest.py Index: clang/utils/analyzer/SATest.py =================================================================== --- clang/utils/analyzer/SATest.py +++ clang/utils/analyzer/SATest.py @@ -132,27 +132,35 @@ pass finally: - print("Please wait for docker to clean up") - call("docker stop satest", shell=True) + docker_cleanup() def docker_run(args, command, docker_args=""): - return call("docker run --rm --name satest " - "-v {llvm}:/llvm-project " - "-v {build}:/build " - "-v {clang}:/analyzer " - "-v {scripts}:/scripts " - "-v {projects}:/projects " - "{docker_args} " - "satest-image:latest {command}" - .format(llvm=args.llvm_project_dir, - build=args.build_dir, - clang=args.clang_dir, - scripts=SCRIPTS_DIR, - projects=PROJECTS_DIR, - docker_args=docker_args, - command=command), - shell=True) + try: + return call("docker run --rm --name satest " + "-v {llvm}:/llvm-project " + "-v {build}:/build " + "-v {clang}:/analyzer " + "-v {scripts}:/scripts " + "-v {projects}:/projects " + "{docker_args} " + "satest-image:latest {command}" + .format(llvm=args.llvm_project_dir, + build=args.build_dir, + clang=args.clang_dir, + scripts=SCRIPTS_DIR, + projects=PROJECTS_DIR, + docker_args=docker_args, + command=command), + shell=True) + + except KeyboardInterrupt: + docker_cleanup() + + +def docker_cleanup(): + print("Please wait for docker to clean up") + call("docker stop satest", shell=True) def main(): -------------- next part -------------- A non-text attachment was scrubbed... Name: D83373.276948.patch Type: text/x-patch Size: 2087 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:33:37 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:33:37 +0000 (UTC) Subject: [PATCH] D83374: [analyzer][tests] Fix zip unpacking In-Reply-To: References: Message-ID: <72f54a1e4acc4617736d68a2e628bfbb@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG00997d1cad9e: [analyzer][tests] Fix zip unpacking (authored by vsavchenko). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83374/new/ https://reviews.llvm.org/D83374 Files: clang/utils/analyzer/SATestBuild.py Index: clang/utils/analyzer/SATestBuild.py =================================================================== --- clang/utils/analyzer/SATestBuild.py +++ clang/utils/analyzer/SATestBuild.py @@ -601,7 +601,7 @@ stdout=build_log_file, shell=True) def _unpack_zip(self, directory: str, build_log_file: IO): - zip_files = list(glob.glob(os.path.join(directory, "/*.zip"))) + zip_files = list(glob.glob(directory + "/*.zip")) if len(zip_files) == 0: raise ValueError( -------------- next part -------------- A non-text attachment was scrubbed... Name: D83374.276949.patch Type: text/x-patch Size: 529 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:35:20 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:35:20 +0000 (UTC) Subject: [PATCH] D83539: [analyzer][tests] Introduce analyzer benchmarking framework In-Reply-To: References: Message-ID: vsavchenko updated this revision to Diff 276950. vsavchenko added a comment. Rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83539/new/ https://reviews.llvm.org/D83539 Files: clang/utils/analyzer/SATest.py clang/utils/analyzer/SATestBenchmark.py clang/utils/analyzer/SATestBuild.py clang/utils/analyzer/SATestUpdateDiffs.py clang/utils/analyzer/requirements.txt -------------- next part -------------- A non-text attachment was scrubbed... Name: D83539.276950.patch Type: text/x-patch Size: 19426 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:40:28 2020 From: cfe-commits at lists.llvm.org (Valeriy Savchenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:40:28 +0000 (UTC) Subject: [PATCH] D83539: [analyzer][tests] Introduce analyzer benchmarking framework In-Reply-To: References: Message-ID: vsavchenko added a comment. Here is an example of how benchmarking chart looks like: F12321843: plot2.png It has 20 runs on each of those projects. It was the same revision of the analyzer, so it is still very sensitive to other stuff happening on the test machine. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83539/new/ https://reviews.llvm.org/D83539 From cfe-commits at lists.llvm.org Fri Jul 10 01:42:55 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:42:55 +0000 (UTC) Subject: [PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts. In-Reply-To: References: Message-ID: <4d659c3211742e9ffd7d81f12ce3119f@localhost.localdomain> ebevhan marked an inline comment as done. ebevhan added inline comments. ================ Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3857 + + // TODO: This misses out on the sanitizer check below. + if (Ops.isFixedPointOp()) ---------------- leonardchan wrote: > I don't suppose you could file a bug for this and CC me on it so we can remember to do this sometime after this lands? I could do that. I guess the issue is larger than just this; I think other ops do not get proper UBSan checks for fixedpoint. So the ticket would probably entail supporting UBSan for fixedpoint, which is maybe a bit larger in scope. ================ Comment at: clang/test/Frontend/fixed_point_compound.c:388-390 + // UNSIGNED-NEXT: [[TMP7:%.*]] = icmp slt i16 [[TMP6]], 0 + // UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP7]], i16 0, i16 [[TMP6]] + // UNSIGNED-NEXT: store i16 [[SATMIN]], i16* @suf, align 2 ---------------- leonardchan wrote: > I'm assuming these checks are also a result of D82663? I don't think for the padding case, we should need to do the compare and select if we're already using the signed sat intrinsic. But I'm guessing it might make the implementation more complicated by having to check for this. > > If this codegen comes from the `EmitFixedPointConversion` at the end of `EmitFixedPointBinOp`, perhaps it might be worthwhile adding a parameter in `EmitFixedPointConversion` to indicate that we shouldn't emit this. I think there's some cases in D82663 also where we might not need to do these checks afterwards with other operations like with: > > ``` > // UNSIGNED-NEXT: [[TMP25:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP22]], i16 32767) > // UNSIGNED-NEXT: [[TMP26:%.*]] = icmp slt i16 [[TMP25]], 0 > // UNSIGNED-NEXT: [[SATMIN2:%.*]] = select i1 [[TMP26]], i16 0, i16 [[TMP25]] > // UNSIGNED-NEXT: store i16 [[SATMIN2]], i16* @suf, align 2 > ``` Yes, this is correct. And it is also correct that in the case of shift (and other operations) it is not necessary. It was just more elegant to make the common semantic signed and the result semantic unsigned and get the clamp automatically. I think the alternative is to handle the signedness of ops separate from the semantic during codegen and then emit a clamp manually per-operation instead of relying on the result conversion. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83294/new/ https://reviews.llvm.org/D83294 From cfe-commits at lists.llvm.org Fri Jul 10 01:48:16 2020 From: cfe-commits at lists.llvm.org (Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:48:16 +0000 (UTC) Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu In-Reply-To: References: Message-ID: <3f1781a12d833fcb238b155b76a99817@localhost.localdomain> khchen updated this revision to Diff 276951. khchen added a comment. addess asb's comment. [RISCV][Clang] Support -mcpu option. Summary: 1. gcc uses `-march` and `-mtune` flag to chose arch and pipeline model, but clang does not have `-mtune` flag, we uses `-mcpu` to chose both info. 2. Add SiFive e31 and u54 cpu which have default march and pipeline model. 3. Specific `-mcpu` with rocket-rv[32|64] would select pipeline model only, and use the driver's arch choosing logic to get default arch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71124/new/ https://reviews.llvm.org/D71124 Files: clang/lib/Basic/Targets/RISCV.cpp clang/lib/Basic/Targets/RISCV.h clang/lib/Driver/ToolChains/Arch/RISCV.cpp clang/lib/Driver/ToolChains/Arch/RISCV.h clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/riscv-cpus.c llvm/include/llvm/Support/RISCVTargetParser.def llvm/include/llvm/Support/TargetParser.h llvm/lib/Support/TargetParser.cpp llvm/lib/Target/RISCV/RISCV.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D71124.276951.patch Type: text/x-patch Size: 17919 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:49:35 2020 From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:49:35 +0000 (UTC) Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures In-Reply-To: References: Message-ID: <7f15282f031666d47926d09f210786f0@localhost.localdomain> DavidSpickett updated this revision to Diff 276952. DavidSpickett added a comment. - mv with stderr redirected instead of using non standard file -E flag Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83055/new/ https://reviews.llvm.org/D83055 Files: clang/test/Driver/program-path-priority.c clang/test/lit.cfg.py -------------- next part -------------- A non-text attachment was scrubbed... Name: D83055.276952.patch Type: text/x-patch Size: 7716 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 01:50:55 2020 From: cfe-commits at lists.llvm.org (Hans Wennborg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:50:55 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: hans accepted this revision. hans added a comment. Still lgtm. For what it's worth, I think you could have just re-committed with the fixes rather than uploading for review again. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Fri Jul 10 01:51:24 2020 From: cfe-commits at lists.llvm.org (Stephan Herhut via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:51:24 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: herhut added a comment. Could you add the normalization back? This is in line with the comment to make sure the old and new files align. ================ Comment at: clang/include/clang/Driver/Options.td:3455 + HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, + MarshallingInfoString<"TargetOpts->Triple", "llvm::sys::getDefaultTargetTriple()", "std::string">, + AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; ---------------- There is some explicit normalization missing here. In CC1Options.td this is ``` def triple : Separate<["-"], "triple">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">, AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; ``` It seems the normalizer does not apply to the defaults and we now see a failure in `clang/unittests/Frontend/CompilerInvocationTest.cpp` for powerpc targets. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 01:52:10 2020 From: cfe-commits at lists.llvm.org (David Spickett via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 08:52:10 +0000 (UTC) Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures In-Reply-To: References: Message-ID: <6afd9fdaae9a360452696b035dae279c@localhost.localdomain> DavidSpickett marked 2 inline comments as done. DavidSpickett added inline comments. ================ Comment at: clang/test/Driver/program-path-priority.c:117 +/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple +// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \ +// RUN: mv %t/$DEFAULT_TRIPLE-gcc %t/prefix || true ---------------- stevewan wrote: > Maybe I'm not seeing something obvious here, but I'm not aware of the `file -E` usage, and on Linux I got `file: invalid option -- 'E'`. I was looking for a way to mimic [! -f ], which worked on the command line but not in a test. From my system's file: -E On filesystem errors (file not found etc), instead of handling the error as regu‐ lar output as POSIX mandates and keep going, issue an error message and exit. I didn't realise it was non-standard, so I've switched to mv || true with the error redirected so it won't confuse the verbose output. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83055/new/ https://reviews.llvm.org/D83055 From cfe-commits at lists.llvm.org Fri Jul 10 02:13:38 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:13:38 +0000 (UTC) Subject: [PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor. In-Reply-To: References: Message-ID: <864b0e48a49d22c19a2e6d21464378d2@localhost.localdomain> kadircet added a comment. thanks for doing this! but i believe these look like bugs that should be addressed in other components, rather than worked around in hover. the first example is likely a bug in selection tree, file location corresponds to a macro body that's never expanded, which resides inside a namespace (who's declaration contains everything within it's braces), hence selection tree attributes the selection to the namespace because there's no fine-grained children around the cursor. the second one is likely a bug in ast-traversal logic, i suppose the function doesn't get a `TypeSourceInfo` when it is `invalid`, hence we don't get to traverse its parameters(children) and therefore assume all the declaration belongs to function itself. --- As for your workaround in hover, it is surprising that no other tests has regressed, but in theory `D->getLocation` only corresponds to the main token in a declaration (e.g. name of a function), and hover can refer to declarations whose names are away from the cursor, e.g. if you are on (closing) parens of a function/ctor call. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83508/new/ https://reviews.llvm.org/D83508 From cfe-commits at lists.llvm.org Fri Jul 10 02:18:48 2020 From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:18:48 +0000 (UTC) Subject: [PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff. In-Reply-To: References: Message-ID: nikic added a comment. Numbers for the new patch: https://llvm-compile-time-tracker.com/compare.php?from=c0308fd154f9a945608bd42630dc81dce5edfb40&to=e6e3534e77961cfa65d36828de5c75f36a25d009&stat=instructions The regression is definitely smaller now, but still fairly large. E.g. > 2% on mafft. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77341/new/ https://reviews.llvm.org/D77341 From cfe-commits at lists.llvm.org Fri Jul 10 02:22:51 2020 From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:22:51 +0000 (UTC) Subject: [PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor. In-Reply-To: References: Message-ID: <39644cd6173a062684df7c4c61bcb6a7@localhost.localdomain> ArcsinX added a comment. @kadircet Thanks for your reply. Think that you are right, because the same problem appears in GTD (with the same test cases). And as for GTD the similar workaround also does not break any regression tests except override/final. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83508/new/ https://reviews.llvm.org/D83508 From cfe-commits at lists.llvm.org Fri Jul 10 02:25:56 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:25:56 +0000 (UTC) Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit. In-Reply-To: References: Message-ID: <5c3d1d06f857f836704051e7f4a6b9b2@localhost.localdomain> hokein updated this revision to Diff 276959. hokein added a comment. Clarify the documentation for dependence-bits, and extend it to error. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83213/new/ https://reviews.llvm.org/D83213 Files: clang/include/clang/AST/DependenceFlags.h clang/include/clang/AST/Expr.h clang/lib/AST/ComputeDependence.cpp clang/lib/Sema/SemaExpr.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83213.276959.patch Type: text/x-patch Size: 9094 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 02:26:42 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:26:42 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: <90c0f585a9f1a0de2e673724cac45304@localhost.localdomain> eduucaldas updated this revision to Diff 276960. eduucaldas added a comment. - Add comment explaining complication on LOK_Raw and LOK_Template - Use FileRange::text instead of Lexer::getSpelling Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 Files: clang/include/clang/Tooling/Syntax/Nodes.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Syntax/Nodes.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82157.276960.patch Type: text/x-patch Size: 13572 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 02:28:12 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:28:12 +0000 (UTC) Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit. In-Reply-To: References: Message-ID: <5f4dadaa8a42d92bf1fa493e1946726d@localhost.localdomain> hokein updated this revision to Diff 276961. hokein added a comment. more tweaks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83213/new/ https://reviews.llvm.org/D83213 Files: clang/include/clang/AST/DependenceFlags.h clang/include/clang/AST/Expr.h clang/lib/AST/ComputeDependence.cpp clang/lib/Sema/SemaExpr.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83213.276961.patch Type: text/x-patch Size: 9089 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 02:28:47 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:28:47 +0000 (UTC) Subject: [PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of RecoveryExpr. In-Reply-To: References: Message-ID: <8081d90d19b903d07874249339431ce3@localhost.localdomain> hokein abandoned this revision. hokein added a comment. closing this in favor of D83213 . Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83215/new/ https://reviews.llvm.org/D83215 From cfe-commits at lists.llvm.org Fri Jul 10 02:41:51 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:41:51 +0000 (UTC) Subject: [PATCH] D83301: [clang-tidy] More strict on matching the standard memset function in memset-usage check. In-Reply-To: References: Message-ID: hokein added a comment. thanks for the review. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83301/new/ https://reviews.llvm.org/D83301 From cfe-commits at lists.llvm.org Fri Jul 10 02:42:45 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via cfe-commits) Date: Fri, 10 Jul 2020 02:42:45 -0700 (PDT) Subject: [clang-tools-extra] 5f41ca4 - [clang-tidy] More strict on matching the standard memset function in memset-usage check. Message-ID: <5f083815.1c69fb81.fdf28.c43c@mx.google.com> Author: Haojian Wu Date: 2020-07-10T11:42:35+02:00 New Revision: 5f41ca48d1c46fc78958d47c0edfb2dbcde47217 URL: https://github.com/llvm/llvm-project/commit/5f41ca48d1c46fc78958d47c0edfb2dbcde47217 DIFF: https://github.com/llvm/llvm-project/commit/5f41ca48d1c46fc78958d47c0edfb2dbcde47217.diff LOG: [clang-tidy] More strict on matching the standard memset function in memset-usage check. The check assumed the matched function call has 3 arguments, but the matcher didn't guaranteed that. Differential Revision: https://reviews.llvm.org/D83301 Added: Modified: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp index 9f98316984ed..37748d9fa8cc 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp @@ -20,11 +20,19 @@ namespace tidy { namespace bugprone { void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) { - // Note: void *memset(void *buffer, int fill_char, size_t byte_count); + // Match the standard memset: + // void *memset(void *buffer, int fill_char, size_t byte_count); + auto MemsetDecl = + functionDecl(hasName("::memset"), + parameterCountIs(3), + hasParameter(0, hasType(pointerType(pointee(voidType())))), + hasParameter(1, hasType(isInteger())), + hasParameter(2, hasType(isInteger()))); + // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended. Finder->addMatcher( callExpr( - callee(functionDecl(hasName("::memset"))), + callee(MemsetDecl), hasArgument(1, characterLiteral(equals(static_cast('0'))) .bind("char-zero-fill")), unless( @@ -36,14 +44,14 @@ void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) { // Look for memset with an integer literal in its fill_char argument. // Will check if it gets truncated. - Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))), + Finder->addMatcher(callExpr(callee(MemsetDecl), hasArgument(1, integerLiteral().bind("num-fill")), unless(isInTemplateInstantiation())), this); // Look for memset(x, y, 0) as that is most likely an argument swap. Finder->addMatcher( - callExpr(callee(functionDecl(hasName("::memset"))), + callExpr(callee(MemsetDecl), unless(hasArgument(1, anyOf(characterLiteral(equals( static_cast('0'))), integerLiteral()))), diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp index f33ae5ae10a8..9a7e423f4012 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp @@ -75,3 +75,8 @@ void foo(int xsize, int ysize) { // despite v == 0. memset(p, -1, v); } + +void *memset(int); +void NoCrash() { + memset(1); +} From cfe-commits at lists.llvm.org Fri Jul 10 02:42:53 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 09:42:53 +0000 (UTC) Subject: [PATCH] D83301: [clang-tidy] More strict on matching the standard memset function in memset-usage check. In-Reply-To: References: Message-ID: <32e4332dc8678496667f9a56af7b5897@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG5f41ca48d1c4: [clang-tidy] More strict on matching the standard memset function in memset… (authored by hokein). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83301/new/ https://reviews.llvm.org/D83301 Files: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp +++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp @@ -75,3 +75,8 @@ // despite v == 0. memset(p, -1, v); } + +void *memset(int); +void NoCrash() { + memset(1); +} Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp +++ clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp @@ -20,11 +20,19 @@ namespace bugprone { void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) { - // Note: void *memset(void *buffer, int fill_char, size_t byte_count); + // Match the standard memset: + // void *memset(void *buffer, int fill_char, size_t byte_count); + auto MemsetDecl = + functionDecl(hasName("::memset"), + parameterCountIs(3), + hasParameter(0, hasType(pointerType(pointee(voidType())))), + hasParameter(1, hasType(isInteger())), + hasParameter(2, hasType(isInteger()))); + // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended. Finder->addMatcher( callExpr( - callee(functionDecl(hasName("::memset"))), + callee(MemsetDecl), hasArgument(1, characterLiteral(equals(static_cast('0'))) .bind("char-zero-fill")), unless( @@ -36,14 +44,14 @@ // Look for memset with an integer literal in its fill_char argument. // Will check if it gets truncated. - Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))), + Finder->addMatcher(callExpr(callee(MemsetDecl), hasArgument(1, integerLiteral().bind("num-fill")), unless(isInTemplateInstantiation())), this); // Look for memset(x, y, 0) as that is most likely an argument swap. Finder->addMatcher( - callExpr(callee(functionDecl(hasName("::memset"))), + callExpr(callee(MemsetDecl), unless(hasArgument(1, anyOf(characterLiteral(equals( static_cast('0'))), integerLiteral()))), -------------- next part -------------- A non-text attachment was scrubbed... Name: D83301.276968.patch Type: text/x-patch Size: 2526 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 03:43:59 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 10:43:59 +0000 (UTC) Subject: [PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor. In-Reply-To: References: Message-ID: <54f7d18d105bd27e8d4860c497cd22f9@localhost.localdomain> sammccall added a comment. Yeah SelectionTree is the right place to solve this but it's a harder problem there. In general we *don't* only want to trigger on the single token returned by getLocation(). The strategy SelectionTree uses is to attribute tokens to an outer node unless they're associated with an inner node or ignored. Your test cases show two problems with this strategy: - we ignore comments and semicolons, but not preprocessor directives (or disabled preprocessor regions). I think we can fix this by asking TokenBuffer if a spelled token is part of a region that maps to no (PP-)expanded tokens. - in the case of syntax errors, tokens are emitted by the preprocessor but then no AST node is built from them, and we associate them with the parent by default. Maybe we don't need to fix this case? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83508/new/ https://reviews.llvm.org/D83508 From cfe-commits at lists.llvm.org Fri Jul 10 03:47:35 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 10:47:35 +0000 (UTC) Subject: [PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'. In-Reply-To: References: Message-ID: Szelethus added a comment. In D72705#2143405 , @balazske wrote: > We must check on every execution path that a specific condition on a value is satisfied (or: find one where the condition is not satisfied). This would be the most simple form of this checker. This can be done with the path sensitive check and `checkDeadSymbols`. If the symbol becomes dead with unsatisfied condition a warning is emitted. The "condition" is a syntactic-like check that looks for code like "`X != EOF`". This is probably done best by using `StmtVisitor` if a value is evaluated (at assignment or condition in `if` or other statements), different than the current form. Pathsensitivity is about checking **one** specific path of execution with rather great precision, we really need dataflow to argue about **all** paths. Syntactic checking and pathsensitive analysis fundamentally lacks a lot of information that dataflow by design has. With that said, asking whether a symbol is dead is a part of liveness analysis which is a dataflow algorithm, but what that interface lacks is //why// a symbol is live/dead. I think what you need here is a set of reads reachable from the return value point. For this example, you are interested in which reads are reachable from b9, and you could analyze them one-by-one (which could be done syntactically at that point): c = fgetc(fd); // [b9] if (c == '+' || c == '*' || c == '|' || c == '>' || c == '@' || c == EOF || c == '\n') { [b1] } // [b8] [b7] [b6] [b5] [b4] [b3] [b2] // [b0 (EXIT)] Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72705/new/ https://reviews.llvm.org/D72705 From cfe-commits at lists.llvm.org Fri Jul 10 03:53:51 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 10:53:51 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <7e1d1159a9804062c7c7461208c4e8f1@localhost.localdomain> LukeGeeson updated this revision to Diff 276977. LukeGeeson marked 3 inline comments as done. LukeGeeson added a comment. - Addresses dmgreens comments - reordered CPUs in the right places - added code/tests in all files that exist in the a77 patch made minor adjustments including: - adding FeatureRCPC to the missing CPUs Please let me know if there is anything else CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.276977.patch Type: text/x-patch Size: 21205 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 04:04:21 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 11:04:21 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: aaron.ballman marked an inline comment as done. aaron.ballman added inline comments. ================ Comment at: clang/lib/CodeGen/CGCall.cpp:2515 + } else { + AI->addAttr(llvm::Attribute::NonNull); + } ---------------- rjmccall wrote: > Isn't the old logic still correct? If the element size is static and the element count is positive, the argument is dereferenceable out to their product; otherwise it's nonnull if null is the zero value and we aren't semantically allowing that to be a valid pointer. I was questioning this -- I didn't think the old logic was correct because it checks that the array is in address space 0, but the nonnull-ness should apply regardless of address space (I think). The point about valid null pointers still stands, though. Am I misunderstanding the intended address space behavior? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 From cfe-commits at lists.llvm.org Fri Jul 10 04:06:12 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 11:06:12 +0000 (UTC) Subject: [PATCH] D83120: [Analyzer][StreamChecker] Using BugType::SuppressOnSink at resource leak report. In-Reply-To: References: Message-ID: <703e9bc6631242481773d85fd612ba2e@localhost.localdomain> Szelethus added a reviewer: NoQ. Szelethus accepted this revision. Szelethus added a comment. This revision is now accepted and ready to land. LGTM! Though, the test file change is interesting. You could add a test that behaves differently from the previous implementation: { FILE *f = fopen(...); } // leak here 10 / 0; // sink Unless this `SuppressOnSink` behaves differently on sink //error// nodes -- I honestly don't know :^) ================ Comment at: clang/test/Analysis/stream.c:274-284 // Check that "location uniqueing" works. // This results in reporting only one occurence of resource leak for a stream. void check_leak_noreturn_2() { FILE *F1 = tmpfile(); if (!F1) return; if (Test == 1) { ---------------- Why did this change? Is there a sink in the return branch? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83120/new/ https://reviews.llvm.org/D83120 From cfe-commits at lists.llvm.org Fri Jul 10 04:17:11 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 11:17:11 +0000 (UTC) Subject: [PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state. In-Reply-To: References: Message-ID: Szelethus accepted this revision. Szelethus added a comment. This revision is now accepted and ready to land. I'd prefer if you moved `f_leak_2` to `stream-notes.c`. Otherwise, LGTM. ================ Comment at: clang/test/Analysis/stream.c:147-150 + FILE *p1 = fopen("foo1.c", "r"); + if (!p1) + return; + FILE *p2 = fopen("foo2.c", "r"); ---------------- I'd prefer to see notes from D81407 here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82845/new/ https://reviews.llvm.org/D82845 From cfe-commits at lists.llvm.org Fri Jul 10 04:18:26 2020 From: cfe-commits at lists.llvm.org (Sebastian Neubauer via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 11:18:26 +0000 (UTC) Subject: [PATCH] D81728: [InstCombine] Add target-specific inst combining In-Reply-To: References: Message-ID: <0de5388c34093c23e219822767215e74@localhost.localdomain> Flakebi updated this revision to Diff 276983. Flakebi added a comment. Rebased (no conflicts this time). Friendly ping for review. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81728/new/ https://reviews.llvm.org/D81728 Files: clang/test/CodeGen/thinlto-distributed-newpm.ll llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/include/llvm/IR/Function.h llvm/include/llvm/Transforms/InstCombine/InstCombiner.h llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/IR/Function.cpp llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h llvm/lib/Target/AMDGPU/CMakeLists.txt llvm/lib/Target/AMDGPU/InstCombineTables.td llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp llvm/lib/Target/ARM/ARMTargetTransformInfo.h llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.h llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h llvm/lib/Target/X86/CMakeLists.txt llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp llvm/lib/Target/X86/X86TargetTransformInfo.h llvm/lib/Transforms/InstCombine/CMakeLists.txt llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/lib/Transforms/InstCombine/InstCombineInternal.h llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/lib/Transforms/InstCombine/InstCombineNegator.cpp llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/lib/Transforms/InstCombine/InstCombineTables.td llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp llvm/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/test/CodeGen/Thumb2/mve-intrinsics/predicates.ll llvm/test/CodeGen/Thumb2/mve-intrinsics/vadc-multiple.ll llvm/test/CodeGen/Thumb2/mve-vpt-from-intrinsics.ll llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-demanded-vector-elts.ll llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll llvm/test/Transforms/InstCombine/AMDGPU/ldexp.ll llvm/test/Transforms/InstCombine/ARM/mve-v2i2v.ll llvm/test/Transforms/InstCombine/ARM/neon-intrinsics.ll llvm/test/Transforms/InstCombine/NVPTX/nvvm-intrins.ll llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll llvm/test/Transforms/InstCombine/X86/addcarry.ll llvm/test/Transforms/InstCombine/X86/clmulqdq.ll llvm/test/Transforms/InstCombine/X86/x86-avx2.ll llvm/test/Transforms/InstCombine/X86/x86-avx512.ll llvm/test/Transforms/InstCombine/X86/x86-bmi-tbm.ll llvm/test/Transforms/InstCombine/X86/x86-insertps.ll llvm/test/Transforms/InstCombine/X86/x86-masked-memops.ll llvm/test/Transforms/InstCombine/X86/x86-movmsk.ll llvm/test/Transforms/InstCombine/X86/x86-pack.ll llvm/test/Transforms/InstCombine/X86/x86-pshufb.ll llvm/test/Transforms/InstCombine/X86/x86-sse.ll llvm/test/Transforms/InstCombine/X86/x86-sse2.ll llvm/test/Transforms/InstCombine/X86/x86-sse41.ll llvm/test/Transforms/InstCombine/X86/x86-sse4a.ll llvm/test/Transforms/InstCombine/X86/x86-vec_demanded_elts.ll llvm/test/Transforms/InstCombine/X86/x86-vector-shifts.ll llvm/test/Transforms/InstCombine/X86/x86-vpermil.ll llvm/test/Transforms/InstCombine/X86/x86-xop.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D81728.276983.patch Type: text/x-patch Size: 484375 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 04:27:21 2020 From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits) Date: Fri, 10 Jul 2020 04:27:21 -0700 (PDT) Subject: [clang-tools-extra] a25487f - [clang-tidy] Use Options priority in enum options where it was missing Message-ID: <5f085099.1c69fb81.bae4c.d55d@mx.google.com> Author: Nathan James Date: 2020-07-10T12:27:08+01:00 New Revision: a25487fd8cb91f99cfc1db1d4159184ac2a816a9 URL: https://github.com/llvm/llvm-project/commit/a25487fd8cb91f99cfc1db1d4159184ac2a816a9 DIFF: https://github.com/llvm/llvm-project/commit/a25487fd8cb91f99cfc1db1d4159184ac2a816a9.diff LOG: [clang-tidy] Use Options priority in enum options where it was missing Added: Modified: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 7ddf054a21a9..780a3569afdb 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -76,16 +76,25 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const { return llvm::make_error((NamePrefix + LocalName).str()); } +static ClangTidyOptions::OptionMap::const_iterator +findPriorityOption(const ClangTidyOptions::OptionMap &Options, StringRef NamePrefix, + StringRef LocalName) { + auto IterLocal = Options.find((NamePrefix + LocalName).str()); + auto IterGlobal = Options.find(LocalName.str()); + if (IterLocal == Options.end()) + return IterGlobal; + if (IterGlobal == Options.end()) + return IterLocal; + if (IterLocal->second.Priority >= IterGlobal->second.Priority) + return IterLocal; + return IterGlobal; +} + llvm::Expected ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const { - auto IterLocal = CheckOptions.find(NamePrefix + LocalName.str()); - auto IterGlobal = CheckOptions.find(LocalName.str()); - if (IterLocal != CheckOptions.end() && - (IterGlobal == CheckOptions.end() || - IterLocal->second.Priority >= IterGlobal->second.Priority)) - return IterLocal->second.Value; - if (IterGlobal != CheckOptions.end()) - return IterGlobal->second.Value; + auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName); + if (Iter != CheckOptions.end()) + return Iter->second.Value; return llvm::make_error((NamePrefix + LocalName).str()); } @@ -124,14 +133,9 @@ bool ClangTidyCheck::OptionsView::get(StringRef LocalName, template <> llvm::Expected ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const { - auto IterLocal = CheckOptions.find(NamePrefix + LocalName.str()); - auto IterGlobal = CheckOptions.find(LocalName.str()); - if (IterLocal != CheckOptions.end() && - (IterGlobal == CheckOptions.end() || - IterLocal->second.Priority >= IterGlobal->second.Priority)) - return getAsBool(IterLocal->second.Value, NamePrefix + LocalName); - if (IterGlobal != CheckOptions.end()) - return getAsBool(IterGlobal->second.Value, llvm::Twine(LocalName)); + auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName); + if (Iter != CheckOptions.end()) + return getAsBool(Iter->second.Value, Iter->first); return llvm::make_error((NamePrefix + LocalName).str()); } @@ -160,9 +164,8 @@ void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options, llvm::Expected ClangTidyCheck::OptionsView::getEnumInt( StringRef LocalName, ArrayRef> Mapping, bool CheckGlobal, bool IgnoreCase) { - auto Iter = CheckOptions.find((NamePrefix + LocalName).str()); - if (CheckGlobal && Iter == CheckOptions.end()) - Iter = CheckOptions.find(LocalName.str()); + auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, LocalName) + : CheckOptions.find((NamePrefix + LocalName).str()); if (Iter == CheckOptions.end()) return llvm::make_error((NamePrefix + LocalName).str()); From cfe-commits at lists.llvm.org Fri Jul 10 04:29:09 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 11:29:09 +0000 (UTC) Subject: [PATCH] D83115: [Analyzer] Report every bug if only uniqueing location differs. In-Reply-To: References: Message-ID: <6ac56fe73b12306f0a7deb87662be9e3@localhost.localdomain> Szelethus added reviewers: NoQ, vsavchenko, xazax.hun, martong. Szelethus added a subscriber: NoQ. Szelethus added inline comments. ================ Comment at: clang/lib/Analysis/PathDiagnostic.cpp:1136-1137 ID.Add(getLocation()); + ID.Add(getUniqueingLoc()); + ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr); ID.AddString(BugType); ---------------- This looks a bit odd -- why do we need both of these? Also, didn't we use uniqueing location in the `BugReportEquivClass` or whatever its called? Why do we need to add this here as well? I would like some technical explanation. ================ Comment at: clang/test/Analysis/malloc.c:793 int *p = malloc(12); p = malloc(12); +} // expected-warning {{Potential leak of memory pointed to by}}\ ---------------- On an unrelated note, shouldn't one of the notes be here? @NoQ, is this the same issue as the one you raised with zombie symbols? http://lists.llvm.org/pipermail/cfe-dev/2016-March/047922.html ================ Comment at: clang/test/Analysis/pr22954.c:346-356 struct JJ J0 = {{{1, 2, 0}, {3, 4, 0}, {5, 6, 0}}, 0}; J0.s2 = strdup("hello"); J0.s1[0].s2 = strdup("hello"); J0.s1[1].s2 = strdup("hi"); J0.s1[2].s2 = strdup("world"); char input[2] = {'a', 'b'}; memcpy(J0.s1[i].s1, input, 2); ---------------- What a god awful test case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83115/new/ https://reviews.llvm.org/D83115 From cfe-commits at lists.llvm.org Fri Jul 10 04:31:56 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 11:31:56 +0000 (UTC) Subject: [PATCH] D81061: [Analyzer][VLASizeChecker] Fix problem with zero index assumption. In-Reply-To: References: Message-ID: Szelethus added a comment. I don't have much to say here, this goes a bit outside my expertise. @NoQ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81061/new/ https://reviews.llvm.org/D81061 From cfe-commits at lists.llvm.org Fri Jul 10 04:33:29 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 11:33:29 +0000 (UTC) Subject: [PATCH] D78280: [Analyzer][StreamChecker] Track streams that were not found to be opened. In-Reply-To: References: Message-ID: <1da933309173c3c03bd24e2879bd9629@localhost.localdomain> Szelethus added a comment. Its a bit hard to judge this. Have you tested this on open source projects? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78280/new/ https://reviews.llvm.org/D78280 From cfe-commits at lists.llvm.org Fri Jul 10 04:41:15 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 11:41:15 +0000 (UTC) Subject: [PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute In-Reply-To: References: Message-ID: <99423db475c4ad29240a0cac0e352e48@localhost.localdomain> aaron.ballman added a comment. In D83174#2137133 , @rsmith wrote: > @aaron.ballman We will need to do something like this in general, but I'm not sure it's going to be as easy as just inheriting the attribute in the general case. What do you think? I agree that we're going to need a more general solution at some point. We do this automatically in `mergeDeclAttributes()` with: else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr)) NewAttr = cast(Attr->clone(S.Context)); for the general case (and similar for merging parameter attributes in `mergeParamDeclAttributes()`, but we have custom merging logic for the other cases. However, the custom merging logic is usually for diagnosing bad combinations of attributes, which I don't think we need to handle in this case, do we? ================ Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3544 + const auto *IA = + dyn_cast(Previous->getAttr()); + ---------------- Don't do `hasAttr` followed by `getAttr` (that duplicates work); also, you don't need to `dyn_cast<>` the call to `getAttr`. How about: ``` const auto *IA = Previous->getAttr(); if (IA && Previous->hasAttr()) { ... } ``` ================ Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3546 + + NewAttr = new (Context) MSInheritanceAttr( + IA->getRange(), Context, IA->getBestCase(), IA->getSpellingListIndex()); ---------------- Rather than do it this way, how about: `NewAttr = cast(IA->clone(Context));` ================ Comment at: clang/test/Modules/Inputs/inherit-attribute/a.h:11 +#endif \ No newline at end of file ---------------- Please add a newline to the end of the file. (Same for the other files.) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83174/new/ https://reviews.llvm.org/D83174 From cfe-commits at lists.llvm.org Fri Jul 10 04:52:12 2020 From: cfe-commits at lists.llvm.org (Xiangling Liao via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 11:52:12 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: Xiangling_L updated this revision to Diff 276991. Xiangling_L marked 6 inline comments as done. Xiangling_L added a comment. Set `Handled...` = true for non-AIX power alignment; Addressed other comments; CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 Files: clang/include/clang/AST/RecordLayout.h clang/include/clang/Basic/TargetInfo.h clang/lib/AST/ASTContext.cpp clang/lib/AST/RecordLayout.cpp clang/lib/AST/RecordLayoutBuilder.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Basic/Targets/PPC.h clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp clang/test/Layout/aix-Wpacked-no-diagnostics.cpp clang/test/Layout/aix-double-struct-member.cpp clang/test/Layout/aix-no-unique-address-with-double.cpp clang/test/Layout/aix-pack-attr-on-base.cpp clang/test/Layout/aix-power-alignment-typedef.cpp clang/test/Layout/aix-virtual-function-and-base-with-double.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D79719.276991.patch Type: text/x-patch Size: 69274 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 04:53:39 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 11:53:39 +0000 (UTC) Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit. In-Reply-To: References: Message-ID: <650b22ff8445dfbb475275873f9aba26@localhost.localdomain> sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang/include/clang/AST/DependenceFlags.h:22 + // cause instantiation to fail + // - or an error (usually in a non-template context) + // ---------------- nit: I'd weaken usually->often ================ Comment at: clang/include/clang/AST/DependenceFlags.h:25 + // Note that C++ standard doesn't define the instantiation-dependent term, + // we follow the formal definition coming from the Itanium C++ ABI. Instantiation = 2, ---------------- Maybe add ", and extend it to errors" ================ Comment at: clang/include/clang/AST/DependenceFlags.h:55 + /// Whether this type somehow involves + /// - a template parameter, evenif the resolution of the type does not + /// depend on a template parameter. ---------------- evenif > even if ================ Comment at: clang/include/clang/AST/DependenceFlags.h:62 + /// - or it somehow involves an error, e.g. denoted by + /// decltype(recovery-expr) where recovery-expr is contains-errors Dependent = 4, ---------------- nit: i'd just say "e.g. decltype(expr-with-errors)" ================ Comment at: clang/include/clang/AST/DependenceFlags.h:112 UnexpandedPack = 1, // Uses a template parameter, even if it doesn't affect the result. + // Validity depends on the template parameter, or an error. ---------------- I'd rephrase as "Depends on a template parameter or error in some way. Validity depends on how the template is instantiated or the error is resolved." ================ Comment at: clang/include/clang/AST/Expr.h:162 + /// - a template parameter (C++ [temp.dep.constexpr]) + /// - or an error + /// ---------------- maybe "or an error, whose resolution is unknown" This hints at the connection between template and error dependency, and also is more accurate for type-dependence (where sometimes we're not type dependent because the type depends on an error but we've guessed at what the resolution is) ================ Comment at: clang/include/clang/AST/Expr.h:6233 +/// unlike other dependent expressions, RecoveryExpr can be produced in +/// non-template contexts. In addition, we will preserve the type in +/// RecoveryExpr when the type is known, e.g. preserving the return type for a ---------------- I'm not sure why this "in addition" is part of the same paragraph, it seems unrelated. I'd move to a separate paragraph and drop "in addition". ================ Comment at: clang/include/clang/AST/Expr.h:6236 +/// broken non-overloaded function call, a overloaded call where all candidates +/// have the same return type. /// ---------------- maybe "In this case, the expression is not type-dependent (unless the known type is itself dependent)" ================ Comment at: clang/lib/AST/ComputeDependence.cpp:499 + // RecoveryExpr is + // - always value-dependent, instantiation-dependent and contains-errors + // - type-dependent if we don't know the type (fallback to an opequa ---------------- nit: I'd say "always value-dependent, and therefore instantiation dependent" and make "contains-errors" a separate bullet at the end like "- contains errors (ExprDependence::Error), by definition" ================ Comment at: clang/lib/AST/ComputeDependence.cpp:500 + // - always value-dependent, instantiation-dependent and contains-errors + // - type-dependent if we don't know the type (fallback to an opequa + // dependent type), or the type is known and dependent, or it has ---------------- opaque ================ Comment at: clang/lib/AST/ComputeDependence.cpp:502 + // dependent type), or the type is known and dependent, or it has + // type-dependent subexpressions auto D = toExprDependence(E->getType()->getDependence()) | ---------------- hmm, I'd missed the type-dependent subexpressions question. If there are type-dependent subexpressions, but a non-dependent type was specified for the RecoveryExpr, is the expr type-dependent? This is the part that I think we have discretion over. The definition of type-dependent does say "any type-dependent subexpression" but then lays out a list of exceptions such as casts, which are not type-dependent even if their argument is. What these have in common is that the type is known. So I think this comes down to whether it's the caller's job to work this out, or we want to conservatively call these expressions dependent. I think the former is probably better - marking the expression as type-dependent but not having its actual type be dependent doesn't serve any purpose I'm aware of. It's also inconsistent with the informal definition of type-dependence described earlier in this patch. So the comment should describe the current state, but maybe a FIXME to remove the type-dependent subexpressions clause? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83213/new/ https://reviews.llvm.org/D83213 From cfe-commits at lists.llvm.org Fri Jul 10 05:01:31 2020 From: cfe-commits at lists.llvm.org (Ulrich Weigand via cfe-commits) Date: Fri, 10 Jul 2020 05:01:31 -0700 (PDT) Subject: [clang] 4c5a93b - [ABI] Handle C++20 [[no_unique_address]] attribute Message-ID: <5f08589b.1c69fb81.73c51.db99@mx.google.com> Author: Ulrich Weigand Date: 2020-07-10T14:01:05+02:00 New Revision: 4c5a93bd58bad70e91ac525b0e020bd5119a321a URL: https://github.com/llvm/llvm-project/commit/4c5a93bd58bad70e91ac525b0e020bd5119a321a DIFF: https://github.com/llvm/llvm-project/commit/4c5a93bd58bad70e91ac525b0e020bd5119a321a.diff LOG: [ABI] Handle C++20 [[no_unique_address]] attribute Many platform ABIs have special support for passing aggregates that either just contain a single member of floatint-point type, or else a homogeneous set of members of the same floating-point type. When making this determination, any extra "empty" members of the aggregate type will typically be ignored. However, in C++ (at least in all prior versions), no data member would actually count as empty, even if it's type is an empty record -- it would still be considered to take up at least one byte of space, and therefore make those ABI special cases not apply. This is now changing in C++20, which introduced the [[no_unique_address]] attribute. Members of empty record type, if they also carry this attribute, now do *not* take up any space in the type, and therefore the ABI special cases for single-element or homogeneous aggregates should apply. The C++ Itanium ABI has been updated accordingly, and GCC 10 has added support for this new case. This patch now adds support to LLVM. This is cross-platform; it affects all platforms that use the single-element or homogeneous aggregate ABI special case and implement this using any of the following common subroutines in lib/CodeGen/TargetInfo.cpp: isEmptyField isEmptyRecord isSingleElementStruct isHomogeneousAggregate Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/systemz-abi.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index b83267dec6f0..9cd63ebe29ee 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -499,11 +499,15 @@ static bool isEmptyField(ASTContext &Context, const FieldDecl *FD, // Constant arrays of empty records count as empty, strip them off. // Constant arrays of zero length always count as empty. + bool WasArray = false; if (AllowArrays) while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) { if (AT->getSize() == 0) return true; FT = AT->getElementType(); + // The [[no_unique_address]] special case below does not apply to + // arrays of C++ empty records, so we need to remember this fact. + WasArray = true; } const RecordType *RT = FT->getAs(); @@ -514,7 +518,14 @@ static bool isEmptyField(ASTContext &Context, const FieldDecl *FD, // // FIXME: We should use a predicate for whether this behavior is true in the // current ABI. - if (isa(RT->getDecl())) + // + // The exception to the above rule are fields marked with the + // [[no_unique_address]] attribute (since C++20). Those do count as empty + // according to the Itanium ABI. The exception applies only to records, + // not arrays of records, so we must also check whether we stripped off an + // array type above. + if (isa(RT->getDecl()) && + (WasArray || !FD->hasAttr())) return false; return isEmptyRecord(Context, FT, AllowArrays); @@ -7236,6 +7247,10 @@ QualType SystemZABIInfo::GetSingleElementType(QualType Ty) const { if (getContext().getLangOpts().CPlusPlus && FD->isZeroLengthBitField(getContext())) continue; + // Like isSingleElementStruct(), ignore C++20 empty data members. + if (FD->hasAttr() && + isEmptyRecord(getContext(), FD->getType(), true)) + continue; // Unlike isSingleElementStruct(), arrays do not count. // Nested structures still do though. diff --git a/clang/test/CodeGen/systemz-abi.cpp b/clang/test/CodeGen/systemz-abi.cpp index 7604dea41dde..a91cb72ae33e 100644 --- a/clang/test/CodeGen/systemz-abi.cpp +++ b/clang/test/CodeGen/systemz-abi.cpp @@ -23,3 +23,37 @@ struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp arg) { return arg; // CHECK-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, float %{{.*}}) // SOFT-FLOAT-LABEL: define void @_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret align 4 %{{.*}}, i32 %{{.*}}) + +// A field member of empty class type in C++ makes the record nonhomogeneous, +// unless it is marked as [[no_unique_address]]. This does not apply to arrays. +struct empty { }; +struct agg_nofloat_empty { float a; empty dummy; }; +struct agg_nofloat_empty pass_agg_nofloat_empty(struct agg_nofloat_empty arg) { return arg; } +// CHECK-LABEL: define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}}) +// SOFT-FLOAT-LABEL: define void @_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* noalias sret align 4 %{{.*}}, i64 %{{.*}}) +struct agg_float_empty { float a; [[no_unique_address]] empty dummy; }; +struct agg_float_empty pass_agg_float_empty(struct agg_float_empty arg) { return arg; } +// CHECK-LABEL: define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, float %{{.*}}) +// SOFT-FLOAT-LABEL: define void @_Z20pass_agg_float_empty15agg_float_empty(%struct.agg_float_empty* noalias sret align 4 %{{.*}}, i32 %{{.*}}) +struct agg_nofloat_emptyarray { float a; [[no_unique_address]] empty dummy[3]; }; +struct agg_nofloat_emptyarray pass_agg_nofloat_emptyarray(struct agg_nofloat_emptyarray arg) { return arg; } +// CHECK-LABEL: define void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret align 4 %{{.*}}, i64 %{{.*}}) +// SOFT-FLOAT-LABEL: define void @_Z27pass_agg_nofloat_emptyarray22agg_nofloat_emptyarray(%struct.agg_nofloat_emptyarray* noalias sret align 4 %{{.*}}, i64 %{{.*}}) + +// And likewise for members of base classes. +struct noemptybase { empty dummy; }; +struct agg_nofloat_emptybase : noemptybase { float a; }; +struct agg_nofloat_emptybase pass_agg_nofloat_emptybase(struct agg_nofloat_emptybase arg) { return arg; } +// CHECK-LABEL: define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}}) +// SOFT-FLOAT-LABEL: define void @_Z26pass_agg_nofloat_emptybase21agg_nofloat_emptybase(%struct.agg_nofloat_emptybase* noalias sret align 4 %{{.*}}, i64 %{{.*}}) +struct emptybase { [[no_unique_address]] empty dummy; }; +struct agg_float_emptybase : emptybase { float a; }; +struct agg_float_emptybase pass_agg_float_emptybase(struct agg_float_emptybase arg) { return arg; } +// CHECK-LABEL: define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, float %{{.*}}) +// SOFT-FLOAT-LABEL: define void @_Z24pass_agg_float_emptybase19agg_float_emptybase(%struct.agg_float_emptybase* noalias sret align 4 %{{.*}}, i32 %{{.*}}) +struct noemptybasearray { [[no_unique_address]] empty dummy[3]; }; +struct agg_nofloat_emptybasearray : noemptybasearray { float a; }; +struct agg_nofloat_emptybasearray pass_agg_nofloat_emptybasearray(struct agg_nofloat_emptybasearray arg) { return arg; } +// CHECK-LABEL: define void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret align 4 %{{.*}}, i64 %{{.*}}) +// SOFT-FLOAT-LABEL: define void @_Z31pass_agg_nofloat_emptybasearray26agg_nofloat_emptybasearray(%struct.agg_nofloat_emptybasearray* noalias sret align 4 %{{.*}}, i64 %{{.*}}) + From cfe-commits at lists.llvm.org Fri Jul 10 05:02:30 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:02:30 +0000 (UTC) Subject: [PATCH] D83546: [clangd] Fix hover crash on InitListExpr. Message-ID: hokein created this revision. hokein added a reviewer: kadircet. Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. Fixes https://github.com/clangd/clangd/issues/455 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83546 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -801,6 +801,20 @@ HI.LocalScope = "Foo::"; HI.Type = "int"; HI.AccessSpecifier = "public"; + }}, + {R"cpp( + struct Foo { + int a[10]; + }; + constexpr Foo k2 = { + ^[[{]]1} // FIXME: why the hover range is 1 character? + }; + )cpp", + [](HoverInfo &HI) { + HI.Name = "expression"; + HI.Kind = index::SymbolKind::Unknown; + HI.Type = "int [10]"; + HI.Value = "{1}"; }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -336,6 +336,15 @@ if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() || T->isFunctionReferenceType()) return llvm::None; + // InitListExpr has two forms, syntactic and semantic. They are the same thing + // (refer to a same AST node) in most cases. + // When they are different, RAV returns the syntacic form, and we should feed + // the semantic form to EvaluateAsRValue. + if (const auto *ILE = llvm::dyn_cast(E)) { + if (!ILE->isSemanticForm()) + E = ILE->getSemanticForm(); + } + // Attempt to evaluate. If expr is dependent, evaluation crashes! if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) || // Disable printing for record-types, as they are usually confusing and -------------- next part -------------- A non-text attachment was scrubbed... Name: D83546.276993.patch Type: text/x-patch Size: 1781 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 05:10:12 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Krist=C3=B3f_Umann_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 12:10:12 +0000 (UTC) Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions In-Reply-To: References: Message-ID: <4a34cc7b0b7824e4d3706569b415798c@localhost.localdomain> Szelethus marked an inline comment as done. Szelethus added a comment. I'm yet to go over line-by-line, but the overall logic looks great. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:328-329 struct Signature { - const ArgTypes ArgTys; - const QualType RetTy; + ArgTypes ArgTys; + QualType RetTy; Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) { ---------------- Ah right, because we need to copy this. Shame that `Optional` can't just inplace construct the object with a copy constructor or something. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1746 + if (StructSockaddrPtrRestrictTy && Socklen_tPtrRestrictTy) { + auto Accept = Summary(NoEvalCall) + .ArgConstraint(ArgumentCondition(0, WithinRange, ---------------- `AcceptSummary`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83407/new/ https://reviews.llvm.org/D83407 From cfe-commits at lists.llvm.org Fri Jul 10 05:12:03 2020 From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:12:03 +0000 (UTC) Subject: [PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute In-Reply-To: References: Message-ID: uweigand closed this revision. uweigand added a comment. Committed as 4c5a93bd58bad70e91ac525b0e020bd5119a321a . CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81583/new/ https://reviews.llvm.org/D81583 From cfe-commits at lists.llvm.org Fri Jul 10 05:17:59 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:17:59 +0000 (UTC) Subject: [PATCH] D83511: [clangd] Config: If.PathExclude In-Reply-To: References: Message-ID: sammccall marked an inline comment as done. sammccall added a comment. BTW I'm **not** planning to add Suffix/SuffixExclude in the immediate future, at least for clangd 11 people will have to use `PathMatch: '.*\.h'` or so. Sound OK? ================ Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:73 + Frag.If.PathMatch.emplace_back("b.*"); + Frag.If.PathExclude.emplace_back(".*r"); + EXPECT_FALSE(compileAndApply()); ---------------- hokein wrote: > IIUC the semantic is: we only process the file `if (PathMatch("bar", "b.*") && !PathExclude("bar", ".*r"))`, PathExclude is true here, so we won't process the file. Exactly. Added a small message to the assertion to clarify the intent. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83511/new/ https://reviews.llvm.org/D83511 From cfe-commits at lists.llvm.org Fri Jul 10 05:31:14 2020 From: cfe-commits at lists.llvm.org (Sam McCall via cfe-commits) Date: Fri, 10 Jul 2020 05:31:14 -0700 (PDT) Subject: [clang-tools-extra] 86f1313 - [clangd] Config: If.PathExclude Message-ID: <5f085f92.1c69fb81.b0849.d8ad@mx.google.com> Author: Sam McCall Date: 2020-07-10T14:31:02+02:00 New Revision: 86f1313424fb578b0fd6c950d3ce7cb241f326ea URL: https://github.com/llvm/llvm-project/commit/86f1313424fb578b0fd6c950d3ce7cb241f326ea DIFF: https://github.com/llvm/llvm-project/commit/86f1313424fb578b0fd6c950d3ce7cb241f326ea.diff LOG: [clangd] Config: If.PathExclude Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83511 Added: Modified: clang-tools-extra/clangd/ConfigCompile.cpp clang-tools-extra/clangd/ConfigFragment.h clang-tools-extra/clangd/ConfigYAML.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp index 63c1681ceb0b..04c0df88bbf7 100644 --- a/clang-tools-extra/clangd/ConfigCompile.cpp +++ b/clang-tools-extra/clangd/ConfigCompile.cpp @@ -103,6 +103,22 @@ struct FragmentCompiler { }); }); } + + auto PathExclude = std::make_unique>(); + for (auto &Entry : F.PathExclude) { + if (auto RE = compileRegex(Entry)) + PathExclude->push_back(std::move(*RE)); + } + if (!PathExclude->empty()) { + Out.Conditions.push_back( + [PathExclude(std::move(PathExclude))](const Params &P) { + if (P.Path.empty()) + return false; + return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) { + return RE.match(P.Path); + }); + }); + } } void compile(Fragment::CompileFlagsBlock &&F) { diff --git a/clang-tools-extra/clangd/ConfigFragment.h b/clang-tools-extra/clangd/ConfigFragment.h index be5bd5edc188..42f9ec2edc72 100644 --- a/clang-tools-extra/clangd/ConfigFragment.h +++ b/clang-tools-extra/clangd/ConfigFragment.h @@ -108,6 +108,9 @@ struct Fragment { struct IfBlock { /// The file being processed must fully match a regular expression. std::vector> PathMatch; + /// The file being processed must *not* fully match a regular expression. + std::vector> PathExclude; + /// An unrecognized key was found while parsing the condition. /// The condition will evaluate to false. bool HasUnrecognizedCondition = false; diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp b/clang-tools-extra/clangd/ConfigYAML.cpp index 0674c6030903..ef6003b02439 100644 --- a/clang-tools-extra/clangd/ConfigYAML.cpp +++ b/clang-tools-extra/clangd/ConfigYAML.cpp @@ -50,6 +50,10 @@ class Parser { if (auto Values = scalarValues(N)) F.PathMatch = std::move(*Values); }); + Dict.handle("PathExclude", [&](Node &N) { + if (auto Values = scalarValues(N)) + F.PathExclude = std::move(*Values); + }); Dict.parse(N); } diff --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp index 17db87afecfd..825d6878727d 100644 --- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -67,6 +67,13 @@ TEST_F(ConfigCompileTests, Condition) { EXPECT_TRUE(compileAndApply()); EXPECT_THAT(Diags.Diagnostics, IsEmpty()); + // Excluded regex. + Frag = {}; + Frag.If.PathMatch.emplace_back("b.*"); + Frag.If.PathExclude.emplace_back(".*r"); + EXPECT_FALSE(compileAndApply()) << "Included but also excluded"; + EXPECT_THAT(Diags.Diagnostics, IsEmpty()); + // Invalid regex. Frag = {}; Frag.If.PathMatch.emplace_back("**]@theu"); From cfe-commits at lists.llvm.org Fri Jul 10 05:31:22 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:31:22 +0000 (UTC) Subject: [PATCH] D83511: [clangd] Config: If.PathExclude In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG86f1313424fb: [clangd] Config: If.PathExclude (authored by sammccall). Changed prior to commit: https://reviews.llvm.org/D83511?vs=276839&id=277000#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83511/new/ https://reviews.llvm.org/D83511 Files: clang-tools-extra/clangd/ConfigCompile.cpp clang-tools-extra/clangd/ConfigFragment.h clang-tools-extra/clangd/ConfigYAML.cpp clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -67,6 +67,13 @@ EXPECT_TRUE(compileAndApply()); EXPECT_THAT(Diags.Diagnostics, IsEmpty()); + // Excluded regex. + Frag = {}; + Frag.If.PathMatch.emplace_back("b.*"); + Frag.If.PathExclude.emplace_back(".*r"); + EXPECT_FALSE(compileAndApply()) << "Included but also excluded"; + EXPECT_THAT(Diags.Diagnostics, IsEmpty()); + // Invalid regex. Frag = {}; Frag.If.PathMatch.emplace_back("**]@theu"); Index: clang-tools-extra/clangd/ConfigYAML.cpp =================================================================== --- clang-tools-extra/clangd/ConfigYAML.cpp +++ clang-tools-extra/clangd/ConfigYAML.cpp @@ -50,6 +50,10 @@ if (auto Values = scalarValues(N)) F.PathMatch = std::move(*Values); }); + Dict.handle("PathExclude", [&](Node &N) { + if (auto Values = scalarValues(N)) + F.PathExclude = std::move(*Values); + }); Dict.parse(N); } Index: clang-tools-extra/clangd/ConfigFragment.h =================================================================== --- clang-tools-extra/clangd/ConfigFragment.h +++ clang-tools-extra/clangd/ConfigFragment.h @@ -108,6 +108,9 @@ struct IfBlock { /// The file being processed must fully match a regular expression. std::vector> PathMatch; + /// The file being processed must *not* fully match a regular expression. + std::vector> PathExclude; + /// An unrecognized key was found while parsing the condition. /// The condition will evaluate to false. bool HasUnrecognizedCondition = false; Index: clang-tools-extra/clangd/ConfigCompile.cpp =================================================================== --- clang-tools-extra/clangd/ConfigCompile.cpp +++ clang-tools-extra/clangd/ConfigCompile.cpp @@ -103,6 +103,22 @@ }); }); } + + auto PathExclude = std::make_unique>(); + for (auto &Entry : F.PathExclude) { + if (auto RE = compileRegex(Entry)) + PathExclude->push_back(std::move(*RE)); + } + if (!PathExclude->empty()) { + Out.Conditions.push_back( + [PathExclude(std::move(PathExclude))](const Params &P) { + if (P.Path.empty()) + return false; + return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) { + return RE.match(P.Path); + }); + }); + } } void compile(Fragment::CompileFlagsBlock &&F) { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83511.277000.patch Type: text/x-patch Size: 2723 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 05:31:59 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:31:59 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: dang marked an inline comment as done. dang added inline comments. ================ Comment at: clang/include/clang/Driver/Options.td:3455 + HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, + MarshallingInfoString<"TargetOpts->Triple", "llvm::sys::getDefaultTargetTriple()", "std::string">, + AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; ---------------- herhut wrote: > There is some explicit normalization missing here. In CC1Options.td this is > > ``` > def triple : Separate<["-"], "triple">, > HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, > MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">, > AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; > ``` > > It seems the normalizer does not apply to the defaults and we now see a failure in `clang/unittests/Frontend/CompilerInvocationTest.cpp` for powerpc targets. Of course, I must have lost it at some point. Can you link me to the failure for reference. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 05:50:47 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via cfe-commits) Date: Fri, 10 Jul 2020 05:50:47 -0700 (PDT) Subject: [clang] d4ce862 - Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support." Message-ID: <5f086427.1c69fb81.98f5a.f062@mx.google.com> Author: Kevin P. Neal Date: 2020-07-10T08:49:45-04:00 New Revision: d4ce862f2aa8b7e4b11462bd72014b08ab9468b3 URL: https://github.com/llvm/llvm-project/commit/d4ce862f2aa8b7e4b11462bd72014b08ab9468b3 DIFF: https://github.com/llvm/llvm-project/commit/d4ce862f2aa8b7e4b11462bd72014b08ab9468b3.diff LOG: Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support." We currently have strict floating point/constrained floating point enabled for all targets. Constrained SDAG nodes get converted to the regular ones before reaching the target layer. In theory this should be fine. However, the changes are exposed to users through multiple clang options already in use in the field, and the changes are _completely_ _untested_ on almost all of our targets. Bugs have already been found, like "https://bugs.llvm.org/show_bug.cgi?id=45274". This patch disables constrained floating point options in clang everywhere except X86 and SystemZ. A warning will be printed when this happens. Use the new -fexperimental-strict-floating-point flag to force allowing strict floating point on hosts that aren't already marked as supporting it (X86 and SystemZ). Differential Revision: https://reviews.llvm.org/D80952 Added: clang/test/CodeGen/fp-strictfp-exp.cpp clang/test/CodeGen/fp-strictfp.cpp Modified: clang/docs/ClangCommandLineReference.rst clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/LangOptions.def clang/include/clang/Basic/TargetInfo.h clang/include/clang/Driver/Options.td clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/SystemZ.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/aarch64-neon-misc-constrained.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c clang/test/CodeGen/arm-neon-directed-rounding-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/builtins-ppc-fpconstrained.c clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c clang/test/CodeGen/fpconstrained.c clang/test/CodeGen/fpconstrained.cpp Removed: ################################################################################ diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 0b56b7ac4206..1613c8e45318 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -818,6 +818,10 @@ Discard value names in LLVM IR Enables an experimental new pass manager in LLVM. +.. option:: -fexperimental-strict-floating-point + +Enables the use of non-default rounding modes and non-default exception handling on targets that are not currently ready. + .. option:: -ffine-grained-bitfield-accesses, -fno-fine-grained-bitfield-accesses Use separate accesses for consecutive bitfield runs with legal widths and alignments. diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index d465e00d4c70..67c0b4203420 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -58,6 +58,8 @@ CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM IR passes to get ///< frontend. CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with optnone at O0 +CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, experimental + ///< strict floating point. CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental ///< pass manager. CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index ceb24bce5978..b202d2abffa0 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -37,6 +37,12 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo; def warn_fe_override_module : Warning< "overriding the module target triple with %0">, InGroup>; +def warn_fe_backend_unsupported_fp_rounding : Warning< + "overriding currently unsupported rounding mode on this target">, + InGroup; +def warn_fe_backend_unsupported_fp_exceptions : Warning< + "overriding currently unsupported use of floating point exceptions " + "on this target">, InGroup; def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo, InGroup; diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 76c38686a050..6a50ceef4191 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -107,6 +107,7 @@ def DoublePromotion : DiagGroup<"double-promotion">; def EnumTooLarge : DiagGroup<"enum-too-large">; def UnsupportedNan : DiagGroup<"unsupported-nan">; def UnsupportedAbs : DiagGroup<"unsupported-abs">; +def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">; def UnsupportedCB : DiagGroup<"unsupported-cb">; def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">; def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">; diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index a20639c828c3..70f68d664bb7 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -272,6 +272,7 @@ LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating poi LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math") /// FP_CONTRACT mode (on/off/fast). BENIGN_ENUM_LANGOPT(DefaultFPContractMode, FPModeKind, 2, FPM_Off, "FP contraction type") +COMPATIBLE_LANGOPT(ExpStrictFP, 1, false, "Enable experimental strict floating point") BENIGN_ENUM_LANGOPT(FPRoundingMode, RoundingMode, 3, RoundingMode::NearestTiesToEven, "FP Rounding Mode type") BENIGN_ENUM_LANGOPT(FPExceptionMode, FPExceptionModeKind, 2, FPE_Ignore, "FP Exception Behavior Mode type") LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment") diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 140f55ff66b1..2ee3b1659630 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -192,6 +192,7 @@ class TargetInfo : public virtual TransferrableTargetInfo, bool HasFloat128; bool HasFloat16; bool HasBFloat16; + bool HasStrictFP; unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; unsigned short SimdDefaultAlign; @@ -577,6 +578,9 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Determine whether the _BFloat16 type is supported on this target. virtual bool hasBFloat16Type() const { return HasBFloat16; } + /// Determine whether constrained floating point is supported on this target. + virtual bool hasStrictFP() const { return HasStrictFP; } + /// Return the alignment that is suitable for storing any /// object with a fundamental alignment requirement. unsigned getSuitableAlign() const { return SuitableAlign; } diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c6acd745bfd0..e24914e9e4b6 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1243,6 +1243,9 @@ def fexperimental_isel : Flag<["-"], "fexperimental-isel">, Group def fexperimental_new_pass_manager : Flag<["-"], "fexperimental-new-pass-manager">, Group, Flags<[CC1Option]>, HelpText<"Enables an experimental new pass manager in LLVM.">; +def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">, + Group, Flags<[CC1Option]>, + HelpText<"Enables experimental strict floating point in LLVM.">; def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group; def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group; def finstrument_functions : Flag<["-"], "finstrument-functions">, Group, Flags<[CC1Option]>, diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index 7f360b715da9..eccdc21d724a 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -37,6 +37,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) { HasFloat128 = false; HasFloat16 = false; HasBFloat16 = false; + HasStrictFP = false; PointerWidth = PointerAlign = 32; BoolWidth = BoolAlign = 8; IntWidth = IntAlign = 32; diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 134b0313b86a..d7869e3754a8 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -48,6 +48,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { MinGlobalAlign = 16; resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"); MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; + HasStrictFP = true; } void getTargetDefines(const LangOptions &Opts, diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 4d76193e7e95..72a01d2514c2 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -141,6 +141,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo { : TargetInfo(Triple) { LongDoubleFormat = &llvm::APFloat::x87DoubleExtended(); AddrSpaceMap = &X86AddrSpaceMap; + HasStrictFP = true; } const char *getLongDoubleMangling() const override { diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 9dc9c42297ed..4613ed8d7f61 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -933,6 +933,19 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO)); } + if (!getTarget().hasStrictFP() && !getLangOpts().ExpStrictFP) { + if (getLangOpts().getFPRoundingMode() != + llvm::RoundingMode::NearestTiesToEven) { + getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_rounding); + getLangOpts().setFPRoundingMode(llvm::RoundingMode::NearestTiesToEven); + } + if (getLangOpts().getFPExceptionMode() != LangOptions::FPE_Ignore) { + getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_exceptions); + getLangOpts().setFPExceptionMode(LangOptions::FPE_Ignore); + } + // FIXME: can we disable FEnvAccess? + } + // Inform the target of the language options. // // FIXME: We shouldn't need to do this, the target should be immutable once diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 64dcfa831824..e24de29a309e 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3281,6 +3281,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val; } + if (Args.hasArg(OPT_fexperimental_strict_floating_point)) + Opts.ExpStrictFP = true; + auto FPRM = llvm::RoundingMode::NearestTiesToEven; if (Args.hasArg(OPT_frounding_math)) { FPRM = llvm::RoundingMode::Dynamic; diff --git a/clang/test/CodeGen/aarch64-neon-misc-constrained.c b/clang/test/CodeGen/aarch64-neon-misc-constrained.c index 0385358291c9..a0a503df3375 100644 --- a/clang/test/CodeGen/aarch64-neon-misc-constrained.c +++ b/clang/test/CodeGen/aarch64-neon-misc-constrained.c @@ -3,6 +3,7 @@ // RUN: | opt -S -mem2reg | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -disable-O0-optnone -fallow-half-arguments-and-returns -emit-llvm -o - %s \ // RUN: | opt -S -mem2reg | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \ @@ -10,6 +11,7 @@ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -disable-O0-optnone -fallow-half-arguments-and-returns -S -o - %s \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s diff --git a/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c b/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c index cbe5627337fd..311950362f33 100644 --- a/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c +++ b/clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c @@ -3,6 +3,7 @@ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-cpu cyclone \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-cpu cyclone \ @@ -10,6 +11,7 @@ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-cpu cyclone \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | llc -o=- - \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s diff --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c index 6058e6f92832..478c4a27c3e7 100644 --- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c +++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c @@ -4,6 +4,7 @@ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-feature +fullfp16 -target-feature +v8.2a\ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S -disable-O0-optnone -emit-llvm -o - %s \ // RUN: | opt -S -mem2reg \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s @@ -13,6 +14,7 @@ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -target-feature +fullfp16 -target-feature +v8.2a\ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -fallow-half-arguments-and-returns -flax-vector-conversions=none -S -disable-O0-optnone -emit-llvm -o - %s \ // RUN: | opt -S -mem2reg | llc -o=- - \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s diff --git a/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c b/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c index 5246993173f8..7dedab375c81 100644 --- a/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c +++ b/clang/test/CodeGen/arm-neon-directed-rounding-constrained.c @@ -7,10 +7,12 @@ // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \ // RUN: opt -S -mem2reg | FileCheck -check-prefixes=COMMON,COMMONIR,CONSTRAINED %s // RUN: %clang_cc1 -triple arm64-linux-gnueabihf -target-feature +neon \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \ // RUN: opt -S -mem2reg | FileCheck -check-prefixes=COMMON,COMMONIR,CONSTRAINED %s @@ -23,10 +25,12 @@ // RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \ // RUN: opt -S -mem2reg | llc -o=- - | FileCheck -check-prefixes=COMMON,CHECK-ASM32 %s // RUN: %clang_cc1 -triple arm64-linux-gnueabihf -target-feature +neon \ // RUN: -ffp-exception-behavior=strict \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \ // RUN: opt -S -mem2reg | llc -o=- - | FileCheck -check-prefixes=COMMON,CHECK-ASM64 %s diff --git a/clang/test/CodeGen/arm64-vrnd-constrained.c b/clang/test/CodeGen/arm64-vrnd-constrained.c index bbded8f2c7f6..ee2edbcbd096 100644 --- a/clang/test/CodeGen/arm64-vrnd-constrained.c +++ b/clang/test/CodeGen/arm64-vrnd-constrained.c @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -flax-vector-conversions=none -emit-llvm -o - %s \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s -// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -flax-vector-conversions=none -ffp-exception-behavior=strict -emit-llvm -o - %s \ +// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -flax-vector-conversions=none -fexperimental-strict-floating-point -ffp-exception-behavior=strict -emit-llvm -o - %s \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s // RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -flax-vector-conversions=none -emit-llvm -o - %s | llc -o=- - \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s -// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -flax-vector-conversions=none -ffp-exception-behavior=strict -emit-llvm -o - %s | llc -o=- - \ +// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -ffreestanding -flax-vector-conversions=none -fexperimental-strict-floating-point -ffp-exception-behavior=strict -emit-llvm -o - %s | llc -o=- - \ // RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s // REQUIRES: aarch64-registered-target diff --git a/clang/test/CodeGen/builtins-ppc-fpconstrained.c b/clang/test/CodeGen/builtins-ppc-fpconstrained.c index 38cdfb6aab38..c8b08c3fb5d4 100644 --- a/clang/test/CodeGen/builtins-ppc-fpconstrained.c +++ b/clang/test/CodeGen/builtins-ppc-fpconstrained.c @@ -2,12 +2,14 @@ // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \ // RUN: -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-UNCONSTRAINED %s // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -ffp-exception-behavior=strict -emit-llvm %s -o - | FileCheck \ // RUN: --check-prefix=CHECK-CONSTRAINED -vv %s // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \ // RUN: -fallow-half-arguments-and-returns -S -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK %s // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \ +// RUN: -fexperimental-strict-floating-point \ // RUN: -fallow-half-arguments-and-returns -S -ffp-exception-behavior=strict \ // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \ // RUN: --check-prefix=FIXME-CHECK %s diff --git a/clang/test/CodeGen/fp-strictfp-exp.cpp b/clang/test/CodeGen/fp-strictfp-exp.cpp new file mode 100644 index 000000000000..7b9718a50ff2 --- /dev/null +++ b/clang/test/CodeGen/fp-strictfp-exp.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple mips64-linux-gnu -fexperimental-strict-floating-point -frounding-math -ffp-exception-behavior=strict -O2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -fexperimental-strict-floating-point -ffp-exception-behavior=strict -O2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -fexperimental-strict-floating-point -frounding-math -O2 -emit-llvm -o - %s | FileCheck %s +// +// Verify that constrained intrinsics are used due to the experimental flag. +// As more targets gain support for constrained intrinsics the triple +// in this test will need to change. + +float fp_precise_1(float a, float b, float c) { +// CHECK-LABEL: define float @_Z12fp_precise_1fff +// CHECK: %[[M:.+]] = tail call float @llvm.experimental.constrained.fmul.f32(float {{.*}}, float {{.*}}, metadata {{.*}}) +// CHECK: tail call float @llvm.experimental.constrained.fadd.f32(float %[[M]], float %c, metadata {{.*}}) + return a * b + c; +} diff --git a/clang/test/CodeGen/fp-strictfp.cpp b/clang/test/CodeGen/fp-strictfp.cpp new file mode 100644 index 000000000000..bfa13b4dd354 --- /dev/null +++ b/clang/test/CodeGen/fp-strictfp.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s +// +// Verify that constrained intrinsics are not used. +// As more targets gain support for constrained intrinsics the triple +// in this test will need to change. + +// rounding-warning@* {{overriding currently unsupported rounding mode on this target}} +// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}} +float fp_precise_1(float a, float b, float c) { +// CHECK: define float @_Z12fp_precise_1fff +// CHECK: %[[M:.+]] = fmul float{{.*}} +// CHECK: fadd float %[[M]], %c + return a * b + c; +} diff --git a/clang/test/CodeGen/fpconstrained-cmp-double.c b/clang/test/CodeGen/fpconstrained-cmp-double.c index 2819970a3fcf..6f19db2099db 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-double.c +++ b/clang/test/CodeGen/fpconstrained-cmp-double.c @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=FCMP -// RUN: %clang_cc1 -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT -// RUN: %clang_cc1 -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP +// RUN: %clang_cc1 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT +// RUN: %clang_cc1 -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE -// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT -// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP +// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT +// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP _Bool QuietEqual(double f1, double f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2) diff --git a/clang/test/CodeGen/fpconstrained-cmp-float.c b/clang/test/CodeGen/fpconstrained-cmp-float.c index 0265fc54c02b..bca0cdb7eda4 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-float.c +++ b/clang/test/CodeGen/fpconstrained-cmp-float.c @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=FCMP -// RUN: %clang_cc1 -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT -// RUN: %clang_cc1 -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP +// RUN: %clang_cc1 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT +// RUN: %clang_cc1 -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE -// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT -// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP +// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT +// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP _Bool QuietEqual(float f1, float f2) { // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2) diff --git a/clang/test/CodeGen/fpconstrained.c b/clang/test/CodeGen/fpconstrained.c index 902d6b5baf49..0307ebbd357f 100644 --- a/clang/test/CodeGen/fpconstrained.c +++ b/clang/test/CodeGen/fpconstrained.c @@ -1,10 +1,11 @@ -// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT +// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT // RUN: %clang_cc1 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST -// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT -// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP +// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT +// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP + float f0, f1, f2; void foo() { diff --git a/clang/test/CodeGen/fpconstrained.cpp b/clang/test/CodeGen/fpconstrained.cpp index e914abcc6926..305c3684486d 100644 --- a/clang/test/CodeGen/fpconstrained.cpp +++ b/clang/test/CodeGen/fpconstrained.cpp @@ -1,10 +1,11 @@ -// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT +// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST -// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT -// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP +// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT +// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP + float f0, f1, f2; template From cfe-commits at lists.llvm.org Fri Jul 10 05:50:59 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:50:59 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <03bc94fdf05a9268ffdbc54e24866a12@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGd4ce862f2aa8: Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets… (authored by kpn). Herald added a reviewer: dang. Changed prior to commit: https://reviews.llvm.org/D80952?vs=276166&id=277004#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 Files: clang/docs/ClangCommandLineReference.rst clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Basic/DiagnosticFrontendKinds.td clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/LangOptions.def clang/include/clang/Basic/TargetInfo.h clang/include/clang/Driver/Options.td clang/lib/Basic/TargetInfo.cpp clang/lib/Basic/Targets/SystemZ.h clang/lib/Basic/Targets/X86.h clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/aarch64-neon-misc-constrained.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c clang/test/CodeGen/arm-neon-directed-rounding-constrained.c clang/test/CodeGen/arm64-vrnd-constrained.c clang/test/CodeGen/builtins-ppc-fpconstrained.c clang/test/CodeGen/fp-strictfp-exp.cpp clang/test/CodeGen/fp-strictfp.cpp clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c clang/test/CodeGen/fpconstrained.c clang/test/CodeGen/fpconstrained.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D80952.277004.patch Type: text/x-patch Size: 26320 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 05:51:03 2020 From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:51:03 +0000 (UTC) Subject: [PATCH] D83548: [clangd] Fix tests build for GCC5 Message-ID: ArcsinX created this revision. Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. Build log: llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatchTest_Define_Test::TestBody()’: llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"\012 #define BAR\012 [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLitera ’ }; ^ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 2\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"\012 #define BAR \\\012\012 [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 2\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"\012 #define \\\012 BAR\012 [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 3\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatchTest_LocateMacroAtWorks_Test::TestBody()’: llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ }; ^ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define $def^FOO\012 #undef $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define $def^FOO\012 #undef FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define \\\012 $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #\\\012 define /* FOO */\\\012 /* FOO */ $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: error: could not convert ‘(const char*)"\012 #define BAR\012 #define $def^FOO\012 $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatchTest_RefsToMacros_Test::TestBody()’: llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ }; ^ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"\012 #define ^FOO\012 ^[[FOO]]"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"\012 #define BAR\012 #define ^FOO\012 ^[[FOO]]"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: error: could not convert ‘(const char*)"\012 #define ^FOO\012 #undef ^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member function ‘virtual void clang::clangd::{anonymous}::PreamblePatch_ModifiedBounds_Test::TestBody()’: llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)""’ from ‘const char*’ to ‘llvm::StringLiteral’ }; ^ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"\012 #define FOO\012 FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"#define BAR"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"\012 #define FOO\012 #undef FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:512:3: error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’ Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83548 Files: clang-tools-extra/clangd/unittests/PreambleTests.cpp Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/PreambleTests.cpp +++ clang-tools-extra/clangd/unittests/PreambleTests.cpp @@ -230,8 +230,8 @@ TEST(PreamblePatchTest, Define) { // BAR should be defined while parsing the AST. struct { - llvm::StringLiteral Contents; - llvm::StringLiteral ExpectedPatch; + const char *const Contents; + const char *const ExpectedPatch; } Cases[] = { { R"cpp( @@ -270,7 +270,7 @@ SCOPED_TRACE(Case.Contents); Annotations Modified(Case.Contents); EXPECT_THAT(getPreamblePatch("", Modified.code()), - MatchesRegex(Case.ExpectedPatch.str())); + MatchesRegex(Case.ExpectedPatch)); auto AST = createPatchedAST("", Modified.code()); ASSERT_TRUE(AST); @@ -304,8 +304,8 @@ TEST(PreamblePatchTest, LocateMacroAtWorks) { struct { - llvm::StringLiteral Baseline; - llvm::StringLiteral Modified; + const char *const Baseline; + const char *const Modified; } Cases[] = { // Addition of new directive { @@ -417,8 +417,8 @@ TEST(PreamblePatchTest, RefsToMacros) { struct { - llvm::StringLiteral Baseline; - llvm::StringLiteral Modified; + const char *const Baseline; + const char *const Modified; } Cases[] = { // Newly added { @@ -491,8 +491,8 @@ TEST(PreamblePatch, ModifiedBounds) { struct { - llvm::StringLiteral Baseline; - llvm::StringLiteral Modified; + const char *const Baseline; + const char *const Modified; } Cases[] = { // Size increased { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83548.277005.patch Type: text/x-patch Size: 1690 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 05:56:40 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:56:40 +0000 (UTC) Subject: [PATCH] D83511: [clangd] Config: If.PathExclude In-Reply-To: References: Message-ID: hokein added a comment. In D83511#2143803 , @sammccall wrote: > BTW I'm **not** planning to add Suffix/SuffixExclude in the immediate future, at least for clangd 11 people will have to use `PathMatch: '.*\.h'` or so. Sound OK? yeah, that sounds good to me. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83511/new/ https://reviews.llvm.org/D83511 From cfe-commits at lists.llvm.org Fri Jul 10 05:59:23 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via cfe-commits) Date: Fri, 10 Jul 2020 05:59:23 -0700 (PDT) Subject: [clang] 0555db0 - Normalize default value for -triple correctly Message-ID: <5f08662b.1c69fb81.da110.d9a4@mx.google.com> Author: Daniel Grumberg Date: 2020-07-10T13:58:48+01:00 New Revision: 0555db0a5df4d669ce4c2125668ec7a8a42fcd9d URL: https://github.com/llvm/llvm-project/commit/0555db0a5df4d669ce4c2125668ec7a8a42fcd9d DIFF: https://github.com/llvm/llvm-project/commit/0555db0a5df4d669ce4c2125668ec7a8a42fcd9d.diff LOG: Normalize default value for -triple correctly Added: Modified: clang/include/clang/Driver/Options.td Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e24914e9e4b6..042d66a1b61a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3456,7 +3456,7 @@ def target_feature : Separate<["-"], "target-feature">, HelpText<"Target specific attributes">; def triple : Separate<["-"], "triple">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, - MarshallingInfoString<"TargetOpts->Triple", "llvm::sys::getDefaultTargetTriple()", "std::string">, + MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">, AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; def target_abi : Separate<["-"], "target-abi">, HelpText<"Target a particular ABI type">; From cfe-commits at lists.llvm.org Fri Jul 10 05:59:59 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 12:59:59 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: dang marked 2 inline comments as done. dang added inline comments. ================ Comment at: clang/include/clang/Driver/Options.td:3455 + HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, + MarshallingInfoString<"TargetOpts->Triple", "llvm::sys::getDefaultTargetTriple()", "std::string">, + AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; ---------------- dang wrote: > herhut wrote: > > There is some explicit normalization missing here. In CC1Options.td this is > > > > ``` > > def triple : Separate<["-"], "triple">, > > HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, > > MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">, > > AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; > > ``` > > > > It seems the normalizer does not apply to the defaults and we now see a failure in `clang/unittests/Frontend/CompilerInvocationTest.cpp` for powerpc targets. > Of course, I must have lost it at some point. Can you link me to the failure for reference. Done in 0555db0a5df4 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 06:00:34 2020 From: cfe-commits at lists.llvm.org (Cullen Rhodes via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:00:34 +0000 (UTC) Subject: [PATCH] D83550: [PATCH 1/4][Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute Message-ID: c-rhodes created this revision. c-rhodes added reviewers: sdesmalen, rsandifo-arm, efriedma, ctetreau, cameron.mcinally. Herald added subscribers: danielkiss, kristof.beyls, tschuett. Herald added a reviewer: rengolin. Herald added a reviewer: aaron.ballman. Herald added a project: clang. This patch implements parsing support for the 'arm_sve_vector_bits' type attribute, defined by the Arm C Language Extensions (ACLE, version 00bet5, section 3.7.3) for SVE [1]. The purpose of this attribute is to define fixed-length (VLST) versions of existing sizeless types (VLAT). For example: #if __ARM_FEATURE_SVE_BITS==512 typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512))); #endif Creates a type 'fixed_svint32_t' that is a fixed-length version of 'svint32_t' that is normal-sized (rather than sizeless) and contains exactly 512 bits. Unlike 'svint32_t', this type can be used in places such as structs and arrays where sizeless types can't. Implemented in this patch is the following: - Defined and tested attribute taking single argument. - Checks the argument is an integer constant expression. - Attribute can only be attached to a single SVE vector or predicate type, excluding tuple types such as svint32x4_t. - Validates N == __ARM_FEATURE_SVE_BITS, where N is the number of bits passed to the attribute. - Basic validation of the __ARM_FEATURE_SVE_BITS macro. The __ARM_FEATURE_SVE_BITS macro will be enabled by the -msve-vector-bits= flag in the final patch of the series. [1] https://developer.arm.com/documentation/100987/latest Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83550 Files: clang/include/clang/AST/Type.h clang/include/clang/Basic/Attr.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/AST/Type.cpp clang/lib/AST/TypePrinter.cpp clang/lib/Sema/SemaType.cpp clang/test/Sema/arm-feature-sve-bits-macro.c clang/test/Sema/attr-arm-sve-vector-bits.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83550.277009.patch Type: text/x-patch Size: 12983 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 06:04:45 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:04:45 +0000 (UTC) Subject: [PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression. In-Reply-To: References: Message-ID: hokein marked an inline comment as done. hokein added inline comments. ================ Comment at: clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp:129 + S &s1 = f({}, 0, 0.0); // expected-error {{no matching function}} \ + expected-error {{non-const lvalue reference to type 'S' cannot bind to a value of unrelated type 'int'}} } ---------------- the secondary diagnostic is technically correct, but I don't quite like it, it is confusing, ok to leave it as-is? or fix that before landing this patch? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82657/new/ https://reviews.llvm.org/D82657 From cfe-commits at lists.llvm.org Fri Jul 10 06:05:09 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:05:09 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: <691fe8e736483434c217a857cf367423@localhost.localdomain> dang added inline comments. Herald added a subscriber: dexonsmith. ================ Comment at: clang/include/clang/Driver/Options.td:1246 HelpText<"Enables an experimental new pass manager in LLVM.">; +def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">, + Group, Flags<[CC1Option]>, ---------------- A bit late to the party, but can you mark this as `MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if (Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = true;` in CompilerInvocation.cpp gets generated automatically, we also get serializing the option for free this way. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Fri Jul 10 06:05:53 2020 From: cfe-commits at lists.llvm.org (Cullen Rhodes via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:05:53 +0000 (UTC) Subject: [PATCH] D83551: [PATCH 2/4][Sema][AArch64] Add semantics for arm_sve_vector_bits attribute Message-ID: c-rhodes created this revision. c-rhodes added reviewers: sdesmalen, rsandifo-arm, efriedma, cameron.mcinally, ctetreau. Herald added subscribers: danielkiss, kristof.beyls, tschuett. Herald added a reviewer: rengolin. Herald added a reviewer: aaron.ballman. Herald added a project: clang. This patch implements semantics for the 'arm_sve_vector_bits' type attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1]. The purpose of this attribute is to define fixed-length (VLST) versions of existing sizeless types (VLAT). Implemented in this patch is the the behaviour described in section 3.7.3.2 and minimal parts of sections 3.7.3.3 and 3.7.3.4, this includes: - Defining VLST globals, structs, unions, and local variables - Implicit casting between VLAT <=> VLST. - Diagnosis of ill-formed conditional expressions of the form: C ? E1 : E2 where E1 is a VLAT type and E2 is a VLST, or vice-versa. This avoids any ambiguity about the nature of the result type (i.e is it sized or sizeless). - For vectors: - sizeof(VLST) == N/8 - alignof(VLST) == 16 - For predicates: - sizeof(VLST) == N/64 - alignof(VLST) == 2 VLSTs have the same representation as VLATs in the AST but are wrapped with a TypeAttribute. Scalable types are currently emitted in the IR for uses such as globals and structs which don't support these types, this is addressed in the next patch with codegen, where VLSTs are lowered to sized arrays for globals, structs / unions and arrays. Not implemented in this patch is the behaviour guarded by the feature macros: - __ARM_FEATURE_SVE_VECTOR_OPERATORS - __ARM_FEATURE_SVE_PREDICATE_OPERATORS As such, the GNU __attribute__((vector_size)) extension is not available and operators such as binary '+' are not supported for VLSTs. Support for this is intended to be addressed by later patches. [1] https://developer.arm.com/documentation/100987/latest Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83551 Files: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/Type.h clang/include/clang/Basic/Attr.td clang/include/clang/Sema/Sema.h clang/lib/AST/ASTContext.cpp clang/lib/AST/Type.cpp clang/lib/AST/TypePrinter.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaType.cpp clang/test/Sema/attr-arm-sve-vector-bits.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83551.277012.patch Type: text/x-patch Size: 19274 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 06:06:33 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:06:33 +0000 (UTC) Subject: [PATCH] D83546: [clangd] Fix hover crash on InitListExpr. In-Reply-To: References: Message-ID: <32890aaa47525e11f4c0c9cad3fdc08d@localhost.localdomain> kadircet added inline comments. ================ Comment at: clang-tools-extra/clangd/Hover.cpp:345 + if (!ILE->isSemanticForm()) + E = ILE->getSemanticForm(); + } ---------------- shouldn't we put this before `QualType T = E->getType();` ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83546/new/ https://reviews.llvm.org/D83546 From cfe-commits at lists.llvm.org Fri Jul 10 06:09:20 2020 From: cfe-commits at lists.llvm.org (Cullen Rhodes via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:09:20 +0000 (UTC) Subject: [PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute Message-ID: c-rhodes created this revision. c-rhodes added reviewers: sdesmalen, rsandifo-arm, efriedma, cameron.mcinally, ctetreau. Herald added subscribers: danielkiss, kristof.beyls, tschuett. Herald added a reviewer: rengolin. Herald added a project: clang. This patch implements codegen for the 'arm_sve_vector_bits' type attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1]. The purpose of this attribute is to define fixed-length (VLST) versions of existing sizeless types (VLAT). Implemented in this patch is the lowering of VLSTs to valid types. VLSTs (unlike VLATs) can be used in globals, members of structs and unions, and arrays. To support this in this patch we lower VLSTs to arrays. For example, in the following C code: #if __ARM_FEATURE_SVE_BITS==512 typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512))); struct struct_int32 { fixed_int32_t x; } struct_int32; #endif the struct is lowered to: %struct.struct_int32 = type { [16 x i32] } where the member 'x' is a fixed-length variant of 'svint32_t' that contains exactly 512 bits. When loading from a VLST to a VLAT, or when storing a VLAT to a VLST, the address is bitcasted, e.g. bitcast [N x i8]* %addr.ptr to * [1] https://developer.arm.com/documentation/100987/latest Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83553 Files: clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/CodeGenTypes.h clang/test/Sema/attr-arm-sve-vector-bits-bitcast.c clang/test/Sema/attr-arm-sve-vector-bits-call.c clang/test/Sema/attr-arm-sve-vector-bits-cast.c clang/test/Sema/attr-arm-sve-vector-bits-codegen.c clang/test/Sema/attr-arm-sve-vector-bits-globals.c clang/test/Sema/attr-arm-sve-vector-bits-types.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83553.277013.patch Type: text/x-patch Size: 70163 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 06:11:36 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:11:36 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: kpn marked an inline comment as done. kpn added inline comments. ================ Comment at: clang/include/clang/Driver/Options.td:1246 HelpText<"Enables an experimental new pass manager in LLVM.">; +def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">, + Group, Flags<[CC1Option]>, ---------------- dang wrote: > A bit late to the party, but can you mark this as `MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if (Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = true;` in CompilerInvocation.cpp gets generated automatically, we also get serializing the option for free this way. Assuming this patch makes it to the afternoon, how about I open a new review for this? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Fri Jul 10 06:17:11 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:17:11 +0000 (UTC) Subject: [PATCH] D83546: [clangd] Fix hover crash on InitListExpr. In-Reply-To: References: Message-ID: <238b888402f3f6081176528f4873941c@localhost.localdomain> hokein updated this revision to Diff 277016. hokein marked 2 inline comments as done. hokein added a comment. address comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83546/new/ https://reviews.llvm.org/D83546 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -801,6 +801,21 @@ HI.LocalScope = "Foo::"; HI.Type = "int"; HI.AccessSpecifier = "public"; + }}, + {// No crash on InitListExpr. + R"cpp( + struct Foo { + int a[10]; + }; + constexpr Foo k2 = { + ^[[{]]1} // FIXME: why the hover range is 1 character? + }; + )cpp", + [](HoverInfo &HI) { + HI.Name = "expression"; + HI.Kind = index::SymbolKind::Unknown; + HI.Type = "int [10]"; + HI.Value = "{1}"; }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -329,13 +329,23 @@ llvm::Optional printExprValue(const Expr *E, const ASTContext &Ctx) { - Expr::EvalResult Constant; + // InitListExpr has two forms, syntactic and semantic. They are the same thing + // (refer to a same AST node) in most cases. + // When they are different, RAV returns the syntacic form, and we should feed + // the semantic form to EvaluateAsRValue. + if (const auto *ILE = llvm::dyn_cast(E)) { + if (!ILE->isSemanticForm()) + E = ILE->getSemanticForm(); + } + // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up // to the enclosing call. QualType T = E->getType(); if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() || T->isFunctionReferenceType()) return llvm::None; + + Expr::EvalResult Constant; // Attempt to evaluate. If expr is dependent, evaluation crashes! if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) || // Disable printing for record-types, as they are usually confusing and -------------- next part -------------- A non-text attachment was scrubbed... Name: D83546.277016.patch Type: text/x-patch Size: 2149 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 06:17:52 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:17:52 +0000 (UTC) Subject: [PATCH] D83546: [clangd] Fix hover crash on InitListExpr. In-Reply-To: References: Message-ID: <2db74548f75f2dbd25b7172e8c0f1483@localhost.localdomain> hokein added inline comments. ================ Comment at: clang-tools-extra/clangd/Hover.cpp:345 + if (!ILE->isSemanticForm()) + E = ILE->getSemanticForm(); + } ---------------- kadircet wrote: > shouldn't we put this before `QualType T = E->getType();` ? ah, I think you're right. put it there. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83546/new/ https://reviews.llvm.org/D83546 From cfe-commits at lists.llvm.org Fri Jul 10 06:24:54 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:24:54 +0000 (UTC) Subject: [PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support. In-Reply-To: References: Message-ID: dang added inline comments. ================ Comment at: clang/include/clang/Driver/Options.td:1246 HelpText<"Enables an experimental new pass manager in LLVM.">; +def fexperimental_strict_floating_point : Flag<["-"], "fexperimental-strict-floating-point">, + Group, Flags<[CC1Option]>, ---------------- kpn wrote: > dang wrote: > > A bit late to the party, but can you mark this as `MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if (Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = true;` in CompilerInvocation.cpp gets generated automatically, we also get serializing the option for free this way. > Assuming this patch makes it to the afternoon, how about I open a new review for this? Sure no problem Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80952/new/ https://reviews.llvm.org/D80952 From cfe-commits at lists.llvm.org Fri Jul 10 06:34:35 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:34:35 +0000 (UTC) Subject: [PATCH] D83548: [clangd] Fix tests build for GCC5 In-Reply-To: References: Message-ID: kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. thanks, lgtm! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83548/new/ https://reviews.llvm.org/D83548 From cfe-commits at lists.llvm.org Fri Jul 10 06:36:42 2020 From: cfe-commits at lists.llvm.org (Kadir Cetinkaya via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:36:42 +0000 (UTC) Subject: [PATCH] D83546: [clangd] Fix hover crash on InitListExpr. In-Reply-To: References: Message-ID: <0cacb42ded348e91c43fc6c70507e1c0@localhost.localdomain> kadircet accepted this revision. kadircet added a comment. This revision is now accepted and ready to land. thanks, lgtm! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83546/new/ https://reviews.llvm.org/D83546 From cfe-commits at lists.llvm.org Fri Jul 10 06:37:40 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:37:40 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: LukeGeeson updated this revision to Diff 277019. LukeGeeson added a comment. - Added FP16 to Cortex-X1 set of features CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.277019.patch Type: text/x-patch Size: 21296 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 06:43:09 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:43:09 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman marked an inline comment as done. dgoldman added inline comments. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92 + if (const auto *ID = dyn_cast(D)) { + if (const auto *IMD = ID->getImplementation()) + return IMD; + return ID->getDefinition(); + } ---------------- sammccall wrote: > dgoldman wrote: > > Let me know if there's a better way to handle this multi-"definition" support > I think there might be (what you've done seems reasonable in isolation but I'm not sure it'll yield the best behavior). > > Consider this code: > ``` > int foo(); // A > int foo(); // B > int foo(){} // C > ``` > We have 3 declarations. A will be chosen as the canonical declaration (because it's first, though things get more complicated when the index is involved). C is the definition. So go-to-definition will land on C, and then triggering it again will take you to A, and then back to C. go-to-declaration is the opposite. B is basically just a reference for our purposes, we won't navigate you there (except by find-refs). > > Now let's look at your example again: > ``` > @class MyClass; // A > @interface MyClass ... @end // B > @implementation MyClass ... @end // C > ``` > Thinking about where you might want to navigate to, A is certainly the least important of these, right? > It seems clear we want B to be considered the canonical declaration and C the definition. > > So I think: > - we should only return the implementation here if it exists, and otherwise nullptr rather than the inferface. > - getCanonicalDecl in AddResultDecl should special case ObjCInterfaceDecl to get the definition (i.e. @interface) if possible > - we need to convince other parts of clangd that these are the same symbol: > - targetDecl should resolve any reference to an ObjCImplDecl to the corresponding ObjCInterfaceDecl instead > - the indexer (`SymbolCollector`) also needs to handle this (the ObjCImplDecl should end up being the stored Definition under the ObjCInterfaceDecl's SymbolID) > > Some code will only see the forward declaration and that's OK. The index's merge rules are that a candidate "canonical declaration" which has an associated definition is preferred over one that doesn't. Since the implementation can always see the interface, the interface will end up being the canonical declaration after merge. Thanks, that makes sense - I agree that B should be the actual canonical declaration for our case (even though Clang picks A) and C is the definition. I think that part was confusing me, since Clang seems to use the forward declaration as the canonical one when it exists, but it seems like that's intentional/OK and shouldn't change (e.g. for `ReferenceFinder` in the same file). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Fri Jul 10 06:47:54 2020 From: cfe-commits at lists.llvm.org (Vaibhav Garg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:47:54 +0000 (UTC) Subject: [PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute In-Reply-To: References: Message-ID: <2d6880fa04d451eca7fecbe45ee66634@localhost.localdomain> gargvaibhav64 updated this revision to Diff 277022. gargvaibhav64 marked 3 inline comments as done. gargvaibhav64 added a comment. Incorporated the changes CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83174/new/ https://reviews.llvm.org/D83174 Files: clang/lib/Serialization/ASTReaderDecl.cpp clang/test/Modules/Inputs/inherit-attribute/a.h clang/test/Modules/Inputs/inherit-attribute/b.h clang/test/Modules/Inputs/inherit-attribute/c.h clang/test/Modules/Inputs/inherit-attribute/module.modulemap clang/test/Modules/inherit-attribute.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83174.277022.patch Type: text/x-patch Size: 3547 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 06:48:36 2020 From: cfe-commits at lists.llvm.org (Dave Green via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 13:48:36 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <989c73eb2652020dd6202ea3b9a2dcee@localhost.localdomain> dmgreen added inline comments. ================ Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:135 + (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | + AArch64::AEK_SSBS | AArch64::AEK_RAS)) AARCH64_CPU_NAME("neoverse-e1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, ---------------- AEK_RAS will be included in ARMV8_2A, I believe. ================ Comment at: llvm/include/llvm/Support/ARMTargetParser.def:298 +ARM_CPU_NAME("cortex-a78",ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + (ARM::AEK_RAS | ARM::AEK_DOTPROD)) +ARM_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, ---------------- This one too I think. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 From cfe-commits at lists.llvm.org Fri Jul 10 07:01:02 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 14:01:02 +0000 (UTC) Subject: [PATCH] D83120: [Analyzer][StreamChecker] Using BugType::SuppressOnSink at resource leak report. In-Reply-To: References: Message-ID: <9d05594f5a6c4e53149849d6e7e9bdd1@localhost.localdomain> balazske marked an inline comment as done. balazske added inline comments. ================ Comment at: clang/test/Analysis/stream.c:274-284 // Check that "location uniqueing" works. // This results in reporting only one occurence of resource leak for a stream. void check_leak_noreturn_2() { FILE *F1 = tmpfile(); if (!F1) return; if (Test == 1) { ---------------- Szelethus wrote: > Why did this change? Is there a sink in the return branch? The change is probably because D83115. Because the "uniqueing" one resource leak is reported from the two possible, and the order changes somehow (probably not the shortest is found first). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83120/new/ https://reviews.llvm.org/D83120 From cfe-commits at lists.llvm.org Fri Jul 10 07:06:25 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:06:25 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: <87af580a891ad26c5a4480a2d5498781@localhost.localdomain> dgoldman updated this revision to Diff 277026. dgoldman added a comment. Fixes for getDefinition/getCanonicalDecl for ObjC Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/XRefs.cpp clang-tools-extra/clangd/unittests/XRefsTests.cpp Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -688,7 +688,14 @@ R"objc(//objc @class $decl[[Foo]]; - @interface $def[[Foo]] + Fo^o * getFoo() { + return 0; + } + )objc", + + R"objc(//objc + @class Foo; + @interface $decl[[Foo]] @end Fo^o * getFoo() { return 0; @@ -696,8 +703,8 @@ )objc", R"objc(//objc - @class $decl[[Foo]]; - @interface Foo + @class Foo; + @interface $decl[[Foo]] @end @implementation $def[[Foo]] @end Index: clang-tools-extra/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/clangd/XRefs.cpp +++ clang-tools-extra/clangd/XRefs.cpp @@ -80,16 +80,8 @@ return FD->getDefinition(); if (const auto *PD = dyn_cast(D)) return PD->getDefinition(); - // Objective-C classes can have three types of declarations: - // - // - forward declaration: @class MyClass; - // - definition declaration: @interface MyClass ... @end - // - implementation: @implementation MyClass ... @end - if (const auto *ID = dyn_cast(D)) { - if (const auto *IMD = ID->getImplementation()) - return IMD; - return ID->getDefinition(); - } + if (const auto *ID = dyn_cast(D)) + return ID->getImplementation(); // Only a single declaration is allowed. if (isa(D) || isa(D) || isa(D)) // except cases above @@ -235,6 +227,30 @@ return llvm::None; } +// A wrapper around `Decl::getCanonicalDecl` to support cases where Clang's +// definition of a canonical declaration doesn't match up to what a programmer +// would expect. For example, Objective-C classes can have three types of +// declarations: +// +// - forward declaration(s): @class MyClass; +// - definition declaration: @interface MyClass ... @end +// - implementation: @implementation MyClass ... @end +// +// Clang will consider the forward declaration to be the canonical declaration +// because it is first, but we actually want the class definition if it is +// available since that is what a programmer would consider the real definition +// to be. +const NamedDecl *getNonStandardCanonicalDecl(const NamedDecl *D) { + D = llvm::cast(D->getCanonicalDecl()); + + // Prefer Objective-C class definitions over the forward declaration. + if (const auto *ID = dyn_cast(D)) + if (const auto *DefinitionID = ID->getDefinition()) + return DefinitionID; + + return D; +} + // Decls are more complicated. // The AST contains at least a declaration, maybe a definition. // These are up-to-date, and so generally preferred over index results. @@ -250,7 +266,7 @@ llvm::DenseMap ResultIndex; auto AddResultDecl = [&](const NamedDecl *D) { - D = llvm::cast(D->getCanonicalDecl()); + D = getNonStandardCanonicalDecl(D); auto Loc = makeLocation(AST.getASTContext(), nameLocation(*D, SM), MainFilePath); if (!Loc) -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.277026.patch Type: text/x-patch Size: 3338 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 07:08:42 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:08:42 +0000 (UTC) Subject: [PATCH] D83556: [clangd] Update semanticTokens support to reflect latest LSP draft Message-ID: sammccall created this revision. sammccall added a reviewer: hokein. Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay, ilya-biryukov. Herald added a project: clang. Mostly a few methods and message names have been renamed. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83556 Files: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/Protocol.cpp clang-tools-extra/clangd/Protocol.h clang-tools-extra/clangd/test/initialize-params.test clang-tools-extra/clangd/test/semantic-tokens.test -------------- next part -------------- A non-text attachment was scrubbed... Name: D83556.277027.patch Type: text/x-patch Size: 9424 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 07:19:04 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via cfe-commits) Date: Fri, 10 Jul 2020 07:19:04 -0700 (PDT) Subject: [clang-tools-extra] 015a0fa - [clangd] Fix hover crash on InitListExpr. Message-ID: <5f0878d8.1c69fb81.fd83a.f32f@mx.google.com> Author: Haojian Wu Date: 2020-07-10T16:18:16+02:00 New Revision: 015a0faa5e9ef3095d521e1daf03fab9683ba028 URL: https://github.com/llvm/llvm-project/commit/015a0faa5e9ef3095d521e1daf03fab9683ba028 DIFF: https://github.com/llvm/llvm-project/commit/015a0faa5e9ef3095d521e1daf03fab9683ba028.diff LOG: [clangd] Fix hover crash on InitListExpr. Fixes https://github.com/clangd/clangd/issues/455 Differential Revision: https://reviews.llvm.org/D83546 Added: Modified: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index cba933508fd5..8305a4724035 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -329,13 +329,23 @@ void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D, llvm::Optional printExprValue(const Expr *E, const ASTContext &Ctx) { - Expr::EvalResult Constant; + // InitListExpr has two forms, syntactic and semantic. They are the same thing + // (refer to a same AST node) in most cases. + // When they are diff erent, RAV returns the syntactic form, and we should feed + // the semantic form to EvaluateAsRValue. + if (const auto *ILE = llvm::dyn_cast(E)) { + if (!ILE->isSemanticForm()) + E = ILE->getSemanticForm(); + } + // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up // to the enclosing call. QualType T = E->getType(); if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() || T->isFunctionReferenceType()) return llvm::None; + + Expr::EvalResult Constant; // Attempt to evaluate. If expr is dependent, evaluation crashes! if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) || // Disable printing for record-types, as they are usually confusing and diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 43f1e7142550..19ab6d63947b 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -801,6 +801,21 @@ class Foo {})cpp"; HI.LocalScope = "Foo::"; HI.Type = "int"; HI.AccessSpecifier = "public"; + }}, + {// No crash on InitListExpr. + R"cpp( + struct Foo { + int a[10]; + }; + constexpr Foo k2 = { + ^[[{]]1} // FIXME: why the hover range is 1 character? + }; + )cpp", + [](HoverInfo &HI) { + HI.Name = "expression"; + HI.Kind = index::SymbolKind::Unknown; + HI.Type = "int [10]"; + HI.Value = "{1}"; }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); From cfe-commits at lists.llvm.org Fri Jul 10 07:19:18 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:19:18 +0000 (UTC) Subject: [PATCH] D83546: [clangd] Fix hover crash on InitListExpr. In-Reply-To: References: Message-ID: <72bacd0161c41b46a5ef90abf814ffce@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG015a0faa5e9e: [clangd] Fix hover crash on InitListExpr. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D83546?vs=277016&id=277031#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83546/new/ https://reviews.llvm.org/D83546 Files: clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -801,6 +801,21 @@ HI.LocalScope = "Foo::"; HI.Type = "int"; HI.AccessSpecifier = "public"; + }}, + {// No crash on InitListExpr. + R"cpp( + struct Foo { + int a[10]; + }; + constexpr Foo k2 = { + ^[[{]]1} // FIXME: why the hover range is 1 character? + }; + )cpp", + [](HoverInfo &HI) { + HI.Name = "expression"; + HI.Kind = index::SymbolKind::Unknown; + HI.Type = "int [10]"; + HI.Value = "{1}"; }}}; for (const auto &Case : Cases) { SCOPED_TRACE(Case.Code); Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -329,13 +329,23 @@ llvm::Optional printExprValue(const Expr *E, const ASTContext &Ctx) { - Expr::EvalResult Constant; + // InitListExpr has two forms, syntactic and semantic. They are the same thing + // (refer to a same AST node) in most cases. + // When they are different, RAV returns the syntactic form, and we should feed + // the semantic form to EvaluateAsRValue. + if (const auto *ILE = llvm::dyn_cast(E)) { + if (!ILE->isSemanticForm()) + E = ILE->getSemanticForm(); + } + // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up // to the enclosing call. QualType T = E->getType(); if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() || T->isFunctionReferenceType()) return llvm::None; + + Expr::EvalResult Constant; // Attempt to evaluate. If expr is dependent, evaluation crashes! if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) || // Disable printing for record-types, as they are usually confusing and -------------- next part -------------- A non-text attachment was scrubbed... Name: D83546.277031.patch Type: text/x-patch Size: 2150 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 07:20:20 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:20:20 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <2643c394554079cff7ff46527cbeed37@localhost.localdomain> LukeGeeson updated this revision to Diff 277032. LukeGeeson added a comment. - removed RAS as it's in 8.2a CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.277032.patch Type: text/x-patch Size: 21262 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 07:22:16 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:22:16 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: LukeGeeson updated this revision to Diff 277033. LukeGeeson marked an inline comment as done. LukeGeeson added a comment. - removed missed RAS CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.277033.patch Type: text/x-patch Size: 21247 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 07:26:24 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:26:24 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <86e1244fe3d5a675aa5ab0e5f154c86c@localhost.localdomain> LukeGeeson updated this revision to Diff 277036. LukeGeeson added a comment. - Added FP16 to ARM a78 CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.277036.patch Type: text/x-patch Size: 21278 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 07:27:18 2020 From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:27:18 +0000 (UTC) Subject: [PATCH] D83556: [clangd] Update semanticTokens support to reflect latest LSP draft In-Reply-To: References: Message-ID: hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. thanks! Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83556/new/ https://reviews.llvm.org/D83556 From cfe-commits at lists.llvm.org Fri Jul 10 07:33:49 2020 From: cfe-commits at lists.llvm.org (Gabor Marton via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:33:49 +0000 (UTC) Subject: [PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions In-Reply-To: References: Message-ID: martong marked 2 inline comments as done. martong added inline comments. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:328-329 struct Signature { - const ArgTypes ArgTys; - const QualType RetTy; + ArgTypes ArgTys; + QualType RetTy; Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) { ---------------- Szelethus wrote: > Ah right, because we need to copy this. Shame that `Optional` can't just inplace construct the object with a copy constructor or something. The problem is rather with the copy assignment. I think, copy construction could be implemented if we keep the `const`, but assignment is not. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1746 + if (StructSockaddrPtrRestrictTy && Socklen_tPtrRestrictTy) { + auto Accept = Summary(NoEvalCall) + .ArgConstraint(ArgumentCondition(0, WithinRange, ---------------- Szelethus wrote: > `AcceptSummary`? I prefer simply `Accept` because right after the `=` sign we have the `Summary` string :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83407/new/ https://reviews.llvm.org/D83407 From cfe-commits at lists.llvm.org Fri Jul 10 07:34:31 2020 From: cfe-commits at lists.llvm.org (Kevin P. Neal via cfe-commits) Date: Fri, 10 Jul 2020 07:34:31 -0700 (PDT) Subject: [clang] 523a851 - [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support." Message-ID: <5f087c77.1c69fb81.2e7fe.e720@mx.google.com> Author: Kevin P. Neal Date: 2020-07-10T10:34:15-04:00 New Revision: 523a8513f8ba4d6b111496c541b9ba9f4d5f0261 URL: https://github.com/llvm/llvm-project/commit/523a8513f8ba4d6b111496c541b9ba9f4d5f0261 DIFF: https://github.com/llvm/llvm-project/commit/523a8513f8ba4d6b111496c541b9ba9f4d5f0261.diff LOG: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support." Use the new -fexperimental-strict-floating-point flag in more cases to fix the arm and aarch64 bots. Differential Revision: https://reviews.llvm.org/D80952 Added: Modified: clang/test/CodeGen/fpconstrained-cmp-double.c clang/test/CodeGen/fpconstrained-cmp-float.c Removed: ################################################################################ diff --git a/clang/test/CodeGen/fpconstrained-cmp-double.c b/clang/test/CodeGen/fpconstrained-cmp-double.c index 6f19db2099db..335b7e49b01d 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-double.c +++ b/clang/test/CodeGen/fpconstrained-cmp-double.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=FCMP // RUN: %clang_cc1 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP -// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE +// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP diff --git a/clang/test/CodeGen/fpconstrained-cmp-float.c b/clang/test/CodeGen/fpconstrained-cmp-float.c index bca0cdb7eda4..e9667904122b 100644 --- a/clang/test/CodeGen/fpconstrained-cmp-float.c +++ b/clang/test/CodeGen/fpconstrained-cmp-float.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=FCMP +// RUN: %clang_cc1 -ffp-exception-behavior=ignore -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=FCMP // RUN: %clang_cc1 -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP -// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE +// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP From cfe-commits at lists.llvm.org Fri Jul 10 07:44:54 2020 From: cfe-commits at lists.llvm.org (Jeroen Dobbelaere via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:44:54 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: <6ae9ae12ffa2156a8d8f5668b4f5c3ca@localhost.localdomain> jeroen.dobbelaere added a comment. I think that 'clang/include/clang/Driver/CC1Options.td' should also be removed ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 07:52:10 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:52:10 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: <9bc4249fad349f3d2c6e32d8f76ef506@localhost.localdomain> sammccall added a comment. I think without index changes this will still give the wrong answer for go-to-definition if the @implementation is in a different file. Do you want to include those too or will that work ok in a separate patch? (I'm not 100% sure of the interactions here, possible it'll seem a bit glitchy) ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:241 +// because it is first, but we actually want the class definition if it is +// available since that is what a programmer would consider the real definition +// to be. ---------------- nit: real definition -> primary declaration ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:243 +// to be. +const NamedDecl *getNonStandardCanonicalDecl(const NamedDecl *D) { + D = llvm::cast(D->getCanonicalDecl()); ---------------- I'd consider getPreferredDecl here. We may consider moving this to AST.h someday. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92 + if (const auto *ID = dyn_cast(D)) { + if (const auto *IMD = ID->getImplementation()) + return IMD; + return ID->getDefinition(); + } ---------------- dgoldman wrote: > sammccall wrote: > > dgoldman wrote: > > > Let me know if there's a better way to handle this multi-"definition" support > > I think there might be (what you've done seems reasonable in isolation but I'm not sure it'll yield the best behavior). > > > > Consider this code: > > ``` > > int foo(); // A > > int foo(); // B > > int foo(){} // C > > ``` > > We have 3 declarations. A will be chosen as the canonical declaration (because it's first, though things get more complicated when the index is involved). C is the definition. So go-to-definition will land on C, and then triggering it again will take you to A, and then back to C. go-to-declaration is the opposite. B is basically just a reference for our purposes, we won't navigate you there (except by find-refs). > > > > Now let's look at your example again: > > ``` > > @class MyClass; // A > > @interface MyClass ... @end // B > > @implementation MyClass ... @end // C > > ``` > > Thinking about where you might want to navigate to, A is certainly the least important of these, right? > > It seems clear we want B to be considered the canonical declaration and C the definition. > > > > So I think: > > - we should only return the implementation here if it exists, and otherwise nullptr rather than the inferface. > > - getCanonicalDecl in AddResultDecl should special case ObjCInterfaceDecl to get the definition (i.e. @interface) if possible > > - we need to convince other parts of clangd that these are the same symbol: > > - targetDecl should resolve any reference to an ObjCImplDecl to the corresponding ObjCInterfaceDecl instead > > - the indexer (`SymbolCollector`) also needs to handle this (the ObjCImplDecl should end up being the stored Definition under the ObjCInterfaceDecl's SymbolID) > > > > Some code will only see the forward declaration and that's OK. The index's merge rules are that a candidate "canonical declaration" which has an associated definition is preferred over one that doesn't. Since the implementation can always see the interface, the interface will end up being the canonical declaration after merge. > Thanks, that makes sense - I agree that B should be the actual canonical declaration for our case (even though Clang picks A) and C is the definition. I think that part was confusing me, since Clang seems to use the forward declaration as the canonical one when it exists, but it seems like that's intentional/OK and shouldn't change (e.g. for `ReferenceFinder` in the same file). > Clang seems to use the forward declaration as the canonical one when it exists This is **super** confusing. Clang has a concept of canonical declaration that's basically arbitrary: you pick one so that e.g. if you have canonical decls you can compare their pointers. It picks the first one seen, which is nice because it's stable over the life of the parse. Clangd has a concept of canonical declaration that's not arbitrary: it's meant to be the declaration the user wants to see. And yet, clangd's canonical is initialized to clang's canonical by default, because we've got to pick something. There is some more logic (e.g. a class's canonical decl is its def, if that's in a header file) but it mostly exists in the indexer, so it's not really obvious. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Fri Jul 10 07:53:09 2020 From: cfe-commits at lists.llvm.org (Sam McCall via cfe-commits) Date: Fri, 10 Jul 2020 07:53:09 -0700 (PDT) Subject: [clang-tools-extra] 5fea54b - [clangd] Update semanticTokens support to reflect latest LSP draft Message-ID: <5f0880d5.1c69fb81.3b1b9.031a@mx.google.com> Author: Sam McCall Date: 2020-07-10T16:52:57+02:00 New Revision: 5fea54bc05a71e81e843fd9284d258cd38d7fe23 URL: https://github.com/llvm/llvm-project/commit/5fea54bc05a71e81e843fd9284d258cd38d7fe23 DIFF: https://github.com/llvm/llvm-project/commit/5fea54bc05a71e81e843fd9284d258cd38d7fe23.diff LOG: [clangd] Update semanticTokens support to reflect latest LSP draft Summary: Mostly a few methods and message names have been renamed. Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83556 Added: Modified: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/Protocol.cpp clang-tools-extra/clangd/Protocol.h clang-tools-extra/clangd/test/initialize-params.test clang-tools-extra/clangd/test/semantic-tokens.test Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 1d794b1898c7..b0aba886edbe 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -599,8 +599,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params, }}, {"semanticTokensProvider", llvm::json::Object{ - {"documentProvider", llvm::json::Object{{"edits", true}}}, - {"rangeProvider", false}, + {"full", llvm::json::Object{{"delta", true}}}, + {"range", false}, {"legend", llvm::json::Object{{"tokenTypes", semanticTokenTypes()}, {"tokenModifiers", llvm::json::Array()}}}, @@ -1311,9 +1311,9 @@ void ClangdLSPServer::onSemanticTokens(const SemanticTokensParams &Params, }); } -void ClangdLSPServer::onSemanticTokensEdits( - const SemanticTokensEditsParams &Params, - Callback CB) { +void ClangdLSPServer::onSemanticTokensDelta( + const SemanticTokensDeltaParams &Params, + Callback CB) { Server->semanticHighlights( Params.textDocument.uri.file(), [this, PrevResultID(Params.previousResultId), @@ -1323,7 +1323,7 @@ void ClangdLSPServer::onSemanticTokensEdits( return CB(HT.takeError()); std::vector Toks = toSemanticTokens(*HT); - SemanticTokensOrEdits Result; + SemanticTokensOrDelta Result; { std::lock_guard Lock(SemanticTokensMutex); auto &Last = LastSemanticTokens[File]; @@ -1331,8 +1331,8 @@ void ClangdLSPServer::onSemanticTokensEdits( if (PrevResultID == Last.resultId) { Result.edits = diff Tokens(Last.tokens, Toks); } else { - vlog("semanticTokens/edits: wanted edits vs {0} but last result " - "had ID {1}. Returning full token list.", + vlog("semanticTokens/full/delta: wanted edits vs {0} but last " + "result had ID {1}. Returning full token list.", PrevResultID, Last.resultId); Result.tokens = Toks; } @@ -1393,8 +1393,8 @@ ClangdLSPServer::ClangdLSPServer( MsgHandler->bind("typeHierarchy/resolve", &ClangdLSPServer::onResolveTypeHierarchy); MsgHandler->bind("textDocument/selectionRange", &ClangdLSPServer::onSelectionRange); MsgHandler->bind("textDocument/documentLink", &ClangdLSPServer::onDocumentLink); - MsgHandler->bind("textDocument/semanticTokens", &ClangdLSPServer::onSemanticTokens); - MsgHandler->bind("textDocument/semanticTokens/edits", &ClangdLSPServer::onSemanticTokensEdits); + MsgHandler->bind("textDocument/semanticTokens/full", &ClangdLSPServer::onSemanticTokens); + MsgHandler->bind("textDocument/semanticTokens/full/delta", &ClangdLSPServer::onSemanticTokensDelta); // clang-format on } diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h b/clang-tools-extra/clangd/ClangdLSPServer.h index 6ccef9500679..a779e9036c4a 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.h +++ b/clang-tools-extra/clangd/ClangdLSPServer.h @@ -121,8 +121,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks { void onDocumentLink(const DocumentLinkParams &, Callback>); void onSemanticTokens(const SemanticTokensParams &, Callback); - void onSemanticTokensEdits(const SemanticTokensEditsParams &, - Callback); + void onSemanticTokensDelta(const SemanticTokensDeltaParams &, + Callback); std::vector getFixes(StringRef File, const clangd::Diagnostic &D); diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index ecae65336e5b..239603715785 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -1029,7 +1029,7 @@ llvm::json::Value toJSON(const SemanticTokensEdit &Edit) { {"data", encodeTokens(Edit.tokens)}}; } -llvm::json::Value toJSON(const SemanticTokensOrEdits &TE) { +llvm::json::Value toJSON(const SemanticTokensOrDelta &TE) { llvm::json::Object Result{{"resultId", TE.resultId}}; if (TE.edits) Result["edits"] = *TE.edits; @@ -1043,7 +1043,7 @@ bool fromJSON(const llvm::json::Value &Params, SemanticTokensParams &R) { return O && O.map("textDocument", R.textDocument); } -bool fromJSON(const llvm::json::Value &Params, SemanticTokensEditsParams &R) { +bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R) { llvm::json::ObjectMapper O(Params); return O && O.map("textDocument", R.textDocument) && O.map("previousResultId", R.previousResultId); diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index 0177ee262ae3..77d402a6a9ba 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -1384,27 +1384,27 @@ struct SemanticTokens { // send a delta. std::string resultId; - /// The actual tokens. For a detailed description about how the data is - /// structured pls see - /// https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L71 - std::vector tokens; + /// The actual tokens. + std::vector tokens; // encoded as a flat integer array. }; llvm::json::Value toJSON(const SemanticTokens &); +/// Body of textDocument/semanticTokens/full request. struct SemanticTokensParams { /// The text document. TextDocumentIdentifier textDocument; }; bool fromJSON(const llvm::json::Value &, SemanticTokensParams &); +/// Body of textDocument/semanticTokens/full/delta request. /// Requests the changes in semantic tokens since a previous response. -struct SemanticTokensEditsParams { +struct SemanticTokensDeltaParams { /// The text document. TextDocumentIdentifier textDocument; /// The previous result id. std::string previousResultId; }; -bool fromJSON(const llvm::json::Value &Params, SemanticTokensEditsParams &R); +bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R); /// Describes a a replacement of a contiguous range of semanticTokens. struct SemanticTokensEdit { @@ -1413,20 +1413,20 @@ struct SemanticTokensEdit { // We use token counts instead, and translate when serializing this struct. unsigned startToken = 0; unsigned deleteTokens = 0; - std::vector tokens; + std::vector tokens; // encoded as a flat integer array }; llvm::json::Value toJSON(const SemanticTokensEdit &); -/// This models LSP SemanticTokensEdits | SemanticTokens, which is the result of -/// textDocument/semanticTokens/edits. -struct SemanticTokensOrEdits { +/// This models LSP SemanticTokensDelta | SemanticTokens, which is the result of +/// textDocument/semanticTokens/full/delta. +struct SemanticTokensOrDelta { std::string resultId; /// Set if we computed edits relative to a previous set of tokens. llvm::Optional> edits; /// Set if we computed a fresh set of tokens. - llvm::Optional> tokens; + llvm::Optional> tokens; // encoded as integer array }; -llvm::json::Value toJSON(const SemanticTokensOrEdits &); +llvm::json::Value toJSON(const SemanticTokensOrDelta &); /// Represents a semantic highlighting information that has to be applied on a /// specific line of the text document. diff --git a/clang-tools-extra/clangd/test/initialize-params.test b/clang-tools-extra/clangd/test/initialize-params.test index f1f5312d1009..f0a0f791c2f6 100644 --- a/clang-tools-extra/clangd/test/initialize-params.test +++ b/clang-tools-extra/clangd/test/initialize-params.test @@ -42,8 +42,8 @@ # CHECK-NEXT: "renameProvider": true, # CHECK-NEXT: "selectionRangeProvider": true, # CHECK-NEXT: "semanticTokensProvider": { -# CHECK-NEXT: "documentProvider": { -# CHECK-NEXT: "edits": true +# CHECK-NEXT: "full": { +# CHECK-NEXT: "delta": true # CHECK-NEXT: }, # CHECK-NEXT: "legend": { # CHECK-NEXT: "tokenModifiers": [], @@ -51,7 +51,7 @@ # CHECK-NEXT: "variable", # CHECK: ] # CHECK-NEXT: }, -# CHECK-NEXT: "rangeProvider": false +# CHECK-NEXT: "range": false # CHECK-NEXT: }, # CHECK-NEXT: "signatureHelpProvider": { # CHECK-NEXT: "triggerCharacters": [ diff --git a/clang-tools-extra/clangd/test/semantic-tokens.test b/clang-tools-extra/clangd/test/semantic-tokens.test index 6fab10362b28..ed0c0d09a13e 100644 --- a/clang-tools-extra/clangd/test/semantic-tokens.test +++ b/clang-tools-extra/clangd/test/semantic-tokens.test @@ -13,7 +13,7 @@ }}} --- # Non-incremental token request. -{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens","params":{"textDocument":{"uri":"test:///foo.cpp"}}} +{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"test:///foo.cpp"}}} # CHECK: "id": 1, # CHECK-NEXT: "jsonrpc": "2.0", # CHECK-NEXT: "result": { @@ -34,7 +34,7 @@ }} --- # Incremental token request, based on previous response. -{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{ +{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full/delta","params":{ "textDocument": {"uri":"test:///foo.cpp"}, "previousResultId": "1" }} @@ -60,7 +60,7 @@ # CHECK-NEXT: } --- # Incremental token request with incorrect baseline => full tokens list. -{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{ +{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full/delta","params":{ "textDocument": {"uri":"test:///foo.cpp"}, "previousResultId": "bogus" }} From cfe-commits at lists.llvm.org Fri Jul 10 07:53:20 2020 From: cfe-commits at lists.llvm.org (Sam McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 14:53:20 +0000 (UTC) Subject: [PATCH] D83556: [clangd] Update semanticTokens support to reflect latest LSP draft In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG5fea54bc05a7: [clangd] Update semanticTokens support to reflect latest LSP draft (authored by sammccall). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83556/new/ https://reviews.llvm.org/D83556 Files: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/Protocol.cpp clang-tools-extra/clangd/Protocol.h clang-tools-extra/clangd/test/initialize-params.test clang-tools-extra/clangd/test/semantic-tokens.test -------------- next part -------------- A non-text attachment was scrubbed... Name: D83556.277038.patch Type: text/x-patch Size: 9424 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 08:00:04 2020 From: cfe-commits at lists.llvm.org (Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:00:04 +0000 (UTC) Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu In-Reply-To: References: Message-ID: <8cb4ae811e002ac8ac4400abf52f785d@localhost.localdomain> khchen updated this revision to Diff 277042. khchen added a comment. fix typo Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71124/new/ https://reviews.llvm.org/D71124 Files: clang/lib/Basic/Targets/RISCV.cpp clang/lib/Basic/Targets/RISCV.h clang/lib/Driver/ToolChains/Arch/RISCV.cpp clang/lib/Driver/ToolChains/Arch/RISCV.h clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/riscv-cpus.c llvm/include/llvm/Support/RISCVTargetParser.def llvm/include/llvm/Support/TargetParser.h llvm/lib/Support/TargetParser.cpp llvm/lib/Target/RISCV/RISCV.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D71124.277042.patch Type: text/x-patch Size: 17920 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 08:05:42 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:05:42 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: <1df6a21fbaa0f671c41dcb79727cd121@localhost.localdomain> gribozavr2 accepted this revision. gribozavr2 added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:749 + else + return new (allocator()) syntax::FloatUserDefinedLiteralExpression; + } ---------------- `... else { assert(Literal.isFloatingLiteral()); return new ... }` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 From cfe-commits at lists.llvm.org Fri Jul 10 08:05:52 2020 From: cfe-commits at lists.llvm.org (Cullen Rhodes via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:05:52 +0000 (UTC) Subject: [PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute In-Reply-To: References: Message-ID: <135282858081e1ead83b4eb360bc97e7@localhost.localdomain> c-rhodes updated this revision to Diff 277043. c-rhodes added a comment. Changes: - Use fixed-length instead of fixed-width in naming. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83553/new/ https://reviews.llvm.org/D83553 Files: clang/lib/CodeGen/CGExpr.cpp clang/lib/CodeGen/CGRecordLayoutBuilder.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/CodeGenTypes.h clang/test/Sema/attr-arm-sve-vector-bits-bitcast.c clang/test/Sema/attr-arm-sve-vector-bits-call.c clang/test/Sema/attr-arm-sve-vector-bits-cast.c clang/test/Sema/attr-arm-sve-vector-bits-codegen.c clang/test/Sema/attr-arm-sve-vector-bits-globals.c clang/test/Sema/attr-arm-sve-vector-bits-types.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83553.277043.patch Type: text/x-patch Size: 70170 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 08:18:10 2020 From: cfe-commits at lists.llvm.org (Bevin Hansson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:18:10 +0000 (UTC) Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations. In-Reply-To: References: Message-ID: <7a08130ffc8e9dc54768b37662014657@localhost.localdomain> ebevhan added a comment. In D82663#2142426 , @rjmccall wrote: > Would it be sensible to use a technical design more like what the matrix folks are doing, where LLVM provides a small interface for emitting operations with various semantics? FixedPointSemantics would move to that header, and Clang would just call into it. That way you get a lot more flexibility in how you generate code, and the Clang IRGen logic is still transparently correct. If you want to add intrinsics or otherwise change the IR patterns used for various operations, you don't have to rewrite a bunch of Clang IRGen logic every time, you just have to update the tests. It'd then be pretty straightforward to have internal helper functions in that interface for computing things like whether you should use signed or unsigned intrinsics given the desired FixedPointSemantics. This seems like a reasonable thing to do for other reasons as well. Also moving the actual APFixedPoint class to LLVM would make it easier to reuse the fixedpoint calculation code for constant folding in LLVM, for example. > My interest here is mainly in (1) keeping IRGen's logic as obviously correct as possible, (2) not hard-coding a bunch of things that really feel like workarounds for backend limitations, and (3) not complicating core abstractions like FixedPointSemantics with unnecessary extra rules for appropriate use, like having to pass an extra "for codegen" flag to get optimal codegen. If IRGen can just pass down the high-level semantics it wants to some library that will make intelligent decisions about how to emit IR, that seems best. Just to clarify something here; would the interface in LLVM still emit signed operations for unsigned with padding? If so, why does dealing with the padding bit detail in LLVM rather than Clang make more sense? The regular IRBuilder is relatively straightforward in its behavior. I suspect that if anything, LLVM would be equally unwilling to take to take IRBuilder patches that emitted signed intrinsics for certain unsigned operations only due to a detail in Embedded-C's implementation of fixedpoint support. I could remove the special behavior from FixedPointSemantics and only deal with it in EmitFixedPointBinOp instead. I agree that the FixedPointSemantics interface is muddied by the extra parameter. Unless I alter the semantics object it might make EmitFixedPointBinOp rather messy, though. --- Regarding backend limitations, I guess I could propose an alternate solution. If we change FixedPointSemantics to strip the padding bit for both saturating and nonsaturating operations, it may be possible to detect in isel that the corresponding signed operation could be used instead when we promote the type of an unsigned one. For example, if we emit i15 umul.fix scale 15, we could tell in lowering that i16 smul.fix scale 15 is legal and use that instead. Same for all the other intrinsics, including the non-fixedpoint uadd.sat/usub.sat. The issue with this approach (which is why I didn't really want to do it) is that it's not testable. No upstream target has these intrinsics marked as legal. I doubt anyone would accept a patch with no tests. It may also be less efficient than just emitting the signed operations in the first place, because we are forced to trunc and zext in IR before and after every operation. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82663/new/ https://reviews.llvm.org/D82663 From cfe-commits at lists.llvm.org Fri Jul 10 08:27:50 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:27:50 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman updated this revision to Diff 277054. dgoldman marked 2 inline comments as done. dgoldman added a comment. Add support for categories + fix tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/XRefs.cpp clang-tools-extra/clangd/unittests/XRefsTests.cpp Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -676,7 +676,7 @@ }; )cpp", - R"objc(//objc + R"objc( @protocol $decl[[Dog]]; @protocol $def[[Dog]] - (void)bark; @@ -686,14 +686,25 @@ } )objc", - R"objc(//objc + R"objc( + @interface Cat + @end + @interface $decl[[Ca^t]] (Extension) + - (void)meow; + @end + @implementation $def[[Cat]] (Extension) + - (void)meow {} + @end + )objc", + + R"objc( @class $decl[[Foo]]; Fo^o * getFoo() { return 0; } )objc", - R"objc(//objc + R"objc( @class Foo; @interface $decl[[Foo]] @end @@ -702,7 +713,7 @@ } )objc", - R"objc(//objc + R"objc( @class Foo; @interface $decl[[Foo]] @end @@ -726,14 +737,10 @@ TestTU TU; TU.Code = std::string(T.code()); - std::string ObjcPrefix = "//objc"; - if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) { - TU.Filename = "TestTU.m"; - } - // FIXME: Auto-completion in a template requires disabling delayed template // parsing. TU.ExtraArgs.push_back("-fno-delayed-template-parsing"); + TU.ExtraArgs.push_back("-xobjective-c++"); auto AST = TU.build(); auto Results = locateSymbolAt(AST, T.point()); Index: clang-tools-extra/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/clangd/XRefs.cpp +++ clang-tools-extra/clangd/XRefs.cpp @@ -82,6 +82,8 @@ return PD->getDefinition(); if (const auto *ID = dyn_cast(D)) return ID->getImplementation(); + if (const auto *CD = dyn_cast(D)) + return CD->getImplementation(); // Only a single declaration is allowed. if (isa(D) || isa(D) || isa(D)) // except cases above -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.277054.patch Type: text/x-patch Size: 2204 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 08:39:40 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:39:40 +0000 (UTC) Subject: [PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend In-Reply-To: References: Message-ID: <377084893c089599678ef3e6412bfbc7@localhost.localdomain> amyk added a comment. Please update this patch to remove the instruction defs and MC tests. Also, you can update the patch to put your backend llc tests in the file I've introduced in: https://reviews.llvm.org/D82467 ================ Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:14 -#include +#include "altivec.h" ---------------- unintended change? ================ Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14165 + // The width of the narrow type becomes an operand of the LXVRZX node + SDValue Width = ; + SDValue LoadOps[] = {LD->getChain(), LD->getBasePtr(), DAG.getIntPtrConstant(MemoryType.getScalarSizeInBits(), dl)}; ---------------- You did not assign anything here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82502/new/ https://reviews.llvm.org/D82502 From cfe-commits at lists.llvm.org Fri Jul 10 08:40:45 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:40:45 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: <1e39974d4e20fd7d3fa829ff14ba154d@localhost.localdomain> eduucaldas updated this revision to Diff 277060. eduucaldas marked an inline comment as done. eduucaldas added a comment. Add assert Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 Files: clang/include/clang/Tooling/Syntax/Nodes.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Syntax/Nodes.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82157.277060.patch Type: text/x-patch Size: 13629 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 08:42:42 2020 From: cfe-commits at lists.llvm.org (Nathan Ridge via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:42:42 +0000 (UTC) Subject: [PATCH] D83536: [clangd] Index refs to main-file symbols as well In-Reply-To: References: Message-ID: <080eea7b057667e0b7ca9f03f5eb2097@localhost.localdomain> nridge added a comment. In D83536#2143436 , @kadircet wrote: > I can see how this is needed for implementing the full protocol though (we've already cut on the multi-level callees support), so would you be so kind to hide this behind an option to symbol collector (`CollectRefsInMainFile`) and then introduce a flag to clangd for controlling it `--collect-refs-in-main-file` and plumb it to `BackgroundIndex` and `FileIndex` via `ClangdServer`? I can do that. Another thing we could consider, if the space increase is a concern, is to limit which references we store, e.g. to functions only (not variables or classes). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83536/new/ https://reviews.llvm.org/D83536 From cfe-commits at lists.llvm.org Fri Jul 10 08:43:07 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:43:07 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman marked an inline comment as done. dgoldman added a comment. In D83501#2144144 , @sammccall wrote: > I think without index changes this will still give the wrong answer for go-to-definition if the @implementation is in a different file. > Do you want to include those too or will that work ok in a separate patch? > (I'm not 100% sure of the interactions here, possible it'll seem a bit glitchy) I'll look into the index changes as well in this change, just wanted to get the base functionality down for xrefs first. If it seems large I'll probably send a follow up diff. ================ Comment at: clang-tools-extra/clangd/XRefs.cpp:276 getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) { // Special case: void foo() ^override: jump to the overridden method. if (const auto *CMD = llvm::dyn_cast(D)) { ---------------- sammccall wrote: > dgoldman wrote: > > Think it would make sense to special case ObjCInterfaceDecl here to get at both the interface definition + implementation if available? > Rather than returning both results, I think it's more consistent to return them as a declaration/definition pair. > > (This means special-casing ObjCImplDecl in namedDecl or at least getDeclAsPosition, so you always end up with the ObjCInterfaceDecl instead) Whoops, meant to comment here but it was lost. I'm not sure what you meant here. Should this be done here inside the for loop or in getDeclAtPosition? Are you saying that given: ``` @interface Foo // A @end @implementation Foo // B @end ``` B --> A here and similarly ``` @interface Foo // A @end @interface Foo (Ext) // B @end @implementation Foo (Ext) // C @end ``` B --> A C --> B (and A? it's unclear how this should map over, e.g. maybe Foo loc --> A, Ext --> B) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Fri Jul 10 08:55:23 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via cfe-commits) Date: Fri, 10 Jul 2020 08:55:23 -0700 (PDT) Subject: [clang] 3607aac - Delete CC1Options.td, since it should have happened in D82574 Message-ID: <5f088f6b.1c69fb81.80483.e363@mx.google.com> Author: Daniel Grumberg Date: 2020-07-10T16:55:05+01:00 New Revision: 3607aacc59817f76bffb9b567f128871340d54d2 URL: https://github.com/llvm/llvm-project/commit/3607aacc59817f76bffb9b567f128871340d54d2 DIFF: https://github.com/llvm/llvm-project/commit/3607aacc59817f76bffb9b567f128871340d54d2.diff LOG: Delete CC1Options.td, since it should have happened in D82574 Added: Modified: Removed: clang/include/clang/Driver/CC1Options.td ################################################################################ diff --git a/clang/include/clang/Driver/CC1Options.td b/clang/include/clang/Driver/CC1Options.td deleted file mode 100644 index 5a7077ce9e46..000000000000 --- a/clang/include/clang/Driver/CC1Options.td +++ /dev/null @@ -1,946 +0,0 @@ -//===--- CC1Options.td - Options for clang -cc1 ---------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines the options accepted by clang -cc1 and clang -cc1as. -// -//===----------------------------------------------------------------------===// - -let Flags = [CC1Option, NoDriverOption] in { - -//===----------------------------------------------------------------------===// -// Target Options -//===----------------------------------------------------------------------===// - -let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { - -def target_cpu : Separate<["-"], "target-cpu">, - HelpText<"Target a specific cpu type">; -def target_feature : Separate<["-"], "target-feature">, - HelpText<"Target specific attributes">; -def triple : Separate<["-"], "triple">, - HelpText<"Specify target triple (e.g. i686-apple-darwin9)">, - MarshallingInfoString<"TargetOpts->Triple", "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">, - AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString; -def target_abi : Separate<["-"], "target-abi">, - HelpText<"Target a particular ABI type">; -def target_sdk_version_EQ : Joined<["-"], "target-sdk-version=">, - HelpText<"The version of target SDK used for compilation">; - -} - -def target_linker_version : Separate<["-"], "target-linker-version">, - HelpText<"Target linker version">; -def triple_EQ : Joined<["-"], "triple=">, Alias; -def mfpmath : Separate<["-"], "mfpmath">, - HelpText<"Which unit to use for fp math">; - -def fpadding_on_unsigned_fixed_point : Flag<["-"], "fpadding-on-unsigned-fixed-point">, - HelpText<"Force each unsigned fixed point type to have an extra bit of padding to align their scales with those of signed fixed point types">; -def fno_padding_on_unsigned_fixed_point : Flag<["-"], "fno-padding-on-unsigned-fixed-point">; - -//===----------------------------------------------------------------------===// -// Analyzer Options -//===----------------------------------------------------------------------===// - -def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">, - HelpText<"Generate unoptimized CFGs for all analyses">; -def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">, - HelpText<"Add C++ implicit destructors to CFGs for all analyses">; - -def analyzer_store : Separate<["-"], "analyzer-store">, - HelpText<"Source Code Analysis - Abstract Memory Store Models">; -def analyzer_store_EQ : Joined<["-"], "analyzer-store=">, Alias; - -def analyzer_constraints : Separate<["-"], "analyzer-constraints">, - HelpText<"Source Code Analysis - Symbolic Constraint Engines">; -def analyzer_constraints_EQ : Joined<["-"], "analyzer-constraints=">, - Alias; - -def analyzer_output : Separate<["-"], "analyzer-output">, - HelpText<"Source Code Analysis - Output Options">; -def analyzer_output_EQ : Joined<["-"], "analyzer-output=">, - Alias; - -def analyzer_purge : Separate<["-"], "analyzer-purge">, - HelpText<"Source Code Analysis - Dead Symbol Removal Frequency">; -def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, Alias; - -def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">, - HelpText<"Force the static analyzer to analyze functions defined in header files">; -def analyzer_opt_analyze_nested_blocks : Flag<["-"], "analyzer-opt-analyze-nested-blocks">, - HelpText<"Analyze the definitions of blocks in addition to functions">; -def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">, - HelpText<"Emit verbose output about the analyzer's progress">; -def analyze_function : Separate<["-"], "analyze-function">, - HelpText<"Run analysis on specific function (for C++ include parameters in name)">; -def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias; -def trim_egraph : Flag<["-"], "trim-egraph">, - HelpText<"Only show error-related paths in the analysis graph">; -def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">, - HelpText<"Display exploded graph using GraphViz">; -def analyzer_dump_egraph : Separate<["-"], "analyzer-dump-egraph">, - HelpText<"Dump exploded graph to the specified file">; -def analyzer_dump_egraph_EQ : Joined<["-"], "analyzer-dump-egraph=">, Alias; - -def analyzer_inline_max_stack_depth : Separate<["-"], "analyzer-inline-max-stack-depth">, - HelpText<"Bound on stack depth while inlining (4 by default)">; -def analyzer_inline_max_stack_depth_EQ : Joined<["-"], "analyzer-inline-max-stack-depth=">, - Alias; - -def analyzer_inlining_mode : Separate<["-"], "analyzer-inlining-mode">, - HelpText<"Specify the function selection heuristic used during inlining">; -def analyzer_inlining_mode_EQ : Joined<["-"], "analyzer-inlining-mode=">, Alias; - -def analyzer_disable_retry_exhausted : Flag<["-"], "analyzer-disable-retry-exhausted">, - HelpText<"Do not re-analyze paths leading to exhausted nodes with a diff erent strategy (may decrease code coverage)">; - -def analyzer_max_loop : Separate<["-"], "analyzer-max-loop">, - HelpText<"The maximum number of times the analyzer will go through a loop">; -def analyzer_stats : Flag<["-"], "analyzer-stats">, - HelpText<"Print internal analyzer statistics.">; - -def analyzer_checker : Separate<["-"], "analyzer-checker">, - HelpText<"Choose analyzer checkers to enable">, - ValuesCode<[{ - const char *Values = - #define GET_CHECKERS - #define CHECKER(FULLNAME, CLASS, HT, DOC_URI, IS_HIDDEN) FULLNAME "," - #include "clang/StaticAnalyzer/Checkers/Checkers.inc" - #undef GET_CHECKERS - #define GET_PACKAGES - #define PACKAGE(FULLNAME) FULLNAME "," - #include "clang/StaticAnalyzer/Checkers/Checkers.inc" - #undef GET_PACKAGES - ; - }]>; -def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">, - Alias; - -def analyzer_disable_checker : Separate<["-"], "analyzer-disable-checker">, - HelpText<"Choose analyzer checkers to disable">; -def analyzer_disable_checker_EQ : Joined<["-"], "analyzer-disable-checker=">, - Alias; - -def analyzer_disable_all_checks : Flag<["-"], "analyzer-disable-all-checks">, - HelpText<"Disable all static analyzer checks">; - -def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">, - HelpText<"Display the list of analyzer checkers that are available">; - -def analyzer_checker_help_alpha : Flag<["-"], "analyzer-checker-help-alpha">, - HelpText<"Display the list of in development analyzer checkers. These " - "are NOT considered safe, they are unstable and will emit incorrect " - "reports. Enable ONLY FOR DEVELOPMENT purposes">; - -def analyzer_checker_help_developer : Flag<["-"], "analyzer-checker-help-developer">, - HelpText<"Display the list of developer-only checkers such as modeling " - "and debug checkers">; - -def analyzer_config_help : Flag<["-"], "analyzer-config-help">, - HelpText<"Display the list of -analyzer-config options. These are meant for " - "development purposes only!">; - -def analyzer_list_enabled_checkers : Flag<["-"], "analyzer-list-enabled-checkers">, - HelpText<"Display the list of enabled analyzer checkers">; - -def analyzer_config : Separate<["-"], "analyzer-config">, - HelpText<"Choose analyzer options to enable">; - -def analyzer_checker_option_help : Flag<["-"], "analyzer-checker-option-help">, - HelpText<"Display the list of checker and package options">; - -def analyzer_checker_option_help_alpha : Flag<["-"], "analyzer-checker-option-help-alpha">, - HelpText<"Display the list of in development checker and package options. " - "These are NOT considered safe, they are unstable and will emit " - "incorrect reports. Enable ONLY FOR DEVELOPMENT purposes">; - -def analyzer_checker_option_help_developer : Flag<["-"], "analyzer-checker-option-help-developer">, - HelpText<"Display the list of checker and package options meant for " - "development purposes only">; - -def analyzer_config_compatibility_mode : Separate<["-"], "analyzer-config-compatibility-mode">, - HelpText<"Don't emit errors on invalid analyzer-config inputs">; - -def analyzer_config_compatibility_mode_EQ : Joined<["-"], "analyzer-config-compatibility-mode=">, - Alias; - -def analyzer_werror : Flag<["-"], "analyzer-werror">, - HelpText<"Emit analyzer results as errors rather than warnings">; - -//===----------------------------------------------------------------------===// -// Migrator Options -//===----------------------------------------------------------------------===// -def migrator_no_nsalloc_error : Flag<["-"], "no-ns-alloc-error">, - HelpText<"Do not error on use of NSAllocateCollectable/NSReallocateCollectable">; - -def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">, - HelpText<"Do not remove finalize method in gc mode">; - -//===----------------------------------------------------------------------===// -// CodeGen Options -//===----------------------------------------------------------------------===// - -let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { -def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">; -def debug_info_macro : Flag<["-"], "debug-info-macro">, - HelpText<"Emit macro debug information">; -def default_function_attr : Separate<["-"], "default-function-attr">, - HelpText<"Apply given attribute to all functions">; -def dwarf_version_EQ : Joined<["-"], "dwarf-version=">; -def debugger_tuning_EQ : Joined<["-"], "debugger-tuning=">; -def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">, - HelpText<"The string to embed in the Dwarf debug flags record.">; -def record_command_line : Separate<["-"], "record-command-line">, - HelpText<"The string to embed in the .LLVM.command.line section.">; -def compress_debug_sections : Flag<["-", "--"], "compress-debug-sections">, - HelpText<"DWARF debug sections compression">; -def compress_debug_sections_EQ : Joined<["-", "--"], "compress-debug-sections=">, - HelpText<"DWARF debug sections compression type">; -def mno_exec_stack : Flag<["-"], "mnoexecstack">, - HelpText<"Mark the file as not needing an executable stack">; -def massembler_no_warn : Flag<["-"], "massembler-no-warn">, - HelpText<"Make assembler not emit warnings">; -def massembler_fatal_warnings : Flag<["-"], "massembler-fatal-warnings">, - HelpText<"Make assembler warnings fatal">; -def mrelax_relocations : Flag<["--"], "mrelax-relocations">, - HelpText<"Use relaxable elf relocations">; -def msave_temp_labels : Flag<["-"], "msave-temp-labels">, - HelpText<"Save temporary labels in the symbol table. " - "Note this may change .s semantics and shouldn't generally be used " - "on compiler-generated code.">; -def mrelocation_model : Separate<["-"], "mrelocation-model">, - HelpText<"The relocation model to use">, Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">, - NormalizedValuesScope<"llvm::Reloc">, - NormalizedValues<["Static", "PIC_", "ROPI", "RWPI", "ROPI_RWPI", "DynamicNoPIC"]>, - MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_", "Model">, - AutoNormalizeEnum; -def fno_math_builtin : Flag<["-"], "fno-math-builtin">, - HelpText<"Disable implicit builtin knowledge of math functions">; -} - -def disable_llvm_verifier : Flag<["-"], "disable-llvm-verifier">, - HelpText<"Don't run the LLVM IR verifier pass">; -def disable_llvm_passes : Flag<["-"], "disable-llvm-passes">, - HelpText<"Use together with -emit-llvm to get pristine LLVM IR from the " - "frontend by not running any LLVM passes at all">; -def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">, - Alias; -def disable_lifetimemarkers : Flag<["-"], "disable-lifetime-markers">, - HelpText<"Disable lifetime-markers emission even when optimizations are " - "enabled">; -def disable_O0_optnone : Flag<["-"], "disable-O0-optnone">, - HelpText<"Disable adding the optnone attribute to functions at O0">; -def disable_red_zone : Flag<["-"], "disable-red-zone">, - HelpText<"Do not emit code that uses the red zone.">; -def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">, - HelpText<"Generate debug info with external references to clang modules" - " or precompiled headers">; -def dwarf_explicit_import : Flag<["-"], "dwarf-explicit-import">, - HelpText<"Generate explicit import from anonymous namespace to containing" - " scope">; -def debug_forward_template_params : Flag<["-"], "debug-forward-template-params">, - HelpText<"Emit complete descriptions of template parameters in forward" - " declarations">; -def fforbid_guard_variables : Flag<["-"], "fforbid-guard-variables">, - HelpText<"Emit an error if a C++ static local initializer would need a guard variable">; -def no_implicit_float : Flag<["-"], "no-implicit-float">, - HelpText<"Don't generate implicit floating point instructions">; -def fdump_vtable_layouts : Flag<["-"], "fdump-vtable-layouts">, - HelpText<"Dump the layouts of all vtables that will be emitted in a translation unit">; -def fmerge_functions : Flag<["-"], "fmerge-functions">, - HelpText<"Permit merging of identical functions when optimizing.">; -def femit_coverage_notes : Flag<["-"], "femit-coverage-notes">, - HelpText<"Emit a gcov coverage notes file when compiling.">; -def femit_coverage_data: Flag<["-"], "femit-coverage-data">, - HelpText<"Instrument the program to emit gcov coverage data when run.">; -def coverage_data_file : Separate<["-"], "coverage-data-file">, - HelpText<"Emit coverage data to this filename.">; -def coverage_data_file_EQ : Joined<["-"], "coverage-data-file=">, - Alias; -def coverage_notes_file : Separate<["-"], "coverage-notes-file">, - HelpText<"Emit coverage notes to this filename.">; -def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">, - Alias; -def coverage_version_EQ : Joined<["-"], "coverage-version=">, - HelpText<"Four-byte version string for gcov files.">; -def test_coverage : Flag<["-"], "test-coverage">, - HelpText<"Do not generate coverage files or remove coverage changes from IR">; -def dump_coverage_mapping : Flag<["-"], "dump-coverage-mapping">, - HelpText<"Dump the coverage mapping records, for testing">; -def fuse_register_sized_bitfield_access: Flag<["-"], "fuse-register-sized-bitfield-access">, - HelpText<"Use register sized accesses to bit-fields, when possible.">; -def relaxed_aliasing : Flag<["-"], "relaxed-aliasing">, - HelpText<"Turn off Type Based Alias Analysis">; -def no_struct_path_tbaa : Flag<["-"], "no-struct-path-tbaa">, - HelpText<"Turn off struct-path aware Type Based Alias Analysis">; -def new_struct_path_tbaa : Flag<["-"], "new-struct-path-tbaa">, - HelpText<"Enable enhanced struct-path aware Type Based Alias Analysis">; -def mdebug_pass : Separate<["-"], "mdebug-pass">, - HelpText<"Enable additional debug output">; -def mframe_pointer_EQ : Joined<["-"], "mframe-pointer=">, - HelpText<"Specify which frame pointers to retain (all, non-leaf, none).">, Values<"all,non-leaf,none">; -def mdisable_tail_calls : Flag<["-"], "mdisable-tail-calls">, - HelpText<"Disable tail call optimization, keeping the call stack accurate">; -def menable_no_infinities : Flag<["-"], "menable-no-infs">, - HelpText<"Allow optimization to assume there are no infinities.">; -def menable_no_nans : Flag<["-"], "menable-no-nans">, - HelpText<"Allow optimization to assume there are no NaNs.">; -def menable_unsafe_fp_math : Flag<["-"], "menable-unsafe-fp-math">, - HelpText<"Allow unsafe floating-point math optimizations which may decrease " - "precision">; -def mreassociate : Flag<["-"], "mreassociate">, - HelpText<"Allow reassociation transformations for floating-point instructions">; -def mabi_EQ_ieeelongdouble : Flag<["-"], "mabi=ieeelongdouble">, - HelpText<"Use IEEE 754 quadruple-precision for long double">; -def mfloat_abi : Separate<["-"], "mfloat-abi">, - HelpText<"The float ABI to use">; -def mtp : Separate<["-"], "mtp">, - HelpText<"Mode for reading thread pointer">; -def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, - HelpText<"Limit float precision to the given value">; -def split_stacks : Flag<["-"], "split-stacks">, - HelpText<"Try to use a split stack if possible.">; -def mregparm : Separate<["-"], "mregparm">, - HelpText<"Limit the number of registers available for integer arguments">; -def msmall_data_limit : Separate<["-"], "msmall-data-limit">, - HelpText<"Put global and static data smaller than the limit into a special section">; -def munwind_tables : Flag<["-"], "munwind-tables">, - HelpText<"Generate unwinding tables for all functions">; -def mconstructor_aliases : Flag<["-"], "mconstructor-aliases">, - HelpText<"Emit complete constructors and destructors as aliases when possible">; -def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">, - HelpText<"Link the given bitcode file before performing optimizations.">; -def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">, - HelpText<"Link and internalize needed symbols from the given bitcode file " - "before performing optimizations.">; -def mlink_cuda_bitcode : Separate<["-"], "mlink-cuda-bitcode">, - Alias; -def vectorize_loops : Flag<["-"], "vectorize-loops">, - HelpText<"Run the Loop vectorization passes">; -def vectorize_slp : Flag<["-"], "vectorize-slp">, - HelpText<"Run the SLP vectorization passes">; -def dependent_lib : Joined<["--"], "dependent-lib=">, - HelpText<"Add dependent library">; -def linker_option : Joined<["--"], "linker-option=">, - HelpText<"Add linker option">; -def fsanitize_coverage_type : Joined<["-"], "fsanitize-coverage-type=">, - HelpText<"Sanitizer coverage type">; -def fsanitize_coverage_indirect_calls - : Flag<["-"], "fsanitize-coverage-indirect-calls">, - HelpText<"Enable sanitizer coverage for indirect calls">; -def fsanitize_coverage_trace_bb - : Flag<["-"], "fsanitize-coverage-trace-bb">, - HelpText<"Enable basic block tracing in sanitizer coverage">; -def fsanitize_coverage_trace_cmp - : Flag<["-"], "fsanitize-coverage-trace-cmp">, - HelpText<"Enable cmp instruction tracing in sanitizer coverage">; -def fsanitize_coverage_trace_div - : Flag<["-"], "fsanitize-coverage-trace-div">, - HelpText<"Enable div instruction tracing in sanitizer coverage">; -def fsanitize_coverage_trace_gep - : Flag<["-"], "fsanitize-coverage-trace-gep">, - HelpText<"Enable gep instruction tracing in sanitizer coverage">; -def fsanitize_coverage_8bit_counters - : Flag<["-"], "fsanitize-coverage-8bit-counters">, - HelpText<"Enable frequency counters in sanitizer coverage">; -def fsanitize_coverage_inline_8bit_counters - : Flag<["-"], "fsanitize-coverage-inline-8bit-counters">, - HelpText<"Enable inline 8-bit counters in sanitizer coverage">; -def fsanitize_coverage_inline_bool_flag - : Flag<["-"], "fsanitize-coverage-inline-bool-flag">, - HelpText<"Enable inline bool flag in sanitizer coverage">; -def fsanitize_coverage_pc_table - : Flag<["-"], "fsanitize-coverage-pc-table">, - HelpText<"Create a table of coverage-instrumented PCs">; -def fsanitize_coverage_trace_pc - : Flag<["-"], "fsanitize-coverage-trace-pc">, - HelpText<"Enable PC tracing in sanitizer coverage">; -def fsanitize_coverage_trace_pc_guard - : Flag<["-"], "fsanitize-coverage-trace-pc-guard">, - HelpText<"Enable PC tracing with guard in sanitizer coverage">; -def fsanitize_coverage_no_prune - : Flag<["-"], "fsanitize-coverage-no-prune">, - HelpText<"Disable coverage pruning (i.e. instrument all blocks/edges)">; -def fsanitize_coverage_stack_depth - : Flag<["-"], "fsanitize-coverage-stack-depth">, - HelpText<"Enable max stack depth tracing">; -def fpatchable_function_entry_offset_EQ - : Joined<["-"], "fpatchable-function-entry-offset=">, MetaVarName<"">, - HelpText<"Generate M NOPs before function entry">; -def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">, - HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, " - "or none">, Values<"none,clang,llvm">; -def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">, - HelpText<"Generate instrumented code to collect execution counts into " - " (overridden by LLVM_PROFILE_FILE env var)">; -def fprofile_instrument_use_path_EQ : - Joined<["-"], "fprofile-instrument-use-path=">, - HelpText<"Specify the profile path in PGO use compilation">; -def flto_visibility_public_std: - Flag<["-"], "flto-visibility-public-std">, - HelpText<"Use public LTO visibility for classes in std and stdext namespaces">; -def flto_unit: Flag<["-"], "flto-unit">, - HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable opt)">; -def fno_lto_unit: Flag<["-"], "fno-lto-unit">; -def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">, - HelpText<"Prints debug information for the new pass manager">; -def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">, - HelpText<"Disables debug printing for the new pass manager">; -// The driver option takes the key as a parameter to the -msign-return-address= -// and -mbranch-protection= options, but CC1 has a separate option so we -// don't have to parse the parameter twice. -def msign_return_address_key_EQ : Joined<["-"], "msign-return-address-key=">, - Values<"a_key,b_key">; -def mbranch_target_enforce : Flag<["-"], "mbranch-target-enforce">; -def fno_dllexport_inlines : Flag<["-"], "fno-dllexport-inlines">; -def cfguard_no_checks : Flag<["-"], "cfguard-no-checks">, - HelpText<"Emit Windows Control Flow Guard tables only (no checks)">; -def cfguard : Flag<["-"], "cfguard">, - HelpText<"Emit Windows Control Flow Guard tables and checks">; - -def fdenormal_fp_math_f32_EQ : Joined<["-"], "fdenormal-fp-math-f32=">, - Group; - -//===----------------------------------------------------------------------===// -// Dependency Output Options -//===----------------------------------------------------------------------===// - -def sys_header_deps : Flag<["-"], "sys-header-deps">, - HelpText<"Include system headers in dependency output">; -def module_file_deps : Flag<["-"], "module-file-deps">, - HelpText<"Include module files in dependency output">; -def header_include_file : Separate<["-"], "header-include-file">, - HelpText<"Filename (or -) to write header include output to">; -def show_includes : Flag<["--"], "show-includes">, - HelpText<"Print cl.exe style /showIncludes to stdout">; - -//===----------------------------------------------------------------------===// -// Diagnostic Options -//===----------------------------------------------------------------------===// - -def diagnostic_log_file : Separate<["-"], "diagnostic-log-file">, - HelpText<"Filename (or -) to log diagnostics to">; -def diagnostic_serialized_file : Separate<["-"], "serialize-diagnostic-file">, - MetaVarName<"">, - HelpText<"File for serializing diagnostics in a binary format">; - -def fdiagnostics_format : Separate<["-"], "fdiagnostics-format">, - HelpText<"Change diagnostic formatting to match IDE and command line tools">, Values<"clang,msvc,msvc-fallback,vi">; -def fdiagnostics_show_category : Separate<["-"], "fdiagnostics-show-category">, - HelpText<"Print diagnostic category">, Values<"none,id,name">; -def fno_diagnostics_use_presumed_location : Flag<["-"], "fno-diagnostics-use-presumed-location">, - HelpText<"Ignore #line directives when displaying diagnostic locations">; -def ftabstop : Separate<["-"], "ftabstop">, MetaVarName<"">, - HelpText<"Set the tab stop distance.">; -def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"">, - HelpText<"Set the maximum number of errors to emit before stopping (0 = no limit).">; -def fmacro_backtrace_limit : Separate<["-"], "fmacro-backtrace-limit">, MetaVarName<"">, - HelpText<"Set the maximum number of entries to print in a macro expansion backtrace (0 = no limit).">; -def ftemplate_backtrace_limit : Separate<["-"], "ftemplate-backtrace-limit">, MetaVarName<"">, - HelpText<"Set the maximum number of entries to print in a template instantiation backtrace (0 = no limit).">; -def fconstexpr_backtrace_limit : Separate<["-"], "fconstexpr-backtrace-limit">, MetaVarName<"">, - HelpText<"Set the maximum number of entries to print in a constexpr evaluation backtrace (0 = no limit).">; -def fspell_checking_limit : Separate<["-"], "fspell-checking-limit">, MetaVarName<"">, - HelpText<"Set the maximum number of times to perform spell checking on unrecognized identifiers (0 = no limit).">; -def fcaret_diagnostics_max_lines : - Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"">, - HelpText<"Set the maximum number of source lines to show in a caret diagnostic">; -def verify_EQ : CommaJoined<["-"], "verify=">, - MetaVarName<"">, - HelpText<"Verify diagnostic output using comment directives that start with" - " prefixes in the comma-separated sequence ">; -def verify : Flag<["-"], "verify">, - HelpText<"Equivalent to -verify=expected">; -def verify_ignore_unexpected : Flag<["-"], "verify-ignore-unexpected">, - HelpText<"Ignore unexpected diagnostic messages">; -def verify_ignore_unexpected_EQ : CommaJoined<["-"], "verify-ignore-unexpected=">, - HelpText<"Ignore unexpected diagnostic messages">; -def Wno_rewrite_macros : Flag<["-"], "Wno-rewrite-macros">, - HelpText<"Silence ObjC rewriting warnings">; - -//===----------------------------------------------------------------------===// -// Frontend Options -//===----------------------------------------------------------------------===// - -// This isn't normally used, it is just here so we can parse a -// CompilerInvocation out of a driver-derived argument vector. -def cc1 : Flag<["-"], "cc1">; -def cc1as : Flag<["-"], "cc1as">; - -def ast_merge : Separate<["-"], "ast-merge">, - MetaVarName<"">, - HelpText<"Merge the given AST file into the translation unit being compiled.">; -def aux_target_cpu : Separate<["-"], "aux-target-cpu">, - HelpText<"Target a specific auxiliary cpu type">; -def aux_target_feature : Separate<["-"], "aux-target-feature">, - HelpText<"Target specific auxiliary attributes">; -def aux_triple : Separate<["-"], "aux-triple">, - HelpText<"Auxiliary target triple.">; -def code_completion_at : Separate<["-"], "code-completion-at">, - MetaVarName<"::">, - HelpText<"Dump code-completion information at a location">; -def remap_file : Separate<["-"], "remap-file">, - MetaVarName<";">, - HelpText<"Replace the contents of the file with the contents of the file">; -def code_completion_at_EQ : Joined<["-"], "code-completion-at=">, - Alias; -def code_completion_macros : Flag<["-"], "code-completion-macros">, - HelpText<"Include macros in code-completion results">; -def code_completion_patterns : Flag<["-"], "code-completion-patterns">, - HelpText<"Include code patterns in code-completion results">; -def no_code_completion_globals : Flag<["-"], "no-code-completion-globals">, - HelpText<"Do not include global declarations in code-completion results.">; -def no_code_completion_ns_level_decls : Flag<["-"], "no-code-completion-ns-level-decls">, - HelpText<"Do not include declarations inside namespaces (incl. global namespace) in the code-completion results.">; -def code_completion_brief_comments : Flag<["-"], "code-completion-brief-comments">, - HelpText<"Include brief documentation comments in code-completion results.">; -def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">, - HelpText<"Include code completion results which require small fix-its.">; -def disable_free : Flag<["-"], "disable-free">, - HelpText<"Disable freeing of memory on exit">; -def discard_value_names : Flag<["-"], "discard-value-names">, - HelpText<"Discard value names in LLVM IR">; -def load : Separate<["-"], "load">, MetaVarName<"">, - HelpText<"Load the named plugin (dynamic shared object)">; -def plugin : Separate<["-"], "plugin">, MetaVarName<"">, - HelpText<"Use the named plugin action instead of the default action (use \"help\" to list available options)">; -def plugin_arg : JoinedAndSeparate<["-"], "plugin-arg-">, - MetaVarName<" ">, - HelpText<"Pass to plugin ">; -def add_plugin : Separate<["-"], "add-plugin">, MetaVarName<"">, - HelpText<"Use the named plugin action in addition to the default action">; -def ast_dump_filter : Separate<["-"], "ast-dump-filter">, - MetaVarName<"">, - HelpText<"Use with -ast-dump or -ast-print to dump/print only AST declaration" - " nodes having a certain substring in a qualified name. Use" - " -ast-list to list all filterable declaration node names.">; -def fno_modules_global_index : Flag<["-"], "fno-modules-global-index">, - HelpText<"Do not automatically generate or update the global module index">; -def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">, - HelpText<"Do not automatically import modules for error recovery">; -def fmodule_map_file_home_is_cwd : Flag<["-"], "fmodule-map-file-home-is-cwd">, - HelpText<"Use the current working directory as the home directory of " - "module maps specified by -fmodule-map-file=">; -def fmodule_feature : Separate<["-"], "fmodule-feature">, - MetaVarName<"">, - HelpText<"Enable in module map requires declarations">; -def fmodules_embed_file_EQ : Joined<["-"], "fmodules-embed-file=">, - MetaVarName<"">, - HelpText<"Embed the contents of the specified file into the module file " - "being compiled.">; -def fmodules_embed_all_files : Joined<["-"], "fmodules-embed-all-files">, - HelpText<"Embed the contents of all files read by this compilation into " - "the produced module file.">; -def fmodules_local_submodule_visibility : - Flag<["-"], "fmodules-local-submodule-visibility">, - HelpText<"Enforce name visibility rules across submodules of the same " - "top-level module.">; -def fmodules_codegen : - Flag<["-"], "fmodules-codegen">, - HelpText<"Generate code for uses of this module that assumes an explicit " - "object file will be built for the module">; -def fmodules_debuginfo : - Flag<["-"], "fmodules-debuginfo">, - HelpText<"Generate debug info for types in an object file built from this " - "module and do not generate them elsewhere">; -def fmodule_format_EQ : Joined<["-"], "fmodule-format=">, - HelpText<"Select the container format for clang modules and PCH. " - "Supported options are 'raw' and 'obj'.">; -def ftest_module_file_extension_EQ : - Joined<["-"], "ftest-module-file-extension=">, - HelpText<"introduce a module file extension for testing purposes. " - "The argument is parsed as blockname:major:minor:hashed:user info">; -def fconcepts_ts : Flag<["-"], "fconcepts-ts">, - HelpText<"Enable C++ Extensions for Concepts. (deprecated - use -std=c++2a)">; -def fno_concept_satisfaction_caching : Flag<["-"], - "fno-concept-satisfaction-caching">, - HelpText<"Disable satisfaction caching for C++2a Concepts.">; - -def frecovery_ast : Flag<["-"], "frecovery-ast">, - HelpText<"Preserve expressions in AST rather than dropping them when " - "encountering semantic errors">; -def fno_recovery_ast : Flag<["-"], "fno-recovery-ast">; -def frecovery_ast_type : Flag<["-"], "frecovery-ast-type">, - HelpText<"Preserve the type for recovery expressions when possible " - "(experimental)">; -def fno_recovery_ast_type : Flag<["-"], "fno-recovery-ast-type">; - -let Group = Action_Group in { - -def Eonly : Flag<["-"], "Eonly">, - HelpText<"Just run preprocessor, no output (for timings)">; -def dump_raw_tokens : Flag<["-"], "dump-raw-tokens">, - HelpText<"Lex file in raw mode and dump raw tokens">; -def analyze : Flag<["-"], "analyze">, - HelpText<"Run static analysis engine">; -def dump_tokens : Flag<["-"], "dump-tokens">, - HelpText<"Run preprocessor, dump internal rep of tokens">; -def init_only : Flag<["-"], "init-only">, - HelpText<"Only execute frontend initialization">; -def fixit : Flag<["-"], "fixit">, - HelpText<"Apply fix-it advice to the input source">; -def fixit_EQ : Joined<["-"], "fixit=">, - HelpText<"Apply fix-it advice creating a file with the given suffix">; -def print_preamble : Flag<["-"], "print-preamble">, - HelpText<"Print the \"preamble\" of a file, which is a candidate for implicit" - " precompiled headers.">; -def emit_html : Flag<["-"], "emit-html">, - HelpText<"Output input source as HTML">; -def ast_print : Flag<["-"], "ast-print">, - HelpText<"Build ASTs and then pretty-print them">; -def ast_list : Flag<["-"], "ast-list">, - HelpText<"Build ASTs and print the list of declaration node qualified names">; -def ast_dump : Flag<["-"], "ast-dump">, - HelpText<"Build ASTs and then debug dump them">; -def ast_dump_EQ : Joined<["-"], "ast-dump=">, - HelpText<"Build ASTs and then debug dump them in the specified format. " - "Supported formats include: default, json">; -def ast_dump_all : Flag<["-"], "ast-dump-all">, - HelpText<"Build ASTs and then debug dump them, forcing deserialization">; -def ast_dump_all_EQ : Joined<["-"], "ast-dump-all=">, - HelpText<"Build ASTs and then debug dump them in the specified format, " - "forcing deserialization. Supported formats include: default, json">; -def ast_dump_decl_types : Flag<["-"], "ast-dump-decl-types">, - HelpText<"Include declaration types in AST dumps">; -def templight_dump : Flag<["-"], "templight-dump">, - HelpText<"Dump templight information to stdout">; -def ast_dump_lookups : Flag<["-"], "ast-dump-lookups">, - HelpText<"Build ASTs and then debug dump their name lookup tables">; -def ast_view : Flag<["-"], "ast-view">, - HelpText<"Build ASTs and view them with GraphViz">; -def emit_module : Flag<["-"], "emit-module">, - HelpText<"Generate pre-compiled module file from a module map">; -def emit_module_interface : Flag<["-"], "emit-module-interface">, - HelpText<"Generate pre-compiled module file from a C++ module interface">; -def emit_header_module : Flag<["-"], "emit-header-module">, - HelpText<"Generate pre-compiled module file from a set of header files">; -def emit_pch : Flag<["-"], "emit-pch">, - HelpText<"Generate pre-compiled header file">; -def emit_llvm_bc : Flag<["-"], "emit-llvm-bc">, - HelpText<"Build ASTs then convert to LLVM, emit .bc file">; -def emit_llvm_only : Flag<["-"], "emit-llvm-only">, - HelpText<"Build ASTs and convert to LLVM, discarding output">; -def emit_codegen_only : Flag<["-"], "emit-codegen-only">, - HelpText<"Generate machine code, but discard output">; -def emit_obj : Flag<["-"], "emit-obj">, - HelpText<"Emit native object files">; -def rewrite_test : Flag<["-"], "rewrite-test">, - HelpText<"Rewriter playground">; -def rewrite_macros : Flag<["-"], "rewrite-macros">, - HelpText<"Expand macros without full preprocessing">; -def migrate : Flag<["-"], "migrate">, - HelpText<"Migrate source code">; -def compiler_options_dump : Flag<["-"], "compiler-options-dump">, - HelpText<"Dump the compiler configuration options">; -def print_dependency_directives_minimized_source : Flag<["-"], - "print-dependency-directives-minimized-source">, - HelpText<"Print the output of the dependency directives source minimizer">; -} - -def emit_llvm_uselists : Flag<["-"], "emit-llvm-uselists">, - HelpText<"Preserve order of LLVM use-lists when serializing">; -def no_emit_llvm_uselists : Flag<["-"], "no-emit-llvm-uselists">, - HelpText<"Don't preserve order of LLVM use-lists when serializing">; - -def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">, - HelpText<"Directory for temporary files produced during ARC or ObjC migration">; -def arcmt_check : Flag<["-"], "arcmt-check">, - HelpText<"Check for ARC migration issues that need manual handling">; -def arcmt_modify : Flag<["-"], "arcmt-modify">, - HelpText<"Apply modifications to files to conform to ARC">; -def arcmt_migrate : Flag<["-"], "arcmt-migrate">, - HelpText<"Apply modifications and produces temporary files that conform to ARC">; - -def opt_record_file : Separate<["-"], "opt-record-file">, - HelpText<"File name to use for YAML optimization record output">; -def opt_record_passes : Separate<["-"], "opt-record-passes">, - HelpText<"Only record remark information for passes whose names match the given regular expression">; -def opt_record_format : Separate<["-"], "opt-record-format">, - HelpText<"The format used for serializing remarks (default: YAML)">; - -def print_stats : Flag<["-"], "print-stats">, - HelpText<"Print performance metrics and statistics">; -def stats_file : Joined<["-"], "stats-file=">, - HelpText<"Filename to write statistics to">; -def fdump_record_layouts : Flag<["-"], "fdump-record-layouts">, - HelpText<"Dump record layout information">; -def fdump_record_layouts_simple : Flag<["-"], "fdump-record-layouts-simple">, - HelpText<"Dump record layout information in a simple form used for testing">; -def fix_what_you_can : Flag<["-"], "fix-what-you-can">, - HelpText<"Apply fix-it advice even in the presence of unfixable errors">; -def fix_only_warnings : Flag<["-"], "fix-only-warnings">, - HelpText<"Apply fix-it advice only for warnings, not errors">; -def fixit_recompile : Flag<["-"], "fixit-recompile">, - HelpText<"Apply fix-it changes and recompile">; -def fixit_to_temp : Flag<["-"], "fixit-to-temporary">, - HelpText<"Apply fix-it changes to temporary files">; - -def foverride_record_layout_EQ : Joined<["-"], "foverride-record-layout=">, - HelpText<"Override record layouts with those in the given file">; -def pch_through_header_EQ : Joined<["-"], "pch-through-header=">, - HelpText<"Stop PCH generation after including this file. When using a PCH, " - "skip tokens until after this file is included.">; -def pch_through_hdrstop_create : Flag<["-"], "pch-through-hdrstop-create">, - HelpText<"When creating a PCH, stop PCH generation after #pragma hdrstop.">; -def pch_through_hdrstop_use : Flag<["-"], "pch-through-hdrstop-use">, - HelpText<"When using a PCH, skip tokens until after a #pragma hdrstop.">; -def fno_pch_timestamp : Flag<["-"], "fno-pch-timestamp">, - HelpText<"Disable inclusion of timestamp in precompiled headers">; -def building_pch_with_obj : Flag<["-"], "building-pch-with-obj">, - HelpText<"This compilation is part of building a PCH with corresponding object file.">; - -def aligned_alloc_unavailable : Flag<["-"], "faligned-alloc-unavailable">, - HelpText<"Aligned allocation/deallocation functions are unavailable">; - -//===----------------------------------------------------------------------===// -// Language Options -//===----------------------------------------------------------------------===// - -let Flags = [CC1Option, CC1AsOption, NoDriverOption] in { - -def version : Flag<["-"], "version">, - HelpText<"Print the compiler version">; -def main_file_name : Separate<["-"], "main-file-name">, - HelpText<"Main file name to use for debug info and source if missing">; -def split_dwarf_output : Separate<["-"], "split-dwarf-output">, - HelpText<"File name to use for split dwarf debug info output">; - -} - -def fblocks_runtime_optional : Flag<["-"], "fblocks-runtime-optional">, - HelpText<"Weakly link in the blocks runtime">; -def fexternc_nounwind : Flag<["-"], "fexternc-nounwind">, - HelpText<"Assume all functions with C linkage do not unwind">; -def split_dwarf_file : Separate<["-"], "split-dwarf-file">, - HelpText<"Name of the split dwarf debug info file to encode in the object file">; -def fno_wchar : Flag<["-"], "fno-wchar">, - HelpText<"Disable C++ builtin type wchar_t">; -def fconstant_string_class : Separate<["-"], "fconstant-string-class">, - MetaVarName<"">, - HelpText<"Specify the class to use for constant Objective-C string objects.">; -def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, - HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">; -def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, - HelpText<"The target Objective-C runtime supports ARC weak operations">; -def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">, - HelpText<"Objective-C dispatch method to use">, Values<"legacy,non-legacy,mixed">; -def disable_objc_default_synthesize_properties : Flag<["-"], "disable-objc-default-synthesize-properties">, - HelpText<"disable the default synthesis of Objective-C properties">; -def fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signature">, - HelpText<"enable extended encoding of block type signature">; -def function_alignment : Separate<["-"], "function-alignment">, - HelpText<"default alignment for functions">; -def pic_level : Separate<["-"], "pic-level">, - HelpText<"Value for __PIC__">; -def pic_is_pie : Flag<["-"], "pic-is-pie">, - HelpText<"File is for a position independent executable">; -def fno_validate_pch : Flag<["-"], "fno-validate-pch">, - HelpText<"Disable validation of precompiled headers">; -def fallow_pch_with_errors : Flag<["-"], "fallow-pch-with-compiler-errors">, - HelpText<"Accept a PCH file that was created with compiler errors">; -def dump_deserialized_pch_decls : Flag<["-"], "dump-deserialized-decls">, - HelpText<"Dump declarations that are deserialized from PCH, for testing">; -def error_on_deserialized_pch_decl : Separate<["-"], "error-on-deserialized-decl">, - HelpText<"Emit error if a specific declaration is deserialized from PCH, for testing">; -def error_on_deserialized_pch_decl_EQ : Joined<["-"], "error-on-deserialized-decl=">, - Alias; -def static_define : Flag<["-"], "static-define">, - HelpText<"Should __STATIC__ be defined">; -def stack_protector : Separate<["-"], "stack-protector">, - HelpText<"Enable stack protectors">; -def stack_protector_buffer_size : Separate<["-"], "stack-protector-buffer-size">, - HelpText<"Lower bound for a buffer to be considered for stack protection">; -def fvisibility : Separate<["-"], "fvisibility">, - HelpText<"Default type and symbol visibility">; -def ftype_visibility : Separate<["-"], "ftype-visibility">, - HelpText<"Default type visibility">; -def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility-to-externs">, - HelpText<"Apply global symbol visibility to external declarations without an explicit visibility">; -def ftemplate_depth : Separate<["-"], "ftemplate-depth">, - HelpText<"Maximum depth of recursive template instantiation">; -def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">, - HelpText<"Maximum number of 'operator->'s to call for a member access">; -def fconstexpr_depth : Separate<["-"], "fconstexpr-depth">, - HelpText<"Maximum depth of recursive constexpr function calls">; -def fconstexpr_steps : Separate<["-"], "fconstexpr-steps">, - HelpText<"Maximum number of steps in constexpr function evaluation">; -def fbracket_depth : Separate<["-"], "fbracket-depth">, - HelpText<"Maximum nesting level for parentheses, brackets, and braces">; -def fconst_strings : Flag<["-"], "fconst-strings">, - HelpText<"Use a const qualified type for string literals in C and ObjC">; -def fno_const_strings : Flag<["-"], "fno-const-strings">, - HelpText<"Don't use a const qualified type for string literals in C and ObjC">; -def fno_bitfield_type_align : Flag<["-"], "fno-bitfield-type-align">, - HelpText<"Ignore bit-field types when aligning structures">; -def ffake_address_space_map : Flag<["-"], "ffake-address-space-map">, - HelpText<"Use a fake address space map; OpenCL testing purposes only">; -def faddress_space_map_mangling_EQ : Joined<["-"], "faddress-space-map-mangling=">, MetaVarName<"">, - HelpText<"Set the mode for address space map based mangling; OpenCL testing purposes only">; -def funknown_anytype : Flag<["-"], "funknown-anytype">, - HelpText<"Enable parser support for the __unknown_anytype type; for testing purposes only">; -def fdebugger_support : Flag<["-"], "fdebugger-support">, - HelpText<"Enable special debugger support behavior">; -def fdebugger_cast_result_to_id : Flag<["-"], "fdebugger-cast-result-to-id">, - HelpText<"Enable casting unknown expression results to id">; -def fdebugger_objc_literal : Flag<["-"], "fdebugger-objc-literal">, - HelpText<"Enable special debugger support for Objective-C subscripting and literals">; -def fdeprecated_macro : Flag<["-"], "fdeprecated-macro">, - HelpText<"Defines the __DEPRECATED macro">; -def fno_deprecated_macro : Flag<["-"], "fno-deprecated-macro">, - HelpText<"Undefines the __DEPRECATED macro">; -def fobjc_subscripting_legacy_runtime : Flag<["-"], "fobjc-subscripting-legacy-runtime">, - HelpText<"Allow Objective-C array and dictionary subscripting in legacy runtime">; -def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">, - HelpText<"Control vtordisp placement on win32 targets">; -def fnative_half_type: Flag<["-"], "fnative-half-type">, - HelpText<"Use the native half type for __fp16 instead of promoting to float">; -def fnative_half_arguments_and_returns : Flag<["-"], "fnative-half-arguments-and-returns">, - HelpText<"Use the native __fp16 type for arguments and returns (and skip ABI-specific lowering)">; -def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, - HelpText<"Allow function arguments and returns of type half">; -def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, - HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">; -def finclude_default_header : Flag<["-"], "finclude-default-header">, - HelpText<"Include default header file for OpenCL">; -def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">, - HelpText<"Add OpenCL builtin function declarations (experimental)">; -def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">, - HelpText<"Preserve 3-component vector type">; -def fwchar_type_EQ : Joined<["-"], "fwchar-type=">, - HelpText<"Select underlying type for wchar_t">, Values<"char,short,int">; -def fsigned_wchar : Flag<["-"], "fsigned-wchar">, - HelpText<"Use a signed type for wchar_t">; -def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">, - HelpText<"Use an unsigned type for wchar_t">; -def fcompatibility_qualified_id_block_param_type_checking : Flag<["-"], "fcompatibility-qualified-id-block-type-checking">, - HelpText<"Allow using blocks with parameters of more specific type than " - "the type system guarantees when a parameter is qualified id">; - -// FIXME: Remove these entirely once functionality/tests have been excised. -def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group, - HelpText<"Use GC exclusively for Objective-C related memory management">; -def fobjc_gc : Flag<["-"], "fobjc-gc">, Group, - HelpText<"Enable Objective-C garbage collection">; - -//===----------------------------------------------------------------------===// -// Header Search Options -//===----------------------------------------------------------------------===// - -def nostdsysteminc : Flag<["-"], "nostdsysteminc">, - HelpText<"Disable standard system #include directories">; -def fdisable_module_hash : Flag<["-"], "fdisable-module-hash">, - HelpText<"Disable the module hash">; -def fmodules_hash_content : Flag<["-"], "fmodules-hash-content">, - HelpText<"Enable hashing the content of a module file">; -def fmodules_strict_context_hash : Flag<["-"], "fmodules-strict-context-hash">, - HelpText<"Enable hashing of all compiler options that could impact the " - "semantics of a module in an implicit build">, - MarshallingInfoFlag<"HeaderSearchOpts->ModulesStrictContextHash", "false">; -def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, MetaVarName<"">, - HelpText<"Add directory to the C SYSTEM include search path">; -def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">, - MetaVarName<"">, - HelpText<"Add directory to the ObjC SYSTEM include search path">; -def objcxx_isystem : JoinedOrSeparate<["-"], "objcxx-isystem">, - MetaVarName<"">, - HelpText<"Add directory to the ObjC++ SYSTEM include search path">; -def internal_isystem : JoinedOrSeparate<["-"], "internal-isystem">, - MetaVarName<"">, - HelpText<"Add directory to the internal system include search path; these " - "are assumed to not be user-provided and are used to model system " - "and standard headers' paths.">; -def internal_externc_isystem : JoinedOrSeparate<["-"], "internal-externc-isystem">, - MetaVarName<"">, - HelpText<"Add directory to the internal system include search path with " - "implicit extern \"C\" semantics; these are assumed to not be " - "user-provided and are used to model system and standard headers' " - "paths.">; - -//===----------------------------------------------------------------------===// -// Preprocessor Options -//===----------------------------------------------------------------------===// - -def chain_include : Separate<["-"], "chain-include">, MetaVarName<"">, - HelpText<"Include and chain a header file after turning it into PCH">; -def preamble_bytes_EQ : Joined<["-"], "preamble-bytes=">, - HelpText<"Assume that the precompiled header is a precompiled preamble " - "covering the first N bytes of the main file">; -def detailed_preprocessing_record : Flag<["-"], "detailed-preprocessing-record">, - HelpText<"include a detailed record of preprocessing actions">; -def setup_static_analyzer : Flag<["-"], "setup-static-analyzer">, - HelpText<"Set up preprocessor for static analyzer (done automatically when static analyzer is run).">; -def disable_pragma_debug_crash : Flag<["-"], "disable-pragma-debug-crash">, - HelpText<"Disable any #pragma clang __debug that can lead to crashing behavior. This is meant for testing.">; - -//===----------------------------------------------------------------------===// -// OpenCL Options -//===----------------------------------------------------------------------===// - -def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, - HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">; - -//===----------------------------------------------------------------------===// -// CUDA Options -//===----------------------------------------------------------------------===// - -def fcuda_is_device : Flag<["-"], "fcuda-is-device">, - HelpText<"Generate code for CUDA device">; -def fcuda_include_gpubinary : Separate<["-"], "fcuda-include-gpubinary">, - HelpText<"Incorporate CUDA device-side binary into host object file.">; -def fcuda_allow_variadic_functions : Flag<["-"], "fcuda-allow-variadic-functions">, - HelpText<"Allow variadic functions in CUDA device code.">; -def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr">, - HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">; - -//===----------------------------------------------------------------------===// -// OpenMP Options -//===----------------------------------------------------------------------===// - -def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">, - HelpText<"Generate code only for an OpenMP target device.">; -def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, - HelpText<"Path to the IR file produced by the frontend for the host.">; - -//===----------------------------------------------------------------------===// -// SYCL Options -//===----------------------------------------------------------------------===// - -def fsycl_is_device : Flag<["-"], "fsycl-is-device">, - HelpText<"Generate code for SYCL device.">; - -} // let Flags = [CC1Option] - -//===----------------------------------------------------------------------===// -// cc1as-only Options -//===----------------------------------------------------------------------===// - -let Flags = [CC1AsOption, NoDriverOption] in { - -// Language Options -def n : Flag<["-"], "n">, - HelpText<"Don't automatically start assembly file with a text section">; - -// Frontend Options -def filetype : Separate<["-"], "filetype">, - HelpText<"Specify the output file type ('asm', 'null', or 'obj')">; - -// Transliterate Options -def output_asm_variant : Separate<["-"], "output-asm-variant">, - HelpText<"Select the asm variant index to use for output">; -def show_encoding : Flag<["-"], "show-encoding">, - HelpText<"Show instruction encoding information in transliterate mode">; -def show_inst : Flag<["-"], "show-inst">, - HelpText<"Show internal instruction representation in transliterate mode">; - -// Assemble Options -def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">, - HelpText<"The string to embed in the Dwarf debug AT_producer record.">; - -def defsym : Separate<["-"], "defsym">, - HelpText<"Define a value for a symbol">; -} // let Flags = [CC1AsOption] From cfe-commits at lists.llvm.org Fri Jul 10 08:58:04 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 15:58:04 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: dang added a comment. In D82574#2144140 , @jeroen.dobbelaere wrote: > I think that 'clang/include/clang/Driver/CC1Options.td' should also be removed ? Yes must have missed it when rebasing. Done now in 3607aacc5981 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 09:01:46 2020 From: cfe-commits at lists.llvm.org (=?utf-8?q?Nicolai_H=C3=A4hnle_via_Phabricator?= via cfe-commits) Date: Fri, 10 Jul 2020 16:01:46 +0000 (UTC) Subject: [PATCH] D83088: Introduce CfgTraits abstraction In-Reply-To: References: Message-ID: <096321d6dc8c28fb1040aaa2fffd5e61@localhost.localdomain> nhaehnle marked an inline comment as done. nhaehnle added inline comments. ================ Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:136-138 + // Prefer to avoid support for bundled instructions as long as we + // don't really need it. + assert(!m_instr->isBundle()); ---------------- arsenm wrote: > nhaehnle wrote: > > arsenm wrote: > > > I've been thinking about more aggressively using bundles around call sites to handle waterfall looping around divergent calls with SGPR arguments > > Hmm, so what's the correct iteration behavior in the presence of bundles? Iterate over all instructions in the bundle (which is that MachineBasicBlock::instr_iterator does) and only iterate over explicit defs? I think that's what makes the most sense, and what I'm going with for now... > I don't think this actually needs to specially consider bundles. The BUNDLE itself is supposed to have the uses/defs that cover all the uses/defs inside the bundle. You shouldn't need to worry about the individual instructions This is what should be there with the last change :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83088/new/ https://reviews.llvm.org/D83088 From cfe-commits at lists.llvm.org Fri Jul 10 09:01:57 2020 From: cfe-commits at lists.llvm.org (MyDeveloperDay via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:01:57 +0000 (UTC) Subject: [PATCH] D83564: [clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack Message-ID: MyDeveloperDay created this revision. MyDeveloperDay added reviewers: krasimir, curdeius, JakeMerdichAMD. MyDeveloperDay added projects: clang, clang-format. https://bugs.llvm.org/show_bug.cgi?id=46609 Ensure `*...` obey they left/middle/right rules of Pointer alignment Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83564 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -5325,7 +5325,7 @@ verifyFormat("template S(Ts...) -> S;"); verifyFormat( "template \n" - "array(T &&... t) -> array, sizeof...(T)>;"); + "array(T &&...t) -> array, sizeof...(T)>;"); verifyFormat("template A() -> Afoo<3>())>;"); verifyFormat("template A() -> A>)>;"); verifyFormat("template A() -> Afoo<1>)>;"); @@ -8179,13 +8179,20 @@ } TEST_F(FormatTest, UnderstandsEllipsis) { + FormatStyle Style = getLLVMStyle(); verifyFormat("int printf(const char *fmt, ...);"); verifyFormat("template void Foo(Ts... ts) { Foo(ts...); }"); - verifyFormat("template void Foo(Ts *... ts) {}"); + verifyFormat("template void Foo(Ts *...ts) {}"); + + verifyFormat("template a;", Style); + + Style.PointerAlignment = FormatStyle::PAS_Left; + verifyFormat("template void Foo(Ts*... ts) {}", Style); + + verifyFormat("template a;", Style); - FormatStyle PointersLeft = getLLVMStyle(); - PointersLeft.PointerAlignment = FormatStyle::PAS_Left; - verifyFormat("template void Foo(Ts*... ts) {}", PointersLeft); + Style.PointerAlignment = FormatStyle::PAS_Middle; + verifyFormat("template a;", Style); } TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -2844,6 +2844,11 @@ Left.Previous && !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon, tok::l_square)); + // Ensure right pointer alignement with ellipsis e.g. int *...P + if (Left.is(tok::ellipsis) && Left.Previous && + Left.Previous->isOneOf(tok::star, tok::amp, tok::ampamp)) + return Style.PointerAlignment != FormatStyle::PAS_Right; + if (Right.is(tok::star) && Left.is(tok::l_paren)) return false; if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp)) -------------- next part -------------- A non-text attachment was scrubbed... Name: D83564.277064.patch Type: text/x-patch Size: 2435 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:02:46 2020 From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:02:46 +0000 (UTC) Subject: [PATCH] D83548: [clangd] Fix tests build for GCC5 In-Reply-To: References: Message-ID: <0f535589b143f09d7939520836581d68@localhost.localdomain> ArcsinX added a comment. As far as I do not have commit access, could you please commit for me? Aleksandr Platonov Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83548/new/ https://reviews.llvm.org/D83548 From cfe-commits at lists.llvm.org Fri Jul 10 09:04:59 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via cfe-commits) Date: Fri, 10 Jul 2020 09:04:59 -0700 (PDT) Subject: [clang] 1fbb719 - [LPM] Port CGProfilePass from NPM to LPM Message-ID: <5f0891ab.1c69fb81.c351e.f050@mx.google.com> Author: Zequan Wu Date: 2020-07-10T09:04:51-07:00 New Revision: 1fbb719470c6e0395abaab66c68fae3b8ae405d0 URL: https://github.com/llvm/llvm-project/commit/1fbb719470c6e0395abaab66c68fae3b8ae405d0 DIFF: https://github.com/llvm/llvm-project/commit/1fbb719470c6e0395abaab66c68fae3b8ae405d0.diff LOG: [LPM] Port CGProfilePass from NPM to LPM Reviewers: hans, chandlerc!, asbirlea, nikic Reviewed By: hans, nikic Subscribers: steven_wu, dexonsmith, nikic, echristo, void, zhizhouy, cfe-commits, aeubanks, MaskRay, jvesely, nhaehnle, hiraditya, kerbowa, llvm-commits Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D83013 Added: Modified: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll Removed: llvm/test/Other/new-pm-cgprofile.ll ################################################################################ diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def index 67c0b4203420..c7e01eb12851 100644 --- a/clang/include/clang/Basic/CodeGenOptions.def +++ b/clang/include/clang/Basic/CodeGenOptions.def @@ -254,7 +254,6 @@ CODEGENOPT(UnwindTables , 1, 0) ///< Emit unwind tables. CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer. CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer. CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate. -CODEGENOPT(CallGraphProfile , 1, 0) ///< Run call graph profile. /// Attempt to use register sized accesses to bit-fields in structures, when /// possible. diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 9e6d5e4593d3..dce0940670a2 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -620,6 +620,9 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, PMBuilder.SizeLevel = CodeGenOpts.OptimizeSize; PMBuilder.SLPVectorize = CodeGenOpts.VectorizeSLP; PMBuilder.LoopVectorize = CodeGenOpts.VectorizeLoop; + // Only enable CGProfilePass when using integrated assembler, since + // non-integrated assemblers don't recognize .cgprofile section. + PMBuilder.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops; // Loop interleaving in the loop vectorizer has historically been set to be @@ -1144,7 +1147,9 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( PTO.LoopInterleaving = CodeGenOpts.UnrollLoops; PTO.LoopVectorization = CodeGenOpts.VectorizeLoop; PTO.SLPVectorization = CodeGenOpts.VectorizeSLP; - PTO.CallGraphProfile = CodeGenOpts.CallGraphProfile; + // Only enable CGProfilePass when using integrated assembler, since + // non-integrated assemblers don't recognize .cgprofile section. + PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS; PTO.Coroutines = LangOpts.Coroutines; PassInstrumentationCallbacks PIC; @@ -1562,7 +1567,9 @@ static void runThinLTOBackend( Conf.PTO.LoopInterleaving = CGOpts.UnrollLoops; Conf.PTO.LoopVectorization = CGOpts.VectorizeLoop; Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP; - Conf.PTO.CallGraphProfile = CGOpts.CallGraphProfile; + // Only enable CGProfilePass when using integrated assembler, since + // non-integrated assemblers don't recognize .cgprofile section. + Conf.PTO.CallGraphProfile = !CGOpts.DisableIntegratedAS; // Context sensitive profile. if (CGOpts.hasProfileCSIRInstr()) { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index e24de29a309e..863c6b3ca4f3 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -860,7 +860,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Opts.RerollLoops = Args.hasArg(OPT_freroll_loops); Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as); - Opts.CallGraphProfile = !Opts.DisableIntegratedAS; Opts.Autolink = !Args.hasArg(OPT_fno_autolink); Opts.SampleProfileFile = std::string(Args.getLastArgValue(OPT_fprofile_sample_use_EQ)); diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index f0d5accf13c5..06e8507036ac 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -103,6 +103,7 @@ void initializeCFGViewerLegacyPassPass(PassRegistry&); void initializeCFIInstrInserterPass(PassRegistry&); void initializeCFLAndersAAWrapperPassPass(PassRegistry&); void initializeCFLSteensAAWrapperPassPass(PassRegistry&); +void initializeCGProfileLegacyPassPass(PassRegistry &); void initializeCallGraphDOTPrinterPass(PassRegistry&); void initializeCallGraphPrinterLegacyPassPass(PassRegistry&); void initializeCallGraphViewerPass(PassRegistry&); diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h index 28e454d3b0fc..d1b9f269d5d4 100644 --- a/llvm/include/llvm/Transforms/IPO.h +++ b/llvm/include/llvm/Transforms/IPO.h @@ -282,6 +282,8 @@ ModulePass *createSampleProfileLoaderPass(StringRef Name); ModulePass *createWriteThinLTOBitcodePass(raw_ostream &Str, raw_ostream *ThinLinkOS = nullptr); +ModulePass *createCGProfileLegacyPass(); + } // End llvm namespace #endif diff --git a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h index 8b03bcba10e4..a9928c3f5a40 100644 --- a/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -156,6 +156,7 @@ class PassManagerBuilder { bool DisableTailCalls; bool DisableUnrollLoops; + bool CallGraphProfile; bool SLPVectorize; bool LoopVectorize; bool LoopsInterleaved; diff --git a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h index 28fd3804dec9..4cb45fd42f80 100644 --- a/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h +++ b/llvm/include/llvm/Transforms/Instrumentation/CGProfile.h @@ -19,11 +19,6 @@ namespace llvm { class CGProfilePass : public PassInfoMixin { public: PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); - -private: - void addModuleFlags( - Module &M, - MapVector, uint64_t> &Counts) const; }; } // end namespace llvm diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 675511a542a1..771cdfd17aa5 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -248,10 +248,6 @@ static cl::opt EnableCHR("enable-chr-npm", cl::init(true), cl::Hidden, cl::desc("Enable control height reduction optimization (CHR)")); -static cl::opt EnableCallGraphProfile( - "enable-npm-call-graph-profile", cl::init(true), cl::Hidden, - cl::desc("Enable call graph profile pass for the new PM (default = on)")); - /// Flag to enable inline deferral during PGO. static cl::opt EnablePGOInlineDeferral("enable-npm-pgo-inline-deferral", cl::init(true), @@ -267,7 +263,7 @@ PipelineTuningOptions::PipelineTuningOptions() { Coroutines = false; LicmMssaOptCap = SetLicmMssaOptCap; LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap; - CallGraphProfile = EnableCallGraphProfile; + CallGraphProfile = true; } extern cl::opt EnableHotColdSplit; diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 9534fb874107..b65eb469a492 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -195,6 +195,7 @@ PassManagerBuilder::PassManagerBuilder() { PrepareForThinLTO = EnablePrepareForThinLTO; PerformThinLTO = EnablePerformThinLTO; DivergentTarget = false; + CallGraphProfile = true; } PassManagerBuilder::~PassManagerBuilder() { @@ -834,6 +835,10 @@ void PassManagerBuilder::populateModulePassManager( if (MergeFunctions) MPM.add(createMergeFunctionsPass()); + // Add Module flag "CG Profile" based on Branch Frequency Information. + if (CallGraphProfile) + MPM.add(createCGProfileLegacyPass()); + // LoopSink pass sinks instructions hoisted by LICM, which serves as a // canonicalization pass that enables other optimizations. As a result, // LoopSink pass needs to be a very late IR pass to avoid undoing LICM diff --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp index 2d5bd9570940..05451733625e 100644 --- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp +++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp @@ -10,22 +10,47 @@ #include "llvm/ADT/MapVector.h" #include "llvm/Analysis/BlockFrequencyInfo.h" +#include "llvm/Analysis/LazyBlockFrequencyInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/PassManager.h" +#include "llvm/InitializePasses.h" #include "llvm/ProfileData/InstrProf.h" +#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Instrumentation.h" #include using namespace llvm; -PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { +static bool +addModuleFlags(Module &M, + MapVector, uint64_t> &Counts) { + if (Counts.empty()) + return false; + + LLVMContext &Context = M.getContext(); + MDBuilder MDB(Context); + std::vector Nodes; + + for (auto E : Counts) { + Metadata *Vals[] = {ValueAsMetadata::get(E.first.first), + ValueAsMetadata::get(E.first.second), + MDB.createConstant(ConstantInt::get( + Type::getInt64Ty(Context), E.second))}; + Nodes.push_back(MDNode::get(Context, Vals)); + } + + M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); + return true; +} + +static bool runCGProfilePass( + Module &M, function_ref GetBFI, + function_ref GetTTI, bool LazyBFI) { MapVector, uint64_t> Counts; - FunctionAnalysisManager &FAM = - MAM.getResult(M).getManager(); InstrProfSymtab Symtab; auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F, Function *CalledF, uint64_t NewCount) { @@ -35,14 +60,18 @@ PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { Count = SaturatingAdd(Count, NewCount); }; // Ignore error here. Indirect calls are ignored if this fails. - (void)(bool)Symtab.create(M); + (void)(bool) Symtab.create(M); for (auto &F : M) { - if (F.isDeclaration()) + // Avoid extra cost of running passes for BFI when the function doesn't have + // entry count. Since LazyBlockFrequencyInfoPass only exists in LPM, check + // if using LazyBlockFrequencyInfoPass. + // TODO: Remove LazyBFI when LazyBlockFrequencyInfoPass is available in NPM. + if (F.isDeclaration() || (LazyBFI && !F.getEntryCount())) continue; - auto &BFI = FAM.getResult(F); + auto &BFI = GetBFI(F); if (BFI.getEntryFreq() == 0) continue; - TargetTransformInfo &TTI = FAM.getResult(F); + TargetTransformInfo &TTI = GetTTI(F); for (auto &BB : F) { Optional BBCount = BFI.getBlockProfileCount(&BB); if (!BBCount) @@ -69,28 +98,56 @@ PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { } } - addModuleFlags(M, Counts); - - return PreservedAnalyses::all(); + return addModuleFlags(M, Counts); } -void CGProfilePass::addModuleFlags( - Module &M, - MapVector, uint64_t> &Counts) const { - if (Counts.empty()) - return; +namespace { +struct CGProfileLegacyPass final : public ModulePass { + static char ID; + CGProfileLegacyPass() : ModulePass(ID) { + initializeCGProfileLegacyPassPass(*PassRegistry::getPassRegistry()); + } - LLVMContext &Context = M.getContext(); - MDBuilder MDB(Context); - std::vector Nodes; + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesCFG(); + AU.addRequired(); + AU.addRequired(); + } - for (auto E : Counts) { - Metadata *Vals[] = {ValueAsMetadata::get(E.first.first), - ValueAsMetadata::get(E.first.second), - MDB.createConstant(ConstantInt::get( - Type::getInt64Ty(Context), E.second))}; - Nodes.push_back(MDNode::get(Context, Vals)); + bool runOnModule(Module &M) override { + auto GetBFI = [this](Function &F) -> BlockFrequencyInfo & { + return this->getAnalysis(F).getBFI(); + }; + auto GetTTI = [this](Function &F) -> TargetTransformInfo & { + return this->getAnalysis().getTTI(F); + }; + + return runCGProfilePass(M, GetBFI, GetTTI, true); } +}; - M.addModuleFlag(Module::Append, "CG Profile", MDNode::get(Context, Nodes)); +} // namespace + +char CGProfileLegacyPass::ID = 0; + +INITIALIZE_PASS(CGProfileLegacyPass, "cg-profile", "Call Graph Profile", false, + false) + +ModulePass *llvm::createCGProfileLegacyPass() { + return new CGProfileLegacyPass(); +} + +PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) { + FunctionAnalysisManager &FAM = + MAM.getResult(M).getManager(); + auto GetBFI = [&FAM](Function &F) -> BlockFrequencyInfo & { + return FAM.getResult(F); + }; + auto GetTTI = [&FAM](Function &F) -> TargetTransformInfo & { + return FAM.getResult(F); + }; + + runCGProfilePass(M, GetBFI, GetTTI, false); + + return PreservedAnalyses::all(); } diff --git a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp index 64626225f23f..ad238f1357c6 100644 --- a/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/Instrumentation.cpp @@ -112,6 +112,7 @@ void llvm::initializeInstrumentation(PassRegistry &Registry) { initializePGOInstrumentationUseLegacyPassPass(Registry); initializePGOIndirectCallPromotionLegacyPassPass(Registry); initializePGOMemOPSizeOptLegacyPassPass(Registry); + initializeCGProfileLegacyPassPass(Registry); initializeInstrOrderFileLegacyPassPass(Registry); initializeInstrProfilingLegacyPassPass(Registry); initializeMemorySanitizerLegacyPassPass(Registry); diff --git a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll index 32d36f4e7280..85f9d8c867bf 100644 --- a/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll +++ b/llvm/test/CodeGen/AMDGPU/opt-pipeline.ll @@ -276,6 +276,12 @@ ; GCN-O1-NEXT: Warn about non-applied transformations ; GCN-O1-NEXT: Alignment from assumptions ; GCN-O1-NEXT: Strip Unused Function Prototypes +; GCN-O1-NEXT: Call Graph Profile +; GCN-O1-NEXT: FunctionPass Manager +; GCN-O1-NEXT: Dominator Tree Construction +; GCN-O1-NEXT: Natural Loop Information +; GCN-O1-NEXT: Lazy Branch Probability Analysis +; GCN-O1-NEXT: Lazy Block Frequency Analysis ; GCN-O1-NEXT: FunctionPass Manager ; GCN-O1-NEXT: Dominator Tree Construction ; GCN-O1-NEXT: Natural Loop Information @@ -623,6 +629,12 @@ ; GCN-O2-NEXT: Strip Unused Function Prototypes ; GCN-O2-NEXT: Dead Global Elimination ; GCN-O2-NEXT: Merge Duplicate Global Constants +; GCN-O2-NEXT: Call Graph Profile +; GCN-O2-NEXT: FunctionPass Manager +; GCN-O2-NEXT: Dominator Tree Construction +; GCN-O2-NEXT: Natural Loop Information +; GCN-O2-NEXT: Lazy Branch Probability Analysis +; GCN-O2-NEXT: Lazy Block Frequency Analysis ; GCN-O2-NEXT: FunctionPass Manager ; GCN-O2-NEXT: Dominator Tree Construction ; GCN-O2-NEXT: Natural Loop Information @@ -975,6 +987,12 @@ ; GCN-O3-NEXT: Strip Unused Function Prototypes ; GCN-O3-NEXT: Dead Global Elimination ; GCN-O3-NEXT: Merge Duplicate Global Constants +; GCN-O3-NEXT: Call Graph Profile +; GCN-O3-NEXT: FunctionPass Manager +; GCN-O3-NEXT: Dominator Tree Construction +; GCN-O3-NEXT: Natural Loop Information +; GCN-O3-NEXT: Lazy Branch Probability Analysis +; GCN-O3-NEXT: Lazy Block Frequency Analysis ; GCN-O3-NEXT: FunctionPass Manager ; GCN-O3-NEXT: Dominator Tree Construction ; GCN-O3-NEXT: Natural Loop Information diff --git a/llvm/test/Instrumentation/cgprofile.ll b/llvm/test/Instrumentation/cgprofile.ll index 1edf3b6ec518..70a1f81aa53e 100644 --- a/llvm/test/Instrumentation/cgprofile.ll +++ b/llvm/test/Instrumentation/cgprofile.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -passes cg-profile -S | FileCheck %s +; RUN: opt < %s -cg-profile -S | FileCheck %s declare void @b() diff --git a/llvm/test/Other/new-pm-cgprofile.ll b/llvm/test/Other/new-pm-cgprofile.ll deleted file mode 100644 index c7fe31ab570f..000000000000 --- a/llvm/test/Other/new-pm-cgprofile.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: opt -debug-pass-manager -passes='default' %s 2>&1 |FileCheck %s --check-prefixes=DEFAULT -; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=0 %s 2>&1 |FileCheck %s --check-prefixes=OFF -; RUN: opt -debug-pass-manager -passes='default' -enable-npm-call-graph-profile=1 %s 2>&1 |FileCheck %s --check-prefixes=ON -; -; DEFAULT: Running pass: CGProfilePass -; OFF-NOT: Running pass: CGProfilePass -; ON: Running pass: CGProfilePass - -define void @foo() { - ret void -} diff --git a/llvm/test/Other/opt-O2-pipeline.ll b/llvm/test/Other/opt-O2-pipeline.ll index ca72ec1f7567..56f85d0fb9a8 100644 --- a/llvm/test/Other/opt-O2-pipeline.ll +++ b/llvm/test/Other/opt-O2-pipeline.ll @@ -280,6 +280,12 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: Call Graph Profile +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/Other/opt-O3-pipeline.ll b/llvm/test/Other/opt-O3-pipeline.ll index f629bfc3444b..942f7d9dfead 100644 --- a/llvm/test/Other/opt-O3-pipeline.ll +++ b/llvm/test/Other/opt-O3-pipeline.ll @@ -285,6 +285,12 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: Call Graph Profile +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information diff --git a/llvm/test/Other/opt-Os-pipeline.ll b/llvm/test/Other/opt-Os-pipeline.ll index dde9fbeb9950..d975cc48b629 100644 --- a/llvm/test/Other/opt-Os-pipeline.ll +++ b/llvm/test/Other/opt-Os-pipeline.ll @@ -266,6 +266,12 @@ ; CHECK-NEXT: Strip Unused Function Prototypes ; CHECK-NEXT: Dead Global Elimination ; CHECK-NEXT: Merge Duplicate Global Constants +; CHECK-NEXT: Call Graph Profile +; CHECK-NEXT: FunctionPass Manager +; CHECK-NEXT: Dominator Tree Construction +; CHECK-NEXT: Natural Loop Information +; CHECK-NEXT: Lazy Branch Probability Analysis +; CHECK-NEXT: Lazy Block Frequency Analysis ; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Natural Loop Information From cfe-commits at lists.llvm.org Fri Jul 10 09:05:12 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:05:12 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <65e2cb0c0ace9414211f2e1048827320@localhost.localdomain> This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rG1fbb719470c6: [LPM] Port CGProfilePass from NPM to LPM (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 Files: clang/include/clang/Basic/CodeGenOptions.def clang/lib/CodeGen/BackendUtil.cpp clang/lib/Frontend/CompilerInvocation.cpp llvm/include/llvm/InitializePasses.h llvm/include/llvm/Transforms/IPO.h llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h llvm/include/llvm/Transforms/Instrumentation/CGProfile.h llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/IPO/PassManagerBuilder.cpp llvm/lib/Transforms/Instrumentation/CGProfile.cpp llvm/lib/Transforms/Instrumentation/Instrumentation.cpp llvm/test/CodeGen/AMDGPU/opt-pipeline.ll llvm/test/Instrumentation/cgprofile.ll llvm/test/Other/new-pm-cgprofile.ll llvm/test/Other/opt-O2-pipeline.ll llvm/test/Other/opt-O3-pipeline.ll llvm/test/Other/opt-Os-pipeline.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83013.277065.patch Type: text/x-patch Size: 18322 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:05:42 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:05:42 +0000 (UTC) Subject: [PATCH] D83514: [Lexer] Fix missing coverage line after #endif In-Reply-To: References: Message-ID: <984111519e693d00b8090cd3054aa209@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGdcd76c0c0716: [Lexer] Fix missing coverage line after #endif (authored by zequanwu). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83514/new/ https://reviews.llvm.org/D83514 Files: clang-tools-extra/clangd/SemanticHighlighting.cpp clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D83514.277066.patch Type: text/x-patch Size: 4651 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:05:41 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via cfe-commits) Date: Fri, 10 Jul 2020 09:05:41 -0700 (PDT) Subject: [clang] dcd76c0 - [Lexer] Fix missing coverage line after #endif Message-ID: <5f0891d5.1c69fb81.bda2a.ef72@mx.google.com> Author: Zequan Wu Date: 2020-07-10T09:05:20-07:00 New Revision: dcd76c0c0716a4417110423718c7cae4b516b4d0 URL: https://github.com/llvm/llvm-project/commit/dcd76c0c0716a4417110423718c7cae4b516b4d0 DIFF: https://github.com/llvm/llvm-project/commit/dcd76c0c0716a4417110423718c7cae4b516b4d0.diff LOG: [Lexer] Fix missing coverage line after #endif Summary: bug reported here: https://bugs.llvm.org/show_bug.cgi?id=46660 Reviewers: vsk, efriedma, arphaman Reviewed By: vsk Subscribers: dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83514 Added: Modified: clang-tools-extra/clangd/SemanticHighlighting.cpp clang/lib/Lex/PPDirectives.cpp clang/test/CoverageMapping/preprocessor.c Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index d2470da60140..ed75ce80999c 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -224,7 +224,7 @@ class HighlightingsBuilder { // Create one token for each line in the skipped range, so it works // with line-based diff ing. assert(R.start.line <= R.end.line); - for (int Line = R.start.line; Line < R.end.line; ++Line) { + for (int Line = R.start.line; Line <= R.end.line; ++Line) { // Don't bother computing the offset for the end of the line, just use // zero. The client will treat this highlighting kind specially, and // highlight the entire line visually (i.e. not just to where the text diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 396ba529fc9a..053ef1d2dd18 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -432,6 +432,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Skip to the next '#endif' / '#else' / '#elif'. CurLexer->skipOver(*SkipLength); } + SourceLocation endLoc; while (true) { CurLexer->Lex(Tok); @@ -538,7 +539,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Restore the value of LexingRawMode so that trailing comments // are handled correctly, if we've reached the outermost block. CurPPLexer->LexingRawMode = false; - CheckEndOfDirective("endif"); + endLoc = CheckEndOfDirective("endif"); CurPPLexer->LexingRawMode = true; if (Callbacks) Callbacks->Endif(Tok.getLocation(), CondInfo.IfLoc); @@ -565,7 +566,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // Restore the value of LexingRawMode so that trailing comments // are handled correctly. CurPPLexer->LexingRawMode = false; - CheckEndOfDirective("else"); + endLoc = CheckEndOfDirective("else"); CurPPLexer->LexingRawMode = true; if (Callbacks) Callbacks->Else(Tok.getLocation(), CondInfo.IfLoc); @@ -621,7 +622,9 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc, // by the end of the preamble; we'll resume parsing after the preamble. if (Callbacks && (Tok.isNot(tok::eof) || !isRecordingPreamble())) Callbacks->SourceRangeSkipped( - SourceRange(HashTokenLoc, CurPPLexer->getSourceLocation()), + SourceRange(HashTokenLoc, endLoc.isValid() + ? endLoc + : CurPPLexer->getSourceLocation()), Tok.getLocation()); } diff --git a/clang/test/CoverageMapping/preprocessor.c b/clang/test/CoverageMapping/preprocessor.c index b3ebc7bd4ec0..9225c9f162a2 100644 --- a/clang/test/CoverageMapping/preprocessor.c +++ b/clang/test/CoverageMapping/preprocessor.c @@ -3,7 +3,7 @@ // CHECK: func void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 int i = 0; -#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+3]]:1 = 0 +#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0 int x = i; #endif } @@ -11,7 +11,7 @@ void func() { // CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0 // CHECK: main int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 int i = 0; -# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:1 = 0 +# if 0 // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+4]]:29 = 0 if(i == 0) { i = 1; } @@ -22,44 +22,44 @@ int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0 if(i == 0) { // CHECK: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1 i = 1; } -#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+6]]:1 = 0 +#else // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0 if(i == 1) { i = 0; } } #endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:24 #\ if 0 #\ endif // also skipped #if 1 - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7 #\ elif 0 #endif #if 1 - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+3]]:7 #\ else #endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8 #\ ifdef NOT_DEFINED #\ endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+5]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+4]]:8 #\ ifndef __FILE__ #\ endif - // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+7]]:1 + // CHECK-NEXT: Skipped,File 0, [[@LINE+1]]:1 -> [[@LINE+6]]:26 #\ ifdef NOT_DEFINED #\ From cfe-commits at lists.llvm.org Fri Jul 10 09:06:32 2020 From: cfe-commits at lists.llvm.org (Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:06:32 +0000 (UTC) Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu In-Reply-To: References: Message-ID: <0c70e1950cdd53a5b1775a913b1c594c@localhost.localdomain> khchen updated this revision to Diff 277067. khchen added a comment. avoid to check compiler version in testcase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71124/new/ https://reviews.llvm.org/D71124 Files: clang/lib/Basic/Targets/RISCV.cpp clang/lib/Basic/Targets/RISCV.h clang/lib/Driver/ToolChains/Arch/RISCV.cpp clang/lib/Driver/ToolChains/Arch/RISCV.h clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/riscv-cpus.c llvm/include/llvm/Support/RISCVTargetParser.def llvm/include/llvm/Support/TargetParser.h llvm/lib/Support/TargetParser.cpp llvm/lib/Target/RISCV/RISCV.td -------------- next part -------------- A non-text attachment was scrubbed... Name: D71124.277067.patch Type: text/x-patch Size: 17890 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:07:47 2020 From: cfe-commits at lists.llvm.org (Serge Pavlov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:07:47 +0000 (UTC) Subject: [PATCH] D78902: [Driver] Add output file to properties of Command In-Reply-To: References: Message-ID: <38243a07078089715c6527fafba72b53@localhost.localdomain> sepavloff updated this revision to Diff 277069. sepavloff added a comment. Rebased patch Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78902/new/ https://reviews.llvm.org/D78902 Files: clang/include/clang/Driver/Job.h clang/lib/Driver/Job.cpp clang/lib/Driver/ToolChains/AIX.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AVR.cpp clang/lib/Driver/ToolChains/Ananas.cpp clang/lib/Driver/ToolChains/BareMetal.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/CloudABI.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/CrossWindows.cpp clang/lib/Driver/ToolChains/Cuda.cpp clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/DragonFly.cpp clang/lib/Driver/ToolChains/Flang.cpp clang/lib/Driver/ToolChains/FreeBSD.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/HIP.cpp clang/lib/Driver/ToolChains/Hexagon.cpp clang/lib/Driver/ToolChains/InterfaceStubs.cpp clang/lib/Driver/ToolChains/MSP430.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/MinGW.cpp clang/lib/Driver/ToolChains/Minix.cpp clang/lib/Driver/ToolChains/Myriad.cpp clang/lib/Driver/ToolChains/NaCl.cpp clang/lib/Driver/ToolChains/NetBSD.cpp clang/lib/Driver/ToolChains/OpenBSD.cpp clang/lib/Driver/ToolChains/PS4CPU.cpp clang/lib/Driver/ToolChains/RISCVToolchain.cpp clang/lib/Driver/ToolChains/Solaris.cpp clang/lib/Driver/ToolChains/WebAssembly.cpp clang/lib/Driver/ToolChains/XCore.cpp clang/unittests/Driver/ToolChainTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D78902.277069.patch Type: text/x-patch Size: 46016 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:07:56 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:07:56 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: <0150e884cd5f11f8156b91469a751b3b@localhost.localdomain> zequanwu added a comment. In D83013#2143470 , @hans wrote: > Still lgtm. For what it's worth, I think you could have just re-committed with the fixes rather than uploading for review again. Gotcha, thanks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Fri Jul 10 09:19:50 2020 From: cfe-commits at lists.llvm.org (Jonas Devlieghere via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:19:50 +0000 (UTC) Subject: [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional. In-Reply-To: References: Message-ID: <91136691978c9cd640ca20837fbfe590@localhost.localdomain> JDevlieghere added a comment. In D83454#2142719 , @michele.scandale wrote: > I tested locally the standalone build of Clang with D83426 . > I just want to make sure that we all agree this is right way moving forward. Yep, with the target exported this is the right thing to do. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83454/new/ https://reviews.llvm.org/D83454 From cfe-commits at lists.llvm.org Fri Jul 10 09:20:38 2020 From: cfe-commits at lists.llvm.org (Valeriy Dmitriev via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:20:38 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: <66e443365e8d3a86c4bdaa85f27f07ad@localhost.localdomain> vdmitrie added inline comments. ================ Comment at: clang/include/clang/Driver/Options.td:3668 + HelpText<"Do not emit code that uses the red zone.">; +def dwarf_column_info : Flag<["-"], "dwarf-column-info">, + HelpText<"Turn on column location information.">; ---------------- This option was deleted. ================ Comment at: clang/include/clang/Driver/Options.td:3738 + HelpText<"Try to use a split stack if possible.">; +def mno_zero_initialized_in_bss : Flag<["-"], "mno-zero-initialized-in-bss">, + HelpText<"Do not put zero initialized data in the BSS">; ---------------- This option was deleted. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 09:21:23 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via cfe-commits) Date: Fri, 10 Jul 2020 09:21:23 -0700 (PDT) Subject: [clang] f33c2c2 - Fix crash on `user defined literals` Message-ID: <5f089583.1c69fb81.b25d5.f344@mx.google.com> Author: Eduardo Caldas Date: 2020-07-10T16:21:11Z New Revision: f33c2c27a8d4ea831aa7c2c2649066be91318d85 URL: https://github.com/llvm/llvm-project/commit/f33c2c27a8d4ea831aa7c2c2649066be91318d85 DIFF: https://github.com/llvm/llvm-project/commit/f33c2c27a8d4ea831aa7c2c2649066be91318d85.diff LOG: Fix crash on `user defined literals` Summary: Given an UserDefinedLiteral `1.2_w`: Problem: Lexer generates one Token for the literal, but ClangAST references two source locations Fix: Ignore the operator and interpret it as the underlying literal. e.g.: `1.2_w` token generates syntax node IntegerLiteral(1.2_w) Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82157 Added: Modified: clang/include/clang/Tooling/Syntax/Nodes.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Syntax/Nodes.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Tooling/Syntax/Nodes.h b/clang/include/clang/Tooling/Syntax/Nodes.h index 97605ceb76b7..fb63c36bc4cc 100644 --- a/clang/include/clang/Tooling/Syntax/Nodes.h +++ b/clang/include/clang/Tooling/Syntax/Nodes.h @@ -50,6 +50,11 @@ enum class NodeKind : uint16_t { StringLiteralExpression, BoolLiteralExpression, CxxNullPtrExpression, + UnknownUserDefinedLiteralExpression, + IntegerUserDefinedLiteralExpression, + FloatUserDefinedLiteralExpression, + CharUserDefinedLiteralExpression, + StringUserDefinedLiteralExpression, IdExpression, // Statements. @@ -325,6 +330,88 @@ class CxxNullPtrExpression final : public Expression { syntax::Leaf *nullPtrKeyword(); }; +/// Expression for user-defined literal. C++ [lex.ext] +/// user-defined-literal: +/// user-defined-integer-literal +/// user-defined-floating-point-literal +/// user-defined-string-literal +/// user-defined-character-literal +class UserDefinedLiteralExpression : public Expression { +public: + UserDefinedLiteralExpression(NodeKind K) : Expression(K) {} + static bool classof(const Node *N) { + return N->kind() == NodeKind::UnknownUserDefinedLiteralExpression || + N->kind() == NodeKind::IntegerUserDefinedLiteralExpression || + N->kind() == NodeKind::FloatUserDefinedLiteralExpression || + N->kind() == NodeKind::CharUserDefinedLiteralExpression || + N->kind() == NodeKind::StringUserDefinedLiteralExpression; + } + syntax::Leaf *literalToken(); +}; + +// We cannot yet distinguish between user-defined-integer-literal and +// user-defined-floating-point-literal, when using raw literal operator or +// numeric literal operator. C++ [lex.ext]p3, p4 +/// Expression for an unknown user-defined-literal. +class UnknownUserDefinedLiteralExpression final + : public UserDefinedLiteralExpression { +public: + UnknownUserDefinedLiteralExpression() + : UserDefinedLiteralExpression( + NodeKind::UnknownUserDefinedLiteralExpression) {} + static bool classof(const Node *N) { + return N->kind() == NodeKind::UnknownUserDefinedLiteralExpression; + } +}; + +/// Expression for user-defined-integer-literal. C++ [lex.ext] +class IntegerUserDefinedLiteralExpression final + : public UserDefinedLiteralExpression { +public: + IntegerUserDefinedLiteralExpression() + : UserDefinedLiteralExpression( + NodeKind::IntegerUserDefinedLiteralExpression) {} + static bool classof(const Node *N) { + return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression; + } +}; + +/// Expression for user-defined-floating-point-literal. C++ [lex.ext] +class FloatUserDefinedLiteralExpression final + : public UserDefinedLiteralExpression { +public: + FloatUserDefinedLiteralExpression() + : UserDefinedLiteralExpression( + NodeKind::FloatUserDefinedLiteralExpression) {} + static bool classof(const Node *N) { + return N->kind() == NodeKind::FloatUserDefinedLiteralExpression; + } +}; + +/// Expression for user-defined-character-literal. C++ [lex.ext] +class CharUserDefinedLiteralExpression final + : public UserDefinedLiteralExpression { +public: + CharUserDefinedLiteralExpression() + : UserDefinedLiteralExpression( + NodeKind::CharUserDefinedLiteralExpression) {} + static bool classof(const Node *N) { + return N->kind() == NodeKind::CharUserDefinedLiteralExpression; + } +}; + +/// Expression for user-defined-string-literal. C++ [lex.ext] +class StringUserDefinedLiteralExpression final + : public UserDefinedLiteralExpression { +public: + StringUserDefinedLiteralExpression() + : UserDefinedLiteralExpression( + NodeKind::StringUserDefinedLiteralExpression) {} + static bool classof(const Node *N) { + return N->kind() == NodeKind::StringUserDefinedLiteralExpression; + } +}; + /// An abstract class for prefix and postfix unary operators. class UnaryOperatorExpression : public Expression { public: diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index f9fdf47bff26..8204d3fc66f3 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -216,7 +216,8 @@ static SourceRange getDeclaratorRange(const SourceManager &SM, TypeLoc T, } if (Initializer.isValid()) { auto InitializerEnd = Initializer.getEnd(); - assert(SM.isBeforeInTranslationUnit(End, InitializerEnd) || End == InitializerEnd); + assert(SM.isBeforeInTranslationUnit(End, InitializerEnd) || + End == InitializerEnd); End = InitializerEnd; } return SourceRange(Start, End); @@ -708,6 +709,42 @@ class BuildTreeVisitor : public RecursiveASTVisitor { return NNS; } + bool TraverseUserDefinedLiteral(UserDefinedLiteral *S) { + // The semantic AST node `UserDefinedLiteral` (UDL) may have one child node + // referencing the location of the UDL suffix (`_w` in `1.2_w`). The + // UDL suffix location does not point to the beginning of a token, so we + // can't represent the UDL suffix as a separate syntax tree node. + + return WalkUpFromUserDefinedLiteral(S); + } + + syntax::NodeKind getUserDefinedLiteralKind(UserDefinedLiteral *S) { + switch (S->getLiteralOperatorKind()) { + case clang::UserDefinedLiteral::LOK_Integer: + return syntax::NodeKind::IntegerUserDefinedLiteralExpression; + case clang::UserDefinedLiteral::LOK_Floating: + return syntax::NodeKind::FloatUserDefinedLiteralExpression; + case clang::UserDefinedLiteral::LOK_Character: + return syntax::NodeKind::CharUserDefinedLiteralExpression; + case clang::UserDefinedLiteral::LOK_String: + return syntax::NodeKind::StringUserDefinedLiteralExpression; + case clang::UserDefinedLiteral::LOK_Raw: + case clang::UserDefinedLiteral::LOK_Template: + // FIXME: Apply `NumericLiteralParser` to the underlying token to deduce + // the right UDL kind. That would require a `Preprocessor` though. + return syntax::NodeKind::UnknownUserDefinedLiteralExpression; + } + } + + bool WalkUpFromUserDefinedLiteral(UserDefinedLiteral *S) { + Builder.markChildToken(S->getBeginLoc(), syntax::NodeRole::LiteralToken); + Builder.foldNode(Builder.getExprRange(S), + new (allocator()) syntax::UserDefinedLiteralExpression( + getUserDefinedLiteralKind(S)), + S); + return true; + } + bool WalkUpFromDeclRefExpr(DeclRefExpr *S) { if (auto *NNS = BuildNestedNameSpecifier(S->getQualifierLoc())) Builder.markChild(NNS, syntax::NodeRole::IdExpression_qualifier); @@ -817,9 +854,9 @@ class BuildTreeVisitor : public RecursiveASTVisitor { bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) { if (getOperatorNodeKind(*S) == syntax::NodeKind::PostfixUnaryOperatorExpression) { - // A postfix unary operator is declared as taking two operands. The second - // operand is used to distinguish from its prefix counterpart. In the - // semantic AST this "phantom" operand is represented as a + // A postfix unary operator is declared as taking two operands. The + // second operand is used to distinguish from its prefix counterpart. In + // the semantic AST this "phantom" operand is represented as a // `IntegerLiteral` with invalid `SourceLocation`. We skip visiting this // operand because it does not correspond to anything written in source // code diff --git a/clang/lib/Tooling/Syntax/Nodes.cpp b/clang/lib/Tooling/Syntax/Nodes.cpp index 3d9b943d6db1..e1aa2521a2a9 100644 --- a/clang/lib/Tooling/Syntax/Nodes.cpp +++ b/clang/lib/Tooling/Syntax/Nodes.cpp @@ -32,6 +32,16 @@ llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, NodeKind K) { return OS << "BoolLiteralExpression"; case NodeKind::CxxNullPtrExpression: return OS << "CxxNullPtrExpression"; + case NodeKind::UnknownUserDefinedLiteralExpression: + return OS << "UnknownUserDefinedLiteralExpression"; + case NodeKind::IntegerUserDefinedLiteralExpression: + return OS << "IntegerUserDefinedLiteralExpression"; + case NodeKind::FloatUserDefinedLiteralExpression: + return OS << "FloatUserDefinedLiteralExpression"; + case NodeKind::CharUserDefinedLiteralExpression: + return OS << "CharUserDefinedLiteralExpression"; + case NodeKind::StringUserDefinedLiteralExpression: + return OS << "StringUserDefinedLiteralExpression"; case NodeKind::PrefixUnaryOperatorExpression: return OS << "PrefixUnaryOperatorExpression"; case NodeKind::PostfixUnaryOperatorExpression: @@ -252,6 +262,11 @@ syntax::Leaf *syntax::CxxNullPtrExpression::nullPtrKeyword() { findChild(syntax::NodeRole::LiteralToken)); } +syntax::Leaf *syntax::UserDefinedLiteralExpression::literalToken() { + return llvm::cast_or_null( + findChild(syntax::NodeRole::LiteralToken)); +} + syntax::Expression *syntax::BinaryOperatorExpression::lhs() { return llvm::cast_or_null( findChild(syntax::NodeRole::BinaryOperatorExpression_leftHandSide)); diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index acd0fbf2b52e..91e7a8f33e4e 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -1184,20 +1184,108 @@ void test() { )txt")); } -TEST_P(SyntaxTreeTest, IntegerLiteral) { +TEST_P(SyntaxTreeTest, UserDefinedLiteral) { + if (!GetParam().isCXX11OrLater()) { + return; + } EXPECT_TRUE(treeDumpEqual( R"cpp( +unsigned operator "" _i(unsigned long long); +unsigned operator "" _f(long double); +unsigned operator "" _c(char); + +unsigned operator "" _r(const char*); // raw-literal operator + +template +unsigned operator "" _t(); // numeric literal operator template + void test() { - 12; - 12u; - 12l; - 12ul; - 014; - 0XC; + 12_i; // call: operator "" _i(12uLL) | kind: integer + 1.2_f; // call: operator "" _f(1.2L) | kind: float + '2'_c; // call: operator "" _c('2') | kind: char + + // TODO: Generate `FloatUserDefinedLiteralExpression` and + // `IntegerUserDefinedLiteralExpression` instead of + // `UnknownUserDefinedLiteralExpression`. See `getUserDefinedLiteralKind` + 12_r; // call: operator "" _r("12") | kind: integer + 1.2_r; // call: operator "" _i("1.2") | kind: float + 12_t; // call: operator<'1', '2'> "" _x() | kind: integer + 1.2_t; // call: operator<'1', '2'> "" _x() | kind: float } -)cpp", + )cpp", R"txt( *: TranslationUnit +|-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" +| | |-_i +| | `-ParametersAndQualifiers +| | |-( +| | |-SimpleDeclaration +| | | |-unsigned +| | | |-long +| | | `-long +| | `-) +| `-; +|-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" +| | |-_f +| | `-ParametersAndQualifiers +| | |-( +| | |-SimpleDeclaration +| | | |-long +| | | `-double +| | `-) +| `-; +|-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" +| | |-_c +| | `-ParametersAndQualifiers +| | |-( +| | |-SimpleDeclaration +| | | `-char +| | `-) +| `-; +|-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" +| | |-_r +| | `-ParametersAndQualifiers +| | |-( +| | |-SimpleDeclaration +| | | |-const +| | | |-char +| | | `-SimpleDeclarator +| | | `-* +| | `-) +| `-; +|-TemplateDeclaration +| |-template +| |-< +| |-SimpleDeclaration +| | `-char +| |-... +| |-> +| `-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" +| | |-_t +| | `-ParametersAndQualifiers +| | |-( +| | `-) +| `-; `-SimpleDeclaration |-void |-SimpleDeclarator @@ -1208,28 +1296,95 @@ void test() { `-CompoundStatement |-{ |-ExpressionStatement - | |-IntegerLiteralExpression - | | `-12 + | |-IntegerUserDefinedLiteralExpression + | | `-12_i | `-; |-ExpressionStatement - | |-IntegerLiteralExpression - | | `-12u + | |-FloatUserDefinedLiteralExpression + | | `-1.2_f | `-; |-ExpressionStatement - | |-IntegerLiteralExpression - | | `-12l + | |-CharUserDefinedLiteralExpression + | | `-'2'_c | `-; |-ExpressionStatement - | |-IntegerLiteralExpression - | | `-12ul + | |-UnknownUserDefinedLiteralExpression + | | `-12_r | `-; |-ExpressionStatement - | |-IntegerLiteralExpression - | | `-014 + | |-UnknownUserDefinedLiteralExpression + | | `-1.2_r | `-; |-ExpressionStatement - | |-IntegerLiteralExpression - | | `-0XC + | |-UnknownUserDefinedLiteralExpression + | | `-12_t + | `-; + |-ExpressionStatement + | |-UnknownUserDefinedLiteralExpression + | | `-1.2_t + | `-; + `-} +)txt")); +} + +TEST_P(SyntaxTreeTest, UserDefinedLiteralString) { + if (!GetParam().isCXX11OrLater()) { + return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +typedef decltype(sizeof(void *)) size_t; +unsigned operator "" _s(const char*, size_t); +void test() { + "12"_s;// call: operator "" _s("12") | kind: string +} + )cpp", + R"txt( +*: TranslationUnit +|-SimpleDeclaration +| |-typedef +| |-decltype +| |-( +| |-UnknownExpression +| | |-sizeof +| | |-( +| | |-void +| | |-* +| | `-) +| |-) +| |-SimpleDeclarator +| | `-size_t +| `-; +|-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" +| | |-_s +| | `-ParametersAndQualifiers +| | |-( +| | |-SimpleDeclaration +| | | |-const +| | | |-char +| | | `-SimpleDeclarator +| | | `-* +| | |-, +| | |-SimpleDeclaration +| | | `-size_t +| | `-) +| `-; +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | `-) + `-CompoundStatement + |-{ + |-ExpressionStatement + | |-StringUserDefinedLiteralExpression + | | `-"12"_s | `-; `-} )txt")); From cfe-commits at lists.llvm.org Fri Jul 10 09:21:25 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:21:25 +0000 (UTC) Subject: [PATCH] D82157: Fix crash on `user defined literals` In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGf33c2c27a8d4: Fix crash on `user defined literals` (authored by eduucaldas). Changed prior to commit: https://reviews.llvm.org/D82157?vs=277060&id=277071#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82157/new/ https://reviews.llvm.org/D82157 Files: clang/include/clang/Tooling/Syntax/Nodes.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Syntax/Nodes.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82157.277071.patch Type: text/x-patch Size: 13534 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:21:25 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via cfe-commits) Date: Fri, 10 Jul 2020 09:21:25 -0700 (PDT) Subject: [clang] 1db5b34 - Add kinded UDL for raw literal operator and numeric literal operator template Message-ID: <5f089585.1c69fb81.564d.eedc@mx.google.com> Author: Eduardo Caldas Date: 2020-07-10T16:21:11Z New Revision: 1db5b348c4c93b6610afb4fd515b389989efc302 URL: https://github.com/llvm/llvm-project/commit/1db5b348c4c93b6610afb4fd515b389989efc302 DIFF: https://github.com/llvm/llvm-project/commit/1db5b348c4c93b6610afb4fd515b389989efc302.diff LOG: Add kinded UDL for raw literal operator and numeric literal operator template Added: Modified: clang/include/clang/Tooling/Syntax/Nodes.h clang/lib/Tooling/Syntax/BuildTree.cpp clang/lib/Tooling/Syntax/Nodes.cpp clang/unittests/Tooling/Syntax/TreeTest.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Tooling/Syntax/Nodes.h b/clang/include/clang/Tooling/Syntax/Nodes.h index fb63c36bc4cc..d97b127638bb 100644 --- a/clang/include/clang/Tooling/Syntax/Nodes.h +++ b/clang/include/clang/Tooling/Syntax/Nodes.h @@ -50,7 +50,6 @@ enum class NodeKind : uint16_t { StringLiteralExpression, BoolLiteralExpression, CxxNullPtrExpression, - UnknownUserDefinedLiteralExpression, IntegerUserDefinedLiteralExpression, FloatUserDefinedLiteralExpression, CharUserDefinedLiteralExpression, @@ -340,8 +339,7 @@ class UserDefinedLiteralExpression : public Expression { public: UserDefinedLiteralExpression(NodeKind K) : Expression(K) {} static bool classof(const Node *N) { - return N->kind() == NodeKind::UnknownUserDefinedLiteralExpression || - N->kind() == NodeKind::IntegerUserDefinedLiteralExpression || + return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression || N->kind() == NodeKind::FloatUserDefinedLiteralExpression || N->kind() == NodeKind::CharUserDefinedLiteralExpression || N->kind() == NodeKind::StringUserDefinedLiteralExpression; @@ -349,21 +347,6 @@ class UserDefinedLiteralExpression : public Expression { syntax::Leaf *literalToken(); }; -// We cannot yet distinguish between user-defined-integer-literal and -// user-defined-floating-point-literal, when using raw literal operator or -// numeric literal operator. C++ [lex.ext]p3, p4 -/// Expression for an unknown user-defined-literal. -class UnknownUserDefinedLiteralExpression final - : public UserDefinedLiteralExpression { -public: - UnknownUserDefinedLiteralExpression() - : UserDefinedLiteralExpression( - NodeKind::UnknownUserDefinedLiteralExpression) {} - static bool classof(const Node *N) { - return N->kind() == NodeKind::UnknownUserDefinedLiteralExpression; - } -}; - /// Expression for user-defined-integer-literal. C++ [lex.ext] class IntegerUserDefinedLiteralExpression final : public UserDefinedLiteralExpression { diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 8204d3fc66f3..5afe4965793a 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -23,6 +23,7 @@ #include "clang/Basic/Specifiers.h" #include "clang/Basic/TokenKinds.h" #include "clang/Lex/Lexer.h" +#include "clang/Lex/LiteralSupport.h" #include "clang/Tooling/Syntax/Nodes.h" #include "clang/Tooling/Syntax/Tokens.h" #include "clang/Tooling/Syntax/Tree.h" @@ -552,8 +553,8 @@ class syntax::TreeBuilder { namespace { class BuildTreeVisitor : public RecursiveASTVisitor { public: - explicit BuildTreeVisitor(ASTContext &Ctx, syntax::TreeBuilder &Builder) - : Builder(Builder), LangOpts(Ctx.getLangOpts()) {} + explicit BuildTreeVisitor(ASTContext &Context, syntax::TreeBuilder &Builder) + : Builder(Builder), Context(Context) {} bool shouldTraversePostOrder() const { return true; } @@ -718,30 +719,44 @@ class BuildTreeVisitor : public RecursiveASTVisitor { return WalkUpFromUserDefinedLiteral(S); } - syntax::NodeKind getUserDefinedLiteralKind(UserDefinedLiteral *S) { + syntax::UserDefinedLiteralExpression * + buildUserDefinedLiteral(UserDefinedLiteral *S) { switch (S->getLiteralOperatorKind()) { case clang::UserDefinedLiteral::LOK_Integer: - return syntax::NodeKind::IntegerUserDefinedLiteralExpression; + return new (allocator()) syntax::IntegerUserDefinedLiteralExpression; case clang::UserDefinedLiteral::LOK_Floating: - return syntax::NodeKind::FloatUserDefinedLiteralExpression; + return new (allocator()) syntax::FloatUserDefinedLiteralExpression; case clang::UserDefinedLiteral::LOK_Character: - return syntax::NodeKind::CharUserDefinedLiteralExpression; + return new (allocator()) syntax::CharUserDefinedLiteralExpression; case clang::UserDefinedLiteral::LOK_String: - return syntax::NodeKind::StringUserDefinedLiteralExpression; + return new (allocator()) syntax::StringUserDefinedLiteralExpression; case clang::UserDefinedLiteral::LOK_Raw: case clang::UserDefinedLiteral::LOK_Template: - // FIXME: Apply `NumericLiteralParser` to the underlying token to deduce - // the right UDL kind. That would require a `Preprocessor` though. - return syntax::NodeKind::UnknownUserDefinedLiteralExpression; + // For raw literal operator and numeric literal operator template we + // cannot get the type of the operand in the semantic AST. We get this + // information from the token. As integer and floating point have the same + // token kind, we run `NumericLiteralParser` again to distinguish them. + auto TokLoc = S->getBeginLoc(); + auto buffer = SmallVector(); + bool invalidSpelling = false; + auto TokSpelling = + Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(), + Context.getLangOpts(), &invalidSpelling); + assert(!invalidSpelling); + auto Literal = + NumericLiteralParser(TokSpelling, TokLoc, Context.getSourceManager(), + Context.getLangOpts(), Context.getTargetInfo(), + Context.getDiagnostics()); + if (Literal.isIntegerLiteral()) + return new (allocator()) syntax::IntegerUserDefinedLiteralExpression; + else + return new (allocator()) syntax::FloatUserDefinedLiteralExpression; } } bool WalkUpFromUserDefinedLiteral(UserDefinedLiteral *S) { Builder.markChildToken(S->getBeginLoc(), syntax::NodeRole::LiteralToken); - Builder.foldNode(Builder.getExprRange(S), - new (allocator()) syntax::UserDefinedLiteralExpression( - getUserDefinedLiteralKind(S)), - S); + Builder.foldNode(Builder.getExprRange(S), buildUserDefinedLiteral(S), S); return true; } @@ -1262,7 +1277,7 @@ class BuildTreeVisitor : public RecursiveASTVisitor { llvm::BumpPtrAllocator &allocator() { return Builder.allocator(); } syntax::TreeBuilder &Builder; - const LangOptions &LangOpts; + const ASTContext &Context; }; } // namespace diff --git a/clang/lib/Tooling/Syntax/Nodes.cpp b/clang/lib/Tooling/Syntax/Nodes.cpp index e1aa2521a2a9..2435ae0a91dd 100644 --- a/clang/lib/Tooling/Syntax/Nodes.cpp +++ b/clang/lib/Tooling/Syntax/Nodes.cpp @@ -32,8 +32,6 @@ llvm::raw_ostream &syntax::operator<<(llvm::raw_ostream &OS, NodeKind K) { return OS << "BoolLiteralExpression"; case NodeKind::CxxNullPtrExpression: return OS << "CxxNullPtrExpression"; - case NodeKind::UnknownUserDefinedLiteralExpression: - return OS << "UnknownUserDefinedLiteralExpression"; case NodeKind::IntegerUserDefinedLiteralExpression: return OS << "IntegerUserDefinedLiteralExpression"; case NodeKind::FloatUserDefinedLiteralExpression: diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index 91e7a8f33e4e..bd639aa58166 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -1190,32 +1190,45 @@ TEST_P(SyntaxTreeTest, UserDefinedLiteral) { } EXPECT_TRUE(treeDumpEqual( R"cpp( +typedef decltype(sizeof(void *)) size_t; + unsigned operator "" _i(unsigned long long); unsigned operator "" _f(long double); unsigned operator "" _c(char); - -unsigned operator "" _r(const char*); // raw-literal operator - +unsigned operator "" _s(const char*, size_t); +unsigned operator "" _r(const char*); template -unsigned operator "" _t(); // numeric literal operator template +unsigned operator "" _t(); void test() { - 12_i; // call: operator "" _i(12uLL) | kind: integer - 1.2_f; // call: operator "" _f(1.2L) | kind: float - '2'_c; // call: operator "" _c('2') | kind: char + 12_i; // call: operator "" _i(12uLL) | kind: integer + 1.2_f; // call: operator "" _f(1.2L) | kind: float + '2'_c; // call: operator "" _c('2') | kind: char + "12"_s; // call: operator "" _s("12") | kind: string - // TODO: Generate `FloatUserDefinedLiteralExpression` and - // `IntegerUserDefinedLiteralExpression` instead of - // `UnknownUserDefinedLiteralExpression`. See `getUserDefinedLiteralKind` - 12_r; // call: operator "" _r("12") | kind: integer - 1.2_r; // call: operator "" _i("1.2") | kind: float - 12_t; // call: operator<'1', '2'> "" _x() | kind: integer - 1.2_t; // call: operator<'1', '2'> "" _x() | kind: float + 12_r; // call: operator "" _r("12") | kind: integer + 1.2_r; // call: operator "" _i("1.2") | kind: float + 12_t; // call: operator<'1', '2'> "" _x() | kind: integer + 1.2_t; // call: operator<'1', '2'> "" _x() | kind: float } )cpp", R"txt( *: TranslationUnit |-SimpleDeclaration +| |-typedef +| |-decltype +| |-( +| |-UnknownExpression +| | |-sizeof +| | |-( +| | |-void +| | |-* +| | `-) +| |-) +| |-SimpleDeclarator +| | `-size_t +| `-; +|-SimpleDeclaration | |-unsigned | |-SimpleDeclarator | | |-operator @@ -1259,6 +1272,24 @@ void test() { | |-SimpleDeclarator | | |-operator | | |-"" +| | |-_s +| | `-ParametersAndQualifiers +| | |-( +| | |-SimpleDeclaration +| | | |-const +| | | |-char +| | | `-SimpleDeclarator +| | | `-* +| | |-, +| | |-SimpleDeclaration +| | | `-size_t +| | `-) +| `-; +|-SimpleDeclaration +| |-unsigned +| |-SimpleDeclarator +| | |-operator +| | |-"" | | |-_r | | `-ParametersAndQualifiers | | |-( @@ -1308,88 +1339,29 @@ void test() { | | `-'2'_c | `-; |-ExpressionStatement - | |-UnknownUserDefinedLiteralExpression + | |-StringUserDefinedLiteralExpression + | | `-"12"_s + | `-; + |-ExpressionStatement + | |-IntegerUserDefinedLiteralExpression | | `-12_r | `-; |-ExpressionStatement - | |-UnknownUserDefinedLiteralExpression + | |-FloatUserDefinedLiteralExpression | | `-1.2_r | `-; |-ExpressionStatement - | |-UnknownUserDefinedLiteralExpression + | |-IntegerUserDefinedLiteralExpression | | `-12_t | `-; |-ExpressionStatement - | |-UnknownUserDefinedLiteralExpression + | |-FloatUserDefinedLiteralExpression | | `-1.2_t | `-; `-} )txt")); } -TEST_P(SyntaxTreeTest, UserDefinedLiteralString) { - if (!GetParam().isCXX11OrLater()) { - return; - } - EXPECT_TRUE(treeDumpEqual( - R"cpp( -typedef decltype(sizeof(void *)) size_t; -unsigned operator "" _s(const char*, size_t); -void test() { - "12"_s;// call: operator "" _s("12") | kind: string -} - )cpp", - R"txt( -*: TranslationUnit -|-SimpleDeclaration -| |-typedef -| |-decltype -| |-( -| |-UnknownExpression -| | |-sizeof -| | |-( -| | |-void -| | |-* -| | `-) -| |-) -| |-SimpleDeclarator -| | `-size_t -| `-; -|-SimpleDeclaration -| |-unsigned -| |-SimpleDeclarator -| | |-operator -| | |-"" -| | |-_s -| | `-ParametersAndQualifiers -| | |-( -| | |-SimpleDeclaration -| | | |-const -| | | |-char -| | | `-SimpleDeclarator -| | | `-* -| | |-, -| | |-SimpleDeclaration -| | | `-size_t -| | `-) -| `-; -`-SimpleDeclaration - |-void - |-SimpleDeclarator - | |-test - | `-ParametersAndQualifiers - | |-( - | `-) - `-CompoundStatement - |-{ - |-ExpressionStatement - | |-StringUserDefinedLiteralExpression - | | `-"12"_s - | `-; - `-} -)txt")); -} - TEST_P(SyntaxTreeTest, IntegerLiteralLongLong) { if (!GetParam().isCXX11OrLater()) { return; From cfe-commits at lists.llvm.org Fri Jul 10 09:21:27 2020 From: cfe-commits at lists.llvm.org (Eduardo Caldas via cfe-commits) Date: Fri, 10 Jul 2020 09:21:27 -0700 (PDT) Subject: [clang] a474d5b - Use FileRange::text instead of Lexer::getSpelling Message-ID: <5f089587.1c69fb81.d4602.e3b6@mx.google.com> Author: Eduardo Caldas Date: 2020-07-10T16:21:12Z New Revision: a474d5bae4773782d50d4a5a62300c0f4a2dff28 URL: https://github.com/llvm/llvm-project/commit/a474d5bae4773782d50d4a5a62300c0f4a2dff28 DIFF: https://github.com/llvm/llvm-project/commit/a474d5bae4773782d50d4a5a62300c0f4a2dff28.diff LOG: Use FileRange::text instead of Lexer::getSpelling * as we are using them only for integer and floating literals they have the same behavior * FileRange::text is simpler to call and is within the context of syntax trees Added: Modified: clang/lib/Tooling/Syntax/BuildTree.cpp Removed: ################################################################################ diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 5afe4965793a..6d13f1ace83b 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -737,20 +737,18 @@ class BuildTreeVisitor : public RecursiveASTVisitor { // information from the token. As integer and floating point have the same // token kind, we run `NumericLiteralParser` again to distinguish them. auto TokLoc = S->getBeginLoc(); - auto buffer = SmallVector(); - bool invalidSpelling = false; auto TokSpelling = - Lexer::getSpelling(TokLoc, buffer, Context.getSourceManager(), - Context.getLangOpts(), &invalidSpelling); - assert(!invalidSpelling); + Builder.findToken(TokLoc)->text(Context.getSourceManager()); auto Literal = NumericLiteralParser(TokSpelling, TokLoc, Context.getSourceManager(), Context.getLangOpts(), Context.getTargetInfo(), Context.getDiagnostics()); if (Literal.isIntegerLiteral()) return new (allocator()) syntax::IntegerUserDefinedLiteralExpression; - else + else { + assert(Literal.isFloatingLiteral()); return new (allocator()) syntax::FloatUserDefinedLiteralExpression; + } } } From cfe-commits at lists.llvm.org Fri Jul 10 09:21:50 2020 From: cfe-commits at lists.llvm.org (Yuanfang Chen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:21:50 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager In-Reply-To: References: Message-ID: <0ce86e5b5b1096eb46df3437dc060880@localhost.localdomain> ychen added a comment. High-level request: how about split this patch into two, the first for the `require` pass part; the second for the PassInstrument callback. Then we could discuss the choices of first patch and D82344 . ================ Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150 for (auto &C : Callbacks->BeforePassCallbacks) - ShouldRun &= C(Pass.name(), llvm::Any(&IR)); + ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR)); return ShouldRun; ---------------- aeubanks wrote: > aeubanks wrote: > > ychen wrote: > > > Could we do this to not changing the callback API? > > > `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();` > > Each pass instrumentation should decide whether or not to run the pass based on whether or not the pass is required or optional. An optional pass may still be run, (which should be the case for the vast majority of instances). > > > > For example, the optnone would only care if a pass is required or not if it sees that a function is marked optnone. > > Similarly, opt-bisect would only care if a pass is required if it's hit the bisect limit. > Sorry, now I understand what you mean, the ands and ors confused me. > > I don't want to rule out the possibility of some future pass instrumentation wanting to skip even a required pass. But I am open to discussion on this point. > I don't want to rule out the possibility of some future pass instrumentation wanting to skip even a required pass. But I am open to discussion on this point. That makes sense. However, since this requires changing the callback API(return value or parameter), and there is no real use of it for the moment. IMHO we should defer it to the use case comes up. If there was no change to the callback API, I wouldn't mind doing this for now. The immediate motivation for the `require` is the same as D82344 (the approach is a little bit different). That's we don't want to consider infrastructure passes (pass managers, adaptor passes that have a nested pass manager) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83519/new/ https://reviews.llvm.org/D83519 From cfe-commits at lists.llvm.org Fri Jul 10 09:25:29 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:25:29 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: LukeGeeson updated this revision to Diff 277074. LukeGeeson added a comment. removed FP16FML feature CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.277074.patch Type: text/x-patch Size: 21179 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:29:04 2020 From: cfe-commits at lists.llvm.org (Dave Green via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:29:04 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <4110487d1355de851f44aebb0694095c@localhost.localdomain> dmgreen accepted this revision. dmgreen added a comment. This revision is now accepted and ready to land. Thanks. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 From cfe-commits at lists.llvm.org Fri Jul 10 09:30:03 2020 From: cfe-commits at lists.llvm.org (Arthur Eubanks via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:30:03 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager In-Reply-To: References: Message-ID: <23ceb78c3c9757d97f79949c41c5ed2c@localhost.localdomain> aeubanks marked an inline comment as done. aeubanks added a comment. In D83519#2144403 , @ychen wrote: > High-level request: how about split this patch into two, the first for the `require` pass part; the second for the PassInstrument callback. Then we could discuss the choices of first patch and D82344 . Good idea, will split the patch and take a closer look at your patch. ================ Comment at: llvm/include/llvm/IR/PassInstrumentation.h:150 for (auto &C : Callbacks->BeforePassCallbacks) - ShouldRun &= C(Pass.name(), llvm::Any(&IR)); + ShouldRun &= C(Pass.name(), Pass.isRequired(), llvm::Any(&IR)); return ShouldRun; ---------------- ychen wrote: > aeubanks wrote: > > aeubanks wrote: > > > ychen wrote: > > > > Could we do this to not changing the callback API? > > > > `ShouldRun &= C(Pass.name(), llvm::Any(&IR)) || Pass.isRequired();` > > > Each pass instrumentation should decide whether or not to run the pass based on whether or not the pass is required or optional. An optional pass may still be run, (which should be the case for the vast majority of instances). > > > > > > For example, the optnone would only care if a pass is required or not if it sees that a function is marked optnone. > > > Similarly, opt-bisect would only care if a pass is required if it's hit the bisect limit. > > Sorry, now I understand what you mean, the ands and ors confused me. > > > > I don't want to rule out the possibility of some future pass instrumentation wanting to skip even a required pass. But I am open to discussion on this point. > > I don't want to rule out the possibility of some future pass instrumentation wanting to skip even a required pass. But I am open to discussion on this point. > > That makes sense. However, since this requires changing the callback API(return value or parameter), and there is no real use of it for the moment. IMHO we should defer it to the use case comes up. If there was no change to the callback API, I wouldn't mind doing this for now. > > The immediate motivation for the `require` is the same as D82344 (the approach is a little bit different). That's we don't want to consider infrastructure passes (pass managers, adaptor passes that have a nested pass manager) Sounds good, I'll go with your approach for keeping the current API. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83519/new/ https://reviews.llvm.org/D83519 From cfe-commits at lists.llvm.org Fri Jul 10 09:37:34 2020 From: cfe-commits at lists.llvm.org (Saleem Abdulrasool via cfe-commits) Date: Fri, 10 Jul 2020 09:37:34 -0700 (PDT) Subject: [clang] aa7a5ad - repair standalone clang builds Message-ID: <5f08994e.1c69fb81.20bd.f6ba@mx.google.com> Author: Saleem Abdulrasool Date: 2020-07-10T09:36:27-07:00 New Revision: aa7a5ad56b6028e0963e1a8d45b4e82f3f6bc70e URL: https://github.com/llvm/llvm-project/commit/aa7a5ad56b6028e0963e1a8d45b4e82f3f6bc70e DIFF: https://github.com/llvm/llvm-project/commit/aa7a5ad56b6028e0963e1a8d45b4e82f3f6bc70e.diff LOG: repair standalone clang builds Add missing C++ language standard setup for clang standalone build. Patch by Michele Scandale! Differential Revision: https://reviews.llvm.org/D83426 Added: Modified: clang/CMakeLists.txt Removed: ################################################################################ diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 83c30528499c..7f8e0718c2eb 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -9,6 +9,10 @@ endif() if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) project(Clang) + set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") + set(CMAKE_CXX_STANDARD_REQUIRED YES) + set(CMAKE_CXX_EXTENSIONS NO) + # Rely on llvm-config. set(CONFIG_OUTPUT) if(LLVM_CONFIG) From cfe-commits at lists.llvm.org Fri Jul 10 09:37:37 2020 From: cfe-commits at lists.llvm.org (Saleem Abdulrasool via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:37:37 +0000 (UTC) Subject: [PATCH] D83426: Unbreak Clang standalone build. In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGaa7a5ad56b60: repair standalone clang builds (authored by compnerd). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83426/new/ https://reviews.llvm.org/D83426 Files: clang/CMakeLists.txt Index: clang/CMakeLists.txt =================================================================== --- clang/CMakeLists.txt +++ clang/CMakeLists.txt @@ -9,6 +9,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) project(Clang) + set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to") + set(CMAKE_CXX_STANDARD_REQUIRED YES) + set(CMAKE_CXX_EXTENSIONS NO) + # Rely on llvm-config. set(CONFIG_OUTPUT) if(LLVM_CONFIG) -------------- next part -------------- A non-text attachment was scrubbed... Name: D83426.277076.patch Type: text/x-patch Size: 454 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 09:50:39 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:50:39 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: gribozavr2 accepted this revision. gribozavr2 added a comment. This revision is now accepted and ready to land. Could you take a look at test failures and check if they are relevant? `linux > Clang.AST::ast-dump-attr.cpp` looks extremely close to the area you're working on. I'm not quite comfortable adding this code without unittests. We don't have a great way to unit test the AST, but I think we should try. I think `clang/unittests/AST/MatchVerifier.h` could help here. The test could match a while loop with AST matchers, and then assert that the source locations are what we expect. The while loop could come from the code directly, or be instantiated from a template; also test what happens for parse errors. ================ Comment at: clang/include/clang/AST/Stmt.h:2292 WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, - SourceLocation WL); + SourceLocation WL, SourceLocation LP, SourceLocation RP); ---------------- I'd prefer to unabbreviate here. (use `LParenLoc` as well) ================ Comment at: clang/include/clang/AST/Stmt.h:2300 static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, - Stmt *Body, SourceLocation WL); + Stmt *Body, SourceLocation WL, SourceLocation LP, + SourceLocation RP); ---------------- I'd prefer to unabbreviate here. (use `LParenLoc` as well) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 From cfe-commits at lists.llvm.org Fri Jul 10 09:55:41 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via cfe-commits) Date: Fri, 10 Jul 2020 09:55:41 -0700 (PDT) Subject: [clang] a2cffb1 - Remove clang options that were added back when merging the TableGen files Message-ID: <5f089d8d.1c69fb81.6df42.ff34@mx.google.com> Author: Daniel Grumberg Date: 2020-07-10T17:54:44+01:00 New Revision: a2cffb11e287f0e35685ac404400edab12cae51e URL: https://github.com/llvm/llvm-project/commit/a2cffb11e287f0e35685ac404400edab12cae51e DIFF: https://github.com/llvm/llvm-project/commit/a2cffb11e287f0e35685ac404400edab12cae51e.diff LOG: Remove clang options that were added back when merging the TableGen files Added: Modified: clang/include/clang/Driver/Options.td Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 042d66a1b61a..e09b1b0b306f 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3669,8 +3669,6 @@ def disable_O0_optnone : Flag<["-"], "disable-O0-optnone">, HelpText<"Disable adding the optnone attribute to functions at O0">; def disable_red_zone : Flag<["-"], "disable-red-zone">, HelpText<"Do not emit code that uses the red zone.">; -def dwarf_column_info : Flag<["-"], "dwarf-column-info">, - HelpText<"Turn on column location information.">; def dwarf_ext_refs : Flag<["-"], "dwarf-ext-refs">, HelpText<"Generate debug info with external references to clang modules" " or precompiled headers">; @@ -3739,8 +3737,6 @@ def mlimit_float_precision : Separate<["-"], "mlimit-float-precision">, HelpText<"Limit float precision to the given value">; def split_stacks : Flag<["-"], "split-stacks">, HelpText<"Try to use a split stack if possible.">; -def mno_zero_initialized_in_bss : Flag<["-"], "mno-zero-initialized-in-bss">, - HelpText<"Do not put zero initialized data in the BSS">; def mregparm : Separate<["-"], "mregparm">, HelpText<"Limit the number of registers available for integer arguments">; def msmall_data_limit : Separate<["-"], "msmall-data-limit">, From cfe-commits at lists.llvm.org Fri Jul 10 09:56:10 2020 From: cfe-commits at lists.llvm.org (Daniel Grumberg via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:56:10 +0000 (UTC) Subject: [PATCH] D82574: Merge TableGen files used for clang options In-Reply-To: References: Message-ID: <726bdf18829bec4ce324a9f620c6898a@localhost.localdomain> dang added a comment. Sorry again, removed the offending options in a2cffb11e287 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82574/new/ https://reviews.llvm.org/D82574 From cfe-commits at lists.llvm.org Fri Jul 10 09:57:42 2020 From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 16:57:42 +0000 (UTC) Subject: [PATCH] D81728: [InstCombine] Add target-specific inst combining In-Reply-To: References: Message-ID: nikic added inline comments. ================ Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:540 + bool instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II, + Instruction **ResultI) const; + bool simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II, ---------------- For all three functions, the calling convention seems rather non-idiomatic for InstCombine. Rather than having an `Instruction **` argument and bool result, is there any reason not to have an `Instruction *` return value, with nullptr indicating that the intrinsic couldn't be simplified? ================ Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:542 + bool simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II, + APInt DemandedMask, KnownBits &Known, + bool &KnownBitsComputed, ---------------- `const APInt &DemandedMask`? ================ Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:546 + bool simplifyDemandedVectorEltsIntrinsic( + InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, + APInt &UndefElts2, APInt &UndefElts3, ---------------- `const APInt &DemandedElts`? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81728/new/ https://reviews.llvm.org/D81728 From cfe-commits at lists.llvm.org Fri Jul 10 10:04:31 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:04:31 +0000 (UTC) Subject: [PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations. In-Reply-To: References: Message-ID: <41889b3ef30be10c64aab776ca225a2d@localhost.localdomain> rjmccall added a comment. In D82663#2144219 , @ebevhan wrote: > In D82663#2142426 , @rjmccall wrote: > > > Would it be sensible to use a technical design more like what the matrix folks are doing, where LLVM provides a small interface for emitting operations with various semantics? FixedPointSemantics would move to that header, and Clang would just call into it. That way you get a lot more flexibility in how you generate code, and the Clang IRGen logic is still transparently correct. If you want to add intrinsics or otherwise change the IR patterns used for various operations, you don't have to rewrite a bunch of Clang IRGen logic every time, you just have to update the tests. It'd then be pretty straightforward to have internal helper functions in that interface for computing things like whether you should use signed or unsigned intrinsics given the desired FixedPointSemantics. > > > This seems like a reasonable thing to do for other reasons as well. Also moving the actual APFixedPoint class to LLVM would make it easier to reuse the fixedpoint calculation code for constant folding in LLVM, for example. Just to say "I told you so", I'm pretty sure I told people this would happen. :) >> My interest here is mainly in (1) keeping IRGen's logic as obviously correct as possible, (2) not hard-coding a bunch of things that really feel like workarounds for backend limitations, and (3) not complicating core abstractions like FixedPointSemantics with unnecessary extra rules for appropriate use, like having to pass an extra "for codegen" flag to get optimal codegen. If IRGen can just pass down the high-level semantics it wants to some library that will make intelligent decisions about how to emit IR, that seems best. > > Just to clarify something here; would the interface in LLVM still emit signed operations for unsigned with padding? If that's the best IR pattern to emit, yes. > If so, why does dealing with the padding bit detail in LLVM rather than Clang make more sense? Because frontends should be able to just say "I have a value of a type with these semantics, I need you to do these operations, go do them". The whole purpose of this interface would be to go down a level of abstraction by picking the best IR to represent those operations. Maybe we're not in agreement about what this interface looks like — I'm imagining something like struct FixedPointEmitter { IRBuilder &B; FixedPointEmitter(IRBuilder &B) : B(B) {} Value *convert(Value *src, FixedPointSemantics srcSemantics, FixedPointSemantics destSemantics); Value *add(Value *lhs, FixedPointSemantics lhsSemantics, Value *rhs, FixedPointSemantics rhsSemantics) }; > The regular IRBuilder is relatively straightforward in its behavior. I suspect that if anything, LLVM would be equally unwilling to take to take IRBuilder patches that emitted signed intrinsics for certain unsigned operations only due to a detail in Embedded-C's implementation of fixedpoint support. Most things in IRBuilder don't have variant representations beyond what's expressed by the value type. The fact that we've chosen to do so here necessitates a more complex interface. > Regarding backend limitations, I guess I could propose an alternate solution. If we change FixedPointSemantics to strip the padding bit for both saturating and nonsaturating operations, it may be possible to detect in isel that the corresponding signed operation could be used instead when we promote the type of an unsigned one. For example, if we emit i15 umul.fix scale 15, we could tell in lowering that i16 smul.fix scale 15 is legal and use that instead. Same for all the other intrinsics, including the non-fixedpoint uadd.sat/usub.sat. > > The issue with this approach (which is why I didn't really want to do it) is that it's not testable. No upstream target has these intrinsics marked as legal. I doubt anyone would accept a patch with no tests. > It may also be less efficient than just emitting the signed operations in the first place, because we are forced to trunc and zext in IR before and after every operation. I don't want to tell you the best IR to use to get good code; I just want frontends to have a reasonably canonical interface to use that matches up well with the information we have. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82663/new/ https://reviews.llvm.org/D82663 From cfe-commits at lists.llvm.org Fri Jul 10 10:07:26 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:07:26 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: <1b3e7a82e972e93798bf383238255f80@localhost.localdomain> riccibruno requested changes to this revision. riccibruno added inline comments. This revision now requires changes to proceed. ================ Comment at: clang/lib/Serialization/ASTReaderStmt.cpp:275 + S->setLParenLoc(readSourceLocation()); + S->setRParenLoc(readSourceLocation()); } ---------------- The serialization part is missing (this is the reason for the test failures). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 From cfe-commits at lists.llvm.org Fri Jul 10 10:09:44 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:09:44 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman updated this revision to Diff 277084. dgoldman added a comment. Swap to getPreferredDecl and improve targetDecl Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/XRefs.cpp clang-tools-extra/clangd/unittests/FindTargetTests.cpp Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -608,6 +608,24 @@ )cpp"; EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface Foo"); + Code = R"cpp( + @interface Foo + @end + @implementation [[Foo]] + @end + )cpp"; + EXPECT_DECLS("ObjCImplementationDecl", "@interface Foo"); + + Code = R"cpp( + @interface Foo + @end + @interface Foo (Ext) + @end + @implementation [[Foo]] (Ext) + @end + )cpp"; + EXPECT_DECLS("ObjCCategoryImplDecl", "@interface Foo(Ext)"); + Code = R"cpp( @protocol Foo @end Index: clang-tools-extra/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/clangd/XRefs.cpp +++ clang-tools-extra/clangd/XRefs.cpp @@ -239,10 +239,10 @@ // - implementation: @implementation MyClass ... @end // // Clang will consider the forward declaration to be the canonical declaration -// because it is first, but we actually want the class definition if it is -// available since that is what a programmer would consider the real definition -// to be. -const NamedDecl *getNonStandardCanonicalDecl(const NamedDecl *D) { +// because it is first. We actually want the class definition if it is +// available since that is what a programmer would consider the primary +// declaration to be. +const NamedDecl *getPreferredDecl(const NamedDecl *D) { D = llvm::cast(D->getCanonicalDecl()); // Prefer Objective-C class definitions over the forward declaration. @@ -268,7 +268,7 @@ llvm::DenseMap ResultIndex; auto AddResultDecl = [&](const NamedDecl *D) { - D = getNonStandardCanonicalDecl(D); + D = getPreferredDecl(D); auto Loc = makeLocation(AST.getASTContext(), nameLocation(*D, SM), MainFilePath); if (!Loc) Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -270,6 +270,15 @@ // Record the underlying decl instead, if allowed. D = USD->getTargetDecl(); Flags |= Rel::Underlying; // continue with the underlying decl. + } else if (const ObjCImplementationDecl *IID = + dyn_cast(D)) { + // Objective-C implementation should map back to its interface. + D = IID->getClassInterface(); + } else if (const ObjCCategoryImplDecl *CID = + dyn_cast(D)) { + // Objective-C category implementation should map back to its category + // declaration. + D = CID->getCategoryDecl(); } if (const Decl *Pat = getTemplatePattern(D)) { -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.277084.patch Type: text/x-patch Size: 2899 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 10:12:17 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:12:17 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: <667c99f1ead004f5f48ade11f2b605c8@localhost.localdomain> dgoldman marked 5 inline comments as done and an inline comment as not done. dgoldman added inline comments. ================ Comment at: clang-tools-extra/clangd/FindTarget.cpp:273 Flags |= Rel::Underlying; // continue with the underlying decl. + } else if (const ObjCImplementationDecl *IID = + dyn_cast(D)) { ---------------- I think this is what you had in mind for findTarget, right? I guess though to be safe we should check D for nullptr before reporting below? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 From cfe-commits at lists.llvm.org Fri Jul 10 10:22:34 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:22:34 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: rjmccall added inline comments. ================ Comment at: clang/lib/CodeGen/CGCall.cpp:2515 + } else { + AI->addAttr(llvm::Attribute::NonNull); + } ---------------- aaron.ballman wrote: > rjmccall wrote: > > Isn't the old logic still correct? If the element size is static and the element count is positive, the argument is dereferenceable out to their product; otherwise it's nonnull if null is the zero value and we aren't semantically allowing that to be a valid pointer. > I was questioning this -- I didn't think the old logic was correct because it checks that the array is in address space 0, but the nonnull-ness should apply regardless of address space (I think). The point about valid null pointers still stands, though. Am I misunderstanding the intended address space behavior? I believe LLVM's `nonnull` actually always means nonzero. `static` just tells us that the address is valid, so (1) we always have to suppress the attribute under `NullPointerIsValid` and (2) we have the suppress the attribute if the null address is nonzero, because the zero address could still be valid in that case. The way the existing code is implementing the latter seems excessively conservative about non-standard address spaces, since we might know that they still use a zero null pointer; more importantly, it seems wrong in the face of an address space that lowers to LLVM's address space 0 but doesn't use a zero null pointer. You can call `getTargetInfo().getNullPointerValue(ETy.getAddressSpace()) == 0` to answer this more correctly. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 From cfe-commits at lists.llvm.org Fri Jul 10 10:23:10 2020 From: cfe-commits at lists.llvm.org (Arthur Eubanks via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:23:10 +0000 (UTC) Subject: [PATCH] D83519: [NewPM] Support optnone under new pass manager In-Reply-To: References: Message-ID: aeubanks added a comment. In D83519#2144463 , @aeubanks wrote: > In D83519#2144403 , @ychen wrote: > > > High-level request: how about split this patch into two, the first for the `require` pass part; the second for the PassInstrument callback. Then we could discuss the choices of first patch and D82344 . > > > Good idea, will split the patch and take a closer look at your patch. I split the required passes part into https://reviews.llvm.org/D83575. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83519/new/ https://reviews.llvm.org/D83519 From cfe-commits at lists.llvm.org Fri Jul 10 10:24:41 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via cfe-commits) Date: Fri, 10 Jul 2020 10:24:41 -0700 (PDT) Subject: [clang] 954db63 - [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM Message-ID: <5f08a459.1c69fb81.cc5e.011d@mx.google.com> Author: Luke Geeson Date: 2020-07-10T18:24:11+01:00 New Revision: 954db63cd149df031d9b660bf68f0fe1de1defb9 URL: https://github.com/llvm/llvm-project/commit/954db63cd149df031d9b660bf68f0fe1de1defb9 DIFF: https://github.com/llvm/llvm-project/commit/954db63cd149df031d9b660bf68f0fe1de1defb9.diff LOG: [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM This patch upstreams support for the Arm-v8 Cortex-A78 and Cortex-X1 processors for AArch64 and ARM. In detail: - Adding cortex-a78 and cortex-x1 as cpu options for aarch64 and arm targets in clang - Adding Cortex-A78 and Cortex-X1 CPU names and ProcessorModels in llvm details of the CPU can be found here: https://www.arm.com/products/cortex-x https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78 The following people contributed to this patch: - Luke Geeson - Mikhail Maltsev Reviewers: t.p.northover, dmgreen Reviewed By: dmgreen Subscribers: dmgreen, kristof.beyls, hiraditya, danielkiss, cfe-commits, llvm-commits, miyuki Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D83206 Added: Modified: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp Removed: ################################################################################ diff --git a/clang/test/Driver/aarch64-cpus.c b/clang/test/Driver/aarch64-cpus.c index 53b546265f6a..f39241bee8a6 100644 --- a/clang/test/Driver/aarch64-cpus.c +++ b/clang/test/Driver/aarch64-cpus.c @@ -173,6 +173,10 @@ // RUN: %clang -target aarch64 -mcpu=cortex-a77 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A77 %s // CORTEX-A77: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a77" +// RUN: %clang -target aarch64 -mcpu=cortex-x1 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXX1 %s +// CORTEXX1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x1" +// RUN: %clang -target aarch64 -mcpu=cortex-a78 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXA78 %s +// CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78" // RUN: %clang -target aarch64_be -mcpu=exynos-m3 -### -c %s 2>&1 | FileCheck -check-prefix=M3 %s // RUN: %clang -target aarch64 -mbig-endian -mcpu=exynos-m3 -### -c %s 2>&1 | FileCheck -check-prefix=M3 %s diff --git a/clang/test/Driver/arm-cortex-cpus.c b/clang/test/Driver/arm-cortex-cpus.c index d99526abe446..6de1040e9420 100644 --- a/clang/test/Driver/arm-cortex-cpus.c +++ b/clang/test/Driver/arm-cortex-cpus.c @@ -840,6 +840,18 @@ // CHECK-CORTEX-A76AE-SOFT: "-target-feature" "+soft-float" // CHECK-CORTEX-A76AE-SOFT: "-target-feature" "+soft-float-abi" +// RUN: %clang -target armv8a-arm-none-eabi -mcpu=cortex-x1 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-X1 %s +// RUN: %clang -target armv8a-arm-none-eabi -mcpu=cortex-x1 -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-X1-MFPU %s +// CHECK-CORTEX-X1: "-cc1"{{.*}} "-triple" "armv8.2a-{{.*}} "-target-cpu" "cortex-x1" +// CHECK-CORTEX-X1-MFPU: "-cc1"{{.*}} "-target-feature" "+fp-armv8" +// CHECK-CORTEX-X1-MFPU: "-target-feature" "+crypto" + +// RUN: %clang -target armv8a-arm-none-eabi -mcpu=cortex-a78 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A78 %s +// RUN: %clang -target armv8a-arm-none-eabi -mcpu=cortex-a78 -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CORTEX-A78-MFPU %s +// CHECK-CORTEX-A78: "-cc1"{{.*}} "-triple" "armv8.2a-{{.*}} "-target-cpu" "cortex-a78" +// CHECK-CORTEX-A78-MFPU: "-cc1"{{.*}} "-target-feature" "+fp-armv8" +// CHECK-CORTEX-A78-MFPU: "-target-feature" "+crypto" + // RUN: %clang -target arm -mcpu=cortex-m23 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV8MBASE %s // CHECK-CPUV8MBASE: "-cc1"{{.*}} "-triple" "thumbv8m.base- diff --git a/llvm/include/llvm/Support/AArch64TargetParser.def b/llvm/include/llvm/Support/AArch64TargetParser.def index 66843c6e1941..13b7cfc4b5cd 100644 --- a/llvm/include/llvm/Support/AArch64TargetParser.def +++ b/llvm/include/llvm/Support/AArch64TargetParser.def @@ -127,6 +127,12 @@ AARCH64_CPU_NAME("cortex-a76ae", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, AARCH64_CPU_NAME("cortex-a77", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_FP16 | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD | AArch64::AEK_SSBS)) +AARCH64_CPU_NAME("cortex-a78", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | + AArch64::AEK_SSBS)) +AARCH64_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | + AArch64::AEK_SSBS)) AARCH64_CPU_NAME("neoverse-e1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (AArch64::AEK_DOTPROD | AArch64::AEK_FP16 | AArch64::AEK_RAS | AArch64::AEK_RCPC | AArch64::AEK_SSBS)) diff --git a/llvm/include/llvm/Support/ARMTargetParser.def b/llvm/include/llvm/Support/ARMTargetParser.def index 7a81af72ad33..9f51c841e429 100644 --- a/llvm/include/llvm/Support/ARMTargetParser.def +++ b/llvm/include/llvm/Support/ARMTargetParser.def @@ -294,6 +294,10 @@ ARM_CPU_NAME("cortex-a76ae", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) ARM_CPU_NAME("cortex-a77", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) +ARM_CPU_NAME("cortex-a78",ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) +ARM_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, + (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) ARM_CPU_NAME("neoverse-n1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false, (ARM::AEK_FP16 | ARM::AEK_DOTPROD)) ARM_CPU_NAME("cyclone", ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC) diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index adfb599f55ff..8dc8c4e9775a 100644 --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -205,6 +205,8 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) { .Case("0xd0a", "cortex-a75") .Case("0xd0b", "cortex-a76") .Case("0xd0d", "cortex-a77") + .Case("0xd41", "cortex-a78") + .Case("0xd44", "cortex-x1") .Case("0xd0c", "neoverse-n1") .Default("generic"); } diff --git a/llvm/lib/Target/AArch64/AArch64.td b/llvm/lib/Target/AArch64/AArch64.td index da68e3ed17a2..534af9686af0 100644 --- a/llvm/lib/Target/AArch64/AArch64.td +++ b/llvm/lib/Target/AArch64/AArch64.td @@ -636,6 +636,36 @@ def ProcA77 : SubtargetFeature<"a77", "ARMProcFamily", "CortexA77", FeatureDotProd ]>; +def ProcA78 : SubtargetFeature<"cortex-a78", "ARMProcFamily", + "CortexA78", + "Cortex-A78 ARM processors", [ + HasV8_2aOps, + FeatureCrypto, + FeatureFPARMv8, + FeatureFuseAES, + FeatureNEON, + FeatureRCPC, + FeaturePerfMon, + FeaturePostRAScheduler, + FeatureSPE, + FeatureFullFP16, + FeatureSSBS, + FeatureDotProd]>; + +def ProcX1 : SubtargetFeature<"cortex-x1", "ARMProcFamily", "CortexX1", + "Cortex-X1 ARM processors", [ + HasV8_2aOps, + FeatureCrypto, + FeatureFPARMv8, + FeatureFuseAES, + FeatureNEON, + FeatureRCPC, + FeaturePerfMon, + FeaturePostRAScheduler, + FeatureSPE, + FeatureFullFP16, + FeatureDotProd]>; + def ProcA64FX : SubtargetFeature<"a64fx", "ARMProcFamily", "A64FX", "Fujitsu A64FX processors", [ HasV8_2aOps, @@ -978,6 +1008,8 @@ def : ProcessorModel<"cortex-a75", CortexA57Model, [ProcA75]>; def : ProcessorModel<"cortex-a76", CortexA57Model, [ProcA76]>; def : ProcessorModel<"cortex-a76ae", CortexA57Model, [ProcA76]>; def : ProcessorModel<"cortex-a77", CortexA57Model, [ProcA77]>; +def : ProcessorModel<"cortex-a78", CortexA57Model, [ProcA78]>; +def : ProcessorModel<"cortex-x1", CortexA57Model, [ProcX1]>; def : ProcessorModel<"neoverse-e1", CortexA53Model, [ProcNeoverseE1]>; def : ProcessorModel<"neoverse-n1", CortexA57Model, [ProcNeoverseN1]>; def : ProcessorModel<"exynos-m3", ExynosM3Model, [ProcExynosM3]>; diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp index 2f5abd76cc3a..029535cb98b5 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.cpp +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.cpp @@ -102,6 +102,8 @@ void AArch64Subtarget::initializeProperties() { case CortexA75: case CortexA76: case CortexA77: + case CortexA78: + case CortexX1: PrefFunctionLogAlignment = 4; break; case A64FX: diff --git a/llvm/lib/Target/AArch64/AArch64Subtarget.h b/llvm/lib/Target/AArch64/AArch64Subtarget.h index b7dc05e27e6a..b111f0016948 100644 --- a/llvm/lib/Target/AArch64/AArch64Subtarget.h +++ b/llvm/lib/Target/AArch64/AArch64Subtarget.h @@ -56,6 +56,8 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo { CortexA75, CortexA76, CortexA77, + CortexA78, + CortexX1, ExynosM3, Falkor, Kryo, diff --git a/llvm/lib/Target/ARM/ARM.td b/llvm/lib/Target/ARM/ARM.td index 90b581447372..0468f7f1cf8e 100644 --- a/llvm/lib/Target/ARM/ARM.td +++ b/llvm/lib/Target/ARM/ARM.td @@ -596,6 +596,10 @@ def ProcA76 : SubtargetFeature<"a76", "ARMProcFamily", "CortexA76", "Cortex-A76 ARM processors", []>; def ProcA77 : SubtargetFeature<"a77", "ARMProcFamily", "CortexA77", "Cortex-A77 ARM processors", []>; +def ProcA78 : SubtargetFeature<"cortex-a78", "ARMProcFamily", "CortexA78", + "Cortex-A78 ARM processors", []>; +def ProcX1 : SubtargetFeature<"cortex-x1", "ARMProcFamily", "CortexX1", + "Cortex-X1 ARM processors", []>; def ProcKrait : SubtargetFeature<"krait", "ARMProcFamily", "Krait", "Qualcomm Krait processors", []>; @@ -1234,6 +1238,22 @@ def : ProcNoItin<"cortex-a77", [ARMv82a, ProcA77, FeatureFullFP16, FeatureDotProd]>; +def : ProcNoItin<"cortex-a78", [ARMv82a, ProcA78, + FeatureHWDivThumb, + FeatureHWDivARM, + FeatureCrypto, + FeatureCRC, + FeatureFullFP16, + FeatureDotProd]>; + +def : ProcNoItin<"cortex-x1", [ARMv82a, ProcX1, + FeatureHWDivThumb, + FeatureHWDivARM, + FeatureCrypto, + FeatureCRC, + FeatureFullFP16, + FeatureDotProd]>; + def : ProcNoItin<"neoverse-n1", [ARMv82a, FeatureHWDivThumb, FeatureHWDivARM, diff --git a/llvm/lib/Target/ARM/ARMSubtarget.cpp b/llvm/lib/Target/ARM/ARMSubtarget.cpp index 3d828e55c869..46802037c2aa 100644 --- a/llvm/lib/Target/ARM/ARMSubtarget.cpp +++ b/llvm/lib/Target/ARM/ARMSubtarget.cpp @@ -293,12 +293,14 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { case CortexA75: case CortexA76: case CortexA77: + case CortexA78: case CortexR4: case CortexR4F: case CortexR5: case CortexR7: case CortexM3: case CortexR52: + case CortexX1: break; case Exynos: LdStMultipleTiming = SingleIssuePlusExtras; diff --git a/llvm/lib/Target/ARM/ARMSubtarget.h b/llvm/lib/Target/ARM/ARMSubtarget.h index c42356f28b65..2703e385dd81 100644 --- a/llvm/lib/Target/ARM/ARMSubtarget.h +++ b/llvm/lib/Target/ARM/ARMSubtarget.h @@ -62,6 +62,7 @@ class ARMSubtarget : public ARMGenSubtargetInfo { CortexA75, CortexA76, CortexA77, + CortexA78, CortexA8, CortexA9, CortexM3, @@ -70,6 +71,7 @@ class ARMSubtarget : public ARMGenSubtargetInfo { CortexR5, CortexR52, CortexR7, + CortexX1, Exynos, Krait, Kryo, diff --git a/llvm/test/CodeGen/AArch64/cpus.ll b/llvm/test/CodeGen/AArch64/cpus.ll index 107aca373923..3d4ad97b7fb2 100644 --- a/llvm/test/CodeGen/AArch64/cpus.ll +++ b/llvm/test/CodeGen/AArch64/cpus.ll @@ -16,6 +16,8 @@ ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a76ae 2>&1 | FileCheck %s ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a76 2>&1 | FileCheck %s ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a77 2>&1 | FileCheck %s +; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-a78 2>&1 | FileCheck %s +; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=cortex-x1 2>&1 | FileCheck %s ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-e1 2>&1 | FileCheck %s ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n1 2>&1 | FileCheck %s ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m3 2>&1 | FileCheck %s diff --git a/llvm/test/CodeGen/AArch64/remat.ll b/llvm/test/CodeGen/AArch64/remat.ll index 400be14b6e46..90ad2508fe17 100644 --- a/llvm/test/CodeGen/AArch64/remat.ll +++ b/llvm/test/CodeGen/AArch64/remat.ll @@ -9,6 +9,8 @@ ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a73 -o - %s | FileCheck %s ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a75 -o - %s | FileCheck %s ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a77 -o - %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-a78 -o - %s | FileCheck %s +; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=cortex-x1 -o - %s | FileCheck %s ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=neoverse-e1 -o - %s | FileCheck %s ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=neoverse-n1 -o - %s | FileCheck %s ; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=exynos-m3 -o - %s | FileCheck %s diff --git a/llvm/test/MC/AArch64/armv8.2a-dotprod.s b/llvm/test/MC/AArch64/armv8.2a-dotprod.s index 6315066efe58..3b9f416a63fb 100644 --- a/llvm/test/MC/AArch64/armv8.2a-dotprod.s +++ b/llvm/test/MC/AArch64/armv8.2a-dotprod.s @@ -5,6 +5,8 @@ // RUN: llvm-mc -triple aarch64 -mcpu=cortex-a75 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD // RUN: llvm-mc -triple aarch64 -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD // RUN: llvm-mc -triple aarch64 -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD +// RUN: llvm-mc -triple aarch64 -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD +// RUN: llvm-mc -triple aarch64 -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD // RUN: llvm-mc -triple aarch64 -mcpu=neoverse-e1 -show-encoding < %s| FileCheck %s --check-prefix=CHECK-DOTPROD // RUN: llvm-mc -triple aarch64 -mcpu=neoverse-n1 -show-encoding < %s| FileCheck %s --check-prefix=CHECK-DOTPROD // RUN: llvm-mc -triple aarch64 -mcpu=tsv110 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD @@ -19,6 +21,10 @@ // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s // RUN: not llvm-mc -triple aarch64 -mcpu=cortex-a77 -mattr=-dotprod -show-encoding < %s 2> %t // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s +// RUN: not llvm-mc -triple aarch64 -mcpu=cortex-a78 -mattr=-dotprod -show-encoding < %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s +// RUN: not llvm-mc -triple aarch64 -mcpu=cortex-x1 -mattr=-dotprod -show-encoding < %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s // RUN: not llvm-mc -triple aarch64 -mcpu=neoverse-n1 -mattr=-dotprod -show-encoding < %s 2> %t // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s diff --git a/llvm/test/MC/ARM/armv8.2a-dotprod-a32.s b/llvm/test/MC/ARM/armv8.2a-dotprod-a32.s index 748392630920..8ca2a97c602d 100644 --- a/llvm/test/MC/ARM/armv8.2a-dotprod-a32.s +++ b/llvm/test/MC/ARM/armv8.2a-dotprod-a32.s @@ -4,11 +4,17 @@ // RUN: llvm-mc -triple arm -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: llvm-mc -triple arm -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: llvm-mc -triple arm -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK +// RUN: llvm-mc -triple arm -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK +// RUN: llvm-mc -triple arm -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: not llvm-mc -triple arm -mattr=-dotprod -show-encoding < %s 2> %t // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s // RUN: not llvm-mc -triple arm -mcpu=cortex-a77 -mattr=-dotprod -show-encoding < %s 2> %t // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s +// RUN: not llvm-mc -triple arm -mcpu=cortex-a78 -mattr=-dotprod -show-encoding < %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s +// RUN: not llvm-mc -triple arm -mcpu=cortex-x1 -mattr=-dotprod -show-encoding < %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s // RUN: not llvm-mc -triple arm -show-encoding < %s 2> %t // RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s // RUN: not llvm-mc -triple arm -mattr=+v8.1a -show-encoding < %s 2> %t diff --git a/llvm/test/MC/ARM/armv8.2a-dotprod-t32.s b/llvm/test/MC/ARM/armv8.2a-dotprod-t32.s index 47837729eef6..8570a7be3150 100644 --- a/llvm/test/MC/ARM/armv8.2a-dotprod-t32.s +++ b/llvm/test/MC/ARM/armv8.2a-dotprod-t32.s @@ -3,6 +3,8 @@ // RUN: llvm-mc -triple thumb -mcpu=cortex-a75 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: llvm-mc -triple thumb -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: llvm-mc -triple thumb -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK +// RUN: llvm-mc -triple thumb -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK +// RUN: llvm-mc -triple thumb -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t diff --git a/llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt b/llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt index 1c41882119b3..8b0aac526999 100644 --- a/llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt +++ b/llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt @@ -5,6 +5,8 @@ # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s +# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a78 --disassemble < %s | FileCheck %s +# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s diff --git a/llvm/unittests/Support/TargetParserTest.cpp b/llvm/unittests/Support/TargetParserTest.cpp index b9736481e0e3..0127cb6ae009 100644 --- a/llvm/unittests/Support/TargetParserTest.cpp +++ b/llvm/unittests/Support/TargetParserTest.cpp @@ -262,6 +262,18 @@ TEST(TargetParserTest, testARMCPU) { ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 | ARM::AEK_RAS | ARM::AEK_DOTPROD, "8.2-A")); + EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8", + ARM::AEK_DOTPROD | ARM::AEK_FP16 | + ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | + ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | + ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS, + "8.2-A")); + EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8", + ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD | + ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | + ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | + ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS, + "8.2-A")); EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8", ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | @@ -310,7 +322,7 @@ TEST(TargetParserTest, testARMCPU) { "7-S")); } -static constexpr unsigned NumARMCPUArchs = 87; +static constexpr unsigned NumARMCPUArchs = 89; TEST(TargetParserTest, testARMCPUArchList) { SmallVector List; @@ -864,6 +876,20 @@ TEST(TargetParserTest, testAArch64CPU) { AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A")); + EXPECT_TRUE(testAArch64CPU( + "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8", + AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP | + AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS | + AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | + AArch64::AEK_RCPC | AArch64::AEK_SSBS, + "8.2-A")); + EXPECT_TRUE(testAArch64CPU( + "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8", + AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP | + AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS | + AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | + AArch64::AEK_RCPC | AArch64::AEK_SSBS, + "8.2-A")); EXPECT_TRUE(testAArch64CPU( "cyclone", "armv8-a", "crypto-neon-fp-armv8", AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A")); @@ -1002,7 +1028,7 @@ TEST(TargetParserTest, testAArch64CPU) { "8.2-A")); } -static constexpr unsigned NumAArch64CPUArchs = 40; +static constexpr unsigned NumAArch64CPUArchs = 42; TEST(TargetParserTest, testAArch64CPUArchList) { SmallVector List; From cfe-commits at lists.llvm.org Fri Jul 10 10:24:52 2020 From: cfe-commits at lists.llvm.org (Luke Geeson via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:24:52 +0000 (UTC) Subject: [PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM In-Reply-To: References: Message-ID: <4b26057b4954628a16e9bba2a7cb1c53@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG954db63cd149: [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM (authored by LukeGeeson). Changed prior to commit: https://reviews.llvm.org/D83206?vs=277074&id=277093#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83206/new/ https://reviews.llvm.org/D83206 Files: clang/test/Driver/aarch64-cpus.c clang/test/Driver/arm-cortex-cpus.c llvm/include/llvm/Support/AArch64TargetParser.def llvm/include/llvm/Support/ARMTargetParser.def llvm/lib/Support/Host.cpp llvm/lib/Target/AArch64/AArch64.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/Target/AArch64/AArch64Subtarget.h llvm/lib/Target/ARM/ARM.td llvm/lib/Target/ARM/ARMSubtarget.cpp llvm/lib/Target/ARM/ARMSubtarget.h llvm/test/CodeGen/AArch64/cpus.ll llvm/test/CodeGen/AArch64/remat.ll llvm/test/MC/AArch64/armv8.2a-dotprod.s llvm/test/MC/ARM/armv8.2a-dotprod-a32.s llvm/test/MC/ARM/armv8.2a-dotprod-t32.s llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt llvm/unittests/Support/TargetParserTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83206.277093.patch Type: text/x-patch Size: 21213 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 10:35:43 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:35:43 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: yaxunl updated this revision to Diff 277095. yaxunl marked 2 inline comments as done. yaxunl added a comment. Herald added a reviewer: dang. Separate detecting ROCm path and device library path. Assume 3.5 as default HIP version. If -rocm-path is specified, do not require version file to exist. Added --hip-version to override detected HIP version. Fixed default option for -std and -fhip-use-new-launch-api. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/CodeGen/CGCUDANV.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/HIP.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/ROCm.h clang/test/Driver/Inputs/rocm/bin/.hipVersion clang/test/Driver/hip-launch-api.hip clang/test/Driver/hip-std.hip clang/test/Driver/hip-version.hip clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-detect.hip clang/test/Driver/rocm-not-found.cl -------------- next part -------------- A non-text attachment was scrubbed... Name: D82930.277095.patch Type: text/x-patch Size: 31852 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 10:47:41 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:47:41 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman updated this revision to Diff 277100. dgoldman added a comment. Find target fixes + symbol collector test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/unittests/FindTargetTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -542,6 +542,29 @@ // Figure out why it's platform-dependent. } +TEST_F(SymbolCollectorTest, ObjCLocations) { + Annotations Header(R"( + // Declared in header, defined in main. + @interface $dogdecl[[Dog]] + @end + @interface $fluffydecl[[Dog]] (Fluffy) + @end + )"); + Annotations Main(R"( + @implementation $dogdef[[Dog]] + @end + @implementation $fluffydef[[Dog]] (Fluffy) + @end + )"); + runSymbolCollector(Header.code(), Main.code(), {"-xobjective-c++"}); + EXPECT_THAT(Symbols, + UnorderedElementsAre( + AllOf(QName("Dog"), DeclRange(Header.range("dogdecl")), + DefRange(Main.range("dogdef"))), + AllOf(QName("Fluffy"), DeclRange(Header.range("fluffydecl")), + DefRange(Main.range("fluffydef"))))); +} + TEST_F(SymbolCollectorTest, Locations) { Annotations Header(R"cpp( // Declared in header, defined in main. Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -614,7 +614,7 @@ @implementation [[Foo]] @end )cpp"; - EXPECT_DECLS("ObjCImplementationDecl", "@interface Foo"); + EXPECT_DECLS("ObjCImplementationDecl", {"@interface Foo", Rel::Underlying}); Code = R"cpp( @interface Foo @@ -624,7 +624,8 @@ @implementation [[Foo]] (Ext) @end )cpp"; - EXPECT_DECLS("ObjCCategoryImplDecl", "@interface Foo(Ext)"); + EXPECT_DECLS("ObjCCategoryImplDecl", + {"@interface Foo(Ext)", Rel::Underlying}); Code = R"cpp( @protocol Foo Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -274,11 +274,13 @@ dyn_cast(D)) { // Objective-C implementation should map back to its interface. D = IID->getClassInterface(); + Flags |= Rel::Underlying; } else if (const ObjCCategoryImplDecl *CID = dyn_cast(D)) { // Objective-C category implementation should map back to its category // declaration. D = CID->getCategoryDecl(); + Flags |= Rel::Underlying; } if (const Decl *Pat = getTemplatePattern(D)) { @@ -288,6 +290,8 @@ Flags |= Rel::TemplateInstantiation; } + if (!D) + return; report(D, Flags); } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.277100.patch Type: text/x-patch Size: 2896 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 10:52:14 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:52:14 +0000 (UTC) Subject: [PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM In-Reply-To: References: Message-ID: MaskRay added a comment. In D83013#2143470 , @hans wrote: > Still lgtm. For what it's worth, I think you could have just re-committed with the fixes rather than uploading for review again. This may be a difference of habits but I usually upload the last revision if it contains anything more than comment changes. The reviewed version might be read by posterity to get a quick overview about the patch. Browsing git log -p is not very convenient at times. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83013/new/ https://reviews.llvm.org/D83013 From cfe-commits at lists.llvm.org Fri Jul 10 10:58:17 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 17:58:17 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: dgoldman updated this revision to Diff 277103. dgoldman added a comment. Move up null check Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/FindTarget.cpp Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -282,6 +282,8 @@ D = CID->getCategoryDecl(); Flags |= Rel::Underlying; } + if (!D) + return; if (const Decl *Pat = getTemplatePattern(D)) { assert(Pat != D); @@ -290,8 +292,6 @@ Flags |= Rel::TemplateInstantiation; } - if (!D) - return; report(D, Flags); } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.277103.patch Type: text/x-patch Size: 536 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 11:02:05 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:02:05 +0000 (UTC) Subject: [PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes In-Reply-To: References: Message-ID: <45823de467cbba1b35453b0ba26e5798@localhost.localdomain> dgoldman updated this revision to Diff 277105. dgoldman added a comment. rebase, phabricator keeps getting confused Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83501/new/ https://reviews.llvm.org/D83501 Files: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/XRefs.cpp clang-tools-extra/clangd/unittests/FindTargetTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp clang-tools-extra/clangd/unittests/XRefsTests.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83501.277105.patch Type: text/x-patch Size: 7065 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 11:04:06 2020 From: cfe-commits at lists.llvm.org (Dmitri Gribenko via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:04:06 +0000 (UTC) Subject: [PATCH] D83513: [AST][ObjC] Fix crash when printing invalid objc categories In-Reply-To: References: Message-ID: <1cfb14c937ab1712252240525840bb62@localhost.localdomain> gribozavr2 accepted this revision. gribozavr2 added inline comments. This revision is now accepted and ready to land. ================ Comment at: clang/unittests/AST/DeclPrinterTest.cpp:180 + return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, "input.m", + /*PolicyModifier*/ nullptr, AllowError); } ---------------- `/*PolicyModifier=*/` (with equal sign) (also below for AllowError comments) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83513/new/ https://reviews.llvm.org/D83513 From cfe-commits at lists.llvm.org Fri Jul 10 11:04:33 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:04:33 +0000 (UTC) Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot In-Reply-To: References: Message-ID: <67cabda891aa6132dcd37e0c4b447874@localhost.localdomain> arsenm added a comment. In D82087#2140778 , @sameerds wrote: > The documentation for HIP __ballot seems to indicate that the user does not have to explicitly specify the warp size. How is that achieved with these new builtins? Can this be captured in a lit test here? This seems like a defect in the design to me > https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82087/new/ https://reviews.llvm.org/D82087 From cfe-commits at lists.llvm.org Fri Jul 10 11:05:00 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:05:00 +0000 (UTC) Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot In-Reply-To: References: Message-ID: arsenm marked 2 inline comments as done. arsenm added inline comments. ================ Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:288 + if (!IsNullCPU) { + // Default to wave32 if available, or wave64 if not + if (Features.count("wavefrontsize32") == 0 && ---------------- sameerds wrote: > So the implication here is that wave32 is the preferred choice on newer architectures, and hence the default when available? Yes, this has always been the case ================ Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:293 + "wavefrontsize32" : "wavefrontsize64"; + Features.insert(std::make_pair(DefaultWaveSizeFeature, true)); + } ---------------- yaxunl wrote: > what's the default wave front size in backend for gfx10* before this change? It's always been wave32 CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82087/new/ https://reviews.llvm.org/D82087 From cfe-commits at lists.llvm.org Fri Jul 10 11:05:30 2020 From: cfe-commits at lists.llvm.org (Anastasia Stulova via cfe-commits) Date: Fri, 10 Jul 2020 11:05:30 -0700 (PDT) Subject: [clang] 8c8a2fd - [OpenCL] Fixed typo for ctor stub name in UsersManual Message-ID: <5f08adea.1c69fb81.bfdf5.f278@mx.google.com> Author: Anastasia Stulova Date: 2020-07-10T19:04:49+01:00 New Revision: 8c8a2fd1f015525d048444610a6e27c66aa96293 URL: https://github.com/llvm/llvm-project/commit/8c8a2fd1f015525d048444610a6e27c66aa96293 DIFF: https://github.com/llvm/llvm-project/commit/8c8a2fd1f015525d048444610a6e27c66aa96293.diff LOG: [OpenCL] Fixed typo for ctor stub name in UsersManual Added: Modified: clang/docs/UsersManual.rst Removed: ################################################################################ diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst index 4b4e28a8b65c..8615a77596b4 100644 --- a/clang/docs/UsersManual.rst +++ b/clang/docs/UsersManual.rst @@ -3132,7 +3132,7 @@ Global objects must be constructed before the first kernel using the global obje is executed and destroyed just after the last kernel using the program objects is executed. In OpenCL v2.0 drivers there is no specific API for invoking global constructors. However, an easy workaround would be to enqueue a constructor -initialization kernel that has a name ``@_GLOBAL__sub_I_``. +initialization kernel that has a name ``_GLOBAL__sub_I_``. This kernel is only present if there are any global objects to be initialized in the compiled binary. One way to check this is by passing ``CL_PROGRAM_KERNEL_NAMES`` to ``clGetProgramInfo`` (OpenCL v2.0 s5.8.7). @@ -3148,7 +3148,7 @@ before running any kernels in which the objects are used. clang -cl-std=clc++ test.cl If there are any global objects to be initialized, the final binary will contain -the ``@_GLOBAL__sub_I_test.cl`` kernel to be enqueued. +the ``_GLOBAL__sub_I_test.cl`` kernel to be enqueued. Global destructors can not be invoked in OpenCL v2.0 drivers. However, all memory used for program scope objects is released on ``clReleaseProgram``. From cfe-commits at lists.llvm.org Fri Jul 10 11:12:40 2020 From: cfe-commits at lists.llvm.org (Matt Arsenault via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:12:40 +0000 (UTC) Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot In-Reply-To: References: Message-ID: <8e79f469570ec3cf61b874082154c556@localhost.localdomain> arsenm added a comment. In D82087#2140778 , @sameerds wrote: > The documentation for HIP __ballot seems to indicate that the user does not have to explicitly specify the warp size. How is that achieved with these new builtins? Can this be captured in a lit test here? > > https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions I think if the language interface insists on fixing the wave size, then I think the correct solution is to implement this in the header based on a wave size macro (which we're desperately missing). The library implementation should be responsible for inserting the extension to 64-bit for wave32 CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82087/new/ https://reviews.llvm.org/D82087 From cfe-commits at lists.llvm.org Fri Jul 10 11:19:16 2020 From: cfe-commits at lists.llvm.org (Steven Wan via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:19:16 +0000 (UTC) Subject: [PATCH] D83055: [clang][Driver] Fix tool path priority test failures In-Reply-To: References: Message-ID: <766a8266fb693be3bed6458fb0b66a94@localhost.localdomain> stevewan added inline comments. ================ Comment at: clang/test/Driver/program-path-priority.c:117 +/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple +// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \ +// RUN: mv %t/$DEFAULT_TRIPLE-gcc %t/prefix || true ---------------- DavidSpickett wrote: > stevewan wrote: > > Maybe I'm not seeing something obvious here, but I'm not aware of the `file -E` usage, and on Linux I got `file: invalid option -- 'E'`. > I was looking for a way to mimic [! -f ], which worked on the command line but not in a test. From my system's file: > -E On filesystem errors (file not found etc), instead of handling the error as regu‐ > lar output as POSIX mandates and keep going, issue an error message and exit. > > I didn't realise it was non-standard, so I've switched to mv || true with the error redirected so it won't confuse the verbose output. I believe having just `mv || true` works, but I did like the idea of pre-checking for the existence of the file, and the test is more robust with the check. Is there a reason we wouldn't use `test -f` here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83055/new/ https://reviews.llvm.org/D83055 From cfe-commits at lists.llvm.org Fri Jul 10 11:43:27 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 18:43:27 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: tra accepted this revision. tra added a comment. This revision is now accepted and ready to land. Herald added a subscriber: dexonsmith. LGTM in principle. Few style comments. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:161 + unsigned Minor = 0; + auto Splits = HIPVersionArg.split('.'); + Splits.first.getAsInteger(0, Major); ---------------- A comment about expected version format would be helpful here. Perhaps it could be simplified by splitting the string on "." into an array in one call instead of doing it one element at a time. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:244-257 + llvm::sys::path::append(LibDevicePath, "amdgcn", "bitcode"); + HasDeviceLibrary = CheckDeviceLib(); + if (HasDeviceLibrary) + return; + LibDevicePath = InstallPath; + llvm::sys::path::append(LibDevicePath, "lib"); + HasDeviceLibrary = CheckDeviceLib(); ---------------- It would be nice to collect the list of directories to check into an array and then loop over it -- the same way you already do for the InstallPath candidates. Makes it easier to add/change search logic. E.g. in the end we would get something like this: ``` for (path: {InstallPath, make_path(InstallPath, "lib"), make_path(InstallPath, "lib", "bitcode"), ... }) { if (CheckDeviceLib(path)) { // record path as the correct location return; } } ``` ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:248-249 + return; + LibDevicePath = InstallPath; + llvm::sys::path::append(LibDevicePath, "lib"); + HasDeviceLibrary = CheckDeviceLib(); ---------------- tra wrote: > `CheckDeviceLib` should probably take the path to check as an argument and so should `scanLibDevicePath`. > Creation of the path from base+suffixes seems to be a common pattern to be extracted into a lambda. I'm surprised it's not provided by LLVM itself. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:248-250 + LibDevicePath = InstallPath; + llvm::sys::path::append(LibDevicePath, "lib"); + HasDeviceLibrary = CheckDeviceLib(); ---------------- `CheckDeviceLib` should probably take the path to check as an argument and so should `scanLibDevicePath`. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:299 ArgStringList &CC1Args) const { + bool IsRocm35 = VersionMajorMinor <= llvm::VersionTuple(3, 5); + ---------------- Nit: `IsRocm35` is a bit misleading as it would be true for versions other than 3.5. Rename it to something closer matching the intent? `IsRocm35OrOlder` ot, perhaps, `hipUsesRuntimeWrapper`. ================ Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:333 + if (!IsRocm35) { + CC1Args.push_back("-include"); + CC1Args.push_back("__clang_hip_runtime_wrapper.h"); ---------------- You could use `CC1Args.append({"foo", "bar"})` here. ================ Comment at: clang/lib/Driver/ToolChains/HIP.cpp:283 // Find in --hip-device-lib-path and HIP_LIBRARY_PATH. - for (auto Path : - DriverArgs.getAllArgValues(options::OPT_hip_device_lib_path_EQ)) - LibraryPaths.push_back(DriverArgs.MakeArgString(Path)); + for (auto P : RocmInstallation.getRocmDeviceLibPathArg()) + LibraryPaths.push_back(DriverArgs.MakeArgString(P)); ---------------- Nit: `Path` was fine. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Fri Jul 10 12:02:53 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:02:53 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: oontvoo updated this revision to Diff 277115. oontvoo marked 3 inline comments as done. oontvoo added a comment. Added unit test and the missing serialisation code Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 Files: clang/include/clang/AST/Stmt.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Stmt.cpp clang/lib/Parse/ParseStmt.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/unittests/AST/SourceLocationTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83529.277115.patch Type: text/x-patch Size: 13556 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 12:07:31 2020 From: cfe-commits at lists.llvm.org (Hubert Tong via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:07:31 +0000 (UTC) Subject: [PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double In-Reply-To: References: Message-ID: hubert.reinterpretcast added inline comments. ================ Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1244 + if (!Base->Class->isEmpty() && !HandledFirstNonOverlappingEmptyField) { + IsFirstNonEmptyBase = true; + // By handling a base class that is not empty, we're handling the ---------------- `IsFirstNonEmptyBase` can be removed. It is set, but not used. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79719/new/ https://reviews.llvm.org/D79719 From cfe-commits at lists.llvm.org Fri Jul 10 12:10:34 2020 From: cfe-commits at lists.llvm.org (Erik Pilkington via cfe-commits) Date: Fri, 10 Jul 2020 12:10:34 -0700 (PDT) Subject: [clang] dafc310 - [Sema] Emit a -Wformat warning for printf("%s", (void*)p) Message-ID: <5f08bd2a.1c69fb81.38726.f93b@mx.google.com> Author: Erik Pilkington Date: 2020-07-10T15:10:24-04:00 New Revision: dafc3106d2069b806a10e072306a2196f1cda585 URL: https://github.com/llvm/llvm-project/commit/dafc3106d2069b806a10e072306a2196f1cda585 DIFF: https://github.com/llvm/llvm-project/commit/dafc3106d2069b806a10e072306a2196f1cda585.diff LOG: [Sema] Emit a -Wformat warning for printf("%s", (void*)p) Its dangerous to assume that the opaque pointer points to a null-terminated string, and this has an easy fix (casting to char*). rdar://62432331 Added: Modified: clang/lib/AST/FormatString.cpp clang/test/Sema/format-strings.c Removed: ################################################################################ diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp index e9f6b88631af..83b952116a5e 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -419,7 +419,6 @@ ArgType::matchesType(ASTContext &C, QualType argTy) const { QualType pointeeTy = PT->getPointeeType(); if (const BuiltinType *BT = pointeeTy->getAs()) switch (BT->getKind()) { - case BuiltinType::Void: case BuiltinType::Char_U: case BuiltinType::UChar: case BuiltinType::Char_S: diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index 11acfcd1b9a6..e8cd478d2512 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -290,8 +290,11 @@ void test11(void *p, char *s) { printf("%0p", p); // expected-warning{{flag '0' results in undefined behavior with 'p' conversion specifier}} printf("%s", s); // no-warning printf("%+s", p); // expected-warning{{flag '+' results in undefined behavior with 's' conversion specifier}} + // expected-warning at -1 {{format specifies type 'char *' but the argument has type 'void *'}} printf("% s", p); // expected-warning{{flag ' ' results in undefined behavior with 's' conversion specifier}} + // expected-warning at -1 {{format specifies type 'char *' but the argument has type 'void *'}} printf("%0s", p); // expected-warning{{flag '0' results in undefined behavior with 's' conversion specifier}} + // expected-warning at -1 {{format specifies type 'char *' but the argument has type 'void *'}} } void test12(char *b) { @@ -707,3 +710,7 @@ void PR30481() { // This caused crashes due to invalid casts. printf(1 > 0); // expected-warning{{format string is not a string literal}} expected-warning{{incompatible integer to pointer conversion}} expected-note at format-strings.c:*{{passing argument to parameter here}} expected-note{{to avoid this}} } + +void test_printf_opaque_ptr(void *op) { + printf("%s", op); // expected-warning{{format specifies type 'char *' but the argument has type 'void *'}} +} From cfe-commits at lists.llvm.org Fri Jul 10 12:18:17 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:18:17 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: aaron.ballman updated this revision to Diff 277120. aaron.ballman marked an inline comment as done. aaron.ballman added a comment. Updated based on review feedback. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/CodeGen/CGCall.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/vla.c clang/test/Sema/static-array.c Index: clang/test/Sema/static-array.c =================================================================== --- clang/test/Sema/static-array.c +++ clang/test/Sema/static-array.c @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -pedantic -verify %s -void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}} +void cat0(int a[static 0]) {} // expected-warning {{zero size arrays are an extension}} \ + // expected-note {{callee declares array parameter as static here}} void cat(int a[static 3]) {} // expected-note 4 {{callee declares array parameter as static here}} expected-note 2 {{passing argument to parameter 'a' here}} @@ -9,7 +10,7 @@ void f(int *p) { int a[2], b[3], c[4]; - cat0(0); + cat0(0); // expected-warning {{null passed to a callee that requires a non-null argument}} cat(0); // expected-warning {{null passed to a callee that requires a non-null argument}} cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}} Index: clang/test/CodeGen/vla.c =================================================================== --- clang/test/CodeGen/vla.c +++ clang/test/CodeGen/vla.c @@ -206,3 +206,7 @@ // NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a) // NULL-VALID: define void @test9(i32 %n, i32* %a) +// Make sure a zero-sized static array extent is still required to be nonnull. +void test10(int a[static 0]) {} +// NULL-INVALID: define void @test10(i32* nonnull %a) +// NULL-VALID: define void @test10(i32* %a) Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -2393,13 +2393,6 @@ ? diag::err_typecheck_zero_array_size : diag::ext_typecheck_zero_array_size) << ArraySize->getSourceRange(); - - if (ASM == ArrayType::Static) { - Diag(ArraySize->getBeginLoc(), - diag::warn_typecheck_zero_static_array_size) - << ArraySize->getSourceRange(); - ASM = ArrayType::Normal; - } } else if (!T->isDependentType() && !T->isVariablyModifiedType() && !T->isIncompleteType() && !T->isUndeducedType()) { // Is the array too large? Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -2504,9 +2504,11 @@ ArrSize) { llvm::AttrBuilder Attrs; Attrs.addDereferenceableAttr( - getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize); + getContext().getTypeSizeInChars(ETy).getQuantity() * + ArrSize); AI->addAttrs(Attrs); - } else if (getContext().getTargetAddressSpace(ETy) == 0 && + } else if (getContext().getTargetInfo().getNullPointerValue( + ETy.getAddressSpace()) == 0 && !CGM.getCodeGenOpts().NullPointerIsValid) { AI->addAttr(llvm::Attribute::NonNull); } Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5395,9 +5395,6 @@ "zero size arrays are an extension">, InGroup; def err_typecheck_zero_array_size : Error< "zero-length arrays are not permitted in C++">; -def warn_typecheck_zero_static_array_size : Warning< - "'static' has no effect on zero-length arrays">, - InGroup; def err_array_size_non_int : Error<"size of array has non-integer type %0">; def err_init_element_not_constant : Error< "initializer element is not a compile-time constant">; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83502.277120.patch Type: text/x-patch Size: 4127 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 12:18:20 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:18:20 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: aaron.ballman added inline comments. ================ Comment at: clang/lib/CodeGen/CGCall.cpp:2515 + } else { + AI->addAttr(llvm::Attribute::NonNull); + } ---------------- rjmccall wrote: > aaron.ballman wrote: > > rjmccall wrote: > > > Isn't the old logic still correct? If the element size is static and the element count is positive, the argument is dereferenceable out to their product; otherwise it's nonnull if null is the zero value and we aren't semantically allowing that to be a valid pointer. > > I was questioning this -- I didn't think the old logic was correct because it checks that the array is in address space 0, but the nonnull-ness should apply regardless of address space (I think). The point about valid null pointers still stands, though. Am I misunderstanding the intended address space behavior? > I believe LLVM's `nonnull` actually always means nonzero. `static` just tells us that the address is valid, so (1) we always have to suppress the attribute under `NullPointerIsValid` and (2) we have the suppress the attribute if the null address is nonzero, because the zero address could still be valid in that case. The way the existing code is implementing the latter seems excessively conservative about non-standard address spaces, since we might know that they still use a zero null pointer; more importantly, it seems wrong in the face of an address space that lowers to LLVM's address space 0 but doesn't use a zero null pointer. You can call `getTargetInfo().getNullPointerValue(ETy.getAddressSpace()) == 0` to answer this more correctly. Ah, I see! Thank you for the explanation -- I wasn't aware that null could be a valid address in other address spaces, but that makes sense. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 From cfe-commits at lists.llvm.org Fri Jul 10 12:22:53 2020 From: cfe-commits at lists.llvm.org (Sebastian Neubauer via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:22:53 +0000 (UTC) Subject: [PATCH] D81728: [InstCombine] Add target-specific inst combining In-Reply-To: References: Message-ID: <6e8b02f127ad4a766c5a81ce99096b00@localhost.localdomain> Flakebi marked an inline comment as done. Flakebi added inline comments. ================ Comment at: llvm/include/llvm/Analysis/TargetTransformInfo.h:540 + bool instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II, + Instruction **ResultI) const; + bool simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II, ---------------- nikic wrote: > For all three functions, the calling convention seems rather non-idiomatic for InstCombine. Rather than having an `Instruction **` argument and bool result, is there any reason not to have an `Instruction *` return value, with nullptr indicating that the intrinsic couldn't be simplified? Yes, the function must have the option to return a nullptr and prevent that `visitCallBase` is called or other code is executed after `instCombineIntrinsic`. So, somehow the caller must be able to see a difference between 'do nothing, just continue execution' and 'return this Instruction*', where the `Instruction*` can also be a nullptr. The return type could be an `optional`. I’ll take a look at your other comments on Monday. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81728/new/ https://reviews.llvm.org/D81728 From cfe-commits at lists.llvm.org Fri Jul 10 12:36:47 2020 From: cfe-commits at lists.llvm.org (David Goldman via cfe-commits) Date: Fri, 10 Jul 2020 12:36:47 -0700 (PDT) Subject: [clang] ea201e8 - [AST][ObjC] Fix crash when printing invalid objc categories Message-ID: <5f08c34f.1c69fb81.e240a.0c4c@mx.google.com> Author: David Goldman Date: 2020-07-10T15:35:14-04:00 New Revision: ea201e83e292f39c3ee7fe8810a348ee98000398 URL: https://github.com/llvm/llvm-project/commit/ea201e83e292f39c3ee7fe8810a348ee98000398 DIFF: https://github.com/llvm/llvm-project/commit/ea201e83e292f39c3ee7fe8810a348ee98000398.diff LOG: [AST][ObjC] Fix crash when printing invalid objc categories Summary: If no valid interface definition was found previously we would crash. With this change instead we just print `<>` in place of the NULL interface. In the future this could be improved by saving the invalid interface's name and using that. Reviewers: sammccall, gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83513 Added: Modified: clang/lib/AST/DeclPrinter.cpp clang/unittests/AST/DeclPrinterTest.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp index 4df6512e6c76..2e48b2b46c4d 100644 --- a/clang/lib/AST/DeclPrinter.cpp +++ b/clang/lib/AST/DeclPrinter.cpp @@ -1374,7 +1374,12 @@ void DeclPrinter::VisitObjCProtocolDecl(ObjCProtocolDecl *PID) { } void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { - Out << "@implementation " << *PID->getClassInterface() << '(' << *PID <<")\n"; + Out << "@implementation "; + if (const auto *CID = PID->getClassInterface()) + Out << *CID; + else + Out << "<>"; + Out << '(' << *PID << ")\n"; VisitDeclContext(PID, false); Out << "@end"; @@ -1382,7 +1387,11 @@ void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { } void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) { - Out << "@interface " << *PID->getClassInterface(); + Out << "@interface "; + if (const auto *CID = PID->getClassInterface()) + Out << *CID; + else + Out << "<>"; if (auto TypeParams = PID->getTypeParamList()) { PrintObjCTypeParams(TypeParams); } diff --git a/clang/unittests/AST/DeclPrinterTest.cpp b/clang/unittests/AST/DeclPrinterTest.cpp index 018e99237ae9..939c8b52c12c 100644 --- a/clang/unittests/AST/DeclPrinterTest.cpp +++ b/clang/unittests/AST/DeclPrinterTest.cpp @@ -76,14 +76,16 @@ ::testing::AssertionResult PrintedDeclMatches(StringRef Code, const std::vector &Args, const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted, StringRef FileName, - PrintingPolicyModifier PolicyModifier = nullptr) { + PrintingPolicyModifier PolicyModifier = nullptr, + bool AllowError = false) { PrintMatch Printer(PolicyModifier); MatchFinder Finder; Finder.addMatcher(NodeMatch, &Printer); std::unique_ptr Factory( newFrontendActionFactory(&Finder)); - if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName) && + !AllowError) return testing::AssertionFailure() << "Parsing error in \"" << Code.str() << "\""; @@ -170,16 +172,12 @@ PrintedDeclCXX1ZMatches(StringRef Code, const DeclarationMatcher &NodeMatch, "input.cc"); } -::testing::AssertionResult PrintedDeclObjCMatches( - StringRef Code, - const DeclarationMatcher &NodeMatch, - StringRef ExpectedPrinted) { +::testing::AssertionResult +PrintedDeclObjCMatches(StringRef Code, const DeclarationMatcher &NodeMatch, + StringRef ExpectedPrinted, bool AllowError = false) { std::vector Args(1, ""); - return PrintedDeclMatches(Code, - Args, - NodeMatch, - ExpectedPrinted, - "input.m"); + return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, "input.m", + /*PolicyModifier=*/nullptr, AllowError); } } // unnamed namespace @@ -1321,3 +1319,17 @@ TEST(DeclPrinter, TestObjCProtocol2) { namedDecl(hasName("P1")).bind("id"), "@protocol P1\n at end")); } + +TEST(DeclPrinter, TestObjCCategoryInvalidInterface) { + ASSERT_TRUE(PrintedDeclObjCMatches( + "@interface I (Extension) @end", + namedDecl(hasName("Extension")).bind("id"), + "@interface <>(Extension)\n at end", /*AllowError=*/true)); +} + +TEST(DeclPrinter, TestObjCCategoryImplInvalidInterface) { + ASSERT_TRUE(PrintedDeclObjCMatches( + "@implementation I (Extension) @end", + namedDecl(hasName("Extension")).bind("id"), + "@implementation <>(Extension)\n at end", /*AllowError=*/true)); +} From cfe-commits at lists.llvm.org Fri Jul 10 12:36:53 2020 From: cfe-commits at lists.llvm.org (David Goldman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:36:53 +0000 (UTC) Subject: [PATCH] D83513: [AST][ObjC] Fix crash when printing invalid objc categories In-Reply-To: References: Message-ID: <3640836d3fbdb3b9b82ee0bd4530b257@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGea201e83e292: [AST][ObjC] Fix crash when printing invalid objc categories (authored by dgoldman). Changed prior to commit: https://reviews.llvm.org/D83513?vs=276841&id=277126#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83513/new/ https://reviews.llvm.org/D83513 Files: clang/lib/AST/DeclPrinter.cpp clang/unittests/AST/DeclPrinterTest.cpp Index: clang/unittests/AST/DeclPrinterTest.cpp =================================================================== --- clang/unittests/AST/DeclPrinterTest.cpp +++ clang/unittests/AST/DeclPrinterTest.cpp @@ -76,14 +76,16 @@ PrintedDeclMatches(StringRef Code, const std::vector &Args, const DeclarationMatcher &NodeMatch, StringRef ExpectedPrinted, StringRef FileName, - PrintingPolicyModifier PolicyModifier = nullptr) { + PrintingPolicyModifier PolicyModifier = nullptr, + bool AllowError = false) { PrintMatch Printer(PolicyModifier); MatchFinder Finder; Finder.addMatcher(NodeMatch, &Printer); std::unique_ptr Factory( newFrontendActionFactory(&Finder)); - if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName)) + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args, FileName) && + !AllowError) return testing::AssertionFailure() << "Parsing error in \"" << Code.str() << "\""; @@ -170,16 +172,12 @@ "input.cc"); } -::testing::AssertionResult PrintedDeclObjCMatches( - StringRef Code, - const DeclarationMatcher &NodeMatch, - StringRef ExpectedPrinted) { +::testing::AssertionResult +PrintedDeclObjCMatches(StringRef Code, const DeclarationMatcher &NodeMatch, + StringRef ExpectedPrinted, bool AllowError = false) { std::vector Args(1, ""); - return PrintedDeclMatches(Code, - Args, - NodeMatch, - ExpectedPrinted, - "input.m"); + return PrintedDeclMatches(Code, Args, NodeMatch, ExpectedPrinted, "input.m", + /*PolicyModifier=*/nullptr, AllowError); } } // unnamed namespace @@ -1321,3 +1319,17 @@ namedDecl(hasName("P1")).bind("id"), "@protocol P1\n at end")); } + +TEST(DeclPrinter, TestObjCCategoryInvalidInterface) { + ASSERT_TRUE(PrintedDeclObjCMatches( + "@interface I (Extension) @end", + namedDecl(hasName("Extension")).bind("id"), + "@interface <>(Extension)\n at end", /*AllowError=*/true)); +} + +TEST(DeclPrinter, TestObjCCategoryImplInvalidInterface) { + ASSERT_TRUE(PrintedDeclObjCMatches( + "@implementation I (Extension) @end", + namedDecl(hasName("Extension")).bind("id"), + "@implementation <>(Extension)\n at end", /*AllowError=*/true)); +} Index: clang/lib/AST/DeclPrinter.cpp =================================================================== --- clang/lib/AST/DeclPrinter.cpp +++ clang/lib/AST/DeclPrinter.cpp @@ -1374,7 +1374,12 @@ } void DeclPrinter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *PID) { - Out << "@implementation " << *PID->getClassInterface() << '(' << *PID <<")\n"; + Out << "@implementation "; + if (const auto *CID = PID->getClassInterface()) + Out << *CID; + else + Out << "<>"; + Out << '(' << *PID << ")\n"; VisitDeclContext(PID, false); Out << "@end"; @@ -1382,7 +1387,11 @@ } void DeclPrinter::VisitObjCCategoryDecl(ObjCCategoryDecl *PID) { - Out << "@interface " << *PID->getClassInterface(); + Out << "@interface "; + if (const auto *CID = PID->getClassInterface()) + Out << *CID; + else + Out << "<>"; if (auto TypeParams = PID->getTypeParamList()) { PrintObjCTypeParams(TypeParams); } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83513.277126.patch Type: text/x-patch Size: 3581 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 12:37:48 2020 From: cfe-commits at lists.llvm.org (Albion Fung via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:37:48 +0000 (UTC) Subject: [PATCH] D83516: [PowerPC][Power10] Vector shift Instruction definitions and MC Tests In-Reply-To: References: Message-ID: <528e306c06201000dceef7d02198a229@localhost.localdomain> Conanap updated this revision to Diff 277127. Conanap added a comment. Added a new line to the end of ppc64-encoding-ISA31.txt Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83516/new/ https://reviews.llvm.org/D83516 Files: llvm/lib/Target/PowerPC/PPCInstrPrefix.td llvm/test/MC/Disassembler/PowerPC/ppc64-encoding-ISA31.txt llvm/test/MC/PowerPC/ppc64-encoding-ISA31.s -------------- next part -------------- A non-text attachment was scrubbed... Name: D83516.277127.patch Type: text/x-patch Size: 11966 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 12:43:23 2020 From: cfe-commits at lists.llvm.org (Alina Sbirlea via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:43:23 +0000 (UTC) Subject: [PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff. In-Reply-To: References: Message-ID: asbirlea added a comment. Thank you for the testing. Could you help with with instructions on how to run the tracker myself? My local testing showed a negligible regression for mafft and a negligible improvement on other benchmarks, so it looked like noise on average. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77341/new/ https://reviews.llvm.org/D77341 From cfe-commits at lists.llvm.org Fri Jul 10 12:47:11 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:47:11 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Thanks, LGTM. ================ Comment at: clang/lib/CodeGen/CGCall.cpp:2515 + } else { + AI->addAttr(llvm::Attribute::NonNull); + } ---------------- aaron.ballman wrote: > rjmccall wrote: > > aaron.ballman wrote: > > > rjmccall wrote: > > > > Isn't the old logic still correct? If the element size is static and the element count is positive, the argument is dereferenceable out to their product; otherwise it's nonnull if null is the zero value and we aren't semantically allowing that to be a valid pointer. > > > I was questioning this -- I didn't think the old logic was correct because it checks that the array is in address space 0, but the nonnull-ness should apply regardless of address space (I think). The point about valid null pointers still stands, though. Am I misunderstanding the intended address space behavior? > > I believe LLVM's `nonnull` actually always means nonzero. `static` just tells us that the address is valid, so (1) we always have to suppress the attribute under `NullPointerIsValid` and (2) we have the suppress the attribute if the null address is nonzero, because the zero address could still be valid in that case. The way the existing code is implementing the latter seems excessively conservative about non-standard address spaces, since we might know that they still use a zero null pointer; more importantly, it seems wrong in the face of an address space that lowers to LLVM's address space 0 but doesn't use a zero null pointer. You can call `getTargetInfo().getNullPointerValue(ETy.getAddressSpace()) == 0` to answer this more correctly. > Ah, I see! Thank you for the explanation -- I wasn't aware that null could be a valid address in other address spaces, but that makes sense. (the zero representation, not null) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 From cfe-commits at lists.llvm.org Fri Jul 10 12:58:24 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via cfe-commits) Date: Fri, 10 Jul 2020 12:58:24 -0700 (PDT) Subject: [clang] 006c49d - Change behavior with zero-sized static array extents Message-ID: <5f08c860.1c69fb81.eb4a1.f9c1@mx.google.com> Author: Aaron Ballman Date: 2020-07-10T15:58:11-04:00 New Revision: 006c49d890da633d1ce502117fc2a49863cd65b7 URL: https://github.com/llvm/llvm-project/commit/006c49d890da633d1ce502117fc2a49863cd65b7 DIFF: https://github.com/llvm/llvm-project/commit/006c49d890da633d1ce502117fc2a49863cd65b7.diff LOG: Change behavior with zero-sized static array extents Currently, Clang previously diagnosed this code by default: void f(int a[static 0]); saying that "static has no effect on zero-length arrays", which was accurate. However, static array extents require that the caller of the function pass a nonnull pointer to an array of *at least* that number of elements, but it can pass more (see C17 6.7.6.3p6). Given that we allow zero-sized arrays as a GNU extension and that it's valid to pass more elements than specified by the static array extent, we now support zero-sized static array extents with the usual semantics because it can be useful in cases like: void my_bzero(char p[static 0], int n); my_bzero(&c+1, 0); //ok my_bzero(t+k,n-k); //ok, pattern from actual code Added: Modified: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/CodeGen/CGCall.cpp clang/lib/Sema/SemaType.cpp clang/test/CodeGen/vla.c clang/test/Sema/static-array.c Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 29408be6881f..24e942037ecf 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5395,9 +5395,6 @@ def ext_typecheck_zero_array_size : Extension< "zero size arrays are an extension">, InGroup; def err_typecheck_zero_array_size : Error< "zero-length arrays are not permitted in C++">; -def warn_typecheck_zero_static_array_size : Warning< - "'static' has no effect on zero-length arrays">, - InGroup; def err_array_size_non_int : Error<"size of array has non-integer type %0">; def err_init_element_not_constant : Error< "initializer element is not a compile-time constant">; diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 7af986981e5b..e8235c775d8f 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2504,9 +2504,11 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, ArrSize) { llvm::AttrBuilder Attrs; Attrs.addDereferenceableAttr( - getContext().getTypeSizeInChars(ETy).getQuantity()*ArrSize); + getContext().getTypeSizeInChars(ETy).getQuantity() * + ArrSize); AI->addAttrs(Attrs); - } else if (getContext().getTargetAddressSpace(ETy) == 0 && + } else if (getContext().getTargetInfo().getNullPointerValue( + ETy.getAddressSpace()) == 0 && !CGM.getCodeGenOpts().NullPointerIsValid) { AI->addAttr(llvm::Attribute::NonNull); } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index b8a787f010d6..b8f7f1a58159 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2393,13 +2393,6 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, ? diag::err_typecheck_zero_array_size : diag::ext_typecheck_zero_array_size) << ArraySize->getSourceRange(); - - if (ASM == ArrayType::Static) { - Diag(ArraySize->getBeginLoc(), - diag::warn_typecheck_zero_static_array_size) - << ArraySize->getSourceRange(); - ASM = ArrayType::Normal; - } } else if (!T->isDependentType() && !T->isVariablyModifiedType() && !T->isIncompleteType() && !T->isUndeducedType()) { // Is the array too large? diff --git a/clang/test/CodeGen/vla.c b/clang/test/CodeGen/vla.c index 37243cd17290..16b82f4acc7d 100644 --- a/clang/test/CodeGen/vla.c +++ b/clang/test/CodeGen/vla.c @@ -206,3 +206,7 @@ void test9(int n, int a[static n]) { } // NULL-INVALID: define void @test9(i32 %n, i32* nonnull %a) // NULL-VALID: define void @test9(i32 %n, i32* %a) +// Make sure a zero-sized static array extent is still required to be nonnull. +void test10(int a[static 0]) {} +// NULL-INVALID: define void @test10(i32* nonnull %a) +// NULL-VALID: define void @test10(i32* %a) diff --git a/clang/test/Sema/static-array.c b/clang/test/Sema/static-array.c index cc1043fe9c47..ef070718dc63 100644 --- a/clang/test/Sema/static-array.c +++ b/clang/test/Sema/static-array.c @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14.0 -fsyntax-only -fblocks -pedantic -verify %s -void cat0(int a[static 0]) {} // expected-warning {{'static' has no effect on zero-length arrays}} +void cat0(int a[static 0]) {} // expected-warning {{zero size arrays are an extension}} \ + // expected-note {{callee declares array parameter as static here}} void cat(int a[static 3]) {} // expected-note 4 {{callee declares array parameter as static here}} expected-note 2 {{passing argument to parameter 'a' here}} @@ -9,7 +10,7 @@ void vat(int i, int a[static i]) {} // expected-note {{callee declares array par void f(int *p) { int a[2], b[3], c[4]; - cat0(0); + cat0(0); // expected-warning {{null passed to a callee that requires a non-null argument}} cat(0); // expected-warning {{null passed to a callee that requires a non-null argument}} cat(a); // expected-warning {{array argument is too small; contains 2 elements, callee requires at least 3}} From cfe-commits at lists.llvm.org Fri Jul 10 12:59:31 2020 From: cfe-commits at lists.llvm.org (Aaron Ballman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 19:59:31 +0000 (UTC) Subject: [PATCH] D83502: Change behavior with zero-sized static array extents In-Reply-To: References: Message-ID: <4f253b235d6c28fa3ddea3c9efa3dad2@localhost.localdomain> aaron.ballman closed this revision. aaron.ballman marked an inline comment as done. aaron.ballman added a comment. Thanks for the review, I've gone ahead and committed in 006c49d890da633d1ce502117fc2a49863cd65b7 ================ Comment at: clang/lib/CodeGen/CGCall.cpp:2515 + } else { + AI->addAttr(llvm::Attribute::NonNull); + } ---------------- rjmccall wrote: > aaron.ballman wrote: > > rjmccall wrote: > > > aaron.ballman wrote: > > > > rjmccall wrote: > > > > > Isn't the old logic still correct? If the element size is static and the element count is positive, the argument is dereferenceable out to their product; otherwise it's nonnull if null is the zero value and we aren't semantically allowing that to be a valid pointer. > > > > I was questioning this -- I didn't think the old logic was correct because it checks that the array is in address space 0, but the nonnull-ness should apply regardless of address space (I think). The point about valid null pointers still stands, though. Am I misunderstanding the intended address space behavior? > > > I believe LLVM's `nonnull` actually always means nonzero. `static` just tells us that the address is valid, so (1) we always have to suppress the attribute under `NullPointerIsValid` and (2) we have the suppress the attribute if the null address is nonzero, because the zero address could still be valid in that case. The way the existing code is implementing the latter seems excessively conservative about non-standard address spaces, since we might know that they still use a zero null pointer; more importantly, it seems wrong in the face of an address space that lowers to LLVM's address space 0 but doesn't use a zero null pointer. You can call `getTargetInfo().getNullPointerValue(ETy.getAddressSpace()) == 0` to answer this more correctly. > > Ah, I see! Thank you for the explanation -- I wasn't aware that null could be a valid address in other address spaces, but that makes sense. > (the zero representation, not null) Agreed -- sorry for being imprecise when it mattered. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83502/new/ https://reviews.llvm.org/D83502 From cfe-commits at lists.llvm.org Fri Jul 10 13:00:43 2020 From: cfe-commits at lists.llvm.org (Lei Huang via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 20:00:43 +0000 (UTC) Subject: [PATCH] D83516: [PowerPC][Power10] 128-bit Binary Integer Operation instruction definitions and MC Tests In-Reply-To: References: Message-ID: <85c4d655fb230e33118f58b148fc9a8f@localhost.localdomain> lei accepted this revision. lei added a comment. This revision is now accepted and ready to land. LGTM Please address the nits on commit. ================ Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:1022 + def XSCVUQQP : X_VT5_XO5_VB5<63, 3, 836, "xscvuqqp", []>; + def XSCVSQQP: X_VT5_XO5_VB5<63, 11, 836, "xscvsqqp", []>; } ---------------- nit: looks like there's a mix of diff spacings in the section above. Please keep it consistent. It should be `def NAME : DEF` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83516/new/ https://reviews.llvm.org/D83516 From cfe-commits at lists.llvm.org Fri Jul 10 13:03:17 2020 From: cfe-commits at lists.llvm.org (Nikita Popov via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 20:03:17 +0000 (UTC) Subject: [PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff. In-Reply-To: References: Message-ID: nikic added a comment. In D77341#2144974 , @asbirlea wrote: > Thank you for the testing. Could you help with with instructions on how to run the tracker myself? > My local testing showed a negligible regression for mafft and a negligible improvement on other benchmarks, so it looked like noise on average. The tracker just compiles test-suite under `perf stat` using the cached cmake configs. If I pick out the file with the largest regression (mafft `constants.c` in `ReleaseThinLTO` config with 18% regression) I can reproduce this locally as follows: perf stat /home/nikic/llvm-project/build/bin/clang -DNDEBUG -O3 -fomit-frame-pointer -flto=thin -DNDEBUG -w -Werror=date-time -DLLVM -MD -MT MultiSource/Benchmarks/mafft/CMakeFiles/pairlocalalign.dir/constants.c.o -MF MultiSource/Benchmarks/mafft/CMakeFiles/pairlocalalign.dir/constants.c.o.d -o MultiSource/Benchmarks/mafft/CMakeFiles/pairlocalalign.dir/constants.c.o -c ../MultiSource/Benchmarks/mafft/constants.c This gives me 3.5M instructions before and 4.2M instructions after. Those particular numbers are for an assertion-enabled build (the numbers on the website are without assertions.) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77341/new/ https://reviews.llvm.org/D77341 From cfe-commits at lists.llvm.org Fri Jul 10 13:23:45 2020 From: cfe-commits at lists.llvm.org (Artem Dergachev via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 20:23:45 +0000 (UTC) Subject: [PATCH] D83120: [Analyzer][StreamChecker] Using BugType::SuppressOnSink at resource leak report. In-Reply-To: References: Message-ID: <05bfbc27ebd9f5c94be846840244c741@localhost.localdomain> NoQ added a comment. Before i forget again: commit messages (and, therefore, review titles) are traditionally written in imperative mood, i.e. "Using" -> "Use" as if you ask git to change something in the project. ================ Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:207 BugType BT_StreamEof{this, "Stream already in EOF", "Stream handling error"}; - BugType BT_ResourceLeak{this, "Resource leak", "Stream handling error"}; + BugType BT_ResourceLeak{this, "Resource leak", "Stream handling error", true}; ---------------- Pls add a comment about what "true" means so that was easier to read, i.e. `/*SuppressOnSink =*/ true`. ================ Comment at: clang/test/Analysis/stream.c:274-284 // Check that "location uniqueing" works. // This results in reporting only one occurence of resource leak for a stream. void check_leak_noreturn_2() { FILE *F1 = tmpfile(); if (!F1) return; if (Test == 1) { ---------------- balazske wrote: > Szelethus wrote: > > Why did this change? Is there a sink in the return branch? > The change is probably because D83115. Because the "uniqueing" one resource leak is reported from the two possible, and the order changes somehow (probably not the shortest is found first). The shortest should still be found first. I strongly suggest debugging this. Looks like a bug in suppress-on-sink. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83120/new/ https://reviews.llvm.org/D83120 From cfe-commits at lists.llvm.org Fri Jul 10 13:25:59 2020 From: cfe-commits at lists.llvm.org (Artem Dergachev via cfe-commits) Date: Fri, 10 Jul 2020 13:25:59 -0700 (PDT) Subject: [clang] cb6c110 - [analyzer] Silence a warning. Message-ID: <5f08ced7.1c69fb81.f09ca.0ef1@mx.google.com> Author: Artem Dergachev Date: 2020-07-10T13:25:46-07:00 New Revision: cb6c1106141efa721a3902a98c37a54d135464fd URL: https://github.com/llvm/llvm-project/commit/cb6c1106141efa721a3902a98c37a54d135464fd DIFF: https://github.com/llvm/llvm-project/commit/cb6c1106141efa721a3902a98c37a54d135464fd.diff LOG: [analyzer] Silence a warning. An old clang warns that the const object has no default constructor so it may remain uninitialized forever. That's a false alarm because all fields have a default initializer. Apply the suggested fixit anyway. Added: Modified: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Removed: ################################################################################ diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index 08413c080d41..cb6f61e86ae3 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -672,7 +672,7 @@ class SymbolicRangeInferrer if (!BinaryOperator::isComparisonOp(CurrentOP) || (CurrentOP == BO_Cmp)) return EmptyRangeSet; - static const OperatorRelationsTable CmpOpTable; + static const OperatorRelationsTable CmpOpTable{}; const SymExpr *LHS = SSE->getLHS(); const SymExpr *RHS = SSE->getRHS(); From cfe-commits at lists.llvm.org Fri Jul 10 13:33:39 2020 From: cfe-commits at lists.llvm.org (Michele Scandale via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 20:33:39 +0000 (UTC) Subject: [PATCH] D83454: [CMake] Make `intrinsics_gen` dependency unconditional. In-Reply-To: References: Message-ID: <28b91f0222e70692ed23dc37f2eded4a@localhost.localdomain> michele.scandale added a comment. In D83454#2144386 , @JDevlieghere wrote: > In D83454#2142719 , @michele.scandale wrote: > > > I tested locally the standalone build of Clang with D83426 . > > I just want to make sure that we all agree this is right way moving forward. > > > Yep, with the target exported this is the right thing to do. Great. I don't have commit rights. Could someone land this on my behalf? Thanks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83454/new/ https://reviews.llvm.org/D83454 From cfe-commits at lists.llvm.org Fri Jul 10 13:39:25 2020 From: cfe-commits at lists.llvm.org (Bruno Ricci via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 20:39:25 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: <917ea674a243f0605613267de93911da@localhost.localdomain> riccibruno accepted this revision. riccibruno added a comment. This revision is now accepted and ready to land. No objection from me, but I am not a reviewer. I am just accepting this to cancel my comment on the missing serialization. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 From cfe-commits at lists.llvm.org Fri Jul 10 13:56:26 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 20:56:26 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: <2f30f5adb738a417226a401cbe0a5437@localhost.localdomain> oontvoo added a comment. In D83529#2145087 , @riccibruno wrote: > No objection from me, but I am not a reviewer. I am just accepting this to cancel my comment on the missing serialization. No worries. Thanks for your input! I think Dmitri has already accepted this (pending additional test and variables renaming, which I've done). I'm re-running the sanitizer tests to make sure it's not related then will commit, unless someone else would like to chime in ... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 From cfe-commits at lists.llvm.org Fri Jul 10 14:28:49 2020 From: cfe-commits at lists.llvm.org (Tom Stellard via cfe-commits) Date: Fri, 10 Jul 2020 14:28:49 -0700 (PDT) Subject: [clang] 1d68a78 - [clang-shlib] Don't link with static clang libraries Message-ID: <5f08dd91.1c69fb81.a59b7.14dd@mx.google.com> Author: Tom Stellard Date: 2020-07-10T14:28:05-07:00 New Revision: 1d68a780b34e1f18f865d0754fce6c6177dc5d21 URL: https://github.com/llvm/llvm-project/commit/1d68a780b34e1f18f865d0754fce6c6177dc5d21 DIFF: https://github.com/llvm/llvm-project/commit/1d68a780b34e1f18f865d0754fce6c6177dc5d21.diff LOG: [clang-shlib] Don't link with static clang libraries Summary: If we are building static libraries we don't need to link them into clang-shlib, since clang-shlib already has all the individual object files linked in. Reviewers: smeenai Reviewed By: smeenai Subscribers: mgorny, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82694 Added: Modified: clang/tools/clang-shlib/CMakeLists.txt Removed: ################################################################################ diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index 07ee0f0a9a92..5949223fc8e3 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -13,7 +13,12 @@ foreach (lib ${clang_libs}) else() list(APPEND _OBJECTS $) endif() - list(APPEND _DEPS $) + if (BUILD_SHARED_LIBS) + # If we are building static libraries, then we don't need to add the static + # libraries as a depedency, because we are already linking against the + # individual object files. + list(APPEND _DEPS $) + endif() # clang libraries are redundant since we are linking all the individual # object files into libclang-cpp.so, so filter them out from _DEPS. From cfe-commits at lists.llvm.org Fri Jul 10 14:28:52 2020 From: cfe-commits at lists.llvm.org (Tom Stellard via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 21:28:52 +0000 (UTC) Subject: [PATCH] D82694: [clang-shlib] Don't link with static clang libraries In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG1d68a780b34e: [clang-shlib] Don't link with static clang libraries (authored by tstellar). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82694/new/ https://reviews.llvm.org/D82694 Files: clang/tools/clang-shlib/CMakeLists.txt Index: clang/tools/clang-shlib/CMakeLists.txt =================================================================== --- clang/tools/clang-shlib/CMakeLists.txt +++ clang/tools/clang-shlib/CMakeLists.txt @@ -13,7 +13,12 @@ else() list(APPEND _OBJECTS $) endif() - list(APPEND _DEPS $) + if (BUILD_SHARED_LIBS) + # If we are building static libraries, then we don't need to add the static + # libraries as a depedency, because we are already linking against the + # individual object files. + list(APPEND _DEPS $) + endif() # clang libraries are redundant since we are linking all the individual # object files into libclang-cpp.so, so filter them out from _DEPS. -------------- next part -------------- A non-text attachment was scrubbed... Name: D82694.277147.patch Type: text/x-patch Size: 818 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 14:30:06 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 21:30:06 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: oontvoo updated this revision to Diff 277148. oontvoo added a comment. rebase Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 Files: clang/include/clang/AST/Stmt.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Stmt.cpp clang/lib/Parse/ParseStmt.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/unittests/AST/SourceLocationTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83529.277148.patch Type: text/x-patch Size: 13556 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 15:05:51 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 22:05:51 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions Message-ID: jdoerfert created this revision. jdoerfert added reviewers: tra, hfinkel, JonChesterfield. Herald added subscribers: sstefan1, guansong, bollu, yaxunl. Herald added a project: clang. The old way worked to some degree for C++-mode but in C mode we actually tried to introduce variants of macros (e.g., isinf). To make both modes work reliably we get rid of those extra variants and directly use NVIDIA intrinsics in the complex implementation. While this has to be revisited as we add other GPU targets which want to reuse the code, it should be fine for now. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83591 Files: clang/lib/Headers/__clang_cuda_complex_builtins.h clang/lib/Headers/__clang_cuda_math.h clang/test/Headers/nvptx_device_math_complex.c clang/test/Headers/nvptx_device_math_complex.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83591.277152.patch Type: text/x-patch Size: 6424 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 15:08:13 2020 From: cfe-commits at lists.llvm.org (Eli Friedman via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 22:08:13 +0000 (UTC) Subject: [PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute In-Reply-To: References: Message-ID: <70d533d68dfab56435f2064442c047e9@localhost.localdomain> efriedma added a comment. What's the tradeoff of representing these in IR as vscale'ed vector types, as opposed to fixed-wdith vector types? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83553/new/ https://reviews.llvm.org/D83553 From cfe-commits at lists.llvm.org Fri Jul 10 15:10:00 2020 From: cfe-commits at lists.llvm.org (Amy Kwan via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 22:10:00 +0000 (UTC) Subject: [PATCH] D83497: [PowerPC][Power10] Fix VINS* (vector insert byte/half/word) instructions to have i32 arguments. In-Reply-To: References: Message-ID: <1796f90eb3df1bead3e449390749bc22@localhost.localdomain> amyk updated this revision to Diff 277153. amyk retitled this revision from "[PowerPC][Power10] Fix the VINSW instruction to have an i32 argument." to "[PowerPC][Power10] Fix VINS* (vector insert byte/half/word) instructions to have i32 arguments.". amyk edited the summary of this revision. amyk added a comment. Herald added a project: clang. Herald added a subscriber: cfe-commits. Updated revision to fix vector insert byte/half/word versions to have an i32 argument. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83497/new/ https://reviews.llvm.org/D83497 Files: clang/include/clang/Basic/BuiltinsPPC.def clang/test/CodeGen/builtins-ppc-p10vector.c llvm/include/llvm/IR/IntrinsicsPowerPC.td llvm/lib/Target/PowerPC/PPCInstrPrefix.td llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D83497.277153.patch Type: text/x-patch Size: 18081 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 15:41:40 2020 From: cfe-commits at lists.llvm.org (Zequan Wu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 22:41:40 +0000 (UTC) Subject: [PATCH] D83592: [Parser] Add comment to skipped regions Message-ID: zequanwu created this revision. zequanwu added a reviewer: hans. Herald added a project: clang. Herald added a subscriber: cfe-commits. Not sure if this is good idea to untrack comments, it breaks many tests under CoverageMapping. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83592 Files: clang/lib/Parse/Parser.cpp Index: clang/lib/Parse/Parser.cpp =================================================================== --- clang/lib/Parse/Parser.cpp +++ clang/lib/Parse/Parser.cpp @@ -34,6 +34,7 @@ explicit ActionCommentHandler(Sema &S) : S(S) { } bool HandleComment(Preprocessor &PP, SourceRange Comment) override { + PP.getPPCallbacks()->SourceRangeSkipped(Comment, Comment.getEnd()); S.ActOnComment(Comment); return false; } -------------- next part -------------- A non-text attachment was scrubbed... Name: D83592.277157.patch Type: text/x-patch Size: 436 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 15:41:56 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 22:41:56 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <8061eb600e5ee644bba685454cba666b@localhost.localdomain> yaxunl marked 11 inline comments as done. yaxunl added a comment. thanks. will fix when commit CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Fri Jul 10 15:53:04 2020 From: cfe-commits at lists.llvm.org (Alexandre Ganea via cfe-commits) Date: Fri, 10 Jul 2020 15:53:04 -0700 (PDT) Subject: [clang] 41d2813 - [PDB] Attempt fix for debug-info-codeview-buildinfo.c test Message-ID: <5f08f150.1c69fb81.53827.fa87@mx.google.com> Author: Alexandre Ganea Date: 2020-07-10T18:52:52-04:00 New Revision: 41d2813a5faea1c18b7d329109e0287c5cd9ffea URL: https://github.com/llvm/llvm-project/commit/41d2813a5faea1c18b7d329109e0287c5cd9ffea DIFF: https://github.com/llvm/llvm-project/commit/41d2813a5faea1c18b7d329109e0287c5cd9ffea.diff LOG: [PDB] Attempt fix for debug-info-codeview-buildinfo.c test This is a bit a shot in the dark, as it doesn't occur on my Windows 10 machines, nor on x64 Linux Ubuntu 18.04. This patch tries to fix the following kind of error: - http://lab.llvm.org:8011/builders/clang-ppc64le-linux/builds/31511/steps/cmake%20stage%201/logs/stdio - http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/25150/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-codeview-buildinfo.c - http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/7947/steps/check/logs/stdio Added: Modified: clang/cmake/caches/BaremetalARM.cmake clang/cmake/caches/CrossWinToARMLinux.cmake clang/cmake/caches/Fuchsia-stage2.cmake clang/test/CMakeLists.txt clang/test/CodeGen/debug-info-codeview-buildinfo.c Removed: ################################################################################ diff --git a/clang/cmake/caches/BaremetalARM.cmake b/clang/cmake/caches/BaremetalARM.cmake index 85295d9db392..e44355cfcbd7 100644 --- a/clang/cmake/caches/BaremetalARM.cmake +++ b/clang/cmake/caches/BaremetalARM.cmake @@ -31,6 +31,7 @@ set(LLVM_TOOLCHAIN_TOOLS llvm-dwarfdump llvm-nm llvm-objdump + llvm-pdbutil llvm-ranlib llvm-readobj llvm-size diff --git a/clang/cmake/caches/CrossWinToARMLinux.cmake b/clang/cmake/caches/CrossWinToARMLinux.cmake index 9aa0efa8049f..ccfccce3cb89 100644 --- a/clang/cmake/caches/CrossWinToARMLinux.cmake +++ b/clang/cmake/caches/CrossWinToARMLinux.cmake @@ -137,6 +137,7 @@ set(LLVM_TOOLCHAIN_TOOLS llvm-lib llvm-nm llvm-objdump + llvm-pdbutil llvm-profdata llvm-ranlib llvm-readobj diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index 259684ff2b0d..8b5e9d0c4181 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -240,6 +240,7 @@ set(LLVM_TOOLCHAIN_TOOLS llvm-nm llvm-objcopy llvm-objdump + llvm-pdbutil llvm-profdata llvm-ranlib llvm-readelf diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index 38bbc5be90d5..b2777fded0ae 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -126,6 +126,7 @@ if( NOT CLANG_BUILT_STANDALONE ) llvm-nm llvm-objcopy llvm-objdump + llvm-pdbutil llvm-profdata llvm-readelf llvm-readobj diff --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c b/clang/test/CodeGen/debug-info-codeview-buildinfo.c index 3434f5f86579..e1082d2532b2 100644 --- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c +++ b/clang/test/CodeGen/debug-info-codeview-buildinfo.c @@ -1,7 +1,6 @@ -// UNSUPPORTED: s390x -// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s +// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s -// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s +// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -fdebug-compilation-dir=. -- %s // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE int main() { return 42; } From cfe-commits at lists.llvm.org Fri Jul 10 16:03:51 2020 From: cfe-commits at lists.llvm.org (Eric Christopher via cfe-commits) Date: Fri, 10 Jul 2020 16:03:51 -0700 Subject: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record In-Reply-To: <8c477d792c405aae7777933ed204393d@localhost.localdomain> References: <8c477d792c405aae7777933ed204393d@localhost.localdomain> Message-ID: I'm seeing tests fail with a crash. Can we revert the patch and attempted fixes and start working from there? Stacktrace for the curious :) @ 0x56420187cbbe llvm::MCStreamer::emitIntValue() @ 0x5641fec38899 llvm::MCStreamer::emitInt16() @ 0x5641ff73b337 llvm::CodeViewDebug::emitCompilerInformation() @ 0x5641ff73ac73 llvm::CodeViewDebug::endModule() @ 0x5641ff718e83 llvm::AsmPrinter::doFinalization() @ 0x5642016fd9ca llvm::FPPassManager::doFinalization() @ 0x5642016f954e (anonymous namespace)::MPPassManager::runOnModule() -eric On Tue, Jun 30, 2020 at 11:56 AM Alexandre Ganea via Phabricator via cfe-commits wrote: > aganea added a comment. > > In D80833#2109172 , @uweigand > wrote: > > > Hmm, with clang-cl it seems the driver is trying to use this: > > Target: s390x-pc-windows-msvc > > which of course doesn't exist. Not sure what is supposed to be > happening here, but it seems that it's falling back on s390x-linux since on > s390x, Linux is currently the only supported OS. > > > I'm seeing some of the tests are setting the target explicitly `%clang_cl > --target=x86_64-windows-msvc`. Would that work on your machine? Or should I > do `UNSUPPORTED: s390x` ? > > > Repository: > rG LLVM Github Monorepo > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D80833/new/ > > https://reviews.llvm.org/D80833 > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:07:09 2020 From: cfe-commits at lists.llvm.org (Eric Christopher via cfe-commits) Date: Fri, 10 Jul 2020 16:07:09 -0700 Subject: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record In-Reply-To: References: <8c477d792c405aae7777933ed204393d@localhost.localdomain> Message-ID: You'll probably want the assert as well: assert.h assertion failed at llvm-project/llvm/lib/MC/MCStreamer.cpp:134 in virtual void llvm::MCStreamer::emitIntValue(uint64_t, unsigned int): (isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) && "Invalid size" On Fri, Jul 10, 2020 at 4:03 PM Eric Christopher wrote: > I'm seeing tests fail with a crash. Can we revert the patch and attempted > fixes and start working from there? > > Stacktrace for the curious :) > > @ 0x56420187cbbe llvm::MCStreamer::emitIntValue() > @ 0x5641fec38899 llvm::MCStreamer::emitInt16() > @ 0x5641ff73b337 llvm::CodeViewDebug::emitCompilerInformation() > @ 0x5641ff73ac73 llvm::CodeViewDebug::endModule() > @ 0x5641ff718e83 llvm::AsmPrinter::doFinalization() > @ 0x5642016fd9ca llvm::FPPassManager::doFinalization() > @ 0x5642016f954e (anonymous > namespace)::MPPassManager::runOnModule() > > -eric > > On Tue, Jun 30, 2020 at 11:56 AM Alexandre Ganea via Phabricator via > cfe-commits wrote: > >> aganea added a comment. >> >> In D80833#2109172 , @uweigand >> wrote: >> >> > Hmm, with clang-cl it seems the driver is trying to use this: >> > Target: s390x-pc-windows-msvc >> > which of course doesn't exist. Not sure what is supposed to be >> happening here, but it seems that it's falling back on s390x-linux since on >> s390x, Linux is currently the only supported OS. >> >> >> I'm seeing some of the tests are setting the target explicitly `%clang_cl >> --target=x86_64-windows-msvc`. Would that work on your machine? Or should I >> do `UNSUPPORTED: s390x` ? >> >> >> Repository: >> rG LLVM Github Monorepo >> >> CHANGES SINCE LAST ACTION >> https://reviews.llvm.org/D80833/new/ >> >> https://reviews.llvm.org/D80833 >> >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits at lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:11:59 2020 From: cfe-commits at lists.llvm.org (Alexandre Ganea via cfe-commits) Date: Fri, 10 Jul 2020 23:11:59 +0000 Subject: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record In-Reply-To: References: <8c477d792c405aae7777933ed204393d@localhost.localdomain> Message-ID: Thanks for letting me know Eric. What test fails exactly? What config? De : Eric Christopher Envoyé : July 10, 2020 7:04 PM À : reviews+D80833+public+da87cf0eabdca5a2 at reviews.llvm.org; Alexandre Ganea via Phabricator Cc : Alexandre Ganea ; Hans Wennborg ; Adrian McCarthy ; Martin Storsjo ; Amy Huang ; dmajor at mozilla.com; john.reagan at vmssoftware.com; zturner at roblox.com; 88888yl at gmail.com; llvm-commits ; stefan.reinalter at molecular-matters.com; Ulrich Weigand ; mlekena at skidmore.edu; Clang Commits ; Han Shen Objet : Re: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record I'm seeing tests fail with a crash. Can we revert the patch and attempted fixes and start working from there? Stacktrace for the curious :) @ 0x56420187cbbe llvm::MCStreamer::emitIntValue() @ 0x5641fec38899 llvm::MCStreamer::emitInt16() @ 0x5641ff73b337 llvm::CodeViewDebug::emitCompilerInformation() @ 0x5641ff73ac73 llvm::CodeViewDebug::endModule() @ 0x5641ff718e83 llvm::AsmPrinter::doFinalization() @ 0x5642016fd9ca llvm::FPPassManager::doFinalization() @ 0x5642016f954e (anonymous namespace)::MPPassManager::runOnModule() -eric On Tue, Jun 30, 2020 at 11:56 AM Alexandre Ganea via Phabricator via cfe-commits > wrote: aganea added a comment. In D80833#2109172 , @uweigand wrote: > Hmm, with clang-cl it seems the driver is trying to use this: > Target: s390x-pc-windows-msvc > which of course doesn't exist. Not sure what is supposed to be happening here, but it seems that it's falling back on s390x-linux since on s390x, Linux is currently the only supported OS. I'm seeing some of the tests are setting the target explicitly `%clang_cl --target=x86_64-windows-msvc`. Would that work on your machine? Or should I do `UNSUPPORTED: s390x` ? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80833/new/ https://reviews.llvm.org/D80833 _______________________________________________ cfe-commits mailing list cfe-commits at lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:17:30 2020 From: cfe-commits at lists.llvm.org (Eric Christopher via cfe-commits) Date: Fri, 10 Jul 2020 16:17:30 -0700 Subject: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record In-Reply-To: References: <8c477d792c405aae7777933ed204393d@localhost.localdomain> Message-ID: Release+Asserts on x86_64-linux and the debug-info-codeview-buildinfo.c test. Sorry if the latter wasn't clear :) -eric On Fri, Jul 10, 2020 at 4:12 PM Alexandre Ganea wrote: > Thanks for letting me know Eric. What test fails exactly? What config? > > > > *De :* Eric Christopher > *Envoyé :* July 10, 2020 7:04 PM > *À :* reviews+D80833+public+da87cf0eabdca5a2 at reviews.llvm.org; Alexandre > Ganea via Phabricator > *Cc :* Alexandre Ganea ; Hans Wennborg < > hans at chromium.org>; Adrian McCarthy ; Martin Storsjo > ; Amy Huang ; dmajor at mozilla.com; > john.reagan at vmssoftware.com; zturner at roblox.com; 88888yl at gmail.com; > llvm-commits ; > stefan.reinalter at molecular-matters.com; Ulrich Weigand < > ulrich.weigand at de.ibm.com>; mlekena at skidmore.edu; Clang Commits < > cfe-commits at lists.llvm.org>; Han Shen > *Objet :* Re: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO > record > > > > I'm seeing tests fail with a crash. Can we revert the patch and attempted > fixes and start working from there? > > > > Stacktrace for the curious :) > > > > @ 0x56420187cbbe llvm::MCStreamer::emitIntValue() > @ 0x5641fec38899 llvm::MCStreamer::emitInt16() > @ 0x5641ff73b337 llvm::CodeViewDebug::emitCompilerInformation() > @ 0x5641ff73ac73 llvm::CodeViewDebug::endModule() > @ 0x5641ff718e83 llvm::AsmPrinter::doFinalization() > @ 0x5642016fd9ca llvm::FPPassManager::doFinalization() > @ 0x5642016f954e (anonymous > namespace)::MPPassManager::runOnModule() > > > > -eric > > > > On Tue, Jun 30, 2020 at 11:56 AM Alexandre Ganea via Phabricator via > cfe-commits wrote: > > aganea added a comment. > > In D80833#2109172 , @uweigand > wrote: > > > Hmm, with clang-cl it seems the driver is trying to use this: > > Target: s390x-pc-windows-msvc > > which of course doesn't exist. Not sure what is supposed to be > happening here, but it seems that it's falling back on s390x-linux since on > s390x, Linux is currently the only supported OS. > > > I'm seeing some of the tests are setting the target explicitly `%clang_cl > --target=x86_64-windows-msvc`. Would that work on your machine? Or should I > do `UNSUPPORTED: s390x` ? > > > Repository: > rG LLVM Github Monorepo > > CHANGES SINCE LAST ACTION > https://reviews.llvm.org/D80833/new/ > > https://reviews.llvm.org/D80833 > > > > _______________________________________________ > cfe-commits mailing list > cfe-commits at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:27:15 2020 From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:27:15 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <69e6799b29f661ed192204a7bac49632@localhost.localdomain> JonChesterfield accepted this revision. JonChesterfield added a comment. This revision is now accepted and ready to land. Fine by me. Let's get nvptx working properly in tree now and work out how to wire up amdgcn subsequently. I'm sure a reasonable abstraction will present itself. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 16:30:26 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:30:26 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: <98cfce7abf62f8a28ac4b08004677331@localhost.localdomain> ahatanak updated this revision to Diff 277163. ahatanak added a comment. Assert in `EmitReturnFromThunk` that the result type isn't an aggregate. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 Files: clang/lib/CodeGen/CGCXXABI.cpp clang/lib/CodeGen/CGVTables.cpp clang/test/CodeGenCXX/trivial_abi.cpp clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm Index: clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm =================================================================== --- clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm +++ clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm @@ -178,3 +178,32 @@ void testCallContainsNonTrivial(ContainsNonTrivial *a) { testParamContainsNonTrivial(*a); } + +namespace testThunk { + +// CHECK-LABEL: define i64 @_ZThn8_N9testThunk2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN9testThunk2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i8* +// CHECK: store i8* %[[COERCE_VAL_IP]], i8** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i8*, i8** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i8* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +struct B0 { + virtual Strong m0(); +}; + +struct B1 { + virtual Strong m0(); +}; + +struct D0 : B0, B1 { + Strong m0() override; +}; + +Strong D0::m0() { return {}; } + +} Index: clang/test/CodeGenCXX/trivial_abi.cpp =================================================================== --- clang/test/CodeGenCXX/trivial_abi.cpp +++ clang/test/CodeGenCXX/trivial_abi.cpp @@ -43,6 +43,31 @@ NonTrivial m; }; +struct B0 { + virtual Small m0(); +}; + +struct B1 { + virtual Small m0(); +}; + +struct D0 : B0, B1 { + Small m0() override; +}; + +// CHECK-LABEL: define i64 @_ZThn8_N2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i32* +// CHECK: store i32* %[[COERCE_VAL_IP]], i32** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i32*, i32** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i32* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +Small D0::m0() { return {}; } + // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]]) // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0 Index: clang/lib/CodeGen/CGVTables.cpp =================================================================== --- clang/lib/CodeGen/CGVTables.cpp +++ clang/lib/CodeGen/CGVTables.cpp @@ -363,7 +363,8 @@ : FPT->getReturnType(); ReturnValueSlot Slot; if (!ResultType->isVoidType() && - CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) + (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect || + hasAggregateEvaluationKind(ResultType))) Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified(), /*IsUnused=*/false, /*IsExternallyDestructed=*/true); Index: clang/lib/CodeGen/CGCXXABI.cpp =================================================================== --- clang/lib/CodeGen/CGCXXABI.cpp +++ clang/lib/CodeGen/CGCXXABI.cpp @@ -156,6 +156,7 @@ void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType) { + assert(!hasAggregateEvaluationKind(ResultType) && "cannot handle aggregates"); CGF.EmitReturnOfRValue(RV, ResultType); } -------------- next part -------------- A non-text attachment was scrubbed... Name: D82513.277163.patch Type: text/x-patch Size: 3774 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:42:15 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:42:15 +0000 (UTC) Subject: [PATCH] D83492: [OpenMP] Use common interface to access GPU Grid Values In-Reply-To: References: Message-ID: <7ca1c618169e914466be015049569dcf@localhost.localdomain> jdoerfert added inline comments. ================ Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:654 + unsigned LaneIDBits = + CGF.getTarget().getGridValue(llvm::omp::GV_Warp_Size_Log2); return Bld.CreateAShr(getNVPTXThreadID(CGF), LaneIDBits, "nvptx_warp_id"); ---------------- Why do we keep the enum value with this name then? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83492/new/ https://reviews.llvm.org/D83492 From cfe-commits at lists.llvm.org Fri Jul 10 16:47:40 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:47:40 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <8bdf37b28484ca17cc3ce048ab94e4d1@localhost.localdomain> tra added a comment. In D83591#2145378 , @JonChesterfield wrote: > Fine by me. Let's get nvptx working properly in tree now and work out how to wire up amdgcn subsequently. I'm sure a reasonable abstraction will present itself. I'm missing something -- what was wrong with the changes in D80897 ? AMD's HIP compilation already piggy-backs on using clang's C++ wrappers, so this change will likely break them now and I'll be the first in line to revert the change. @yaxunl -- Sam, does this change affect HIP compilation? If it does, perhaps we should keep C++-based macro definitions around. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 16:51:24 2020 From: cfe-commits at lists.llvm.org (Yifan Shen via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:51:24 +0000 (UTC) Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event In-Reply-To: References: Message-ID: <7770c0e7cd1532fe2e4f6a21963a3e19@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGf7f80159753b: [lldb-vscode] Add Support for Module Event (authored by aelitashen, committed by Walter Erquinigo <waltermelon at fb.com>). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82477/new/ https://reviews.llvm.org/D82477 Files: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py lldb/test/API/tools/lldb-vscode/module/Makefile lldb/test/API/tools/lldb-vscode/module/TestVSCode_module.py lldb/test/API/tools/lldb-vscode/module/main.cpp lldb/tools/lldb-vscode/JSONUtils.cpp lldb/tools/lldb-vscode/JSONUtils.h lldb/tools/lldb-vscode/VSCode.cpp lldb/tools/lldb-vscode/lldb-vscode.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82477.277169.patch Type: text/x-patch Size: 10565 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:51:47 2020 From: cfe-commits at lists.llvm.org (John McCall via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:51:47 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: <6125dace74dd0567ee74650e026d2b13@localhost.localdomain> rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Thanks! LGTM. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 From cfe-commits at lists.llvm.org Fri Jul 10 16:53:08 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:53:08 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <8b3add989bf4f15fba0091a05ed6d709@localhost.localdomain> jdoerfert added a comment. In D83591#2145411 , @tra wrote: > In D83591#2145378 , @JonChesterfield wrote: > > > Fine by me. Let's get nvptx working properly in tree now and work out how to wire up amdgcn subsequently. I'm sure a reasonable abstraction will present itself. > > > I'm missing something -- what was wrong with the changes in D80897 ? It doesn't work for OpenMP. The problem is that we overload some of the math functions fine, e.g., `sin(float)` but not the template ones. So when the code below calls `copysign(int, double)` (or something similar), the OpenMP target variant overload is missing. I have template overload support locally but it needs tests and there is one issue I've seen. This was supposed to be a stopgap as it unblocks the OpenMP mode. > AMD's HIP compilation already piggy-backs on using clang's C++ wrappers, so this change will likely break them now and I'll be the first in line to revert the change. I did not know they are using __clang_cuda headers. (Site note, we should rename them then.) > @yaxunl -- Sam, does this change affect HIP compilation? If it does, perhaps we should keep C++-based macro definitions around. Sure, I can do this only in OpenMP mode and keep the proper C++ std functions in C++ mode. Does that sound good? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 16:55:25 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits) Date: Fri, 10 Jul 2020 16:55:25 -0700 (PDT) Subject: [clang] 7f1e6fc - [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in wrapper headers Message-ID: <5f08ffed.1c69fb81.acd8d.1063@mx.google.com> Author: Johannes Doerfert Date: 2020-07-10T18:53:34-05:00 New Revision: 7f1e6fcff9427adfa8efa3bfeeeac801da788b87 URL: https://github.com/llvm/llvm-project/commit/7f1e6fcff9427adfa8efa3bfeeeac801da788b87 DIFF: https://github.com/llvm/llvm-project/commit/7f1e6fcff9427adfa8efa3bfeeeac801da788b87.diff LOG: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in wrapper headers Due to recent changes we cannot use OpenMP in CUDA files anymore (PR45533) as the math handling of CUDA is different when _OPENMP is defined. We actually want this different behavior only if we are offloading with OpenMP to NVIDIA, thus generating NVPTX. With this patch we do not interfere with the CUDA math handling except if we are in NVPTX offloading mode, as indicated by the presence of __OPENMP_NVPTX__. Reviewed By: tra Differential Revision: https://reviews.llvm.org/D78155 Added: Modified: clang/lib/Headers/__clang_cuda_cmath.h clang/lib/Headers/__clang_cuda_device_functions.h clang/lib/Headers/__clang_cuda_libdevice_declares.h clang/lib/Headers/__clang_cuda_math.h clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h clang/lib/Headers/openmp_wrappers/cmath clang/lib/Headers/openmp_wrappers/math.h Removed: ################################################################################ diff --git a/clang/lib/Headers/__clang_cuda_cmath.h b/clang/lib/Headers/__clang_cuda_cmath.h index f406112164e5..8ba182689a4f 100644 --- a/clang/lib/Headers/__clang_cuda_cmath.h +++ b/clang/lib/Headers/__clang_cuda_cmath.h @@ -12,7 +12,7 @@ #error "This file is for CUDA compilation only." #endif -#ifndef _OPENMP +#ifndef __OPENMP_NVPTX__ #include #endif @@ -32,7 +32,7 @@ // implementation. Declaring in the global namespace and pulling into namespace // std covers all of the known knowns. -#ifdef _OPENMP +#ifdef __OPENMP_NVPTX__ #define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) #else #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline)) @@ -69,7 +69,7 @@ __DEVICE__ float frexp(float __arg, int *__exp) { // Windows. For OpenMP we omit these as some old system headers have // non-conforming `isinf(float)` and `isnan(float)` implementations that return // an `int`. The system versions of these functions should be fine anyway. -#if !defined(_MSC_VER) && !defined(_OPENMP) +#if !defined(_MSC_VER) && !defined(__OPENMP_NVPTX__) __DEVICE__ bool isinf(float __x) { return ::__isinff(__x); } __DEVICE__ bool isinf(double __x) { return ::__isinf(__x); } __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); } @@ -146,7 +146,7 @@ __DEVICE__ float tanh(float __x) { return ::tanhf(__x); } // libdevice doesn't provide an implementation, and we don't want to be in the // business of implementing tricky libm functions in this header. -#ifndef _OPENMP +#ifndef __OPENMP_NVPTX__ // Now we've defined everything we promised we'd define in // __clang_cuda_math_forward_declares.h. We need to do two additional things to @@ -463,7 +463,7 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif -#endif // _OPENMP +#endif // __OPENMP_NVPTX__ #undef __DEVICE__ diff --git a/clang/lib/Headers/__clang_cuda_device_functions.h b/clang/lib/Headers/__clang_cuda_device_functions.h index 76c588997f18..f801e5426aa4 100644 --- a/clang/lib/Headers/__clang_cuda_device_functions.h +++ b/clang/lib/Headers/__clang_cuda_device_functions.h @@ -10,7 +10,7 @@ #ifndef __CLANG_CUDA_DEVICE_FUNCTIONS_H__ #define __CLANG_CUDA_DEVICE_FUNCTIONS_H__ -#ifndef _OPENMP +#ifndef __OPENMP_NVPTX__ #if CUDA_VERSION < 9000 #error This file is intended to be used with CUDA-9+ only. #endif @@ -20,7 +20,7 @@ // we implement in this file. We need static in order to avoid emitting unused // functions and __forceinline__ helps inlining these wrappers at -O1. #pragma push_macro("__DEVICE__") -#ifdef _OPENMP +#ifdef __OPENMP_NVPTX__ #define __DEVICE__ static __attribute__((always_inline, nothrow)) #else #define __DEVICE__ static __device__ __forceinline__ @@ -1466,14 +1466,14 @@ __DEVICE__ unsigned int __vsubus4(unsigned int __a, unsigned int __b) { // For OpenMP we require the user to include as we need to know what // clock_t is on the system. -#ifndef _OPENMP +#ifndef __OPENMP_NVPTX__ __DEVICE__ /* clock_t= */ int clock() { return __nvvm_read_ptx_sreg_clock(); } #endif __DEVICE__ long long clock64() { return __nvvm_read_ptx_sreg_clock64(); } // These functions shouldn't be declared when including this header // for math function resolution purposes. -#ifndef _OPENMP +#ifndef __OPENMP_NVPTX__ __DEVICE__ void *memcpy(void *__a, const void *__b, size_t __c) { return __builtin_memcpy(__a, __b, __c); } diff --git a/clang/lib/Headers/__clang_cuda_libdevice_declares.h b/clang/lib/Headers/__clang_cuda_libdevice_declares.h index 4d70353394c8..6173b589e3ef 100644 --- a/clang/lib/Headers/__clang_cuda_libdevice_declares.h +++ b/clang/lib/Headers/__clang_cuda_libdevice_declares.h @@ -14,7 +14,7 @@ extern "C" { #endif -#if defined(_OPENMP) +#if defined(__OPENMP_NVPTX__) #define __DEVICE__ #elif defined(__CUDA__) #define __DEVICE__ __device__ diff --git a/clang/lib/Headers/__clang_cuda_math.h b/clang/lib/Headers/__clang_cuda_math.h index 939c71a731e5..2e8e6ae71d9c 100644 --- a/clang/lib/Headers/__clang_cuda_math.h +++ b/clang/lib/Headers/__clang_cuda_math.h @@ -12,7 +12,7 @@ #error "This file is for CUDA compilation only." #endif -#ifndef _OPENMP +#ifndef __OPENMP_NVPTX__ #if CUDA_VERSION < 9000 #error This file is intended to be used with CUDA-9+ only. #endif @@ -22,7 +22,7 @@ // we implement in this file. We need static in order to avoid emitting unused // functions and __forceinline__ helps inlining these wrappers at -O1. #pragma push_macro("__DEVICE__") -#ifdef _OPENMP +#ifdef __OPENMP_NVPTX__ #if defined(__cplusplus) #define __DEVICE__ static constexpr __attribute__((always_inline, nothrow)) #else @@ -36,7 +36,7 @@ // because the OpenMP overlay requires constexpr functions here but prior to // c++14 void return functions could not be constexpr. #pragma push_macro("__DEVICE_VOID__") -#ifdef _OPENMP && defined(__cplusplus) && __cplusplus < 201402L +#ifdef __OPENMP_NVPTX__ && defined(__cplusplus) && __cplusplus < 201402L #define __DEVICE_VOID__ static __attribute__((always_inline, nothrow)) #else #define __DEVICE_VOID__ __DEVICE__ diff --git a/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h b/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h index 9ff0a186273a..406c9748e286 100644 --- a/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h +++ b/clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h @@ -22,11 +22,15 @@ extern "C" { #endif #define __CUDA__ +#define __OPENMP_NVPTX__ + /// Include declarations for libdevice functions. #include <__clang_cuda_libdevice_declares.h> /// Provide definitions for these functions. #include <__clang_cuda_device_functions.h> + +#undef __OPENMP_NVPTX__ #undef __CUDA__ #ifdef __cplusplus diff --git a/clang/lib/Headers/openmp_wrappers/cmath b/clang/lib/Headers/openmp_wrappers/cmath index 05be252fa9fb..bd6011eb6f6d 100644 --- a/clang/lib/Headers/openmp_wrappers/cmath +++ b/clang/lib/Headers/openmp_wrappers/cmath @@ -28,7 +28,9 @@ device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)}) #define __CUDA__ +#define __OPENMP_NVPTX__ #include <__clang_cuda_cmath.h> +#undef __OPENMP_NVPTX__ #undef __CUDA__ // Overloads not provided by the CUDA wrappers but by the CUDA system headers. diff --git a/clang/lib/Headers/openmp_wrappers/math.h b/clang/lib/Headers/openmp_wrappers/math.h index e917a149b5c9..c64af8b13ece 100644 --- a/clang/lib/Headers/openmp_wrappers/math.h +++ b/clang/lib/Headers/openmp_wrappers/math.h @@ -41,7 +41,9 @@ device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any)}) #define __CUDA__ +#define __OPENMP_NVPTX__ #include <__clang_cuda_math.h> +#undef __OPENMP_NVPTX__ #undef __CUDA__ #pragma omp end declare variant From cfe-commits at lists.llvm.org Fri Jul 10 16:55:39 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:55:39 +0000 (UTC) Subject: [PATCH] D78155: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in wrapper headers In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG7f1e6fcff942: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in wrapper headers (authored by jdoerfert). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D78155/new/ https://reviews.llvm.org/D78155 Files: clang/lib/Headers/__clang_cuda_cmath.h clang/lib/Headers/__clang_cuda_device_functions.h clang/lib/Headers/__clang_cuda_libdevice_declares.h clang/lib/Headers/__clang_cuda_math.h clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h clang/lib/Headers/openmp_wrappers/cmath clang/lib/Headers/openmp_wrappers/math.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D78155.277171.patch Type: text/x-patch Size: 6366 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 16:58:18 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Fri, 10 Jul 2020 23:58:18 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <9d790641418c1f620bb4c6a43154fc55@localhost.localdomain> jdoerfert updated this revision to Diff 277173. jdoerfert added a comment. Keep the std:: functions in non-OpenMP mode Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 Files: clang/lib/Headers/__clang_cuda_complex_builtins.h clang/lib/Headers/__clang_cuda_math.h clang/test/Headers/nvptx_device_math_complex.c clang/test/Headers/nvptx_device_math_complex.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83591.277173.patch Type: text/x-patch Size: 6657 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 17:04:35 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 00:04:35 +0000 (UTC) Subject: [PATCH] D83478: [OPENMP]Fix compiler crash for target data directive without actual target codegen. In-Reply-To: References: Message-ID: <28c5e219b46b85de97f8b27d7c7fbed7@localhost.localdomain> jdoerfert accepted this revision. jdoerfert added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83478/new/ https://reviews.llvm.org/D83478 From cfe-commits at lists.llvm.org Fri Jul 10 17:11:35 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits) Date: Fri, 10 Jul 2020 17:11:35 -0700 (PDT) Subject: [clang] cd0ea03 - [OpenMP][NFC] Remove unused and untested code from the device runtime Message-ID: <5f0903b7.1c69fb81.c7d17.09e0@mx.google.com> Author: Johannes Doerfert Date: 2020-07-10T19:09:41-05:00 New Revision: cd0ea03e6f157e8fb477cd8368b29e1448eeb265 URL: https://github.com/llvm/llvm-project/commit/cd0ea03e6f157e8fb477cd8368b29e1448eeb265 DIFF: https://github.com/llvm/llvm-project/commit/cd0ea03e6f157e8fb477cd8368b29e1448eeb265.diff LOG: [OpenMP][NFC] Remove unused and untested code from the device runtime Summary: We carried a lot of unused and untested code in the device runtime. Among other reasons, we are planning major rewrites for which reduced size is going to help a lot. The number of code lines reduced by 14%! Before: ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- CUDA 13 489 841 2454 C/C++ Header 14 322 493 1377 C 12 117 124 559 CMake 4 64 64 262 C++ 1 6 6 39 ------------------------------------------------------------------------------- SUM: 44 998 1528 4691 ------------------------------------------------------------------------------- After: ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- CUDA 13 366 733 1879 C/C++ Header 14 317 484 1293 C 12 117 124 559 CMake 4 64 64 262 C++ 1 6 6 39 ------------------------------------------------------------------------------- SUM: 44 870 1411 4032 ------------------------------------------------------------------------------- Reviewers: hfinkel, jhuber6, fghanim, JonChesterfield, grokos, AndreyChurbanov, ye-luo, tianshilei1992, ggeorgakoudis, Hahnfeld, ABataev, hbae, ronlieb, gregrodgers Subscribers: jvesely, yaxunl, bollu, guansong, jfb, sstefan1, aaron.ballman, openmp-commits, cfe-commits Tags: #clang, #openmp Differential Revision: https://reviews.llvm.org/D83349 Added: Modified: clang/test/OpenMP/nvptx_target_simd_codegen.cpp openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h openmp/libomptarget/deviceRTLs/common/omptarget.h openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu openmp/libomptarget/deviceRTLs/common/src/libcall.cu openmp/libomptarget/deviceRTLs/common/src/loop.cu openmp/libomptarget/deviceRTLs/common/src/omptarget.cu openmp/libomptarget/deviceRTLs/common/src/parallel.cu openmp/libomptarget/deviceRTLs/common/src/reduction.cu openmp/libomptarget/deviceRTLs/common/src/support.cu openmp/libomptarget/deviceRTLs/common/src/sync.cu openmp/libomptarget/deviceRTLs/common/support.h openmp/libomptarget/deviceRTLs/interface.h openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h Removed: ################################################################################ diff --git a/clang/test/OpenMP/nvptx_target_simd_codegen.cpp b/clang/test/OpenMP/nvptx_target_simd_codegen.cpp index 073d6fa2f14e..7a1f01c1f1ad 100644 --- a/clang/test/OpenMP/nvptx_target_simd_codegen.cpp +++ b/clang/test/OpenMP/nvptx_target_simd_codegen.cpp @@ -78,7 +78,6 @@ int bar(int n){ // CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0, i16 0) // CHECK-NOT: call void @__kmpc_for_static_init // CHECK-NOT: call void @__kmpc_for_static_fini -// CHECK-NOT: call i32 @__kmpc_nvptx_simd_reduce_nowait( // CHECK-NOT: call void @__kmpc_nvptx_end_reduce_nowait( // CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0) // CHECK: ret void diff --git a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h index 77a0ffb54f95..3c90b39282c9 100644 --- a/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h @@ -140,8 +140,6 @@ DEVICE int GetNumberOfThreadsInBlock(); DEVICE unsigned GetWarpId(); DEVICE unsigned GetLaneId(); -DEVICE bool __kmpc_impl_is_first_active_thread(); - // Locks DEVICE void __kmpc_impl_init_lock(omp_lock_t *lock); DEVICE void __kmpc_impl_destroy_lock(omp_lock_t *lock); diff --git a/openmp/libomptarget/deviceRTLs/common/omptarget.h b/openmp/libomptarget/deviceRTLs/common/omptarget.h index 986eb3677dcf..88807de4e19c 100644 --- a/openmp/libomptarget/deviceRTLs/common/omptarget.h +++ b/openmp/libomptarget/deviceRTLs/common/omptarget.h @@ -200,7 +200,6 @@ class omptarget_nvptx_TeamDescr { INLINE omptarget_nvptx_WorkDescr &WorkDescr() { return workDescrForActiveParallel; } - INLINE uint64_t *getLastprivateIterBuffer() { return &lastprivateIterBuffer; } // init INLINE void InitTeamDescr(); @@ -251,7 +250,6 @@ class omptarget_nvptx_TeamDescr { levelZeroTaskDescr; // icv for team master initial thread omptarget_nvptx_WorkDescr workDescrForActiveParallel; // one, ONLY for the active par - uint64_t lastprivateIterBuffer; ALIGN(16) __kmpc_data_sharing_worker_slot_static worker_rootS[WARPSIZE]; @@ -277,10 +275,6 @@ class omptarget_nvptx_ThreadPrivateContext { INLINE uint16_t &NumThreadsForNextParallel(int tid) { return nextRegion.tnum[tid]; } - // simd - INLINE uint16_t &SimdLimitForNextSimd(int tid) { - return nextRegion.slim[tid]; - } // schedule (for dispatch) INLINE kmp_sched_t &ScheduleType(int tid) { return schedule[tid]; } INLINE int64_t &Chunk(int tid) { return chunk[tid]; } @@ -304,8 +298,6 @@ class omptarget_nvptx_ThreadPrivateContext { // Only one of the two is live at the same time. // parallel uint16_t tnum[MAX_THREADS_PER_TEAM]; - // simd limit - uint16_t slim[MAX_THREADS_PER_TEAM]; } nextRegion; // schedule (for dispatch) kmp_sched_t schedule[MAX_THREADS_PER_TEAM]; // remember schedule type for #for diff --git a/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu b/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu index f6523c8ce8aa..ca2fd1d30754 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu @@ -17,297 +17,6 @@ INLINE static bool IsMasterThread(bool isSPMDExecutionMode) { return !isSPMDExecutionMode && GetMasterThreadID() == GetThreadIdInBlock(); } -/// Return the provided size aligned to the size of a pointer. -INLINE static size_t AlignVal(size_t Val) { - const size_t Align = (size_t)sizeof(void *); - if (Val & (Align - 1)) { - Val += Align; - Val &= ~(Align - 1); - } - return Val; -} - -#define DSFLAG 0 -#define DSFLAG_INIT 0 -#define DSPRINT(_flag, _str, _args...) \ - { \ - if (_flag) { \ - /*printf("(%d,%d) -> " _str, blockIdx.x, threadIdx.x, _args);*/ \ - } \ - } -#define DSPRINT0(_flag, _str) \ - { \ - if (_flag) { \ - /*printf("(%d,%d) -> " _str, blockIdx.x, threadIdx.x);*/ \ - } \ - } - -// Initialize the shared data structures. This is expected to be called for the -// master thread and warp masters. \param RootS: A pointer to the root of the -// data sharing stack. \param InitialDataSize: The initial size of the data in -// the slot. -EXTERN void -__kmpc_initialize_data_sharing_environment(__kmpc_data_sharing_slot *rootS, - size_t InitialDataSize) { - ASSERT0(LT_FUSSY, isRuntimeInitialized(), "Runtime must be initialized."); - DSPRINT0(DSFLAG_INIT, - "Entering __kmpc_initialize_data_sharing_environment\n"); - - unsigned WID = GetWarpId(); - DSPRINT(DSFLAG_INIT, "Warp ID: %u\n", WID); - - omptarget_nvptx_TeamDescr *teamDescr = - &omptarget_nvptx_threadPrivateContext->TeamContext(); - __kmpc_data_sharing_slot *RootS = - teamDescr->RootS(WID, IsMasterThread(isSPMDMode())); - - DataSharingState.SlotPtr[WID] = RootS; - DataSharingState.StackPtr[WID] = (void *)&RootS->Data[0]; - - // We don't need to initialize the frame and active threads. - - DSPRINT(DSFLAG_INIT, "Initial data size: %08x \n", (unsigned)InitialDataSize); - DSPRINT(DSFLAG_INIT, "Root slot at: %016llx \n", (unsigned long long)RootS); - DSPRINT(DSFLAG_INIT, "Root slot data-end at: %016llx \n", - (unsigned long long)RootS->DataEnd); - DSPRINT(DSFLAG_INIT, "Root slot next at: %016llx \n", - (unsigned long long)RootS->Next); - DSPRINT(DSFLAG_INIT, "Shared slot ptr at: %016llx \n", - (unsigned long long)DataSharingState.SlotPtr[WID]); - DSPRINT(DSFLAG_INIT, "Shared stack ptr at: %016llx \n", - (unsigned long long)DataSharingState.StackPtr[WID]); - - DSPRINT0(DSFLAG_INIT, "Exiting __kmpc_initialize_data_sharing_environment\n"); -} - -EXTERN void *__kmpc_data_sharing_environment_begin( - __kmpc_data_sharing_slot **SavedSharedSlot, void **SavedSharedStack, - void **SavedSharedFrame, __kmpc_impl_lanemask_t *SavedActiveThreads, - size_t SharingDataSize, size_t SharingDefaultDataSize, - int16_t IsOMPRuntimeInitialized) { - - DSPRINT0(DSFLAG, "Entering __kmpc_data_sharing_environment_begin\n"); - - // If the runtime has been elided, used shared memory for master-worker - // data sharing. - if (!IsOMPRuntimeInitialized) - return (void *)&DataSharingState; - - DSPRINT(DSFLAG, "Data Size %016llx\n", (unsigned long long)SharingDataSize); - DSPRINT(DSFLAG, "Default Data Size %016llx\n", - (unsigned long long)SharingDefaultDataSize); - - unsigned WID = GetWarpId(); - __kmpc_impl_lanemask_t CurActiveThreads = __kmpc_impl_activemask(); - - __kmpc_data_sharing_slot *&SlotP = DataSharingState.SlotPtr[WID]; - void *&StackP = DataSharingState.StackPtr[WID]; - void * volatile &FrameP = DataSharingState.FramePtr[WID]; - __kmpc_impl_lanemask_t &ActiveT = DataSharingState.ActiveThreads[WID]; - - DSPRINT0(DSFLAG, "Save current slot/stack values.\n"); - // Save the current values. - *SavedSharedSlot = SlotP; - *SavedSharedStack = StackP; - *SavedSharedFrame = FrameP; - *SavedActiveThreads = ActiveT; - - DSPRINT(DSFLAG, "Warp ID: %u\n", WID); - DSPRINT(DSFLAG, "Saved slot ptr at: %016llx \n", (unsigned long long)SlotP); - DSPRINT(DSFLAG, "Saved stack ptr at: %016llx \n", (unsigned long long)StackP); - DSPRINT(DSFLAG, "Saved frame ptr at: %016llx \n", (long long)FrameP); - DSPRINT(DSFLAG, "Active threads: %08x \n", (unsigned)ActiveT); - - // Only the warp active master needs to grow the stack. - if (__kmpc_impl_is_first_active_thread()) { - // Save the current active threads. - ActiveT = CurActiveThreads; - - // Make sure we use aligned sizes to avoid rematerialization of data. - SharingDataSize = AlignVal(SharingDataSize); - // FIXME: The default data size can be assumed to be aligned? - SharingDefaultDataSize = AlignVal(SharingDefaultDataSize); - - // Check if we have room for the data in the current slot. - const uintptr_t CurrentStartAddress = (uintptr_t)StackP; - const uintptr_t CurrentEndAddress = (uintptr_t)SlotP->DataEnd; - const uintptr_t RequiredEndAddress = - CurrentStartAddress + (uintptr_t)SharingDataSize; - - DSPRINT(DSFLAG, "Data Size %016llx\n", (unsigned long long)SharingDataSize); - DSPRINT(DSFLAG, "Default Data Size %016llx\n", - (unsigned long long)SharingDefaultDataSize); - DSPRINT(DSFLAG, "Current Start Address %016llx\n", - (unsigned long long)CurrentStartAddress); - DSPRINT(DSFLAG, "Current End Address %016llx\n", - (unsigned long long)CurrentEndAddress); - DSPRINT(DSFLAG, "Required End Address %016llx\n", - (unsigned long long)RequiredEndAddress); - DSPRINT(DSFLAG, "Active Threads %08x\n", (unsigned)ActiveT); - - // If we require a new slot, allocate it and initialize it (or attempt to - // reuse one). Also, set the shared stack and slot pointers to the new - // place. If we do not need to grow the stack, just adapt the stack and - // frame pointers. - if (CurrentEndAddress < RequiredEndAddress) { - size_t NewSize = (SharingDataSize > SharingDefaultDataSize) - ? SharingDataSize - : SharingDefaultDataSize; - __kmpc_data_sharing_slot *NewSlot = 0; - - // Attempt to reuse an existing slot. - if (__kmpc_data_sharing_slot *ExistingSlot = SlotP->Next) { - uintptr_t ExistingSlotSize = (uintptr_t)ExistingSlot->DataEnd - - (uintptr_t)(&ExistingSlot->Data[0]); - if (ExistingSlotSize >= NewSize) { - DSPRINT(DSFLAG, "Reusing stack slot %016llx\n", - (unsigned long long)ExistingSlot); - NewSlot = ExistingSlot; - } else { - DSPRINT(DSFLAG, "Cleaning up -failed reuse - %016llx\n", - (unsigned long long)SlotP->Next); - SafeFree(ExistingSlot, "Failed reuse"); - } - } - - if (!NewSlot) { - NewSlot = (__kmpc_data_sharing_slot *)SafeMalloc( - sizeof(__kmpc_data_sharing_slot) + NewSize, - "Warp master slot allocation"); - DSPRINT(DSFLAG, "New slot allocated %016llx (data size=%016llx)\n", - (unsigned long long)NewSlot, NewSize); - } - - NewSlot->Next = 0; - NewSlot->DataEnd = &NewSlot->Data[NewSize]; - - SlotP->Next = NewSlot; - SlotP = NewSlot; - StackP = &NewSlot->Data[SharingDataSize]; - FrameP = &NewSlot->Data[0]; - } else { - - // Clean up any old slot that we may still have. The slot producers, do - // not eliminate them because that may be used to return data. - if (SlotP->Next) { - DSPRINT(DSFLAG, "Cleaning up - old not required - %016llx\n", - (unsigned long long)SlotP->Next); - SafeFree(SlotP->Next, "Old slot not required"); - SlotP->Next = 0; - } - - FrameP = StackP; - StackP = (void *)RequiredEndAddress; - } - } - - // FIXME: Need to see the impact of doing it here. - __kmpc_impl_threadfence_block(); - - DSPRINT0(DSFLAG, "Exiting __kmpc_data_sharing_environment_begin\n"); - - // All the threads in this warp get the frame they should work with. - return FrameP; -} - -EXTERN void __kmpc_data_sharing_environment_end( - __kmpc_data_sharing_slot **SavedSharedSlot, void **SavedSharedStack, - void **SavedSharedFrame, __kmpc_impl_lanemask_t *SavedActiveThreads, - int32_t IsEntryPoint) { - - DSPRINT0(DSFLAG, "Entering __kmpc_data_sharing_environment_end\n"); - - unsigned WID = GetWarpId(); - - if (IsEntryPoint) { - if (__kmpc_impl_is_first_active_thread()) { - DSPRINT0(DSFLAG, "Doing clean up\n"); - - // The master thread cleans the saved slot, because this is an environment - // only for the master. - __kmpc_data_sharing_slot *S = IsMasterThread(isSPMDMode()) - ? *SavedSharedSlot - : DataSharingState.SlotPtr[WID]; - - if (S->Next) { - SafeFree(S->Next, "Sharing environment end"); - S->Next = 0; - } - } - - DSPRINT0(DSFLAG, "Exiting Exiting __kmpc_data_sharing_environment_end\n"); - return; - } - - __kmpc_impl_lanemask_t CurActive = __kmpc_impl_activemask(); - - // Only the warp master can restore the stack and frame information, and only - // if there are no other threads left behind in this environment (i.e. the - // warp diverged and returns in diff erent places). This only works if we - // assume that threads will converge right after the call site that started - // the environment. - if (__kmpc_impl_is_first_active_thread()) { - __kmpc_impl_lanemask_t &ActiveT = DataSharingState.ActiveThreads[WID]; - - DSPRINT0(DSFLAG, "Before restoring the stack\n"); - // Zero the bits in the mask. If it is still diff erent from zero, then we - // have other threads that will return after the current ones. - ActiveT &= ~CurActive; - - DSPRINT(DSFLAG, "Active threads: %08x; New mask: %08x\n", - (unsigned)CurActive, (unsigned)ActiveT); - - if (!ActiveT) { - // No other active threads? Great, lets restore the stack. - - __kmpc_data_sharing_slot *&SlotP = DataSharingState.SlotPtr[WID]; - void *&StackP = DataSharingState.StackPtr[WID]; - void * volatile &FrameP = DataSharingState.FramePtr[WID]; - - SlotP = *SavedSharedSlot; - StackP = *SavedSharedStack; - FrameP = *SavedSharedFrame; - ActiveT = *SavedActiveThreads; - - DSPRINT(DSFLAG, "Restored slot ptr at: %016llx \n", - (unsigned long long)SlotP); - DSPRINT(DSFLAG, "Restored stack ptr at: %016llx \n", - (unsigned long long)StackP); - DSPRINT(DSFLAG, "Restored frame ptr at: %016llx \n", - (unsigned long long)FrameP); - DSPRINT(DSFLAG, "Active threads: %08x \n", (unsigned)ActiveT); - } - } - - // FIXME: Need to see the impact of doing it here. - __kmpc_impl_threadfence_block(); - - DSPRINT0(DSFLAG, "Exiting __kmpc_data_sharing_environment_end\n"); - return; -} - -EXTERN void * -__kmpc_get_data_sharing_environment_frame(int32_t SourceThreadID, - int16_t IsOMPRuntimeInitialized) { - DSPRINT0(DSFLAG, "Entering __kmpc_get_data_sharing_environment_frame\n"); - - // If the runtime has been elided, use shared memory for master-worker - // data sharing. We're reusing the statically allocated data structure - // that is used for standard data sharing. - if (!IsOMPRuntimeInitialized) - return (void *)&DataSharingState; - - // Get the frame used by the requested thread. - - unsigned SourceWID = SourceThreadID / WARPSIZE; - - DSPRINT(DSFLAG, "Source warp: %u\n", SourceWID); - - void * volatile P = DataSharingState.FramePtr[SourceWID]; - DSPRINT0(DSFLAG, "Exiting __kmpc_get_data_sharing_environment_frame\n"); - return P; -} - //////////////////////////////////////////////////////////////////////////////// // Runtime functions for trunk data sharing scheme. //////////////////////////////////////////////////////////////////////////////// diff --git a/openmp/libomptarget/deviceRTLs/common/src/libcall.cu b/openmp/libomptarget/deviceRTLs/common/src/libcall.cu index 89c481bcf8da..cfa438ff1717 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/libcall.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/libcall.cu @@ -362,53 +362,3 @@ EXTERN int omp_test_lock(omp_lock_t *lock) { PRINT(LD_IO, "call omp_test_lock() return %d\n", rc); return rc; } - -// for xlf Fortran -// Fortran, the return is LOGICAL type - -#define FLOGICAL long -EXTERN FLOGICAL __xlf_omp_is_initial_device_i8() { - int ret = omp_is_initial_device(); - if (ret == 0) - return (FLOGICAL)0; - else - return (FLOGICAL)1; -} - -EXTERN int __xlf_omp_is_initial_device_i4() { - int ret = omp_is_initial_device(); - if (ret == 0) - return 0; - else - return 1; -} - -EXTERN long __xlf_omp_get_team_num_i4() { - int ret = omp_get_team_num(); - return (long)ret; -} - -EXTERN long __xlf_omp_get_num_teams_i4() { - int ret = omp_get_num_teams(); - return (long)ret; -} - -EXTERN void xlf_debug_print_int(int *p) { - printf("xlf DEBUG %d): %p %d\n", omp_get_team_num(), p, p == 0 ? 0 : *p); -} - -EXTERN void xlf_debug_print_long(long *p) { - printf("xlf DEBUG %d): %p %ld\n", omp_get_team_num(), p, p == 0 ? 0 : *p); -} - -EXTERN void xlf_debug_print_float(float *p) { - printf("xlf DEBUG %d): %p %f\n", omp_get_team_num(), p, p == 0 ? 0 : *p); -} - -EXTERN void xlf_debug_print_double(double *p) { - printf("xlf DEBUG %d): %p %f\n", omp_get_team_num(), p, p == 0 ? 0 : *p); -} - -EXTERN void xlf_debug_print_addr(void *p) { - printf("xlf DEBUG %d): %p \n", omp_get_team_num(), p); -} diff --git a/openmp/libomptarget/deviceRTLs/common/src/loop.cu b/openmp/libomptarget/deviceRTLs/common/src/loop.cu index 417460db138a..f625d9ea9e23 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/loop.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/loop.cu @@ -754,55 +754,3 @@ void __kmpc_for_static_init_8u_simple_generic( EXTERN void __kmpc_for_static_fini(kmp_Ident *loc, int32_t global_tid) { PRINT0(LD_IO, "call kmpc_for_static_fini\n"); } - -namespace { -INLINE void syncWorkersInGenericMode(uint32_t NumThreads) { - int NumWarps = ((NumThreads + WARPSIZE - 1) / WARPSIZE); -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 - // On Volta and newer architectures we require that all lanes in - // a warp (at least, all present for the kernel launch) participate in the - // barrier. This is enforced when launching the parallel region. An - // exception is when there are < WARPSIZE workers. In this case only 1 worker - // is started, so we don't need a barrier. - if (NumThreads > 1) { -#endif - __kmpc_impl_named_sync(L1_BARRIER, WARPSIZE * NumWarps); -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 - } -#endif -} -}; // namespace - -EXTERN void __kmpc_reduce_conditional_lastprivate(kmp_Ident *loc, int32_t gtid, - int32_t varNum, void *array) { - PRINT0(LD_IO, "call to __kmpc_reduce_conditional_lastprivate(...)\n"); - ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), - "Expected non-SPMD mode + initialized runtime."); - - omptarget_nvptx_TeamDescr &teamDescr = getMyTeamDescriptor(); - uint32_t NumThreads = GetNumberOfOmpThreads(checkSPMDMode(loc)); - uint64_t *Buffer = teamDescr.getLastprivateIterBuffer(); - for (unsigned i = 0; i < varNum; i++) { - // Reset buffer. - if (gtid == 0) - *Buffer = 0; // Reset to minimum loop iteration value. - - // Barrier. - syncWorkersInGenericMode(NumThreads); - - // Atomic max of iterations. - uint64_t *varArray = (uint64_t *)array; - uint64_t elem = varArray[i]; - (void)__kmpc_atomic_max((unsigned long long int *)Buffer, - (unsigned long long int)elem); - - // Barrier. - syncWorkersInGenericMode(NumThreads); - - // Read max value and update thread private array. - varArray[i] = *Buffer; - - // Barrier. - syncWorkersInGenericMode(NumThreads); - } -} diff --git a/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu b/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu index 23fbd00cacaf..6c1d5319595c 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/omptarget.cu @@ -25,13 +25,6 @@ extern DEVICE // init entry points //////////////////////////////////////////////////////////////////////////////// -EXTERN void __kmpc_kernel_init_params(void *Ptr) { - PRINT(LD_IO, "call to __kmpc_kernel_init_params with version %f\n", - OMPTARGET_NVPTX_VERSION); - - SetTeamsReductionScratchpadPtr(Ptr); -} - EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime) { PRINT(LD_IO, "call to __kmpc_kernel_init with version %f\n", OMPTARGET_NVPTX_VERSION); @@ -152,10 +145,6 @@ EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime, } } -EXTERN __attribute__((deprecated)) void __kmpc_spmd_kernel_deinit() { - __kmpc_spmd_kernel_deinit_v2(isRuntimeInitialized()); -} - EXTERN void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime) { // We're not going to pop the task descr stack of each thread since // there are no more parallel regions in SPMD mode. diff --git a/openmp/libomptarget/deviceRTLs/common/src/parallel.cu b/openmp/libomptarget/deviceRTLs/common/src/parallel.cu index ab031e99e51f..4f3c3ac0c08a 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/parallel.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/parallel.cu @@ -35,161 +35,6 @@ #include "common/omptarget.h" #include "target_impl.h" -typedef struct ConvergentSimdJob { - omptarget_nvptx_TaskDescr taskDescr; - omptarget_nvptx_TaskDescr *convHeadTaskDescr; - uint16_t slimForNextSimd; -} ConvergentSimdJob; - -//////////////////////////////////////////////////////////////////////////////// -// support for convergent simd (team of threads in a warp only) -//////////////////////////////////////////////////////////////////////////////// -EXTERN bool __kmpc_kernel_convergent_simd(void *buffer, - __kmpc_impl_lanemask_t Mask, - bool *IsFinal, int32_t *LaneSource, - int32_t *LaneId, int32_t *NumLanes) { - PRINT0(LD_IO, "call to __kmpc_kernel_convergent_simd\n"); - __kmpc_impl_lanemask_t ConvergentMask = Mask; - int32_t ConvergentSize = __kmpc_impl_popc(ConvergentMask); - __kmpc_impl_lanemask_t WorkRemaining = ConvergentMask >> (*LaneSource + 1); - *LaneSource += __kmpc_impl_ffs(WorkRemaining); - *IsFinal = __kmpc_impl_popc(WorkRemaining) == 1; - __kmpc_impl_lanemask_t lanemask_lt = __kmpc_impl_lanemask_lt(); - *LaneId = __kmpc_impl_popc(ConvergentMask & lanemask_lt); - - int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); - int sourceThreadId = (threadId & ~(WARPSIZE - 1)) + *LaneSource; - - ConvergentSimdJob *job = (ConvergentSimdJob *)buffer; - int32_t SimdLimit = - omptarget_nvptx_threadPrivateContext->SimdLimitForNextSimd(threadId); - job->slimForNextSimd = SimdLimit; - - int32_t SimdLimitSource = __kmpc_impl_shfl_sync(Mask, SimdLimit, *LaneSource); - // reset simdlimit to avoid propagating to successive #simd - if (SimdLimitSource > 0 && threadId == sourceThreadId) - omptarget_nvptx_threadPrivateContext->SimdLimitForNextSimd(threadId) = 0; - - // We cannot have more than the # of convergent threads. - if (SimdLimitSource > 0) - *NumLanes = __kmpc_impl_min(ConvergentSize, SimdLimitSource); - else - *NumLanes = ConvergentSize; - ASSERT(LT_FUSSY, *NumLanes > 0, "bad thread request of %d threads", - (int)*NumLanes); - - // Set to true for lanes participating in the simd region. - bool isActive = false; - // Initialize state for active threads. - if (*LaneId < *NumLanes) { - omptarget_nvptx_TaskDescr *currTaskDescr = - omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId); - omptarget_nvptx_TaskDescr *sourceTaskDescr = - omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr( - sourceThreadId); - job->convHeadTaskDescr = currTaskDescr; - // install top descriptor from the thread for which the lanes are working. - omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr(threadId, - sourceTaskDescr); - isActive = true; - } - - // requires a memory fence between threads of a warp - return isActive; -} - -EXTERN void __kmpc_kernel_end_convergent_simd(void *buffer) { - PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_end_convergent_parallel\n"); - // pop stack - int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); - ConvergentSimdJob *job = (ConvergentSimdJob *)buffer; - omptarget_nvptx_threadPrivateContext->SimdLimitForNextSimd(threadId) = - job->slimForNextSimd; - omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr( - threadId, job->convHeadTaskDescr); -} - -typedef struct ConvergentParallelJob { - omptarget_nvptx_TaskDescr taskDescr; - omptarget_nvptx_TaskDescr *convHeadTaskDescr; - uint16_t tnumForNextPar; -} ConvergentParallelJob; - -//////////////////////////////////////////////////////////////////////////////// -// support for convergent parallelism (team of threads in a warp only) -//////////////////////////////////////////////////////////////////////////////// -EXTERN bool __kmpc_kernel_convergent_parallel(void *buffer, - __kmpc_impl_lanemask_t Mask, - bool *IsFinal, - int32_t *LaneSource) { - PRINT0(LD_IO, "call to __kmpc_kernel_convergent_parallel\n"); - __kmpc_impl_lanemask_t ConvergentMask = Mask; - int32_t ConvergentSize = __kmpc_impl_popc(ConvergentMask); - __kmpc_impl_lanemask_t WorkRemaining = ConvergentMask >> (*LaneSource + 1); - *LaneSource += __kmpc_impl_ffs(WorkRemaining); - *IsFinal = __kmpc_impl_popc(WorkRemaining) == 1; - __kmpc_impl_lanemask_t lanemask_lt = __kmpc_impl_lanemask_lt(); - uint32_t OmpId = __kmpc_impl_popc(ConvergentMask & lanemask_lt); - - int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); - int sourceThreadId = (threadId & ~(WARPSIZE - 1)) + *LaneSource; - - ConvergentParallelJob *job = (ConvergentParallelJob *)buffer; - int32_t NumThreadsClause = - omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(threadId); - job->tnumForNextPar = NumThreadsClause; - - int32_t NumThreadsSource = - __kmpc_impl_shfl_sync(Mask, NumThreadsClause, *LaneSource); - // reset numthreads to avoid propagating to successive #parallel - if (NumThreadsSource > 0 && threadId == sourceThreadId) - omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(threadId) = - 0; - - // We cannot have more than the # of convergent threads. - uint16_t NumThreads; - if (NumThreadsSource > 0) - NumThreads = __kmpc_impl_min(ConvergentSize, NumThreadsSource); - else - NumThreads = ConvergentSize; - ASSERT(LT_FUSSY, NumThreads > 0, "bad thread request of %d threads", - (int)NumThreads); - - // Set to true for workers participating in the parallel region. - bool isActive = false; - // Initialize state for active threads. - if (OmpId < NumThreads) { - // init L2 task descriptor and storage for the L1 parallel task descriptor. - omptarget_nvptx_TaskDescr *newTaskDescr = &job->taskDescr; - ASSERT0(LT_FUSSY, newTaskDescr, "expected a task descr"); - omptarget_nvptx_TaskDescr *currTaskDescr = - omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr(threadId); - omptarget_nvptx_TaskDescr *sourceTaskDescr = - omptarget_nvptx_threadPrivateContext->GetTopLevelTaskDescr( - sourceThreadId); - job->convHeadTaskDescr = currTaskDescr; - newTaskDescr->CopyConvergentParent(sourceTaskDescr, OmpId, NumThreads); - // install new top descriptor - omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr(threadId, - newTaskDescr); - isActive = true; - } - - // requires a memory fence between threads of a warp - return isActive; -} - -EXTERN void __kmpc_kernel_end_convergent_parallel(void *buffer) { - PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_end_convergent_parallel\n"); - // pop stack - int threadId = GetLogicalThreadIdInBlock(isSPMDMode()); - ConvergentParallelJob *job = (ConvergentParallelJob *)buffer; - omptarget_nvptx_threadPrivateContext->SetTopLevelTaskDescr( - threadId, job->convHeadTaskDescr); - omptarget_nvptx_threadPrivateContext->NumThreadsForNextParallel(threadId) = - job->tnumForNextPar; -} - //////////////////////////////////////////////////////////////////////////////// // support for parallel that goes parallel (1 static level only) //////////////////////////////////////////////////////////////////////////////// @@ -446,14 +291,6 @@ EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t tid, num_threads; } -EXTERN void __kmpc_push_simd_limit(kmp_Ident *loc, int32_t tid, - int32_t simd_limit) { - PRINT(LD_IO, "call kmpc_push_simd_limit %d\n", (int)simd_limit); - ASSERT0(LT_FUSSY, checkRuntimeInitialized(loc), "Runtime must be initialized."); - tid = GetLogicalThreadIdInBlock(checkSPMDMode(loc)); - omptarget_nvptx_threadPrivateContext->SimdLimitForNextSimd(tid) = simd_limit; -} - // Do nothing. The host guarantees we started the requested number of // teams and we only need inspection of gridDim. diff --git a/openmp/libomptarget/deviceRTLs/common/src/reduction.cu b/openmp/libomptarget/deviceRTLs/common/src/reduction.cu index 427c90a7e091..0230fa26ac10 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/reduction.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/reduction.cu @@ -73,22 +73,6 @@ gpu_irregular_simd_reduce(void *reduce_data, kmp_ShuffleReductFctPtr shflFct) { return (logical_lane_id == 0); } -EXTERN -int32_t __kmpc_nvptx_simd_reduce_nowait(int32_t global_tid, int32_t num_vars, - size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, - kmp_InterWarpCopyFctPtr cpyFct) { - __kmpc_impl_lanemask_t Liveness = __kmpc_impl_activemask(); - if (Liveness == __kmpc_impl_all_lanes) { - gpu_regular_warp_reduce(reduce_data, shflFct); - return GetThreadIdInBlock() % WARPSIZE == - 0; // Result on lane 0 of the simd warp. - } else { - return gpu_irregular_simd_reduce( - reduce_data, shflFct); // Result on the first active lane. - } -} - INLINE static int32_t nvptx_parallel_reduce_nowait( int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, @@ -177,14 +161,6 @@ static int32_t nvptx_parallel_reduce_nowait( #endif // __CUDA_ARCH__ >= 700 } -EXTERN __attribute__((deprecated)) int32_t __kmpc_nvptx_parallel_reduce_nowait( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct) { - return nvptx_parallel_reduce_nowait(global_tid, num_vars, reduce_size, - reduce_data, shflFct, cpyFct, - isSPMDMode(), isRuntimeUninitialized()); -} - EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_v2( kmp_Ident *loc, int32_t global_tid, int32_t num_vars, size_t reduce_size, @@ -195,201 +171,6 @@ int32_t __kmpc_nvptx_parallel_reduce_nowait_v2( checkSPMDMode(loc), checkRuntimeUninitialized(loc)); } -EXTERN -int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_spmd( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct) { - return nvptx_parallel_reduce_nowait( - global_tid, num_vars, reduce_size, reduce_data, shflFct, cpyFct, - /*isSPMDExecutionMode=*/true, /*isRuntimeUninitialized=*/true); -} - -EXTERN -int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_generic( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct) { - return nvptx_parallel_reduce_nowait( - global_tid, num_vars, reduce_size, reduce_data, shflFct, cpyFct, - /*isSPMDExecutionMode=*/false, /*isRuntimeUninitialized=*/true); -} - -INLINE -static int32_t nvptx_teams_reduce_nowait(int32_t global_tid, int32_t num_vars, - size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, - kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr scratchFct, - kmp_LoadReduceFctPtr ldFct, - bool isSPMDExecutionMode) { - uint32_t ThreadId = GetLogicalThreadIdInBlock(isSPMDExecutionMode); - // In non-generic mode all workers participate in the teams reduction. - // In generic mode only the team master participates in the teams - // reduction because the workers are waiting for parallel work. - uint32_t NumThreads = - isSPMDExecutionMode ? GetNumberOfOmpThreads(/*isSPMDExecutionMode=*/true) - : /*Master thread only*/ 1; - uint32_t TeamId = GetBlockIdInKernel(); - uint32_t NumTeams = GetNumberOfBlocksInKernel(); - static SHARED volatile bool IsLastTeam; - - // Team masters of all teams write to the scratchpad. - if (ThreadId == 0) { - unsigned int *timestamp = GetTeamsReductionTimestamp(); - char *scratchpad = GetTeamsReductionScratchpad(); - - scratchFct(reduce_data, scratchpad, TeamId, NumTeams); - __kmpc_impl_threadfence(); - - // atomicInc increments 'timestamp' and has a range [0, NumTeams-1]. - // It resets 'timestamp' back to 0 once the last team increments - // this counter. - unsigned val = __kmpc_atomic_inc(timestamp, NumTeams - 1); - IsLastTeam = val == NumTeams - 1; - } - - // We have to wait on L1 barrier because in GENERIC mode the workers - // are waiting on barrier 0 for work. - // - // If we guard this barrier as follows it leads to deadlock, probably - // because of a compiler bug: if (!IsGenericMode()) __syncthreads(); - uint16_t SyncWarps = (NumThreads + WARPSIZE - 1) / WARPSIZE; - __kmpc_impl_named_sync(L1_BARRIER, SyncWarps * WARPSIZE); - - // If this team is not the last, quit. - if (/* Volatile read by all threads */ !IsLastTeam) - return 0; - - // - // Last team processing. - // - - // Threads in excess of #teams do not participate in reduction of the - // scratchpad values. -#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 700 - uint32_t ActiveThreads = NumThreads; - if (NumTeams < NumThreads) { - ActiveThreads = - (NumTeams < WARPSIZE) ? 1 : NumTeams & ~((uint16_t)WARPSIZE - 1); - } - if (ThreadId >= ActiveThreads) - return 0; - - // Load from scratchpad and reduce. - char *scratchpad = GetTeamsReductionScratchpad(); - ldFct(reduce_data, scratchpad, ThreadId, NumTeams, /*Load only*/ 0); - for (uint32_t i = ActiveThreads + ThreadId; i < NumTeams; i += ActiveThreads) - ldFct(reduce_data, scratchpad, i, NumTeams, /*Load and reduce*/ 1); - - uint32_t WarpsNeeded = (ActiveThreads + WARPSIZE - 1) / WARPSIZE; - uint32_t WarpId = ThreadId / WARPSIZE; - - // Reduce across warps to the warp master. - if ((ActiveThreads % WARPSIZE == 0) || - (WarpId < WarpsNeeded - 1)) // Full warp - gpu_regular_warp_reduce(reduce_data, shflFct); - else if (ActiveThreads > 1) // Partial warp but contiguous lanes - // Only SPMD execution mode comes thru this case. - gpu_irregular_warp_reduce(reduce_data, shflFct, - /*LaneCount=*/ActiveThreads % WARPSIZE, - /*LaneId=*/ThreadId % WARPSIZE); - - // When we have more than [warpsize] number of threads - // a block reduction is performed here. - if (ActiveThreads > WARPSIZE) { - // Gather all the reduced values from each warp - // to the first warp. - cpyFct(reduce_data, WarpsNeeded); - - if (WarpId == 0) - gpu_irregular_warp_reduce(reduce_data, shflFct, WarpsNeeded, ThreadId); - } -#else - if (ThreadId >= NumTeams) - return 0; - - // Load from scratchpad and reduce. - char *scratchpad = GetTeamsReductionScratchpad(); - ldFct(reduce_data, scratchpad, ThreadId, NumTeams, /*Load only*/ 0); - for (uint32_t i = NumThreads + ThreadId; i < NumTeams; i += NumThreads) - ldFct(reduce_data, scratchpad, i, NumTeams, /*Load and reduce*/ 1); - - // Reduce across warps to the warp master. - __kmpc_impl_lanemask_t Liveness = __kmpc_impl_activemask(); - if (Liveness == __kmpc_impl_all_lanes) // Full warp - gpu_regular_warp_reduce(reduce_data, shflFct); - else // Partial warp but contiguous lanes - gpu_irregular_warp_reduce(reduce_data, shflFct, - /*LaneCount=*/__kmpc_impl_popc(Liveness), - /*LaneId=*/ThreadId % WARPSIZE); - - // When we have more than [warpsize] number of threads - // a block reduction is performed here. - uint32_t ActiveThreads = NumTeams < NumThreads ? NumTeams : NumThreads; - if (ActiveThreads > WARPSIZE) { - uint32_t WarpsNeeded = (ActiveThreads + WARPSIZE - 1) / WARPSIZE; - // Gather all the reduced values from each warp - // to the first warp. - cpyFct(reduce_data, WarpsNeeded); - - uint32_t WarpId = ThreadId / WARPSIZE; - if (WarpId == 0) - gpu_irregular_warp_reduce(reduce_data, shflFct, WarpsNeeded, ThreadId); - } -#endif // __CUDA_ARCH__ >= 700 - - return ThreadId == 0; -} - -EXTERN -int32_t __kmpc_nvptx_teams_reduce_nowait(int32_t global_tid, int32_t num_vars, - size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, - kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr scratchFct, - kmp_LoadReduceFctPtr ldFct) { - return nvptx_teams_reduce_nowait(global_tid, num_vars, reduce_size, - reduce_data, shflFct, cpyFct, scratchFct, - ldFct, isSPMDMode()); -} - -EXTERN -int32_t __kmpc_nvptx_teams_reduce_nowait_simple_spmd( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr scratchFct, kmp_LoadReduceFctPtr ldFct) { - return nvptx_teams_reduce_nowait(global_tid, num_vars, reduce_size, - reduce_data, shflFct, cpyFct, scratchFct, - ldFct, /*isSPMDExecutionMode=*/true); -} - -EXTERN -int32_t __kmpc_nvptx_teams_reduce_nowait_simple_generic( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr scratchFct, kmp_LoadReduceFctPtr ldFct) { - return nvptx_teams_reduce_nowait(global_tid, num_vars, reduce_size, - reduce_data, shflFct, cpyFct, scratchFct, - ldFct, /*isSPMDExecutionMode=*/false); -} - -EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple(kmp_Ident *loc, - int32_t global_tid, - kmp_CriticalName *crit) { - if (checkSPMDMode(loc) && GetThreadIdInBlock() != 0) - return 0; - // The master thread of the team actually does the reduction. - while (__kmpc_atomic_cas((uint32_t *)crit, 0u, 1u)) - ; - return 1; -} - -EXTERN void -__kmpc_nvptx_teams_end_reduce_nowait_simple(kmp_Ident *loc, int32_t global_tid, - kmp_CriticalName *crit) { - __kmpc_impl_threadfence_system(); - (void)__kmpc_atomic_exchange((uint32_t *)crit, 0u); -} - INLINE static bool isMaster(kmp_Ident *loc, uint32_t ThreadId) { return checkGenericMode(loc) || IsTeamMaster(ThreadId); } diff --git a/openmp/libomptarget/deviceRTLs/common/src/support.cu b/openmp/libomptarget/deviceRTLs/common/src/support.cu index 85747511d46c..e02c533e78b2 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/support.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/support.cu @@ -264,6 +264,3 @@ DEVICE char *GetTeamsReductionScratchpad() { return static_cast(ReductionScratchpadPtr) + 256; } -DEVICE void SetTeamsReductionScratchpadPtr(void *ScratchpadPtr) { - ReductionScratchpadPtr = ScratchpadPtr; -} diff --git a/openmp/libomptarget/deviceRTLs/common/src/sync.cu b/openmp/libomptarget/deviceRTLs/common/src/sync.cu index 2ac3e3f9c7c0..3979e2054fc9 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/sync.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/sync.cu @@ -79,23 +79,6 @@ EXTERN void __kmpc_barrier_simple_spmd(kmp_Ident *loc_ref, int32_t tid) { PRINT0(LD_SYNC, "completed kmpc_barrier_simple_spmd\n"); } -// Emit a simple barrier call in Generic mode. Assumes the caller is in an L0 -// parallel region and that all worker threads participate. -EXTERN void __kmpc_barrier_simple_generic(kmp_Ident *loc_ref, int32_t tid) { - int numberOfActiveOMPThreads = GetNumberOfThreadsInBlock() - WARPSIZE; - // The #threads parameter must be rounded up to the WARPSIZE. - int threads = - WARPSIZE * ((numberOfActiveOMPThreads + WARPSIZE - 1) / WARPSIZE); - - PRINT(LD_SYNC, - "call kmpc_barrier_simple_generic with %d omp threads, sync parameter " - "%d\n", - (int)numberOfActiveOMPThreads, (int)threads); - // Barrier #1 is for synchronization among active threads. - __kmpc_impl_named_sync(L1_BARRIER, threads); - PRINT0(LD_SYNC, "completed kmpc_barrier_simple_generic\n"); -} - //////////////////////////////////////////////////////////////////////////////// // KMP MASTER //////////////////////////////////////////////////////////////////////////////// diff --git a/openmp/libomptarget/deviceRTLs/common/support.h b/openmp/libomptarget/deviceRTLs/common/support.h index 913c4c3c323f..a46432825782 100644 --- a/openmp/libomptarget/deviceRTLs/common/support.h +++ b/openmp/libomptarget/deviceRTLs/common/support.h @@ -94,6 +94,5 @@ DEVICE unsigned long PadBytes(unsigned long size, unsigned long alignment); //////////////////////////////////////////////////////////////////////////////// DEVICE unsigned int *GetTeamsReductionTimestamp(); DEVICE char *GetTeamsReductionScratchpad(); -DEVICE void SetTeamsReductionScratchpadPtr(void *ScratchpadPtr); #endif diff --git a/openmp/libomptarget/deviceRTLs/interface.h b/openmp/libomptarget/deviceRTLs/interface.h index 3c216a5e61c5..39ce73cba957 100644 --- a/openmp/libomptarget/deviceRTLs/interface.h +++ b/openmp/libomptarget/deviceRTLs/interface.h @@ -193,17 +193,10 @@ typedef struct ident { // parallel defs typedef ident_t kmp_Ident; -typedef void (*kmp_ParFctPtr)(int32_t *global_tid, int32_t *bound_tid, ...); -typedef void (*kmp_ReductFctPtr)(void *lhsData, void *rhsData); typedef void (*kmp_InterWarpCopyFctPtr)(void *src, int32_t warp_num); typedef void (*kmp_ShuffleReductFctPtr)(void *rhsData, int16_t lane_id, int16_t lane_offset, int16_t shortCircuit); -typedef void (*kmp_CopyToScratchpadFctPtr)(void *reduceData, void *scratchpad, - int32_t index, int32_t width); -typedef void (*kmp_LoadReduceFctPtr)(void *reduceData, void *scratchpad, - int32_t index, int32_t width, - int32_t reduce); typedef void (*kmp_ListGlobalFctPtr)(void *buffer, int idx, void *reduce_data); // task defs @@ -227,12 +220,6 @@ typedef int32_t kmp_CriticalName[8]; EXTERN int32_t __kmpc_global_thread_num(kmp_Ident *loc); EXTERN void __kmpc_push_num_threads(kmp_Ident *loc, int32_t global_tid, int32_t num_threads); -// simd -EXTERN void __kmpc_push_simd_limit(kmp_Ident *loc, int32_t global_tid, - int32_t simd_limit); -// aee ... not supported -// EXTERN void __kmpc_fork_call(kmp_Ident *loc, int32_t argc, kmp_ParFctPtr -// microtask, ...); EXTERN void __kmpc_serialized_parallel(kmp_Ident *loc, uint32_t global_tid); EXTERN void __kmpc_end_serialized_parallel(kmp_Ident *loc, uint32_t global_tid); @@ -354,61 +341,25 @@ EXTERN void __kmpc_dispatch_fini_4u(kmp_Ident *loc, int32_t global_tid); EXTERN void __kmpc_dispatch_fini_8(kmp_Ident *loc, int32_t global_tid); EXTERN void __kmpc_dispatch_fini_8u(kmp_Ident *loc, int32_t global_tid); -// Support for reducing conditional lastprivate variables -EXTERN void __kmpc_reduce_conditional_lastprivate(kmp_Ident *loc, - int32_t global_tid, - int32_t varNum, void *array); - // reduction EXTERN void __kmpc_nvptx_end_reduce(int32_t global_tid); EXTERN void __kmpc_nvptx_end_reduce_nowait(int32_t global_tid); -EXTERN __attribute__((deprecated)) int32_t __kmpc_nvptx_parallel_reduce_nowait( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_v2( kmp_Ident *loc, int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); -EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_spmd( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); -EXTERN int32_t __kmpc_nvptx_parallel_reduce_nowait_simple_generic( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); -EXTERN int32_t __kmpc_nvptx_simd_reduce_nowait( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct); EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_v2( kmp_Ident *loc, int32_t global_tid, void *global_buffer, int32_t num_of_records, void *reduce_data, kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, kmp_ListGlobalFctPtr lgcpyFct, kmp_ListGlobalFctPtr lgredFct, kmp_ListGlobalFctPtr glcpyFct, kmp_ListGlobalFctPtr glredFct); -EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr sratchFct, kmp_LoadReduceFctPtr ldFct); -EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple_spmd( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr sratchFct, kmp_LoadReduceFctPtr ldFct); -EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple_generic( - int32_t global_tid, int32_t num_vars, size_t reduce_size, void *reduce_data, - kmp_ShuffleReductFctPtr shflFct, kmp_InterWarpCopyFctPtr cpyFct, - kmp_CopyToScratchpadFctPtr sratchFct, kmp_LoadReduceFctPtr ldFct); -EXTERN int32_t __kmpc_nvptx_teams_reduce_nowait_simple(kmp_Ident *loc, - int32_t global_tid, - kmp_CriticalName *crit); -EXTERN void __kmpc_nvptx_teams_end_reduce_nowait_simple(kmp_Ident *loc, - int32_t global_tid, - kmp_CriticalName *crit); EXTERN int32_t __kmpc_shuffle_int32(int32_t val, int16_t delta, int16_t size); EXTERN int64_t __kmpc_shuffle_int64(int64_t val, int16_t delta, int16_t size); // sync barrier EXTERN void __kmpc_barrier(kmp_Ident *loc_ref, int32_t tid); EXTERN void __kmpc_barrier_simple_spmd(kmp_Ident *loc_ref, int32_t tid); -EXTERN void __kmpc_barrier_simple_generic(kmp_Ident *loc_ref, int32_t tid); EXTERN int32_t __kmpc_cancel_barrier(kmp_Ident *loc, int32_t global_tid); // single @@ -468,29 +419,16 @@ EXTERN int32_t __kmpc_cancel(kmp_Ident *loc, int32_t global_tid, int32_t cancelVal); // non standard -EXTERN void __kmpc_kernel_init_params(void *ReductionScratchpadPtr); EXTERN void __kmpc_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime); EXTERN void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized); EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime, int16_t RequiresDataSharing); -EXTERN __attribute__((deprecated)) void __kmpc_spmd_kernel_deinit(); EXTERN void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime); EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, int16_t IsOMPRuntimeInitialized); EXTERN bool __kmpc_kernel_parallel(void **WorkFn, int16_t IsOMPRuntimeInitialized); EXTERN void __kmpc_kernel_end_parallel(); -EXTERN bool __kmpc_kernel_convergent_parallel(void *buffer, - __kmpc_impl_lanemask_t Mask, - bool *IsFinal, - int32_t *LaneSource); -EXTERN void __kmpc_kernel_end_convergent_parallel(void *buffer); -EXTERN bool __kmpc_kernel_convergent_simd(void *buffer, - __kmpc_impl_lanemask_t Mask, - bool *IsFinal, int32_t *LaneSource, - int32_t *LaneId, int32_t *NumLanes); -EXTERN void __kmpc_kernel_end_convergent_simd(void *buffer); - EXTERN void __kmpc_data_sharing_init_stack(); EXTERN void __kmpc_data_sharing_init_stack_spmd(); @@ -512,22 +450,6 @@ struct __kmpc_data_sharing_slot { void *DataEnd; char Data[]; }; -EXTERN void -__kmpc_initialize_data_sharing_environment(__kmpc_data_sharing_slot *RootS, - size_t InitialDataSize); -EXTERN void *__kmpc_data_sharing_environment_begin( - __kmpc_data_sharing_slot **SavedSharedSlot, void **SavedSharedStack, - void **SavedSharedFrame, __kmpc_impl_lanemask_t *SavedActiveThreads, - size_t SharingDataSize, size_t SharingDefaultDataSize, - int16_t IsOMPRuntimeInitialized); -EXTERN void __kmpc_data_sharing_environment_end( - __kmpc_data_sharing_slot **SavedSharedSlot, void **SavedSharedStack, - void **SavedSharedFrame, __kmpc_impl_lanemask_t *SavedActiveThreads, - int32_t IsEntryPoint); - -EXTERN void * -__kmpc_get_data_sharing_environment_frame(int32_t SourceThreadID, - int16_t IsOMPRuntimeInitialized); // SPMD execution mode interrogation function. EXTERN int8_t __kmpc_is_spmd_exec_mode(); diff --git a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h index 1b966510ec7e..d009e36a522f 100644 --- a/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h +++ b/openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h @@ -195,15 +195,6 @@ INLINE int GetNumberOfThreadsInBlock() { return blockDim.x; } INLINE unsigned GetWarpId() { return GetThreadIdInBlock() / WARPSIZE; } INLINE unsigned GetLaneId() { return GetThreadIdInBlock() & (WARPSIZE - 1); } -// Return true if this is the first active thread in the warp. -INLINE bool __kmpc_impl_is_first_active_thread() { - unsigned long long Mask = __kmpc_impl_activemask(); - unsigned long long ShNum = WARPSIZE - (GetThreadIdInBlock() % WARPSIZE); - unsigned long long Sh = Mask << ShNum; - // Truncate Sh to the 32 lower bits - return (unsigned)Sh == 0; -} - // Locks EXTERN void __kmpc_impl_init_lock(omp_lock_t *lock); EXTERN void __kmpc_impl_destroy_lock(omp_lock_t *lock); From cfe-commits at lists.llvm.org Fri Jul 10 17:11:38 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 00:11:38 +0000 (UTC) Subject: [PATCH] D83349: [OpenMP][NFC] Remove unused and untested code from the device runtime In-Reply-To: References: Message-ID: <06d115cfc2e20f9240bda0247cace9fb@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGcd0ea03e6f15: [OpenMP][NFC] Remove unused and untested code from the device runtime (authored by jdoerfert). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83349/new/ https://reviews.llvm.org/D83349 Files: clang/test/OpenMP/nvptx_target_simd_codegen.cpp openmp/libomptarget/deviceRTLs/amdgcn/src/target_impl.h openmp/libomptarget/deviceRTLs/common/omptarget.h openmp/libomptarget/deviceRTLs/common/src/data_sharing.cu openmp/libomptarget/deviceRTLs/common/src/libcall.cu openmp/libomptarget/deviceRTLs/common/src/loop.cu openmp/libomptarget/deviceRTLs/common/src/omptarget.cu openmp/libomptarget/deviceRTLs/common/src/parallel.cu openmp/libomptarget/deviceRTLs/common/src/reduction.cu openmp/libomptarget/deviceRTLs/common/src/support.cu openmp/libomptarget/deviceRTLs/common/src/sync.cu openmp/libomptarget/deviceRTLs/common/support.h openmp/libomptarget/deviceRTLs/interface.h openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D83349.277176.patch Type: text/x-patch Size: 50590 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 17:24:35 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via cfe-commits) Date: Fri, 10 Jul 2020 17:24:35 -0700 (PDT) Subject: [clang] e9bf0a7 - [CodeGen] Store the return value of the target function call to the Message-ID: <5f0906c3.1c69fb81.dfe2e.1c43@mx.google.com> Author: Akira Hatanaka Date: 2020-07-10T17:24:13-07:00 New Revision: e9bf0a710c993b932fa69c95ef6d0130fd721115 URL: https://github.com/llvm/llvm-project/commit/e9bf0a710c993b932fa69c95ef6d0130fd721115 DIFF: https://github.com/llvm/llvm-project/commit/e9bf0a710c993b932fa69c95ef6d0130fd721115.diff LOG: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary This fixes PR45997 (https://bugs.llvm.org/show_bug.cgi?id=45997), which is caused by a bug that has existed since we started passing and returning C++ structs with ObjC strong pointer members (see https://reviews.llvm.org/D44908) or structs annotated with trivial_abi directly. rdar://problem/63740936 Differential Revision: https://reviews.llvm.org/D82513 Added: Modified: clang/lib/CodeGen/CGCXXABI.cpp clang/lib/CodeGen/CGVTables.cpp clang/test/CodeGenCXX/trivial_abi.cpp clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp index 928fbaea8278..3d65c0ea805e 100644 --- a/clang/lib/CodeGen/CGCXXABI.cpp +++ b/clang/lib/CodeGen/CGCXXABI.cpp @@ -156,6 +156,7 @@ void CGCXXABI::setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr) { void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType) { + assert(!hasAggregateEvaluationKind(ResultType) && "cannot handle aggregates"); CGF.EmitReturnOfRValue(RV, ResultType); } diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 276993581117..65b3b0c5f53d 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -363,7 +363,8 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee, : FPT->getReturnType(); ReturnValueSlot Slot; if (!ResultType->isVoidType() && - CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) + (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect || + hasAggregateEvaluationKind(ResultType))) Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified(), /*IsUnused=*/false, /*IsExternallyDestructed=*/true); diff --git a/clang/test/CodeGenCXX/trivial_abi.cpp b/clang/test/CodeGenCXX/trivial_abi.cpp index e7e7f840944d..cb9b9dfeb4bd 100644 --- a/clang/test/CodeGenCXX/trivial_abi.cpp +++ b/clang/test/CodeGenCXX/trivial_abi.cpp @@ -43,6 +43,31 @@ struct HasNonTrivial { NonTrivial m; }; +struct B0 { + virtual Small m0(); +}; + +struct B1 { + virtual Small m0(); +}; + +struct D0 : B0, B1 { + Small m0() override; +}; + +// CHECK-LABEL: define i64 @_ZThn8_N2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i32* +// CHECK: store i32* %[[COERCE_VAL_IP]], i32** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i32*, i32** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i32* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +Small D0::m0() { return {}; } + // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]]) // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0 diff --git a/clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm b/clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm index 7a7781f68891..d19534f6922d 100644 --- a/clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm +++ b/clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm @@ -178,3 +178,32 @@ void testParamContainsNonTrivial(ContainsNonTrivial a) { void testCallContainsNonTrivial(ContainsNonTrivial *a) { testParamContainsNonTrivial(*a); } + +namespace testThunk { + +// CHECK-LABEL: define i64 @_ZThn8_N9testThunk2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN9testThunk2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i8* +// CHECK: store i8* %[[COERCE_VAL_IP]], i8** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i8*, i8** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i8* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +struct B0 { + virtual Strong m0(); +}; + +struct B1 { + virtual Strong m0(); +}; + +struct D0 : B0, B1 { + Strong m0() override; +}; + +Strong D0::m0() { return {}; } + +} From cfe-commits at lists.llvm.org Fri Jul 10 17:24:40 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 00:24:40 +0000 (UTC) Subject: [PATCH] D82513: [CodeGen] Store the return value of the target function call to the thunk's return value slot directly when the return type is an aggregate instead of doing so via a temporary In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGe9bf0a710c99: [CodeGen] Store the return value of the target function call to the thunk's… (authored by ahatanak). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82513/new/ https://reviews.llvm.org/D82513 Files: clang/lib/CodeGen/CGCXXABI.cpp clang/lib/CodeGen/CGVTables.cpp clang/test/CodeGenCXX/trivial_abi.cpp clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm Index: clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm =================================================================== --- clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm +++ clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm @@ -178,3 +178,32 @@ void testCallContainsNonTrivial(ContainsNonTrivial *a) { testParamContainsNonTrivial(*a); } + +namespace testThunk { + +// CHECK-LABEL: define i64 @_ZThn8_N9testThunk2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONG]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN9testThunk2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i8* +// CHECK: store i8* %[[COERCE_VAL_IP]], i8** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i8*, i8** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i8* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +struct B0 { + virtual Strong m0(); +}; + +struct B1 { + virtual Strong m0(); +}; + +struct D0 : B0, B1 { + Strong m0() override; +}; + +Strong D0::m0() { return {}; } + +} Index: clang/test/CodeGenCXX/trivial_abi.cpp =================================================================== --- clang/test/CodeGenCXX/trivial_abi.cpp +++ clang/test/CodeGenCXX/trivial_abi.cpp @@ -43,6 +43,31 @@ NonTrivial m; }; +struct B0 { + virtual Small m0(); +}; + +struct B1 { + virtual Small m0(); +}; + +struct D0 : B0, B1 { + Small m0() override; +}; + +// CHECK-LABEL: define i64 @_ZThn8_N2D02m0Ev( +// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8 +// CHECK: %[[CALL:.*]] = tail call i64 @_ZN2D02m0Ev( +// CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[CALL]] to i32* +// CHECK: store i32* %[[COERCE_VAL_IP]], i32** %[[COERCE_DIVE]], align 8 +// CHECK: %[[COERCE_DIVE2:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[RETVAL]], i32 0, i32 0 +// CHECK: %[[V3:.*]] = load i32*, i32** %[[COERCE_DIVE2]], align 8 +// CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint i32* %[[V3]] to i64 +// CHECK: ret i64 %[[COERCE_VAL_PI]] + +Small D0::m0() { return {}; } + // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]]) // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], %[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0 Index: clang/lib/CodeGen/CGVTables.cpp =================================================================== --- clang/lib/CodeGen/CGVTables.cpp +++ clang/lib/CodeGen/CGVTables.cpp @@ -363,7 +363,8 @@ : FPT->getReturnType(); ReturnValueSlot Slot; if (!ResultType->isVoidType() && - CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect) + (CurFnInfo->getReturnInfo().getKind() == ABIArgInfo::Indirect || + hasAggregateEvaluationKind(ResultType))) Slot = ReturnValueSlot(ReturnValue, ResultType.isVolatileQualified(), /*IsUnused=*/false, /*IsExternallyDestructed=*/true); Index: clang/lib/CodeGen/CGCXXABI.cpp =================================================================== --- clang/lib/CodeGen/CGCXXABI.cpp +++ clang/lib/CodeGen/CGCXXABI.cpp @@ -156,6 +156,7 @@ void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType) { + assert(!hasAggregateEvaluationKind(ResultType) && "cannot handle aggregates"); CGF.EmitReturnOfRValue(RV, ResultType); } -------------- next part -------------- A non-text attachment was scrubbed... Name: D82513.277181.patch Type: text/x-patch Size: 3774 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 17:42:26 2020 From: cfe-commits at lists.llvm.org (Akira Hatanaka via cfe-commits) Date: Fri, 10 Jul 2020 17:42:26 -0700 (PDT) Subject: [clang] 3a5617c - Fix build error Message-ID: <5f090af2.1c69fb81.a57ff.019d@mx.google.com> Author: Akira Hatanaka Date: 2020-07-10T17:40:37-07:00 New Revision: 3a5617c02e38618bd5534491077afbc7178adf3f URL: https://github.com/llvm/llvm-project/commit/3a5617c02e38618bd5534491077afbc7178adf3f DIFF: https://github.com/llvm/llvm-project/commit/3a5617c02e38618bd5534491077afbc7178adf3f.diff LOG: Fix build error Added: Modified: clang/lib/CodeGen/CGCXXABI.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGCXXABI.cpp b/clang/lib/CodeGen/CGCXXABI.cpp index 3d65c0ea805e..65327a2435b5 100644 --- a/clang/lib/CodeGen/CGCXXABI.cpp +++ b/clang/lib/CodeGen/CGCXXABI.cpp @@ -156,7 +156,8 @@ void CGCXXABI::setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr) { void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType) { - assert(!hasAggregateEvaluationKind(ResultType) && "cannot handle aggregates"); + assert(!CGF.hasAggregateEvaluationKind(ResultType) && + "cannot handle aggregates"); CGF.EmitReturnOfRValue(RV, ResultType); } From cfe-commits at lists.llvm.org Fri Jul 10 17:44:30 2020 From: cfe-commits at lists.llvm.org (Jon Chesterfield via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 00:44:30 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <0f003323c7af7e6f7f8725dc331c4276@localhost.localdomain> JonChesterfield added a comment. In D83591#2145437 , @jdoerfert wrote: > I did not know they are using __clang_cuda headers. (Site note, we should rename them then.) I also did not know that. I am repeatedly caught out by things named 'cuda', 'nvptx' or '__nv' being used by amdgpu. Perhaps we should refactor the __clang_cuda_* headers to make the distinctions between cuda, hip, openmp-nvptx, openmp-amdgcn clear(er). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 18:11:24 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 01:11:24 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: tra added a comment. In D83591#2145512 , @JonChesterfield wrote: > In D83591#2145437 , @jdoerfert wrote: > > > I did not know they are using __clang_cuda headers. (Site note, we should rename them then.) > > > I also did not know that. I am repeatedly caught out by things named 'cuda', 'nvptx' or '__nv' being used by amdgpu. It's complicated. :-) Originally clang's headers were written to tactically fill in the gaps in the CUDA SDK headers that clang could not deal with. OpenMP grew NVPTX back-end support and wanted to use a subset of those headers that happened to be conveniently close to math.h AMD's HIP shares C++ front-end with CUDA and wants to benefit from the standard library glue we've implemented for CUDA. It also uses a lot of things internally that were originally targeting CUDA, but are now reused for HIP as well. Hence there are number of places where 'cuda' things do the double duty during HIP compilation. So do some of the CUDA-related headers. > Perhaps we should refactor the __clang_cuda_* headers to make the distinctions between cuda, hip, openmp-nvptx, openmp-amdgcn clear(er). Agreed. Balancing OpenMP and CUDA constraints was interesting. With HIP in the picture, it will be even more so. TBH at the moment I do not see a clean way to satisfy all users of GPU-related things in clang. That said, now may be a good time to deal with this. AMD has made a lot of progress making clang work for targeting AMD GPUs and it will likely see a lot more use relatively soon. We do want to keep things working for all parties involved. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 18:12:36 2020 From: cfe-commits at lists.llvm.org (Artem Belevich via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 01:12:36 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: tra accepted this revision. tra added a comment. LGTM. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 18:31:35 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via cfe-commits) Date: Fri, 10 Jul 2020 18:31:35 -0700 (PDT) Subject: [clang] 17ea41e - Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. Message-ID: <5f091677.1c69fb81.3780c.2595@mx.google.com> Author: Vy Nguyen Date: 2020-07-10T21:31:16-04:00 New Revision: 17ea41e472566823e16d3a04661221fbd18d9fae URL: https://github.com/llvm/llvm-project/commit/17ea41e472566823e16d3a04661221fbd18d9fae DIFF: https://github.com/llvm/llvm-project/commit/17ea41e472566823e16d3a04661221fbd18d9fae.diff LOG: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. Summary: This helps avoiding hacks downstream. Reviewers: shafik Subscribers: martong, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83529 Added: Modified: clang/include/clang/AST/Stmt.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Stmt.cpp clang/lib/Parse/ParseStmt.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/unittests/AST/SourceLocationTest.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 01d4301922f8..d3fad58fcf59 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -2277,6 +2277,8 @@ class WhileStmt final : public Stmt, enum { VarOffset = 0, BodyOffsetFromCond = 1 }; enum { NumMandatoryStmtPtr = 2 }; + SourceLocation LParenLoc, RParenLoc; + unsigned varOffset() const { return VarOffset; } unsigned condOffset() const { return VarOffset + hasVarStorage(); } unsigned bodyOffset() const { return condOffset() + BodyOffsetFromCond; } @@ -2287,7 +2289,8 @@ class WhileStmt final : public Stmt, /// Build a while statement. WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, - SourceLocation WL); + SourceLocation WL, SourceLocation LParenLoc, + SourceLocation RParenLoc); /// Build an empty while statement. explicit WhileStmt(EmptyShell Empty, bool HasVar); @@ -2295,7 +2298,8 @@ class WhileStmt final : public Stmt, public: /// Create a while statement. static WhileStmt *Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, - Stmt *Body, SourceLocation WL); + Stmt *Body, SourceLocation WL, + SourceLocation LParenLoc, SourceLocation RParenLoc); /// Create an empty while statement optionally with storage for /// a condition variable. @@ -2359,6 +2363,11 @@ class WhileStmt final : public Stmt, SourceLocation getWhileLoc() const { return WhileStmtBits.WhileLoc; } void setWhileLoc(SourceLocation L) { WhileStmtBits.WhileLoc = L; } + SourceLocation getLParenLoc() const { return LParenLoc; } + void setLParenLoc(SourceLocation L) { LParenLoc = L; } + SourceLocation getRParenLoc() const { return RParenLoc; } + void setRParenLoc(SourceLocation L) { RParenLoc = L; } + SourceLocation getBeginLoc() const { return getWhileLoc(); } SourceLocation getEndLoc() const LLVM_READONLY { return getBody()->getEndLoc(); diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 1d75515d494e..e809d87b59a0 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -2071,8 +2071,9 @@ class Parser : public CodeCompletionHandler { StmtResult ParseCompoundStatementBody(bool isStmtExpr = false); bool ParseParenExprOrCondition(StmtResult *InitStmt, Sema::ConditionResult &CondResult, - SourceLocation Loc, - Sema::ConditionKind CK); + SourceLocation Loc, Sema::ConditionKind CK, + SourceLocation *LParenLoc = nullptr, + SourceLocation *RParenLoc = nullptr); StmtResult ParseIfStatement(SourceLocation *TrailingElseLoc); StmtResult ParseSwitchStatement(SourceLocation *TrailingElseLoc); StmtResult ParseWhileStatement(SourceLocation *TrailingElseLoc); diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index c3bebea0cccb..e75ac185eb2c 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -4377,7 +4377,8 @@ class Sema final { ConditionResult Cond); StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body); - StmtResult ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, + StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, + ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body); StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index fa2421ee826e..3779e0cb872b 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -6117,11 +6117,13 @@ ExpectedStmt ASTNodeImporter::VisitWhileStmt(WhileStmt *S) { auto ToCond = importChecked(Err, S->getCond()); auto ToBody = importChecked(Err, S->getBody()); auto ToWhileLoc = importChecked(Err, S->getWhileLoc()); + auto ToLParenLoc = importChecked(Err, S->getLParenLoc()); + auto ToRParenLoc = importChecked(Err, S->getRParenLoc()); if (Err) return std::move(Err); return WhileStmt::Create(Importer.getToContext(), ToConditionVariable, ToCond, - ToBody, ToWhileLoc); + ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc); } ExpectedStmt ASTNodeImporter::VisitDoStmt(DoStmt *S) { diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index ce76d4941b32..25e685be3e9b 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -1012,7 +1012,8 @@ void SwitchStmt::setConditionVariable(const ASTContext &Ctx, VarDecl *V) { } WhileStmt::WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, - Stmt *Body, SourceLocation WL) + Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, + SourceLocation RParenLoc) : Stmt(WhileStmtClass) { bool HasVar = Var != nullptr; WhileStmtBits.HasVar = HasVar; @@ -1023,6 +1024,8 @@ WhileStmt::WhileStmt(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, setConditionVariable(Ctx, Var); setWhileLoc(WL); + setLParenLoc(LParenLoc); + setRParenLoc(RParenLoc); } WhileStmt::WhileStmt(EmptyShell Empty, bool HasVar) @@ -1031,12 +1034,14 @@ WhileStmt::WhileStmt(EmptyShell Empty, bool HasVar) } WhileStmt *WhileStmt::Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, - Stmt *Body, SourceLocation WL) { + Stmt *Body, SourceLocation WL, + SourceLocation LParenLoc, + SourceLocation RParenLoc) { bool HasVar = Var != nullptr; void *Mem = Ctx.Allocate(totalSizeToAlloc(NumMandatoryStmtPtr + HasVar), alignof(WhileStmt)); - return new (Mem) WhileStmt(Ctx, Var, Cond, Body, WL); + return new (Mem) WhileStmt(Ctx, Var, Cond, Body, WL, LParenLoc, RParenLoc); } WhileStmt *WhileStmt::CreateEmpty(const ASTContext &Ctx, bool HasVar) { diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 3299a059c437..89a6a2b829ae 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1156,10 +1156,14 @@ StmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { /// should try to recover harder. It returns false if the condition is /// successfully parsed. Note that a successful parse can still have semantic /// errors in the condition. +/// Additionally, if LParenLoc and RParenLoc are non-null, it will assign +/// the location of the outer-most '(' and ')', respectively, to them. bool Parser::ParseParenExprOrCondition(StmtResult *InitStmt, Sema::ConditionResult &Cond, SourceLocation Loc, - Sema::ConditionKind CK) { + Sema::ConditionKind CK, + SourceLocation *LParenLoc, + SourceLocation *RParenLoc) { BalancedDelimiterTracker T(*this, tok::l_paren); T.consumeOpen(); @@ -1189,6 +1193,13 @@ bool Parser::ParseParenExprOrCondition(StmtResult *InitStmt, // Otherwise the condition is valid or the rparen is present. T.consumeClose(); + if (LParenLoc != nullptr) { + *LParenLoc = T.getOpenLocation(); + } + if (RParenLoc != nullptr) { + *RParenLoc = T.getCloseLocation(); + } + // Check for extraneous ')'s to catch things like "if (foo())) {". We know // that all callers are looking for a statement after the condition, so ")" // isn't valid. @@ -1582,8 +1593,10 @@ StmtResult Parser::ParseWhileStatement(SourceLocation *TrailingElseLoc) { // Parse the condition. Sema::ConditionResult Cond; + SourceLocation LParen; + SourceLocation RParen; if (ParseParenExprOrCondition(nullptr, Cond, WhileLoc, - Sema::ConditionKind::Boolean)) + Sema::ConditionKind::Boolean, &LParen, &RParen)) return StmtError(); // C99 6.8.5p5 - In C99, the body of the while statement is a scope, even if @@ -1613,7 +1626,7 @@ StmtResult Parser::ParseWhileStatement(SourceLocation *TrailingElseLoc) { if (Cond.isInvalid() || Body.isInvalid()) return StmtError(); - return Actions.ActOnWhileStmt(WhileLoc, Cond, Body.get()); + return Actions.ActOnWhileStmt(WhileLoc, LParen, Cond, RParen, Body.get()); } /// ParseDoStatement diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index a22a1116eb0b..73f3183c163f 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -1328,8 +1328,9 @@ Sema::DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, } } -StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, - Stmt *Body) { +StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc, + SourceLocation LParenLoc, ConditionResult Cond, + SourceLocation RParenLoc, Stmt *Body) { if (Cond.isInvalid()) return StmtError(); @@ -1344,7 +1345,7 @@ StmtResult Sema::ActOnWhileStmt(SourceLocation WhileLoc, ConditionResult Cond, getCurCompoundScope().setHasEmptyLoopBodies(); return WhileStmt::Create(Context, CondVal.first, CondVal.second, Body, - WhileLoc); + WhileLoc, LParenLoc, RParenLoc); } StmtResult diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 1b7c22f0901b..ae0e9f1119b4 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1347,9 +1347,10 @@ class TreeTransform { /// /// By default, performs semantic analysis to build the new statement. /// Subclasses may override this routine to provide diff erent behavior. - StmtResult RebuildWhileStmt(SourceLocation WhileLoc, - Sema::ConditionResult Cond, Stmt *Body) { - return getSema().ActOnWhileStmt(WhileLoc, Cond, Body); + StmtResult RebuildWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, + Sema::ConditionResult Cond, + SourceLocation RParenLoc, Stmt *Body) { + return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body); } /// Build a new do-while statement. @@ -7335,7 +7336,8 @@ TreeTransform::TransformWhileStmt(WhileStmt *S) { Body.get() == S->getBody()) return Owned(S); - return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get()); + return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(), + Cond, S->getRParenLoc(), Body.get()); } template diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index e3bac703f9f7..a40c5499a6d7 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -271,6 +271,8 @@ void ASTStmtReader::VisitWhileStmt(WhileStmt *S) { S->setConditionVariable(Record.getContext(), readDeclAs()); S->setWhileLoc(readSourceLocation()); + S->setLParenLoc(readSourceLocation()); + S->setRParenLoc(readSourceLocation()); } void ASTStmtReader::VisitDoStmt(DoStmt *S) { diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index 941665ff0cba..0767b3a24bf2 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -194,6 +194,8 @@ void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) { Record.AddDeclRef(S->getConditionVariable()); Record.AddSourceLocation(S->getWhileLoc()); + Record.AddSourceLocation(S->getLParenLoc()); + Record.AddSourceLocation(S->getRParenLoc()); Code = serialization::STMT_WHILE; } diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp index cb96afed64d3..32dc382aa05c 100644 --- a/clang/unittests/AST/SourceLocationTest.cpp +++ b/clang/unittests/AST/SourceLocationTest.cpp @@ -60,6 +60,59 @@ TEST(RangeVerifier, WrongRange) { EXPECT_FALSE(Verifier.match("int i;", varDecl())); } +class WhileParenLocationVerifier : public MatchVerifier { + unsigned ExpectLParenLine = 0, ExpectLParenColumn = 0; + unsigned ExpectRParenLine = 0, ExpectRParenColumn = 0; + +public: + void expectLocations(unsigned LParenLine, unsigned LParenColumn, + unsigned RParenLine, unsigned RParenColumn) { + ExpectLParenLine = LParenLine; + ExpectLParenColumn = LParenColumn; + ExpectRParenLine = RParenLine; + ExpectRParenColumn = RParenColumn; + } + +protected: + void verify(const MatchFinder::MatchResult &Result, + const WhileStmt &Node) override { + SourceLocation LParenLoc = Node.getLParenLoc(); + SourceLocation RParenLoc = Node.getRParenLoc(); + unsigned LParenLine = + Result.SourceManager->getSpellingLineNumber(LParenLoc); + unsigned LParenColumn = + Result.SourceManager->getSpellingColumnNumber(LParenLoc); + unsigned RParenLine = + Result.SourceManager->getSpellingLineNumber(RParenLoc); + unsigned RParenColumn = + Result.SourceManager->getSpellingColumnNumber(RParenLoc); + + if (LParenLine != ExpectLParenLine || LParenColumn != ExpectLParenColumn || + RParenLine != ExpectRParenLine || RParenColumn != ExpectRParenColumn) { + std::string MsgStr; + llvm::raw_string_ostream Msg(MsgStr); + Msg << "Expected LParen Location <" << ExpectLParenLine << ":" + << ExpectLParenColumn << ">, found <"; + LParenLoc.print(Msg, *Result.SourceManager); + Msg << ">\n"; + + Msg << "Expected RParen Location <" << ExpectRParenLine << ":" + << ExpectRParenColumn << ">, found <"; + RParenLoc.print(Msg, *Result.SourceManager); + Msg << ">"; + + this->setFailure(Msg.str()); + } + } +}; + +TEST(LocationVerifier, WhileParenLoc) { + WhileParenLocationVerifier Verifier; + Verifier.expectLocations(1, 17, 1, 38); + EXPECT_TRUE(Verifier.match("void f() { while(true/*some comment*/) {} }", + whileStmt())); +} + class LabelDeclRangeVerifier : public RangeVerifier { protected: SourceRange getRange(const LabelStmt &Node) override { From cfe-commits at lists.llvm.org Fri Jul 10 18:31:44 2020 From: cfe-commits at lists.llvm.org (Vy Nguyen via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 01:31:44 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: <766a773d7a2e7e4f4f1b8165f643d9da@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG17ea41e47256: Summary: [clang] Provide a way for WhileStmt to report the location of its… (authored by oontvoo). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 Files: clang/include/clang/AST/Stmt.h clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/AST/ASTImporter.cpp clang/lib/AST/Stmt.cpp clang/lib/Parse/ParseStmt.cpp clang/lib/Sema/SemaStmt.cpp clang/lib/Sema/TreeTransform.h clang/lib/Serialization/ASTReaderStmt.cpp clang/lib/Serialization/ASTWriterStmt.cpp clang/unittests/AST/SourceLocationTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83529.277189.patch Type: text/x-patch Size: 13556 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 18:41:47 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 01:41:47 +0000 (UTC) Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event In-Reply-To: References: Message-ID: <7edaa498d1f50e40a81c86a87bd54d1e@localhost.localdomain> MaskRay added a comment. Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git commit with the following script: arcfilter () { arc amend git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F - } `Reviewed By: ` is considered important by some people. Please keep the tag. (`--date=now` is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time)) `llvm/utils/git/pre-push.py` can validate the message does not include unneeded tags. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82477/new/ https://reviews.llvm.org/D82477 From cfe-commits at lists.llvm.org Fri Jul 10 18:44:05 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 01:44:05 +0000 (UTC) Subject: [PATCH] D83529: Summary: [clang] Provide a way for WhileStmt to report the location of its LParen and RParen. In-Reply-To: References: Message-ID: <4a12d657f1454f7ce8e41257a15d3744@localhost.localdomain> MaskRay added a comment. Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git commit with the following script: arcfilter () { arc amend git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F - } `Reviewed By: ` is considered important by some people. Please keep the tag. (`--date=now` is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time)) `llvm/utils/git/pre-push.py` can validate the message does not include unneeded tags. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83529/new/ https://reviews.llvm.org/D83529 From cfe-commits at lists.llvm.org Fri Jul 10 19:24:42 2020 From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 02:24:42 +0000 (UTC) Subject: [PATCH] D83611: [clang][NFC] Add 'override' keyword to virtual function overrides Message-ID: logan-5 created this revision. logan-5 added a project: clang. Herald added subscribers: cfe-commits, martong. This patch adds `override` to several overriding virtual functions that were missing the keyword within the clang/ directory. NFC. These were found by a Clang build equipped with `-Wsuggest-override`, as implemented in this patch (D82728 ). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83611 Files: clang/include/clang/AST/DeclOpenMP.h clang/lib/AST/Interp/InterpFrame.h clang/lib/AST/OSLog.cpp clang/lib/Basic/Targets/OSTargets.h clang/lib/Sema/SemaDeclCXX.cpp clang/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp clang/lib/StaticAnalyzer/Checkers/ObjCContainersChecker.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83611.277200.patch Type: text/x-patch Size: 5438 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 20:05:25 2020 From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 03:05:25 +0000 (UTC) Subject: [PATCH] D83616: [clang] Add 'override' to virtual function overrides generated by ClangAttrEmitter Message-ID: logan-5 created this revision. logan-5 added reviewers: rsmith, aaron.ballman, john.brawn. logan-5 added a project: clang. Herald added a subscriber: cfe-commits. ClangAttrEmitter.cpp generates `ParsedAttr` derived classes with virtual overrides in them (which end up in AttrParsedAttrImpl.inc); this patch ensures these generated functions are marked `override`, and not (redundantly) `virtual`. I hesitate to say NFC since this does of course affect the behavior of the generator code, but the generated code behaves the same as it did before, so it's NFC in that sense. These missing override sites were found by a Clang build equipped with -Wsuggest-override, as implemented in this patch (D82728 ). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83616 Files: clang/utils/TableGen/ClangAttrEmitter.cpp Index: clang/utils/TableGen/ClangAttrEmitter.cpp =================================================================== --- clang/utils/TableGen/ClangAttrEmitter.cpp +++ clang/utils/TableGen/ClangAttrEmitter.cpp @@ -2012,10 +2012,10 @@ return; // Generate a function that constructs a set of matching rules that describe // to which declarations the attribute should apply to. - OS << "virtual void getPragmaAttributeMatchRules(" + OS << "void getPragmaAttributeMatchRules(" << "llvm::SmallVectorImpl> &MatchRules, const LangOptions &LangOpts) const {\n"; + << ", bool>> &MatchRules, const LangOptions &LangOpts) const override {\n"; const Record *SubjectObj = Attr.getValueAsDef("Subjects"); std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects"); for (const auto *Subject : Subjects) { @@ -3519,8 +3519,8 @@ // at all (for instance because it was applied to a type), or that the caller // has determined that the check should fail (perhaps prior to the creation // of the declaration). - OS << "virtual bool diagAppertainsToDecl(Sema &S, "; - OS << "const ParsedAttr &Attr, const Decl *D) const {\n"; + OS << "bool diagAppertainsToDecl(Sema &S, "; + OS << "const ParsedAttr &Attr, const Decl *D) const override {\n"; OS << " if ("; for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) { // If the subject has custom code associated with it, use the generated @@ -3594,8 +3594,8 @@ if (LangOpts.empty()) return; - OS << "virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) "; - OS << "const {\n"; + OS << "bool diagLangOpts(Sema &S, const ParsedAttr &Attr) "; + OS << "const override {\n"; OS << " auto &LangOpts = S.LangOpts;\n"; OS << " if (" << GenerateTestExpression(LangOpts) << ")\n"; OS << " return true;\n\n"; @@ -3639,7 +3639,7 @@ std::string Test; bool UsesT = GenerateTargetSpecificAttrChecks(R, Arches, Test, &FnName); - OS << "virtual bool existsInTarget(const TargetInfo &Target) const {\n"; + OS << "bool existsInTarget(const TargetInfo &Target) const override {\n"; if (UsesT) OS << " const llvm::Triple &T = Target.getTriple(); (void)T;\n"; OS << " return " << Test << ";\n"; @@ -3664,8 +3664,8 @@ std::string Enum = CreateSemanticSpellings(Spellings, SemanticToSyntacticMap); std::string Name = Attr.getName().str() + "AttrSpellingMap"; - OS << "virtual unsigned spellingIndexToSemanticSpelling("; - OS << "const ParsedAttr &Attr) const {\n"; + OS << "unsigned spellingIndexToSemanticSpelling("; + OS << "const ParsedAttr &Attr) const override {\n"; OS << Enum; OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n"; WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS); @@ -3678,8 +3678,8 @@ return; // Generate a function which just converts from ParsedAttr to the Attr type. - OS << "virtual AttrHandling handleDeclAttribute(Sema &S, Decl *D,"; - OS << "const ParsedAttr &Attr) const {\n"; + OS << "AttrHandling handleDeclAttribute(Sema &S, Decl *D,"; + OS << "const ParsedAttr &Attr) const override {\n"; OS << " D->addAttr(::new (S.Context) " << Attr.getName(); OS << "Attr(S.Context, Attr));\n"; OS << " return AttributeApplied;\n"; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83616.277209.patch Type: text/x-patch Size: 3347 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 20:20:56 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via cfe-commits) Date: Fri, 10 Jul 2020 20:20:56 -0700 (PDT) Subject: [clang] 849d440 - [HIP] Fix rocm detection Message-ID: <5f093018.1c69fb81.aeec7.2e70@mx.google.com> Author: Yaxun (Sam) Liu Date: 2020-07-10T23:20:15-04:00 New Revision: 849d4405f534434ebbda9889f24ff20122e34671 URL: https://github.com/llvm/llvm-project/commit/849d4405f534434ebbda9889f24ff20122e34671 DIFF: https://github.com/llvm/llvm-project/commit/849d4405f534434ebbda9889f24ff20122e34671.diff LOG: [HIP] Fix rocm detection Do not detect device library by default in rocm detector. Only detect device library in Rocm and HIP toolchain. Separate detection of HIP runtime and Rocm device library. Detect rocm path by version file in host toolchains. Also added detecting rocm version and printing rocm installation path and version with -v. Fixed include path and device library detection for ROCm 3.5. Added --hip-version option. Renamed --hip-device-lib-path to --rocm-device-lib-path. Fixed default value for -fhip-new-launch-api. Added default -std option for HIP. Differential Revision: https://reviews.llvm.org/D82930 Added: clang/test/Driver/Inputs/rocm/bin/.hipVersion clang/test/Driver/hip-launch-api.hip clang/test/Driver/hip-std.hip clang/test/Driver/hip-version.hip Modified: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/CodeGen/CGCUDANV.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/HIP.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/ROCm.h clang/test/Driver/hip-include-path.hip clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-detect.hip clang/test/Driver/rocm-not-found.cl Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index baf01d853233..558639ecad6a 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -56,12 +56,12 @@ def err_drv_no_cuda_libdevice : Error< "cannot find libdevice for %0. Provide path to diff erent CUDA installation " "via --cuda-path, or pass -nocudalib to build without linking with libdevice.">; -def err_drv_no_rocm_installation : Error< - "cannot find ROCm installation. Provide its path via --rocm-path, or pass " - "-nogpulib and -nogpuinc to build without ROCm device library and HIP includes.">; def err_drv_no_rocm_device_lib : Error< - "cannot find device library for %0. Provide path to diff erent ROCm installation " - "via --rocm-path, or pass -nogpulib to build without linking default libraries.">; + "cannot find ROCm device library%select{| for %1}0. Provide its path via --rocm-path or " + "--rocm-device-lib-path, or pass -nogpulib to build without ROCm device library.">; +def err_drv_no_hip_runtime : Error< + "cannot find HIP runtime. Provide its path via --rocm-path, or pass " + "-nogpuinc to build without HIP runtime.">; def err_drv_cuda_version_unsupported : Error< "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), " diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e09b1b0b306f..f4556c15d744 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -637,15 +637,19 @@ defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr", "Use 32-bit pointers for accessing const/local/shared address spaces">; def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group, HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">; -def hip_device_lib_path_EQ : Joined<["--"], "hip-device-lib-path=">, Group, - HelpText<"HIP device library path. Alternative to rocm-path.">; +def rocm_device_lib_path_EQ : Joined<["--"], "rocm-device-lib-path=">, Group, + HelpText<"ROCm device library path. Alternative to rocm-path.">; +def : Joined<["--"], "hip-device-lib-path=">, Alias; def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group, HelpText<"HIP device library">; +def hip_version_EQ : Joined<["--"], "hip-version=">, + HelpText<"HIP version in the format of major.minor.patch">; def fhip_dump_offload_linker_script : Flag<["-"], "fhip-dump-offload-linker-script">, Group, Flags<[NoArgumentUnused, HelpHidden]>; defm hip_new_launch_api : OptInFFlag<"hip-new-launch-api", - "Use new kernel launching API for HIP">; -defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init", "Allow device side init function in HIP">; + "Use", "Don't use", " new kernel launching API for HIP">; +defm gpu_allow_device_init : OptInFFlag<"gpu-allow-device-init", + "Allow", "Don't allow", " device side init function in HIP">; def gpu_max_threads_per_block_EQ : Joined<["--"], "gpu-max-threads-per-block=">, Flags<[CC1Option]>, HelpText<"Default max threads per block for kernel launch bounds for HIP">; diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp index 351c5058aa4c..baf2c79cc2b6 100644 --- a/clang/lib/CodeGen/CGCUDANV.cpp +++ b/clang/lib/CodeGen/CGCUDANV.cpp @@ -242,7 +242,7 @@ void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF, EmittedKernels.push_back({CGF.CurFn, CGF.CurFuncDecl}); if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(), CudaFeature::CUDA_USES_NEW_LAUNCH) || - CGF.getLangOpts().HIPUseNewLaunchAPI) + (CGF.getLangOpts().HIP && CGF.getLangOpts().HIPUseNewLaunchAPI)) emitDeviceStubBodyNew(CGF, Args); else emitDeviceStubBodyLegacy(CGF, Args); diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index a5dd28be4b1a..cfc71d7810b4 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -21,16 +21,14 @@ using namespace clang::driver::toolchains; using namespace clang; using namespace llvm::opt; -void RocmInstallationDetector::scanLibDevicePath() { - assert(!LibDevicePath.empty()); +void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) { + assert(!Path.empty()); const StringRef Suffix(".bc"); const StringRef Suffix2(".amdgcn.bc"); std::error_code EC; - for (llvm::vfs::directory_iterator - LI = D.getVFS().dir_begin(LibDevicePath, EC), - LE; + for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Path, EC), LE; !EC && LI != LE; LI = LI.increment(EC)) { StringRef FilePath = LI->path(); StringRef FileName = llvm::sys::path::filename(FilePath); @@ -89,60 +87,114 @@ void RocmInstallationDetector::scanLibDevicePath() { } } -RocmInstallationDetector::RocmInstallationDetector( - const Driver &D, const llvm::Triple &HostTriple, - const llvm::opt::ArgList &Args) - : D(D) { - struct Candidate { - std::string Path; - bool StrictChecking; - - Candidate(std::string Path, bool StrictChecking = false) - : Path(Path), StrictChecking(StrictChecking) {} - }; +void RocmInstallationDetector::ParseHIPVersionFile(llvm::StringRef V) { + SmallVector VersionParts; + V.split(VersionParts, '\n'); + unsigned Major; + unsigned Minor; + for (auto Part : VersionParts) { + auto Splits = Part.split('='); + if (Splits.first == "HIP_VERSION_MAJOR") + Splits.second.getAsInteger(0, Major); + else if (Splits.first == "HIP_VERSION_MINOR") + Splits.second.getAsInteger(0, Minor); + else if (Splits.first == "HIP_VERSION_PATCH") + VersionPatch = Splits.second.str(); + } + VersionMajorMinor = llvm::VersionTuple(Major, Minor); + DetectedVersion = + (Twine(Major) + "." + Twine(Minor) + "." + VersionPatch).str(); +} +// For candidate specified by --rocm-path we do not do strict check. +SmallVector +RocmInstallationDetector::getInstallationPathCandidates() { SmallVector Candidates; + if (!RocmPathArg.empty()) { + Candidates.emplace_back(RocmPathArg.str()); + return Candidates; + } - if (Args.hasArg(clang::driver::options::OPT_rocm_path_EQ)) { - Candidates.emplace_back( - Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ).str()); - } else { - // Try to find relative to the compiler binary. - const char *InstallDir = D.getInstalledDir(); + // Try to find relative to the compiler binary. + const char *InstallDir = D.getInstalledDir(); - // Check both a normal Unix prefix position of the clang binary, as well as - // the Windows-esque layout the ROCm packages use with the host architecture - // subdirectory of bin. + // Check both a normal Unix prefix position of the clang binary, as well as + // the Windows-esque layout the ROCm packages use with the host architecture + // subdirectory of bin. - // Strip off directory (usually bin) - StringRef ParentDir = llvm::sys::path::parent_path(InstallDir); - StringRef ParentName = llvm::sys::path::filename(ParentDir); + // Strip off directory (usually bin) + StringRef ParentDir = llvm::sys::path::parent_path(InstallDir); + StringRef ParentName = llvm::sys::path::filename(ParentDir); - // Some builds use bin/{host arch}, so go up again. - if (ParentName == "bin") { - ParentDir = llvm::sys::path::parent_path(ParentDir); - ParentName = llvm::sys::path::filename(ParentDir); - } + // Some builds use bin/{host arch}, so go up again. + if (ParentName == "bin") { + ParentDir = llvm::sys::path::parent_path(ParentDir); + ParentName = llvm::sys::path::filename(ParentDir); + } - if (ParentName == "llvm") { - // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin - Candidates.emplace_back(llvm::sys::path::parent_path(ParentDir).str(), - /*StrictChecking=*/true); - } + // Some versions of the rocm llvm package install to /opt/rocm/llvm/bin + if (ParentName == "llvm") + ParentDir = llvm::sys::path::parent_path(ParentDir); + + Candidates.emplace_back(ParentDir.str(), /*StrictChecking=*/true); + + // Device library may be installed in clang resource directory. + Candidates.emplace_back(D.ResourceDir, /*StrictChecking=*/true); + + Candidates.emplace_back(D.SysRoot + "/opt/rocm", /*StrictChecking=*/true); + return Candidates; +} - Candidates.emplace_back(D.SysRoot + "/opt/rocm"); +RocmInstallationDetector::RocmInstallationDetector( + const Driver &D, const llvm::Triple &HostTriple, + const llvm::opt::ArgList &Args, bool DetectHIPRuntime, bool DetectDeviceLib) + : D(D) { + RocmPathArg = Args.getLastArgValue(clang::driver::options::OPT_rocm_path_EQ); + RocmDeviceLibPathArg = + Args.getAllArgValues(clang::driver::options::OPT_rocm_device_lib_path_EQ); + if (auto *A = Args.getLastArg(clang::driver::options::OPT_hip_version_EQ)) { + HIPVersionArg = A->getValue(); + unsigned Major = 0; + unsigned Minor = 0; + SmallVector Parts; + HIPVersionArg.split(Parts, '.'); + if (Parts.size()) + Parts[0].getAsInteger(0, Major); + if (Parts.size() > 1) + Parts[1].getAsInteger(0, Minor); + if (Parts.size() > 2) + VersionPatch = Parts[2].str(); + if (VersionPatch.empty()) + VersionPatch = "0"; + if (Major == 0 || Minor == 0) + D.Diag(diag::err_drv_invalid_value) + << A->getAsString(Args) << HIPVersionArg; + + VersionMajorMinor = llvm::VersionTuple(Major, Minor); + DetectedVersion = + (Twine(Major) + "." + Twine(Minor) + "." + VersionPatch).str(); + } else { + VersionPatch = DefaultVersionPatch; + VersionMajorMinor = + llvm::VersionTuple(DefaultVersionMajor, DefaultVersionMinor); + DetectedVersion = (Twine(DefaultVersionMajor) + "." + + Twine(DefaultVersionMinor) + "." + VersionPatch) + .str(); } - bool NoBuiltinLibs = Args.hasArg(options::OPT_nogpulib); + if (DetectHIPRuntime) + detectHIPRuntime(); + if (DetectDeviceLib) + detectDeviceLibrary(); +} +void RocmInstallationDetector::detectDeviceLibrary() { assert(LibDevicePath.empty()); - if (Args.hasArg(clang::driver::options::OPT_hip_device_lib_path_EQ)) { - LibDevicePath - = Args.getLastArgValue(clang::driver::options::OPT_hip_device_lib_path_EQ); - } else if (const char *LibPathEnv = ::getenv("HIP_DEVICE_LIB_PATH")) { + if (!RocmDeviceLibPathArg.empty()) + LibDevicePath = RocmDeviceLibPathArg[RocmDeviceLibPathArg.size() - 1]; + else if (const char *LibPathEnv = ::getenv("HIP_DEVICE_LIB_PATH")) LibDevicePath = LibPathEnv; - } auto &FS = D.getVFS(); if (!LibDevicePath.empty()) { @@ -152,61 +204,109 @@ RocmInstallationDetector::RocmInstallationDetector( if (!FS.exists(LibDevicePath)) return; - scanLibDevicePath(); - IsValid = allGenericLibsValid() && !LibDeviceMap.empty(); + scanLibDevicePath(LibDevicePath); + HasDeviceLibrary = allGenericLibsValid() && !LibDeviceMap.empty(); return; } + // The install path situation in old versions of ROCm is a real mess, and + // use a diff erent install layout. Multiple copies of the device libraries + // exist for each frontend project, and diff er depending on which build + // system produced the packages. Standalone OpenCL builds also have a + // diff erent directory structure from the ROCm OpenCL package. + auto Candidates = getInstallationPathCandidates(); + for (const auto &Candidate : Candidates) { + auto CandidatePath = Candidate.Path; + + // Check device library exists at the given path. + auto CheckDeviceLib = [&](StringRef Path) { + bool CheckLibDevice = (!NoBuiltinLibs || Candidate.StrictChecking); + if (CheckLibDevice && !FS.exists(Path)) + return false; + + scanLibDevicePath(Path); + + if (!NoBuiltinLibs) { + // Check that the required non-target libraries are all available. + if (!allGenericLibsValid()) + return false; + + // Check that we have found at least one libdevice that we can link in + // if -nobuiltinlib hasn't been specified. + if (LibDeviceMap.empty()) + return false; + } + return true; + }; + + // The possible structures are: + // - ${ROCM_ROOT}/amdgcn/bitcode/* + // - ${ROCM_ROOT}/lib/* + // - ${ROCM_ROOT}/lib/bitcode/* + // so try to detect these layouts. + static llvm::SmallVector SubDirsList[] = { + {"amdgcn", "bitcode"}, + {"lib"}, + {"lib", "bitcode"}, + }; + + // Make a path by appending sub-directories to InstallPath. + auto MakePath = [&](const llvm::ArrayRef &SubDirs) { + auto Path = CandidatePath; + for (auto SubDir : SubDirs) + llvm::sys::path::append(Path, SubDir); + return Path; + }; + + for (auto SubDirs : SubDirsList) { + LibDevicePath = MakePath(SubDirs); + HasDeviceLibrary = CheckDeviceLib(LibDevicePath); + if (HasDeviceLibrary) + return; + } + } +} + +void RocmInstallationDetector::detectHIPRuntime() { + auto Candidates = getInstallationPathCandidates(); + auto &FS = D.getVFS(); + for (const auto &Candidate : Candidates) { InstallPath = Candidate.Path; if (InstallPath.empty() || !FS.exists(InstallPath)) continue; - // The install path situation in old versions of ROCm is a real mess, and - // use a diff erent install layout. Multiple copies of the device libraries - // exist for each frontend project, and diff er depending on which build - // system produced the packages. Standalone OpenCL builds also have a - // diff erent directory structure from the ROCm OpenCL package. - // - // The desired structure is (${ROCM_ROOT} or - // ${OPENCL_ROOT})/amdgcn/bitcode/*, so try to detect this layout. - - // BinPath = InstallPath + "/bin"; - llvm::sys::path::append(IncludePath, InstallPath, "include"); - llvm::sys::path::append(LibDevicePath, InstallPath, "amdgcn", "bitcode"); + BinPath = InstallPath; + llvm::sys::path::append(BinPath, "bin"); + IncludePath = InstallPath; + llvm::sys::path::append(IncludePath, "include"); + LibPath = InstallPath; + llvm::sys::path::append(LibPath, "lib"); - // We don't need the include path for OpenCL, since clang already ships with - // the default header. - - bool CheckLibDevice = (!NoBuiltinLibs || Candidate.StrictChecking); - if (CheckLibDevice && !FS.exists(LibDevicePath)) + llvm::ErrorOr> VersionFile = + FS.getBufferForFile(BinPath + "/.hipVersion"); + if (!VersionFile && Candidate.StrictChecking) continue; - scanLibDevicePath(); - - if (!NoBuiltinLibs) { - // Check that the required non-target libraries are all available. - if (!allGenericLibsValid()) - continue; + if (HIPVersionArg.empty() && VersionFile) + ParseHIPVersionFile((*VersionFile)->getBuffer()); - // Check that we have found at least one libdevice that we can link in if - // -nobuiltinlib hasn't been specified. - if (LibDeviceMap.empty()) - continue; - } - - IsValid = true; - break; + HasHIPRuntime = true; + return; } + HasHIPRuntime = false; } void RocmInstallationDetector::print(raw_ostream &OS) const { - if (isValid()) - OS << "Found ROCm installation: " << InstallPath << '\n'; + if (hasHIPRuntime()) + OS << "Found HIP installation: " << InstallPath << ", version " + << DetectedVersion << '\n'; } void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, ArgStringList &CC1Args) const { + bool UsesRuntimeWrapper = VersionMajorMinor > llvm::VersionTuple(3, 5); + if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) { // HIP header includes standard library wrapper headers under clang // cuda_wrappers directory. Since these wrapper headers include_next @@ -218,9 +318,12 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, // Since standard C++ and other clang include paths are added in other // places after this function, here we only need to make sure wrapper // include path is added. + // + // ROCm 3.5 does not fully support the wrapper headers. Therefore it needs + // a workaround. SmallString<128> P(D.ResourceDir); - llvm::sys::path::append(P, "include"); - llvm::sys::path::append(P, "cuda_wrappers"); + if (UsesRuntimeWrapper) + llvm::sys::path::append(P, "include", "cuda_wrappers"); CC1Args.push_back("-internal-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(P)); } @@ -228,15 +331,15 @@ void RocmInstallationDetector::AddHIPIncludeArgs(const ArgList &DriverArgs, if (DriverArgs.hasArg(options::OPT_nogpuinc)) return; - if (!isValid()) { - D.Diag(diag::err_drv_no_rocm_installation); + if (!hasHIPRuntime()) { + D.Diag(diag::err_drv_no_hip_runtime); return; } CC1Args.push_back("-internal-isystem"); CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath())); - CC1Args.push_back("-include"); - CC1Args.push_back("__clang_hip_runtime_wrapper.h"); + if (UsesRuntimeWrapper) + CC1Args.append({"-include", "__clang_hip_runtime_wrapper.h"}); } void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -386,8 +489,9 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : AMDGPUToolChain(D, Triple, Args), - RocmInstallation(D, Triple, Args) { } + : AMDGPUToolChain(D, Triple, Args), + RocmInstallation(D, Triple, Args, /*DetectHIPRuntime=*/false, + /*DetectDeviceLib=*/true) {} void AMDGPUToolChain::addClangTargetOptions( const llvm::opt::ArgList &DriverArgs, @@ -418,8 +522,8 @@ void ROCMToolChain::addClangTargetOptions( if (DriverArgs.hasArg(options::OPT_nogpulib)) return; - if (!RocmInstallation.isValid()) { - getDriver().Diag(diag::err_drv_no_rocm_installation); + if (!RocmInstallation.hasDeviceLibrary()) { + getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0; return; } @@ -429,7 +533,7 @@ void ROCMToolChain::addClangTargetOptions( const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind); std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch); if (LibDeviceFile.empty()) { - getDriver().Diag(diag::err_drv_no_rocm_device_lib) << GpuArch; + getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GpuArch; return; } diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 9b424beec428..9d6333bb5f1d 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -3953,7 +3953,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } - const llvm::Triple *AuxTriple = IsCuda ? TC.getAuxTriple() : nullptr; + const llvm::Triple *AuxTriple = + (IsCuda || IsHIP) ? TC.getAuxTriple() : nullptr; bool IsWindowsMSVC = RawTriple.isWindowsMSVCEnvironment(); bool IsIAMCU = RawTriple.isOSIAMCU(); @@ -4868,10 +4869,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_finstrument_functions_after_inlining, options::OPT_finstrument_function_entry_bare); - // NVPTX doesn't support PGO or coverage. There's no runtime support for - // sampling, overhead of call arc collection is way too high and there's no - // way to collect the output. - if (!Triple.isNVPTX()) + // NVPTX/AMDGCN doesn't support PGO or coverage. There's no runtime support + // for sampling, overhead of call arc collection is way too high and there's + // no way to collect the output. + if (!Triple.isNVPTX() && !Triple.isAMDGCN()) addPGOAndCoverageFlags(TC, C, D, Output, Args, CmdArgs); Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ); @@ -4990,6 +4991,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_ftrigraphs, options::OPT_fno_trigraphs); + + // HIP headers has minimum C++ standard requirements. Therefore set the + // default language standard. + if (IsHIP) + CmdArgs.push_back(IsWindowsMSVC ? "-std=c++14" : "-std=c++11"); } // GCC's behavior for -Wwrite-strings is a bit strange: @@ -5398,8 +5404,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // Forward -cl options to -cc1 RenderOpenCLOptions(Args, CmdArgs); - if (Args.hasFlag(options::OPT_fhip_new_launch_api, - options::OPT_fno_hip_new_launch_api, false)) + if (IsHIP && Args.hasFlag(options::OPT_fhip_new_launch_api, + options::OPT_fno_hip_new_launch_api, true)) CmdArgs.push_back("-fhip-new-launch-api"); if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) { diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index 47a93376cac9..c8a7fce07ef1 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2658,6 +2658,7 @@ void Generic_GCC::printVerboseInfo(raw_ostream &OS) const { // Print the information about how we detected the GCC installation. GCCInstallation.print(OS); CudaInstallation.print(OS); + RocmInstallation.print(OS); } bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const { diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp index 15c9dbf3488d..32734f5c1180 100644 --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -224,6 +224,7 @@ HIPToolChain::HIPToolChain(const Driver &D, const llvm::Triple &Triple, // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); + RocmInstallation.detectHIPRuntime(); } void HIPToolChain::addClangTargetOptions( @@ -279,8 +280,7 @@ void HIPToolChain::addClangTargetOptions( ArgStringList LibraryPaths; // Find in --hip-device-lib-path and HIP_LIBRARY_PATH. - for (auto Path : - DriverArgs.getAllArgValues(options::OPT_hip_device_lib_path_EQ)) + for (auto Path : RocmInstallation.getRocmDeviceLibPathArg()) LibraryPaths.push_back(DriverArgs.MakeArgString(Path)); addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH"); @@ -291,14 +291,14 @@ void HIPToolChain::addClangTargetOptions( for (auto Lib : BCLibs) addBCLib(getDriver(), DriverArgs, CC1Args, LibraryPaths, Lib); } else { - if (!RocmInstallation.isValid()) { - getDriver().Diag(diag::err_drv_no_rocm_installation); + if (!RocmInstallation.hasDeviceLibrary()) { + getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 0; return; } std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch); if (LibDeviceFile.empty()) { - getDriver().Diag(diag::err_drv_no_rocm_device_lib) << GpuArch; + getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GpuArch; return; } diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index f6c94e2d01c7..6b3c00e2ab6d 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -807,6 +807,7 @@ void MSVCToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs, void MSVCToolChain::printVerboseInfo(raw_ostream &OS) const { CudaInstallation.print(OS); + RocmInstallation.print(OS); } // Windows SDKs and VC Toolchains group their contents into subdirectories based diff --git a/clang/lib/Driver/ToolChains/ROCm.h b/clang/lib/Driver/ToolChains/ROCm.h index 779e2e133bec..962c72fedfe0 100644 --- a/clang/lib/Driver/ToolChains/ROCm.h +++ b/clang/lib/Driver/ToolChains/ROCm.h @@ -18,6 +18,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/Triple.h" #include "llvm/Option/ArgList.h" +#include "llvm/Support/VersionTuple.h" namespace clang { namespace driver { @@ -38,11 +39,43 @@ class RocmInstallationDetector { } }; + // Installation path candidate. + struct Candidate { + llvm::SmallString<0> Path; + bool StrictChecking; + + Candidate(std::string Path, bool StrictChecking = false) + : Path(Path), StrictChecking(StrictChecking) {} + }; + const Driver &D; - bool IsValid = false; - // RocmVersion Version = RocmVersion::UNKNOWN; + bool HasHIPRuntime = false; + bool HasDeviceLibrary = false; + + // Default version if not detected or specified. + const unsigned DefaultVersionMajor = 3; + const unsigned DefaultVersionMinor = 5; + const char *DefaultVersionPatch = "0"; + + // The version string in Major.Minor.Patch format. + std::string DetectedVersion; + // Version containing major and minor. + llvm::VersionTuple VersionMajorMinor; + // Version containing patch. + std::string VersionPatch; + + // ROCm path specified by --rocm-path. + StringRef RocmPathArg; + // ROCm device library paths specified by --rocm-device-lib-path. + std::vector RocmDeviceLibPathArg; + // HIP version specified by --hip-version. + StringRef HIPVersionArg; + // Wheter -nogpulib is specified. + bool NoBuiltinLibs = false; + + // Paths SmallString<0> InstallPath; - // SmallString<0> BinPath; + SmallString<0> BinPath; SmallString<0> LibPath; SmallString<0> LibDevicePath; SmallString<0> IncludePath; @@ -74,11 +107,15 @@ class RocmInstallationDetector { // CheckRocmVersionSupportsArch. mutable llvm::SmallSet ArchsWithBadVersion; - void scanLibDevicePath(); + void scanLibDevicePath(llvm::StringRef Path); + void ParseHIPVersionFile(llvm::StringRef V); + SmallVector getInstallationPathCandidates(); public: RocmInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, - const llvm::opt::ArgList &Args); + const llvm::opt::ArgList &Args, + bool DetectHIPRuntime = true, + bool DetectDeviceLib = false); /// Add arguments needed to link default bitcode libraries. void addCommonBitcodeLibCC1Args(const llvm::opt::ArgList &DriverArgs, @@ -93,8 +130,12 @@ class RocmInstallationDetector { /// most one error per Arch. void CheckRocmVersionSupportsArch(CudaArch Arch) const; - /// Check whether we detected a valid Rocm install. - bool isValid() const { return IsValid; } + /// Check whether we detected a valid HIP runtime. + bool hasHIPRuntime() const { return HasHIPRuntime; } + + /// Check whether we detected a valid ROCm device library. + bool hasDeviceLibrary() const { return HasDeviceLibrary; } + /// Print information about the detected ROCm installation. void print(raw_ostream &OS) const; @@ -163,6 +204,22 @@ class RocmInstallationDetector { void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const; + + void detectDeviceLibrary(); + void detectHIPRuntime(); + + /// Get the values for --rocm-device-lib-path arguments + std::vector getRocmDeviceLibPathArg() const { + return RocmDeviceLibPathArg; + } + + /// Get the value for --rocm-path argument + StringRef getRocmPathArg() const { return RocmPathArg; } + + /// Get the value for --hip-version argument + StringRef getHIPVersionArg() const { return HIPVersionArg; } + + std::string getHIPVersion() const { return DetectedVersion; } }; } // end namespace driver diff --git a/clang/test/Driver/Inputs/rocm/bin/.hipVersion b/clang/test/Driver/Inputs/rocm/bin/.hipVersion new file mode 100644 index 000000000000..48ee6f10c3e4 --- /dev/null +++ b/clang/test/Driver/Inputs/rocm/bin/.hipVersion @@ -0,0 +1,4 @@ +# Auto-generated by cmake +HIP_VERSION_MAJOR=3 +HIP_VERSION_MINOR=6 +HIP_VERSION_PATCH=20214-a2917cd diff --git a/clang/test/Driver/hip-include-path.hip b/clang/test/Driver/hip-include-path.hip index ea508a91dd43..7af06fabe5ae 100644 --- a/clang/test/Driver/hip-include-path.hip +++ b/clang/test/Driver/hip-include-path.hip @@ -37,3 +37,15 @@ // skip check of standard C++ include path // CLANG-SAME: "-internal-isystem" "{{.*}}clang/{{.*}}/include" // NOCLANG-NOT: "{{.*}}clang/{{.*}}/include" + +// RUN: %clang -c -### -target x86_64-unknown-linux-gnu --cuda-gpu-arch=gfx900 \ +// RUN: -std=c++11 --rocm-path=%S/Inputs/rocm -nogpulib %s 2>&1 \ +// RUN: --hip-version=3.5 | FileCheck -check-prefixes=ROCM35 %s + +// ROCM35-LABEL: "{{[^"]*}}clang{{[^"]*}}" "-cc1" +// ROCM35-NOT: "{{.*}}clang/{{.*}}/include/cuda_wrappers" +// ROCM35-SAME: "-internal-isystem" "{{[^"]*}}clang/{{[^"]*}}" +// ROCM35-SAME: "-internal-isystem" "{{[^"]*}}Inputs/rocm/include" +// ROCM35-NOT: "-include" "__clang_hip_runtime_wrapper.h" +// skip check of standard C++ include path +// ROCM35-SAME: "-internal-isystem" "{{[^"]*}}clang/{{[^"]*}}/include" diff --git a/clang/test/Driver/hip-launch-api.hip b/clang/test/Driver/hip-launch-api.hip new file mode 100644 index 000000000000..a7d7d15c9b5a --- /dev/null +++ b/clang/test/Driver/hip-launch-api.hip @@ -0,0 +1,17 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// By default FE assumes -fhip-new-launch-api. + +// RUN: %clang -### -target x86_64-unknown-linux-gnu -offload-arch=gfx906 %s \ +// RUN: 2>&1 | FileCheck -check-prefixes=NEW %s +// NEW: "-fhip-new-launch-api" + +// RUN: %clang -### -target x86_64-unknown-linux-gnu -offload-arch=gfx906 %s \ +// RUN: -fhip-new-launch-api 2>&1 | FileCheck -check-prefixes=NEW %s +// NEW: "-fhip-new-launch-api" + +// RUN: %clang -### -target x86_64-unknown-linux-gnu -offload-arch=gfx906 %s \ +// RUN: -fno-hip-new-launch-api 2>&1 | FileCheck -check-prefixes=OLD %s +// OLD-NOT: "-fhip-new-launch-api" diff --git a/clang/test/Driver/hip-std.hip b/clang/test/Driver/hip-std.hip new file mode 100644 index 000000000000..4bdf05ab495d --- /dev/null +++ b/clang/test/Driver/hip-std.hip @@ -0,0 +1,23 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// RUN: %clang -### -target x86_64-unknown-linux-gnu -offload-arch=gfx906 %s \ +// RUN: 2>&1 | FileCheck -check-prefixes=DEFAULT %s +// DEFAULT: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-fcuda-is-device"{{.*}}"-std=c++11" +// DEFAULT: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-std=c++11" + +// RUN: %clang -### -target x86_64-unknown-linux-gnu -offload-arch=gfx906 %s \ +// RUN: -std=c++17 %s 2>&1 | FileCheck -check-prefixes=SPECIFIED %s +// SPECIFIED: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-fcuda-is-device"{{.*}}"-std=c++17" +// SPECIFIED: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-std=c++17" + +// RUN: %clang -### -target x86_64-pc-windows-msvc -offload-arch=gfx906 %s \ +// RUN: 2>&1 | FileCheck -check-prefixes=MSVC-DEF %s +// MSVC-DEF: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-fcuda-is-device"{{.*}}"-std=c++14" +// MSVC-DEF: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-std=c++14" + +// RUN: %clang -### -target x86_64-pc-windows-msvc -offload-arch=gfx906 %s \ +// RUN: -std=c++17 %s 2>&1 | FileCheck -check-prefixes=MSVC-SPEC %s +// MSVC-SPEC: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-fcuda-is-device"{{.*}}"-std=c++17" +// MSVC-SPEC: "{{.*}}clang{{.*}}" "-cc1"{{.*}}"-std=c++17" diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip new file mode 100644 index 000000000000..cf80ae15ac6d --- /dev/null +++ b/clang/test/Driver/hip-version.hip @@ -0,0 +1,30 @@ +// REQUIRES: clang-driver +// REQUIRES: x86-registered-target +// REQUIRES: amdgpu-registered-target + +// RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \ +// RUN: | FileCheck -check-prefixes=FOUND %s + +// FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd + +// When --rocm-path is set and .hipVersion is not found, use default version + +// RUN: %clang -v --rocm-path=%S 2>&1 \ +// RUN: | FileCheck -check-prefixes=DEFAULT %s + +// DEFAULT: Found HIP installation: {{.*Driver}}, version 3.5. + +// RUN: %clang -v --rocm-path=%S --hip-version=3.7.0 2>&1 \ +// RUN: | FileCheck -check-prefixes=SPECIFIED %s + +// SPECIFIED: Found HIP installation: {{.*Driver}}, version 3.7.0 + +// RUN: %clang -v --rocm-path=%S --hip-version=3.7 2>&1 \ +// RUN: | FileCheck -check-prefixes=SPECIFIED2 %s + +// SPECIFIED2: Found HIP installation: {{.*Driver}}, version 3.7.0 + +// RUN: not %clang -v --rocm-path=%S --hip-version=x.y 2>&1 \ +// RUN: | FileCheck -check-prefixes=INVALID %s + +// INVALID: error: invalid value 'x.y' in '--hip-version=x.y' diff --git a/clang/test/Driver/rocm-detect.cl b/clang/test/Driver/rocm-detect.cl index 75378bf003be..2fac3aa7cc8d 100644 --- a/clang/test/Driver/rocm-detect.cl +++ b/clang/test/Driver/rocm-detect.cl @@ -16,6 +16,6 @@ // RUN: | FileCheck -check-prefixes=COMMON,GFX902,NODEFAULTLIBS %s -// GFX902-DEFAULTLIBS: error: cannot find device library for gfx902. Provide path to diff erent ROCm installation via --rocm-path, or pass -nogpulib to build without linking default libraries. +// GFX902-DEFAULTLIBS: error: cannot find ROCm device library for gfx902. Provide its path via --rocm-path or --rocm-device-lib-path, or pass -nogpulib to build without ROCm device library // NODEFAULTLIBS-NOT: error: cannot find diff --git a/clang/test/Driver/rocm-detect.hip b/clang/test/Driver/rocm-detect.hip index 9490ec9ba376..3a3a028facb4 100644 --- a/clang/test/Driver/rocm-detect.hip +++ b/clang/test/Driver/rocm-detect.hip @@ -22,6 +22,6 @@ // RUN: | FileCheck -check-prefixes=COMMON,GFX902,NODEFAULTLIBS %s -// GFX902-DEFAULTLIBS: error: cannot find device library for gfx902. Provide path to diff erent ROCm installation via --rocm-path, or pass -nogpulib to build without linking default libraries. +// GFX902-DEFAULTLIBS: error: cannot find ROCm device library for gfx902. Provide its path via --rocm-path or --rocm-device-lib-path, or pass -nogpulib to build without ROCm device library // NODEFAULTLIBS-NOT: error: cannot find diff --git a/clang/test/Driver/rocm-not-found.cl b/clang/test/Driver/rocm-not-found.cl index ee931971d9e6..122f826714b5 100644 --- a/clang/test/Driver/rocm-not-found.cl +++ b/clang/test/Driver/rocm-not-found.cl @@ -5,7 +5,7 @@ // RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR -// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib and -nogpuinc to build without ROCm device library and HIP includes. +// ERR: cannot find ROCm device library. Provide its path via --rocm-path or --rocm-device-lib-path, or pass -nogpulib to build without ROCm device library // Accept nogpulib or nostdlib for OpenCL. // RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK From cfe-commits at lists.llvm.org Fri Jul 10 20:21:05 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 03:21:05 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <5b439d3252e7a6ab6ef280fbb13a68c8@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG849d4405f534: [HIP] Fix rocm detection (authored by yaxunl). Herald added a project: clang. Changed prior to commit: https://reviews.llvm.org/D82930?vs=277095&id=277214#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/CodeGen/CGCUDANV.cpp clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/HIP.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/ROCm.h clang/test/Driver/Inputs/rocm/bin/.hipVersion clang/test/Driver/hip-include-path.hip clang/test/Driver/hip-launch-api.hip clang/test/Driver/hip-std.hip clang/test/Driver/hip-version.hip clang/test/Driver/rocm-detect.cl clang/test/Driver/rocm-detect.hip clang/test/Driver/rocm-not-found.cl -------------- next part -------------- A non-text attachment was scrubbed... Name: D82930.277214.patch Type: text/x-patch Size: 33860 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 20:36:41 2020 From: cfe-commits at lists.llvm.org (Joel E. Denny via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 03:36:41 +0000 (UTC) Subject: [PATCH] D83061: [OpenMP] Implement TR8 `present` map type modifier in Clang (1/2) In-Reply-To: References: Message-ID: <0d5d1436f335d062c326b414d2d0c1d0@localhost.localdomain> jdenny updated this revision to Diff 277215. jdenny added a comment. Rebased. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83061/new/ https://reviews.llvm.org/D83061 Files: clang/include/clang/AST/OpenMPClause.h clang/include/clang/Basic/DiagnosticParseKinds.td clang/include/clang/Basic/OpenMPKinds.def clang/lib/CodeGen/CGOpenMPRuntime.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/target_ast_print.cpp clang/test/OpenMP/target_data_ast_print.cpp clang/test/OpenMP/target_data_codegen.cpp clang/test/OpenMP/target_defaultmap_codegen.cpp clang/test/OpenMP/target_enter_data_codegen.cpp clang/test/OpenMP/target_map_codegen.cpp clang/test/OpenMP/target_map_messages.cpp clang/test/OpenMP/target_parallel_for_map_messages.cpp clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp clang/test/OpenMP/target_parallel_map_messages.cpp clang/test/OpenMP/target_simd_map_messages.cpp clang/test/OpenMP/target_teams_distribute_map_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp clang/test/OpenMP/target_teams_map_messages.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83061.277215.patch Type: text/x-patch Size: 77261 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 21:13:34 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 04:13:34 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <56ef12f54eba3e9fbc63f0c875046321@localhost.localdomain> yaxunl accepted this revision. yaxunl added a comment. LGTM. This fixed the regression caused by previous change. Thanks. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 22:12:55 2020 From: cfe-commits at lists.llvm.org (Vitaly Buka via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 05:12:55 +0000 (UTC) Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X In-Reply-To: References: Message-ID: <0d6efa2b4762dc40499b0666a1c74446@localhost.localdomain> vitalybuka added subscribers: eugenis, guiand, vitalybuka. vitalybuka added a comment. After this patch we have false msan reports on code like this: bool iv_compare2(const int *op1, const int *op2) { if (op1[1] != op2[1]) return op1[1] < op2[1]; for (int i = 1; i >= 0; i--) { if (op1[i] != op2[i]) return op1[i] < op2[i]; } return false; } void foo() { int a[2] = {}; int b[2] = {}; auto UNINITIALIZED= iv_compare2(a, b); } Here it looks fine and the same as before the patch. It returns "and undef, false" which should be false. *** IR Dump After Simplify the CFG *** ; Function Attrs: norecurse nounwind readonly sanitize_memory uwtable define zeroext i1 @_Z11iv_compare2PKiS0_(i32* nocapture readonly %op1, i32* nocapture readonly %op2) local_unnamed_addr #0 !dbg !8 { entry: %arrayidx = getelementptr inbounds i32, i32* %op1, i64 1, !dbg !10 %0 = load i32, i32* %arrayidx, align 4, !dbg !10 %arrayidx1 = getelementptr inbounds i32, i32* %op2, i64 1, !dbg !11 %1 = load i32, i32* %arrayidx1, align 4, !dbg !11 %cmp.not = icmp eq i32 %0, %1, !dbg !12 br i1 %cmp.not, label %for.cond, label %if.then, !dbg !10 if.then: ; preds = %entry %cmp4 = icmp slt i32 %0, %1, !dbg !13 ret i1 %cmp4, !dbg !14 for.cond: ; preds = %entry %2 = load i32, i32* %op1, align 4, !dbg !15 %3 = load i32, i32* %op2, align 4, !dbg !16 %cmp9.not.1 = icmp eq i32 %2, %3, !dbg !17 %cmp15 = icmp slt i32 %2, %3 %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15, !dbg !15 %spec.select40 = select i1 %cmp9.not.1, i1 false, i1 true, !dbg !15 %spec.select = and i1 %spec.select39, %spec.select40 ret i1 %spec.select } However with this patch after the next transformation it breaks the code: Now it returns undef instead of false if %2 == %3 *** IR Dump After Combine redundant instructions *** ; Function Attrs: norecurse nounwind readonly sanitize_memory uwtable define zeroext i1 @_Z11iv_compare2PKiS0_(i32* nocapture readonly %op1, i32* nocapture readonly %op2) local_unnamed_addr #0 !dbg !8 { entry: %arrayidx = getelementptr inbounds i32, i32* %op1, i64 1, !dbg !10 %0 = load i32, i32* %arrayidx, align 4, !dbg !10 %arrayidx1 = getelementptr inbounds i32, i32* %op2, i64 1, !dbg !11 %1 = load i32, i32* %arrayidx1, align 4, !dbg !11 %cmp.not = icmp eq i32 %0, %1, !dbg !12 br i1 %cmp.not, label %for.cond, label %if.then, !dbg !10 if.then: ; preds = %entry %cmp4 = icmp slt i32 %0, %1, !dbg !13 ret i1 %cmp4, !dbg !14 for.cond: ; preds = %entry %2 = load i32, i32* %op1, align 4, !dbg !15 %3 = load i32, i32* %op2, align 4, !dbg !16 %cmp9.not.1 = icmp eq i32 %2, %3, !dbg !17 %cmp15 = icmp slt i32 %2, %3 %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15, !dbg !15 ret i1 %spec.select39 } The msan reasonably reports a bug. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83360/new/ https://reviews.llvm.org/D83360 From cfe-commits at lists.llvm.org Fri Jul 10 22:39:43 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 05:39:43 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: jdoerfert added a comment. Thx for the reviews! FWIW, OpenMP should be able to use the C/C++ standard functions/macros for this eventually. Getting the overloads right if you don't have type system support is tricky though and I need more time... On a separate note, we should bundle the resources to get more "GPU-compatible" generic headers in. At the end of the day, what we need for CUDA/HIP/OPENMP on NVIDIA/AMD/... hardware should be very similar, assuming we can make some design choices right ;) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 From cfe-commits at lists.llvm.org Fri Jul 10 22:42:32 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits) Date: Fri, 10 Jul 2020 22:42:32 -0700 (PDT) Subject: [clang] b5667d0 - [OpenMP][CUDA] Fix std::complex in GPU regions Message-ID: <5f095148.1c69fb81.fd0df.3e85@mx.google.com> Author: Johannes Doerfert Date: 2020-07-11T00:40:05-05:00 New Revision: b5667d00e0447747419a783697b84a37f59ce055 URL: https://github.com/llvm/llvm-project/commit/b5667d00e0447747419a783697b84a37f59ce055 DIFF: https://github.com/llvm/llvm-project/commit/b5667d00e0447747419a783697b84a37f59ce055.diff LOG: [OpenMP][CUDA] Fix std::complex in GPU regions The old way worked to some degree for C++-mode but in C mode we actually tried to introduce variants of macros (e.g., isinf). To make both modes work reliably we get rid of those extra variants and directly use NVIDIA intrinsics in the complex implementation. While this has to be revisited as we add other GPU targets which want to reuse the code, it should be fine for now. Reviewed By: tra, JonChesterfield, yaxunl Differential Revision: https://reviews.llvm.org/D83591 Added: Modified: clang/lib/Headers/__clang_cuda_complex_builtins.h clang/lib/Headers/__clang_cuda_math.h clang/test/Headers/nvptx_device_math_complex.c clang/test/Headers/nvptx_device_math_complex.cpp Removed: ################################################################################ diff --git a/clang/lib/Headers/__clang_cuda_complex_builtins.h b/clang/lib/Headers/__clang_cuda_complex_builtins.h index c48c754ed1a4..8c10ff6b461f 100644 --- a/clang/lib/Headers/__clang_cuda_complex_builtins.h +++ b/clang/lib/Headers/__clang_cuda_complex_builtins.h @@ -23,20 +23,16 @@ #define __DEVICE__ __device__ inline #endif -// Make the algorithms available for C and C++ by selecting the right functions. -#if defined(__cplusplus) -// TODO: In OpenMP mode we cannot overload isinf/isnan/isfinite the way we -// overload all other math functions because old math system headers and not -// always conformant and return an integer instead of a boolean. Until that has -// been addressed we need to work around it. For now, we substituate with the -// calls we would have used to implement those three functions. Note that we -// could use the C alternatives as well. -#define _ISNANd ::__isnan -#define _ISNANf ::__isnanf -#define _ISINFd ::__isinf -#define _ISINFf ::__isinff -#define _ISFINITEd ::__isfinited -#define _ISFINITEf ::__finitef +// To make the algorithms available for C and C++ in CUDA and OpenMP we select +// diff erent but equivalent function versions. TODO: For OpenMP we currently +// select the native builtins as the overload support for templates is lacking. +#if !defined(_OPENMP) +#define _ISNANd std::isnan +#define _ISNANf std::isnan +#define _ISINFd std::isinf +#define _ISINFf std::isinf +#define _ISFINITEd std::isfinite +#define _ISFINITEf std::isfinite #define _COPYSIGNd std::copysign #define _COPYSIGNf std::copysign #define _SCALBNd std::scalbn @@ -46,20 +42,20 @@ #define _LOGBd std::logb #define _LOGBf std::logb #else -#define _ISNANd isnan -#define _ISNANf isnanf -#define _ISINFd isinf -#define _ISINFf isinff -#define _ISFINITEd isfinite -#define _ISFINITEf isfinitef -#define _COPYSIGNd copysign -#define _COPYSIGNf copysignf -#define _SCALBNd scalbn -#define _SCALBNf scalbnf -#define _ABSd abs -#define _ABSf absf -#define _LOGBd logb -#define _LOGBf logbf +#define _ISNANd __nv_isnand +#define _ISNANf __nv_isnanf +#define _ISINFd __nv_isinfd +#define _ISINFf __nv_isinff +#define _ISFINITEd __nv_isfinited +#define _ISFINITEf __nv_finitef +#define _COPYSIGNd __nv_copysign +#define _COPYSIGNf __nv_copysignf +#define _SCALBNd __nv_scalbn +#define _SCALBNf __nv_scalbnf +#define _ABSd __nv_fabs +#define _ABSf __nv_fabsf +#define _LOGBd __nv_logb +#define _LOGBf __nv_logbf #endif #if defined(__cplusplus) diff --git a/clang/lib/Headers/__clang_cuda_math.h b/clang/lib/Headers/__clang_cuda_math.h index 2e8e6ae71d9c..332e616702ac 100644 --- a/clang/lib/Headers/__clang_cuda_math.h +++ b/clang/lib/Headers/__clang_cuda_math.h @@ -340,16 +340,6 @@ __DEVICE__ float y1f(float __a) { return __nv_y1f(__a); } __DEVICE__ double yn(int __a, double __b) { return __nv_yn(__a, __b); } __DEVICE__ float ynf(int __a, float __b) { return __nv_ynf(__a, __b); } -// In C++ mode OpenMP takes the system versions of these because some math -// headers provide the wrong return type. This cannot happen in C and we can and -// want to use the specialized versions right away. -#if defined(_OPENMP) && !defined(__cplusplus) -__DEVICE__ int isinff(float __x) { return __nv_isinff(__x); } -__DEVICE__ int isinf(double __x) { return __nv_isinfd(__x); } -__DEVICE__ int isnanf(float __x) { return __nv_isnanf(__x); } -__DEVICE__ int isnan(double __x) { return __nv_isnand(__x); } -#endif - #pragma pop_macro("__DEVICE__") #pragma pop_macro("__DEVICE_VOID__") #pragma pop_macro("__FAST_OR_SLOW") diff --git a/clang/test/Headers/nvptx_device_math_complex.c b/clang/test/Headers/nvptx_device_math_complex.c index 0e212592dd2b..6e3e8bffbd24 100644 --- a/clang/test/Headers/nvptx_device_math_complex.c +++ b/clang/test/Headers/nvptx_device_math_complex.c @@ -11,12 +11,34 @@ #include #endif -// CHECK-DAG: define weak {{.*}} @__mulsc3 -// CHECK-DAG: define weak {{.*}} @__muldc3 -// CHECK-DAG: define weak {{.*}} @__divsc3 -// CHECK-DAG: define weak {{.*}} @__divdc3 +// CHECK: define weak {{.*}} @__muldc3 +// CHECK-DAG: call i32 @__nv_isnand( +// CHECK-DAG: call i32 @__nv_isinfd( +// CHECK-DAG: call double @__nv_copysign( +// CHECK: define weak {{.*}} @__mulsc3 +// CHECK-DAG: call i32 @__nv_isnanf( +// CHECK-DAG: call i32 @__nv_isinff( +// CHECK-DAG: call float @__nv_copysignf( + +// CHECK: define weak {{.*}} @__divdc3 +// CHECK-DAG: call i32 @__nv_isnand( +// CHECK-DAG: call i32 @__nv_isinfd( +// CHECK-DAG: call i32 @__nv_isfinited( +// CHECK-DAG: call double @__nv_copysign( +// CHECK-DAG: call double @__nv_scalbn( +// CHECK-DAG: call double @__nv_fabs( +// CHECK-DAG: call double @__nv_logb( + +// CHECK: define weak {{.*}} @__divsc3 +// CHECK-DAG: call i32 @__nv_isnanf( +// CHECK-DAG: call i32 @__nv_isinff( +// CHECK-DAG: call i32 @__nv_finitef( +// CHECK-DAG: call float @__nv_copysignf( // CHECK-DAG: call float @__nv_scalbnf( +// CHECK-DAG: call float @__nv_fabsf( +// CHECK-DAG: call float @__nv_logbf( + void test_scmplx(float _Complex a) { #pragma omp target { @@ -24,7 +46,6 @@ void test_scmplx(float _Complex a) { } } -// CHECK-DAG: call double @__nv_scalbn( void test_dcmplx(double _Complex a) { #pragma omp target { diff --git a/clang/test/Headers/nvptx_device_math_complex.cpp b/clang/test/Headers/nvptx_device_math_complex.cpp index 58ed24b74b0e..e4b78deb05d7 100644 --- a/clang/test/Headers/nvptx_device_math_complex.cpp +++ b/clang/test/Headers/nvptx_device_math_complex.cpp @@ -5,12 +5,34 @@ #include -// CHECK-DAG: define weak {{.*}} @__mulsc3 -// CHECK-DAG: define weak {{.*}} @__muldc3 -// CHECK-DAG: define weak {{.*}} @__divsc3 -// CHECK-DAG: define weak {{.*}} @__divdc3 +// CHECK: define weak {{.*}} @__muldc3 +// CHECK-DAG: call i32 @__nv_isnand( +// CHECK-DAG: call i32 @__nv_isinfd( +// CHECK-DAG: call double @__nv_copysign( +// CHECK: define weak {{.*}} @__mulsc3 +// CHECK-DAG: call i32 @__nv_isnanf( +// CHECK-DAG: call i32 @__nv_isinff( +// CHECK-DAG: call float @__nv_copysignf( + +// CHECK: define weak {{.*}} @__divdc3 +// CHECK-DAG: call i32 @__nv_isnand( +// CHECK-DAG: call i32 @__nv_isinfd( +// CHECK-DAG: call i32 @__nv_isfinited( +// CHECK-DAG: call double @__nv_copysign( +// CHECK-DAG: call double @__nv_scalbn( +// CHECK-DAG: call double @__nv_fabs( +// CHECK-DAG: call double @__nv_logb( + +// CHECK: define weak {{.*}} @__divsc3 +// CHECK-DAG: call i32 @__nv_isnanf( +// CHECK-DAG: call i32 @__nv_isinff( +// CHECK-DAG: call i32 @__nv_finitef( +// CHECK-DAG: call float @__nv_copysignf( // CHECK-DAG: call float @__nv_scalbnf( +// CHECK-DAG: call float @__nv_fabsf( +// CHECK-DAG: call float @__nv_logbf( + void test_scmplx(std::complex a) { #pragma omp target { @@ -18,7 +40,6 @@ void test_scmplx(std::complex a) { } } -// CHECK-DAG: call double @__nv_scalbn( void test_dcmplx(std::complex a) { #pragma omp target { From cfe-commits at lists.llvm.org Fri Jul 10 22:42:34 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 05:42:34 +0000 (UTC) Subject: [PATCH] D83591: [OpenMP][CUDA] Fix std::complex in GPU regions In-Reply-To: References: Message-ID: <3e6f463095bacb28ad53ace0e91e9451@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGb5667d00e044: [OpenMP][CUDA] Fix std::complex in GPU regions (authored by jdoerfert). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83591/new/ https://reviews.llvm.org/D83591 Files: clang/lib/Headers/__clang_cuda_complex_builtins.h clang/lib/Headers/__clang_cuda_math.h clang/test/Headers/nvptx_device_math_complex.c clang/test/Headers/nvptx_device_math_complex.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83591.277217.patch Type: text/x-patch Size: 6657 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Fri Jul 10 22:53:49 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits) Date: Fri, 10 Jul 2020 22:53:49 -0700 (PDT) Subject: [clang] c986995 - [OpenMP][NFC] Remove unused (always fixed) arguments Message-ID: <5f0953ed.1c69fb81.d7015.22d1@mx.google.com> Author: Johannes Doerfert Date: 2020-07-11T00:51:51-05:00 New Revision: c98699582a6333bbe76ff7853b4cd6beb45754cf URL: https://github.com/llvm/llvm-project/commit/c98699582a6333bbe76ff7853b4cd6beb45754cf DIFF: https://github.com/llvm/llvm-project/commit/c98699582a6333bbe76ff7853b4cd6beb45754cf.diff LOG: [OpenMP][NFC] Remove unused (always fixed) arguments There are various runtime calls in the device runtime with unused, or always fixed, arguments. This is bad for all sorts of reasons. Clean up two before as we match them in OpenMPOpt now. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D83268 Added: Modified: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp clang/test/OpenMP/nvptx_data_sharing.cpp clang/test/OpenMP/nvptx_parallel_codegen.cpp clang/test/OpenMP/nvptx_target_codegen.cpp clang/test/OpenMP/nvptx_target_teams_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp llvm/include/llvm/Frontend/OpenMP/OMPKinds.def openmp/libomptarget/deviceRTLs/common/src/parallel.cu openmp/libomptarget/deviceRTLs/interface.h Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index cabd06bd76e8..cbd443134e7a 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -38,11 +38,9 @@ enum OpenMPRTLFunctionNVPTX { /// Call to void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime); OMPRTL_NVPTX__kmpc_spmd_kernel_deinit_v2, /// Call to void __kmpc_kernel_prepare_parallel(void - /// *outlined_function, int16_t - /// IsOMPRuntimeInitialized); + /// *outlined_function); OMPRTL_NVPTX__kmpc_kernel_prepare_parallel, - /// Call to bool __kmpc_kernel_parallel(void **outlined_function, - /// int16_t IsOMPRuntimeInitialized); + /// Call to bool __kmpc_kernel_parallel(void **outlined_function); OMPRTL_NVPTX__kmpc_kernel_parallel, /// Call to void __kmpc_kernel_end_parallel(); OMPRTL_NVPTX__kmpc_kernel_end_parallel, @@ -1466,8 +1464,7 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoop(CodeGenFunction &CGF, CGF.InitTempAlloca(WorkFn, llvm::Constant::getNullValue(CGF.Int8PtrTy)); // TODO: Optimize runtime initialization and pass in correct value. - llvm::Value *Args[] = {WorkFn.getPointer(), - /*RequiresOMPRuntime=*/Bld.getInt16(1)}; + llvm::Value *Args[] = {WorkFn.getPointer()}; llvm::Value *Ret = CGF.EmitRuntimeCall( createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_parallel), Args); Bld.CreateStore(Bld.CreateZExt(Ret, CGF.Int8Ty), ExecStatus); @@ -1595,17 +1592,16 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction(unsigned Function) { } case OMPRTL_NVPTX__kmpc_kernel_prepare_parallel: { /// Build void __kmpc_kernel_prepare_parallel( - /// void *outlined_function, int16_t IsOMPRuntimeInitialized); - llvm::Type *TypeParams[] = {CGM.Int8PtrTy, CGM.Int16Ty}; + /// void *outlined_function); + llvm::Type *TypeParams[] = {CGM.Int8PtrTy}; auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false); RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_prepare_parallel"); break; } case OMPRTL_NVPTX__kmpc_kernel_parallel: { - /// Build bool __kmpc_kernel_parallel(void **outlined_function, - /// int16_t IsOMPRuntimeInitialized); - llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy, CGM.Int16Ty}; + /// Build bool __kmpc_kernel_parallel(void **outlined_function); + llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy}; llvm::Type *RetTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy); auto *FnTy = llvm::FunctionType::get(RetTy, TypeParams, /*isVarArg*/ false); @@ -2569,7 +2565,7 @@ void CGOpenMPRuntimeNVPTX::emitNonSPMDParallelCall( llvm::Value *ID = Bld.CreateBitOrPointerCast(WFn, CGM.Int8PtrTy); // Prepare for parallel region. Indicate the outlined function. - llvm::Value *Args[] = {ID, /*RequiresOMPRuntime=*/Bld.getInt16(1)}; + llvm::Value *Args[] = {ID}; CGF.EmitRuntimeCall( createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_prepare_parallel), Args); diff --git a/clang/test/OpenMP/nvptx_data_sharing.cpp b/clang/test/OpenMP/nvptx_data_sharing.cpp index 2ee6bd2b4701..1372246c7fc8 100644 --- a/clang/test/OpenMP/nvptx_data_sharing.cpp +++ b/clang/test/OpenMP/nvptx_data_sharing.cpp @@ -55,7 +55,7 @@ void test_ds(){ // CK1: [[A:%.+]] = getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[GLOBALSTACK2]], i32 0, i32 0 // CK1: [[B:%.+]] = getelementptr inbounds %struct._globalized_locals_ty, %struct._globalized_locals_ty* [[GLOBALSTACK2]], i32 0, i32 1 // CK1: store i32 10, i32* [[A]] -// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i16 1) +// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}) // CK1: call void @__kmpc_begin_sharing_variables(i8*** [[SHAREDARGS1]], i64 1) // CK1: [[SHARGSTMP1:%.+]] = load i8**, i8*** [[SHAREDARGS1]] // CK1: [[SHARGSTMP2:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP1]], i64 0 @@ -65,7 +65,7 @@ void test_ds(){ // CK1: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CK1: call void @__kmpc_end_sharing_variables() // CK1: store i32 100, i32* [[B]] -// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i16 1) +// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}) // CK1: call void @__kmpc_begin_sharing_variables(i8*** [[SHAREDARGS2]], i64 2) // CK1: [[SHARGSTMP3:%.+]] = load i8**, i8*** [[SHAREDARGS2]] // CK1: [[SHARGSTMP4:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP3]], i64 0 diff --git a/clang/test/OpenMP/nvptx_parallel_codegen.cpp b/clang/test/OpenMP/nvptx_parallel_codegen.cpp index c8b15c8f6e3b..ad25e0d775d1 100644 --- a/clang/test/OpenMP/nvptx_parallel_codegen.cpp +++ b/clang/test/OpenMP/nvptx_parallel_codegen.cpp @@ -92,7 +92,7 @@ int bar(int n){ // // CHECK: [[AWAIT_WORK]] // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) #[[#CONVERGENT:]] -// CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]] +// CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], @@ -166,13 +166,13 @@ int bar(int n){ // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize() // CHECK: [[MTMP1:%.+]] = sub nuw i32 [[MNTH]], [[MWS]] // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]] -// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN1]]_wrapper to i8*), +// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN1]]_wrapper to i8*)) // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CHECK: call void @__kmpc_serialized_parallel( // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]]( // CHECK: call void @__kmpc_end_serialized_parallel( -// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN2]]_wrapper to i8*), +// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN2]]_wrapper to i8*)) // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CHECK-64-DAG: load i32, i32* [[REF_A]] @@ -211,7 +211,7 @@ int bar(int n){ // // CHECK: [[AWAIT_WORK]] // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) -// CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], +// CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], @@ -291,7 +291,7 @@ int bar(int n){ // CHECK: br i1 [[CMP]], label {{%?}}[[IF_THEN:.+]], label {{%?}}[[IF_ELSE:.+]] // // CHECK: [[IF_THEN]] -// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN4]]_wrapper to i8*), +// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* [[PARALLEL_FN4]]_wrapper to i8*)) // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) // CHECK: br label {{%?}}[[IF_END:.+]] diff --git a/clang/test/OpenMP/nvptx_target_codegen.cpp b/clang/test/OpenMP/nvptx_target_codegen.cpp index 91f31185d8c1..56f04cb01f0a 100644 --- a/clang/test/OpenMP/nvptx_target_codegen.cpp +++ b/clang/test/OpenMP/nvptx_target_codegen.cpp @@ -612,7 +612,7 @@ int baz(int f, double &a) { // CHECK: call void @__kmpc_end_serialized_parallel(%struct.ident_t* [[UNKNOWN]], i32 [[GTID]]) // CHECK: br label -// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* @{{.+}} to i8*), i16 1) +// CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* @{{.+}} to i8*)) // CHECK: call void @__kmpc_begin_sharing_variables(i8*** [[SHARED_PTR:%.+]], i{{64|32}} 2) // CHECK: [[SHARED:%.+]] = load i8**, i8*** [[SHARED_PTR]], // CHECK: [[REF:%.+]] = getelementptr inbounds i8*, i8** [[SHARED]], i{{64|32}} 0 diff --git a/clang/test/OpenMP/nvptx_target_teams_codegen.cpp b/clang/test/OpenMP/nvptx_target_teams_codegen.cpp index 3ab955fa8508..8ff393f074e4 100644 --- a/clang/test/OpenMP/nvptx_target_teams_codegen.cpp +++ b/clang/test/OpenMP/nvptx_target_teams_codegen.cpp @@ -68,7 +68,7 @@ int bar(int n){ // // CHECK: [[AWAIT_WORK]] // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) - // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1) + // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], @@ -154,7 +154,7 @@ int bar(int n){ // // CHECK: [[AWAIT_WORK]] // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) - // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1) + // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]) // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8 // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1 // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], diff --git a/clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp b/clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp index fe294bbddf2b..4f23f18730cc 100644 --- a/clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp +++ b/clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp @@ -88,7 +88,7 @@ int bar(int n){ // CHECK: [[I_ADDR:%.+]] = getelementptr inbounds [[GLOB_TY]], [[GLOB_TY]]* [[RD]], i32 0, i32 0 // // CHECK: call void @__kmpc_for_static_init_4( - // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* @{{.+}} to i8*), i16 1) + // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32)* @{{.+}} to i8*)) // CHECK: call void @__kmpc_begin_sharing_variables(i8*** [[SHARED_VARS_PTR:%.+]], i{{64|32}} 1) // CHECK: [[SHARED_VARS_BUF:%.+]] = load i8**, i8*** [[SHARED_VARS_PTR]], // CHECK: [[VARS_BUF:%.+]] = getelementptr inbounds i8*, i8** [[SHARED_VARS_BUF]], i{{64|32}} 0 diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def index f286403e657c..bf799a781ae1 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def +++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def @@ -584,6 +584,11 @@ __OMP_RTL(__tgt_push_mapper_component, false, Void, VoidPtr, VoidPtr, VoidPtr, __OMP_RTL(__kmpc_task_allow_completion_event, false, VoidPtr, IdentPtr, /* Int */ Int32, /* kmp_task_t */ VoidPtr) +/// Note that device runtime functions (in the following) do not necessarily +/// need attributes as we expect to see the definitions. +__OMP_RTL(__kmpc_kernel_parallel, false, Int1, VoidPtrPtr) +__OMP_RTL(__kmpc_kernel_prepare_parallel, false, Void, VoidPtr) + __OMP_RTL(__last, false, Void, ) #undef __OMP_RTL diff --git a/openmp/libomptarget/deviceRTLs/common/src/parallel.cu b/openmp/libomptarget/deviceRTLs/common/src/parallel.cu index 4f3c3ac0c08a..20b03e9bab1b 100644 --- a/openmp/libomptarget/deviceRTLs/common/src/parallel.cu +++ b/openmp/libomptarget/deviceRTLs/common/src/parallel.cu @@ -72,10 +72,8 @@ INLINE static uint16_t determineNumberOfThreads(uint16_t NumThreadsClause, } // This routine is always called by the team master.. -EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, - int16_t IsOMPRuntimeInitialized) { +EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn) { PRINT0(LD_IO, "call to __kmpc_kernel_prepare_parallel\n"); - ASSERT0(LT_FUSSY, IsOMPRuntimeInitialized, "Expected initialized runtime."); omptarget_nvptx_workFn = WorkFn; @@ -120,12 +118,9 @@ EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, // returns True if this thread is active, else False. // // Only the worker threads call this routine. -EXTERN bool __kmpc_kernel_parallel(void **WorkFn, - int16_t IsOMPRuntimeInitialized) { +EXTERN bool __kmpc_kernel_parallel(void **WorkFn) { PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_parallel\n"); - ASSERT0(LT_FUSSY, IsOMPRuntimeInitialized, "Expected initialized runtime."); - // Work function and arguments for L1 parallel region. *WorkFn = omptarget_nvptx_workFn; diff --git a/openmp/libomptarget/deviceRTLs/interface.h b/openmp/libomptarget/deviceRTLs/interface.h index 39ce73cba957..4d352bc648fa 100644 --- a/openmp/libomptarget/deviceRTLs/interface.h +++ b/openmp/libomptarget/deviceRTLs/interface.h @@ -424,10 +424,8 @@ EXTERN void __kmpc_kernel_deinit(int16_t IsOMPRuntimeInitialized); EXTERN void __kmpc_spmd_kernel_init(int ThreadLimit, int16_t RequiresOMPRuntime, int16_t RequiresDataSharing); EXTERN void __kmpc_spmd_kernel_deinit_v2(int16_t RequiresOMPRuntime); -EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, - int16_t IsOMPRuntimeInitialized); -EXTERN bool __kmpc_kernel_parallel(void **WorkFn, - int16_t IsOMPRuntimeInitialized); +EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn); +EXTERN bool __kmpc_kernel_parallel(void **WorkFn); EXTERN void __kmpc_kernel_end_parallel(); EXTERN void __kmpc_data_sharing_init_stack(); From cfe-commits at lists.llvm.org Fri Jul 10 22:54:01 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 05:54:01 +0000 (UTC) Subject: [PATCH] D83268: [OpenMP][NFC] Remove unused (always fixed) arguments In-Reply-To: References: Message-ID: <00d71dbb572f607f88cdb815390a45c4@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGc98699582a63: [OpenMP][NFC] Remove unused (always fixed) arguments (authored by jdoerfert). Changed prior to commit: https://reviews.llvm.org/D83268?vs=275871&id=277218#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83268/new/ https://reviews.llvm.org/D83268 Files: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp clang/test/OpenMP/nvptx_data_sharing.cpp clang/test/OpenMP/nvptx_parallel_codegen.cpp clang/test/OpenMP/nvptx_target_codegen.cpp clang/test/OpenMP/nvptx_target_teams_codegen.cpp clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp llvm/include/llvm/Frontend/OpenMP/OMPKinds.def openmp/libomptarget/deviceRTLs/common/src/parallel.cu openmp/libomptarget/deviceRTLs/interface.h -------------- next part -------------- A non-text attachment was scrubbed... Name: D83268.277218.patch Type: text/x-patch Size: 12882 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sat Jul 11 01:31:51 2020 From: cfe-commits at lists.llvm.org (Juneyoung Lee via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 08:31:51 +0000 (UTC) Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X In-Reply-To: References: Message-ID: <81d79bd7eaa401c8b41e786a71226387@localhost.localdomain> aqjune added a comment. Seems like a bug in instsimplify: define i1 @f(i32 %x, i32 %y) { %cmp9.not.1 = icmp eq i32 %x, %y %cmp15 = icmp slt i32 %x, %y %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15 %spec.select40 = xor i1 %cmp9.not.1, 1 %spec.select = and i1 %spec.select39, %spec.select40 ret i1 %spec.select } => define i1 @f(i32 %x, i32 %y) { %cmp9.not.1 = icmp eq i32 %x, %y %cmp15 = icmp slt i32 %x, %y %spec.select39 = select i1 %cmp9.not.1, i1 undef, i1 %cmp15 ret i1 %spec.select39 } https://godbolt.org/z/a8f7hT Alive2 says it's incorrect: https://alive2.llvm.org/ce/z/-8Q4HL Seems to be related with ValueTracking's isImpliedCondition since this optimizations happens only when operands of the two icmps are the same. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83360/new/ https://reviews.llvm.org/D83360 From cfe-commits at lists.llvm.org Sat Jul 11 02:13:37 2020 From: cfe-commits at lists.llvm.org (Nathan James via cfe-commits) Date: Sat, 11 Jul 2020 02:13:37 -0700 (PDT) Subject: [clang-tools-extra] c3bdc98 - [clang-tidy] Reworked enum options handling(again) Message-ID: <5f0982c1.1c69fb81.af2eb.32e1@mx.google.com> Author: Nathan James Date: 2020-07-11T10:13:20+01:00 New Revision: c3bdc9814d947946bf8e1062f6bf41b7f8813f80 URL: https://github.com/llvm/llvm-project/commit/c3bdc9814d947946bf8e1062f6bf41b7f8813f80 DIFF: https://github.com/llvm/llvm-project/commit/c3bdc9814d947946bf8e1062f6bf41b7f8813f80.diff LOG: [clang-tidy] Reworked enum options handling(again) Reland b9306fd after fixing the issue causing mac builds to fail unittests. Following on from D77085, I was never happy with the passing a mapping to the option get/store functions. This patch addresses this by using explicit specializations to handle the serializing and deserializing of enum options. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D82188 Added: Modified: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp clang-tools-extra/clang-tidy/ClangTidyCheck.h clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp clang-tools-extra/clang-tidy/utils/IncludeSorter.h clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 780a3569afdb..e149978bcdea 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -161,11 +161,13 @@ void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options, store(Options, LocalName, llvm::itostr(Value)); } -llvm::Expected ClangTidyCheck::OptionsView::getEnumInt( - StringRef LocalName, ArrayRef> Mapping, - bool CheckGlobal, bool IgnoreCase) { - auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, LocalName) - : CheckOptions.find((NamePrefix + LocalName).str()); +llvm::Expected +ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName, + ArrayRef Mapping, + bool CheckGlobal, bool IgnoreCase) { + auto Iter = CheckGlobal + ? findPriorityOption(CheckOptions, NamePrefix, LocalName) + : CheckOptions.find((NamePrefix + LocalName).str()); if (Iter == CheckOptions.end()) return llvm::make_error((NamePrefix + LocalName).str()); @@ -174,19 +176,19 @@ llvm::Expected ClangTidyCheck::OptionsView::getEnumInt( unsigned EditDistance = -1; for (const auto &NameAndEnum : Mapping) { if (IgnoreCase) { - if (Value.equals_lower(NameAndEnum.first)) - return NameAndEnum.second; - } else if (Value.equals(NameAndEnum.first)) { - return NameAndEnum.second; - } else if (Value.equals_lower(NameAndEnum.first)) { - Closest = NameAndEnum.first; + if (Value.equals_lower(NameAndEnum.second)) + return NameAndEnum.first; + } else if (Value.equals(NameAndEnum.second)) { + return NameAndEnum.first; + } else if (Value.equals_lower(NameAndEnum.second)) { + Closest = NameAndEnum.second; EditDistance = 0; continue; } - unsigned Distance = Value.edit_distance(NameAndEnum.first); + unsigned Distance = Value.edit_distance(NameAndEnum.second); if (Distance < EditDistance) { EditDistance = Distance; - Closest = NameAndEnum.first; + Closest = NameAndEnum.second; } } if (EditDistance < 3) diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h b/clang-tools-extra/clang-tidy/ClangTidyCheck.h index dfe01a8aaa30..3c625ee0cb79 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h @@ -26,6 +26,13 @@ class SourceManager; namespace tidy { +/// This class should be specialized by any enum type that needs to be converted +/// to and from an \ref llvm::StringRef. +template struct OptionEnumMapping { + // Specializations of this struct must implement this function. + static ArrayRef> getEnumMapping() = delete; +}; + template class OptionError : public llvm::ErrorInfo { std::error_code convertToErrorCode() const override { return llvm::inconvertibleErrorCode(); @@ -312,36 +319,38 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { } /// Read a named option from the ``Context`` and parse it as an - /// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set, - /// it will search the mapping ignoring the case. + /// enum type ``T``. /// /// Reads the option with the check-local name \p LocalName from the /// ``CheckOptions``. If the corresponding key is not present, returns a /// ``MissingOptionError``. If the key can't be parsed as a ``T`` returns a /// ``UnparseableEnumOptionError``. + /// + /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to + /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, llvm::Expected> - get(StringRef LocalName, ArrayRef> Mapping, - bool IgnoreCase = false) { - if (llvm::Expected ValueOr = getEnumInt( - LocalName, typeEraseMapping(Mapping), false, IgnoreCase)) + get(StringRef LocalName, bool IgnoreCase = false) { + if (llvm::Expected ValueOr = + getEnumInt(LocalName, typeEraseMapping(), false, IgnoreCase)) return static_cast(*ValueOr); else return std::move(ValueOr.takeError()); } /// Read a named option from the ``Context`` and parse it as an - /// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set, - /// it will search the mapping ignoring the case. + /// enum type ``T``. /// /// Reads the option with the check-local name \p LocalName from the /// ``CheckOptions``. If the corresponding key is not present or it can't be /// parsed as a ``T``, returns \p Default. + /// + /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to + /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, T> - get(StringRef LocalName, ArrayRef> Mapping, - T Default, bool IgnoreCase = false) { - if (auto ValueOr = get(LocalName, Mapping, IgnoreCase)) + get(StringRef LocalName, T Default, bool IgnoreCase = false) { + if (auto ValueOr = get(LocalName, IgnoreCase)) return *ValueOr; else logErrToStdErr(ValueOr.takeError()); @@ -349,40 +358,41 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { } /// Read a named option from the ``Context`` and parse it as an - /// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set, - /// it will search the mapping ignoring the case. + /// enum type ``T``. /// /// Reads the option with the check-local name \p LocalName from local or /// global ``CheckOptions``. Gets local option first. If local is not /// present, falls back to get global option. If global option is not /// present either, returns a ``MissingOptionError``. If the key can't be /// parsed as a ``T`` returns a ``UnparseableEnumOptionError``. + /// + /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to + /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, llvm::Expected> getLocalOrGlobal(StringRef LocalName, - ArrayRef> Mapping, bool IgnoreCase = false) { - if (llvm::Expected ValueOr = getEnumInt( - LocalName, typeEraseMapping(Mapping), true, IgnoreCase)) + if (llvm::Expected ValueOr = + getEnumInt(LocalName, typeEraseMapping(), true, IgnoreCase)) return static_cast(*ValueOr); else return std::move(ValueOr.takeError()); } /// Read a named option from the ``Context`` and parse it as an - /// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set, - /// it will search the mapping ignoring the case. + /// enum type ``T``. /// /// Reads the option with the check-local name \p LocalName from local or /// global ``CheckOptions``. Gets local option first. If local is not /// present, falls back to get global option. If global option is not /// present either or it can't be parsed as a ``T``, returns \p Default. + /// + /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to + /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value, T> - getLocalOrGlobal(StringRef LocalName, - ArrayRef> Mapping, T Default, - bool IgnoreCase = false) { - if (auto ValueOr = getLocalOrGlobal(LocalName, Mapping, IgnoreCase)) + getLocalOrGlobal(StringRef LocalName, T Default, bool IgnoreCase = false) { + if (auto ValueOr = getLocalOrGlobal(LocalName, IgnoreCase)) return *ValueOr; else logErrToStdErr(ValueOr.takeError()); @@ -400,21 +410,25 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { int64_t Value) const; /// Stores an option with the check-local name \p LocalName as the string - /// representation of the Enum \p Value using the \p Mapping to \p Options. + /// representation of the Enum \p Value to \p Options. + /// + /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to + /// supply the mapping required to convert between ``T`` and a string. template std::enable_if_t::value> - store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value, - ArrayRef> Mapping) { + store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, T Value) { + ArrayRef> Mapping = + OptionEnumMapping::getEnumMapping(); auto Iter = llvm::find_if( - Mapping, [&](const std::pair &NameAndEnum) { - return NameAndEnum.second == Value; + Mapping, [&](const std::pair &NameAndEnum) { + return NameAndEnum.first == Value; }); assert(Iter != Mapping.end() && "Unknown Case Value"); - store(Options, LocalName, Iter->first); + store(Options, LocalName, Iter->second); } private: - using NameAndValue = std::pair; + using NameAndValue = std::pair; llvm::Expected getEnumInt(StringRef LocalName, ArrayRef Mapping, @@ -422,12 +436,14 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback { template std::enable_if_t::value, std::vector> - typeEraseMapping(ArrayRef> Mapping) { + typeEraseMapping() { + ArrayRef> Mapping = + OptionEnumMapping::getEnumMapping(); std::vector Result; Result.reserve(Mapping.size()); for (auto &MappedItem : Mapping) { - Result.emplace_back(MappedItem.first, - static_cast(MappedItem.second)); + Result.emplace_back(static_cast(MappedItem.first), + MappedItem.second); } return Result; } diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp index df4dbd5ff180..11bbcbcb527f 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -27,7 +27,6 @@ StringFindStartswithCheck::StringFindStartswithCheck(StringRef Name, StringLikeClasses(utils::options::parseStringList( Options.get("StringLikeClasses", "::std::basic_string"))), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)), AbseilStringsMatchHeader( Options.get("AbseilStringsMatchHeader", "absl/strings/match.h")) {} @@ -122,8 +121,7 @@ void StringFindStartswithCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "StringLikeClasses", utils::options::serializeStringList(StringLikeClasses)); - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); Options.store(Opts, "AbseilStringsMatchHeader", AbseilStringsMatchHeader); } diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp index 2be3bc4ab3cd..f1755d3f9b85 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -27,13 +27,11 @@ InitVariablesCheck::InitVariablesCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)), MathHeader(Options.get("MathHeader", "math.h")) {} void InitVariablesCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); Options.store(Opts, "MathHeader", MathHeader); } diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp index b48511287f88..dd0bedd742a4 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp @@ -22,7 +22,6 @@ ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck( StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)) {} void ProBoundsConstantArrayIndexCheck::storeOptions( diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index 215ba341f21f..b90af1521baf 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -28,6 +28,31 @@ using namespace llvm; namespace clang { namespace tidy { + +template <> struct OptionEnumMapping { + static llvm::ArrayRef> + getEnumMapping() { + static constexpr std::pair + Mapping[] = {{modernize::Confidence::CL_Reasonable, "reasonable"}, + {modernize::Confidence::CL_Safe, "safe"}, + {modernize::Confidence::CL_Risky, "risky"}}; + return makeArrayRef(Mapping); + } +}; + +template <> struct OptionEnumMapping { + static llvm::ArrayRef< + std::pair> + getEnumMapping() { + static constexpr std::pair + Mapping[] = {{modernize::VariableNamer::NS_CamelCase, "CamelCase"}, + {modernize::VariableNamer::NS_CamelBack, "camelBack"}, + {modernize::VariableNamer::NS_LowerCase, "lower_case"}, + {modernize::VariableNamer::NS_UpperCase, "UPPER_CASE"}}; + return makeArrayRef(Mapping); + } +}; + namespace modernize { static const char LoopNameArray[] = "forLoopArray"; @@ -44,25 +69,6 @@ static const char EndVarName[] = "endVar"; static const char DerefByValueResultName[] = "derefByValueResult"; static const char DerefByRefResultName[] = "derefByRefResult"; -static ArrayRef> -getConfidenceMapping() { - static constexpr std::pair Mapping[] = { - {"reasonable", Confidence::CL_Reasonable}, - {"safe", Confidence::CL_Safe}, - {"risky", Confidence::CL_Risky}}; - return makeArrayRef(Mapping); -} - -static ArrayRef> -getStyleMapping() { - static constexpr std::pair Mapping[] = - {{"CamelCase", VariableNamer::NS_CamelCase}, - {"camelBack", VariableNamer::NS_CamelBack}, - {"lower_case", VariableNamer::NS_LowerCase}, - {"UPPER_CASE", VariableNamer::NS_UpperCase}}; - return makeArrayRef(Mapping); -} - // shared matchers static const TypeMatcher AnyType() { return anything(); } @@ -474,15 +480,13 @@ LoopConvertCheck::RangeDescriptor::RangeDescriptor() LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo), MaxCopySize(Options.get("MaxCopySize", 16ULL)), - MinConfidence(Options.get("MinConfidence", getConfidenceMapping(), - Confidence::CL_Reasonable)), - NamingStyle(Options.get("NamingStyle", getStyleMapping(), - VariableNamer::NS_CamelCase)) {} + MinConfidence(Options.get("MinConfidence", Confidence::CL_Reasonable)), + NamingStyle(Options.get("NamingStyle", VariableNamer::NS_CamelCase)) {} void LoopConvertCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "MaxCopySize", std::to_string(MaxCopySize)); - Options.store(Opts, "MinConfidence", MinConfidence, getConfidenceMapping()); - Options.store(Opts, "NamingStyle", NamingStyle, getStyleMapping()); + Options.store(Opts, "MinConfidence", MinConfidence); + Options.store(Opts, "NamingStyle", NamingStyle); } void LoopConvertCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp index e34fd7038bb8..c677043946f7 100644 --- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp @@ -45,7 +45,6 @@ MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context, StringRef MakeSmartPtrFunctionName) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)), MakeSmartPtrFunctionHeader( Options.get("MakeSmartPtrFunctionHeader", StdMemoryHeader)), @@ -54,8 +53,7 @@ MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context, IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)) {} void MakeSmartPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); Options.store(Opts, "MakeSmartPtrFunctionHeader", MakeSmartPtrFunctionHeader); Options.store(Opts, "MakeSmartPtrFunction", MakeSmartPtrFunctionName); Options.store(Opts, "IgnoreMacros", IgnoreMacros); diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp index ed1a1a26bb62..b6dedfbc2b6e 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -121,13 +121,11 @@ collectParamDecls(const CXXConstructorDecl *Ctor, PassByValueCheck::PassByValueCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)), ValuesOnly(Options.get("ValuesOnly", false)) {} void PassByValueCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); Options.store(Opts, "ValuesOnly", ValuesOnly); } diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp index 295be200bca6..f98254dbf7c8 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp @@ -75,12 +75,10 @@ ReplaceAutoPtrCheck::ReplaceAutoPtrCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)) {} void ReplaceAutoPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); } void ReplaceAutoPtrCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp index 9cfbd87239dc..66917df3e91d 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp @@ -24,7 +24,6 @@ ReplaceRandomShuffleCheck::ReplaceRandomShuffleCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)) {} void ReplaceRandomShuffleCheck::registerMatchers(MatchFinder *Finder) { @@ -52,8 +51,7 @@ void ReplaceRandomShuffleCheck::registerPPCallbacks( void ReplaceRandomShuffleCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); } void ReplaceRandomShuffleCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp index d09673fa7f23..4cbb014867c4 100644 --- a/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp @@ -24,7 +24,6 @@ MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)) {} void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) { @@ -97,8 +96,7 @@ void MoveConstructorInitCheck::registerPPCallbacks( } void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); } } // namespace performance diff --git a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp index d08cec1a2c3c..597445d0fc26 100644 --- a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp @@ -32,7 +32,6 @@ TypePromotionInMathFnCheck::TypePromotionInMathFnCheck( StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)) {} void TypePromotionInMathFnCheck::registerPPCallbacks( @@ -44,8 +43,7 @@ void TypePromotionInMathFnCheck::registerPPCallbacks( void TypePromotionInMathFnCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); } void TypePromotionInMathFnCheck::registerMatchers(MatchFinder *Finder) { diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index 5b5f2ff99478..5de53b1840f1 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -69,7 +69,6 @@ UnnecessaryValueParamCheck::UnnecessaryValueParamCheck( StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - utils::IncludeSorter::getMapping(), utils::IncludeSorter::IS_LLVM)), AllowedTypes( utils::options::parseStringList(Options.get("AllowedTypes", ""))) {} @@ -181,8 +180,7 @@ void UnnecessaryValueParamCheck::registerPPCallbacks( void UnnecessaryValueParamCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - utils::IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); Options.store(Opts, "AllowedTypes", utils::options::serializeStringList(AllowedTypes)); } diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp index 6e7fcaa4345a..c885aac89072 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -26,6 +26,26 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { + +llvm::ArrayRef< + std::pair> +OptionEnumMapping< + readability::IdentifierNamingCheck::CaseType>::getEnumMapping() { + static constexpr std::pair + Mapping[] = { + {readability::IdentifierNamingCheck::CT_AnyCase, "aNy_CasE"}, + {readability::IdentifierNamingCheck::CT_LowerCase, "lower_case"}, + {readability::IdentifierNamingCheck::CT_UpperCase, "UPPER_CASE"}, + {readability::IdentifierNamingCheck::CT_CamelBack, "camelBack"}, + {readability::IdentifierNamingCheck::CT_CamelCase, "CamelCase"}, + {readability::IdentifierNamingCheck::CT_CamelSnakeCase, + "Camel_Snake_Case"}, + {readability::IdentifierNamingCheck::CT_CamelSnakeBack, + "camel_Snake_Back"}}; + return llvm::makeArrayRef(Mapping); +} + namespace readability { // clang-format off @@ -99,16 +119,6 @@ static StringRef const StyleNames[] = { #undef NAMING_KEYS // clang-format on -static constexpr std::pair - Mapping[] = { - {"aNy_CasE", IdentifierNamingCheck::CT_AnyCase}, - {"lower_case", IdentifierNamingCheck::CT_LowerCase}, - {"UPPER_CASE", IdentifierNamingCheck::CT_UpperCase}, - {"camelBack", IdentifierNamingCheck::CT_CamelBack}, - {"CamelCase", IdentifierNamingCheck::CT_CamelCase}, - {"Camel_Snake_Case", IdentifierNamingCheck::CT_CamelSnakeCase}, - {"camel_Snake_Back", IdentifierNamingCheck::CT_CamelSnakeBack}}; - IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name, ClangTidyContext *Context) : RenamerClangTidyCheck(Name, Context), @@ -117,7 +127,7 @@ IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name, for (auto const &Name : StyleNames) { auto CaseOptional = [&]() -> llvm::Optional { - auto ValueOr = Options.get((Name + "Case").str(), makeArrayRef(Mapping)); + auto ValueOr = Options.get((Name + "Case").str()); if (ValueOr) return *ValueOr; llvm::logAllUnhandledErrors( @@ -148,7 +158,7 @@ void IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { if (NamingStyles[i]) { if (NamingStyles[i]->Case) { Options.store(Opts, (StyleNames[i] + "Case").str(), - *NamingStyles[i]->Case, llvm::makeArrayRef(Mapping)); + *NamingStyles[i]->Case); } Options.store(Opts, (StyleNames[i] + "Prefix").str(), NamingStyles[i]->Prefix); diff --git a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h index 04bf53fe16b5..0f6c77b2c9a8 100644 --- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -75,6 +75,12 @@ class IdentifierNamingCheck final : public RenamerClangTidyCheck { }; } // namespace readability +template <> +struct OptionEnumMapping { + static llvm::ArrayRef< + std::pair> + getEnumMapping(); +}; } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp index f946b3a1a6f9..c9d018f076e7 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp +++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp @@ -175,13 +175,14 @@ Optional IncludeSorter::CreateIncludeInsertion(StringRef FileName, IncludeStmt); } -llvm::ArrayRef> -IncludeSorter::getMapping() { - static constexpr std::pair Mapping[] = - {{"llvm", IS_LLVM}, {"google", IS_Google}}; +} // namespace utils + +llvm::ArrayRef> +OptionEnumMapping::getEnumMapping() { + static constexpr std::pair + Mapping[] = {{utils::IncludeSorter::IS_LLVM, "llvm"}, + {utils::IncludeSorter::IS_Google, "google"}}; return makeArrayRef(Mapping); } - -} // namespace utils } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h index 7dab2cc536a4..1d8997364e5c 100644 --- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.h +++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.h @@ -9,7 +9,7 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H -#include "../ClangTidy.h" +#include "../ClangTidyCheck.h" #include namespace clang { @@ -25,8 +25,6 @@ class IncludeSorter { /// Supported include styles. enum IncludeStyle { IS_LLVM = 0, IS_Google = 1 }; - static ArrayRef> getMapping(); - /// The classifications of inclusions, in the order they should be sorted. enum IncludeKinds { IK_MainTUInclude = 0, ///< e.g. ``#include "foo.h"`` when editing foo.cc @@ -66,6 +64,11 @@ class IncludeSorter { }; } // namespace utils + +template <> struct OptionEnumMapping { + static ArrayRef> + getEnumMapping(); +}; } // namespace tidy } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_INCLUDESORTER_H diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp index 665fd5140ceb..03af5dd1565f 100644 --- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp @@ -33,7 +33,6 @@ TransformerClangTidyCheck::TransformerClangTidyCheck( StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), Rule(MakeRule(getLangOpts(), Options)), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - IncludeSorter::getMapping(), IncludeSorter::IS_LLVM)) { if (Rule) assert(llvm::all_of(Rule->Cases, hasExplanation) && @@ -46,7 +45,6 @@ TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), Rule(std::move(R)), IncludeStyle(Options.getLocalOrGlobal("IncludeStyle", - IncludeSorter::getMapping(), IncludeSorter::IS_LLVM)) { assert(llvm::all_of(Rule->Cases, hasExplanation) && "clang-tidy checks must have an explanation by default;" @@ -112,8 +110,7 @@ void TransformerClangTidyCheck::check( void TransformerClangTidyCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { - Options.store(Opts, "IncludeStyle", IncludeStyle, - IncludeSorter::getMapping()); + Options.store(Opts, "IncludeStyle", IncludeStyle); } } // namespace utils diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp index a089281bf16c..63f9a06e91be 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp @@ -6,6 +6,20 @@ namespace clang { namespace tidy { + +enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet }; + +template <> struct OptionEnumMapping { + static llvm::ArrayRef> getEnumMapping() { + static constexpr std::pair Mapping[] = { + {Colours::Red, "Red"}, {Colours::Orange, "Orange"}, + {Colours::Yellow, "Yellow"}, {Colours::Green, "Green"}, + {Colours::Blue, "Blue"}, {Colours::Indigo, "Indigo"}, + {Colours::Violet, "Violet"}}; + return makeArrayRef(Mapping); + } +}; + namespace test { TEST(ParseLineFilter, EmptyFilter) { @@ -208,16 +222,10 @@ TEST(CheckOptionsValidation, ValidIntOptions) { #undef CHECK_ERROR_INT } +// FIXME: Figure out why this test causes crashes on mac os. +#ifndef __APPLE__ TEST(ValidConfiguration, ValidEnumOptions) { - enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet }; - static constexpr std::pair Mapping[] = { - {"Red", Colours::Red}, {"Orange", Colours::Orange}, - {"Yellow", Colours::Yellow}, {"Green", Colours::Green}, - {"Blue", Colours::Blue}, {"Indigo", Colours::Indigo}, - {"Violet", Colours::Violet}}; - static const auto Map = makeArrayRef(Mapping); - ClangTidyOptions Options; auto &CheckOptions = Options.CheckOptions; @@ -237,34 +245,37 @@ TEST(ValidConfiguration, ValidEnumOptions) { #define CHECK_ERROR_ENUM(Name, Expected) \ CHECK_ERROR(Name, UnparseableEnumOptionError, Expected) - CHECK_VAL(TestCheck.getLocal("Valid", Map), Colours::Red); - CHECK_VAL(TestCheck.getGlobal("GlobalValid", Map), Colours::Violet); - CHECK_VAL(TestCheck.getLocal("ValidWrongCase", Map, /*IgnoreCase*/ true), - Colours::Red); + CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red); + CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet); + CHECK_VAL( - TestCheck.getGlobal("GlobalValidWrongCase", Map, /*IgnoreCase*/ true), - Colours::Violet); - CHECK_ERROR_ENUM(TestCheck.getLocal("Invalid", Map), + TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true), + Colours::Red); + CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase", + /*IgnoreCase*/ true), + Colours::Violet); + CHECK_ERROR_ENUM(TestCheck.getIntLocal("Invalid"), "invalid configuration value " "'Scarlet' for option 'test.Invalid'"); - CHECK_ERROR_ENUM(TestCheck.getLocal("ValidWrongCase", Map), + CHECK_ERROR_ENUM(TestCheck.getIntLocal("ValidWrongCase"), "invalid configuration value 'rED' for option " "'test.ValidWrongCase'; did you mean 'Red'?"); - CHECK_ERROR_ENUM(TestCheck.getLocal("NearMiss", Map), + CHECK_ERROR_ENUM(TestCheck.getIntLocal("NearMiss"), "invalid configuration value 'Oragne' for option " "'test.NearMiss'; did you mean 'Orange'?"); - CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalInvalid", Map), + CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalInvalid"), "invalid configuration value " "'Purple' for option 'GlobalInvalid'"); - CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalValidWrongCase", Map), + CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalValidWrongCase"), "invalid configuration value 'vIOLET' for option " "'GlobalValidWrongCase'; did you mean 'Violet'?"); - CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalNearMiss", Map), + CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalNearMiss"), "invalid configuration value 'Yelow' for option " "'GlobalNearMiss'; did you mean 'Yellow'?"); #undef CHECK_ERROR_ENUM } +#endif #undef CHECK_VAL #undef CHECK_ERROR From cfe-commits at lists.llvm.org Sat Jul 11 02:13:52 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 09:13:52 +0000 (UTC) Subject: [PATCH] D82188: [clang-tidy] Reworked enum options handling(again) In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rGc3bdc9814d94: [clang-tidy] Reworked enum options handling(again) (authored by njames93). Changed prior to commit: https://reviews.llvm.org/D82188?vs=275520&id=277227#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82188/new/ https://reviews.llvm.org/D82188 Files: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp clang-tools-extra/clang-tidy/ClangTidyCheck.h clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp clang-tools-extra/clang-tidy/utils/IncludeSorter.h clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D82188.277227.patch Type: text/x-patch Size: 35578 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sat Jul 11 04:03:03 2020 From: cfe-commits at lists.llvm.org (Alexey Lapshin via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 11:03:03 +0000 (UTC) Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls. In-Reply-To: References: Message-ID: <8b57a192e135eaac29ff80fd1d3aa6f3@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rGf7907e9d223d: [TRE] allow TRE for non-capturing calls. (authored by avl). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82085/new/ https://reviews.llvm.org/D82085 Files: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp llvm/test/Transforms/TailCallElim/basic.ll llvm/test/Transforms/TailCallElim/tre-multiple-exits.ll llvm/test/Transforms/TailCallElim/tre-noncapturing-alloca-calls.ll -------------- next part -------------- A non-text attachment was scrubbed... Name: D82085.277231.patch Type: text/x-patch Size: 19838 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sat Jul 11 04:10:56 2020 From: cfe-commits at lists.llvm.org (Nathan James via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 11:10:56 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <619afdec6add39be2810de743a5b4a94@localhost.localdomain> njames93 added a comment. Herald added a subscriber: ormris. This is causing a test case to fail on mac http://45.33.8.238/mac/17048/step_7.txt Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Sat Jul 11 06:05:05 2020 From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 13:05:05 +0000 (UTC) Subject: [PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json Message-ID: ArcsinX created this revision. Herald added subscribers: cfe-commits, usaxena95, kadircet, ilya-biryukov. Herald added a project: clang. If there is no record in compile_commands.json, we try to find suitable record with `MatchTrie.findEquivalent()` call. This is very expensive operation with a lot of `llvm::sys::fs::equivalent()` calls in some cases. This patch adds caching for `MatchTrie.findEquivalent()` call result. Example scenario without this patch: - compile_commands.json generated at clangd build (contains ~3000 files).. - it tooks more than 1 second to get compile command for newly created file in the root folder of LLVM project. - we wait for 1 second every time when clangd requests compile command for this file (at file change). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83621 Files: clang/include/clang/Tooling/JSONCompilationDatabase.h clang/lib/Tooling/JSONCompilationDatabase.cpp Index: clang/lib/Tooling/JSONCompilationDatabase.cpp =================================================================== --- clang/lib/Tooling/JSONCompilationDatabase.cpp +++ clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -230,14 +230,28 @@ SmallString<128> NativeFilePath; llvm::sys::path::native(FilePath, NativeFilePath); - std::string Error; - llvm::raw_string_ostream ES(Error); - StringRef Match = MatchTrie.findEquivalent(NativeFilePath, ES); - if (Match.empty()) - return {}; - const auto CommandsRefI = IndexByFile.find(Match); - if (CommandsRefI == IndexByFile.end()) - return {}; + // Avoid usage of `MatchTrie` if possible. + auto CommandsRefI = IndexByFile.find(NativeFilePath); + if (CommandsRefI == IndexByFile.end()) { + llvm::StringRef Match; + // Try to get cached value. + auto MatchIt = MatchCache.find(NativeFilePath); + if (MatchIt == MatchCache.end()) { + std::string Error; + llvm::raw_string_ostream ES(Error); + Match = MatchTrie.findEquivalent(NativeFilePath, ES); + // Save into cache even if the match result is empty. + MatchCache[NativeFilePath] = Match; + } else { + // Cached value. + Match = MatchIt->second; + } + if (Match.empty()) + return {}; + CommandsRefI = IndexByFile.find(Match); + if (CommandsRefI == IndexByFile.end()) + return {}; + } std::vector Commands; getCommands(CommandsRefI->getValue(), Commands); return Commands; Index: clang/include/clang/Tooling/JSONCompilationDatabase.h =================================================================== --- clang/include/clang/Tooling/JSONCompilationDatabase.h +++ clang/include/clang/Tooling/JSONCompilationDatabase.h @@ -129,6 +129,8 @@ std::vector AllCommands; FileMatchTrie MatchTrie; + // Cache for `MatchTrie`. + mutable llvm::StringMap MatchCache; std::unique_ptr Database; JSONCommandLineSyntax Syntax; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83621.277235.patch Type: text/x-patch Size: 2003 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sat Jul 11 06:22:58 2020 From: cfe-commits at lists.llvm.org (Aleksandr Platonov via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 13:22:58 +0000 (UTC) Subject: [PATCH] D83621: [clang][Tooling] Try to avoid file system access if there is no record for the file in compile_commads.json In-Reply-To: References: Message-ID: ArcsinX added a comment. Also I think that `FileMatchTrie` introduced in https://reviews.llvm.org/D30 is not efficient solution to fight with symlinks and for most cases `InterpolatingCompilationDatabase` will be accurate enough. But I am not sure, is it safe to completely remove `FileMatchTrie`? What do you think? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83621/new/ https://reviews.llvm.org/D83621 From cfe-commits at lists.llvm.org Sat Jul 11 09:27:54 2020 From: cfe-commits at lists.llvm.org (Nico Weber via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 16:27:54 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <80a80766288f024f87b407f917a65802@localhost.localdomain> thakis added a comment. This breaks check-clang on macOS: http://45.33.8.238/mac/17053/step_7.txt The output contains 5: clang: warning: argument unused during compilation: '--rocm-path=/Users/thakis/src/llvm-project/clang/test/Driver/Inputs/rocm' [-Wunused-command-line-argument] which if true would explain the failure. That bot uses the GN build, but I verified that the test fails the same way in the CMake build. Please take a look, and if it takes a while to fix, please revert while you investigate. ================ Comment at: clang/test/Driver/Inputs/rocm/bin/.hipVersion:1 +# Auto-generated by cmake +HIP_VERSION_MAJOR=3 ---------------- Is this true? I don't see any cmake code generating this. Did I miss it? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Sat Jul 11 09:28:33 2020 From: cfe-commits at lists.llvm.org (Nico Weber via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 16:28:33 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <6d706f9976f8e4a6eece61f77369116a@localhost.localdomain> thakis added a comment. …oh, njames said that already 5h ago :) I guess I'll wait another hour or two, and then I'll revert. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Sat Jul 11 09:48:55 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via cfe-commits) Date: Sat, 11 Jul 2020 09:48:55 -0700 (PDT) Subject: [clang] 5d2c3e0 - Fix regression due to test hip-version.hip Message-ID: <5f09ed77.1c69fb81.ea2e9.d3e9@mx.google.com> Author: Yaxun (Sam) Liu Date: 2020-07-11T12:45:29-04:00 New Revision: 5d2c3e031a6861b3e95673d0e238c09938dd9c0d URL: https://github.com/llvm/llvm-project/commit/5d2c3e031a6861b3e95673d0e238c09938dd9c0d DIFF: https://github.com/llvm/llvm-project/commit/5d2c3e031a6861b3e95673d0e238c09938dd9c0d.diff LOG: Fix regression due to test hip-version.hip Added RocmInstallationDetector to Darwin and MinGW. Fixed duplicate ROCm detector in ROCm toolchain. Added: Modified: clang/lib/Driver/ToolChains/AMDGPU.cpp clang/lib/Driver/ToolChains/AMDGPU.h clang/lib/Driver/ToolChains/Darwin.cpp clang/lib/Driver/ToolChains/Darwin.h clang/lib/Driver/ToolChains/FreeBSD.cpp clang/lib/Driver/ToolChains/FreeBSD.h clang/lib/Driver/ToolChains/HIP.cpp clang/lib/Driver/ToolChains/MinGW.cpp clang/lib/Driver/ToolChains/MinGW.h clang/test/Driver/hip-version.hip Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index cfc71d7810b4..bc6d1fcd4a00 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -489,9 +489,9 @@ bool AMDGPUToolChain::isWave64(const llvm::opt::ArgList &DriverArgs, /// ROCM Toolchain ROCMToolChain::ROCMToolChain(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : AMDGPUToolChain(D, Triple, Args), - RocmInstallation(D, Triple, Args, /*DetectHIPRuntime=*/false, - /*DetectDeviceLib=*/true) {} + : AMDGPUToolChain(D, Triple, Args) { + RocmInstallation.detectDeviceLibrary(); +} void AMDGPUToolChain::addClangTargetOptions( const llvm::opt::ArgList &DriverArgs, diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h index 71c66188b045..5d44faf28b05 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -90,9 +90,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF { }; class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public AMDGPUToolChain { -protected: - RocmInstallationDetector RocmInstallation; - public: ROCMToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index 6bf42e6029eb..2e1190c34ea7 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -779,7 +779,7 @@ MachO::MachO(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) /// Darwin - Darwin tool chain for i386 and x86_64. Darwin::Darwin(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : MachO(D, Triple, Args), TargetInitialized(false), - CudaInstallation(D, Triple, Args) {} + CudaInstallation(D, Triple, Args), RocmInstallation(D, Triple, Args) {} types::ID MachO::LookupTypeForExtension(StringRef Ext) const { types::ID Ty = ToolChain::LookupTypeForExtension(Ext); @@ -831,6 +831,11 @@ void Darwin::AddCudaIncludeArgs(const ArgList &DriverArgs, CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args); } +void Darwin::AddHIPIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args); +} + // This is just a MachO name translation routine and there's no // way to join this into ARMTargetParser without breaking all // other assumptions. Maybe MachO should consider standardising @@ -2736,4 +2741,5 @@ SanitizerMask Darwin::getSupportedSanitizers() const { void Darwin::printVerboseInfo(raw_ostream &OS) const { CudaInstallation.print(OS); + RocmInstallation.print(OS); } diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h index a543a8fc27b9..64c252efea7d 100644 --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -10,6 +10,7 @@ #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H #include "Cuda.h" +#include "ROCm.h" #include "clang/Driver/DarwinSDKInfo.h" #include "clang/Driver/Tool.h" #include "clang/Driver/ToolChain.h" @@ -293,6 +294,7 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO { mutable Optional SDKInfo; CudaInstallationDetector CudaInstallation; + RocmInstallationDetector RocmInstallation; private: void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const; @@ -475,6 +477,8 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO { void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; bool UseObjCMixedDispatch() const override { // This is only used with the non-fragile ABI and non-legacy dispatch. diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp index 14cf278c19d9..909ac5e99212 100644 --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -425,6 +425,11 @@ void FreeBSD::AddCudaIncludeArgs(const ArgList &DriverArgs, CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args); } +void FreeBSD::AddHIPIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args); +} + Tool *FreeBSD::buildAssembler() const { return new tools::freebsd::Assembler(*this); } diff --git a/clang/lib/Driver/ToolChains/FreeBSD.h b/clang/lib/Driver/ToolChains/FreeBSD.h index bca3f6b741b6..abc0876cef26 100644 --- a/clang/lib/Driver/ToolChains/FreeBSD.h +++ b/clang/lib/Driver/ToolChains/FreeBSD.h @@ -68,6 +68,8 @@ class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF { llvm::opt::ArgStringList &CmdArgs) const override; void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override; diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp index 32734f5c1180..7d17f809690e 100644 --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -224,7 +224,6 @@ HIPToolChain::HIPToolChain(const Driver &D, const llvm::Triple &Triple, // Lookup binaries into the driver directory, this is used to // discover the clang-offload-bundler executable. getProgramPaths().push_back(getDriver().Dir); - RocmInstallation.detectHIPRuntime(); } void HIPToolChain::addClangTargetOptions( diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index b233e210d889..a1a1b413fb6c 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -398,7 +398,8 @@ llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() { toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) - : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) { + : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args), + RocmInstallation(D, Triple, Args) { getProgramPaths().push_back(getDriver().getInstalledDir()); if (getDriver().SysRoot.size()) @@ -500,8 +501,14 @@ void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs, CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args); } +void toolchains::MinGW::AddHIPIncludeArgs(const ArgList &DriverArgs, + ArgStringList &CC1Args) const { + RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args); +} + void toolchains::MinGW::printVerboseInfo(raw_ostream &OS) const { CudaInstallation.print(OS); + RocmInstallation.print(OS); } // Include directories for various hosts: diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h index 46264a55cfc7..2f1559fcf34c 100644 --- a/clang/lib/Driver/ToolChains/MinGW.h +++ b/clang/lib/Driver/ToolChains/MinGW.h @@ -11,6 +11,7 @@ #include "Cuda.h" #include "Gnu.h" +#include "ROCm.h" #include "clang/Driver/Tool.h" #include "clang/Driver/ToolChain.h" #include "llvm/Support/ErrorOr.h" @@ -81,6 +82,8 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain { void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; + void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; void printVerboseInfo(raw_ostream &OS) const override; @@ -91,6 +94,7 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain { private: CudaInstallationDetector CudaInstallation; + RocmInstallationDetector RocmInstallation; std::string Base; std::string GccLibDir; diff --git a/clang/test/Driver/hip-version.hip b/clang/test/Driver/hip-version.hip index cf80ae15ac6d..eb1295210cfc 100644 --- a/clang/test/Driver/hip-version.hip +++ b/clang/test/Driver/hip-version.hip @@ -5,6 +5,10 @@ // RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \ // RUN: | FileCheck -check-prefixes=FOUND %s +// RUN: %clang -v --rocm-path=%S/Inputs/rocm 2>&1 \ +// RUN: -target amdgcn-amd-amdhsa \ +// RUN: | FileCheck -check-prefixes=FOUND %s + // FOUND: Found HIP installation: {{.*Inputs.*rocm}}, version 3.6.20214-a2917cd // When --rocm-path is set and .hipVersion is not found, use default version @@ -12,11 +16,19 @@ // RUN: %clang -v --rocm-path=%S 2>&1 \ // RUN: | FileCheck -check-prefixes=DEFAULT %s +// RUN: %clang -v --rocm-path=%S 2>&1 \ +// RUN: -target amdgcn-amd-amdhsa \ +// RUN: | FileCheck -check-prefixes=DEFAULT %s + // DEFAULT: Found HIP installation: {{.*Driver}}, version 3.5. // RUN: %clang -v --rocm-path=%S --hip-version=3.7.0 2>&1 \ // RUN: | FileCheck -check-prefixes=SPECIFIED %s +// RUN: %clang -v --rocm-path=%S --hip-version=3.7.0 2>&1 \ +// RUN: -target amdgcn-amd-amdhsa \ +// RUN: | FileCheck -check-prefixes=SPECIFIED %s + // SPECIFIED: Found HIP installation: {{.*Driver}}, version 3.7.0 // RUN: %clang -v --rocm-path=%S --hip-version=3.7 2>&1 \ From cfe-commits at lists.llvm.org Sat Jul 11 09:50:49 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 16:50:49 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: yaxunl added a comment. In D82930#2145914 , @thakis wrote: > This breaks check-clang on macOS: http://45.33.8.238/mac/17053/step_7.txt > > The output contains > > 5: clang: warning: argument unused during compilation: '--rocm-path=/Users/thakis/src/llvm-project/clang/test/Driver/Inputs/rocm' [-Wunused-command-line-argument] > > > which if true would explain the failure. > > That bot uses the GN build, but I verified that the test fails the same way in the CMake build. > > Please take a look, and if it takes a while to fix, please revert while you investigate. should be fixed by 5d2c3e031a6861b3e95673d0e238c09938dd9c0d Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Sat Jul 11 09:51:22 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 16:51:22 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <6afa8fec1ee74febd87503283066bcca@localhost.localdomain> yaxunl added a comment. In D82930#2145827 , @njames93 wrote: > This is causing a test case to fail on mac http://45.33.8.238/mac/17048/step_7.txt 5d2c3e031a6861b3e95673d0e238c09938dd9c0d should fix it Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Sat Jul 11 12:07:24 2020 From: cfe-commits at lists.llvm.org (Greg Clayton via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 19:07:24 +0000 (UTC) Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event In-Reply-To: References: Message-ID: <97502b9d156bf93d26e2cce16dba08e2@localhost.localdomain> clayborg added a comment. In D82477#2145565 , @MaskRay wrote: > Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git commit with the following script: > > arcfilter () { > arc amend > git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F - > } > > > `Reviewed By: ` is considered important by some people. Please keep the tag. (`--date=now` is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time)) > > `llvm/utils/git/pre-push.py` can validate the message does not include unneeded tags. Can we modify this script to remove the unneeded tags instead of detecting it? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82477/new/ https://reviews.llvm.org/D82477 From cfe-commits at lists.llvm.org Sat Jul 11 13:21:24 2020 From: cfe-commits at lists.llvm.org (Michael Liao via cfe-commits) Date: Sat, 11 Jul 2020 13:21:24 -0700 (PDT) Subject: [clang] b8409c0 - Fix `-Wreturn-type` warning. NFC. Message-ID: <5f0a1f44.1c69fb81.e33e7.57f5@mx.google.com> Author: Michael Liao Date: 2020-07-11T16:20:41-04:00 New Revision: b8409c03ed90807f3d49c7d98dceea98cf461f7a URL: https://github.com/llvm/llvm-project/commit/b8409c03ed90807f3d49c7d98dceea98cf461f7a DIFF: https://github.com/llvm/llvm-project/commit/b8409c03ed90807f3d49c7d98dceea98cf461f7a.diff LOG: Fix `-Wreturn-type` warning. NFC. Added: Modified: clang/lib/Tooling/Syntax/BuildTree.cpp Removed: ################################################################################ diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 6d13f1ace83b..1f192180ec45 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -750,6 +750,7 @@ class BuildTreeVisitor : public RecursiveASTVisitor { return new (allocator()) syntax::FloatUserDefinedLiteralExpression; } } + llvm_unreachable("Unknown literal operator kind."); } bool WalkUpFromUserDefinedLiteral(UserDefinedLiteral *S) { From cfe-commits at lists.llvm.org Sat Jul 11 13:44:04 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 20:44:04 +0000 (UTC) Subject: [PATCH] D82477: [lldb-vscode] Add Support for Module Event In-Reply-To: References: Message-ID: <34c8264524a4ef4aaeadda95b7fc42c8@localhost.localdomain> MaskRay added a subscriber: mehdi_amini. MaskRay added a comment. In D82477#2145967 , @clayborg wrote: > In D82477#2145565 , @MaskRay wrote: > > > Hi, your git commit contains extra Phabricator tags. You can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git commit with the following script: > > > > arcfilter () { > > arc amend > > git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F - > > } > > > > > > `Reviewed By: ` is considered important by some people. Please keep the tag. (`--date=now` is my personal preference (author dates are usually not useful. Using committer dates can make log almost monotonic in time)) > > > > `llvm/utils/git/pre-push.py` can validate the message does not include unneeded tags. > > > Can we modify this script to remove the unneeded tags instead of detecting it? @mehdi_amini ^^ Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82477/new/ https://reviews.llvm.org/D82477 From cfe-commits at lists.llvm.org Sat Jul 11 16:42:23 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Sat, 11 Jul 2020 23:42:23 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: dblaikie accepted this revision. dblaikie added a comment. This revision is now accepted and ready to land. In D82728#2142071 , @logan-5 wrote: > Feels like a dumb question, but I'm not sure if and how those build failures are related to this patch? They seem to involve completely separate parts of the LLVM project (and `.c` files to boot). Was it that the build was failing for an unrelated reason at the moment the bots happened to build this patch? Or am I misunderstanding something more obvious? Yeah, don't think those are related, no. Wouldn't worry about them. Looks good - thanks for the patch and all the details! Might be worth turning on by default in the LLVM build (after all the cleanup) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Sat Jul 11 17:21:01 2020 From: cfe-commits at lists.llvm.org (Petr Hosek via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 00:21:01 +0000 (UTC) Subject: [PATCH] D83154: clang: Add -fcoverage-prefix-map In-Reply-To: References: Message-ID: <55a27ca2ac98c2e9514a7f9c662ce755@localhost.localdomain> phosek added a comment. Herald added a subscriber: dang. In D83154#2134984 , @MaskRay wrote: > -fdebug-prefix-map does not make sense to me because coverage is not debug info. > I am on the fence whether we need -fcoverage-prefix-map. I created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96092 (Should --coverage respect -ffile-prefix-map?) Looks like GCC has `-fprofile-prefix-path` in the queue which is trying to achieve a similar thing. I'd prefer `-fprofile-prefix-map` to be consistent with the existing `-f*-prefix-map` options, both in terms of spelling and usage. I think that `-fprofile-prefix-map` is better than `-fcoverage-prefix-map` because it makes it clear that it applies `-fprofile-*` set of options. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83154/new/ https://reviews.llvm.org/D83154 From cfe-commits at lists.llvm.org Sat Jul 11 19:36:35 2020 From: cfe-commits at lists.llvm.org (Nico Weber via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 02:36:35 +0000 (UTC) Subject: [PATCH] D82930: [HIP] Fix rocm detection In-Reply-To: References: Message-ID: <082f6a516c3da77a72591ebfcaca96d2@localhost.localdomain> thakis added a comment. Great, thanks :) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82930/new/ https://reviews.llvm.org/D82930 From cfe-commits at lists.llvm.org Sat Jul 11 19:41:33 2020 From: cfe-commits at lists.llvm.org (Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 02:41:33 +0000 (UTC) Subject: [PATCH] D71124: [RISCV] support clang driver to select cpu In-Reply-To: References: Message-ID: khchen added a comment. @asb @lenary I thought this path is ready to land? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71124/new/ https://reviews.llvm.org/D71124 From cfe-commits at lists.llvm.org Sat Jul 11 19:55:38 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 02:55:38 +0000 (UTC) Subject: [PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: <676dc3a4fc8743c766ee1470e8ca6f4d@localhost.localdomain> yaxunl marked 9 inline comments as done. yaxunl added inline comments. Herald added a subscriber: dang. ================ Comment at: clang/lib/AST/ASTContext.cpp:10068 + isa(D) && cast(D)->isFileVarDecl() && + cast(D)->getStorageClass() == SC_Static) { + return GVA_StrongExternal; ---------------- JonChesterfield wrote: > yaxunl wrote: > > rjmccall wrote: > > > Are you sure this doesn't apply to e.g. local statics? Can't you have kernel lambdas, or am I confusing HIP with another language? > > function-scope static var in a device function is only visible to the device function. Host code cannot access it, therefore no need to externalize it. > This doesn't sound right. An inline function can return a pointer to a function scope static variable, e.g. to implement a singleton in a header file. I think host code can then access said variable. As long as we are not accessing the static variable by symbol we do not need externalize it. If a device function returns a pointer to its static variable and somehow passes that pointer to host code, the host code can use it directly by hipMemCpy. ================ Comment at: clang/lib/AST/ASTContext.cpp:10068 + isa(D) && cast(D)->isFileVarDecl() && + cast(D)->getStorageClass() == SC_Static) { + return GVA_StrongExternal; ---------------- rjmccall wrote: > yaxunl wrote: > > JonChesterfield wrote: > > > yaxunl wrote: > > > > rjmccall wrote: > > > > > Are you sure this doesn't apply to e.g. local statics? Can't you have kernel lambdas, or am I confusing HIP with another language? > > > > function-scope static var in a device function is only visible to the device function. Host code cannot access it, therefore no need to externalize it. > > > This doesn't sound right. An inline function can return a pointer to a function scope static variable, e.g. to implement a singleton in a header file. I think host code can then access said variable. > > As long as we are not accessing the static variable by symbol we do not need externalize it. > > > > If a device function returns a pointer to its static variable and somehow passes that pointer to host code, the host code can use it directly by hipMemCpy. > Right, and IIRC you can declare __host__ __device__ functions as well, which ought to agree on the variable if they agree on globals. If we have a static variable in a device function, it is only visible in the function and not visible by any host code. We only need externalize it if it needs to be accessed `by symbol` in the host code, however, that is impossible, therefore we do not need externalize it. For static variables in a host device function, the static variables should be different instances on host side and device side. The rationale is that a static variable is per function, whereas a host device function is actually two functions: a host instance and a device instance, which could be totally different by using conditional macros. If it is requested that the static variable in a host device function is one instance, it requires special handling in runtime so that the same variable can be accessed on both device side and host side by common load/store instructions, but that is not the case. Therefore the device side instance of a static variable in a host device function is still only visible to device codes, not visible to host codes. Since it cannot be accessed `by symbol` by host code, it does not needs to be externalized. ================ Comment at: clang/lib/CodeGen/CodeGenModule.cpp:6069 + llvm::raw_ostream &OS) const { + OS << ".static." << getLangOpts().CUID; +} ---------------- tra wrote: > I suspect that will have interesting issues if CUID is an arbitrary user-supplied string. We may want to impose some sort of sanity check or filtering on the cuid value. Considering that it's a CC1 flag, it's not a critical problem, but some safeguards would be useful there, too. Should we limit allowed character set? will only allow alphanumeric and underscore in CUID for simplicity. ================ Comment at: clang/test/Driver/hip-cuid.hip:35 +// RUN: --offload-arch=gfx906 \ +// RUN: -c -nogpulib -cuid=abcd \ +// RUN: %S/Inputs/hip_multiple_inputs/a.cu \ ---------------- tra wrote: > Nit: `abcd` could potentially match the value generated by hash. I'd change it to contain characters other than hex. done CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 From cfe-commits at lists.llvm.org Sat Jul 11 19:58:33 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 02:58:33 +0000 (UTC) Subject: [PATCH] D80858: [CUDA][HIP] Support accessing static device variable in host code In-Reply-To: References: Message-ID: <0ca3e8bb0fe1fc96336cc95ccb6521b8@localhost.localdomain> yaxunl updated this revision to Diff 277272. yaxunl marked 3 inline comments as done. yaxunl added a comment. Only allow cuid to be alphanumeric and underscore. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80858/new/ https://reviews.llvm.org/D80858 Files: clang/include/clang/AST/ASTContext.h clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Basic/LangOptions.h clang/include/clang/Driver/Action.h clang/include/clang/Driver/Compilation.h clang/include/clang/Driver/Options.td clang/lib/AST/ASTContext.cpp clang/lib/CodeGen/CGCUDANV.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/Driver/Action.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCUDA/static-device-var.cu clang/test/Driver/hip-cuid.hip clang/test/Frontend/hip-cuid.hip clang/test/SemaCUDA/static-device-var.cu -------------- next part -------------- A non-text attachment was scrubbed... Name: D80858.277272.patch Type: text/x-patch Size: 24125 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sat Jul 11 21:35:31 2020 From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 04:35:31 +0000 (UTC) Subject: [PATCH] D83154: clang: Add -fcoverage-prefix-map In-Reply-To: References: Message-ID: MaskRay added a comment. In D83154#2146085 , @phosek wrote: > In D83154#2134984 , @MaskRay wrote: > > > -fdebug-prefix-map does not make sense to me because coverage is not debug info. > > I am on the fence whether we need -fcoverage-prefix-map. I created https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96092 (Should --coverage respect -ffile-prefix-map?) > > > Looks like GCC has `-fprofile-prefix-path` in the queue which is trying to achieve a similar thing. I'd prefer `-fprofile-prefix-map` to be consistent with the existing `-f*-prefix-map` options, both in terms of spelling and usage. I think that `-fprofile-prefix-map` is better than `-fcoverage-prefix-map` because it makes it clear that it applies `-fprofile-*` set of options. `-fprofile-prefix-map` looks good to me. I made another comment and CCed the author of https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=44b326839d864fc10c459916abcc97f35a9ac3de (which added -fprofile-prefix-path) in that bug. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83154/new/ https://reviews.llvm.org/D83154 From cfe-commits at lists.llvm.org Sun Jul 12 00:19:55 2020 From: cfe-commits at lists.llvm.org (Sameer Sahasrabuddhe via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 07:19:55 +0000 (UTC) Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot In-Reply-To: References: Message-ID: <9120c8b61c01baa87456bc439daec92d@localhost.localdomain> sameerds added a comment. >> https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions > > I think if the language interface insists on fixing the wave size, then I think the correct solution is to implement this in the header based on a wave size macro (which we're desperately missing). The library implementation should be responsible for inserting the extension to 64-bit for wave32 Not sure if the frontend should try to infer warpsize and the mask size, or even whether it can in all cases. But this can result in wrong behaviour when the program passes 32-bit mask but then gets compiled for a 64-bit mask. It's easy to say that the programmer must not assume a warp-size, but it would be useful if the language can In D82087#2144712 , @arsenm wrote: > In D82087#2140778 , @sameerds wrote: > > > The documentation for HIP __ballot seems to indicate that the user does not have to explicitly specify the warp size. How is that achieved with these new builtins? Can this be captured in a lit test here? > > > This seems like a defect in the design to me > > > https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions I tend to agree. The HIP vote/ballot builtins are also missing a mask parameter, whose type needs to match the wavesize. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82087/new/ https://reviews.llvm.org/D82087 From cfe-commits at lists.llvm.org Sun Jul 12 01:39:53 2020 From: cfe-commits at lists.llvm.org (Ten Tzen via cfe-commits) Date: Sun, 12 Jul 2020 01:39:53 -0700 (PDT) Subject: [clang] 66f1dcd - [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally Message-ID: <5f0acc59.1c69fb81.eeb23.92a7@mx.google.com> Author: Ten Tzen Date: 2020-07-12T01:37:56-07:00 New Revision: 66f1dcd872dba189ee054fb016f4bff535fb5afc URL: https://github.com/llvm/llvm-project/commit/66f1dcd872dba189ee054fb016f4bff535fb5afc DIFF: https://github.com/llvm/llvm-project/commit/66f1dcd872dba189ee054fb016f4bff535fb5afc.diff LOG: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally This change fixed a SEH bug (exposed by test58 & test61 in MSVC test xcpt4u.c); when an Except-filter is located inside a finally, the frame-pointer generated today via intrinsic @llvm.eh.recoverfp is the frame-pointer of the immediate parent _finally, not the frame-ptr of outermost host function. The fix is to retrieve the Establisher's frame-pointer that was previously saved in parent's frame. The prolog of a filter inside a _finally should be like code below: %0 = call i8* @llvm.eh.recoverfp(i8* bitcast (@"?fin$0 at 0@main@@"), i8*%frame_pointer) %1 = call i8* @llvm.localrecover(i8* bitcast (@"?fin$0 at 0@main@@"), i8*%0, i32 0) %2 = bitcast i8* %1 to i8** %3 = load i8*, i8** %2, align 8 Differential Revision: https://reviews.llvm.org/D77982 Added: clang/test/CodeGen/windows-seh-filter-inFinally.c Modified: clang/lib/CodeGen/CGException.cpp clang/lib/CodeGen/CodeGenFunction.h Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 2494f38b3159..bdf70252b5ad 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1815,6 +1815,48 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF, llvm::Constant *ParentI8Fn = llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy); ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP}); + + // if the parent is a _finally, the passed-in ParentFP is the FP + // of parent _finally, not Establisher's FP (FP of outermost function). + // Establkisher FP is 2nd paramenter passed into parent _finally. + // Fortunately, it's always saved in parent's frame. The following + // code retrieves it, and escapes it so that spill instruction won't be + // optimized away. + if (ParentCGF.ParentCGF != nullptr) { + // Locate and escape Parent's frame_pointer.addr alloca + // Depending on target, should be 1st/2nd one in LocalDeclMap. + // Let's just scan for ImplicitParamDecl with VoidPtrTy. + llvm::AllocaInst *FramePtrAddrAlloca = nullptr; + for (auto &I : ParentCGF.LocalDeclMap) { + const VarDecl *D = cast(I.first); + if (isa(D) && + D->getType() == getContext().VoidPtrTy) { + assert(D->getName().startswith("frame_pointer")); + FramePtrAddrAlloca = cast(I.second.getPointer()); + break; + } + } + assert(FramePtrAddrAlloca); + auto InsertPair = ParentCGF.EscapedLocals.insert( + std::make_pair(FramePtrAddrAlloca, ParentCGF.EscapedLocals.size())); + int FrameEscapeIdx = InsertPair.first->second; + + // an example of a filter's prolog:: + // %0 = call i8* @llvm.eh.recoverfp(bitcast(@"?fin$0 at 0@main@@"),..) + // %1 = call i8* @llvm.localrecover(bitcast(@"?fin$0 at 0@main@@"),..) + // %2 = bitcast i8* %1 to i8** + // %3 = load i8*, i8* *%2, align 8 + // ==> %3 is the frame-pointer of outermost host function + llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration( + &CGM.getModule(), llvm::Intrinsic::localrecover); + llvm::Constant *ParentI8Fn = + llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy); + ParentFP = Builder.CreateCall( + FrameRecoverFn, {ParentI8Fn, ParentFP, + llvm::ConstantInt::get(Int32Ty, FrameEscapeIdx)}); + ParentFP = Builder.CreateBitCast(ParentFP, CGM.VoidPtrPtrTy); + ParentFP = Builder.CreateLoad(Address(ParentFP, getPointerAlign())); + } } // Create llvm.localrecover calls for all captures. @@ -2013,6 +2055,7 @@ void CodeGenFunction::pushSEHCleanup(CleanupKind Kind, void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) { CodeGenFunction HelperCGF(CGM, /*suppressNewContext=*/true); + HelperCGF.ParentCGF = this; if (const SEHFinallyStmt *Finally = S.getFinallyHandler()) { // Outline the finally block. llvm::Function *FinallyFunc = diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index b1841d646643..1fc2ed76ca9e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -264,6 +264,9 @@ class CodeGenFunction : public CodeGenTypeCache { CodeGenModule &CGM; // Per-module state. const TargetInfo &Target; + // For EH/SEH outlined funclets, this field points to parent's CGF + CodeGenFunction *ParentCGF = nullptr; + typedef std::pair ComplexPairTy; LoopInfoStack LoopStack; CGBuilderTy Builder; diff --git a/clang/test/CodeGen/windows-seh-filter-inFinally.c b/clang/test/CodeGen/windows-seh-filter-inFinally.c new file mode 100644 index 000000000000..f9dfca14f020 --- /dev/null +++ b/clang/test/CodeGen/windows-seh-filter-inFinally.c @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -triple x86_64-windows -fms-extensions -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: %[[dst:[0-9-]+]] = call i8* @llvm.eh.recoverfp(i8* bitcast (void (i8, i8*)* @"?fin$0 at 0@main@@" to i8*), i8* %frame_pointer) +// CHECK-NEXT: %[[dst1:[0-9-]+]] = call i8* @llvm.localrecover(i8* bitcast (void (i8, i8*)* @"?fin$0 at 0@main@@" to i8*), i8* %[[dst]], i32 0) +// CHECK-NEXT: %[[dst2:[0-9-]+]] = bitcast i8* %[[dst1]] to i8** +// CHECK-NEXT: = load i8*, i8** %[[dst2]], align 8 + +int +main(int argc, char *argv[]) +{ + int Counter = 0; + // + // Try/except within the finally clause of a try/finally. + // + __try { + Counter -= 1; + } + __finally { + __try { + Counter += 2; + // RtlRaiseStatus(STATUS_INTEGER_OVERFLOW); + } __except(Counter) { + __try { + Counter += 3; + } + __finally { + if (abnormal_termination() == 1) { + Counter += 5; + } + } + } + } + // expect Counter == 9 + return 1; +} + From cfe-commits at lists.llvm.org Sun Jul 12 01:40:02 2020 From: cfe-commits at lists.llvm.org (Ten Tzen via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 08:40:02 +0000 (UTC) Subject: [PATCH] D77982: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG66f1dcd872db: [Windows SEH] Fix the frame-ptr of a nested-filter within a _finally (authored by tentzen). Changed prior to commit: https://reviews.llvm.org/D77982?vs=257227&id=277279#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77982/new/ https://reviews.llvm.org/D77982 Files: clang/lib/CodeGen/CGException.cpp clang/lib/CodeGen/CodeGenFunction.h clang/test/CodeGen/windows-seh-filter-inFinally.c -------------- next part -------------- A non-text attachment was scrubbed... Name: D77982.277279.patch Type: text/x-patch Size: 4766 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 02:43:59 2020 From: cfe-commits at lists.llvm.org (David Zarzycki via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 09:43:59 +0000 (UTC) Subject: [PATCH] D82085: [TRE] allow TRE for non-capturing calls. In-Reply-To: References: Message-ID: <294696123008e665e0b813c136c34d09@localhost.localdomain> davezarzycki added a comment. Hello. I have an auto-bisecting multi-stage bot that is failing on two after this change. Can we please revert this or commit a quick fix? FAIL: Clang :: CXX/class/class.compare/class.spaceship/p1.cpp (6232 of 64222) ******************** TEST 'Clang :: CXX/class/class.compare/class.spaceship/p1.cpp' FAILED ******************** Script: -- : 'RUN: at line 1'; /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp -fcxx-exceptions -- Exit Code: 134 Command Output (stderr): -- clang: /home/dave/s/lp/clang/lib/Basic/SourceManager.cpp:917: clang::FileID clang::SourceManager::getFileIDLoaded(unsigned int) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp -fcxx-exceptions 1. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:127:38: current parser token ',' 2. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:39:1: parsing namespace 'Deletedness' 3. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:123:12: parsing function body 'Deletedness::g' 4. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:123:12: in compound statement ('{}') #0 0x000000000359273f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/_update_lc/t/bin/clang+0x359273f) #1 0x0000000003590912 llvm::sys::RunSignalHandlers() (/tmp/_update_lc/t/bin/clang+0x3590912) #2 0x0000000003592bb5 SignalHandler(int) (/tmp/_update_lc/t/bin/clang+0x3592bb5) #3 0x00007ffff7fa6a90 __restore_rt (/lib64/libpthread.so.0+0x14a90) #4 0x00007ffff7b3da25 raise (/lib64/libc.so.6+0x3ca25) #5 0x00007ffff7b26895 abort (/lib64/libc.so.6+0x25895) #6 0x00007ffff7b26769 _nl_load_domain.cold (/lib64/libc.so.6+0x25769) #7 0x00007ffff7b35e86 (/lib64/libc.so.6+0x34e86) #8 0x000000000375636c clang::SourceManager::getFileIDLoaded(unsigned int) const (/tmp/_update_lc/t/bin/clang+0x375636c) #9 0x0000000003ee0bbb clang::VerifyDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/tmp/_update_lc/t/bin/clang+0x3ee0bbb) #10 0x00000000037501ab clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/tmp/_update_lc/t/bin/clang+0x37501ab) #11 0x0000000003749fca clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/tmp/_update_lc/t/bin/clang+0x3749fca) #12 0x0000000004df0c60 clang::Sema::EmitCurrentDiagnostic(unsigned int) (/tmp/_update_lc/t/bin/clang+0x4df0c60) #13 0x0000000005092783 (anonymous namespace)::DefaultedComparisonAnalyzer::visitBinaryOperator(clang::OverloadedOperatorKind, llvm::ArrayRef, (anonymous namespace)::DefaultedComparisonSubobject, clang::OverloadCandidateSet*) (/tmp/_update_lc/t/bin/clang+0x5092783) #14 0x0000000005091dba (anonymous namespace)::DefaultedComparisonAnalyzer::visitExpandedSubobject(clang::QualType, (anonymous namespace)::DefaultedComparisonSubobject) (/tmp/_update_lc/t/bin/clang+0x5091dba) #15 0x0000000005091b86 (anonymous namespace)::DefaultedComparisonVisitor<(anonymous namespace)::DefaultedComparisonAnalyzer, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonSubobject>::visitSubobjects((anonymous namespace)::DefaultedComparisonInfo&, clang::CXXRecordDecl*, clang::Qualifiers) (/tmp/_update_lc/t/bin/clang+0x5091b86) #16 0x0000000005058c8c (anonymous namespace)::DefaultedComparisonAnalyzer::visit() (/tmp/_update_lc/t/bin/clang+0x5058c8c) #17 0x000000000505ab22 clang::Sema::DiagnoseDeletedDefaultedFunction(clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x505ab22) #18 0x00000000053e60ed clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x53e60ed) #19 0x000000000514270a BuildOverloadedBinOp(clang::Sema&, clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x514270a) #20 0x00000000050fbf49 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x50fbf49) #21 0x0000000004d52ccc clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult, clang::prec::Level) (/tmp/_update_lc/t/bin/clang+0x4d52ccc) #22 0x0000000004d51be9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51be9) #23 0x0000000004d60dba clang::Parser::ParseExpressionList(llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, llvm::function_ref) (/tmp/_update_lc/t/bin/clang+0x4d60dba) #24 0x0000000004d542d9 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult) (/tmp/_update_lc/t/bin/clang+0x4d542d9) #25 0x0000000004d55b95 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/tmp/_update_lc/t/bin/clang+0x4d55b95) #26 0x0000000004d51b89 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51b89) #27 0x0000000004d51ac9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51ac9) #28 0x0000000004d78368 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/tmp/_update_lc/t/bin/clang+0x4d78368) #29 0x0000000004d76ba0 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/tmp/_update_lc/t/bin/clang+0x4d76ba0) #30 0x0000000004d76614 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/tmp/_update_lc/t/bin/clang+0x4d76614) #31 0x0000000004d7ecd2 clang::Parser::ParseCompoundStatementBody(bool) (/tmp/_update_lc/t/bin/clang+0x4d7ecd2) #32 0x0000000004d7fcd0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/tmp/_update_lc/t/bin/clang+0x4d7fcd0) #33 0x0000000004cfacc0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/tmp/_update_lc/t/bin/clang+0x4cfacc0) #34 0x0000000004d28f2d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/tmp/_update_lc/t/bin/clang+0x4d28f2d) #35 0x0000000004cf9f32 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9f32) #36 0x0000000004cf9938 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9938) #37 0x0000000004cf86fc clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/tmp/_update_lc/t/bin/clang+0x4cf86fc) #38 0x0000000004d02c15 clang::Parser::ParseInnerNamespace(llvm::SmallVector const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/tmp/_update_lc/t/bin/clang+0x4d02c15) #39 0x0000000004d0251a clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/tmp/_update_lc/t/bin/clang+0x4d0251a) #40 0x0000000004d22f0a clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, clang::SourceLocation*) (/tmp/_update_lc/t/bin/clang+0x4d22f0a) #41 0x0000000004cf7e39 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/tmp/_update_lc/t/bin/clang+0x4cf7e39) #42 0x0000000004cf6858 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) (/tmp/_update_lc/t/bin/clang+0x4cf6858) #43 0x0000000004cf16ed clang::ParseAST(clang::Sema&, bool, bool) (/tmp/_update_lc/t/bin/clang+0x4cf16ed) #44 0x0000000003e3eb21 clang::FrontendAction::Execute() (/tmp/_update_lc/t/bin/clang+0x3e3eb21) #45 0x0000000003dba0e3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/tmp/_update_lc/t/bin/clang+0x3dba0e3) #46 0x0000000003ee796b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/tmp/_update_lc/t/bin/clang+0x3ee796b) #47 0x0000000002244636 cc1_main(llvm::ArrayRef, char const*, void*) (/tmp/_update_lc/t/bin/clang+0x2244636) #48 0x000000000224297d ExecuteCC1Tool(llvm::SmallVectorImpl&) (/tmp/_update_lc/t/bin/clang+0x224297d) #49 0x0000000002242619 main (/tmp/_update_lc/t/bin/clang+0x2242619) #50 0x00007ffff7b28042 __libc_start_main (/lib64/libc.so.6+0x27042) #51 0x000000000223f8ce _start (/tmp/_update_lc/t/bin/clang+0x223f8ce) /tmp/_update_lc/t/tools/clang/test/CXX/class/class.compare/class.spaceship/Output/p1.cpp.script: line 1: 4146089 Aborted /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp -fcxx-exceptions -- ******************** Testing: 0.. FAIL: Clang :: CXX/class/class.compare/class.eq/p2.cpp (6242 of 64222) ******************** TEST 'Clang :: CXX/class/class.compare/class.eq/p2.cpp' FAILED ******************** Script: -- : 'RUN: at line 1'; /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp -- Exit Code: 134 Command Output (stderr): -- clang: /home/dave/s/lp/clang/lib/Basic/SourceManager.cpp:917: clang::FileID clang::SourceManager::getFileIDLoaded(unsigned int) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp 1. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp:47:30: current parser token ')' 2. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp:30:13: parsing function body 'test' 3. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp:30:13: in compound statement ('{}') #0 0x000000000359273f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/_update_lc/t/bin/clang+0x359273f) #1 0x0000000003590912 llvm::sys::RunSignalHandlers() (/tmp/_update_lc/t/bin/clang+0x3590912) #2 0x0000000003592bb5 SignalHandler(int) (/tmp/_update_lc/t/bin/clang+0x3592bb5) #3 0x00007ffff7fa6a90 __restore_rt (/lib64/libpthread.so.0+0x14a90) #4 0x00007ffff7b3da25 raise (/lib64/libc.so.6+0x3ca25) #5 0x00007ffff7b26895 abort (/lib64/libc.so.6+0x25895) #6 0x00007ffff7b26769 _nl_load_domain.cold (/lib64/libc.so.6+0x25769) #7 0x00007ffff7b35e86 (/lib64/libc.so.6+0x34e86) #8 0x000000000375636c clang::SourceManager::getFileIDLoaded(unsigned int) const (/tmp/_update_lc/t/bin/clang+0x375636c) #9 0x0000000003ee0bbb clang::VerifyDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/tmp/_update_lc/t/bin/clang+0x3ee0bbb) #10 0x00000000037501ab clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/tmp/_update_lc/t/bin/clang+0x37501ab) #11 0x0000000003749fca clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/tmp/_update_lc/t/bin/clang+0x3749fca) #12 0x0000000004df0c60 clang::Sema::EmitCurrentDiagnostic(unsigned int) (/tmp/_update_lc/t/bin/clang+0x4df0c60) #13 0x00000000050928b7 (anonymous namespace)::DefaultedComparisonAnalyzer::visitBinaryOperator(clang::OverloadedOperatorKind, llvm::ArrayRef, (anonymous namespace)::DefaultedComparisonSubobject, clang::OverloadCandidateSet*) (/tmp/_update_lc/t/bin/clang+0x50928b7) #14 0x0000000005091dba (anonymous namespace)::DefaultedComparisonAnalyzer::visitExpandedSubobject(clang::QualType, (anonymous namespace)::DefaultedComparisonSubobject) (/tmp/_update_lc/t/bin/clang+0x5091dba) #15 0x0000000005091b86 (anonymous namespace)::DefaultedComparisonVisitor<(anonymous namespace)::DefaultedComparisonAnalyzer, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonSubobject>::visitSubobjects((anonymous namespace)::DefaultedComparisonInfo&, clang::CXXRecordDecl*, clang::Qualifiers) (/tmp/_update_lc/t/bin/clang+0x5091b86) #16 0x0000000005058c8c (anonymous namespace)::DefaultedComparisonAnalyzer::visit() (/tmp/_update_lc/t/bin/clang+0x5058c8c) #17 0x000000000505ab22 clang::Sema::DiagnoseDeletedDefaultedFunction(clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x505ab22) #18 0x00000000053e60ed clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x53e60ed) #19 0x000000000514270a BuildOverloadedBinOp(clang::Sema&, clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x514270a) #20 0x00000000050fbf49 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x50fbf49) #21 0x0000000004d52ccc clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult, clang::prec::Level) (/tmp/_update_lc/t/bin/clang+0x4d52ccc) #22 0x0000000004d51be9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51be9) #23 0x0000000004d60dba clang::Parser::ParseExpressionList(llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, llvm::function_ref) (/tmp/_update_lc/t/bin/clang+0x4d60dba) #24 0x0000000004d4b29c clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&) (/tmp/_update_lc/t/bin/clang+0x4d4b29c) #25 0x0000000004d57617 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/tmp/_update_lc/t/bin/clang+0x4d57617) #26 0x0000000004d51b89 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51b89) #27 0x0000000004d51ac9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51ac9) #28 0x0000000004d78368 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/tmp/_update_lc/t/bin/clang+0x4d78368) #29 0x0000000004d76ba0 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/tmp/_update_lc/t/bin/clang+0x4d76ba0) #30 0x0000000004d76614 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/tmp/_update_lc/t/bin/clang+0x4d76614) #31 0x0000000004d7ecd2 clang::Parser::ParseCompoundStatementBody(bool) (/tmp/_update_lc/t/bin/clang+0x4d7ecd2) #32 0x0000000004d7fcd0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/tmp/_update_lc/t/bin/clang+0x4d7fcd0) #33 0x0000000004cfacc0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/tmp/_update_lc/t/bin/clang+0x4cfacc0) #34 0x0000000004d28f2d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/tmp/_update_lc/t/bin/clang+0x4d28f2d) #35 0x0000000004cf9f32 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9f32) #36 0x0000000004cf9938 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9938) #37 0x0000000004cf86fc clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/tmp/_update_lc/t/bin/clang+0x4cf86fc) #38 0x0000000004cf6858 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) (/tmp/_update_lc/t/bin/clang+0x4cf6858) #39 0x0000000004cf16ed clang::ParseAST(clang::Sema&, bool, bool) (/tmp/_update_lc/t/bin/clang+0x4cf16ed) #40 0x0000000003e3eb21 clang::FrontendAction::Execute() (/tmp/_update_lc/t/bin/clang+0x3e3eb21) #41 0x0000000003dba0e3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/tmp/_update_lc/t/bin/clang+0x3dba0e3) #42 0x0000000003ee796b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/tmp/_update_lc/t/bin/clang+0x3ee796b) #43 0x0000000002244636 cc1_main(llvm::ArrayRef, char const*, void*) (/tmp/_update_lc/t/bin/clang+0x2244636) #44 0x000000000224297d ExecuteCC1Tool(llvm::SmallVectorImpl&) (/tmp/_update_lc/t/bin/clang+0x224297d) #45 0x0000000002242619 main (/tmp/_update_lc/t/bin/clang+0x2242619) #46 0x00007ffff7b28042 __libc_start_main (/lib64/libc.so.6+0x27042) #47 0x000000000223f8ce _start (/tmp/_update_lc/t/bin/clang+0x223f8ce) /tmp/_update_lc/t/tools/clang/test/CXX/class/class.compare/class.eq/Output/p2.cpp.script: line 1: 4146047 Aborted /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp -- ******************** Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. ******************** Failed Tests (2): Clang :: CXX/class/class.compare/class.eq/p2.cpp Clang :: CXX/class/class.compare/class.spaceship/p1.cpp Testing Time: 117.51s Unsupported : 12906 Passed : 51214 Expectedly Failed: 100 Failed : 2 FAILED: CMakeFiles/check-all cd /tmp/_update_lc/t && /usr/bin/python3.8 /tmp/_update_lc/t/./bin/llvm-lit -sv --param USE_Z3_SOLVER=0 /tmp/_update_lc/t/tools/clang/test /tmp/_update_lc/t/tools/lld/test /tmp/_update_lc/t/tools/lldb/test /tmp/_update_lc/t/utils/lit /tmp/_update_lc/t/test ninja: build stopped: subcommand failed. + do_error 'FAILURE -- STAGE TWO BUILD of LLVM' 12 + echo FAILURE -- STAGE TWO BUILD of LLVM FAILURE -- STAGE TWO BUILD of LLVM + exit 12 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82085/new/ https://reviews.llvm.org/D82085 From cfe-commits at lists.llvm.org Sun Jul 12 05:34:52 2020 From: cfe-commits at lists.llvm.org (Marek Kurdej via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 12:34:52 +0000 (UTC) Subject: [PATCH] D83564: [clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack In-Reply-To: References: Message-ID: <74d87e6829a5aa58db008629c7cba37f@localhost.localdomain> curdeius accepted this revision. curdeius added a comment. This revision is now accepted and ready to land. LGTM! Thanks for fixing this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83564/new/ https://reviews.llvm.org/D83564 From cfe-commits at lists.llvm.org Sun Jul 12 06:09:54 2020 From: cfe-commits at lists.llvm.org (Yaxun Liu via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 13:09:54 +0000 (UTC) Subject: [PATCH] D82087: AMDGPU/clang: Add builtins for llvm.amdgcn.ballot In-Reply-To: References: Message-ID: yaxunl added a comment. In D82087#2146170 , @sameerds wrote: > >> https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md#warp-vote-and-ballot-functions > > > > I think if the language interface insists on fixing the wave size, then I think the correct solution is to implement this in the header based on a wave size macro (which we're desperately missing). The library implementation should be responsible for inserting the extension to 64-bit for wave32 Agree that FE should have a predefined macro for wave front size. Since it is per amdgpu target and not per language, it should be named as __amdgpu_wavefront_size__ or something similar, then it could be used by all languages. Then we need to initialize warpSize in HIP header by this macro https://github.com/ROCm-Developer-Tools/HIP/blob/386a0e0123d67b95b4c0ebb3ebcf1d1615758146/include/hip/hcc_detail/device_functions.h#L300 I tends to think we should define __ballot in HIP header conditionally by the wavefront size so that the return type is correct for both wave32 and wave64 mode. We should assume normal HIP compilation always have -mcpu specified so that wavefront size is known at compile time. If -mcpu is not specified probably we should not define warpSize or __ballot. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82087/new/ https://reviews.llvm.org/D82087 From cfe-commits at lists.llvm.org Sun Jul 12 10:44:40 2020 From: cfe-commits at lists.llvm.org (via cfe-commits) Date: Sun, 12 Jul 2020 10:44:40 -0700 (PDT) Subject: [clang] 65dc97b - [clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack Message-ID: <5f0b4c08.1c69fb81.692b4.a615@mx.google.com> Author: mydeveloperday Date: 2020-07-12T18:44:26+01:00 New Revision: 65dc97b79eb1979c54e7e17c411ea5f58f8dcc9c URL: https://github.com/llvm/llvm-project/commit/65dc97b79eb1979c54e7e17c411ea5f58f8dcc9c DIFF: https://github.com/llvm/llvm-project/commit/65dc97b79eb1979c54e7e17c411ea5f58f8dcc9c.diff LOG: [clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack Summary: https://bugs.llvm.org/show_bug.cgi?id=46609 Ensure `*...` obey they left/middle/right rules of Pointer alignment Reviewed By: curdeius Differential Revision: https://reviews.llvm.org/D83564 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index a74015d3b4dc..7f8e35126512 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2844,6 +2844,11 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, Left.Previous && !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon, tok::l_square)); + // Ensure right pointer alignement with ellipsis e.g. int *...P + if (Left.is(tok::ellipsis) && Left.Previous && + Left.Previous->isOneOf(tok::star, tok::amp, tok::ampamp)) + return Style.PointerAlignment != FormatStyle::PAS_Right; + if (Right.is(tok::star) && Left.is(tok::l_paren)) return false; if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp)) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index ff9a64e81d5b..6ac3ffbffd1c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5325,7 +5325,7 @@ TEST_F(FormatTest, DeductionGuides) { verifyFormat("template S(Ts...) -> S;"); verifyFormat( "template \n" - "array(T &&... t) -> array, sizeof...(T)>;"); + "array(T &&...t) -> array, sizeof...(T)>;"); verifyFormat("template A() -> Afoo<3>())>;"); verifyFormat("template A() -> A>)>;"); verifyFormat("template A() -> Afoo<1>)>;"); @@ -8179,13 +8179,20 @@ TEST_F(FormatTest, AttributePenaltyBreaking) { } TEST_F(FormatTest, UnderstandsEllipsis) { + FormatStyle Style = getLLVMStyle(); verifyFormat("int printf(const char *fmt, ...);"); verifyFormat("template void Foo(Ts... ts) { Foo(ts...); }"); - verifyFormat("template void Foo(Ts *... ts) {}"); + verifyFormat("template void Foo(Ts *...ts) {}"); + + verifyFormat("template a;", Style); + + Style.PointerAlignment = FormatStyle::PAS_Left; + verifyFormat("template void Foo(Ts*... ts) {}", Style); + + verifyFormat("template a;", Style); - FormatStyle PointersLeft = getLLVMStyle(); - PointersLeft.PointerAlignment = FormatStyle::PAS_Left; - verifyFormat("template void Foo(Ts*... ts) {}", PointersLeft); + Style.PointerAlignment = FormatStyle::PAS_Middle; + verifyFormat("template a;", Style); } TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) { From cfe-commits at lists.llvm.org Sun Jul 12 10:44:52 2020 From: cfe-commits at lists.llvm.org (MyDeveloperDay via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 17:44:52 +0000 (UTC) Subject: [PATCH] D83564: [clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for ellipsis in declarator for pack In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG65dc97b79eb1: [clang-format] PR46609 clang-format does not obey `PointerAlignment: Right` for… (authored by MyDeveloperDay). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83564/new/ https://reviews.llvm.org/D83564 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -5325,7 +5325,7 @@ verifyFormat("template S(Ts...) -> S;"); verifyFormat( "template \n" - "array(T &&... t) -> array, sizeof...(T)>;"); + "array(T &&...t) -> array, sizeof...(T)>;"); verifyFormat("template A() -> Afoo<3>())>;"); verifyFormat("template A() -> A>)>;"); verifyFormat("template A() -> Afoo<1>)>;"); @@ -8179,13 +8179,20 @@ } TEST_F(FormatTest, UnderstandsEllipsis) { + FormatStyle Style = getLLVMStyle(); verifyFormat("int printf(const char *fmt, ...);"); verifyFormat("template void Foo(Ts... ts) { Foo(ts...); }"); - verifyFormat("template void Foo(Ts *... ts) {}"); + verifyFormat("template void Foo(Ts *...ts) {}"); + + verifyFormat("template a;", Style); + + Style.PointerAlignment = FormatStyle::PAS_Left; + verifyFormat("template void Foo(Ts*... ts) {}", Style); + + verifyFormat("template a;", Style); - FormatStyle PointersLeft = getLLVMStyle(); - PointersLeft.PointerAlignment = FormatStyle::PAS_Left; - verifyFormat("template void Foo(Ts*... ts) {}", PointersLeft); + Style.PointerAlignment = FormatStyle::PAS_Middle; + verifyFormat("template a;", Style); } TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -2844,6 +2844,11 @@ Left.Previous && !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon, tok::l_square)); + // Ensure right pointer alignement with ellipsis e.g. int *...P + if (Left.is(tok::ellipsis) && Left.Previous && + Left.Previous->isOneOf(tok::star, tok::amp, tok::ampamp)) + return Style.PointerAlignment != FormatStyle::PAS_Right; + if (Right.is(tok::star) && Left.is(tok::l_paren)) return false; if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp)) -------------- next part -------------- A non-text attachment was scrubbed... Name: D83564.277296.patch Type: text/x-patch Size: 2435 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 11:36:27 2020 From: cfe-commits at lists.llvm.org (Dimitry Andric via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 18:36:27 +0000 (UTC) Subject: [PATCH] D83645: Bump the default target CPU for i386-freebsd to i686 Message-ID: dim created this revision. dim added reviewers: emaste, brooks, rsmith. Herald added subscribers: jfb, krytarowski, arichardson. Herald added a project: clang. Similar to what we have done downstream, some time ago: https://svnweb.freebsd.org/changeset/base/353936 This followed some discussions on the freebsd-arch mailing lists, and most people agreed that it was a better default, and also it worked around several issues where clang generated libcalls to 64 bit atomic primitives, instead of using cmpxchg8b. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83645 Files: clang/lib/Driver/ToolChains/Arch/X86.cpp Index: clang/lib/Driver/ToolChains/Arch/X86.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/X86.cpp +++ clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -94,6 +94,7 @@ switch (Triple.getOS()) { case llvm::Triple::FreeBSD: + return "i686"; case llvm::Triple::NetBSD: case llvm::Triple::OpenBSD: return "i486"; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83645.277301.patch Type: text/x-patch Size: 387 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 12:50:10 2020 From: cfe-commits at lists.llvm.org (Ed Maste via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 19:50:10 +0000 (UTC) Subject: [PATCH] D83645: Bump the default target CPU for i386-freebsd to i686 In-Reply-To: References: Message-ID: emaste accepted this revision. emaste added a comment. This revision is now accepted and ready to land. Fine with me Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83645/new/ https://reviews.llvm.org/D83645 From cfe-commits at lists.llvm.org Sun Jul 12 14:11:13 2020 From: cfe-commits at lists.llvm.org (Richard Smith - zygoloid via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 21:11:13 +0000 (UTC) Subject: [PATCH] D83647: Don't allow mangling substitutions to refer to unrelated entities from different s. Message-ID: rsmith created this revision. rsmith added a reviewer: rjmccall. Herald added a project: clang. Herald added a subscriber: cfe-commits. Per the ABI rules, substitutable components are symbolic constructs, not the associated mangling character strings, so references to function parameters or template parameters of distinct s should not be considered substitutable even if they're at the same depth / index. See https://github.com/itanium-cxx-abi/cxx-abi/issues/106. This change can be turned off by setting -fclang-abi-compat to 10 or earlier. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83647 Files: clang/include/clang/Basic/LangOptions.h clang/lib/AST/ItaniumMangle.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGenCXX/mangle-abi-tag.cpp clang/test/CodeGenCXX/mangle-local-substitutions.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83647.277303.patch Type: text/x-patch Size: 17864 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 14:45:36 2020 From: cfe-commits at lists.llvm.org (Dimitry Andric via cfe-commits) Date: Sun, 12 Jul 2020 14:45:36 -0700 (PDT) Subject: [clang] 02cfa75 - Bump the default target CPU for i386-freebsd to i686 Message-ID: <5f0b8480.1c69fb81.cc080.ec92@mx.google.com> Author: Dimitry Andric Date: 2020-07-12T23:45:22+02:00 New Revision: 02cfa7530d9e7cfd8ea940dab4173afb7938b831 URL: https://github.com/llvm/llvm-project/commit/02cfa7530d9e7cfd8ea940dab4173afb7938b831 DIFF: https://github.com/llvm/llvm-project/commit/02cfa7530d9e7cfd8ea940dab4173afb7938b831.diff LOG: Bump the default target CPU for i386-freebsd to i686 Summary: Similar to what we have done downstream, some time ago: https://svnweb.freebsd.org/changeset/base/353936 This followed some discussions on the freebsd-arch mailing lists, and most people agreed that it was a better default, and also it worked around several issues where clang generated libcalls to 64 bit atomic primitives, instead of using cmpxchg8b. Reviewers: emaste, brooks, rsmith Reviewed By: emaste Subscribers: arichardson, krytarowski, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83645 Added: Modified: clang/lib/Driver/ToolChains/Arch/X86.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index aa95c4189d1e..2cc44c09917f 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -94,6 +94,7 @@ const char *x86::getX86TargetCPU(const ArgList &Args, switch (Triple.getOS()) { case llvm::Triple::FreeBSD: + return "i686"; case llvm::Triple::NetBSD: case llvm::Triple::OpenBSD: return "i486"; From cfe-commits at lists.llvm.org Sun Jul 12 14:45:38 2020 From: cfe-commits at lists.llvm.org (Dimitry Andric via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 21:45:38 +0000 (UTC) Subject: [PATCH] D83645: Bump the default target CPU for i386-freebsd to i686 In-Reply-To: References: Message-ID: <21abe604ea83ded80e0e245b41fae99f@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG02cfa7530d9e: Bump the default target CPU for i386-freebsd to i686 (authored by dim). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83645/new/ https://reviews.llvm.org/D83645 Files: clang/lib/Driver/ToolChains/Arch/X86.cpp Index: clang/lib/Driver/ToolChains/Arch/X86.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/X86.cpp +++ clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -94,6 +94,7 @@ switch (Triple.getOS()) { case llvm::Triple::FreeBSD: + return "i686"; case llvm::Triple::NetBSD: case llvm::Triple::OpenBSD: return "i486"; -------------- next part -------------- A non-text attachment was scrubbed... Name: D83645.277305.patch Type: text/x-patch Size: 387 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 15:14:49 2020 From: cfe-commits at lists.llvm.org (Logan Smith via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 22:14:49 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: <4bb36eef9b2ffce119dfd33efc7364d2@localhost.localdomain> logan-5 added a comment. In D82728#2146067 , @dblaikie wrote: > Looks good - thanks for the patch and all the details! Might be worth turning on by default in the LLVM build (after all the cleanup) Thanks a lot! I don't (think I) have commit access yada yada, so I'd really appreciate any help getting this committed. I've already got some of the cleanup in the works (D83611 and D83616 ), and was planning on taking care of the rest throughout the coming weekish. I'd be happy to turn this warning on in the LLVM build after that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 From cfe-commits at lists.llvm.org Sun Jul 12 15:29:48 2020 From: cfe-commits at lists.llvm.org (Ulrich Weigand via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 22:29:48 +0000 (UTC) Subject: [PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record In-Reply-To: References: Message-ID: uweigand added a comment. In D80833#2123508 , @aganea wrote: > In D80833#2109172 , @uweigand wrote: > > > Hmm, with clang-cl it seems the driver is trying to use this: > > Target: s390x-pc-windows-msvc > > which of course doesn't exist. Not sure what is supposed to be happening here, but it seems that it's falling back on s390x-linux since on s390x, Linux is currently the only supported OS. > > > I'm seeing some of the tests are setting the target explicitly `%clang_cl --target=x86_64-windows-msvc`. Would that work on your machine? Or should I do `UNSUPPORTED: s390x` ? Sorry, looks like I missed this. I think using an explicit target should work. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D80833/new/ https://reviews.llvm.org/D80833 From cfe-commits at lists.llvm.org Sun Jul 12 16:00:31 2020 From: cfe-commits at lists.llvm.org (Richard Smith - zygoloid via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 23:00:31 +0000 (UTC) Subject: [PATCH] D83647: Don't allow mangling substitutions to refer to unrelated entities from different s. In-Reply-To: References: Message-ID: rsmith added a comment. Hm, I think this is not quite right. For example, given: template struct X {}; template auto f(T a, decltype(a)) { struct A {}; struct B {}; return X(); } decltype(f(0, 0)) g() {} ... I think we won't use a substitution from the first parameter of `f` in the second back to the first parameter of `f` in the first . Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83647/new/ https://reviews.llvm.org/D83647 From cfe-commits at lists.llvm.org Sun Jul 12 16:05:31 2020 From: cfe-commits at lists.llvm.org (David Blaikie via cfe-commits) Date: Sun, 12 Jul 2020 16:05:31 -0700 (PDT) Subject: [clang] 1111678 - [clang] Add -Wsuggest-override Message-ID: <5f0b973b.1c69fb81.6518c.c91c@mx.google.com> Author: Logan Smith Date: 2020-07-12T16:05:24-07:00 New Revision: 111167895d47558989f9f3a593a82527b016c7e7 URL: https://github.com/llvm/llvm-project/commit/111167895d47558989f9f3a593a82527b016c7e7 DIFF: https://github.com/llvm/llvm-project/commit/111167895d47558989f9f3a593a82527b016c7e7.diff LOG: [clang] Add -Wsuggest-override This patch adds `-Wsuggest-override`, which allows for more aggressive enforcement of modern C++ best practices, as well as better compatibility with gcc, which has had its own `-Wsuggest-override` since version 5.1. Clang already has `-Winconsistent-missing-override`, which only warns in the case where there is at least one function already marked `override` in a class. This warning strengthens that warning by suggesting the `override` keyword regardless of whether it is already present anywhere. The text between suggest-override and inconsistent-missing-override is now shared, using `TextSubstitution` for the entire diagnostic text. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D82728 Added: clang/test/SemaCXX/warn-suggest-destructor-override clang/test/SemaCXX/warn-suggest-override Modified: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaDeclCXX.cpp Removed: ################################################################################ diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 6a50ceef4191..1e829be4028e 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -280,9 +280,12 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic", def CXX11Narrowing : DiagGroup<"c++11-narrowing">; -def CXX11WarnOverrideDestructor : +def CXX11WarnInconsistentOverrideDestructor : DiagGroup<"inconsistent-missing-destructor-override">; -def CXX11WarnOverrideMethod : DiagGroup<"inconsistent-missing-override">; +def CXX11WarnInconsistentOverrideMethod : + DiagGroup<"inconsistent-missing-override">; +def CXX11WarnSuggestOverrideDestructor : DiagGroup<"suggest-destructor-override">; +def CXX11WarnSuggestOverride : DiagGroup<"suggest-override">; // Original name of this warning in Clang def : DiagGroup<"c++0x-narrowing", [CXX11Narrowing]>; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 24e942037ecf..71517edd6659 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2367,12 +2367,22 @@ def override_keyword_hides_virtual_member_function : Error< "%select{function|functions}1">; def err_function_marked_override_not_overriding : Error< "%0 marked 'override' but does not override any member functions">; -def warn_destructor_marked_not_override_overriding : Warning < - "%0 overrides a destructor but is not marked 'override'">, - InGroup, DefaultIgnore; -def warn_function_marked_not_override_overriding : Warning < - "%0 overrides a member function but is not marked 'override'">, - InGroup; +def warn_destructor_marked_not_override_overriding : TextSubstitution < + "%0 overrides a destructor but is not marked 'override'">; +def warn_function_marked_not_override_overriding : TextSubstitution < + "%0 overrides a member function but is not marked 'override'">; +def warn_inconsistent_destructor_marked_not_override_overriding : Warning < + "%sub{warn_destructor_marked_not_override_overriding}0">, + InGroup, DefaultIgnore; +def warn_inconsistent_function_marked_not_override_overriding : Warning < + "%sub{warn_function_marked_not_override_overriding}0">, + InGroup; +def warn_suggest_destructor_marked_not_override_overriding : Warning < + "%sub{warn_destructor_marked_not_override_overriding}0">, + InGroup, DefaultIgnore; +def warn_suggest_function_marked_not_override_overriding : Warning < + "%sub{warn_function_marked_not_override_overriding}0">, + InGroup, DefaultIgnore; def err_class_marked_final_used_as_base : Error< "base %0 is marked '%select{final|sealed}1'">; def warn_abstract_final_class : Warning< diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index e75ac185eb2c..6f7ad8076718 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -6965,7 +6965,7 @@ class Sema final { /// DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was /// not used in the declaration of an overriding method. - void DiagnoseAbsenceOfOverrideControl(NamedDecl *D); + void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent); /// CheckForFunctionMarkedFinal - Checks whether a virtual member function /// overrides a virtual member function marked 'final', according to diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 9cad6debc600..515a2e9690ed 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3045,7 +3045,7 @@ void Sema::CheckOverrideControl(NamedDecl *D) { << MD->getDeclName(); } -void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) { +void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) { if (D->isInvalidDecl() || D->hasAttr()) return; CXXMethodDecl *MD = dyn_cast(D); @@ -3061,12 +3061,22 @@ void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) { return; if (MD->size_overridden_methods() > 0) { - unsigned DiagID = isa(MD) - ? diag::warn_destructor_marked_not_override_overriding - : diag::warn_function_marked_not_override_overriding; - Diag(MD->getLocation(), DiagID) << MD->getDeclName(); - const CXXMethodDecl *OMD = *MD->begin_overridden_methods(); - Diag(OMD->getLocation(), diag::note_overridden_virtual_function); + auto EmitDiag = [&](unsigned DiagInconsistent, unsigned DiagSuggest) { + unsigned DiagID = + Inconsistent && !Diags.isIgnored(DiagInconsistent, MD->getLocation()) + ? DiagInconsistent + : DiagSuggest; + Diag(MD->getLocation(), DiagID) << MD->getDeclName(); + const CXXMethodDecl *OMD = *MD->begin_overridden_methods(); + Diag(OMD->getLocation(), diag::note_overridden_virtual_function); + }; + if (isa(MD)) + EmitDiag( + diag::warn_inconsistent_destructor_marked_not_override_overriding, + diag::warn_suggest_destructor_marked_not_override_overriding); + else + EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding, + diag::warn_suggest_function_marked_not_override_overriding); } } @@ -6749,13 +6759,10 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { } } - if (HasMethodWithOverrideControl && - HasOverridingMethodWithoutOverrideControl) { - // At least one method has the 'override' control declared. - // Diagnose all other overridden methods which do not have 'override' - // specified on them. + if (HasOverridingMethodWithoutOverrideControl) { + bool HasInconsistentOverrideControl = HasMethodWithOverrideControl; for (auto *M : Record->methods()) - DiagnoseAbsenceOfOverrideControl(M); + DiagnoseAbsenceOfOverrideControl(M, HasInconsistentOverrideControl); } // Check the defaulted secondary comparisons after any other member functions. diff --git a/clang/test/SemaCXX/warn-suggest-destructor-override b/clang/test/SemaCXX/warn-suggest-destructor-override new file mode 100644 index 000000000000..1cfff748678f --- /dev/null +++ b/clang/test/SemaCXX/warn-suggest-destructor-override @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override + +struct A { + ~A(); + virtual void run(); +}; + +struct B : public A { + ~B(); +}; + +struct C { + virtual void run(); + virtual ~C(); // expected-note 2{{overridden virtual function is here}} +}; + +struct D : public C { + void run(); + ~D(); + // expected-warning at -1 {{'~D' overrides a destructor but is not marked 'override'}} +}; + +struct E : public C { + void run(); + virtual ~E(); + // expected-warning at -1 {{'~E' overrides a destructor but is not marked 'override'}} +}; diff --git a/clang/test/SemaCXX/warn-suggest-override b/clang/test/SemaCXX/warn-suggest-override new file mode 100644 index 000000000000..e06c939ff001 --- /dev/null +++ b/clang/test/SemaCXX/warn-suggest-override @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override + +struct A { + ~A(); + void run(); +}; + +struct B : public A { + ~B(); + void run(); +}; + +struct C { + virtual void run(); // expected-note 2{{overridden virtual function is here}} + virtual ~C(); +}; + +struct D : public C { + void run(); + // expected-warning at -1 {{'run()' overrides a member function but is not marked 'override'}} + ~D(); +}; + +struct E : public C { + virtual void run(); + // expected-warning at -1 {{'run()' overrides a member function but is not marked 'override'}} + virtual ~E(); +}; + +struct F : public C { + void run() override; + ~F() override; +}; + +struct G : public C { + void run() final; + ~G() final; +}; From cfe-commits at lists.llvm.org Sun Jul 12 16:05:37 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 23:05:37 +0000 (UTC) Subject: [PATCH] D82728: [clang] Add -Wsuggest-override In-Reply-To: References: Message-ID: This revision was automatically updated to reflect the committed changes. Closed by commit rG111167895d47: [clang] Add -Wsuggest-override (authored by logan-5, committed by dblaikie). Changed prior to commit: https://reviews.llvm.org/D82728?vs=276248&id=277308#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D82728/new/ https://reviews.llvm.org/D82728 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/warn-suggest-destructor-override clang/test/SemaCXX/warn-suggest-override -------------- next part -------------- A non-text attachment was scrubbed... Name: D82728.277308.patch Type: text/x-patch Size: 7636 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 16:17:20 2020 From: cfe-commits at lists.llvm.org (Pengxuan Zheng via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 23:17:20 +0000 (UTC) Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption Message-ID: pzheng created this revision. pzheng added reviewers: MaskRay, dblaikie, echristo. Herald added subscribers: cfe-commits, dang. Herald added a project: clang. DriverOption seems to be accidentally removed from integrated_as definition in commit e5158b5 . Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83648 Files: clang/include/clang/Driver/Options.td Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2887,7 +2887,7 @@ MetaVarName<"">; def y : Joined<["-"], "y">; -defm integrated_as : OptOutFFlag<"integrated-as", "Enable the integrated assembler", "Disable the integrated assembler">; +defm integrated_as : OptOutFFlag<"integrated-as", "Enable", "Disable", " the integrated assembler", [DriverOption]>; def fintegrated_cc1 : Flag<["-"], "fintegrated-cc1">, Flags<[CoreOption, DriverOption]>, Group, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83648.277309.patch Type: text/x-patch Size: 652 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 16:27:42 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Sun, 12 Jul 2020 23:27:42 +0000 (UTC) Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption In-Reply-To: References: Message-ID: dblaikie added a comment. Is there missing test coverage for this in some way? (how does this patch change the observable behavior of clang? I guess --help would change?) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83648/new/ https://reviews.llvm.org/D83648 From cfe-commits at lists.llvm.org Sun Jul 12 17:20:05 2020 From: cfe-commits at lists.llvm.org (Craig Topper via cfe-commits) Date: Sun, 12 Jul 2020 17:20:05 -0700 (PDT) Subject: [clang] b4dbb37 - [X86] Rename X86_CPU_TYPE_COMPAT_ALIAS/X86_CPU_TYPE_COMPAT/X86_CPU_SUBTYPE_COMPAT macros. NFC Message-ID: <5f0ba8b5.1c69fb81.e313.dff2@mx.google.com> Author: Craig Topper Date: 2020-07-12T17:00:24-07:00 New Revision: b4dbb37f32e554e4d6f118d9ddd87717721ea664 URL: https://github.com/llvm/llvm-project/commit/b4dbb37f32e554e4d6f118d9ddd87717721ea664 DIFF: https://github.com/llvm/llvm-project/commit/b4dbb37f32e554e4d6f118d9ddd87717721ea664.diff LOG: [X86] Rename X86_CPU_TYPE_COMPAT_ALIAS/X86_CPU_TYPE_COMPAT/X86_CPU_SUBTYPE_COMPAT macros. NFC Remove _COMPAT. Drop the ARCHNAME. Remove the non-COMPAT versions that are no longer needed. We now only use these macros in places where we need compatibility with libgcc/compiler-rt. So we don't need to call out _COMPAT specifically. Added: Modified: clang/lib/Basic/Targets/X86.cpp clang/lib/CodeGen/CGBuiltin.cpp llvm/include/llvm/Support/X86TargetParser.def llvm/include/llvm/Support/X86TargetParser.h Removed: ################################################################################ diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index e280a7216645..543f232d2459 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -1062,9 +1062,9 @@ void X86TargetInfo::getCPUSpecificCPUDispatchFeatures( bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) const { return llvm::StringSwitch(FeatureStr) #define X86_VENDOR(ENUM, STRING) .Case(STRING, true) -#define X86_CPU_TYPE_COMPAT_ALIAS(ENUM, ALIAS) .Case(ALIAS, true) -#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true) -#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true) +#define X86_CPU_TYPE_ALIAS(ENUM, ALIAS) .Case(ALIAS, true) +#define X86_CPU_TYPE(ENUM, STR) .Case(STR, true) +#define X86_CPU_SUBTYPE(ENUM, STR) .Case(STR, true) #include "llvm/Support/X86TargetParser.def" .Default(false); } diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 1d81ede5dc31..35a93a7889f4 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -11655,11 +11655,11 @@ Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) { std::tie(Index, Value) = StringSwitch>(CPUStr) #define X86_VENDOR(ENUM, STRING) \ .Case(STRING, {0u, static_cast(llvm::X86::ENUM)}) -#define X86_CPU_TYPE_COMPAT_ALIAS(ENUM, ALIAS) \ +#define X86_CPU_TYPE_ALIAS(ENUM, ALIAS) \ .Case(ALIAS, {1u, static_cast(llvm::X86::ENUM)}) -#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) \ +#define X86_CPU_TYPE(ENUM, STR) \ .Case(STR, {1u, static_cast(llvm::X86::ENUM)}) -#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) \ +#define X86_CPU_SUBTYPE(ENUM, STR) \ .Case(STR, {2u, static_cast(llvm::X86::ENUM)}) #include "llvm/Support/X86TargetParser.def" .Default({0, 0}); diff --git a/llvm/include/llvm/Support/X86TargetParser.def b/llvm/include/llvm/Support/X86TargetParser.def index 9e9f0985d15e..697f8c70f962 100644 --- a/llvm/include/llvm/Support/X86TargetParser.def +++ b/llvm/include/llvm/Support/X86TargetParser.def @@ -20,80 +20,70 @@ X86_VENDOR(VENDOR_AMD, "amd") #undef X86_VENDOR // This macro is used for cpu types present in compiler-rt/libgcc. -#ifndef X86_CPU_TYPE_COMPAT -#define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) X86_CPU_TYPE(ARCHNAME, ENUM) -#endif - #ifndef X86_CPU_TYPE -#define X86_CPU_TYPE(ARCHNAME, ENUM) +#define X86_CPU_TYPE(ENUM, STR) #endif -#ifndef X86_CPU_TYPE_COMPAT_ALIAS -#define X86_CPU_TYPE_COMPAT_ALIAS(ENUM, STR) +#ifndef X86_CPU_TYPE_ALIAS +#define X86_CPU_TYPE_ALIAS(ENUM, STR) #endif -// The first part of this list must match what is implemented in libgcc and -// compilert-rt. Clang uses this to know how to implement __builtin_cpu_is. -X86_CPU_TYPE_COMPAT("bonnell", INTEL_BONNELL, "bonnell") -X86_CPU_TYPE_COMPAT("core2", INTEL_CORE2, "core2") -X86_CPU_TYPE_COMPAT("nehalem", INTEL_COREI7, "corei7") -X86_CPU_TYPE_COMPAT("amdfam10", AMDFAM10H, "amdfam10h") -X86_CPU_TYPE_COMPAT("bdver1", AMDFAM15H, "amdfam15h") -X86_CPU_TYPE_COMPAT("silvermont", INTEL_SILVERMONT, "silvermont") -X86_CPU_TYPE_COMPAT("knl", INTEL_KNL, "knl") -X86_CPU_TYPE_COMPAT("btver1", AMD_BTVER1, "btver1") -X86_CPU_TYPE_COMPAT("btver2", AMD_BTVER2, "btver2") -X86_CPU_TYPE_COMPAT("znver1", AMDFAM17H, "amdfam17h") -X86_CPU_TYPE_COMPAT("knm", INTEL_KNM, "knm") -X86_CPU_TYPE_COMPAT("goldmont", INTEL_GOLDMONT, "goldmont") -X86_CPU_TYPE_COMPAT("goldmont-plus", INTEL_GOLDMONT_PLUS, "goldmont-plus") -X86_CPU_TYPE_COMPAT("tremont", INTEL_TREMONT, "tremont") +// This list must match what is implemented in libgcc and compilert-rt. Clang +// uses this to know how to implement __builtin_cpu_is. +X86_CPU_TYPE(INTEL_BONNELL, "bonnell") +X86_CPU_TYPE(INTEL_CORE2, "core2") +X86_CPU_TYPE(INTEL_COREI7, "corei7") +X86_CPU_TYPE(AMDFAM10H, "amdfam10h") +X86_CPU_TYPE(AMDFAM15H, "amdfam15h") +X86_CPU_TYPE(INTEL_SILVERMONT, "silvermont") +X86_CPU_TYPE(INTEL_KNL, "knl") +X86_CPU_TYPE(AMD_BTVER1, "btver1") +X86_CPU_TYPE(AMD_BTVER2, "btver2") +X86_CPU_TYPE(AMDFAM17H, "amdfam17h") +X86_CPU_TYPE(INTEL_KNM, "knm") +X86_CPU_TYPE(INTEL_GOLDMONT, "goldmont") +X86_CPU_TYPE(INTEL_GOLDMONT_PLUS, "goldmont-plus") +X86_CPU_TYPE(INTEL_TREMONT, "tremont") // Alternate names supported by __builtin_cpu_is and target multiversioning. -X86_CPU_TYPE_COMPAT_ALIAS(INTEL_BONNELL, "atom") -X86_CPU_TYPE_COMPAT_ALIAS(AMDFAM10H, "amdfam10") -X86_CPU_TYPE_COMPAT_ALIAS(AMDFAM15H, "amdfam15") -X86_CPU_TYPE_COMPAT_ALIAS(INTEL_SILVERMONT, "slm") +X86_CPU_TYPE_ALIAS(INTEL_BONNELL, "atom") +X86_CPU_TYPE_ALIAS(AMDFAM10H, "amdfam10") +X86_CPU_TYPE_ALIAS(AMDFAM15H, "amdfam15") +X86_CPU_TYPE_ALIAS(INTEL_SILVERMONT, "slm") -#undef X86_CPU_TYPE_COMPAT_ALIAS -#undef X86_CPU_TYPE_COMPAT +#undef X86_CPU_TYPE_ALIAS #undef X86_CPU_TYPE // This macro is used for cpu subtypes present in compiler-rt/libgcc. -#ifndef X86_CPU_SUBTYPE_COMPAT -#define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) X86_CPU_SUBTYPE(ARCHNAME, ENUM) -#endif - #ifndef X86_CPU_SUBTYPE -#define X86_CPU_SUBTYPE(ARCHNAME, ENUM) +#define X86_CPU_SUBTYPE(ENUM, STR) #endif -// The first part of this list must match what is implemented in libgcc and -// compilert-rt. Clang uses this to know how to implement __builtin_cpu_is. -X86_CPU_SUBTYPE_COMPAT("nehalem", INTEL_COREI7_NEHALEM, "nehalem") -X86_CPU_SUBTYPE_COMPAT("westmere", INTEL_COREI7_WESTMERE, "westmere") -X86_CPU_SUBTYPE_COMPAT("sandybridge", INTEL_COREI7_SANDYBRIDGE, "sandybridge") -X86_CPU_SUBTYPE_COMPAT("amdfam10", AMDFAM10H_BARCELONA, "barcelona") -X86_CPU_SUBTYPE_COMPAT("amdfam10", AMDFAM10H_SHANGHAI, "shanghai") -X86_CPU_SUBTYPE_COMPAT("amdfam10", AMDFAM10H_ISTANBUL, "istanbul") -X86_CPU_SUBTYPE_COMPAT("bdver1", AMDFAM15H_BDVER1, "bdver1") -X86_CPU_SUBTYPE_COMPAT("bdver2", AMDFAM15H_BDVER2, "bdver2") -X86_CPU_SUBTYPE_COMPAT("bdver3", AMDFAM15H_BDVER3, "bdver3") -X86_CPU_SUBTYPE_COMPAT("bdver4", AMDFAM15H_BDVER4, "bdver4") -X86_CPU_SUBTYPE_COMPAT("znver1", AMDFAM17H_ZNVER1, "znver1") -X86_CPU_SUBTYPE_COMPAT("ivybridge", INTEL_COREI7_IVYBRIDGE, "ivybridge") -X86_CPU_SUBTYPE_COMPAT("haswell", INTEL_COREI7_HASWELL, "haswell") -X86_CPU_SUBTYPE_COMPAT("broadwell", INTEL_COREI7_BROADWELL, "broadwell") -X86_CPU_SUBTYPE_COMPAT("skylake", INTEL_COREI7_SKYLAKE, "skylake") -X86_CPU_SUBTYPE_COMPAT("skylake-avx512", INTEL_COREI7_SKYLAKE_AVX512, "skylake-avx512") -X86_CPU_SUBTYPE_COMPAT("cannonlake", INTEL_COREI7_CANNONLAKE, "cannonlake") -X86_CPU_SUBTYPE_COMPAT("icelake-client", INTEL_COREI7_ICELAKE_CLIENT, "icelake-client") -X86_CPU_SUBTYPE_COMPAT("icelake-server", INTEL_COREI7_ICELAKE_SERVER, "icelake-server") -X86_CPU_SUBTYPE_COMPAT("znver2", AMDFAM17H_ZNVER2, "znver2") -X86_CPU_SUBTYPE_COMPAT("cascadelake", INTEL_COREI7_CASCADELAKE, "cascadelake") -X86_CPU_SUBTYPE_COMPAT("tigerlake", INTEL_COREI7_TIGERLAKE, "tigerlake") -X86_CPU_SUBTYPE_COMPAT("cooperlake", INTEL_COREI7_COOPERLAKE, "cooperlake") -#undef X86_CPU_SUBTYPE_COMPAT +// This list must match what is implemented in libgcc and compilert-rt. Clang +// uses this to know how to implement __builtin_cpu_is. +X86_CPU_SUBTYPE(INTEL_COREI7_NEHALEM, "nehalem") +X86_CPU_SUBTYPE(INTEL_COREI7_WESTMERE, "westmere") +X86_CPU_SUBTYPE(INTEL_COREI7_SANDYBRIDGE, "sandybridge") +X86_CPU_SUBTYPE(AMDFAM10H_BARCELONA, "barcelona") +X86_CPU_SUBTYPE(AMDFAM10H_SHANGHAI, "shanghai") +X86_CPU_SUBTYPE(AMDFAM10H_ISTANBUL, "istanbul") +X86_CPU_SUBTYPE(AMDFAM15H_BDVER1, "bdver1") +X86_CPU_SUBTYPE(AMDFAM15H_BDVER2, "bdver2") +X86_CPU_SUBTYPE(AMDFAM15H_BDVER3, "bdver3") +X86_CPU_SUBTYPE(AMDFAM15H_BDVER4, "bdver4") +X86_CPU_SUBTYPE(AMDFAM17H_ZNVER1, "znver1") +X86_CPU_SUBTYPE(INTEL_COREI7_IVYBRIDGE, "ivybridge") +X86_CPU_SUBTYPE(INTEL_COREI7_HASWELL, "haswell") +X86_CPU_SUBTYPE(INTEL_COREI7_BROADWELL, "broadwell") +X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE, "skylake") +X86_CPU_SUBTYPE(INTEL_COREI7_SKYLAKE_AVX512, "skylake-avx512") +X86_CPU_SUBTYPE(INTEL_COREI7_CANNONLAKE, "cannonlake") +X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_CLIENT, "icelake-client") +X86_CPU_SUBTYPE(INTEL_COREI7_ICELAKE_SERVER, "icelake-server") +X86_CPU_SUBTYPE(AMDFAM17H_ZNVER2, "znver2") +X86_CPU_SUBTYPE(INTEL_COREI7_CASCADELAKE, "cascadelake") +X86_CPU_SUBTYPE(INTEL_COREI7_TIGERLAKE, "tigerlake") +X86_CPU_SUBTYPE(INTEL_COREI7_COOPERLAKE, "cooperlake") #undef X86_CPU_SUBTYPE diff --git a/llvm/include/llvm/Support/X86TargetParser.h b/llvm/include/llvm/Support/X86TargetParser.h index 4a4fb8ccc4cc..66c474b5c275 100644 --- a/llvm/include/llvm/Support/X86TargetParser.h +++ b/llvm/include/llvm/Support/X86TargetParser.h @@ -34,7 +34,7 @@ enum ProcessorVendors : unsigned { // as a proxy for what's in libgcc/compiler-rt. enum ProcessorTypes : unsigned { CPU_TYPE_DUMMY, -#define X86_CPU_TYPE(ARCHNAME, ENUM) \ +#define X86_CPU_TYPE(ENUM, STRING) \ ENUM, #include "llvm/Support/X86TargetParser.def" CPU_TYPE_MAX @@ -44,7 +44,7 @@ enum ProcessorTypes : unsigned { // as a proxy for what's in libgcc/compiler-rt. enum ProcessorSubtypes : unsigned { CPU_SUBTYPE_DUMMY, -#define X86_CPU_SUBTYPE(ARCHNAME, ENUM) \ +#define X86_CPU_SUBTYPE(ENUM, STRING) \ ENUM, #include "llvm/Support/X86TargetParser.def" CPU_SUBTYPE_MAX From cfe-commits at lists.llvm.org Sun Jul 12 18:27:10 2020 From: cfe-commits at lists.llvm.org (Pengxuan Zheng via Phabricator via cfe-commits) Date: Mon, 13 Jul 2020 01:27:10 +0000 (UTC) Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption In-Reply-To: References: Message-ID: <3b08f342f1d6a52604e19f9b98418810@localhost.localdomain> pzheng added a comment. Actually, this patch won't change --help because it just reduced some duplication by extracting the common part (" the integrated assembler") of the help message into the "help" of "OptOutFFlag". Sorry for the confusion. The real fix here is to restore "integrated_as" as a DriverOption. Without this, when we have -fintegrated-as on a link line, it will be passed to the linker and cause the linker to fail because it is not a valid linker flag. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83648/new/ https://reviews.llvm.org/D83648 From cfe-commits at lists.llvm.org Sun Jul 12 18:32:41 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 13 Jul 2020 01:32:41 +0000 (UTC) Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption In-Reply-To: References: Message-ID: <6e6c1bdf2f9aee58a77131f2954a1550@localhost.localdomain> dblaikie added a comment. In D83648#2146472 , @pzheng wrote: > Actually, this patch won't change --help because it just reduced some duplication by extracting the common part (" the integrated assembler") of the help message into the "help" of "OptOutFFlag". Sorry for the confusion. > > The real fix here is to restore "integrated_as" as a DriverOption. Without this, when we have -fintegrated-as on a link line, it will be passed to the linker and cause the linker to fail because it is not a valid linker flag. Sounds like that could be tested with a driver test (using -### to see what the linker command would be and validating that it doesn't include -fintegrated-as? - see other similar tests in clang/test/Driver, I think) Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83648/new/ https://reviews.llvm.org/D83648 From cfe-commits at lists.llvm.org Sun Jul 12 19:28:02 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 13 Jul 2020 02:28:02 +0000 (UTC) Subject: [PATCH] D83652: Merge some of the PCH object support with modular codegen Message-ID: dblaikie created this revision. dblaikie added reviewers: rnk, llunak, hans. Herald added a project: clang. Herald added a subscriber: cfe-commits. I was trying to pick this up a bit when reviewing D48426 (& perhaps D69778 ) - in any case, looks like D48426 added a module level flag that might not be needed. The D48426 implementation worked by setting a module level flag, then code generating contents from the PCH a special case in ASTContext::DeclMustBeEmitted would be used to delay emitting the definition of these functions if they came from a Module with this flag. This strategy is similar to the one initially implemented for modular codegen that was removed in D29901 in favor of the modular decls list and a bit on each decl to specify whether it's homed to a module. One major difference between PCH object support and modular code generation, other than the specific list of decls that are homed, is the compilation model: MSVC PCH modules are built into the object file for some other source file (when compiling that source file /Yc is specified to say "this compilation is where the PCH is homed"), whereas modular code generation invokes a separate compilation for the PCH alone. So the current modular code generation test of to decide if a decl should be emitted "is the module where this decl is serialized the current main file" has to be extended (as Lubos did in D69778 ) to also test the command line flag -building-pch-with-obj. Otherwise the whole thing is basically streamlined down to the modular code generation path. This even offers one extra material improvement compared to the existing divergent implementation: Homed functions are not emitted into object files that use the pch. Instead at -O0 they are not emitted into the IR at all, and at -O1 they are emitted using available_externally (existing functionality implemented for modular code generation). The pch-codegen test has been updated to reflect this new behavior. [If possible: I'd love it if we could not have the extra MSVC-style way of accessing dllexport-pch-homing, and just do it the modular codegen way, but I understand that it might be a limitation of existing build systems. @hans / @thakis: Do either of you know if it'd be practical to move to something more similar to .pcm handling, where the pch itself is passed to the compilation, rather than homed as a side effect of compiling some other source file?] Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D83652 Files: clang/include/clang/AST/ExternalASTSource.h clang/include/clang/Sema/MultiplexExternalSemaSource.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ModuleFile.h clang/lib/Sema/MultiplexExternalSemaSource.cpp clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D83652.277315.patch Type: text/x-patch Size: 5242 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 19:37:13 2020 From: cfe-commits at lists.llvm.org (Pengxuan Zheng via Phabricator via cfe-commits) Date: Mon, 13 Jul 2020 02:37:13 +0000 (UTC) Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it as a DriverOption In-Reply-To: References: Message-ID: <25e76c76dd400a43a909e44c5d4d4263@localhost.localdomain> pzheng updated this revision to Diff 277316. pzheng added a comment. Add a test case. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83648/new/ https://reviews.llvm.org/D83648 Files: clang/include/clang/Driver/Options.td clang/test/Driver/integrated-as.c Index: clang/test/Driver/integrated-as.c =================================================================== --- clang/test/Driver/integrated-as.c +++ clang/test/Driver/integrated-as.c @@ -7,6 +7,10 @@ // FIAS: cc1as +// RUN: %clang -### -fintegrated-as %s 2>&1 | FileCheck %s -check-prefix FIAS-LINK + +// FIAS-LINK-NOT: -fintegrated-as + // RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \ // RUN: | FileCheck %s -check-prefix NOFIAS Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -2887,7 +2887,7 @@ MetaVarName<"">; def y : Joined<["-"], "y">; -defm integrated_as : OptOutFFlag<"integrated-as", "Enable the integrated assembler", "Disable the integrated assembler">; +defm integrated_as : OptOutFFlag<"integrated-as", "Enable", "Disable", " the integrated assembler", [DriverOption]>; def fintegrated_cc1 : Flag<["-"], "fintegrated-cc1">, Flags<[CoreOption, DriverOption]>, Group, -------------- next part -------------- A non-text attachment was scrubbed... Name: D83648.277316.patch Type: text/x-patch Size: 1114 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 19:44:03 2020 From: cfe-commits at lists.llvm.org (David Blaikie via cfe-commits) Date: Sun, 12 Jul 2020 19:44:03 -0700 (PDT) Subject: [clang] 49e5f60 - Rename/refactor isIntegerConstantExpression to getIntegerConstantExpression Message-ID: <5f0bca73.1c69fb81.95a14.d47a@mx.google.com> Author: David Blaikie Date: 2020-07-12T19:43:24-07:00 New Revision: 49e5f603d40083dce9c05796e3cde3a185c3beba URL: https://github.com/llvm/llvm-project/commit/49e5f603d40083dce9c05796e3cde3a185c3beba DIFF: https://github.com/llvm/llvm-project/commit/49e5f603d40083dce9c05796e3cde3a185c3beba.diff LOG: Rename/refactor isIntegerConstantExpression to getIntegerConstantExpression There is a version that just tests (also called isIntegerConstantExpression) & whereas this version is specifically used when the value is of interest (a few call sites were actually refactored to calling the test-only version) so let's make the API look more like it. Reviewers: aaron.ballman Differential Revision: https://reviews.llvm.org/D76646 Added: Modified: clang/include/clang/AST/Expr.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/MicrosoftMangle.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/Sema/SemaAttr.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaStmtAttr.cpp clang/lib/Sema/SemaType.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 66eafaaab715..a42c7bb5a9f2 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -510,16 +510,15 @@ class Expr : public ValueStmt { /// semantically correspond to a bool. bool isKnownToHaveBooleanValue(bool Semantic = true) const; - /// isIntegerConstantExpr - Return true if this expression is a valid integer - /// constant expression, and, if so, return its value in Result. If not a - /// valid i-c-e, return false and fill in Loc (if specified) with the location - /// of the invalid expression. + /// isIntegerConstantExpr - Return the value if this expression is a valid + /// integer constant expression. If not a valid i-c-e, return None and fill + /// in Loc (if specified) with the location of the invalid expression. /// /// Note: This does not perform the implicit conversions required by C++11 /// [expr.const]p5. - bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, - SourceLocation *Loc = nullptr, - bool isEvaluated = true) const; + Optional getIntegerConstantExpr(const ASTContext &Ctx, + SourceLocation *Loc = nullptr, + bool isEvaluated = true) const; bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc = nullptr) const; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 2ba643f12a82..807028885652 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -9471,17 +9471,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, const ConstantArrayType* CAT) -> std::pair { if (VAT) { - llvm::APSInt TheInt; + Optional TheInt; Expr *E = VAT->getSizeExpr(); - if (E && E->isIntegerConstantExpr(TheInt, *this)) - return std::make_pair(true, TheInt); - else - return std::make_pair(false, TheInt); - } else if (CAT) { - return std::make_pair(true, CAT->getSize()); - } else { - return std::make_pair(false, llvm::APInt()); + if (E && (TheInt = E->getIntegerConstantExpr(*this))) + return std::make_pair(true, *TheInt); + return std::make_pair(false, llvm::APSInt()); } + if (CAT) + return std::make_pair(true, CAT->getSize()); + return std::make_pair(false, llvm::APInt()); }; bool HaveLSize, HaveRSize; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index a4dc0ccad1e0..011dc890496d 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -14883,16 +14883,22 @@ bool Expr::isIntegerConstantExpr(const ASTContext &Ctx, return true; } -bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx, - SourceLocation *Loc, bool isEvaluated) const { +Optional Expr::getIntegerConstantExpr(const ASTContext &Ctx, + SourceLocation *Loc, + bool isEvaluated) const { assert(!isValueDependent() && "Expression evaluator can't be called on a dependent expression."); - if (Ctx.getLangOpts().CPlusPlus11) - return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc); + APSInt Value; + + if (Ctx.getLangOpts().CPlusPlus11) { + if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc)) + return Value; + return None; + } if (!isIntegerConstantExpr(Ctx, Loc)) - return false; + return None; // The only possible side-effects here are due to UB discovered in the // evaluation (for instance, INT_MAX + 1). In such a case, we are still @@ -14906,8 +14912,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx, if (!::EvaluateAsInt(this, ExprResult, Ctx, SE_AllowSideEffects, Info)) llvm_unreachable("ICE cannot be evaluated!"); - Value = ExprResult.Val.getInt(); - return true; + return ExprResult.Val.getInt(); } bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const { diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 529f301e4696..09579c28061a 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -1372,9 +1372,9 @@ void MicrosoftCXXNameMangler::mangleIntegerLiteral(const llvm::APSInt &Value, void MicrosoftCXXNameMangler::mangleExpression(const Expr *E) { // See if this is a constant expression. - llvm::APSInt Value; - if (E->isIntegerConstantExpr(Value, Context.getASTContext())) { - mangleIntegerLiteral(Value, E->getType()->isBooleanType()); + if (Optional Value = + E->getIntegerConstantExpr(Context.getASTContext())) { + mangleIntegerLiteral(*Value, E->getType()->isBooleanType()); return; } diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 35a93a7889f4..3588e33714d2 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -4419,11 +4419,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } else { // If this is required to be a constant, constant fold it so that we // know that the generated intrinsic gets a ConstantInt. - llvm::APSInt Result; - bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result,getContext()); - assert(IsConst && "Constant arg isn't actually constant?"); - (void)IsConst; - ArgValue = llvm::ConstantInt::get(getLLVMContext(), Result); + ArgValue = llvm::ConstantInt::get( + getLLVMContext(), + *E->getArg(i)->getIntegerConstantExpr(getContext())); } // If the intrinsic arg type is diff erent from the builtin arg type @@ -5596,13 +5594,14 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( SmallVectorImpl &Ops, Address PtrOp0, Address PtrOp1, llvm::Triple::ArchType Arch) { // Get the last argument, which specifies the vector type. - llvm::APSInt NeonTypeConst; const Expr *Arg = E->getArg(E->getNumArgs() - 1); - if (!Arg->isIntegerConstantExpr(NeonTypeConst, getContext())) + Optional NeonTypeConst = + Arg->getIntegerConstantExpr(getContext()); + if (!NeonTypeConst) return nullptr; // Determine the type of this overloaded NEON intrinsic. - NeonTypeFlags Type(NeonTypeConst.getZExtValue()); + NeonTypeFlags Type(NeonTypeConst->getZExtValue()); bool Usgn = Type.isUnsigned(); bool Quad = Type.isQuad(); const bool HasLegalHalfType = getTarget().hasLegalHalfType(); @@ -6885,10 +6884,9 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } else { // If this is required to be a constant, constant fold it so that we know // that the generated intrinsic gets a ConstantInt. - llvm::APSInt Result; - bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); - assert(IsConst && "Constant arg isn't actually constant?"); (void)IsConst; - Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); + Ops.push_back(llvm::ConstantInt::get( + getLLVMContext(), + *E->getArg(i)->getIntegerConstantExpr(getContext()))); } } @@ -7099,9 +7097,9 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, // Get the last argument, which specifies the vector type. assert(HasExtraArg); - llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs()-1); - if (!Arg->isIntegerConstantExpr(Result, getContext())) + Optional Result = Arg->getIntegerConstantExpr(getContext()); + if (!Result) return nullptr; if (BuiltinID == ARM::BI__builtin_arm_vcvtr_f || @@ -7114,7 +7112,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, Ty = DoubleTy; // Determine whether this is an unsigned conversion or not. - bool usgn = Result.getZExtValue() == 1; + bool usgn = Result->getZExtValue() == 1; unsigned Int = usgn ? Intrinsic::arm_vcvtru : Intrinsic::arm_vcvtr; // Call the appropriate intrinsic. @@ -7123,7 +7121,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } // Determine the type of this overloaded NEON intrinsic. - NeonTypeFlags Type(Result.getZExtValue()); + NeonTypeFlags Type = Result->getZExtValue(); bool usgn = Type.isUnsigned(); bool rightShift = false; @@ -7267,11 +7265,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, template static Integer GetIntegerConstantValue(const Expr *E, ASTContext &Context) { - llvm::APSInt IntVal; - bool IsConst = E->isIntegerConstantExpr(IntVal, Context); - assert(IsConst && "Sema should have checked this was a constant"); - (void)IsConst; - return IntVal.getExtValue(); + return E->getIntegerConstantExpr(Context)->getExtValue(); } static llvm::Value *SignOrZeroExtend(CGBuilderTy &Builder, llvm::Value *V, @@ -7544,13 +7538,13 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID assert(E->getNumArgs() >= 3); // Get the last argument, which specifies the vector type. - llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs() - 1); - if (!Arg->isIntegerConstantExpr(Result, CGF.getContext())) + Optional Result = Arg->getIntegerConstantExpr(CGF.getContext()); + if (!Result) return nullptr; // Determine the type of this overloaded NEON intrinsic. - NeonTypeFlags Type(Result.getZExtValue()); + NeonTypeFlags Type = Result->getZExtValue(); llvm::VectorType *Ty = GetNeonType(&CGF, Type); if (!Ty) return nullptr; @@ -8936,11 +8930,9 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, } else { // If this is required to be a constant, constant fold it so that we know // that the generated intrinsic gets a ConstantInt. - llvm::APSInt Result; - bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); - assert(IsConst && "Constant arg isn't actually constant?"); - (void)IsConst; - Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); + Ops.push_back(llvm::ConstantInt::get( + getLLVMContext(), + *E->getArg(i)->getIntegerConstantExpr(getContext()))); } } @@ -8955,12 +8947,11 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, return Result; } - llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs()-1); NeonTypeFlags Type(0); - if (Arg->isIntegerConstantExpr(Result, getContext())) + if (Optional Result = Arg->getIntegerConstantExpr(getContext())) // Determine the type of this overloaded NEON intrinsic. - Type = NeonTypeFlags(Result.getZExtValue()); + Type = NeonTypeFlags(Result->getZExtValue()); bool usgn = Type.isUnsigned(); bool quad = Type.isQuad(); @@ -11791,10 +11782,8 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, // If this is required to be a constant, constant fold it so that we know // that the generated intrinsic gets a ConstantInt. - llvm::APSInt Result; - bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); - assert(IsConst && "Constant arg isn't actually constant?"); (void)IsConst; - Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); + Ops.push_back(llvm::ConstantInt::get( + getLLVMContext(), *E->getArg(i)->getIntegerConstantExpr(getContext()))); } // These exist so that the builtin that takes an immediate can be bounds @@ -15073,11 +15062,8 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, llvm::Type *ResultType = ConvertType(E->getType()); Value *X = EmitScalarExpr(E->getArg(0)); // Constant-fold the M4 and M5 mask arguments. - llvm::APSInt M4, M5; - bool IsConstM4 = E->getArg(1)->isIntegerConstantExpr(M4, getContext()); - bool IsConstM5 = E->getArg(2)->isIntegerConstantExpr(M5, getContext()); - assert(IsConstM4 && IsConstM5 && "Constant arg isn't actually constant?"); - (void)IsConstM4; (void)IsConstM5; + llvm::APSInt M4 = *E->getArg(1)->getIntegerConstantExpr(getContext()); + llvm::APSInt M5 = *E->getArg(2)->getIntegerConstantExpr(getContext()); // Check whether this instance can be represented via a LLVM standard // intrinsic. We only support some combinations of M4 and M5. Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -15132,10 +15118,7 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, Value *X = EmitScalarExpr(E->getArg(0)); Value *Y = EmitScalarExpr(E->getArg(1)); // Constant-fold the M4 mask argument. - llvm::APSInt M4; - bool IsConstM4 = E->getArg(2)->isIntegerConstantExpr(M4, getContext()); - assert(IsConstM4 && "Constant arg isn't actually constant?"); - (void)IsConstM4; + llvm::APSInt M4 = *E->getArg(2)->getIntegerConstantExpr(getContext()); // Check whether this instance can be represented via a LLVM standard // intrinsic. We only support some values of M4. Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -15169,10 +15152,7 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, Value *X = EmitScalarExpr(E->getArg(0)); Value *Y = EmitScalarExpr(E->getArg(1)); // Constant-fold the M4 mask argument. - llvm::APSInt M4; - bool IsConstM4 = E->getArg(2)->isIntegerConstantExpr(M4, getContext()); - assert(IsConstM4 && "Constant arg isn't actually constant?"); - (void)IsConstM4; + llvm::APSInt M4 = *E->getArg(2)->getIntegerConstantExpr(getContext()); // Check whether this instance can be represented via a LLVM standard // intrinsic. We only support some values of M4. Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -15839,10 +15819,11 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Address Dst = EmitPointerWithAlignment(E->getArg(0)); Value *Src = EmitScalarExpr(E->getArg(1)); Value *Ldm = EmitScalarExpr(E->getArg(2)); - llvm::APSInt isColMajorArg; - if (!E->getArg(3)->isIntegerConstantExpr(isColMajorArg, getContext())) + Optional isColMajorArg = + E->getArg(3)->getIntegerConstantExpr(getContext()); + if (!isColMajorArg) return nullptr; - bool isColMajor = isColMajorArg.getSExtValue(); + bool isColMajor = isColMajorArg->getSExtValue(); NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID); unsigned IID = isColMajor ? II.IID_col : II.IID_row; if (IID == 0) @@ -15883,10 +15864,11 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Value *Dst = EmitScalarExpr(E->getArg(0)); Address Src = EmitPointerWithAlignment(E->getArg(1)); Value *Ldm = EmitScalarExpr(E->getArg(2)); - llvm::APSInt isColMajorArg; - if (!E->getArg(3)->isIntegerConstantExpr(isColMajorArg, getContext())) + Optional isColMajorArg = + E->getArg(3)->getIntegerConstantExpr(getContext()); + if (!isColMajorArg) return nullptr; - bool isColMajor = isColMajorArg.getSExtValue(); + bool isColMajor = isColMajorArg->getSExtValue(); NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID); unsigned IID = isColMajor ? II.IID_col : II.IID_row; if (IID == 0) @@ -15933,16 +15915,20 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Address SrcA = EmitPointerWithAlignment(E->getArg(1)); Address SrcB = EmitPointerWithAlignment(E->getArg(2)); Address SrcC = EmitPointerWithAlignment(E->getArg(3)); - llvm::APSInt LayoutArg; - if (!E->getArg(4)->isIntegerConstantExpr(LayoutArg, getContext())) + Optional LayoutArg = + E->getArg(4)->getIntegerConstantExpr(getContext()); + if (!LayoutArg) return nullptr; - int Layout = LayoutArg.getSExtValue(); + int Layout = LayoutArg->getSExtValue(); if (Layout < 0 || Layout > 3) return nullptr; llvm::APSInt SatfArg; if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1) SatfArg = 0; // .b1 does not have satf argument. - else if (!E->getArg(5)->isIntegerConstantExpr(SatfArg, getContext())) + else if (Optional OptSatfArg = + E->getArg(5)->getIntegerConstantExpr(getContext())) + SatfArg = *OptSatfArg; + else return nullptr; bool Satf = SatfArg.getSExtValue(); NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID); @@ -16271,9 +16257,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, case WebAssembly::BI__builtin_wasm_extract_lane_i64x2: case WebAssembly::BI__builtin_wasm_extract_lane_f32x4: case WebAssembly::BI__builtin_wasm_extract_lane_f64x2: { - llvm::APSInt LaneConst; - if (!E->getArg(1)->isIntegerConstantExpr(LaneConst, getContext())) - llvm_unreachable("Constant arg isn't actually constant?"); + llvm::APSInt LaneConst = + *E->getArg(1)->getIntegerConstantExpr(getContext()); Value *Vec = EmitScalarExpr(E->getArg(0)); Value *Lane = llvm::ConstantInt::get(getLLVMContext(), LaneConst); Value *Extract = Builder.CreateExtractElement(Vec, Lane); @@ -16299,9 +16284,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, case WebAssembly::BI__builtin_wasm_replace_lane_i64x2: case WebAssembly::BI__builtin_wasm_replace_lane_f32x4: case WebAssembly::BI__builtin_wasm_replace_lane_f64x2: { - llvm::APSInt LaneConst; - if (!E->getArg(1)->isIntegerConstantExpr(LaneConst, getContext())) - llvm_unreachable("Constant arg isn't actually constant?"); + llvm::APSInt LaneConst = + *E->getArg(1)->getIntegerConstantExpr(getContext()); Value *Vec = EmitScalarExpr(E->getArg(0)); Value *Lane = llvm::ConstantInt::get(getLLVMContext(), LaneConst); Value *Val = EmitScalarExpr(E->getArg(2)); diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 9e8770573d70..ab29e32929ce 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3868,15 +3868,17 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, llvm::APSInt ConstLength; if (Length) { // Idx = LowerBound + Length - 1; - if (Length->isIntegerConstantExpr(ConstLength, C)) { - ConstLength = ConstLength.zextOrTrunc(PointerWidthInBits); + if (Optional CL = Length->getIntegerConstantExpr(C)) { + ConstLength = CL->zextOrTrunc(PointerWidthInBits); Length = nullptr; } auto *LowerBound = E->getLowerBound(); llvm::APSInt ConstLowerBound(PointerWidthInBits, /*isUnsigned=*/false); - if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C)) { - ConstLowerBound = ConstLowerBound.zextOrTrunc(PointerWidthInBits); - LowerBound = nullptr; + if (LowerBound) { + if (Optional LB = LowerBound->getIntegerConstantExpr(C)) { + ConstLowerBound = LB->zextOrTrunc(PointerWidthInBits); + LowerBound = nullptr; + } } if (!Length) --ConstLength; @@ -3913,8 +3915,10 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, : BaseTy; if (auto *VAT = C.getAsVariableArrayType(ArrayTy)) { Length = VAT->getSizeExpr(); - if (Length->isIntegerConstantExpr(ConstLength, C)) + if (Optional L = Length->getIntegerConstantExpr(C)) { + ConstLength = *L; Length = nullptr; + } } else { auto *CAT = C.getAsConstantArrayType(ArrayTy); ConstLength = CAT->getSize(); diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index b354e810974c..f9785e4bea5e 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -300,20 +300,18 @@ void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, // If specified then alignment must be a "small" power of two. unsigned AlignmentVal = 0; if (Alignment) { - llvm::APSInt Val; + Optional Val; // pack(0) is like pack(), which just works out since that is what // we use 0 for in PackAttr. - if (Alignment->isTypeDependent() || - Alignment->isValueDependent() || - !Alignment->isIntegerConstantExpr(Val, Context) || - !(Val == 0 || Val.isPowerOf2()) || - Val.getZExtValue() > 16) { + if (Alignment->isTypeDependent() || Alignment->isValueDependent() || + !(Val = Alignment->getIntegerConstantExpr(Context)) || + !(*Val == 0 || Val->isPowerOf2()) || Val->getZExtValue() > 16) { Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment); return; // Ignore } - AlignmentVal = (unsigned) Val.getZExtValue(); + AlignmentVal = (unsigned)Val->getZExtValue(); } if (Action == Sema::PSK_Show) { // Show the current alignment, making sure to show the right value diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index efaf36a69306..c501c706a97b 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2284,10 +2284,7 @@ bool Sema::CheckARMCoprocessorImmediate(const TargetInfo &TI, if (CoprocArg->isTypeDependent() || CoprocArg->isValueDependent()) return false; - llvm::APSInt CoprocNoAP; - bool IsICE = CoprocArg->isIntegerConstantExpr(CoprocNoAP, Context); - (void)IsICE; - assert(IsICE && "Coprocossor immediate is not a constant expression"); + llvm::APSInt CoprocNoAP = *CoprocArg->getIntegerConstantExpr(Context); int64_t CoprocNo = CoprocNoAP.getExtValue(); assert(CoprocNo >= 0 && "Coprocessor immediate must be non-negative"); @@ -2599,8 +2596,7 @@ bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, // The second argument needs to be a constant int Arg = TheCall->getArg(1); - llvm::APSInt Value; - if (!Arg->isIntegerConstantExpr(Value, Context)) { + if (!Arg->isIntegerConstantExpr(Context)) { Diag(Arg->getBeginLoc(), diag::err_preserve_field_info_not_const) << 2 << Arg->getSourceRange(); return true; @@ -3198,11 +3194,10 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { if (BuiltinID == SystemZ::BI__builtin_tabort) { Expr *Arg = TheCall->getArg(0); - llvm::APSInt AbortCode(32); - if (Arg->isIntegerConstantExpr(AbortCode, Context) && - AbortCode.getSExtValue() >= 0 && AbortCode.getSExtValue() < 256) - return Diag(Arg->getBeginLoc(), diag::err_systemz_invalid_tabort_code) - << Arg->getSourceRange(); + if (Optional AbortCode = Arg->getIntegerConstantExpr(Context)) + if (AbortCode->getSExtValue() >= 0 && AbortCode->getSExtValue() < 256) + return Diag(Arg->getBeginLoc(), diag::err_systemz_invalid_tabort_code) + << Arg->getSourceRange(); } // For intrinsics which take an immediate value as part of the instruction, @@ -4923,21 +4918,21 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, } if (SubExprs.size() >= 2 && Form != Init) { - llvm::APSInt Result(32); - if (SubExprs[1]->isIntegerConstantExpr(Result, Context) && - !isValidOrderingForOp(Result.getSExtValue(), Op)) - Diag(SubExprs[1]->getBeginLoc(), - diag::warn_atomic_op_has_invalid_memory_order) - << SubExprs[1]->getSourceRange(); + if (Optional Result = + SubExprs[1]->getIntegerConstantExpr(Context)) + if (!isValidOrderingForOp(Result->getSExtValue(), Op)) + Diag(SubExprs[1]->getBeginLoc(), + diag::warn_atomic_op_has_invalid_memory_order) + << SubExprs[1]->getSourceRange(); } if (auto ScopeModel = AtomicExpr::getScopeModel(Op)) { auto *Scope = Args[Args.size() - 1]; - llvm::APSInt Result(32); - if (Scope->isIntegerConstantExpr(Result, Context) && - !ScopeModel->isValid(Result.getZExtValue())) { - Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope) - << Scope->getSourceRange(); + if (Optional Result = + Scope->getIntegerConstantExpr(Context)) { + if (!ScopeModel->isValid(Result->getZExtValue())) + Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope) + << Scope->getSourceRange(); } SubExprs.push_back(Scope); } @@ -5805,8 +5800,7 @@ bool Sema::SemaBuiltinVSX(CallExpr *TheCall) { << TheCall->getSourceRange(); // Check the third argument is a compile time constant - llvm::APSInt Value; - if(!TheCall->getArg(2)->isIntegerConstantExpr(Value, Context)) + if (!TheCall->getArg(2)->isIntegerConstantExpr(Context)) return Diag(TheCall->getBeginLoc(), diag::err_vsx_builtin_nonconstant_argument) << 3 /* argument index */ << TheCall->getDirectCallee() @@ -5901,17 +5895,18 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { TheCall->getArg(i)->isValueDependent()) continue; - llvm::APSInt Result(32); - if (!TheCall->getArg(i)->isIntegerConstantExpr(Result, Context)) + Optional Result; + if (!(Result = TheCall->getArg(i)->getIntegerConstantExpr(Context))) return ExprError(Diag(TheCall->getBeginLoc(), diag::err_shufflevector_nonconstant_argument) << TheCall->getArg(i)->getSourceRange()); // Allow -1 which will be translated to undef in the IR. - if (Result.isSigned() && Result.isAllOnesValue()) + if (Result->isSigned() && Result->isAllOnesValue()) continue; - if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2) + if (Result->getActiveBits() > 64 || + Result->getZExtValue() >= numElements * 2) return ExprError(Diag(TheCall->getBeginLoc(), diag::err_shufflevector_argument_too_large) << TheCall->getArg(i)->getSourceRange()); @@ -6158,10 +6153,11 @@ bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, if (Arg->isTypeDependent() || Arg->isValueDependent()) return false; - if (!Arg->isIntegerConstantExpr(Result, Context)) + Optional R; + if (!(R = Arg->getIntegerConstantExpr(Context))) return Diag(TheCall->getBeginLoc(), diag::err_constant_integer_arg_type) << FDecl->getDeclName() << Arg->getSourceRange(); - + Result = *R; return false; } @@ -10321,14 +10317,15 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, // If the shift amount is a positive constant, drop the width by // that much. - llvm::APSInt shift; - if (BO->getRHS()->isIntegerConstantExpr(shift, C) && - shift.isNonNegative()) { - unsigned zext = shift.getZExtValue(); - if (zext >= L.Width) - L.Width = (L.NonNegative ? 0 : 1); - else - L.Width -= zext; + if (Optional shift = + BO->getRHS()->getIntegerConstantExpr(C)) { + if (shift->isNonNegative()) { + unsigned zext = shift->getZExtValue(); + if (zext >= L.Width) + L.Width = (L.NonNegative ? 0 : 1); + else + L.Width -= zext; + } } return L; @@ -10352,9 +10349,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, IntRange L = GetExprRange(C, BO->getLHS(), opWidth, InConstantContext); // If the divisor is constant, use that. - llvm::APSInt divisor; - if (BO->getRHS()->isIntegerConstantExpr(divisor, C)) { - unsigned log2 = divisor.logBase2(); // floor(log_2(divisor)) + if (Optional divisor = + BO->getRHS()->getIntegerConstantExpr(C)) { + unsigned log2 = divisor->logBase2(); // floor(log_2(divisor)) if (log2 >= L.Width) L.Width = (L.NonNegative ? 0 : 1); else @@ -10786,23 +10783,20 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) { Expr *RHS = E->getRHS(); if (T->isIntegralType(S.Context)) { - llvm::APSInt RHSValue; - llvm::APSInt LHSValue; - - bool IsRHSIntegralLiteral = RHS->isIntegerConstantExpr(RHSValue, S.Context); - bool IsLHSIntegralLiteral = LHS->isIntegerConstantExpr(LHSValue, S.Context); + Optional RHSValue = RHS->getIntegerConstantExpr(S.Context); + Optional LHSValue = LHS->getIntegerConstantExpr(S.Context); // We don't care about expressions whose result is a constant. - if (IsRHSIntegralLiteral && IsLHSIntegralLiteral) + if (RHSValue && LHSValue) return AnalyzeImpConvsInComparison(S, E); // We only care about expressions where just one side is literal - if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) { + if ((bool)RHSValue ^ (bool)LHSValue) { // Is the constant on the RHS or LHS? - const bool RhsConstant = IsRHSIntegralLiteral; + const bool RhsConstant = (bool)RHSValue; Expr *Const = RhsConstant ? RHS : LHS; Expr *Other = RhsConstant ? LHS : RHS; - const llvm::APSInt &Value = RhsConstant ? RHSValue : LHSValue; + const llvm::APSInt &Value = RhsConstant ? *RHSValue : *LHSValue; // Check whether an integer constant comparison results in a value // of 'true' or 'false'. @@ -11760,8 +11754,8 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, if (SourcePrecision > 0 && TargetPrecision > 0 && SourcePrecision > TargetPrecision) { - llvm::APSInt SourceInt; - if (E->isIntegerConstantExpr(SourceInt, S.Context)) { + if (Optional SourceInt = + E->getIntegerConstantExpr(S.Context)) { // If the source integer is a constant, convert it to the target // floating point type. Issue a warning if the value changes // during the whole conversion. @@ -11769,11 +11763,11 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, S.Context.getFloatTypeSemantics(QualType(TargetBT, 0))); llvm::APFloat::opStatus ConversionStatus = TargetFloatValue.convertFromAPInt( - SourceInt, SourceBT->isSignedInteger(), + *SourceInt, SourceBT->isSignedInteger(), llvm::APFloat::rmNearestTiesToEven); if (ConversionStatus != llvm::APFloat::opOK) { - std::string PrettySourceValue = SourceInt.toString(10); + std::string PrettySourceValue = SourceInt->toString(10); SmallString<32> PrettyTargetValue; TargetFloatValue.toString(PrettyTargetValue, TargetPrecision); @@ -14124,9 +14118,10 @@ namespace { return; if (Expr *RHS = BinOp->getRHS()) { RHS = RHS->IgnoreParenCasts(); - llvm::APSInt Value; + Optional Value; VarWillBeReased = - (RHS && RHS->isIntegerConstantExpr(Value, Context) && Value == 0); + (RHS && (Value = RHS->getIntegerConstantExpr(Context)) && + *Value == 0); } } } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f5e375134c29..dc0f3d68fde3 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -13141,20 +13141,20 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { if (!MagicValueExpr) { continue; } - llvm::APSInt MagicValueInt; - if (!MagicValueExpr->isIntegerConstantExpr(MagicValueInt, Context)) { + Optional MagicValueInt; + if (!(MagicValueInt = MagicValueExpr->getIntegerConstantExpr(Context))) { Diag(I->getRange().getBegin(), diag::err_type_tag_for_datatype_not_ice) << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); continue; } - if (MagicValueInt.getActiveBits() > 64) { + if (MagicValueInt->getActiveBits() > 64) { Diag(I->getRange().getBegin(), diag::err_type_tag_for_datatype_too_large) << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); continue; } - uint64_t MagicValue = MagicValueInt.getZExtValue(); + uint64_t MagicValue = MagicValueInt->getZExtValue(); RegisterTypeTagForDatatype(I->getArgumentKind(), MagicValue, I->getMatchingCType(), diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 1a0594512a60..ece93cbd6a9b 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -240,9 +240,9 @@ template static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx = UINT_MAX, bool StrictlyUnsigned = false) { - llvm::APSInt I(32); + Optional I = llvm::APSInt(32); if (Expr->isTypeDependent() || Expr->isValueDependent() || - !Expr->isIntegerConstantExpr(I, S.Context)) { + !(I = Expr->getIntegerConstantExpr(S.Context))) { if (Idx != UINT_MAX) S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) << &AI << Idx << AANT_ArgumentIntegerConstant @@ -253,19 +253,19 @@ static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, return false; } - if (!I.isIntN(32)) { + if (!I->isIntN(32)) { S.Diag(Expr->getExprLoc(), diag::err_ice_too_large) - << I.toString(10, false) << 32 << /* Unsigned */ 1; + << I->toString(10, false) << 32 << /* Unsigned */ 1; return false; } - if (StrictlyUnsigned && I.isSigned() && I.isNegative()) { + if (StrictlyUnsigned && I->isSigned() && I->isNegative()) { S.Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer) << &AI << /*non-negative*/ 1; return false; } - Val = (uint32_t)I.getZExtValue(); + Val = (uint32_t)I->getZExtValue(); return true; } @@ -332,16 +332,16 @@ static bool checkFunctionOrMethodParameterIndex( unsigned NumParams = (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam; - llvm::APSInt IdxInt; + Optional IdxInt; if (IdxExpr->isTypeDependent() || IdxExpr->isValueDependent() || - !IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) { + !(IdxInt = IdxExpr->getIntegerConstantExpr(S.Context))) { S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) << &AI << AttrArgNum << AANT_ArgumentIntegerConstant << IdxExpr->getSourceRange(); return false; } - unsigned IdxSource = IdxInt.getLimitedValue(UINT_MAX); + unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX); if (IdxSource < 1 || (!IV && IdxSource > NumParams)) { S.Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds) << &AI << AttrArgNum << IdxExpr->getSourceRange(); @@ -1605,8 +1605,8 @@ void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, } if (!E->isValueDependent()) { - llvm::APSInt I(64); - if (!E->isIntegerConstantExpr(I, Context)) { + Optional I = llvm::APSInt(64); + if (!(I = E->getIntegerConstantExpr(Context))) { if (OE) Diag(AttrLoc, diag::err_attribute_argument_n_type) << &TmpAttr << 1 << AANT_ArgumentIntegerConstant @@ -1618,27 +1618,22 @@ void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, return; } - if (!I.isPowerOf2()) { + if (!I->isPowerOf2()) { Diag(AttrLoc, diag::err_alignment_not_power_of_two) << E->getSourceRange(); return; } - if (I > Sema::MaximumAlignment) + if (*I > Sema::MaximumAlignment) Diag(CI.getLoc(), diag::warn_assume_aligned_too_great) << CI.getRange() << Sema::MaximumAlignment; } - if (OE) { - if (!OE->isValueDependent()) { - llvm::APSInt I(64); - if (!OE->isIntegerConstantExpr(I, Context)) { - Diag(AttrLoc, diag::err_attribute_argument_n_type) - << &TmpAttr << 2 << AANT_ArgumentIntegerConstant - << OE->getSourceRange(); - return; - } - } + if (OE && !OE->isValueDependent() && !OE->isIntegerConstantExpr(Context)) { + Diag(AttrLoc, diag::err_attribute_argument_n_type) + << &TmpAttr << 2 << AANT_ArgumentIntegerConstant + << OE->getSourceRange(); + return; } D->addAttr(::new (Context) AssumeAlignedAttr(Context, CI, E, OE)); @@ -2729,36 +2724,36 @@ static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { unsigned sentinel = (unsigned)SentinelAttr::DefaultSentinel; if (AL.getNumArgs() > 0) { Expr *E = AL.getArgAsExpr(0); - llvm::APSInt Idx(32); + Optional Idx = llvm::APSInt(32); if (E->isTypeDependent() || E->isValueDependent() || - !E->isIntegerConstantExpr(Idx, S.Context)) { + !(Idx = E->getIntegerConstantExpr(S.Context))) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL << 1 << AANT_ArgumentIntegerConstant << E->getSourceRange(); return; } - if (Idx.isSigned() && Idx.isNegative()) { + if (Idx->isSigned() && Idx->isNegative()) { S.Diag(AL.getLoc(), diag::err_attribute_sentinel_less_than_zero) << E->getSourceRange(); return; } - sentinel = Idx.getZExtValue(); + sentinel = Idx->getZExtValue(); } unsigned nullPos = (unsigned)SentinelAttr::DefaultNullPos; if (AL.getNumArgs() > 1) { Expr *E = AL.getArgAsExpr(1); - llvm::APSInt Idx(32); + Optional Idx = llvm::APSInt(32); if (E->isTypeDependent() || E->isValueDependent() || - !E->isIntegerConstantExpr(Idx, S.Context)) { + !(Idx = E->getIntegerConstantExpr(S.Context))) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL << 2 << AANT_ArgumentIntegerConstant << E->getSourceRange(); return; } - nullPos = Idx.getZExtValue(); + nullPos = Idx->getZExtValue(); - if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) { + if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) { // FIXME: This error message could be improved, it would be nice // to say what the bounds actually are. S.Diag(AL.getLoc(), diag::err_attribute_sentinel_not_zero_or_one) @@ -4833,19 +4828,19 @@ static Expr *makeLaunchBoundsArgExpr(Sema &S, Expr *E, if (E->isValueDependent()) return E; - llvm::APSInt I(64); - if (!E->isIntegerConstantExpr(I, S.Context)) { + Optional I = llvm::APSInt(64); + if (!(I = E->getIntegerConstantExpr(S.Context))) { S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type) << &AL << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange(); return nullptr; } // Make sure we can fit it in 32 bits. - if (!I.isIntN(32)) { - S.Diag(E->getExprLoc(), diag::err_ice_too_large) << I.toString(10, false) - << 32 << /* Unsigned */ 1; + if (!I->isIntN(32)) { + S.Diag(E->getExprLoc(), diag::err_ice_too_large) + << I->toString(10, false) << 32 << /* Unsigned */ 1; return nullptr; } - if (I < 0) + if (*I < 0) S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative) << &AL << Idx << E->getSourceRange(); @@ -5686,18 +5681,18 @@ static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { } Expr *NumParamsExpr = static_cast(AL.getArgAsExpr(0)); - llvm::APSInt NumParams(32); - if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) { + Optional NumParams = llvm::APSInt(32); + if (!(NumParams = NumParamsExpr->getIntegerConstantExpr(S.Context))) { S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL << AANT_ArgumentIntegerConstant << NumParamsExpr->getSourceRange(); return; } // The argument should be in range 0..63. - unsigned Num = NumParams.getLimitedValue(255); + unsigned Num = NumParams->getLimitedValue(255); if (Num > 63) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) - << AL << (int)NumParams.getSExtValue() + << AL << (int)NumParams->getSExtValue() << NumParamsExpr->getSourceRange(); return; } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index d885920b6c14..e3aa817c6224 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2073,29 +2073,29 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // per CWG1464. Otherwise, if it's not a constant, we must have an // unparenthesized array type. if (!(*ArraySize)->isValueDependent()) { - llvm::APSInt Value; // We've already performed any required implicit conversion to integer or // unscoped enumeration type. // FIXME: Per CWG1464, we are required to check the value prior to // converting to size_t. This will never find a negative array size in // C++14 onwards, because Value is always unsigned here! - if ((*ArraySize)->isIntegerConstantExpr(Value, Context)) { - if (Value.isSigned() && Value.isNegative()) { + if (Optional Value = + (*ArraySize)->getIntegerConstantExpr(Context)) { + if (Value->isSigned() && Value->isNegative()) { return ExprError(Diag((*ArraySize)->getBeginLoc(), diag::err_typecheck_negative_array_size) << (*ArraySize)->getSourceRange()); } if (!AllocType->isDependentType()) { - unsigned ActiveSizeBits = - ConstantArrayType::getNumAddressingBits(Context, AllocType, Value); + unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits( + Context, AllocType, *Value); if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) return ExprError( Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large) - << Value.toString(10) << (*ArraySize)->getSourceRange()); + << Value->toString(10) << (*ArraySize)->getSourceRange()); } - KnownArraySize = Value.getZExtValue(); + KnownArraySize = Value->getZExtValue(); } else if (TypeIdParens.isValid()) { // Can't have dynamic array size when the type-id is in parentheses. Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index b27abb54c170..d1ddf1072417 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5989,8 +5989,7 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG, // Deal with non-constant score and user condition expressions. auto HandleNonConstantScoresAndConditions = [this](Expr *&E, bool IsScore) -> bool { - llvm::APSInt Result; - if (!E || E->isIntegerConstantExpr(Result, Context)) + if (!E || E->isIntegerConstantExpr(Context)) return false; if (IsScore) { @@ -6476,14 +6475,14 @@ bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) { // loop. If test-expr is of form b relational-op var and relational-op is // > or >= then incr-expr must cause var to increase on each iteration of // the loop. - llvm::APSInt Result; - bool IsConstant = NewStep->isIntegerConstantExpr(Result, SemaRef.Context); + Optional Result = + NewStep->getIntegerConstantExpr(SemaRef.Context); bool IsUnsigned = !NewStep->getType()->hasSignedIntegerRepresentation(); bool IsConstNeg = - IsConstant && Result.isSigned() && (Subtract != Result.isNegative()); + Result && Result->isSigned() && (Subtract != Result->isNegative()); bool IsConstPos = - IsConstant && Result.isSigned() && (Subtract == Result.isNegative()); - bool IsConstZero = IsConstant && !Result.getBoolValue(); + Result && Result->isSigned() && (Subtract == Result->isNegative()); + bool IsConstZero = Result && !Result->getBoolValue(); // != with increment is treated as <; != with decrement is treated as > if (!TestIsLessOp.hasValue()) @@ -7914,9 +7913,9 @@ static ExprResult widenIterationCount(unsigned Bits, Expr *E, Sema &SemaRef) { static bool fitsInto(unsigned Bits, bool Signed, const Expr *E, Sema &SemaRef) { if (E == nullptr) return false; - llvm::APSInt Result; - if (E->isIntegerConstantExpr(Result, SemaRef.Context)) - return Signed ? Result.isSignedIntN(Bits) : Result.isIntN(Bits); + if (Optional Result = + E->getIntegerConstantExpr(SemaRef.Context)) + return Signed ? Result->isSignedIntN(Bits) : Result->isIntN(Bits); return false; } @@ -8189,9 +8188,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, // Calculate the last iteration number beforehand instead of doing this on // each iteration. Do not do this if the number of iterations may be kfold-ed. - llvm::APSInt Result; - bool IsConstant = - LastIteration.get()->isIntegerConstantExpr(Result, SemaRef.Context); + bool IsConstant = LastIteration.get()->isIntegerConstantExpr(SemaRef.Context); ExprResult CalcLastIteration; if (!IsConstant) { ExprResult SaveRef = @@ -12582,15 +12579,16 @@ isNonNegativeIntegerValue(Expr *&ValExpr, Sema &SemaRef, OpenMPClauseKind CKind, ValExpr = Value.get(); // The expression must evaluate to a non-negative integer value. - llvm::APSInt Result; - if (ValExpr->isIntegerConstantExpr(Result, SemaRef.Context) && - Result.isSigned() && - !((!StrictlyPositive && Result.isNonNegative()) || - (StrictlyPositive && Result.isStrictlyPositive()))) { - SemaRef.Diag(Loc, diag::err_omp_negative_expression_in_clause) - << getOpenMPClauseName(CKind) << (StrictlyPositive ? 1 : 0) - << ValExpr->getSourceRange(); - return false; + if (Optional Result = + ValExpr->getIntegerConstantExpr(SemaRef.Context)) { + if (Result->isSigned() && + !((!StrictlyPositive && Result->isNonNegative()) || + (StrictlyPositive && Result->isStrictlyPositive()))) { + SemaRef.Diag(Loc, diag::err_omp_negative_expression_in_clause) + << getOpenMPClauseName(CKind) << (StrictlyPositive ? 1 : 0) + << ValExpr->getSourceRange(); + return false; + } } if (!BuildCapture) return true; @@ -13215,9 +13213,9 @@ OMPClause *Sema::ActOnOpenMPScheduleClause( // OpenMP [2.7.1, Restrictions] // chunk_size must be a loop invariant integer expression with a positive // value. - llvm::APSInt Result; - if (ValExpr->isIntegerConstantExpr(Result, Context)) { - if (Result.isSigned() && !Result.isStrictlyPositive()) { + if (Optional Result = + ValExpr->getIntegerConstantExpr(Context)) { + if (Result->isSigned() && !Result->isStrictlyPositive()) { Diag(ChunkSizeLoc, diag::err_omp_negative_expression_in_clause) << "schedule" << 1 << ChunkSize->getSourceRange(); return nullptr; @@ -15688,12 +15686,12 @@ OMPClause *Sema::ActOnOpenMPLinearClause( // Warn about zero linear step (it would be probably better specified as // making corresponding variables 'const'). - llvm::APSInt Result; - bool IsConstant = StepExpr->isIntegerConstantExpr(Result, Context); - if (IsConstant && !Result.isNegative() && !Result.isStrictlyPositive()) - Diag(StepLoc, diag::warn_omp_linear_step_zero) << Vars[0] - << (Vars.size() > 1); - if (!IsConstant && CalcStep.isUsable()) { + if (Optional Result = + StepExpr->getIntegerConstantExpr(Context)) { + if (!Result->isNegative() && !Result->isStrictlyPositive()) + Diag(StepLoc, diag::warn_omp_linear_step_zero) + << Vars[0] << (Vars.size() > 1); + } else if (CalcStep.isUsable()) { // Calculate the step beforehand instead of doing this on each iteration. // (This is not used if the number of iterations may be kfold-ed). CalcStepExpr = CalcStep.get(); @@ -18225,9 +18223,9 @@ OMPClause *Sema::ActOnOpenMPDistScheduleClause( // OpenMP [2.7.1, Restrictions] // chunk_size must be a loop invariant integer expression with a positive // value. - llvm::APSInt Result; - if (ValExpr->isIntegerConstantExpr(Result, Context)) { - if (Result.isSigned() && !Result.isStrictlyPositive()) { + if (Optional Result = + ValExpr->getIntegerConstantExpr(Context)) { + if (Result->isSigned() && !Result->isStrictlyPositive()) { Diag(ChunkSizeLoc, diag::err_omp_negative_expression_in_clause) << "dist_schedule" << ChunkSize->getSourceRange(); return nullptr; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 8635397f4806..7c6acf011d57 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -346,7 +346,6 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( ToType->isRealFloatingType()) { if (IgnoreFloatToIntegralConversion) return NK_Not_Narrowing; - llvm::APSInt IntConstantValue; const Expr *Initializer = IgnoreNarrowingConversion(Ctx, Converted); assert(Initializer && "Unknown conversion expression"); @@ -354,19 +353,20 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( if (Initializer->isValueDependent()) return NK_Dependent_Narrowing; - if (Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) { + if (Optional IntConstantValue = + Initializer->getIntegerConstantExpr(Ctx)) { // Convert the integer to the floating type. llvm::APFloat Result(Ctx.getFloatTypeSemantics(ToType)); - Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(), + Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(), llvm::APFloat::rmNearestTiesToEven); // And back. - llvm::APSInt ConvertedValue = IntConstantValue; + llvm::APSInt ConvertedValue = *IntConstantValue; bool ignored; Result.convertToInteger(ConvertedValue, llvm::APFloat::rmTowardZero, &ignored); // If the resulting value is diff erent, this was a narrowing conversion. - if (IntConstantValue != ConvertedValue) { - ConstantValue = APValue(IntConstantValue); + if (*IntConstantValue != ConvertedValue) { + ConstantValue = APValue(*IntConstantValue); ConstantType = Initializer->getType(); return NK_Constant_Narrowing; } @@ -430,17 +430,18 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( (FromWidth == ToWidth && FromSigned != ToSigned) || (FromSigned && !ToSigned)) { // Not all values of FromType can be represented in ToType. - llvm::APSInt InitializerValue; const Expr *Initializer = IgnoreNarrowingConversion(Ctx, Converted); // If it's value-dependent, we can't tell whether it's narrowing. if (Initializer->isValueDependent()) return NK_Dependent_Narrowing; - if (!Initializer->isIntegerConstantExpr(InitializerValue, Ctx)) { + Optional OptInitializerValue; + if (!(OptInitializerValue = Initializer->getIntegerConstantExpr(Ctx))) { // Such conversions on variables are always narrowing. return NK_Variable_Narrowing; } + llvm::APSInt &InitializerValue = *OptInitializerValue; bool Narrowing = false; if (FromWidth < ToWidth) { // Negative -> unsigned is narrowing. Otherwise, more bits is never @@ -2183,21 +2184,22 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) { // compatibility. if (From) { if (FieldDecl *MemberDecl = From->getSourceBitField()) { - llvm::APSInt BitWidth; + Optional BitWidth; if (FromType->isIntegralType(Context) && - MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) { - llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned()); + (BitWidth = + MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) { + llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned()); ToSize = Context.getTypeSize(ToType); // Are we promoting to an int from a bitfield that fits in an int? - if (BitWidth < ToSize || - (FromType->isSignedIntegerType() && BitWidth <= ToSize)) { + if (*BitWidth < ToSize || + (FromType->isSignedIntegerType() && *BitWidth <= ToSize)) { return To->getKind() == BuiltinType::Int; } // Are we promoting to an unsigned int from an unsigned bitfield // that fits into an unsigned int? - if (FromType->isUnsignedIntegerType() && BitWidth <= ToSize) { + if (FromType->isUnsignedIntegerType() && *BitWidth <= ToSize) { return To->getKind() == BuiltinType::UInt; } diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index e9d3c755eb23..c7b97ec4d975 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -335,15 +335,15 @@ static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, if (NumArgs == 1) { Expr *E = A.getArgAsExpr(0); - llvm::APSInt ArgVal(32); + Optional ArgVal; - if (!E->isIntegerConstantExpr(ArgVal, S.Context)) { + if (!(ArgVal = E->getIntegerConstantExpr(S.Context))) { S.Diag(A.getLoc(), diag::err_attribute_argument_type) << A << AANT_ArgumentIntegerConstant << E->getSourceRange(); return nullptr; } - int Val = ArgVal.getSExtValue(); + int Val = ArgVal->getSExtValue(); if (Val <= 0) { S.Diag(A.getRange().getBegin(), diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index b8f7f1a58159..13426cbf2db4 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2476,8 +2476,8 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr, return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc, VectorType::GenericVector); - llvm::APSInt VecSize(32); - if (!SizeExpr->isIntegerConstantExpr(VecSize, Context)) { + Optional VecSize = SizeExpr->getIntegerConstantExpr(Context); + if (!VecSize) { Diag(AttrLoc, diag::err_attribute_argument_type) << "vector_size" << AANT_ArgumentIntegerConstant << SizeExpr->getSourceRange(); @@ -2489,13 +2489,13 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr, VectorType::GenericVector); // vecSize is specified in bytes - convert to bits. - if (!VecSize.isIntN(61)) { + if (!VecSize->isIntN(61)) { // Bit size will overflow uint64. Diag(AttrLoc, diag::err_attribute_size_too_large) << SizeExpr->getSourceRange() << "vector"; return QualType(); } - uint64_t VectorSizeBits = VecSize.getZExtValue() * 8; + uint64_t VectorSizeBits = VecSize->getZExtValue() * 8; unsigned TypeSize = static_cast(Context.getTypeSize(CurType)); if (VectorSizeBits == 0) { @@ -2540,8 +2540,8 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize, } if (!ArraySize->isTypeDependent() && !ArraySize->isValueDependent()) { - llvm::APSInt vecSize(32); - if (!ArraySize->isIntegerConstantExpr(vecSize, Context)) { + Optional vecSize = ArraySize->getIntegerConstantExpr(Context); + if (!vecSize) { Diag(AttrLoc, diag::err_attribute_argument_type) << "ext_vector_type" << AANT_ArgumentIntegerConstant << ArraySize->getSourceRange(); @@ -2555,7 +2555,7 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize, } // Unlike gcc's vector_size attribute, the size is specified as the // number of elements, not the number of bytes. - unsigned vectorSize = static_cast(vecSize.getZExtValue()); + unsigned vectorSize = static_cast(vecSize->getZExtValue()); if (vectorSize == 0) { Diag(AttrLoc, diag::err_attribute_zero_size) @@ -6254,13 +6254,15 @@ static bool BuildAddressSpaceIndex(Sema &S, LangAS &ASIdx, const Expr *AddrSpace, SourceLocation AttrLoc) { if (!AddrSpace->isValueDependent()) { - llvm::APSInt addrSpace(32); - if (!AddrSpace->isIntegerConstantExpr(addrSpace, S.Context)) { + Optional OptAddrSpace = + AddrSpace->getIntegerConstantExpr(S.Context); + if (!OptAddrSpace) { S.Diag(AttrLoc, diag::err_attribute_argument_type) << "'address_space'" << AANT_ArgumentIntegerConstant << AddrSpace->getSourceRange(); return false; } + llvm::APSInt &addrSpace = *OptAddrSpace; // Bounds checking. if (addrSpace.isSigned()) { @@ -7712,9 +7714,9 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, } // The number of elements must be an ICE. Expr *numEltsExpr = static_cast(Attr.getArgAsExpr(0)); - llvm::APSInt numEltsInt(32); + Optional numEltsInt; if (numEltsExpr->isTypeDependent() || numEltsExpr->isValueDependent() || - !numEltsExpr->isIntegerConstantExpr(numEltsInt, S.Context)) { + !(numEltsInt = numEltsExpr->getIntegerConstantExpr(S.Context))) { S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr << AANT_ArgumentIntegerConstant << numEltsExpr->getSourceRange(); @@ -7730,7 +7732,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // The total size of the vector must be 64 or 128 bits. unsigned typeSize = static_cast(S.Context.getTypeSize(CurType)); - unsigned numElts = static_cast(numEltsInt.getZExtValue()); + unsigned numElts = static_cast(numEltsInt->getZExtValue()); unsigned vecSize = typeSize * numElts; if (vecSize != 64 && vecSize != 128) { S.Diag(Attr.getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType; From cfe-commits at lists.llvm.org Sun Jul 12 19:44:20 2020 From: cfe-commits at lists.llvm.org (David Blaikie via Phabricator via cfe-commits) Date: Mon, 13 Jul 2020 02:44:20 +0000 (UTC) Subject: [PATCH] D76646: Rename/refactor isIntegerConstantExpression to getIntegerConstantExpression In-Reply-To: References: Message-ID: <64b9820defaa8d76136bcf0ae4f371ea@localhost.localdomain> This revision was automatically updated to reflect the committed changes. Closed by commit rG49e5f603d400: Rename/refactor isIntegerConstantExpression to getIntegerConstantExpression (authored by dblaikie). Herald added a subscriber: sstefan1. Changed prior to commit: https://reviews.llvm.org/D76646?vs=252158&id=277317#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76646/new/ https://reviews.llvm.org/D76646 Files: clang/include/clang/AST/Expr.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/MicrosoftMangle.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/Sema/SemaAttr.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaStmtAttr.cpp clang/lib/Sema/SemaType.cpp -------------- next part -------------- A non-text attachment was scrubbed... Name: D76646.277317.patch Type: text/x-patch Size: 54591 bytes Desc: not available URL: From cfe-commits at lists.llvm.org Sun Jul 12 20:23:55 2020 From: cfe-commits at lists.llvm.org (Juneyoung Lee via Phabricator via cfe-commits) Date: Mon, 13 Jul 2020 03:23:55 +0000 (UTC) Subject: [PATCH] D83360: [InstSimplify] Remove select ?, undef, X -> X and select ?, X, undef -> X In-Reply-To: References: Message-ID: <89a710a364b23dc6357a58991f5dbfcf@localhost.localdomain> aqjune added a comment. (renaming variables for readability) %a = select i1 %s, i1 undef, i1 %t %b = xor i1 %s, 1 %c = and i1 %a, %b This series of reasoning happened from a single SimplifyAndInst call: c = a & (s ^ 1) = (a & s) ^ (a & 1) ; ExpandBinOp = ((select s, undef, t) & s) ^ a = (select s, (undef & s), (t & s)) ^ a ; ThreadBinOpOverSelect = (select s, (undef & s), false) ^ a ; since s = (x == y), t = (x < y) = (select s, false, false) ^ a ; choose undef to be false = a = select s, undef, t In general, distributing `a` into operands of xor (second line) isn't sound because it increases the number of uses of `a`. We don't want to totally disable the simplification, however. If InstSimplify never increases the number of uses in the end, we have an alternative solution: tracking to which value undef is folded. Whenever an undef value is chosen to be a concrete value, the decision should be remembered, so the copied undefs won't be folded into different values. In case of InstSimplify, we can identify individual undefs by Use, since InstSimplify won't do any transformation inside. This means SimplifyXXX needs to return two things: the simplified value & the undef cache. Since InstSimplify isn't designed to do transformation directly, other optimizations like InstCombine should perform the final change. Does this solution make sense? Then, I can prepare a patch for this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83360/new/ https://reviews.llvm.org/D83360 From cfe-commits at lists.llvm.org Sun Jul 12 20:30:57 2020 From: cfe-commits at lists.llvm.org (David Blaikie via cfe-commits) Date: Sun, 12 Jul 2020 20:30:57 -0700 (PDT) Subject: [clang] c943329 - Revert "Rename/refactor isIntegerConstantExpression to getIntegerConstantExpression" Message-ID: <5f0bd571.1c69fb81.7ae76.f821@mx.google.com> Author: David Blaikie Date: 2020-07-12T20:29:19-07:00 New Revision: c94332919bd922032e979b3ae3ced5ca5bdf9650 URL: https://github.com/llvm/llvm-project/commit/c94332919bd922032e979b3ae3ced5ca5bdf9650 DIFF: https://github.com/llvm/llvm-project/commit/c94332919bd922032e979b3ae3ced5ca5bdf9650.diff LOG: Revert "Rename/refactor isIntegerConstantExpression to getIntegerConstantExpression" Broke buildbots since I hadn't updated this patch in a while. Sorry for the noise. This reverts commit 49e5f603d40083dce9c05796e3cde3a185c3beba. Added: Modified: clang/include/clang/AST/Expr.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ExprConstant.cpp clang/lib/AST/MicrosoftMangle.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGExpr.cpp clang/lib/Sema/SemaAttr.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaExprCXX.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaStmtAttr.cpp clang/lib/Sema/SemaType.cpp Removed: ################################################################################ diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index a42c7bb5a9f2..66eafaaab715 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -510,15 +510,16 @@ class Expr : public ValueStmt { /// semantically correspond to a bool. bool isKnownToHaveBooleanValue(bool Semantic = true) const; - /// isIntegerConstantExpr - Return the value if this expression is a valid - /// integer constant expression. If not a valid i-c-e, return None and fill - /// in Loc (if specified) with the location of the invalid expression. + /// isIntegerConstantExpr - Return true if this expression is a valid integer + /// constant expression, and, if so, return its value in Result. If not a + /// valid i-c-e, return false and fill in Loc (if specified) with the location + /// of the invalid expression. /// /// Note: This does not perform the implicit conversions required by C++11 /// [expr.const]p5. - Optional getIntegerConstantExpr(const ASTContext &Ctx, - SourceLocation *Loc = nullptr, - bool isEvaluated = true) const; + bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, + SourceLocation *Loc = nullptr, + bool isEvaluated = true) const; bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc = nullptr) const; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 807028885652..2ba643f12a82 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -9471,15 +9471,17 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, const ConstantArrayType* CAT) -> std::pair { if (VAT) { - Optional TheInt; + llvm::APSInt TheInt; Expr *E = VAT->getSizeExpr(); - if (E && (TheInt = E->getIntegerConstantExpr(*this))) - return std::make_pair(true, *TheInt); - return std::make_pair(false, llvm::APSInt()); + if (E && E->isIntegerConstantExpr(TheInt, *this)) + return std::make_pair(true, TheInt); + else + return std::make_pair(false, TheInt); + } else if (CAT) { + return std::make_pair(true, CAT->getSize()); + } else { + return std::make_pair(false, llvm::APInt()); } - if (CAT) - return std::make_pair(true, CAT->getSize()); - return std::make_pair(false, llvm::APInt()); }; bool HaveLSize, HaveRSize; diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 011dc890496d..a4dc0ccad1e0 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -14883,22 +14883,16 @@ bool Expr::isIntegerConstantExpr(const ASTContext &Ctx, return true; } -Optional Expr::getIntegerConstantExpr(const ASTContext &Ctx, - SourceLocation *Loc, - bool isEvaluated) const { +bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx, + SourceLocation *Loc, bool isEvaluated) const { assert(!isValueDependent() && "Expression evaluator can't be called on a dependent expression."); - APSInt Value; - - if (Ctx.getLangOpts().CPlusPlus11) { - if (EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc)) - return Value; - return None; - } + if (Ctx.getLangOpts().CPlusPlus11) + return EvaluateCPlusPlus11IntegralConstantExpr(Ctx, this, &Value, Loc); if (!isIntegerConstantExpr(Ctx, Loc)) - return None; + return false; // The only possible side-effects here are due to UB discovered in the // evaluation (for instance, INT_MAX + 1). In such a case, we are still @@ -14912,7 +14906,8 @@ Optional Expr::getIntegerConstantExpr(const ASTContext &Ctx, if (!::EvaluateAsInt(this, ExprResult, Ctx, SE_AllowSideEffects, Info)) llvm_unreachable("ICE cannot be evaluated!"); - return ExprResult.Val.getInt(); + Value = ExprResult.Val.getInt(); + return true; } bool Expr::isCXX98IntegralConstantExpr(const ASTContext &Ctx) const { diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 09579c28061a..529f301e4696 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -1372,9 +1372,9 @@ void MicrosoftCXXNameMangler::mangleIntegerLiteral(const llvm::APSInt &Value, void MicrosoftCXXNameMangler::mangleExpression(const Expr *E) { // See if this is a constant expression. - if (Optional Value = - E->getIntegerConstantExpr(Context.getASTContext())) { - mangleIntegerLiteral(*Value, E->getType()->isBooleanType()); + llvm::APSInt Value; + if (E->isIntegerConstantExpr(Value, Context.getASTContext())) { + mangleIntegerLiteral(Value, E->getType()->isBooleanType()); return; } diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 3588e33714d2..35a93a7889f4 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -4419,9 +4419,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, } else { // If this is required to be a constant, constant fold it so that we // know that the generated intrinsic gets a ConstantInt. - ArgValue = llvm::ConstantInt::get( - getLLVMContext(), - *E->getArg(i)->getIntegerConstantExpr(getContext())); + llvm::APSInt Result; + bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result,getContext()); + assert(IsConst && "Constant arg isn't actually constant?"); + (void)IsConst; + ArgValue = llvm::ConstantInt::get(getLLVMContext(), Result); } // If the intrinsic arg type is diff erent from the builtin arg type @@ -5594,14 +5596,13 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( SmallVectorImpl &Ops, Address PtrOp0, Address PtrOp1, llvm::Triple::ArchType Arch) { // Get the last argument, which specifies the vector type. + llvm::APSInt NeonTypeConst; const Expr *Arg = E->getArg(E->getNumArgs() - 1); - Optional NeonTypeConst = - Arg->getIntegerConstantExpr(getContext()); - if (!NeonTypeConst) + if (!Arg->isIntegerConstantExpr(NeonTypeConst, getContext())) return nullptr; // Determine the type of this overloaded NEON intrinsic. - NeonTypeFlags Type(NeonTypeConst->getZExtValue()); + NeonTypeFlags Type(NeonTypeConst.getZExtValue()); bool Usgn = Type.isUnsigned(); bool Quad = Type.isQuad(); const bool HasLegalHalfType = getTarget().hasLegalHalfType(); @@ -6884,9 +6885,10 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } else { // If this is required to be a constant, constant fold it so that we know // that the generated intrinsic gets a ConstantInt. - Ops.push_back(llvm::ConstantInt::get( - getLLVMContext(), - *E->getArg(i)->getIntegerConstantExpr(getContext()))); + llvm::APSInt Result; + bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); + assert(IsConst && "Constant arg isn't actually constant?"); (void)IsConst; + Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); } } @@ -7097,9 +7099,9 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, // Get the last argument, which specifies the vector type. assert(HasExtraArg); + llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs()-1); - Optional Result = Arg->getIntegerConstantExpr(getContext()); - if (!Result) + if (!Arg->isIntegerConstantExpr(Result, getContext())) return nullptr; if (BuiltinID == ARM::BI__builtin_arm_vcvtr_f || @@ -7112,7 +7114,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, Ty = DoubleTy; // Determine whether this is an unsigned conversion or not. - bool usgn = Result->getZExtValue() == 1; + bool usgn = Result.getZExtValue() == 1; unsigned Int = usgn ? Intrinsic::arm_vcvtru : Intrinsic::arm_vcvtr; // Call the appropriate intrinsic. @@ -7121,7 +7123,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, } // Determine the type of this overloaded NEON intrinsic. - NeonTypeFlags Type = Result->getZExtValue(); + NeonTypeFlags Type(Result.getZExtValue()); bool usgn = Type.isUnsigned(); bool rightShift = false; @@ -7265,7 +7267,11 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, template static Integer GetIntegerConstantValue(const Expr *E, ASTContext &Context) { - return E->getIntegerConstantExpr(Context)->getExtValue(); + llvm::APSInt IntVal; + bool IsConst = E->isIntegerConstantExpr(IntVal, Context); + assert(IsConst && "Sema should have checked this was a constant"); + (void)IsConst; + return IntVal.getExtValue(); } static llvm::Value *SignOrZeroExtend(CGBuilderTy &Builder, llvm::Value *V, @@ -7538,13 +7544,13 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID assert(E->getNumArgs() >= 3); // Get the last argument, which specifies the vector type. + llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs() - 1); - Optional Result = Arg->getIntegerConstantExpr(CGF.getContext()); - if (!Result) + if (!Arg->isIntegerConstantExpr(Result, CGF.getContext())) return nullptr; // Determine the type of this overloaded NEON intrinsic. - NeonTypeFlags Type = Result->getZExtValue(); + NeonTypeFlags Type(Result.getZExtValue()); llvm::VectorType *Ty = GetNeonType(&CGF, Type); if (!Ty) return nullptr; @@ -8930,9 +8936,11 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, } else { // If this is required to be a constant, constant fold it so that we know // that the generated intrinsic gets a ConstantInt. - Ops.push_back(llvm::ConstantInt::get( - getLLVMContext(), - *E->getArg(i)->getIntegerConstantExpr(getContext()))); + llvm::APSInt Result; + bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); + assert(IsConst && "Constant arg isn't actually constant?"); + (void)IsConst; + Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); } } @@ -8947,11 +8955,12 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, return Result; } + llvm::APSInt Result; const Expr *Arg = E->getArg(E->getNumArgs()-1); NeonTypeFlags Type(0); - if (Optional Result = Arg->getIntegerConstantExpr(getContext())) + if (Arg->isIntegerConstantExpr(Result, getContext())) // Determine the type of this overloaded NEON intrinsic. - Type = NeonTypeFlags(Result->getZExtValue()); + Type = NeonTypeFlags(Result.getZExtValue()); bool usgn = Type.isUnsigned(); bool quad = Type.isQuad(); @@ -11782,8 +11791,10 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, // If this is required to be a constant, constant fold it so that we know // that the generated intrinsic gets a ConstantInt. - Ops.push_back(llvm::ConstantInt::get( - getLLVMContext(), *E->getArg(i)->getIntegerConstantExpr(getContext()))); + llvm::APSInt Result; + bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); + assert(IsConst && "Constant arg isn't actually constant?"); (void)IsConst; + Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); } // These exist so that the builtin that takes an immediate can be bounds @@ -15062,8 +15073,11 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, llvm::Type *ResultType = ConvertType(E->getType()); Value *X = EmitScalarExpr(E->getArg(0)); // Constant-fold the M4 and M5 mask arguments. - llvm::APSInt M4 = *E->getArg(1)->getIntegerConstantExpr(getContext()); - llvm::APSInt M5 = *E->getArg(2)->getIntegerConstantExpr(getContext()); + llvm::APSInt M4, M5; + bool IsConstM4 = E->getArg(1)->isIntegerConstantExpr(M4, getContext()); + bool IsConstM5 = E->getArg(2)->isIntegerConstantExpr(M5, getContext()); + assert(IsConstM4 && IsConstM5 && "Constant arg isn't actually constant?"); + (void)IsConstM4; (void)IsConstM5; // Check whether this instance can be represented via a LLVM standard // intrinsic. We only support some combinations of M4 and M5. Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -15118,7 +15132,10 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, Value *X = EmitScalarExpr(E->getArg(0)); Value *Y = EmitScalarExpr(E->getArg(1)); // Constant-fold the M4 mask argument. - llvm::APSInt M4 = *E->getArg(2)->getIntegerConstantExpr(getContext()); + llvm::APSInt M4; + bool IsConstM4 = E->getArg(2)->isIntegerConstantExpr(M4, getContext()); + assert(IsConstM4 && "Constant arg isn't actually constant?"); + (void)IsConstM4; // Check whether this instance can be represented via a LLVM standard // intrinsic. We only support some values of M4. Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -15152,7 +15169,10 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID, Value *X = EmitScalarExpr(E->getArg(0)); Value *Y = EmitScalarExpr(E->getArg(1)); // Constant-fold the M4 mask argument. - llvm::APSInt M4 = *E->getArg(2)->getIntegerConstantExpr(getContext()); + llvm::APSInt M4; + bool IsConstM4 = E->getArg(2)->isIntegerConstantExpr(M4, getContext()); + assert(IsConstM4 && "Constant arg isn't actually constant?"); + (void)IsConstM4; // Check whether this instance can be represented via a LLVM standard // intrinsic. We only support some values of M4. Intrinsic::ID ID = Intrinsic::not_intrinsic; @@ -15819,11 +15839,10 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Address Dst = EmitPointerWithAlignment(E->getArg(0)); Value *Src = EmitScalarExpr(E->getArg(1)); Value *Ldm = EmitScalarExpr(E->getArg(2)); - Optional isColMajorArg = - E->getArg(3)->getIntegerConstantExpr(getContext()); - if (!isColMajorArg) + llvm::APSInt isColMajorArg; + if (!E->getArg(3)->isIntegerConstantExpr(isColMajorArg, getContext())) return nullptr; - bool isColMajor = isColMajorArg->getSExtValue(); + bool isColMajor = isColMajorArg.getSExtValue(); NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID); unsigned IID = isColMajor ? II.IID_col : II.IID_row; if (IID == 0) @@ -15864,11 +15883,10 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Value *Dst = EmitScalarExpr(E->getArg(0)); Address Src = EmitPointerWithAlignment(E->getArg(1)); Value *Ldm = EmitScalarExpr(E->getArg(2)); - Optional isColMajorArg = - E->getArg(3)->getIntegerConstantExpr(getContext()); - if (!isColMajorArg) + llvm::APSInt isColMajorArg; + if (!E->getArg(3)->isIntegerConstantExpr(isColMajorArg, getContext())) return nullptr; - bool isColMajor = isColMajorArg->getSExtValue(); + bool isColMajor = isColMajorArg.getSExtValue(); NVPTXMmaLdstInfo II = getNVPTXMmaLdstInfo(BuiltinID); unsigned IID = isColMajor ? II.IID_col : II.IID_row; if (IID == 0) @@ -15915,20 +15933,16 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { Address SrcA = EmitPointerWithAlignment(E->getArg(1)); Address SrcB = EmitPointerWithAlignment(E->getArg(2)); Address SrcC = EmitPointerWithAlignment(E->getArg(3)); - Optional LayoutArg = - E->getArg(4)->getIntegerConstantExpr(getContext()); - if (!LayoutArg) + llvm::APSInt LayoutArg; + if (!E->getArg(4)->isIntegerConstantExpr(LayoutArg, getContext())) return nullptr; - int Layout = LayoutArg->getSExtValue(); + int Layout = LayoutArg.getSExtValue(); if (Layout < 0 || Layout > 3) return nullptr; llvm::APSInt SatfArg; if (BuiltinID == NVPTX::BI__bmma_m8n8k128_mma_xor_popc_b1) SatfArg = 0; // .b1 does not have satf argument. - else if (Optional OptSatfArg = - E->getArg(5)->getIntegerConstantExpr(getContext())) - SatfArg = *OptSatfArg; - else + else if (!E->getArg(5)->isIntegerConstantExpr(SatfArg, getContext())) return nullptr; bool Satf = SatfArg.getSExtValue(); NVPTXMmaInfo MI = getNVPTXMmaInfo(BuiltinID); @@ -16257,8 +16271,9 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, case WebAssembly::BI__builtin_wasm_extract_lane_i64x2: case WebAssembly::BI__builtin_wasm_extract_lane_f32x4: case WebAssembly::BI__builtin_wasm_extract_lane_f64x2: { - llvm::APSInt LaneConst = - *E->getArg(1)->getIntegerConstantExpr(getContext()); + llvm::APSInt LaneConst; + if (!E->getArg(1)->isIntegerConstantExpr(LaneConst, getContext())) + llvm_unreachable("Constant arg isn't actually constant?"); Value *Vec = EmitScalarExpr(E->getArg(0)); Value *Lane = llvm::ConstantInt::get(getLLVMContext(), LaneConst); Value *Extract = Builder.CreateExtractElement(Vec, Lane); @@ -16284,8 +16299,9 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID, case WebAssembly::BI__builtin_wasm_replace_lane_i64x2: case WebAssembly::BI__builtin_wasm_replace_lane_f32x4: case WebAssembly::BI__builtin_wasm_replace_lane_f64x2: { - llvm::APSInt LaneConst = - *E->getArg(1)->getIntegerConstantExpr(getContext()); + llvm::APSInt LaneConst; + if (!E->getArg(1)->isIntegerConstantExpr(LaneConst, getContext())) + llvm_unreachable("Constant arg isn't actually constant?"); Value *Vec = EmitScalarExpr(E->getArg(0)); Value *Lane = llvm::ConstantInt::get(getLLVMContext(), LaneConst); Value *Val = EmitScalarExpr(E->getArg(2)); diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index ab29e32929ce..9e8770573d70 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3868,17 +3868,15 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, llvm::APSInt ConstLength; if (Length) { // Idx = LowerBound + Length - 1; - if (Optional CL = Length->getIntegerConstantExpr(C)) { - ConstLength = CL->zextOrTrunc(PointerWidthInBits); + if (Length->isIntegerConstantExpr(ConstLength, C)) { + ConstLength = ConstLength.zextOrTrunc(PointerWidthInBits); Length = nullptr; } auto *LowerBound = E->getLowerBound(); llvm::APSInt ConstLowerBound(PointerWidthInBits, /*isUnsigned=*/false); - if (LowerBound) { - if (Optional LB = LowerBound->getIntegerConstantExpr(C)) { - ConstLowerBound = LB->zextOrTrunc(PointerWidthInBits); - LowerBound = nullptr; - } + if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C)) { + ConstLowerBound = ConstLowerBound.zextOrTrunc(PointerWidthInBits); + LowerBound = nullptr; } if (!Length) --ConstLength; @@ -3915,10 +3913,8 @@ LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, : BaseTy; if (auto *VAT = C.getAsVariableArrayType(ArrayTy)) { Length = VAT->getSizeExpr(); - if (Optional L = Length->getIntegerConstantExpr(C)) { - ConstLength = *L; + if (Length->isIntegerConstantExpr(ConstLength, C)) Length = nullptr; - } } else { auto *CAT = C.getAsConstantArrayType(ArrayTy); ConstLength = CAT->getSize(); diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index f9785e4bea5e..b354e810974c 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -300,18 +300,20 @@ void Sema::ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action, // If specified then alignment must be a "small" power of two. unsigned AlignmentVal = 0; if (Alignment) { - Optional Val; + llvm::APSInt Val; // pack(0) is like pack(), which just works out since that is what // we use 0 for in PackAttr. - if (Alignment->isTypeDependent() || Alignment->isValueDependent() || - !(Val = Alignment->getIntegerConstantExpr(Context)) || - !(*Val == 0 || Val->isPowerOf2()) || Val->getZExtValue() > 16) { + if (Alignment->isTypeDependent() || + Alignment->isValueDependent() || + !Alignment->isIntegerConstantExpr(Val, Context) || + !(Val == 0 || Val.isPowerOf2()) || + Val.getZExtValue() > 16) { Diag(PragmaLoc, diag::warn_pragma_pack_invalid_alignment); return; // Ignore } - AlignmentVal = (unsigned)Val->getZExtValue(); + AlignmentVal = (unsigned) Val.getZExtValue(); } if (Action == Sema::PSK_Show) { // Show the current alignment, making sure to show the right value diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index c501c706a97b..efaf36a69306 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2284,7 +2284,10 @@ bool Sema::CheckARMCoprocessorImmediate(const TargetInfo &TI, if (CoprocArg->isTypeDependent() || CoprocArg->isValueDependent()) return false; - llvm::APSInt CoprocNoAP = *CoprocArg->getIntegerConstantExpr(Context); + llvm::APSInt CoprocNoAP; + bool IsICE = CoprocArg->isIntegerConstantExpr(CoprocNoAP, Context); + (void)IsICE; + assert(IsICE && "Coprocossor immediate is not a constant expression"); int64_t CoprocNo = CoprocNoAP.getExtValue(); assert(CoprocNo >= 0 && "Coprocessor immediate must be non-negative"); @@ -2596,7 +2599,8 @@ bool Sema::CheckBPFBuiltinFunctionCall(unsigned BuiltinID, // The second argument needs to be a constant int Arg = TheCall->getArg(1); - if (!Arg->isIntegerConstantExpr(Context)) { + llvm::APSInt Value; + if (!Arg->isIntegerConstantExpr(Value, Context)) { Diag(Arg->getBeginLoc(), diag::err_preserve_field_info_not_const) << 2 << Arg->getSourceRange(); return true; @@ -3194,10 +3198,11 @@ bool Sema::CheckSystemZBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { if (BuiltinID == SystemZ::BI__builtin_tabort) { Expr *Arg = TheCall->getArg(0); - if (Optional AbortCode = Arg->getIntegerConstantExpr(Context)) - if (AbortCode->getSExtValue() >= 0 && AbortCode->getSExtValue() < 256) - return Diag(Arg->getBeginLoc(), diag::err_systemz_invalid_tabort_code) - << Arg->getSourceRange(); + llvm::APSInt AbortCode(32); + if (Arg->isIntegerConstantExpr(AbortCode, Context) && + AbortCode.getSExtValue() >= 0 && AbortCode.getSExtValue() < 256) + return Diag(Arg->getBeginLoc(), diag::err_systemz_invalid_tabort_code) + << Arg->getSourceRange(); } // For intrinsics which take an immediate value as part of the instruction, @@ -4918,21 +4923,21 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, } if (SubExprs.size() >= 2 && Form != Init) { - if (Optional Result = - SubExprs[1]->getIntegerConstantExpr(Context)) - if (!isValidOrderingForOp(Result->getSExtValue(), Op)) - Diag(SubExprs[1]->getBeginLoc(), - diag::warn_atomic_op_has_invalid_memory_order) - << SubExprs[1]->getSourceRange(); + llvm::APSInt Result(32); + if (SubExprs[1]->isIntegerConstantExpr(Result, Context) && + !isValidOrderingForOp(Result.getSExtValue(), Op)) + Diag(SubExprs[1]->getBeginLoc(), + diag::warn_atomic_op_has_invalid_memory_order) + << SubExprs[1]->getSourceRange(); } if (auto ScopeModel = AtomicExpr::getScopeModel(Op)) { auto *Scope = Args[Args.size() - 1]; - if (Optional Result = - Scope->getIntegerConstantExpr(Context)) { - if (!ScopeModel->isValid(Result->getZExtValue())) - Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope) - << Scope->getSourceRange(); + llvm::APSInt Result(32); + if (Scope->isIntegerConstantExpr(Result, Context) && + !ScopeModel->isValid(Result.getZExtValue())) { + Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope) + << Scope->getSourceRange(); } SubExprs.push_back(Scope); } @@ -5800,7 +5805,8 @@ bool Sema::SemaBuiltinVSX(CallExpr *TheCall) { << TheCall->getSourceRange(); // Check the third argument is a compile time constant - if (!TheCall->getArg(2)->isIntegerConstantExpr(Context)) + llvm::APSInt Value; + if(!TheCall->getArg(2)->isIntegerConstantExpr(Value, Context)) return Diag(TheCall->getBeginLoc(), diag::err_vsx_builtin_nonconstant_argument) << 3 /* argument index */ << TheCall->getDirectCallee() @@ -5895,18 +5901,17 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) { TheCall->getArg(i)->isValueDependent()) continue; - Optional Result; - if (!(Result = TheCall->getArg(i)->getIntegerConstantExpr(Context))) + llvm::APSInt Result(32); + if (!TheCall->getArg(i)->isIntegerConstantExpr(Result, Context)) return ExprError(Diag(TheCall->getBeginLoc(), diag::err_shufflevector_nonconstant_argument) << TheCall->getArg(i)->getSourceRange()); // Allow -1 which will be translated to undef in the IR. - if (Result->isSigned() && Result->isAllOnesValue()) + if (Result.isSigned() && Result.isAllOnesValue()) continue; - if (Result->getActiveBits() > 64 || - Result->getZExtValue() >= numElements * 2) + if (Result.getActiveBits() > 64 || Result.getZExtValue() >= numElements*2) return ExprError(Diag(TheCall->getBeginLoc(), diag::err_shufflevector_argument_too_large) << TheCall->getArg(i)->getSourceRange()); @@ -6153,11 +6158,10 @@ bool Sema::SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, if (Arg->isTypeDependent() || Arg->isValueDependent()) return false; - Optional R; - if (!(R = Arg->getIntegerConstantExpr(Context))) + if (!Arg->isIntegerConstantExpr(Result, Context)) return Diag(TheCall->getBeginLoc(), diag::err_constant_integer_arg_type) << FDecl->getDeclName() << Arg->getSourceRange(); - Result = *R; + return false; } @@ -10317,15 +10321,14 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, // If the shift amount is a positive constant, drop the width by // that much. - if (Optional shift = - BO->getRHS()->getIntegerConstantExpr(C)) { - if (shift->isNonNegative()) { - unsigned zext = shift->getZExtValue(); - if (zext >= L.Width) - L.Width = (L.NonNegative ? 0 : 1); - else - L.Width -= zext; - } + llvm::APSInt shift; + if (BO->getRHS()->isIntegerConstantExpr(shift, C) && + shift.isNonNegative()) { + unsigned zext = shift.getZExtValue(); + if (zext >= L.Width) + L.Width = (L.NonNegative ? 0 : 1); + else + L.Width -= zext; } return L; @@ -10349,9 +10352,9 @@ static IntRange GetExprRange(ASTContext &C, const Expr *E, unsigned MaxWidth, IntRange L = GetExprRange(C, BO->getLHS(), opWidth, InConstantContext); // If the divisor is constant, use that. - if (Optional divisor = - BO->getRHS()->getIntegerConstantExpr(C)) { - unsigned log2 = divisor->logBase2(); // floor(log_2(divisor)) + llvm::APSInt divisor; + if (BO->getRHS()->isIntegerConstantExpr(divisor, C)) { + unsigned log2 = divisor.logBase2(); // floor(log_2(divisor)) if (log2 >= L.Width) L.Width = (L.NonNegative ? 0 : 1); else @@ -10783,20 +10786,23 @@ static void AnalyzeComparison(Sema &S, BinaryOperator *E) { Expr *RHS = E->getRHS(); if (T->isIntegralType(S.Context)) { - Optional RHSValue = RHS->getIntegerConstantExpr(S.Context); - Optional LHSValue = LHS->getIntegerConstantExpr(S.Context); + llvm::APSInt RHSValue; + llvm::APSInt LHSValue; + + bool IsRHSIntegralLiteral = RHS->isIntegerConstantExpr(RHSValue, S.Context); + bool IsLHSIntegralLiteral = LHS->isIntegerConstantExpr(LHSValue, S.Context); // We don't care about expressions whose result is a constant. - if (RHSValue && LHSValue) + if (IsRHSIntegralLiteral && IsLHSIntegralLiteral) return AnalyzeImpConvsInComparison(S, E); // We only care about expressions where just one side is literal - if ((bool)RHSValue ^ (bool)LHSValue) { + if (IsRHSIntegralLiteral ^ IsLHSIntegralLiteral) { // Is the constant on the RHS or LHS? - const bool RhsConstant = (bool)RHSValue; + const bool RhsConstant = IsRHSIntegralLiteral; Expr *Const = RhsConstant ? RHS : LHS; Expr *Other = RhsConstant ? LHS : RHS; - const llvm::APSInt &Value = RhsConstant ? *RHSValue : *LHSValue; + const llvm::APSInt &Value = RhsConstant ? RHSValue : LHSValue; // Check whether an integer constant comparison results in a value // of 'true' or 'false'. @@ -11754,8 +11760,8 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, if (SourcePrecision > 0 && TargetPrecision > 0 && SourcePrecision > TargetPrecision) { - if (Optional SourceInt = - E->getIntegerConstantExpr(S.Context)) { + llvm::APSInt SourceInt; + if (E->isIntegerConstantExpr(SourceInt, S.Context)) { // If the source integer is a constant, convert it to the target // floating point type. Issue a warning if the value changes // during the whole conversion. @@ -11763,11 +11769,11 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T, S.Context.getFloatTypeSemantics(QualType(TargetBT, 0))); llvm::APFloat::opStatus ConversionStatus = TargetFloatValue.convertFromAPInt( - *SourceInt, SourceBT->isSignedInteger(), + SourceInt, SourceBT->isSignedInteger(), llvm::APFloat::rmNearestTiesToEven); if (ConversionStatus != llvm::APFloat::opOK) { - std::string PrettySourceValue = SourceInt->toString(10); + std::string PrettySourceValue = SourceInt.toString(10); SmallString<32> PrettyTargetValue; TargetFloatValue.toString(PrettyTargetValue, TargetPrecision); @@ -14118,10 +14124,9 @@ namespace { return; if (Expr *RHS = BinOp->getRHS()) { RHS = RHS->IgnoreParenCasts(); - Optional Value; + llvm::APSInt Value; VarWillBeReased = - (RHS && (Value = RHS->getIntegerConstantExpr(Context)) && - *Value == 0); + (RHS && RHS->isIntegerConstantExpr(Value, Context) && Value == 0); } } } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index dc0f3d68fde3..f5e375134c29 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -13141,20 +13141,20 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) { if (!MagicValueExpr) { continue; } - Optional MagicValueInt; - if (!(MagicValueInt = MagicValueExpr->getIntegerConstantExpr(Context))) { + llvm::APSInt MagicValueInt; + if (!MagicValueExpr->isIntegerConstantExpr(MagicValueInt, Context)) { Diag(I->getRange().getBegin(), diag::err_type_tag_for_datatype_not_ice) << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); continue; } - if (MagicValueInt->getActiveBits() > 64) { + if (MagicValueInt.getActiveBits() > 64) { Diag(I->getRange().getBegin(), diag::err_type_tag_for_datatype_too_large) << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange(); continue; } - uint64_t MagicValue = MagicValueInt->getZExtValue(); + uint64_t MagicValue = MagicValueInt.getZExtValue(); RegisterTypeTagForDatatype(I->getArgumentKind(), MagicValue, I->getMatchingCType(), diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ece93cbd6a9b..1a0594512a60 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -240,9 +240,9 @@ template static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx = UINT_MAX, bool StrictlyUnsigned = false) { - Optional I = llvm::APSInt(32); + llvm::APSInt I(32); if (Expr->isTypeDependent() || Expr->isValueDependent() || - !(I = Expr->getIntegerConstantExpr(S.Context))) { + !Expr->isIntegerConstantExpr(I, S.Context)) { if (Idx != UINT_MAX) S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) << &AI << Idx << AANT_ArgumentIntegerConstant @@ -253,19 +253,19 @@ static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, return false; } - if (!I->isIntN(32)) { + if (!I.isIntN(32)) { S.Diag(Expr->getExprLoc(), diag::err_ice_too_large) - << I->toString(10, false) << 32 << /* Unsigned */ 1; + << I.toString(10, false) << 32 << /* Unsigned */ 1; return false; } - if (StrictlyUnsigned && I->isSigned() && I->isNegative()) { + if (StrictlyUnsigned && I.isSigned() && I.isNegative()) { S.Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer) << &AI << /*non-negative*/ 1; return false; } - Val = (uint32_t)I->getZExtValue(); + Val = (uint32_t)I.getZExtValue(); return true; } @@ -332,16 +332,16 @@ static bool checkFunctionOrMethodParameterIndex( unsigned NumParams = (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam; - Optional IdxInt; + llvm::APSInt IdxInt; if (IdxExpr->isTypeDependent() || IdxExpr->isValueDependent() || - !(IdxInt = IdxExpr->getIntegerConstantExpr(S.Context))) { + !IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) { S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) << &AI << AttrArgNum << AANT_ArgumentIntegerConstant << IdxExpr->getSourceRange(); return false; } - unsigned IdxSource = IdxInt->getLimitedValue(UINT_MAX); + unsigned IdxSource = IdxInt.getLimitedValue(UINT_MAX); if (IdxSource < 1 || (!IV && IdxSource > NumParams)) { S.Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds) << &AI << AttrArgNum << IdxExpr->getSourceRange(); @@ -1605,8 +1605,8 @@ void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, } if (!E->isValueDependent()) { - Optional I = llvm::APSInt(64); - if (!(I = E->getIntegerConstantExpr(Context))) { + llvm::APSInt I(64); + if (!E->isIntegerConstantExpr(I, Context)) { if (OE) Diag(AttrLoc, diag::err_attribute_argument_n_type) << &TmpAttr << 1 << AANT_ArgumentIntegerConstant @@ -1618,22 +1618,27 @@ void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, return; } - if (!I->isPowerOf2()) { + if (!I.isPowerOf2()) { Diag(AttrLoc, diag::err_alignment_not_power_of_two) << E->getSourceRange(); return; } - if (*I > Sema::MaximumAlignment) + if (I > Sema::MaximumAlignment) Diag(CI.getLoc(), diag::warn_assume_aligned_too_great) << CI.getRange() << Sema::MaximumAlignment; } - if (OE && !OE->isValueDependent() && !OE->isIntegerConstantExpr(Context)) { - Diag(AttrLoc, diag::err_attribute_argument_n_type) - << &TmpAttr << 2 << AANT_ArgumentIntegerConstant - << OE->getSourceRange(); - return; + if (OE) { + if (!OE->isValueDependent()) { + llvm::APSInt I(64); + if (!OE->isIntegerConstantExpr(I, Context)) { + Diag(AttrLoc, diag::err_attribute_argument_n_type) + << &TmpAttr << 2 << AANT_ArgumentIntegerConstant + << OE->getSourceRange(); + return; + } + } } D->addAttr(::new (Context) AssumeAlignedAttr(Context, CI, E, OE)); @@ -2724,36 +2729,36 @@ static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { unsigned sentinel = (unsigned)SentinelAttr::DefaultSentinel; if (AL.getNumArgs() > 0) { Expr *E = AL.getArgAsExpr(0); - Optional Idx = llvm::APSInt(32); + llvm::APSInt Idx(32); if (E->isTypeDependent() || E->isValueDependent() || - !(Idx = E->getIntegerConstantExpr(S.Context))) { + !E->isIntegerConstantExpr(Idx, S.Context)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL << 1 << AANT_ArgumentIntegerConstant << E->getSourceRange(); return; } - if (Idx->isSigned() && Idx->isNegative()) { + if (Idx.isSigned() && Idx.isNegative()) { S.Diag(AL.getLoc(), diag::err_attribute_sentinel_less_than_zero) << E->getSourceRange(); return; } - sentinel = Idx->getZExtValue(); + sentinel = Idx.getZExtValue(); } unsigned nullPos = (unsigned)SentinelAttr::DefaultNullPos; if (AL.getNumArgs() > 1) { Expr *E = AL.getArgAsExpr(1); - Optional Idx = llvm::APSInt(32); + llvm::APSInt Idx(32); if (E->isTypeDependent() || E->isValueDependent() || - !(Idx = E->getIntegerConstantExpr(S.Context))) { + !E->isIntegerConstantExpr(Idx, S.Context)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL << 2 << AANT_ArgumentIntegerConstant << E->getSourceRange(); return; } - nullPos = Idx->getZExtValue(); + nullPos = Idx.getZExtValue(); - if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) { + if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) { // FIXME: This error message could be improved, it would be nice // to say what the bounds actually are. S.Diag(AL.getLoc(), diag::err_attribute_sentinel_not_zero_or_one) @@ -4828,19 +4833,19 @@ static Expr *makeLaunchBoundsArgExpr(Sema &S, Expr *E, if (E->isValueDependent()) return E; - Optional I = llvm::APSInt(64); - if (!(I = E->getIntegerConstantExpr(S.Context))) { + llvm::APSInt I(64); + if (!E->isIntegerConstantExpr(I, S.Context)) { S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type) << &AL << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange(); return nullptr; } // Make sure we can fit it in 32 bits. - if (!I->isIntN(32)) { - S.Diag(E->getExprLoc(), diag::err_ice_too_large) - << I->toString(10, false) << 32 << /* Unsigned */ 1; + if (!I.isIntN(32)) { + S.Diag(E->getExprLoc(), diag::err_ice_too_large) << I.toString(10, false) + << 32 << /* Unsigned */ 1; return nullptr; } - if (*I < 0) + if (I < 0) S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative) << &AL << Idx << E->getSourceRange(); @@ -5681,18 +5686,18 @@ static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { } Expr *NumParamsExpr = static_cast(AL.getArgAsExpr(0)); - Optional NumParams = llvm::APSInt(32); - if (!(NumParams = NumParamsExpr->getIntegerConstantExpr(S.Context))) { + llvm::APSInt NumParams(32); + if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL << AANT_ArgumentIntegerConstant << NumParamsExpr->getSourceRange(); return; } // The argument should be in range 0..63. - unsigned Num = NumParams->getLimitedValue(255); + unsigned Num = NumParams.getLimitedValue(255); if (Num > 63) { S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) - << AL << (int)NumParams->getSExtValue() + << AL << (int)NumParams.getSExtValue() << NumParamsExpr->getSourceRange(); return; } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e3aa817c6224..d885920b6c14 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2073,29 +2073,29 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // per CWG1464. Otherwise, if it's not a constant, we must have an // unparenthesized array type. if (!(*ArraySize)->isValueDependent()) { + llvm::APSInt Value; // We've already performed any required implicit conversion to integer or // unscoped enumeration type. // FIXME: Per CWG1464, we are required to check the value prior to // converting to size_t. This will never find a negative array size in // C++14 onwards, because Value is always unsigned here! - if (Optional Value = - (*ArraySize)->getIntegerConstantExpr(Context)) { - if (Value->isSigned() && Value->isNegative()) { + if ((*ArraySize)->isIntegerConstantExpr(Value, Context)) { + if (Value.isSigned() && Value.isNegative()) { return ExprError(Diag((*ArraySize)->getBeginLoc(), diag::err_typecheck_negative_array_size) << (*ArraySize)->getSourceRange()); } if (!AllocType->isDependentType()) { - unsigned ActiveSizeBits = ConstantArrayType::getNumAddressingBits( - Context, AllocType, *Value); + unsigned ActiveSizeBits = + ConstantArrayType::getNumAddressingBits(Context, AllocType, Value); if (ActiveSizeBits > ConstantArrayType::getMaxSizeBits(Context)) return ExprError( Diag((*ArraySize)->getBeginLoc(), diag::err_array_too_large) - << Value->toString(10) << (*ArraySize)->getSourceRange()); + << Value.toString(10) << (*ArraySize)->getSourceRange()); } - KnownArraySize = Value->getZExtValue(); + KnownArraySize = Value.getZExtValue(); } else if (TypeIdParens.isValid()) { // Can't have dynamic array size when the type-id is in parentheses. Diag((*ArraySize)->getBeginLoc(), diag::ext_new_paren_array_nonconst) diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index d1ddf1072417..b27abb54c170 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -5989,7 +5989,8 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG, // Deal with non-constant score and user condition expressions. auto HandleNonConstantScoresAndConditions = [this](Expr *&E, bool IsScore) -> bool { - if (!E || E->isIntegerConstantExpr(Context)) + llvm::APSInt Result; + if (!E || E->isIntegerConstantExpr(Result, Context)) return false; if (IsScore) { @@ -6475,14 +6476,14 @@ bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) { // loop. If test-expr is of form b relational-op var and relational-op is // > or >= then incr-expr must cause var to increase on each iteration of // the loop. - Optional Result = - NewStep->getIntegerConstantExpr(SemaRef.Context); + llvm::APSInt Result; + bool IsConstant = NewStep->isIntegerConstantExpr(Result, SemaRef.Context); bool IsUnsigned = !NewStep->getType()->hasSignedIntegerRepresentation(); bool IsConstNeg = - Result && Result->isSigned() && (Subtract != Result->isNegative()); + IsConstant && Result.isSigned() && (Subtract != Result.isNegative()); bool IsConstPos = - Result && Result->isSigned() && (Subtract == Result->isNegative()); - bool IsConstZero = Result && !Result->getBoolValue(); + IsConstant && Result.isSigned() && (Subtract == Result.isNegative()); + bool IsConstZero = IsConstant && !Result.getBoolValue(); // != with increment is treated as <; != with decrement is treated as > if (!TestIsLessOp.hasValue()) @@ -7913,9 +7914,9 @@ static ExprResult widenIterationCount(unsigned Bits, Expr *E, Sema &SemaRef) { static bool fitsInto(unsigned Bits, bool Signed, const Expr *E, Sema &SemaRef) { if (E == nullptr) return false; - if (Optional Result = - E->getIntegerConstantExpr(SemaRef.Context)) - return Signed ? Result->isSignedIntN(Bits) : Result->isIntN(Bits); + llvm::APSInt Result; + if (E->isIntegerConstantExpr(Result, SemaRef.Context)) + return Signed ? Result.isSignedIntN(Bits) : Result.isIntN(Bits); return false; } @@ -8188,7 +8189,9 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr, // Calculate the last iteration number beforehand instead of doing this on // each iteration. Do not do this if the number of iterations may be kfold-ed. - bool IsConstant = LastIteration.get()->isIntegerConstantExpr(SemaRef.Context); + llvm::APSInt Result; + bool IsConstant = + LastIteration.get()->isIntegerConstantExpr(Result, SemaRef.Context); ExprResult CalcLastIteration; if (!IsConstant) { ExprResult SaveRef = @@ -12579,16 +12582,15 @@ isNonNegativeIntegerValue(Expr *&ValExpr, Sema &SemaRef, OpenMPClauseKind CKind, ValExpr = Value.get(); // The expression must evaluate to a non-negative integer value. - if (Optional Result = - ValExpr->getIntegerConstantExpr(SemaRef.Context)) { - if (Result->isSigned() && - !((!StrictlyPositive && Result->isNonNegative()) || - (StrictlyPositive && Result->isStrictlyPositive()))) { - SemaRef.Diag(Loc, diag::err_omp_negative_expression_in_clause) - << getOpenMPClauseName(CKind) << (StrictlyPositive ? 1 : 0) - << ValExpr->getSourceRange(); - return false; - } + llvm::APSInt Result; + if (ValExpr->isIntegerConstantExpr(Result, SemaRef.Context) && + Result.isSigned() && + !((!StrictlyPositive && Result.isNonNegative()) || + (StrictlyPositive && Result.isStrictlyPositive()))) { + SemaRef.Diag(Loc, diag::err_omp_negative_expression_in_clause) + << getOpenMPClauseName(CKind) << (StrictlyPositive ? 1 : 0) + << ValExpr->getSourceRange(); + return false; } if (!BuildCapture) return true; @@ -13213,9 +13215,9 @@ OMPClause *Sema::ActOnOpenMPScheduleClause( // OpenMP [2.7.1, Restrictions] // chunk_size must be a loop invariant integer expression with a positive // value. - if (Optional Result = - ValExpr->getIntegerConstantExpr(Context)) { - if (Result->isSigned() && !Result->isStrictlyPositive()) { + llvm::APSInt Result; + if (ValExpr->isIntegerConstantExpr(Result, Context)) { + if (Result.isSigned() && !Result.isStrictlyPositive()) { Diag(ChunkSizeLoc, diag::err_omp_negative_expression_in_clause) << "schedule" << 1 << ChunkSize->getSourceRange(); return nullptr; @@ -15686,12 +15688,12 @@ OMPClause *Sema::ActOnOpenMPLinearClause( // Warn about zero linear step (it would be probably better specified as // making corresponding variables 'const'). - if (Optional Result = - StepExpr->getIntegerConstantExpr(Context)) { - if (!Result->isNegative() && !Result->isStrictlyPositive()) - Diag(StepLoc, diag::warn_omp_linear_step_zero) - << Vars[0] << (Vars.size() > 1); - } else if (CalcStep.isUsable()) { + llvm::APSInt Result; + bool IsConstant = StepExpr->isIntegerConstantExpr(Result, Context); + if (IsConstant && !Result.isNegative() && !Result.isStrictlyPositive()) + Diag(StepLoc, diag::warn_omp_linear_step_zero) << Vars[0] + << (Vars.size() > 1); + if (!IsConstant && CalcStep.isUsable()) { // Calculate the step beforehand instead of doing this on each iteration. // (This is not used if the number of iterations may be kfold-ed). CalcStepExpr = CalcStep.get(); @@ -18223,9 +18225,9 @@ OMPClause *Sema::ActOnOpenMPDistScheduleClause( // OpenMP [2.7.1, Restrictions] // chunk_size must be a loop invariant integer expression with a positive // value. - if (Optional Result = - ValExpr->getIntegerConstantExpr(Context)) { - if (Result->isSigned() && !Result->isStrictlyPositive()) { + llvm::APSInt Result; + if (ValExpr->isIntegerConstantExpr(Result, Context)) { + if (Result.isSigned() && !Result.isStrictlyPositive()) { Diag(ChunkSizeLoc, diag::err_omp_negative_expression_in_clause) << "dist_schedule" << ChunkSize->getSourceRange(); return nullptr; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 7c6acf011d57..8635397f4806 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -346,6 +346,7 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( ToType->isRealFloatingType()) { if (IgnoreFloatToIntegralConversion) return NK_Not_Narrowing; + llvm::APSInt IntConstantValue; const Expr *Initializer = IgnoreNarrowingConversion(Ctx, Converted); assert(Initializer && "Unknown conversion expression"); @@ -353,20 +354,19 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( if (Initializer->isValueDependent()) return NK_Dependent_Narrowing; - if (Optional IntConstantValue = - Initializer->getIntegerConstantExpr(Ctx)) { + if (Initializer->isIntegerConstantExpr(IntConstantValue, Ctx)) { // Convert the integer to the floating type. llvm::APFloat Result(Ctx.getFloatTypeSemantics(ToType)); - Result.convertFromAPInt(*IntConstantValue, IntConstantValue->isSigned(), + Result.convertFromAPInt(IntConstantValue, IntConstantValue.isSigned(), llvm::APFloat::rmNearestTiesToEven); // And back. - llvm::APSInt ConvertedValue = *IntConstantValue; + llvm::APSInt ConvertedValue = IntConstantValue; bool ignored; Result.convertToInteger(ConvertedValue, llvm::APFloat::rmTowardZero, &ignored); // If the resulting value is diff erent, this was a narrowing conversion. - if (*IntConstantValue != ConvertedValue) { - ConstantValue = APValue(*IntConstantValue); + if (IntConstantValue != ConvertedValue) { + ConstantValue = APValue(IntConstantValue); ConstantType = Initializer->getType(); return NK_Constant_Narrowing; } @@ -430,18 +430,17 @@ NarrowingKind StandardConversionSequence::getNarrowingKind( (FromWidth == ToWidth && FromSigned != ToSigned) || (FromSigned && !ToSigned)) { // Not all values of FromType can be represented in ToType. + llvm::APSInt InitializerValue; const Expr *Initializer = IgnoreNarrowingConversion(Ctx, Converted); // If it's value-dependent, we can't tell whether it's narrowing. if (Initializer->isValueDependent()) return NK_Dependent_Narrowing; - Optional OptInitializerValue; - if (!(OptInitializerValue = Initializer->getIntegerConstantExpr(Ctx))) { + if (!Initializer->isIntegerConstantExpr(InitializerValue, Ctx)) { // Such conversions on variables are always narrowing. return NK_Variable_Narrowing; } - llvm::APSInt &InitializerValue = *OptInitializerValue; bool Narrowing = false; if (FromWidth < ToWidth) { // Negative -> unsigned is narrowing. Otherwise, more bits is never @@ -2184,22 +2183,21 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) { // compatibility. if (From) { if (FieldDecl *MemberDecl = From->getSourceBitField()) { - Optional BitWidth; + llvm::APSInt BitWidth; if (FromType->isIntegralType(Context) && - (BitWidth = - MemberDecl->getBitWidth()->getIntegerConstantExpr(Context))) { - llvm::APSInt ToSize(BitWidth->getBitWidth(), BitWidth->isUnsigned()); + MemberDecl->getBitWidth()->isIntegerConstantExpr(BitWidth, Context)) { + llvm::APSInt ToSize(BitWidth.getBitWidth(), BitWidth.isUnsigned()); ToSize = Context.getTypeSize(ToType); // Are we promoting to an int from a bitfield that fits in an int? - if (*BitWidth < ToSize || - (FromType->isSignedIntegerType() && *BitWidth <= ToSize)) { + if (BitWidth < ToSize || + (FromType->isSignedIntegerType() && BitWidth <= ToSize)) { return To->getKind() == BuiltinType::Int; } // Are we promoting to an unsigned int from an unsigned bitfield // that fits into an unsigned int? - if (FromType->isUnsignedIntegerType() && *BitWidth <= ToSize) { + if (FromType->isUnsignedIntegerType() && BitWidth <= ToSize) { return To->getKind() == BuiltinType::UInt; } diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index c7b97ec4d975..e9d3c755eb23 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -335,15 +335,15 @@ static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, if (NumArgs == 1) { Expr *E = A.getArgAsExpr(0); - Optional ArgVal; + llvm::APSInt ArgVal(32); - if (!(ArgVal = E->getIntegerConstantExpr(S.Context))) { + if (!E->isIntegerConstantExpr(ArgVal, S.Context)) { S.Diag(A.getLoc(), diag::err_attribute_argument_type) << A << AANT_ArgumentIntegerConstant << E->getSourceRange(); return nullptr; } - int Val = ArgVal->getSExtValue(); + int Val = ArgVal.getSExtValue(); if (Val <= 0) { S.Diag(A.getRange().getBegin(), diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 13426cbf2db4..b8f7f1a58159 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2476,8 +2476,8 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr, return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc, VectorType::GenericVector); - Optional VecSize = SizeExpr->getIntegerConstantExpr(Context); - if (!VecSize) { + llvm::APSInt VecSize(32); + if (!SizeExpr->isIntegerConstantExpr(VecSize, Context)) { Diag(AttrLoc, diag::err_attribute_argument_type) << "vector_size" << AANT_ArgumentIntegerConstant << SizeExpr->getSourceRange(); @@ -2489,13 +2489,13 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr, VectorType::GenericVector); // vecSize is specified in bytes - convert to bits. - if (!VecSize->isIntN(61)) { + if (!VecSize.isIntN(61)) { // Bit size will overflow uint64. Diag(AttrLoc, diag::err_attribute_size_too_large) << SizeExpr->getSourceRange() << "vector"; return QualType(); } - uint64_t VectorSizeBits = VecSize->getZExtValue() * 8; + uint64_t VectorSizeBits = VecSize.getZExtValue() * 8; unsigned TypeSize = static_cast(Context.getTypeSize(CurType)); if (VectorSizeBits == 0) { @@ -2540,8 +2540,8 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize, } if (!ArraySize->isTypeDependent() && !ArraySize->isValueDependent()) { - Optional vecSize = ArraySize->getIntegerConstantExpr(Context); - if (!vecSize) { + llvm::APSInt vecSize(32); + if (!ArraySize->isIntegerConstantExpr(vecSize, Context)) { Diag(AttrLoc, diag::err_attribute_argument_type) << "ext_vector_type" << AANT_ArgumentIntegerConstant << ArraySize->getSourceRange(); @@ -2555,7 +2555,7 @@ QualType Sema::BuildExtVectorType(QualType T, Expr *ArraySize, } // Unlike gcc's vector_size attribute, the size is specified as the // number of elements, not the number of bytes. - unsigned vectorSize = static_cast(vecSize->getZExtValue()); + unsigned vectorSize = static_cast(vecSize.getZExtValue()); if (vectorSize == 0) { Diag(AttrLoc, diag::err_attribute_zero_size) @@ -6254,15 +6254,13 @@ static bool BuildAddressSpaceIndex(Sema &S, LangAS &ASIdx, const Expr *AddrSpace, SourceLocation AttrLoc) { if (!AddrSpace->isValueDependent()) { - Optional OptAddrSpace = - AddrSpace->getIntegerConstantExpr(S.Context); - if (!OptAddrSpace) { + llvm::APSInt addrSpace(32); + if (!AddrSpace->isIntegerConstantExpr(addrSpace, S.Context)) { S.Diag(AttrLoc, diag::err_attribute_argument_type) << "'address_space'" << AANT_ArgumentIntegerConstant << AddrSpace->getSourceRange(); return false; } - llvm::APSInt &addrSpace = *OptAddrSpace; // Bounds checking. if (addrSpace.isSigned()) { @@ -7714,9 +7712,9 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, } // The number of elements must be an ICE. Expr *numEltsExpr = static_cast(Attr.getArgAsExpr(0)); - Optional numEltsInt; + llvm::APSInt numEltsInt(32); if (numEltsExpr->isTypeDependent() || numEltsExpr->isValueDependent() || - !(numEltsInt = numEltsExpr->getIntegerConstantExpr(S.Context))) { + !numEltsExpr->isIntegerConstantExpr(numEltsInt, S.Context)) { S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr << AANT_ArgumentIntegerConstant << numEltsExpr->getSourceRange(); @@ -7732,7 +7730,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, // The total size of the vector must be 64 or 128 bits. unsigned typeSize = static_cast(S.Context.getTypeSize(CurType)); - unsigned numElts = static_cast(numEltsInt->getZExtValue()); + unsigned numElts = static_cast(numEltsInt.getZExtValue()); unsigned vecSize = typeSize * numElts; if (vecSize != 64 && vecSize != 128) { S.Diag(Attr.getLoc(), diag::err_attribute_bad_neon_vector_size) << CurType; From cfe-commits at lists.llvm.org Sun Jul 12 21:03:52 2020 From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits) Date: Sun, 12 Jul 2020 21:03:52 -0700 (PDT) Subject: [clang] 7844366 - [OpenMP] Add firstprivate as a default data-sharing attribute to clang Message-ID: <5f0bdd28.1c69fb81.8f648.f27c@mx.google.com> Author: Atmn Patel Date: 2020-07-12T23:01:40-05:00 New Revision: 78443666bc18a6957d279a0f58319c8a3e57771a URL: https://github.com/llvm/llvm-project/commit/78443666bc18a6957d279a0f58319c8a3e57771a DIFF: https://github.com/llvm/llvm-project/commit/78443666bc18a6957d279a0f58319c8a3e57771a.diff LOG: [OpenMP] Add firstprivate as a default data-sharing attribute to clang This implements the default(firstprivate) clause as defined in OpenMP Technical Report 8 (2.22.4). Reviewed By: jdoerfert, ABataev Differential Revision: https://reviews.llvm.org/D75591 Added: Modified: clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp clang/docs/LibASTMatchersReference.html clang/include/clang/ASTMatchers/ASTMatchers.h clang/include/clang/Basic/DiagnosticParseKinds.td clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/SemaOpenMP.cpp clang/test/OpenMP/distribute_parallel_for_default_messages.cpp clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/driver.c clang/test/OpenMP/parallel_default_messages.cpp clang/test/OpenMP/parallel_for_default_messages.cpp clang/test/OpenMP/parallel_for_simd_default_messages.cpp clang/test/OpenMP/parallel_master_codegen.cpp clang/test/OpenMP/parallel_master_default_messages.cpp clang/test/OpenMP/parallel_sections_default_messages.cpp clang/test/OpenMP/target_parallel_default_messages.cpp clang/test/OpenMP/target_parallel_for_default_messages.cpp clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp clang/test/OpenMP/target_teams_default_messages.cpp clang/test/OpenMP/target_teams_distribute_default_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/task_default_messages.cpp clang/test/OpenMP/task_messages.cpp clang/test/OpenMP/teams_default_messages.cpp clang/test/OpenMP/teams_distribute_default_messages.cpp clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp clang/test/OpenMP/teams_distribute_simd_default_messages.cpp clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp clang/unittests/ASTMatchers/ASTMatchersTest.h llvm/include/llvm/Frontend/OpenMP/OMPKinds.def Removed: ################################################################################ diff --git a/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst b/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst index 4223a10bd6e9..77114100ba1c 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst @@ -51,3 +51,12 @@ Example // WARNING: OpenMP directive ``parallel`` specifies ``default(shared)`` // clause. Consider using ``default(none)`` clause instead. } + + // ``parallel`` directive can have ``default`` clause, and said clause is + // specified, but with ``firstprivate`` kind, which is not ``none``, diagnose. + void p0_3() { + #pragma omp parallel default(firstprivate) + ; + // WARNING: OpenMP directive ``parallel`` specifies ``default(firstprivate)`` + // clause. Consider using ``default(none)`` clause instead. + } diff --git a/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp b/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp index 35d2d17b1e0e..d1d3b0e441f3 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp @@ -1,5 +1,5 @@ -// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -fopenmp=libomp -fopenmp-version=40 -// RUN: %check_clang_tidy -std=c11 %s openmp-use-default-none %t -- -- -x c -fopenmp=libomp -fopenmp-version=40 +// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -fopenmp=libomp -fopenmp-version=51 +// RUN: %check_clang_tidy -std=c11 %s openmp-use-default-none %t -- -- -x c -fopenmp=libomp -fopenmp-version=51 //----------------------------------------------------------------------------// // Null cases. @@ -42,6 +42,15 @@ void p0_2() { // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified here } +// 'parallel' directive can have 'default' clause, and said clause specified, +// but with 'firstprivate' kind, which is not 'none', diagnose. +void p0_3() { +#pragma omp parallel default(firstprivate) + ; + // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead + // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified here +} + // 'task' directive. // 'task' directive can have 'default' clause, but said clause is not @@ -68,6 +77,15 @@ void p1_2() { // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified here } +// 'task' directive can have 'default' clause, and said clause specified, +// but with 'firstprivate' kind, which is not 'none', diagnose. +void p1_3() { +#pragma omp task default(firstprivate) + ; + // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead + // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified here +} + // 'teams' directive. (has to be inside of 'target' directive) // 'teams' directive can have 'default' clause, but said clause is not @@ -97,6 +115,16 @@ void p2_2() { // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified here } +// 'teams' directive can have 'default' clause, and said clause specified, +// but with 'firstprivate' kind, which is not 'none', diagnose. +void p2_3() { +#pragma omp target +#pragma omp teams default(firstprivate) + ; + // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead + // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified here +} + // 'taskloop' directive. // 'taskloop' directive can have 'default' clause, but said clause is not @@ -126,6 +154,16 @@ void p3_2(const int a) { // CHECK-NOTES: :[[@LINE-4]]:22: note: existing 'default' clause specified here } +// 'taskloop' directive can have 'default' clause, and said clause specified, +// but with 'firstprivate' kind, which is not 'none', diagnose. +void p3_3(const int a) { +#pragma omp taskloop default(firstprivate) + for (int b = 0; b < a; b++) + ; + // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead + // CHECK-NOTES: :[[@LINE-4]]:22: note: existing 'default' clause specified here +} + //----------------------------------------------------------------------------// // Combined directives. // Let's not test every single possible permutation/combination of directives, @@ -158,3 +196,13 @@ void p4_2(const int a) { // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'parallel for' specifies 'default(shared)' clause, consider using 'default(none)' clause instead // CHECK-NOTES: :[[@LINE-4]]:26: note: existing 'default' clause specified here } + +// 'parallel' directive can have 'default' clause, and said clause specified, +// but with 'firstprivate' kind, which is not 'none', diagnose. +void p4_3(const int a) { +#pragma omp parallel for default(firstprivate) + for (int b = 0; b < a; b++) + ; + // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'parallel for' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead + // CHECK-NOTES: :[[@LINE-4]]:26: note: existing 'default' clause specified here +} diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 2256cbf71869..60ff6ffe6056 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -676,9 +676,10 @@

Node Matchers

#pragma omp parallel default(none) #pragma omp parallel default(shared) + #pragma omp parallel default(firstprivate) #pragma omp parallel -``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``. +``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and ``default(firstprivate)``.
@@ -3783,6 +3784,7 @@

Narrowing Matchers

#pragma omp parallel #pragma omp parallel default(none) #pragma omp parallel default(shared) + #pragma omp parallel default(firstprivate) ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``. @@ -3796,11 +3798,26 @@

Narrowing Matchers

#pragma omp parallel #pragma omp parallel default(none) #pragma omp parallel default(shared) + #pragma omp parallel default(firstprivate) ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``. +Matcher<
OMPDefaultClause>isSharedKind +
Matches if the OpenMP ``default`` clause has ``firstprivate`` kind specified.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+  #pragma omp parallel default(firstprivate)
+
+``ompDefaultClause(isFirstPrivateKind())`` matches only ``default(firstprivate)``.
+
+ + Matcher<OMPExecutableDirective>isAllowedToContainClauseKindOpenMPClauseKind CKind
Matches if the OpenMP directive is allowed to contain the specified OpenMP
 clause kind.

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index f16fb876cdd3..643419743a11 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7190,10 +7190,12 @@ AST_MATCHER_P(OMPExecutableDirective, hasAnyClause,
 /// \code
 ///   #pragma omp parallel default(none)
 ///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
 ///   #pragma omp parallel
 /// \endcode
 ///
-/// ``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``.
+/// ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
+/// ``default(firstprivate)``
 extern const internal::VariadicDynCastAllOfMatcher
     ompDefaultClause;
 
@@ -7205,6 +7207,7 @@ extern const internal::VariadicDynCastAllOfMatcher
 ///   #pragma omp parallel
 ///   #pragma omp parallel default(none)
 ///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
 /// \endcode
 ///
 /// ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
@@ -7220,6 +7223,7 @@ AST_MATCHER(OMPDefaultClause, isNoneKind) {
 ///   #pragma omp parallel
 ///   #pragma omp parallel default(none)
 ///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
 /// \endcode
 ///
 /// ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
@@ -7227,6 +7231,24 @@ AST_MATCHER(OMPDefaultClause, isSharedKind) {
   return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_shared;
 }
 
+/// Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
+/// specified.
+///
+/// Given
+///
+/// \code
+///   #pragma omp parallel
+///   #pragma omp parallel default(none)
+///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
+/// \endcode
+///
+/// ``ompDefaultClause(isFirstPrivateKind())`` matches only
+/// ``default(firstprivate)``.
+AST_MATCHER(OMPDefaultClause, isFirstPrivateKind) {
+  return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_firstprivate;
+}
+
 /// Matches if the OpenMP directive is allowed to contain the specified OpenMP
 /// clause kind.
 ///

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index f5b32a6ba5fa..1038a4119d4c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1334,6 +1334,8 @@ def warn_omp_more_one_device_type_clause
       InGroup;
 def err_omp_variant_ctx_second_match_extension : Error<
   "only a single match extension allowed per OpenMP context selector">;
+def err_omp_invalid_dsa: Error<
+  "data-sharing attribute '%0' in '%1' clause requires OpenMP version %2 or above">;
 
 // Pragma loop support.
 def err_pragma_loop_missing_argument : Error<

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index a0a65092a92b..ec2215804c09 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -389,6 +389,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isExpr);
   REGISTER_MATCHER(isExternC);
   REGISTER_MATCHER(isFinal);
+  REGISTER_MATCHER(isFirstPrivateKind);
   REGISTER_MATCHER(isImplicit);
   REGISTER_MATCHER(isInStdNamespace);
   REGISTER_MATCHER(isInTemplateInstantiation);

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index afcef3043843..5223755c8fdf 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -1441,7 +1441,7 @@ bool Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
 /// Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
 ///
 ///    default-clause:
-///         'default' '(' 'none' | 'shared' ')
+///         'default' '(' 'none' | 'shared'  | 'firstprivate' ')
 ///
 ///    proc_bind-clause:
 ///         'proc_bind' '(' 'master' | 'close' | 'spread' ')
@@ -2772,7 +2772,7 @@ OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind,
 /// Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
 ///
 ///    default-clause:
-///         'default' '(' 'none' | 'shared' ')'
+///         'default' '(' 'none' | 'shared' | 'firstprivate' ')'
 ///
 ///    proc_bind-clause:
 ///         'proc_bind' '(' 'master' | 'close' | 'spread' ')'
@@ -2785,6 +2785,14 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind,
   llvm::Optional Val = parseOpenMPSimpleClause(*this, Kind);
   if (!Val || ParseOnly)
     return nullptr;
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+      static_cast(Val.getValue().Type) ==
+          OMP_DEFAULT_firstprivate) {
+    Diag(Val.getValue().LOpen, diag::err_omp_invalid_dsa)
+        << getOpenMPClauseName(OMPC_firstprivate)
+        << getOpenMPClauseName(OMPC_default) << "5.1";
+    return nullptr;
+  }
   return Actions.ActOnOpenMPSimpleClause(
       Kind, Val.getValue().Type, Val.getValue().TypeLoc, Val.getValue().LOpen,
       Val.getValue().Loc, Val.getValue().RLoc);

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b27abb54c170..920463da4027 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -53,9 +53,10 @@ static const Expr *checkMapClauseExpressionBase(
 namespace {
 /// Default data sharing attributes, which can be applied to directive.
 enum DefaultDataSharingAttributes {
-  DSA_unspecified = 0, /// Data sharing attribute not specified.
-  DSA_none = 1 << 0,   /// Default data sharing attribute 'none'.
-  DSA_shared = 1 << 1, /// Default data sharing attribute 'shared'.
+  DSA_unspecified = 0,       /// Data sharing attribute not specified.
+  DSA_none = 1 << 0,         /// Default data sharing attribute 'none'.
+  DSA_shared = 1 << 1,       /// Default data sharing attribute 'shared'.
+  DSA_firstprivate = 1 << 2, /// Default data sharing attribute 'firstprivate'.
 };
 
 /// Stack for tracking declarations used in OpenMP directives and
@@ -684,6 +685,11 @@ class DSAStackTy {
     getTopOfStack().DefaultAttr = DSA_shared;
     getTopOfStack().DefaultAttrLoc = Loc;
   }
+  /// Set default data sharing attribute to firstprivate.
+  void setDefaultDSAFirstPrivate(SourceLocation Loc) {
+    getTopOfStack().DefaultAttr = DSA_firstprivate;
+    getTopOfStack().DefaultAttrLoc = Loc;
+  }
   /// Set default data mapping attribute to Modifier:Kind
   void setDefaultDMAAttr(OpenMPDefaultmapClauseModifier M,
                          OpenMPDefaultmapClauseKind Kind,
@@ -1183,6 +1189,15 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
     return DVar;
   case DSA_none:
     return DVar;
+  case DSA_firstprivate:
+    if (VD->getStorageDuration() == SD_Static &&
+        VD->getDeclContext()->isFileContext()) {
+      DVar.CKind = OMPC_unknown;
+    } else {
+      DVar.CKind = OMPC_firstprivate;
+    }
+    DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;
+    return DVar;
   case DSA_unspecified:
     // OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
     // in a Construct, implicitly determined, p.2]
@@ -2058,7 +2073,13 @@ bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
         // If the variable is artificial and must be captured by value - try to
         // capture by value.
         !(isa(D) && !D->hasAttr() &&
-          !cast(D)->getInit()->isGLValue());
+          !cast(D)->getInit()->isGLValue()) &&
+        // If the variable is implicitly firstprivate and scalar - capture by
+        // copy
+        !(DSAStack->getDefaultDSA() == DSA_firstprivate &&
+          !DSAStack->hasExplicitDSA(
+              D, [](OpenMPClauseKind K) { return K != OMPC_unknown; }, Level) &&
+          !DSAStack->isLoopControlVariable(D, Level).first);
   }
 
   // When passing data by copy, we need to make sure it fits the uintptr size
@@ -2185,10 +2206,13 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo,
         DSAStack->isClauseParsingMode());
     // Global shared must not be captured.
     if (VD && !VD->hasLocalStorage() && DVarPrivate.CKind == OMPC_unknown &&
-        (DSAStack->getDefaultDSA() != DSA_none || DVarTop.CKind == OMPC_shared))
+        ((DSAStack->getDefaultDSA() != DSA_none &&
+          DSAStack->getDefaultDSA() != DSA_firstprivate) ||
+         DVarTop.CKind == OMPC_shared))
       return nullptr;
     if (DVarPrivate.CKind != OMPC_unknown ||
-        (VD && DSAStack->getDefaultDSA() == DSA_none))
+        (VD && (DSAStack->getDefaultDSA() == DSA_none ||
+                DSAStack->getDefaultDSA() == DSA_firstprivate)))
       return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
   }
   return nullptr;
@@ -3333,10 +3357,19 @@ class DSAAttrChecker final : public StmtVisitor {
       // in the construct, and does not have a predetermined data-sharing
       // attribute, must have its data-sharing attribute explicitly determined
       // by being listed in a data-sharing attribute clause.
-      if (DVar.CKind == OMPC_unknown && Stack->getDefaultDSA() == DSA_none &&
+      if (DVar.CKind == OMPC_unknown &&
+          (Stack->getDefaultDSA() == DSA_none ||
+           Stack->getDefaultDSA() == DSA_firstprivate) &&
           isImplicitOrExplicitTaskingRegion(DKind) &&
           VarsWithInheritedDSA.count(VD) == 0) {
-        VarsWithInheritedDSA[VD] = E;
+        bool InheritedDSA = Stack->getDefaultDSA() == DSA_none;
+        if (!InheritedDSA && Stack->getDefaultDSA() == DSA_firstprivate) {
+          DSAStackTy::DSAVarData DVar =
+              Stack->getImplicitDSA(VD, /*FromParent=*/false);
+          InheritedDSA = DVar.CKind == OMPC_unknown;
+        }
+        if (InheritedDSA)
+          VarsWithInheritedDSA[VD] = E;
         return;
       }
 
@@ -3438,7 +3471,9 @@ class DSAAttrChecker final : public StmtVisitor {
 
       // Define implicit data-sharing attributes for task.
       DVar = Stack->getImplicitDSA(VD, /*FromParent=*/false);
-      if (isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared &&
+      if (((isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared) ||
+           (Stack->getDefaultDSA() == DSA_firstprivate &&
+            DVar.CKind == OMPC_firstprivate && !DVar.RefExpr)) &&
           !Stack->isLoopControlVariable(VD).first) {
         ImplicitFirstprivate.push_back(E);
         return;
@@ -5342,8 +5377,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 
   ErrorFound = Res.isInvalid() || ErrorFound;
 
-  // Check variables in the clauses if default(none) was specified.
-  if (DSAStack->getDefaultDSA() == DSA_none) {
+  // Check variables in the clauses if default(none) or
+  // default(firstprivate) was specified.
+  if (DSAStack->getDefaultDSA() == DSA_none ||
+      DSAStack->getDefaultDSA() == DSA_firstprivate) {
     DSAAttrChecker DSAChecker(DSAStack, *this, nullptr);
     for (OMPClause *C : Clauses) {
       switch (C->getClauseKind()) {
@@ -5454,7 +5491,8 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
     if (P.getFirst()->isImplicit() || isa(P.getFirst()))
       continue;
     ErrorFound = true;
-    if (DSAStack->getDefaultDSA() == DSA_none) {
+    if (DSAStack->getDefaultDSA() == DSA_none ||
+        DSAStack->getDefaultDSA() == DSA_firstprivate) {
       Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable)
           << P.first << P.second->getSourceRange();
       Diag(DSAStack->getDefaultDSALocation(), diag::note_omp_default_dsa_none);
@@ -12932,10 +12970,20 @@ OMPClause *Sema::ActOnOpenMPDefaultClause(DefaultKind Kind,
         << getOpenMPClauseName(OMPC_default);
     return nullptr;
   }
-  if (Kind == OMP_DEFAULT_none)
+
+  switch (Kind) {
+  case OMP_DEFAULT_none:
     DSAStack->setDefaultDSANone(KindKwLoc);
-  else if (Kind == OMP_DEFAULT_shared)
+    break;
+  case OMP_DEFAULT_shared:
     DSAStack->setDefaultDSAShared(KindKwLoc);
+    break;
+  case OMP_DEFAULT_firstprivate:
+    DSAStack->setDefaultDSAFirstPrivate(KindKwLoc);
+    break;
+  default:
+    llvm_unreachable("DSA unexpected in OpenMP default clause");
+  }
 
   return new (Context)
       OMPDefaultClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);

diff  --git a/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
index 0629ba096d0c..67e4615ae8c0 100644
--- a/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
@@ -2,8 +2,17 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 template 
 T tmain(T argc) {
   int i;
@@ -14,12 +23,12 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -34,7 +43,7 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -62,12 +71,12 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -82,7 +91,7 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -98,5 +107,15 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return (tmain(argc) + tmain(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }

diff  --git a/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
index b9c5546ec5d9..9aab00f16c48 100644
--- a/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
@@ -2,8 +2,17 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized -DOMP51 -fopenmp-version=51
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized -DOMP51 -fopenmp-version=51
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 template 
 T tmain(T argc) {
   int i;
@@ -14,12 +23,12 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -34,7 +43,7 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -62,12 +71,12 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -82,7 +91,7 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -90,6 +99,15 @@ int main(int argc, char **argv) {
 #pragma omp distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (i = 0; i < argc; ++i)  // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
+#ifdef OpenMP51
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for simd default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
 
 #pragma omp parallel default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
 #pragma omp target

diff  --git a/clang/test/OpenMP/driver.c b/clang/test/OpenMP/driver.c
index fa5bd1a8b5f8..047478256f9f 100644
--- a/clang/test/OpenMP/driver.c
+++ b/clang/test/OpenMP/driver.c
@@ -47,6 +47,7 @@
 // RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=31 | FileCheck --check-prefix=CHECK-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=40 | FileCheck --check-prefix=CHECK-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=45 | FileCheck --check-prefix=CHECK-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=51 | FileCheck --check-prefix=CHECK-VERSION %s
 
 // CHECK-VERSION-NOT: #define _OPENMP
 

diff  --git a/clang/test/OpenMP/parallel_default_messages.cpp b/clang/test/OpenMP/parallel_default_messages.cpp
index 6b8ad6705185..b098c43852a8 100644
--- a/clang/test/OpenMP/parallel_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_default_messages.cpp
@@ -4,18 +4,25 @@
 // RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=40 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-version=31 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-version=30 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=51 -fopenmp -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=51 -fopenmp-simd -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
 
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   const int c = 0;
 
   #pragma omp parallel default // expected-error {{expected '(' after 'default'}}
-  #pragma omp parallel default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp parallel default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
-  #pragma omp parallel default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp parallel default (shared), default(shared) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'default' clause}}
-  #pragma omp parallel default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel default(  // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel default(none                     // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel default(shared), default(shared) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'default' clause}}
+#pragma omp parallel default(x)                       // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
   #pragma omp parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -27,5 +34,14 @@ int main(int argc, char **argv) {
 
   #pragma omp parallel default(none) // ge40-note {{explicit data sharing attribute requested here}}
   (void)c; // ge40-error {{variable 'c' must have explicitly specified data sharing attributes}}
+
+#ifdef OMP51
+#pragma omp parallel default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_for_default_messages.cpp b/clang/test/OpenMP/parallel_for_default_messages.cpp
index b02fa8803a3b..c64b76948c01 100644
--- a/clang/test/OpenMP/parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp parallel for default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel for default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp parallel for default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifdef OMP51
+#pragma omp parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
index 570ee14bbc84..6368d280de5d 100644
--- a/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} expected-error {{variable 'i' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifdef OMP51
+#pragma omp parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    x++; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    y++; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_master_codegen.cpp b/clang/test/OpenMP/parallel_master_codegen.cpp
index 9ffa941314b9..82e18c80f103 100644
--- a/clang/test/OpenMP/parallel_master_codegen.cpp
+++ b/clang/test/OpenMP/parallel_master_codegen.cpp
@@ -118,6 +118,162 @@ void parallel_master_private() {
 
 #endif
 
+#ifdef CK31
+///==========================================================================///
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK31
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK31
+
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK31-DAG:   %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK31-DAG:   [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+
+void parallel_master_default_firstprivate() {
+  int a;
+#pragma omp parallel master default(firstprivate)
+  a++;
+}
+
+// CK31-LABEL: define void @{{.+}}parallel_master{{.+}}
+// CK31:       [[A_VAL:%.+]] = alloca i32{{.+}}
+// CK31:       [[A_CASTED:%.+]] = alloca i64
+// CK31:       [[ZERO_VAL:%.+]] = load i32, i32* [[A_VAL]]
+// CK31:       [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32*
+// CK31:       store i32 [[ZERO_VAL]], i32* [[CONV]]
+// CK31:       [[ONE_VAL:%.+]] = load i64, i64* [[A_CASTED]]
+// CK31:       call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @0, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), i64 [[ONE_VAL]])
+// CK31:       ret void
+
+// CK31:       [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK31:       [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK31:       [[A_ADDR:%.+]] = alloca i64{{.+}}
+// CK31:       store i32* [[GLOBAL_TID:%.+]], i32** [[GLOBAL_TID_ADDR]]{{.+}}
+// CK31:       store i32* [[BOUND_TID:%.+]], i32** [[BOUND_TID_ADDR]]
+// CK31:       store i64 [[A_VAL]], i64* [[A_ADDR]]
+// CK31:       [[CONV]] = bitcast i64* [[A_ADDR]]
+// CK31:       [[ZERO_VAL]] = load i32*, i32** [[GLOBAL_TID_ADDR]]
+// CK31:       [[ONE_VAL]] = load i32, i32* [[ZERO_VAL]]
+// CK31:       [[TWO_VAL:%.+]] = call i32 @__kmpc_master(%struct.ident_t* @0, i32 [[ONE_VAL]])
+// CK31:       [[THREE:%.+]] = icmp ne i32 [[TWO_VAL]], 0
+// CK31:       br i1 %3, label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]]
+
+// CK31:       [[FOUR:%.+]] = load i32, i32* [[CONV:%.+]]
+// CK31:       [[INC:%.+]] = add nsw i32 [[FOUR]]
+// CK31:       store i32 [[INC]], i32* [[CONV]]
+// CK31:       call void @__kmpc_end_master(%struct.ident_t* @0, i32 [[ONE_VAL]])
+// CK31:       br label [[OMP_IF_END]]
+
+// CK31:       ret void
+
+#endif
+
+#ifdef CK32
+///==========================================================================///
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK32
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK32
+
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK32-DAG:   %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK32-DAG:   [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+
+struct St {
+  int a, b;
+  static int y;
+  St() : a(0), b(0) {}
+  ~St() {}
+};
+int St::y = 0;
+
+void parallel_master_default_firstprivate() {
+  St a = St();
+  static int y = 0;
+#pragma omp parallel master default(firstprivate)
+  {
+    a.a += 1;
+    a.b += 1;
+    y++;
+    a.y++;
+  }
+}
+
+// CK32-LABEL: define {{.+}} @{{.+}}parallel_master_default_firstprivate{{.+}}
+// CK32: [[A_VAL:%.+]] = alloca %struct.St{{.+}}
+// CK32: [[Y_CASTED:%.+]] = alloca i64
+// CK32: call void @[[CTOR:.+]](%struct.St* [[A_VAL]])
+// CK32: [[ZERO:%.+]] = load i32, i32* @{{.+}}parallel_master_default_firstprivate{{.+}}
+// CK32: [[CONV:%.+]] = bitcast i64* [[Y_CASTED]] to i32*
+// CK32: store i32 [[ZERO]], i32* [[CONV]]
+// CK32: [[ONE:%.+]] = load i64, i64* [[Y_CASTED]]
+// CK32: call void {{.+}}@{{.+}} %struct.St* [[A_VAL]], i64 [[ONE]])
+// CK32: call void [[DTOR:@.+]](%struct.St* [[A_VAL]])
+
+// CK32: [[THIS_ADDR:%.+]] = alloca %struct.St*
+// CK32: store %struct.St* [[THIS:%.+]], %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE:%.+]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+// CK32: call void [[CTOR_2:.+]](%struct.St* [[THIS_ONE]])
+// CK32: ret void
+
+// CK32: [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK32: [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK32: [[A_ADDR:%.+]] = alloca %struct.St
+// CK32: [[Y_ADDR:%.+]] = alloca i64
+// CK32: store i32* [[GLOBAL_TID:%.+]], i32** [[GLOBAL_TID_ADDR]]
+// CK32: store i32* %.bound_tid., i32** [[BOUND_TID_ADDR]]
+// CK32: store %struct.St* [[A_VAL]], %struct.St** [[A_ADDR]]{{.+}}
+// CK32: store i64 [[Y:%.+]], i64* [[Y_ADDR]]
+// CK32: [[ONE:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]]
+// CK32: [[TWO:%.+]] = load i32, i32* [[ONE]]
+// CK32: [[THREE:%.+]] = call i32 @{{.+}} i32 [[TWO]])
+// CK32: [[FOUR:%.+]] = icmp ne i32 [[THREE]], 0
+// CK32: br i1 [[FOUR]], label [[IF_THEN:%.+]], label [[IF_END:%.+]]
+
+// CK32: [[A_1:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[ZERO]], i32 0, i32 0
+// CK32: [[FIVE:%.+]] = load i32, i32* [[A_1]]
+// CK32: [[ADD:%.+]] = add nsw i32 [[FIVE]], 1
+// CK32: store i32 [[ADD]], i32* [[A_1]]
+// CK32: [[B:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[ZERO]], i32 0, i32 1
+// CK32: [[SIX:%.+]] = load i32, i32* [[B]]
+// CK32: [[ADD_2:%.+]] = add nsw i32 [[SIX]], 1
+// CK32: store i32 [[ADD_2]], i32* [[B]]
+// CK32: [[SEVEN:%.+]] = load i32, i32* [[CONV]]
+// CK32: [[INC:%.+]] = add nsw i32 [[SEVEN]], 1
+// CK32: store i32 [[INC]], i32* [[CONV]]
+// CK32: [[EIGHT:%.+]] = load i32, i32* [[FUNC:@.+]]
+// CK32: [[INC_3:%.+]] = add nsw i32 [[EIGHT]], 1
+// CK32: store i32 [[INC_3]], i32* @{{.+}}
+// CK32: call void @{{.+}} i32 [[TWO]])
+// CK32: br label [[IF_END]]
+
+// CK32: [[DTOR]](%struct.St* [[THIS]])
+// CK32: [[THIS_ADDR]] = alloca %struct.St*
+// CK32: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+// CK32: call void @_ZN2StD2Ev(%struct.St* [[THIS_ONE]])
+
+// CK32: [[THIS_ADDR]] = alloca %struct.St*
+// CK32: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+// CK32: [[A_VAL]] = getelementptr inbounds %struct.St, %struct.St* [[THIS_ONE]], i32 0, i32 0
+// CK32: store i32 0, i32* [[A_VAL]]
+// CK32: [[B_VAL:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[THIS_ONE]], i32 0, i32 1
+// CK32: store i32 0, i32* [[B_VAL]]
+// CK32: ret void
+
+// CK32: [[THIS_ADDR:%.+]] = alloca %struct.St*
+// CK32: store %struct.St* %this, %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+
+#endif
+
 #ifdef CK4
 ///==========================================================================///
 // RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK4

diff  --git a/clang/test/OpenMP/parallel_master_default_messages.cpp b/clang/test/OpenMP/parallel_master_default_messages.cpp
index 557cba5aa322..39f78ea53ae1 100644
--- a/clang/test/OpenMP/parallel_master_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_master_default_messages.cpp
@@ -2,20 +2,29 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp parallel master default // expected-error {{expected '(' after 'default'}}
   {
-#pragma omp parallel master default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel master default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     {
-#pragma omp parallel master default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel master default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
       {
 #pragma omp parallel master default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
         {
 #pragma omp parallel master default(shared), default(shared) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'default' clause}}
           {
-#pragma omp parallel master default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel master default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
             {
               foo();
             }
@@ -37,5 +46,14 @@ int main(int argc, char **argv) {
       ++argc;  // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     }
   }
+
+#ifdef OMP51
+#pragma omp parallel master default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_sections_default_messages.cpp b/clang/test/OpenMP/parallel_sections_default_messages.cpp
index d6a10fe56b34..cfa95445fb53 100644
--- a/clang/test/OpenMP/parallel_sections_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_sections_default_messages.cpp
@@ -7,15 +7,15 @@ void foo();
 int main(int argc, char **argv) {
 #pragma omp parallel sections default // expected-error {{expected '(' after 'default'}}
   {
-#pragma omp parallel sections default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel sections default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     {
-#pragma omp parallel sections default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel sections default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
       {
 #pragma omp parallel sections default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
         {
 #pragma omp parallel sections default(shared), default(shared) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'default' clause}}
           {
-#pragma omp parallel sections default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel sections default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
             {
               foo();
             }

diff  --git a/clang/test/OpenMP/target_parallel_default_messages.cpp b/clang/test/OpenMP/target_parallel_default_messages.cpp
index 0691cdf37e4e..c8f68659438f 100644
--- a/clang/test/OpenMP/target_parallel_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_default_messages.cpp
@@ -2,20 +2,29 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target parallel default // expected-error {{expected '(' after 'default'}}
   foo();
-  #pragma omp target parallel default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
-  #pragma omp target parallel default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
   #pragma omp target parallel default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
   #pragma omp target parallel default (shared), default(shared) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'default' clause}}
   foo();
-  #pragma omp target parallel default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
   #pragma omp target parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -28,5 +37,14 @@ int main(int argc, char **argv) {
   #pragma omp target parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
   #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifndef OMP51
+#pragma omp target parallel default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_parallel_for_default_messages.cpp b/clang/test/OpenMP/target_parallel_for_default_messages.cpp
index fc6ba43138d7..4a3aae68e086 100644
--- a/clang/test/OpenMP/target_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp target parallel for default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target parallel for default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp target parallel for default(shared), default(shared) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifndef OMP51
+#pragma omp target parallel for default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (i = 0; i < argc; ++i) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
index daa93b9c9050..48489309ef03 100644
--- a/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp target parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp target parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp target parallel for simd' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'i' must have explicitly specified data sharing attributes}} expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifndef OMP51
+#pragma omp target parallel for simd default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < argc; i++) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_default_messages.cpp b/clang/test/OpenMP/target_teams_default_messages.cpp
index 21fa8270ef6a..85c417f8f985 100644
--- a/clang/test/OpenMP/target_teams_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_default_messages.cpp
@@ -2,20 +2,29 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp target teams default // expected-error {{expected '(' after 'default'}}
   foo();
-#pragma omp target teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
-#pragma omp target teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 #pragma omp target teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
 #pragma omp target teams default (shared), default(shared) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'default' clause}}
   foo();
-#pragma omp target teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -24,5 +33,14 @@ int main(int argc, char **argv) {
 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
 #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifndef OMP51
+#pragma omp target teams default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_distribute_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
index fd834e7cba32..a490ad61385f 100644
--- a/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
@@ -2,24 +2,41 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target teams distribute default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
-  #pragma omp target teams distribute default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
-  #pragma omp target teams distribute default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
-  #pragma omp target teams distribute default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target teams distribute default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifndef OMP51
+#pragma omp target teams distribute default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < 200; i++) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
index 00e0704a6cca..2fe793136961 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
@@ -2,24 +2,41 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
- #pragma omp target teams distribute parallel for default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 #pragma omp target teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
 #pragma omp target teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
 #pragma omp target teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifndef OMP51
+#pragma omp target teams distribute parallel for default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < 200; i++) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
index 7c46c964d2ec..e5ff85622250 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
@@ -2,16 +2,25 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
 
-#pragma omp target teams distribute parallel for simd default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
 
-#pragma omp target teams distribute parallel for simd default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
 #pragma omp target teams distribute parallel for simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -20,11 +29,19 @@ int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for simd default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute parallel for simd' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
 
-#pragma omp target teams distribute parallel for simd default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
 #pragma omp target teams distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifndef OMP51
+#pragma omp target teams distribute parallel for simd default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < argc; ++i) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/task_default_messages.cpp b/clang/test/OpenMP/task_default_messages.cpp
index 4826c253aa04..8b6809ee05d5 100644
--- a/clang/test/OpenMP/task_default_messages.cpp
+++ b/clang/test/OpenMP/task_default_messages.cpp
@@ -2,15 +2,24 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp task default                          // expected-error {{expected '(' after 'default'}}
-#pragma omp task default(                         // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-#pragma omp task default()                        // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp task default(                         // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task default()                        // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
 #pragma omp task default(none                     // expected-error {{expected ')'}} expected-note {{to match this '('}}
 #pragma omp task default(shared), default(shared) // expected-error {{directive '#pragma omp task' cannot contain more than one 'default' clause}}
-#pragma omp task default(x)                       // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp task default(x)                       // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -19,5 +28,13 @@ int main(int argc, char **argv) {
 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
 #pragma omp task default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifdef OMP51
+#pragma omp task default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
   return 0;
 }

diff  --git a/clang/test/OpenMP/task_messages.cpp b/clang/test/OpenMP/task_messages.cpp
index 8b3183e0bd93..13cbfb6c4569 100644
--- a/clang/test/OpenMP/task_messages.cpp
+++ b/clang/test/OpenMP/task_messages.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
+
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
 #pragma omp task
@@ -16,6 +19,10 @@ void foo() {
 }
 
 typedef unsigned long omp_event_handle_t;
+namespace {
+static int y = 0;
+}
+static int x = 0;
 
 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
 
@@ -52,6 +59,15 @@ int foo() {
 #pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
 #pragma omp task default(shared)
   ++a; // expected-error 2 {{variable 'a' must have explicitly specified data sharing attributes}}
+#ifdef OMP51
+#pragma omp task default(firstprivate) // expected-note 4 {{explicit data sharing attribute requested here}}
+#pragma omp task
+  {
+    ++x; // expected-error 2 {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error 2 {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
 #pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
 #pragma omp task
   // expected-error at +1 {{calling a private constructor of class 'S'}}

diff  --git a/clang/test/OpenMP/teams_default_messages.cpp b/clang/test/OpenMP/teams_default_messages.cpp
index a02505040600..b117ef4948a0 100644
--- a/clang/test/OpenMP/teams_default_messages.cpp
+++ b/clang/test/OpenMP/teams_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams default // expected-error {{expected '(' after 'default'}}
   foo();
   #pragma omp target
-  #pragma omp teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
   #pragma omp target
-  #pragma omp teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
   #pragma omp target
   #pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
   #pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
   foo();
   #pragma omp target
-  #pragma omp teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
   #pragma omp target
@@ -32,5 +41,14 @@ int main(int argc, char **argv) {
   #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}
   #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_default_messages.cpp b/clang/test/OpenMP/teams_distribute_default_messages.cpp
index 7f000208303b..1d5fd40c53a6 100644
--- a/clang/test/OpenMP/teams_distribute_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +30,21 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams distribute default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
index 2c4662398507..3a414543be80 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute parallel for default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +30,21 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams distribute parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
index 93017a8233ff..ce7f35b47959 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized -fopenmp-version=51 -DOMP51
+
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized -fopenmp-version=51 -DOMP51
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for simd default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for simd default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute parallel for simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +30,20 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute parallel for simd default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for simd default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifdef OpenMP51
+#pragma omp teams distribute parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp b/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
index 2775210ae048..11f5d1cd1fc8 100644
--- a/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
@@ -1,18 +1,23 @@
-// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized -fopenmp-version=51
 
-// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized -fopenmp-version=51
 
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute simd default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute simd default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute simd default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +26,22 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute simd default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute simd default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#pragma omp target
+#pragma omp teams distribute simd default(firstprivate) // expected-note {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++)
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+
+#pragma omp target
+#pragma omp teams distribute simd default(firstprivate) // expected-note {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++)
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+
   return 0;
 }

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index aeb4fd098d22..687908043a8d 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -103,9 +103,9 @@ TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
   StringRef input = R"cc(
     void Test() { FOUR_PLUS_FOUR; }
   )cc";
-  EXPECT_TRUE(matchesConditionally(input,
-                                   binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
-                                   true, {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
+  EXPECT_TRUE(matchesConditionally(
+      input, binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")), true,
+      {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
 }
 
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
@@ -143,31 +143,31 @@ TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
 }
 
 TEST(AllOf, AllOverloadsWork) {
-  const char Program[] =
-      "struct T { };"
-      "int f(int, T*, int, int);"
-      "void g(int x) { T t; f(x, &t, 3, 4); }";
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl())))))));
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl()))),
-                     hasArgument(1, hasType(pointsTo(
-                                        recordDecl(hasName("T")))))))));
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl()))),
-                     hasArgument(1, hasType(pointsTo(
-                                        recordDecl(hasName("T"))))),
-                     hasArgument(2, integerLiteral(equals(3)))))));
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl()))),
-                     hasArgument(1, hasType(pointsTo(
-                                        recordDecl(hasName("T"))))),
-                     hasArgument(2, integerLiteral(equals(3))),
-                     hasArgument(3, integerLiteral(equals(4)))))));
+  const char Program[] = "struct T { };"
+                         "int f(int, T*, int, int);"
+                         "void g(int x) { T t; f(x, &t, 3, 4); }";
+  EXPECT_TRUE(matches(
+      Program, callExpr(allOf(callee(functionDecl(hasName("f"))),
+                              hasArgument(0, declRefExpr(to(varDecl())))))));
+  EXPECT_TRUE(matches(
+      Program,
+      callExpr(
+          allOf(callee(functionDecl(hasName("f"))),
+                hasArgument(0, declRefExpr(to(varDecl()))),
+                hasArgument(1, hasType(pointsTo(recordDecl(hasName("T")))))))));
+  EXPECT_TRUE(matches(
+      Program, callExpr(allOf(
+                   callee(functionDecl(hasName("f"))),
+                   hasArgument(0, declRefExpr(to(varDecl()))),
+                   hasArgument(1, hasType(pointsTo(recordDecl(hasName("T"))))),
+                   hasArgument(2, integerLiteral(equals(3)))))));
+  EXPECT_TRUE(matches(
+      Program, callExpr(allOf(
+                   callee(functionDecl(hasName("f"))),
+                   hasArgument(0, declRefExpr(to(varDecl()))),
+                   hasArgument(1, hasType(pointsTo(recordDecl(hasName("T"))))),
+                   hasArgument(2, integerLiteral(equals(3))),
+                   hasArgument(3, integerLiteral(equals(4)))))));
 }
 
 TEST(DeclarationMatcher, MatchHas) {
@@ -176,127 +176,103 @@ TEST(DeclarationMatcher, MatchHas) {
   EXPECT_TRUE(matches("class X {};", HasClassX));
 
   DeclarationMatcher YHasClassX =
-    recordDecl(hasName("Y"), has(recordDecl(hasName("X"))));
+      recordDecl(hasName("Y"), has(recordDecl(hasName("X"))));
   EXPECT_TRUE(matches("class Y { class X {}; };", YHasClassX));
   EXPECT_TRUE(notMatches("class X {};", YHasClassX));
-  EXPECT_TRUE(
-    notMatches("class Y { class Z { class X {}; }; };", YHasClassX));
+  EXPECT_TRUE(notMatches("class Y { class Z { class X {}; }; };", YHasClassX));
 }
 
 TEST(DeclarationMatcher, MatchHasRecursiveAllOf) {
   DeclarationMatcher Recursive =
-    recordDecl(
-      has(recordDecl(
-        has(recordDecl(hasName("X"))),
-        has(recordDecl(hasName("Y"))),
-        hasName("Z"))),
-      has(recordDecl(
-        has(recordDecl(hasName("A"))),
-        has(recordDecl(hasName("B"))),
-        hasName("C"))),
-      hasName("F"));
-
-  EXPECT_TRUE(matches(
-    "class F {"
-      "  class Z {"
-      "    class X {};"
-      "    class Y {};"
-      "  };"
-      "  class C {"
-      "    class A {};"
-      "    class B {};"
-      "  };"
-      "};", Recursive));
-
-  EXPECT_TRUE(matches(
-    "class F {"
-      "  class Z {"
-      "    class A {};"
-      "    class X {};"
-      "    class Y {};"
-      "  };"
-      "  class C {"
-      "    class X {};"
-      "    class A {};"
-      "    class B {};"
-      "  };"
-      "};", Recursive));
-
-  EXPECT_TRUE(matches(
-    "class O1 {"
-      "  class O2 {"
-      "    class F {"
-      "      class Z {"
-      "        class A {};"
-      "        class X {};"
-      "        class Y {};"
-      "      };"
-      "      class C {"
-      "        class X {};"
-      "        class A {};"
-      "        class B {};"
-      "      };"
-      "    };"
-      "  };"
-      "};", Recursive));
+      recordDecl(has(recordDecl(has(recordDecl(hasName("X"))),
+                                has(recordDecl(hasName("Y"))), hasName("Z"))),
+                 has(recordDecl(has(recordDecl(hasName("A"))),
+                                has(recordDecl(hasName("B"))), hasName("C"))),
+                 hasName("F"));
+
+  EXPECT_TRUE(matches("class F {"
+                      "  class Z {"
+                      "    class X {};"
+                      "    class Y {};"
+                      "  };"
+                      "  class C {"
+                      "    class A {};"
+                      "    class B {};"
+                      "  };"
+                      "};",
+                      Recursive));
+
+  EXPECT_TRUE(matches("class F {"
+                      "  class Z {"
+                      "    class A {};"
+                      "    class X {};"
+                      "    class Y {};"
+                      "  };"
+                      "  class C {"
+                      "    class X {};"
+                      "    class A {};"
+                      "    class B {};"
+                      "  };"
+                      "};",
+                      Recursive));
+
+  EXPECT_TRUE(matches("class O1 {"
+                      "  class O2 {"
+                      "    class F {"
+                      "      class Z {"
+                      "        class A {};"
+                      "        class X {};"
+                      "        class Y {};"
+                      "      };"
+                      "      class C {"
+                      "        class X {};"
+                      "        class A {};"
+                      "        class B {};"
+                      "      };"
+                      "    };"
+                      "  };"
+                      "};",
+                      Recursive));
 }
 
 TEST(DeclarationMatcher, MatchHasRecursiveAnyOf) {
-  DeclarationMatcher Recursive =
-    recordDecl(
-      anyOf(
-        has(recordDecl(
-          anyOf(
-            has(recordDecl(
-              hasName("X"))),
-            has(recordDecl(
-              hasName("Y"))),
-            hasName("Z")))),
-        has(recordDecl(
-          anyOf(
-            hasName("C"),
-            has(recordDecl(
-              hasName("A"))),
-            has(recordDecl(
-              hasName("B")))))),
-        hasName("F")));
+  DeclarationMatcher Recursive = recordDecl(
+      anyOf(has(recordDecl(anyOf(has(recordDecl(hasName("X"))),
+                                 has(recordDecl(hasName("Y"))), hasName("Z")))),
+            has(recordDecl(anyOf(hasName("C"), has(recordDecl(hasName("A"))),
+                                 has(recordDecl(hasName("B")))))),
+            hasName("F")));
 
   EXPECT_TRUE(matches("class F {};", Recursive));
   EXPECT_TRUE(matches("class Z {};", Recursive));
   EXPECT_TRUE(matches("class C {};", Recursive));
   EXPECT_TRUE(matches("class M { class N { class X {}; }; };", Recursive));
   EXPECT_TRUE(matches("class M { class N { class B {}; }; };", Recursive));
-  EXPECT_TRUE(
-    matches("class O1 { class O2 {"
-              "  class M { class N { class B {}; }; }; "
-              "}; };", Recursive));
+  EXPECT_TRUE(matches("class O1 { class O2 {"
+                      "  class M { class N { class B {}; }; }; "
+                      "}; };",
+                      Recursive));
 }
 
 TEST(DeclarationMatcher, MatchNot) {
   DeclarationMatcher NotClassX =
-    cxxRecordDecl(
-      isDerivedFrom("Y"),
-      unless(hasName("X")));
+      cxxRecordDecl(isDerivedFrom("Y"), unless(hasName("X")));
   EXPECT_TRUE(notMatches("", NotClassX));
   EXPECT_TRUE(notMatches("class Y {};", NotClassX));
   EXPECT_TRUE(matches("class Y {}; class Z : public Y {};", NotClassX));
   EXPECT_TRUE(notMatches("class Y {}; class X : public Y {};", NotClassX));
   EXPECT_TRUE(
-    notMatches("class Y {}; class Z {}; class X : public Y {};",
-               NotClassX));
+      notMatches("class Y {}; class Z {}; class X : public Y {};", NotClassX));
 
   DeclarationMatcher ClassXHasNotClassY =
-    recordDecl(
-      hasName("X"),
-      has(recordDecl(hasName("Z"))),
-      unless(
-        has(recordDecl(hasName("Y")))));
+      recordDecl(hasName("X"), has(recordDecl(hasName("Z"))),
+                 unless(has(recordDecl(hasName("Y")))));
   EXPECT_TRUE(matches("class X { class Z {}; };", ClassXHasNotClassY));
-  EXPECT_TRUE(notMatches("class X { class Y {}; class Z {}; };",
-                         ClassXHasNotClassY));
+  EXPECT_TRUE(
+      notMatches("class X { class Y {}; class Z {}; };", ClassXHasNotClassY));
 
   DeclarationMatcher NamedNotRecord =
-    namedDecl(hasName("Foo"), unless(recordDecl()));
+      namedDecl(hasName("Foo"), unless(recordDecl()));
   EXPECT_TRUE(matches("void Foo(){}", NamedNotRecord));
   EXPECT_TRUE(notMatches("struct Foo {};", NamedNotRecord));
 }
@@ -318,67 +294,61 @@ TEST(CastExpression, HasCastKind) {
 
 TEST(DeclarationMatcher, HasDescendant) {
   DeclarationMatcher ZDescendantClassX =
-    recordDecl(
-      hasDescendant(recordDecl(hasName("X"))),
-      hasName("Z"));
+      recordDecl(hasDescendant(recordDecl(hasName("X"))), hasName("Z"));
   EXPECT_TRUE(matches("class Z { class X {}; };", ZDescendantClassX));
   EXPECT_TRUE(
-    matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
+      matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
+  EXPECT_TRUE(matches("class Z { class A { class Y { class X {}; }; }; };",
+                      ZDescendantClassX));
   EXPECT_TRUE(
-    matches("class Z { class A { class Y { class X {}; }; }; };",
-            ZDescendantClassX));
-  EXPECT_TRUE(
-    matches("class Z { class A { class B { class Y { class X {}; }; }; }; };",
-            ZDescendantClassX));
+      matches("class Z { class A { class B { class Y { class X {}; }; }; }; };",
+              ZDescendantClassX));
   EXPECT_TRUE(notMatches("class Z {};", ZDescendantClassX));
 
-  DeclarationMatcher ZDescendantClassXHasClassY =
-    recordDecl(
-      hasDescendant(recordDecl(has(recordDecl(hasName("Y"))),
-                               hasName("X"))),
+  DeclarationMatcher ZDescendantClassXHasClassY = recordDecl(
+      hasDescendant(recordDecl(has(recordDecl(hasName("Y"))), hasName("X"))),
       hasName("Z"));
   EXPECT_TRUE(matches("class Z { class X { class Y {}; }; };",
                       ZDescendantClassXHasClassY));
   EXPECT_TRUE(
-    matches("class Z { class A { class B { class X { class Y {}; }; }; }; };",
-            ZDescendantClassXHasClassY));
-  EXPECT_TRUE(notMatches(
-    "class Z {"
-      "  class A {"
-      "    class B {"
-      "      class X {"
-      "        class C {"
-      "          class Y {};"
-      "        };"
-      "      };"
-      "    }; "
-      "  };"
-      "};", ZDescendantClassXHasClassY));
+      matches("class Z { class A { class B { class X { class Y {}; }; }; }; };",
+              ZDescendantClassXHasClassY));
+  EXPECT_TRUE(notMatches("class Z {"
+                         "  class A {"
+                         "    class B {"
+                         "      class X {"
+                         "        class C {"
+                         "          class Y {};"
+                         "        };"
+                         "      };"
+                         "    }; "
+                         "  };"
+                         "};",
+                         ZDescendantClassXHasClassY));
 
   DeclarationMatcher ZDescendantClassXDescendantClassY =
-    recordDecl(
-      hasDescendant(recordDecl(hasDescendant(recordDecl(hasName("Y"))),
-                               hasName("X"))),
-      hasName("Z"));
-  EXPECT_TRUE(
-    matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
-            ZDescendantClassXDescendantClassY));
-  EXPECT_TRUE(matches(
-    "class Z {"
-      "  class A {"
-      "    class X {"
-      "      class B {"
-      "        class Y {};"
-      "      };"
-      "      class Y {};"
-      "    };"
-      "  };"
-      "};", ZDescendantClassXDescendantClassY));
+      recordDecl(hasDescendant(recordDecl(
+                     hasDescendant(recordDecl(hasName("Y"))), hasName("X"))),
+                 hasName("Z"));
+  EXPECT_TRUE(
+      matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
+              ZDescendantClassXDescendantClassY));
+  EXPECT_TRUE(matches("class Z {"
+                      "  class A {"
+                      "    class X {"
+                      "      class B {"
+                      "        class Y {};"
+                      "      };"
+                      "      class Y {};"
+                      "    };"
+                      "  };"
+                      "};",
+                      ZDescendantClassXDescendantClassY));
 }
 
 TEST(DeclarationMatcher, HasDescendantMemoization) {
   DeclarationMatcher CannotMemoize =
-    decl(hasDescendant(typeLoc().bind("x")), has(decl()));
+      decl(hasDescendant(typeLoc().bind("x")), has(decl()));
   EXPECT_TRUE(matches("void f() { int i; }", CannotMemoize));
 }
 
@@ -401,39 +371,36 @@ TEST(DeclarationMatcher, HasAncestorMemoization) {
   // That node can't be memoized so we have to check for it before trying to put
   // it on the cache.
   DeclarationMatcher CannotMemoize = classTemplateSpecializationDecl(
-    hasAnyTemplateArgument(templateArgument().bind("targ")),
-    forEach(fieldDecl(hasAncestor(forStmt()))));
+      hasAnyTemplateArgument(templateArgument().bind("targ")),
+      forEach(fieldDecl(hasAncestor(forStmt()))));
 
   EXPECT_TRUE(notMatches("template  struct S;"
-                           "template <> struct S{ int i; int j; };",
+                         "template <> struct S{ int i; int j; };",
                          CannotMemoize));
 }
 
 TEST(DeclarationMatcher, HasAttr) {
   EXPECT_TRUE(matches("struct __attribute__((warn_unused)) X {};",
                       decl(hasAttr(clang::attr::WarnUnused))));
-  EXPECT_FALSE(matches("struct X {};",
-                       decl(hasAttr(clang::attr::WarnUnused))));
+  EXPECT_FALSE(matches("struct X {};", decl(hasAttr(clang::attr::WarnUnused))));
 }
 
-
 TEST(DeclarationMatcher, MatchAnyOf) {
   DeclarationMatcher YOrZDerivedFromX = cxxRecordDecl(
-    anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
+      anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
   EXPECT_TRUE(matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
   EXPECT_TRUE(matches("class Y {};", YOrZDerivedFromX));
   EXPECT_TRUE(
-    notMatches("class X {}; class W : public X {};", YOrZDerivedFromX));
+      notMatches("class X {}; class W : public X {};", YOrZDerivedFromX));
   EXPECT_TRUE(notMatches("class Z {};", YOrZDerivedFromX));
 
   DeclarationMatcher XOrYOrZOrU =
-    recordDecl(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U")));
+      recordDecl(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U")));
   EXPECT_TRUE(matches("class X {};", XOrYOrZOrU));
   EXPECT_TRUE(notMatches("class V {};", XOrYOrZOrU));
 
-  DeclarationMatcher XOrYOrZOrUOrV =
-    recordDecl(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U"),
-                     hasName("V")));
+  DeclarationMatcher XOrYOrZOrUOrV = recordDecl(anyOf(
+      hasName("X"), hasName("Y"), hasName("Z"), hasName("U"), hasName("V")));
   EXPECT_TRUE(matches("class X {};", XOrYOrZOrUOrV));
   EXPECT_TRUE(matches("class Y {};", XOrYOrZOrUOrV));
   EXPECT_TRUE(matches("class Z {};", XOrYOrZOrUOrV));
@@ -447,8 +414,8 @@ TEST(DeclarationMatcher, MatchAnyOf) {
   EXPECT_TRUE(notMatches("int F() { return 1; }", MixedTypes));
 
   EXPECT_TRUE(
-    matches("void f() try { } catch (int) { } catch (...) { }",
-            cxxCatchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
+      matches("void f() try { } catch (int) { } catch (...) { }",
+              cxxCatchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
 }
 
 TEST(DeclarationMatcher, ClassIsDerived) {
@@ -460,19 +427,17 @@ TEST(DeclarationMatcher, ClassIsDerived) {
   EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
   EXPECT_TRUE(notMatches("", IsDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Y : Y, X {};",
-    IsDerivedFromX));
+                      IsDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Y : X, Y {};",
-    IsDerivedFromX));
+                      IsDerivedFromX));
 
-  DeclarationMatcher IsZDerivedFromX = cxxRecordDecl(hasName("Z"),
-    isDerivedFrom("X"));
-  EXPECT_TRUE(
-    matches(
-      "class X {};"
-      "template class Y : Y {};"
-      "template<> class Y<0> : X {};"
-      "class Z : Y<1> {};",
-      IsZDerivedFromX));
+  DeclarationMatcher IsZDerivedFromX =
+      cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+  EXPECT_TRUE(matches("class X {};"
+                      "template class Y : Y {};"
+                      "template<> class Y<0> : X {};"
+                      "class Z : Y<1> {};",
+                      IsZDerivedFromX));
 
   DeclarationMatcher IsDirectlyDerivedFromX =
       cxxRecordDecl(isDirectlyDerivedFrom("X"));
@@ -493,145 +458,138 @@ TEST(DeclarationMatcher, ClassIsDerived) {
   EXPECT_TRUE(notMatches("", IsAX));
 
   DeclarationMatcher ZIsDerivedFromX =
-    cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+      cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
   DeclarationMatcher ZIsDirectlyDerivedFromX =
       cxxRecordDecl(hasName("Z"), isDirectlyDerivedFrom("X"));
   EXPECT_TRUE(
-    matches("class X {}; class Y : public X {}; class Z : public Y {};",
-            ZIsDerivedFromX));
+      matches("class X {}; class Y : public X {}; class Z : public Y {};",
+              ZIsDerivedFromX));
   EXPECT_TRUE(
       notMatches("class X {}; class Y : public X {}; class Z : public Y {};",
                  ZIsDirectlyDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {};"
-              "template class Y : public X {};"
-              "class Z : public Y {};", ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {};"
+                      "template class Y : public X {};"
+                      "class Z : public Y {};",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(notMatches("class X {};"
                          "template class Y : public X {};"
                          "class Z : public Y {};",
                          ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Z : public X {};",
                       ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X {}; "
+                      "template class Z : public X {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X {}; "
+                      "template class Z : public X {};",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class X {}; "
-              "template class Z : public X {};",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template class X {}; "
-              "template class Z : public X {};",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template class A { class Z : public X {}; };",
-               ZIsDerivedFromX));
+      notMatches("template class A { class Z : public X {}; };",
+                 ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class A { public: class Z : public X {}; }; "
-              "class X{}; void y() { A::Z z; }", ZIsDerivedFromX));
+      matches("template class A { public: class Z : public X {}; }; "
+              "class X{}; void y() { A::Z z; }",
+              ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template  class X {}; "
+      matches("template  class X {}; "
               "template class A { class Z : public X {}; };",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template class X> class A { "
-                 "  class Z : public X {}; };", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template class X> class A { "
-              "  public: class Z : public X {}; }; "
-              "template class X {}; void y() { A::Z z; }",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template class A { class Z : public X::D {}; };",
-               ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template class A { public: "
-              "  class Z : public X::D {}; }; "
-              "class Y { public: class X {}; typedef X D; }; "
-              "void y() { A::Z z; }", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; typedef X Y; class Z : public Y {};",
-            ZIsDerivedFromX));
+              ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("template class X> class A { "
+                         "  class Z : public X {}; };",
+                         ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X> class A { "
+                      "  public: class Z : public X {}; }; "
+                      "template class X {}; void y() { A::Z z; }",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class Y { typedef typename T::U X; "
-              "  class Z : public X {}; };", ZIsDerivedFromX));
-  EXPECT_TRUE(matches("class X {}; class Z : public ::X {};",
+      notMatches("template class A { class Z : public X::D {}; };",
+                 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class A { public: "
+                      "  class Z : public X::D {}; }; "
+                      "class Y { public: class X {}; typedef X D; }; "
+                      "void y() { A::Z z; }",
                       ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; typedef X Y; class Z : public Y {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class Y { typedef typename T::U X; "
+                      "  class Z : public X {}; };",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; class Z : public ::X {};", ZIsDerivedFromX));
   EXPECT_TRUE(
-    notMatches("template class X {}; "
+      notMatches("template class X {}; "
                  "template class A { class Z : public X::D {}; };",
-               ZIsDerivedFromX));
+                 ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class X { public: typedef X D; }; "
+      matches("template class X { public: typedef X D; }; "
               "template class A { public: "
               "  class Z : public X::D {}; }; void y() { A::Z z; }",
-            ZIsDerivedFromX));
+              ZIsDerivedFromX));
   EXPECT_TRUE(
-    notMatches("template class A { class Z : public X::D::E {}; };",
-               ZIsDerivedFromX));
+      notMatches("template class A { class Z : public X::D::E {}; };",
+                 ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("class X {}; typedef X V; typedef V W; class Z : public W {};",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; class Y : public X {}; "
-              "typedef Y V; typedef V W; class Z : public W {};",
-            ZIsDerivedFromX));
+      matches("class X {}; typedef X V; typedef V W; class Z : public W {};",
+              ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; class Y : public X {}; "
+                      "typedef Y V; typedef V W; class Z : public W {};",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(notMatches("class X {}; class Y : public X {}; "
                          "typedef Y V; typedef V W; class Z : public W {};",
                          ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
-    matches("template class X {}; "
+      matches("template class X {}; "
               "template class A { class Z : public X {}; };",
-            ZIsDerivedFromX));
+              ZIsDerivedFromX));
   EXPECT_TRUE(
-    notMatches("template class D { typedef X A; typedef A B; "
+      notMatches("template class D { typedef X A; typedef A B; "
                  "  typedef B C; class Z : public C {}; };",
-               ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; typedef X A; typedef A B; "
-              "class Z : public B {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; typedef X A; typedef A B; typedef B C; "
-              "class Z : public C {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class U {}; typedef U X; typedef X V; "
-              "class Z : public V {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class Base {}; typedef Base X; "
-              "class Z : public Base {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class Base {}; typedef Base Base2; typedef Base2 X; "
-              "class Z : public Base {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("class Base {}; class Base2 {}; typedef Base2 X; "
-                 "class Z : public Base {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class A {}; typedef A X; typedef A Y; "
-              "class Z : public Y {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template  class Z;"
-                 "template <> class Z {};"
-                 "template  class Z : public Z {};",
-               IsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template  class X;"
-              "template <> class X {};"
-              "template  class X : public X {};",
-            IsDerivedFromX));
-  EXPECT_TRUE(matches(
-    "class X {};"
-      "template  class Z;"
-      "template <> class Z {};"
-      "template  class Z : public Z, public X {};",
-    ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template struct X;"
+                 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; typedef X A; typedef A B; "
+                      "class Z : public B {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; typedef X A; typedef A B; typedef B C; "
+                      "class Z : public C {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class U {}; typedef U X; typedef X V; "
+                      "class Z : public V {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class Base {}; typedef Base X; "
+                      "class Z : public Base {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class Base {}; typedef Base Base2; typedef Base2 X; "
+                      "class Z : public Base {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class Base {}; class Base2 {}; typedef Base2 X; "
+                         "class Z : public Base {};",
+                         ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class A {}; typedef A X; typedef A Y; "
+                      "class Z : public Y {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("template  class Z;"
+                         "template <> class Z {};"
+                         "template  class Z : public Z {};",
+                         IsDerivedFromX));
+  EXPECT_TRUE(matches("template  class X;"
+                      "template <> class X {};"
+                      "template  class X : public X {};",
+                      IsDerivedFromX));
+  EXPECT_TRUE(
+      matches("class X {};"
+              "template  class Z;"
+              "template <> class Z {};"
+              "template  class Z : public Z, public X {};",
+              ZIsDerivedFromX));
+  EXPECT_TRUE(
+      notMatches("template struct X;"
                  "template struct X : public X {};",
-               cxxRecordDecl(isDerivedFrom(recordDecl(hasName("Some"))))));
+                 cxxRecordDecl(isDerivedFrom(recordDecl(hasName("Some"))))));
   EXPECT_TRUE(matches(
-    "struct A {};"
+      "struct A {};"
       "template struct X;"
       "template struct X : public X {};"
       "template<> struct X<0> : public A {};"
       "struct B : public X<42> {};",
-    cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"))))));
+      cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"))))));
   EXPECT_TRUE(notMatches(
       "struct A {};"
       "template struct X;"
@@ -645,7 +603,7 @@ TEST(DeclarationMatcher, ClassIsDerived) {
   // get rid of the Variable(...) matching and match the right template
   // declarations directly.
   const char *RecursiveTemplateOneParameter =
-    "class Base1 {}; class Base2 {};"
+      "class Base1 {}; class Base2 {};"
       "template  class Z;"
       "template <> class Z : public Base1 {};"
       "template <> class Z : public Base2 {};"
@@ -654,21 +612,21 @@ TEST(DeclarationMatcher, ClassIsDerived) {
       "template  class Z : public Z, public Z {};"
       "void f() { Z z_float; Z z_double; Z z_char; }";
   EXPECT_TRUE(matches(
-    RecursiveTemplateOneParameter,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
+      RecursiveTemplateOneParameter,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
   EXPECT_TRUE(notMatches(
-    RecursiveTemplateOneParameter,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
-  EXPECT_TRUE(matches(
-    RecursiveTemplateOneParameter,
-    varDecl(hasName("z_char"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1"),
-                                                 isDerivedFrom("Base2")))))));
+      RecursiveTemplateOneParameter,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
+  EXPECT_TRUE(
+      matches(RecursiveTemplateOneParameter,
+              varDecl(hasName("z_char"),
+                      hasInitializer(hasType(cxxRecordDecl(
+                          isDerivedFrom("Base1"), isDerivedFrom("Base2")))))));
 
   const char *RecursiveTemplateTwoParameters =
-    "class Base1 {}; class Base2 {};"
+      "class Base1 {}; class Base2 {};"
       "template  class Z;"
       "template  class Z : public Base1 {};"
       "template  class Z : public Base2 {};"
@@ -679,34 +637,31 @@ TEST(DeclarationMatcher, ClassIsDerived) {
       "void f() { Z z_float; Z z_double; "
       "           Z z_char; }";
   EXPECT_TRUE(matches(
-    RecursiveTemplateTwoParameters,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
-  EXPECT_TRUE(notMatches(
-    RecursiveTemplateTwoParameters,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
-  EXPECT_TRUE(matches(
-    RecursiveTemplateTwoParameters,
-    varDecl(hasName("z_char"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1"),
-                                                 isDerivedFrom("Base2")))))));
-  EXPECT_TRUE(matches(
-    "namespace ns { class X {}; class Y : public X {}; }",
-    cxxRecordDecl(isDerivedFrom("::ns::X"))));
+      RecursiveTemplateTwoParameters,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
   EXPECT_TRUE(notMatches(
-    "class X {}; class Y : public X {};",
-    cxxRecordDecl(isDerivedFrom("::ns::X"))));
+      RecursiveTemplateTwoParameters,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
+  EXPECT_TRUE(
+      matches(RecursiveTemplateTwoParameters,
+              varDecl(hasName("z_char"),
+                      hasInitializer(hasType(cxxRecordDecl(
+                          isDerivedFrom("Base1"), isDerivedFrom("Base2")))))));
+  EXPECT_TRUE(matches("namespace ns { class X {}; class Y : public X {}; }",
+                      cxxRecordDecl(isDerivedFrom("::ns::X"))));
+  EXPECT_TRUE(notMatches("class X {}; class Y : public X {};",
+                         cxxRecordDecl(isDerivedFrom("::ns::X"))));
 
   EXPECT_TRUE(matches(
-    "class X {}; class Y : public X {};",
-    cxxRecordDecl(isDerivedFrom(recordDecl(hasName("X")).bind("test")))));
+      "class X {}; class Y : public X {};",
+      cxxRecordDecl(isDerivedFrom(recordDecl(hasName("X")).bind("test")))));
 
-  EXPECT_TRUE(matches(
-    "template class X {};"
-      "template using Z = X;"
-      "template  class Y : Z {};",
-    cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
+  EXPECT_TRUE(matches("template class X {};"
+                      "template using Z = X;"
+                      "template  class Y : Z {};",
+                      cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
 }
 
 TEST(DeclarationMatcher, IsDerivedFromEmptyName) {
@@ -737,24 +692,24 @@ TEST(DeclarationMatcher, ObjCClassIsDerived) {
 
   DeclarationMatcher IsDirectlyDerivedFromX =
       objcInterfaceDecl(isDirectlyDerivedFrom("X"));
-  EXPECT_TRUE(
-      matchesObjC("@interface X @end @interface Y : X @end", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end",
+                          IsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface X @end @interface Y<__covariant ObjectType> : X @end",
       IsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface X @end @compatibility_alias Y X; @interface Z : Y @end",
       IsDirectlyDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface X @end typedef X Y; @interface Z : Y @end",
-      IsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface X @end typedef X Y; @interface Z : Y @end",
+                  IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@interface X @end", IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@class X;", IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@class Y;", IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@interface X @end @compatibility_alias Y X;",
                              IsDirectlyDerivedFromX));
-  EXPECT_TRUE(notMatchesObjC("@interface X @end typedef X Y;",
-                             IsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      notMatchesObjC("@interface X @end typedef X Y;", IsDirectlyDerivedFromX));
 
   DeclarationMatcher IsAX = objcInterfaceDecl(isSameOrDerivedFrom("X"));
   EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end", IsAX));
@@ -775,9 +730,9 @@ TEST(DeclarationMatcher, ObjCClassIsDerived) {
                           ZIsDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface X @end typedef X Y; @interface Z : Y @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface X @end typedef X Y; @interface Z : Y @end",
-      ZIsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface X @end typedef X Y; @interface Z : Y @end",
+                  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface A @end typedef A X; typedef A Y; @interface Z : Y @end",
       ZIsDerivedFromX));
@@ -798,27 +753,33 @@ TEST(DeclarationMatcher, ObjCClassIsDerived) {
       ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface A @end @compatibility_alias X A; @compatibility_alias Y A;"
-      "@interface Z : Y @end", ZIsDerivedFromX));
+      "@interface Z : Y @end",
+      ZIsDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface A @end @compatibility_alias X A; @compatibility_alias Y A;"
-      "@interface Z : Y @end", ZIsDirectlyDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface Y @end typedef Y X; @interface Z : X @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface Y @end typedef Y X; @interface Z : X @end",
+      "@interface Z : Y @end",
       ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
-      "@interface A @end @compatibility_alias Y A; typedef Y X;"
-      "@interface Z : A @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface A @end @compatibility_alias Y A; typedef Y X;"
-      "@interface Z : A @end", ZIsDirectlyDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface A @end typedef A Y; @compatibility_alias X Y;"
-      "@interface Z : A @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface A @end typedef A Y; @compatibility_alias X Y;"
-      "@interface Z : A @end", ZIsDirectlyDerivedFromX));
+      "@interface Y @end typedef Y X; @interface Z : X @end", ZIsDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface Y @end typedef Y X; @interface Z : X @end",
+                  ZIsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end @compatibility_alias Y A; typedef Y X;"
+                  "@interface Z : A @end",
+                  ZIsDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end @compatibility_alias Y A; typedef Y X;"
+                  "@interface Z : A @end",
+                  ZIsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end typedef A Y; @compatibility_alias X Y;"
+                  "@interface Z : A @end",
+                  ZIsDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end typedef A Y; @compatibility_alias X Y;"
+                  "@interface Z : A @end",
+                  ZIsDirectlyDerivedFromX));
 }
 
 TEST(DeclarationMatcher, IsLambda) {
@@ -830,42 +791,41 @@ TEST(DeclarationMatcher, IsLambda) {
 TEST(Matcher, BindMatchedNodes) {
   DeclarationMatcher ClassX = has(recordDecl(hasName("::X")).bind("x"));
 
-  EXPECT_TRUE(matchAndVerifyResultTrue("class X {};",
-                                       ClassX, std::make_unique>("x")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "class X {};", ClassX,
+      std::make_unique>("x")));
 
-  EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
-                                        ClassX, std::make_unique>("other-id")));
+  EXPECT_TRUE(matchAndVerifyResultFalse(
+      "class X {};", ClassX,
+      std::make_unique>("other-id")));
 
   TypeMatcher TypeAHasClassB = hasDeclaration(
-    recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b"))));
+      recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b"))));
 
-  EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; };",
-                                       TypeAHasClassB,
-                                       std::make_unique>("b")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "class A { public: A *a; class B {}; };", TypeAHasClassB,
+      std::make_unique>("b")));
 
   StatementMatcher MethodX =
-    callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x");
+      callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x");
 
-  EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
-                                       MethodX,
-                                       std::make_unique>("x")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "class A { void x() { x(); } };", MethodX,
+      std::make_unique>("x")));
 }
 
 TEST(Matcher, BindTheSameNameInAlternatives) {
   StatementMatcher matcher = anyOf(
-    binaryOperator(hasOperatorName("+"),
-                   hasLHS(expr().bind("x")),
-                   hasRHS(integerLiteral(equals(0)))),
-    binaryOperator(hasOperatorName("+"),
-                   hasLHS(integerLiteral(equals(0))),
-                   hasRHS(expr().bind("x"))));
+      binaryOperator(hasOperatorName("+"), hasLHS(expr().bind("x")),
+                     hasRHS(integerLiteral(equals(0)))),
+      binaryOperator(hasOperatorName("+"), hasLHS(integerLiteral(equals(0))),
+                     hasRHS(expr().bind("x"))));
 
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    // The first branch of the matcher binds x to 0 but then fails.
-    // The second branch binds x to f() and succeeds.
-    "int f() { return 0 + f(); }",
-    matcher,
-    std::make_unique>("x")));
+      // The first branch of the matcher binds x to 0 but then fails.
+      // The second branch binds x to f() and succeeds.
+      "int f() { return 0 + f(); }", matcher,
+      std::make_unique>("x")));
 }
 
 TEST(Matcher, BindsIDForMemoizedResults) {
@@ -873,48 +833,48 @@ TEST(Matcher, BindsIDForMemoizedResults) {
   // kick in.
   DeclarationMatcher ClassX = recordDecl(hasName("X")).bind("x");
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { class B { class X {}; }; };",
-    DeclarationMatcher(anyOf(
-      recordDecl(hasName("A"), hasDescendant(ClassX)),
-      recordDecl(hasName("B"), hasDescendant(ClassX)))),
-    std::make_unique>("x", 2)));
+      "class A { class B { class X {}; }; };",
+      DeclarationMatcher(
+          anyOf(recordDecl(hasName("A"), hasDescendant(ClassX)),
+                recordDecl(hasName("B"), hasDescendant(ClassX)))),
+      std::make_unique>("x", 2)));
 }
 
 TEST(HasType, MatchesAsString) {
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
-            cxxMemberCallExpr(on(hasType(asString("class Y *"))))));
+      matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
+              cxxMemberCallExpr(on(hasType(asString("class Y *"))))));
   EXPECT_TRUE(
-    matches("class X { void x(int x) {} };",
-            cxxMethodDecl(hasParameter(0, hasType(asString("int"))))));
+      matches("class X { void x(int x) {} };",
+              cxxMethodDecl(hasParameter(0, hasType(asString("int"))))));
   EXPECT_TRUE(matches("namespace ns { struct A {}; }  struct B { ns::A a; };",
                       fieldDecl(hasType(asString("ns::A")))));
-  EXPECT_TRUE(matches("namespace { struct A {}; }  struct B { A a; };",
-                      fieldDecl(hasType(asString("struct (anonymous namespace)::A")))));
+  EXPECT_TRUE(
+      matches("namespace { struct A {}; }  struct B { A a; };",
+              fieldDecl(hasType(asString("struct (anonymous namespace)::A")))));
 }
 
 TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
   StatementMatcher OpCallAndAnd =
-    cxxOperatorCallExpr(hasOverloadedOperatorName("&&"));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("&&"));
   EXPECT_TRUE(matches("class Y { }; "
-                        "bool operator&&(Y x, Y y) { return true; }; "
-                        "Y a; Y b; bool c = a && b;", OpCallAndAnd));
+                      "bool operator&&(Y x, Y y) { return true; }; "
+                      "Y a; Y b; bool c = a && b;",
+                      OpCallAndAnd));
   StatementMatcher OpCallLessLess =
-    cxxOperatorCallExpr(hasOverloadedOperatorName("<<"));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("<<"));
   EXPECT_TRUE(notMatches("class Y { }; "
-                           "bool operator&&(Y x, Y y) { return true; }; "
-                           "Y a; Y b; bool c = a && b;",
+                         "bool operator&&(Y x, Y y) { return true; }; "
+                         "Y a; Y b; bool c = a && b;",
                          OpCallLessLess));
   StatementMatcher OpStarCall =
-    cxxOperatorCallExpr(hasOverloadedOperatorName("*"));
-  EXPECT_TRUE(matches("class Y; int operator*(Y &); void f(Y &y) { *y; }",
-                      OpStarCall));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("*"));
+  EXPECT_TRUE(
+      matches("class Y; int operator*(Y &); void f(Y &y) { *y; }", OpStarCall));
   DeclarationMatcher ClassWithOpStar =
-    cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")));
-  EXPECT_TRUE(matches("class Y { int operator*(); };",
-                      ClassWithOpStar));
-  EXPECT_TRUE(notMatches("class Y { void myOperator(); };",
-                         ClassWithOpStar)) ;
+      cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")));
+  EXPECT_TRUE(matches("class Y { int operator*(); };", ClassWithOpStar));
+  EXPECT_TRUE(notMatches("class Y { void myOperator(); };", ClassWithOpStar));
   DeclarationMatcher AnyOpStar = functionDecl(hasOverloadedOperatorName("*"));
   EXPECT_TRUE(matches("class Y; int operator*(Y &);", AnyOpStar));
   EXPECT_TRUE(matches("class Y { int operator*(); };", AnyOpStar));
@@ -926,23 +886,22 @@ TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
   EXPECT_TRUE(matches("class Y { Y operator&&(Y &); };", AnyAndOp));
 }
 
-
 TEST(Matcher, NestedOverloadedOperatorCalls) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class Y { }; "
+      "class Y { }; "
       "Y& operator&&(Y& x, Y& y) { return x; }; "
       "Y a; Y b; Y c; Y d = a && b && c;",
-    cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
-    std::make_unique>("x", 2)));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
+      std::make_unique>("x", 2)));
   EXPECT_TRUE(matches("class Y { }; "
-                        "Y& operator&&(Y& x, Y& y) { return x; }; "
-                        "Y a; Y b; Y c; Y d = a && b && c;",
+                      "Y& operator&&(Y& x, Y& y) { return x; }; "
+                      "Y a; Y b; Y c; Y d = a && b && c;",
                       cxxOperatorCallExpr(hasParent(cxxOperatorCallExpr()))));
   EXPECT_TRUE(
-    matches("class Y { }; "
+      matches("class Y { }; "
               "Y& operator&&(Y& x, Y& y) { return x; }; "
               "Y a; Y b; Y c; Y d = a && b && c;",
-            cxxOperatorCallExpr(hasDescendant(cxxOperatorCallExpr()))));
+              cxxOperatorCallExpr(hasDescendant(cxxOperatorCallExpr()))));
 }
 
 TEST(Matcher, VarDecl_Storage) {
@@ -971,9 +930,9 @@ TEST(Matcher, VarDecl_StorageDuration) {
 
   EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration())));
   EXPECT_TRUE(
-    notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration())));
+      notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration())));
   EXPECT_TRUE(
-    notMatches(T, varDecl(hasName("a"), hasAutomaticStorageDuration())));
+      notMatches(T, varDecl(hasName("a"), hasAutomaticStorageDuration())));
 
   EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration())));
   EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration())));
@@ -991,48 +950,48 @@ TEST(Matcher, VarDecl_StorageDuration) {
 }
 
 TEST(Matcher, FindsVarDeclInFunctionParameter) {
-  EXPECT_TRUE(matches(
-    "void f(int i) {}",
-    varDecl(hasName("i"))));
+  EXPECT_TRUE(matches("void f(int i) {}", varDecl(hasName("i"))));
 }
 
 TEST(UnaryExpressionOrTypeTraitExpression, MatchesCorrectType) {
-  EXPECT_TRUE(matches("void x() { int a = sizeof(a); }", sizeOfExpr(
-    hasArgumentOfType(asString("int")))));
-  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }", sizeOfExpr(
-    hasArgumentOfType(asString("float")))));
+  EXPECT_TRUE(matches("void x() { int a = sizeof(a); }",
+                      sizeOfExpr(hasArgumentOfType(asString("int")))));
+  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
+                         sizeOfExpr(hasArgumentOfType(asString("float")))));
   EXPECT_TRUE(matches(
-    "struct A {}; void x() { A a; int b = sizeof(a); }",
-    sizeOfExpr(hasArgumentOfType(hasDeclaration(recordDecl(hasName("A")))))));
-  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }", sizeOfExpr(
-    hasArgumentOfType(hasDeclaration(recordDecl(hasName("string")))))));
+      "struct A {}; void x() { A a; int b = sizeof(a); }",
+      sizeOfExpr(hasArgumentOfType(hasDeclaration(recordDecl(hasName("A")))))));
+  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
+                         sizeOfExpr(hasArgumentOfType(
+                             hasDeclaration(recordDecl(hasName("string")))))));
 }
 
 TEST(IsInteger, MatchesIntegers) {
   EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isInteger()))));
-  EXPECT_TRUE(matches(
-    "long long i = 0; void f(long long) { }; void g() {f(i);}",
-    callExpr(hasArgument(0, declRefExpr(
-      to(varDecl(hasType(isInteger()))))))));
+  EXPECT_TRUE(
+      matches("long long i = 0; void f(long long) { }; void g() {f(i);}",
+              callExpr(hasArgument(
+                  0, declRefExpr(to(varDecl(hasType(isInteger()))))))));
 }
 
 TEST(IsInteger, ReportsNoFalsePositives) {
   EXPECT_TRUE(notMatches("int *i;", varDecl(hasType(isInteger()))));
-  EXPECT_TRUE(notMatches("struct T {}; T t; void f(T *) { }; void g() {f(&t);}",
-                         callExpr(hasArgument(0, declRefExpr(
-                           to(varDecl(hasType(isInteger()))))))));
+  EXPECT_TRUE(
+      notMatches("struct T {}; T t; void f(T *) { }; void g() {f(&t);}",
+                 callExpr(hasArgument(
+                     0, declRefExpr(to(varDecl(hasType(isInteger()))))))));
 }
 
 TEST(IsSignedInteger, MatchesSignedIntegers) {
   EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isSignedInteger()))));
-  EXPECT_TRUE(notMatches("unsigned i = 0;",
-                         varDecl(hasType(isSignedInteger()))));
+  EXPECT_TRUE(
+      notMatches("unsigned i = 0;", varDecl(hasType(isSignedInteger()))));
 }
 
 TEST(IsUnsignedInteger, MatchesUnsignedIntegers) {
   EXPECT_TRUE(notMatches("int i = 0;", varDecl(hasType(isUnsignedInteger()))));
-  EXPECT_TRUE(matches("unsigned i = 0;",
-                      varDecl(hasType(isUnsignedInteger()))));
+  EXPECT_TRUE(
+      matches("unsigned i = 0;", varDecl(hasType(isUnsignedInteger()))));
 }
 
 TEST(IsAnyPointer, MatchesPointers) {
@@ -1059,8 +1018,8 @@ TEST(IsAnyCharacter, ReportsNoFalsePositives) {
 TEST(IsArrow, MatchesMemberVariablesViaArrow) {
   EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
                       memberExpr(isArrow())));
-  EXPECT_TRUE(matches("class Y { void x() { y; } int y; };",
-                      memberExpr(isArrow())));
+  EXPECT_TRUE(
+      matches("class Y { void x() { y; } int y; };", memberExpr(isArrow())));
   EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
                          memberExpr(isArrow())));
   EXPECT_TRUE(matches("template  class Y { void x() { this->m; } };",
@@ -1080,10 +1039,9 @@ TEST(IsArrow, MatchesStaticMemberVariablesViaArrow) {
 }
 
 TEST(IsArrow, MatchesMemberCallsViaArrow) {
-  EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
-                      memberExpr(isArrow())));
-  EXPECT_TRUE(matches("class Y { void x() { x(); } };",
-                      memberExpr(isArrow())));
+  EXPECT_TRUE(
+      matches("class Y { void x() { this->x(); } };", memberExpr(isArrow())));
+  EXPECT_TRUE(matches("class Y { void x() { x(); } };", memberExpr(isArrow())));
   EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
                          memberExpr(isArrow())));
   EXPECT_TRUE(
@@ -1128,20 +1086,18 @@ TEST(Matcher, ParameterCount) {
 }
 
 TEST(Matcher, References) {
-  DeclarationMatcher ReferenceClassX = varDecl(
-    hasType(references(recordDecl(hasName("X")))));
-  EXPECT_TRUE(matches("class X {}; void y(X y) { X &x = y; }",
-                      ReferenceClassX));
+  DeclarationMatcher ReferenceClassX =
+      varDecl(hasType(references(recordDecl(hasName("X")))));
   EXPECT_TRUE(
-    matches("class X {}; void y(X y) { const X &x = y; }", ReferenceClassX));
+      matches("class X {}; void y(X y) { X &x = y; }", ReferenceClassX));
+  EXPECT_TRUE(
+      matches("class X {}; void y(X y) { const X &x = y; }", ReferenceClassX));
   // The match here is on the implicit copy constructor code for
   // class X, not on code 'X x = y'.
+  EXPECT_TRUE(matches("class X {}; void y(X y) { X x = y; }", ReferenceClassX));
+  EXPECT_TRUE(notMatches("class X {}; extern X x;", ReferenceClassX));
   EXPECT_TRUE(
-    matches("class X {}; void y(X y) { X x = y; }", ReferenceClassX));
-  EXPECT_TRUE(
-    notMatches("class X {}; extern X x;", ReferenceClassX));
-  EXPECT_TRUE(
-    notMatches("class X {}; void y(X *y) { X *&x = y; }", ReferenceClassX));
+      notMatches("class X {}; void y(X *y) { X *&x = y; }", ReferenceClassX));
 }
 
 TEST(QualType, hasLocalQualifiers) {
@@ -1149,16 +1105,15 @@ TEST(QualType, hasLocalQualifiers) {
                          varDecl(hasType(hasLocalQualifiers()))));
   EXPECT_TRUE(matches("int *const j = nullptr;",
                       varDecl(hasType(hasLocalQualifiers()))));
-  EXPECT_TRUE(matches("int *volatile k;",
-                      varDecl(hasType(hasLocalQualifiers()))));
-  EXPECT_TRUE(notMatches("int m;",
-                         varDecl(hasType(hasLocalQualifiers()))));
+  EXPECT_TRUE(
+      matches("int *volatile k;", varDecl(hasType(hasLocalQualifiers()))));
+  EXPECT_TRUE(notMatches("int m;", varDecl(hasType(hasLocalQualifiers()))));
 }
 
 TEST(IsExternC, MatchesExternCFunctionDeclarations) {
   EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC())));
-  EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
-                      functionDecl(isExternC())));
+  EXPECT_TRUE(
+      matches("extern \"C\" { void f() {} }", functionDecl(isExternC())));
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isExternC())));
 }
 
@@ -1186,7 +1141,7 @@ TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
 
 TEST(IsDeleted, MatchesDeletedFunctionDeclarations) {
   EXPECT_TRUE(
-    notMatches("void Func();", functionDecl(hasName("Func"), isDeleted())));
+      notMatches("void Func();", functionDecl(hasName("Func"), isDeleted())));
   EXPECT_TRUE(matches("void Func() = delete;",
                       functionDecl(hasName("Func"), isDeleted())));
 }
@@ -1195,14 +1150,15 @@ TEST(IsNoThrow, MatchesNoThrowFunctionDeclarations) {
   EXPECT_TRUE(notMatches("void f();", functionDecl(isNoThrow())));
   EXPECT_TRUE(notMatches("void f() throw(int);", functionDecl(isNoThrow())));
   EXPECT_TRUE(
-    notMatches("void f() noexcept(false);", functionDecl(isNoThrow())));
+      notMatches("void f() noexcept(false);", functionDecl(isNoThrow())));
   EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow())));
   EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow())));
 
   EXPECT_TRUE(notMatches("void f();", functionProtoType(isNoThrow())));
-  EXPECT_TRUE(notMatches("void f() throw(int);", functionProtoType(isNoThrow())));
   EXPECT_TRUE(
-    notMatches("void f() noexcept(false);", functionProtoType(isNoThrow())));
+      notMatches("void f() throw(int);", functionProtoType(isNoThrow())));
+  EXPECT_TRUE(
+      notMatches("void f() noexcept(false);", functionProtoType(isNoThrow())));
   EXPECT_TRUE(matches("void f() throw();", functionProtoType(isNoThrow())));
   EXPECT_TRUE(matches("void f() noexcept;", functionProtoType(isNoThrow())));
 }
@@ -1249,41 +1205,41 @@ TEST(hasInitStatement, MatchesRangeForInitializers) {
 
 TEST(TemplateArgumentCountIs, Matches) {
   EXPECT_TRUE(
-    matches("template struct C {}; C c;",
-            classTemplateSpecializationDecl(templateArgumentCountIs(1))));
+      matches("template struct C {}; C c;",
+              classTemplateSpecializationDecl(templateArgumentCountIs(1))));
   EXPECT_TRUE(
-    notMatches("template struct C {}; C c;",
-               classTemplateSpecializationDecl(templateArgumentCountIs(2))));
+      notMatches("template struct C {}; C c;",
+                 classTemplateSpecializationDecl(templateArgumentCountIs(2))));
 
   EXPECT_TRUE(matches("template struct C {}; C c;",
                       templateSpecializationType(templateArgumentCountIs(1))));
   EXPECT_TRUE(
-    notMatches("template struct C {}; C c;",
-               templateSpecializationType(templateArgumentCountIs(2))));
+      notMatches("template struct C {}; C c;",
+                 templateSpecializationType(templateArgumentCountIs(2))));
 }
 
 TEST(IsIntegral, Matches) {
-  EXPECT_TRUE(matches("template struct C {}; C<42> c;",
-                      classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(isIntegral()))));
+  EXPECT_TRUE(matches(
+      "template struct C {}; C<42> c;",
+      classTemplateSpecializationDecl(hasAnyTemplateArgument(isIntegral()))));
   EXPECT_TRUE(notMatches("template struct C {}; C c;",
                          classTemplateSpecializationDecl(hasAnyTemplateArgument(
-                           templateArgument(isIntegral())))));
+                             templateArgument(isIntegral())))));
 }
 
 TEST(EqualsIntegralValue, Matches) {
   EXPECT_TRUE(matches("template struct C {}; C<42> c;",
                       classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(equalsIntegralValue("42")))));
+                          hasAnyTemplateArgument(equalsIntegralValue("42")))));
   EXPECT_TRUE(matches("template struct C {}; C<-42> c;",
                       classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(equalsIntegralValue("-42")))));
+                          hasAnyTemplateArgument(equalsIntegralValue("-42")))));
   EXPECT_TRUE(matches("template struct C {}; C<-0042> c;",
                       classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(equalsIntegralValue("-34")))));
+                          hasAnyTemplateArgument(equalsIntegralValue("-34")))));
   EXPECT_TRUE(notMatches("template struct C {}; C<42> c;",
                          classTemplateSpecializationDecl(hasAnyTemplateArgument(
-                           equalsIntegralValue("0042")))));
+                             equalsIntegralValue("0042")))));
 }
 
 TEST(Matcher, MatchesAccessSpecDecls) {
@@ -1304,7 +1260,7 @@ TEST(Matcher, MatchesFinal) {
                       cxxMethodDecl(isFinal())));
   EXPECT_TRUE(notMatches("class X {};", cxxRecordDecl(isFinal())));
   EXPECT_TRUE(
-    notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal())));
+      notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal())));
 }
 
 TEST(Matcher, MatchesVirtualMethod) {
@@ -1315,12 +1271,12 @@ TEST(Matcher, MatchesVirtualMethod) {
 
 TEST(Matcher, MatchesVirtualAsWrittenMethod) {
   EXPECT_TRUE(matches("class A { virtual int f(); };"
-                        "class B : public A { int f(); };",
+                      "class B : public A { int f(); };",
                       cxxMethodDecl(isVirtualAsWritten(), hasName("::A::f"))));
   EXPECT_TRUE(
-    notMatches("class A { virtual int f(); };"
+      notMatches("class A { virtual int f(); };"
                  "class B : public A { int f(); };",
-               cxxMethodDecl(isVirtualAsWritten(), hasName("::B::f"))));
+                 cxxMethodDecl(isVirtualAsWritten(), hasName("::B::f"))));
 }
 
 TEST(Matcher, MatchesPureMethod) {
@@ -1358,26 +1314,26 @@ TEST(Matcher, MatchesMoveAssignmentOperator) {
 
 TEST(Matcher, MatchesConstMethod) {
   EXPECT_TRUE(
-    matches("struct A { void foo() const; };", cxxMethodDecl(isConst())));
+      matches("struct A { void foo() const; };", cxxMethodDecl(isConst())));
   EXPECT_TRUE(
-    notMatches("struct A { void foo(); };", cxxMethodDecl(isConst())));
+      notMatches("struct A { void foo(); };", cxxMethodDecl(isConst())));
 }
 
 TEST(Matcher, MatchesOverridingMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); }; "
-                        "class Y : public X { int f(); };",
+                      "class Y : public X { int f(); };",
                       cxxMethodDecl(isOverride(), hasName("::Y::f"))));
   EXPECT_TRUE(notMatches("class X { virtual int f(); }; "
-                           "class Y : public X { int f(); };",
+                         "class Y : public X { int f(); };",
                          cxxMethodDecl(isOverride(), hasName("::X::f"))));
   EXPECT_TRUE(notMatches("class X { int f(); }; "
-                           "class Y : public X { int f(); };",
+                         "class Y : public X { int f(); };",
                          cxxMethodDecl(isOverride())));
   EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ",
                          cxxMethodDecl(isOverride())));
   EXPECT_TRUE(
-    matches("template  struct Y : Base { void f() override;};",
-            cxxMethodDecl(isOverride(), hasName("::Y::f"))));
+      matches("template  struct Y : Base { void f() override;};",
+              cxxMethodDecl(isOverride(), hasName("::Y::f"))));
 }
 
 TEST(Matcher, ConstructorArgument) {
@@ -1385,44 +1341,38 @@ TEST(Matcher, ConstructorArgument) {
       ast_type_traits::TK_AsIs,
       cxxConstructExpr(hasArgument(0, declRefExpr(to(varDecl(hasName("y")))))));
 
+  EXPECT_TRUE(matches(
+      "class X { public: X(int); }; void x() { int y; X x(y); }", Constructor));
   EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { int y; X x(y); }",
-            Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { int y; X x = X(y); }",
-            Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { int y; X x = y; }",
-            Constructor));
+      matches("class X { public: X(int); }; void x() { int y; X x = X(y); }",
+              Constructor));
   EXPECT_TRUE(
-    notMatches("class X { public: X(int); }; void x() { int z; X x(z); }",
-               Constructor));
+      matches("class X { public: X(int); }; void x() { int y; X x = y; }",
+              Constructor));
+  EXPECT_TRUE(notMatches(
+      "class X { public: X(int); }; void x() { int z; X x(z); }", Constructor));
 
   StatementMatcher WrongIndex =
       traverse(ast_type_traits::TK_AsIs,
                cxxConstructExpr(
                    hasArgument(42, declRefExpr(to(varDecl(hasName("y")))))));
-  EXPECT_TRUE(
-    notMatches("class X { public: X(int); }; void x() { int y; X x(y); }",
-               WrongIndex));
+  EXPECT_TRUE(notMatches(
+      "class X { public: X(int); }; void x() { int y; X x(y); }", WrongIndex));
 }
 
 TEST(Matcher, ConstructorArgumentCount) {
   auto Constructor1Arg =
       traverse(ast_type_traits::TK_AsIs, cxxConstructExpr(argumentCountIs(1)));
 
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x(0); }",
+                      Constructor1Arg));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x = X(0); }",
+                      Constructor1Arg));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x = 0; }",
+                      Constructor1Arg));
   EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x(0); }",
-            Constructor1Arg));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x = X(0); }",
-            Constructor1Arg));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x = 0; }",
-            Constructor1Arg));
-  EXPECT_TRUE(
-    notMatches("class X { public: X(int, int); }; void x() { X x(0, 0); }",
-               Constructor1Arg));
+      notMatches("class X { public: X(int, int); }; void x() { X x(0, 0); }",
+                 Constructor1Arg));
 }
 
 TEST(Matcher, ConstructorListInitialization) {
@@ -1430,19 +1380,16 @@ TEST(Matcher, ConstructorListInitialization) {
       traverse(ast_type_traits::TK_AsIs,
                varDecl(has(cxxConstructExpr(isListInitialization()))));
 
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x{0}; }",
-            ConstructorListInit));
-  EXPECT_FALSE(
-    matches("class X { public: X(int); }; void x() { X x(0); }",
-            ConstructorListInit));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x{0}; }",
+                      ConstructorListInit));
+  EXPECT_FALSE(matches("class X { public: X(int); }; void x() { X x(0); }",
+                       ConstructorListInit));
 }
 
 TEST(ConstructorDeclaration, IsImplicit) {
   // This one doesn't match because the constructor is not added by the
   // compiler (it is not needed).
-  EXPECT_TRUE(notMatches("class Foo { };",
-                         cxxConstructorDecl(isImplicit())));
+  EXPECT_TRUE(notMatches("class Foo { };", cxxConstructorDecl(isImplicit())));
   // The compiler added the implicit default constructor.
   EXPECT_TRUE(matches("class Foo { }; Foo* f = new Foo();",
                       cxxConstructorDecl(isImplicit())));
@@ -1456,8 +1403,8 @@ TEST(ConstructorDeclaration, IsImplicit) {
 TEST(ConstructorDeclaration, IsExplicit) {
   EXPECT_TRUE(matches("struct S { explicit S(int); };",
                       cxxConstructorDecl(isExplicit())));
-  EXPECT_TRUE(notMatches("struct S { S(int); };",
-                         cxxConstructorDecl(isExplicit())));
+  EXPECT_TRUE(
+      notMatches("struct S { S(int); };", cxxConstructorDecl(isExplicit())));
   EXPECT_TRUE(notMatches("template struct S { explicit(b) S(int);};",
                          cxxConstructorDecl(isExplicit()), langCxx20OrLater()));
   EXPECT_TRUE(matches("struct S { explicit(true) S(int);};",
@@ -1488,9 +1435,9 @@ TEST(DeductionGuideDeclaration, IsExplicit) {
 }
 
 TEST(ConstructorDeclaration, Kinds) {
-  EXPECT_TRUE(matches(
-      "struct S { S(); };",
-      cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit()))));
+  EXPECT_TRUE(
+      matches("struct S { S(); };", cxxConstructorDecl(isDefaultConstructor(),
+                                                       unless(isImplicit()))));
   EXPECT_TRUE(notMatches(
       "struct S { S(); };",
       cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
@@ -1501,9 +1448,9 @@ TEST(ConstructorDeclaration, Kinds) {
   EXPECT_TRUE(notMatches(
       "struct S { S(const S&); };",
       cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit()))));
-  EXPECT_TRUE(matches(
-      "struct S { S(const S&); };",
-      cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
+  EXPECT_TRUE(
+      matches("struct S { S(const S&); };",
+              cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
   EXPECT_TRUE(notMatches(
       "struct S { S(const S&); };",
       cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))));
@@ -1514,9 +1461,9 @@ TEST(ConstructorDeclaration, Kinds) {
   EXPECT_TRUE(notMatches(
       "struct S { S(S&&); };",
       cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
-  EXPECT_TRUE(matches(
-      "struct S { S(S&&); };",
-      cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))));
+  EXPECT_TRUE(
+      matches("struct S { S(S&&); };",
+              cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))));
 }
 
 TEST(ConstructorDeclaration, IsUserProvided) {
@@ -1527,7 +1474,7 @@ TEST(ConstructorDeclaration, IsUserProvided) {
   EXPECT_TRUE(notMatches("struct S { S() = delete; };",
                          cxxConstructorDecl(isUserProvided())));
   EXPECT_TRUE(
-    matches("struct S { S(); };", cxxConstructorDecl(isUserProvided())));
+      matches("struct S { S(); };", cxxConstructorDecl(isUserProvided())));
   EXPECT_TRUE(matches("struct S { S(); }; S::S(){}",
                       cxxConstructorDecl(isUserProvided())));
 }
@@ -1538,11 +1485,11 @@ TEST(ConstructorDeclaration, IsDelegatingConstructor) {
   EXPECT_TRUE(notMatches("struct S { S(){} S(int X) : X(X) {} int X; };",
                          cxxConstructorDecl(isDelegatingConstructor())));
   EXPECT_TRUE(matches(
-    "struct S { S() : S(0) {} S(int X) : X(X) {} int X; };",
-    cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(0))));
+      "struct S { S() : S(0) {} S(int X) : X(X) {} int X; };",
+      cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(0))));
   EXPECT_TRUE(matches(
-    "struct S { S(); S(int X); int X; }; S::S(int X) : S() {}",
-    cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1))));
+      "struct S { S(); S(int X); int X; }; S::S(int X) : S() {}",
+      cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1))));
 }
 
 TEST(StringLiteral, HasSize) {
@@ -1584,38 +1531,28 @@ TEST(Matcher, HasNameSupportsNamespaces) {
 }
 
 TEST(Matcher, HasNameSupportsOuterClasses) {
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("A::B::C"))));
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("::A::B::C"))));
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("B::C"))));
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("c::B::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("A::c::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("A::B::A"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("::B::C"))));
+  EXPECT_TRUE(matches("class A { class B { class C; }; };",
+                      recordDecl(hasName("A::B::C"))));
+  EXPECT_TRUE(matches("class A { class B { class C; }; };",
+                      recordDecl(hasName("::A::B::C"))));
+  EXPECT_TRUE(matches("class A { class B { class C; }; };",
+                      recordDecl(hasName("B::C"))));
+  EXPECT_TRUE(
+      matches("class A { class B { class C; }; };", recordDecl(hasName("C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("c::B::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("A::c::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("A::B::A"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("::B::C"))));
   EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
                          recordDecl(hasName("z::A::B::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("A+B::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("A+B::C"))));
 }
 
 TEST(Matcher, HasNameSupportsInlinedNamespaces) {
@@ -1629,10 +1566,10 @@ TEST(Matcher, HasNameSupportsInlinedNamespaces) {
 TEST(Matcher, HasNameSupportsAnonymousNamespaces) {
   StringRef code = "namespace a { namespace { class C; } }";
   EXPECT_TRUE(
-    matches(code, recordDecl(hasName("a::(anonymous namespace)::C"))));
+      matches(code, recordDecl(hasName("a::(anonymous namespace)::C"))));
   EXPECT_TRUE(matches(code, recordDecl(hasName("a::C"))));
   EXPECT_TRUE(
-    matches(code, recordDecl(hasName("::a::(anonymous namespace)::C"))));
+      matches(code, recordDecl(hasName("::a::(anonymous namespace)::C"))));
   EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C"))));
 }
 
@@ -1689,7 +1626,7 @@ TEST(Matcher, HasAnyName) {
 
   EXPECT_TRUE(notMatches(Code, recordDecl(hasAnyName("::C", "::b::C"))));
   EXPECT_TRUE(
-    matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C"))));
+      matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C"))));
 
   std::vector Names = {"::C", "::b::C", "::a::b::C"};
   EXPECT_TRUE(matches(Code, recordDecl(hasAnyName(Names))));
@@ -1697,27 +1634,27 @@ TEST(Matcher, HasAnyName) {
 
 TEST(Matcher, IsDefinition) {
   DeclarationMatcher DefinitionOfClassA =
-    recordDecl(hasName("A"), isDefinition());
+      recordDecl(hasName("A"), isDefinition());
   EXPECT_TRUE(matches("class A {};", DefinitionOfClassA));
   EXPECT_TRUE(notMatches("class A;", DefinitionOfClassA));
 
   DeclarationMatcher DefinitionOfVariableA =
-    varDecl(hasName("a"), isDefinition());
+      varDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("int a;", DefinitionOfVariableA));
   EXPECT_TRUE(notMatches("extern int a;", DefinitionOfVariableA));
 
   DeclarationMatcher DefinitionOfMethodA =
-    cxxMethodDecl(hasName("a"), isDefinition());
+      cxxMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
   EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
 
   DeclarationMatcher DefinitionOfObjCMethodA =
-    objcMethodDecl(hasName("a"), isDefinition());
+      objcMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matchesObjC("@interface A @end "
                           "@implementation A; -(void)a {} @end",
                           DefinitionOfObjCMethodA));
-  EXPECT_TRUE(notMatchesObjC("@interface A; - (void)a; @end",
-                             DefinitionOfObjCMethodA));
+  EXPECT_TRUE(
+      notMatchesObjC("@interface A; - (void)a; @end", DefinitionOfObjCMethodA));
 }
 
 TEST(Matcher, HandlesNullQualTypes) {
@@ -1728,7 +1665,7 @@ TEST(Matcher, HandlesNullQualTypes) {
   // We don't really care whether this matcher succeeds; we're testing that
   // it completes without crashing.
   EXPECT_TRUE(matches(
-    "struct A { };"
+      "struct A { };"
       "template "
       "void f(T t) {"
       "  T local_t(t /* this becomes a null QualType in the AST */);"
@@ -1736,13 +1673,10 @@ TEST(Matcher, HandlesNullQualTypes) {
       "void g() {"
       "  f(0);"
       "}",
-    expr(hasType(TypeMatcher(
-      anyOf(
-        TypeMatcher(hasDeclaration(anything())),
-        pointsTo(AnyType),
-        references(AnyType)
-        // Other QualType matchers should go here.
-      ))))));
+      expr(hasType(TypeMatcher(anyOf(TypeMatcher(hasDeclaration(anything())),
+                                     pointsTo(AnyType), references(AnyType)
+                                     // Other QualType matchers should go here.
+                                     ))))));
 }
 
 TEST(ObjCIvarRefExprMatcher, IvarExpr) {
@@ -1750,10 +1684,10 @@ TEST(ObjCIvarRefExprMatcher, IvarExpr) {
       "@interface A @end "
       "@implementation A { A *x; } - (void) func { x = 0; } @end";
   EXPECT_TRUE(matchesObjC(ObjCString, objcIvarRefExpr()));
-  EXPECT_TRUE(matchesObjC(ObjCString, objcIvarRefExpr(
-        hasDeclaration(namedDecl(hasName("x"))))));
-  EXPECT_FALSE(matchesObjC(ObjCString, objcIvarRefExpr(
-        hasDeclaration(namedDecl(hasName("y"))))));
+  EXPECT_TRUE(matchesObjC(
+      ObjCString, objcIvarRefExpr(hasDeclaration(namedDecl(hasName("x"))))));
+  EXPECT_FALSE(matchesObjC(
+      ObjCString, objcIvarRefExpr(hasDeclaration(namedDecl(hasName("y"))))));
 }
 
 TEST(BlockExprMatcher, BlockExpr) {
@@ -1761,24 +1695,19 @@ TEST(BlockExprMatcher, BlockExpr) {
 }
 
 TEST(StatementCountIs, FindsNoStatementsInAnEmptyCompoundStatement) {
-  EXPECT_TRUE(matches("void f() { }",
-                      compoundStmt(statementCountIs(0))));
-  EXPECT_TRUE(notMatches("void f() {}",
-                         compoundStmt(statementCountIs(1))));
+  EXPECT_TRUE(matches("void f() { }", compoundStmt(statementCountIs(0))));
+  EXPECT_TRUE(notMatches("void f() {}", compoundStmt(statementCountIs(1))));
 }
 
 TEST(StatementCountIs, AppearsToMatchOnlyOneCount) {
-  EXPECT_TRUE(matches("void f() { 1; }",
-                      compoundStmt(statementCountIs(1))));
-  EXPECT_TRUE(notMatches("void f() { 1; }",
-                         compoundStmt(statementCountIs(0))));
-  EXPECT_TRUE(notMatches("void f() { 1; }",
-                         compoundStmt(statementCountIs(2))));
+  EXPECT_TRUE(matches("void f() { 1; }", compoundStmt(statementCountIs(1))));
+  EXPECT_TRUE(notMatches("void f() { 1; }", compoundStmt(statementCountIs(0))));
+  EXPECT_TRUE(notMatches("void f() { 1; }", compoundStmt(statementCountIs(2))));
 }
 
 TEST(StatementCountIs, WorksWithMultipleStatements) {
-  EXPECT_TRUE(matches("void f() { 1; 2; 3; }",
-                      compoundStmt(statementCountIs(3))));
+  EXPECT_TRUE(
+      matches("void f() { 1; 2; 3; }", compoundStmt(statementCountIs(3))));
 }
 
 TEST(StatementCountIs, WorksWithNestedCompoundStatements) {
@@ -1806,19 +1735,19 @@ TEST(Member, DoesNotMatchTheBaseExpression) {
 
 TEST(Member, MatchesInMemberFunctionCall) {
   EXPECT_TRUE(matches("void f() {"
-                        "  struct { void first() {}; } s;"
-                        "  s.first();"
-                        "};",
+                      "  struct { void first() {}; } s;"
+                      "  s.first();"
+                      "};",
                       memberExpr(member(hasName("first")))));
 }
 
 TEST(Member, MatchesMember) {
-  EXPECT_TRUE(matches(
-    "struct A { int i; }; void f() { A a; a.i = 2; }",
-    memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
-  EXPECT_TRUE(notMatches(
-    "struct A { float f; }; void f() { A a; a.f = 2.0f; }",
-    memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
+  EXPECT_TRUE(
+      matches("struct A { int i; }; void f() { A a; a.i = 2; }",
+              memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
+  EXPECT_TRUE(
+      notMatches("struct A { float f; }; void f() { A a; a.f = 2.0f; }",
+                 memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
 }
 
 TEST(Member, BitFields) {
@@ -1841,26 +1770,26 @@ TEST(Member, InClassInitializer) {
 }
 
 TEST(Member, UnderstandsAccess) {
-  EXPECT_TRUE(matches(
-    "struct A { int i; };", fieldDecl(isPublic(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "struct A { int i; };", fieldDecl(isProtected(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "struct A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
+  EXPECT_TRUE(
+      matches("struct A { int i; };", fieldDecl(isPublic(), hasName("i"))));
+  EXPECT_TRUE(notMatches("struct A { int i; };",
+                         fieldDecl(isProtected(), hasName("i"))));
+  EXPECT_TRUE(
+      notMatches("struct A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
 
-  EXPECT_TRUE(notMatches(
-    "class A { int i; };", fieldDecl(isPublic(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "class A { int i; };", fieldDecl(isProtected(), hasName("i"))));
-  EXPECT_TRUE(matches(
-    "class A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
+  EXPECT_TRUE(
+      notMatches("class A { int i; };", fieldDecl(isPublic(), hasName("i"))));
+  EXPECT_TRUE(notMatches("class A { int i; };",
+                         fieldDecl(isProtected(), hasName("i"))));
+  EXPECT_TRUE(
+      matches("class A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
 
-  EXPECT_TRUE(notMatches(
-    "class A { protected: int i; };", fieldDecl(isPublic(), hasName("i"))));
+  EXPECT_TRUE(notMatches("class A { protected: int i; };",
+                         fieldDecl(isPublic(), hasName("i"))));
   EXPECT_TRUE(matches("class A { protected: int i; };",
                       fieldDecl(isProtected(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "class A { protected: int i; };", fieldDecl(isPrivate(), hasName("i"))));
+  EXPECT_TRUE(notMatches("class A { protected: int i; };",
+                         fieldDecl(isPrivate(), hasName("i"))));
 
   // Non-member decls have the AccessSpecifier AS_none and thus aren't matched.
   EXPECT_TRUE(notMatches("int i;", varDecl(isPublic(), hasName("i"))));
@@ -1883,35 +1812,35 @@ TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) {
   EXPECT_TRUE(
       matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec())));
 
-  EXPECT_TRUE(notMatches("void f();", functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(
+      notMatches("void f();", functionProtoType(hasDynamicExceptionSpec())));
   EXPECT_TRUE(notMatches("void g() noexcept;",
                          functionProtoType(hasDynamicExceptionSpec())));
   EXPECT_TRUE(notMatches("void h() noexcept(true);",
                          functionProtoType(hasDynamicExceptionSpec())));
   EXPECT_TRUE(notMatches("void i() noexcept(false);",
                          functionProtoType(hasDynamicExceptionSpec())));
-  EXPECT_TRUE(
-      matches("void j() throw();", functionProtoType(hasDynamicExceptionSpec())));
-  EXPECT_TRUE(
-      matches("void k() throw(int);", functionProtoType(hasDynamicExceptionSpec())));
-  EXPECT_TRUE(
-      matches("void l() throw(...);", functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(matches("void j() throw();",
+                      functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(matches("void k() throw(int);",
+                      functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(matches("void l() throw(...);",
+                      functionProtoType(hasDynamicExceptionSpec())));
 }
 
 TEST(HasObjectExpression, DoesNotMatchMember) {
   EXPECT_TRUE(notMatches(
-    "class X {}; struct Z { X m; }; void f(Z z) { z.m; }",
-    memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
+      "class X {}; struct Z { X m; }; void f(Z z) { z.m; }",
+      memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
 }
 
 TEST(HasObjectExpression, MatchesBaseOfVariable) {
   EXPECT_TRUE(matches(
-    "struct X { int m; }; void f(X x) { x.m; }",
-    memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
-  EXPECT_TRUE(matches(
-    "struct X { int m; }; void f(X* x) { x->m; }",
-    memberExpr(hasObjectExpression(
-      hasType(pointsTo(recordDecl(hasName("X"))))))));
+      "struct X { int m; }; void f(X x) { x.m; }",
+      memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
+  EXPECT_TRUE(matches("struct X { int m; }; void f(X* x) { x->m; }",
+                      memberExpr(hasObjectExpression(
+                          hasType(pointsTo(recordDecl(hasName("X"))))))));
   EXPECT_TRUE(matches("template  struct X { void f() { T t; t.m; } };",
                       cxxDependentScopeMemberExpr(hasObjectExpression(
                           declRefExpr(to(namedDecl(hasName("t"))))))));
@@ -1936,14 +1865,12 @@ TEST(HasObjectExpression, MatchesBaseOfMemberFunc) {
 
 TEST(HasObjectExpression,
      MatchesObjectExpressionOfImplicitlyFormedMemberExpression) {
-  EXPECT_TRUE(matches(
-    "class X {}; struct S { X m; void f() { this->m; } };",
-    memberExpr(hasObjectExpression(
-      hasType(pointsTo(recordDecl(hasName("S"))))))));
-  EXPECT_TRUE(matches(
-    "class X {}; struct S { X m; void f() { m; } };",
-    memberExpr(hasObjectExpression(
-      hasType(pointsTo(recordDecl(hasName("S"))))))));
+  EXPECT_TRUE(matches("class X {}; struct S { X m; void f() { this->m; } };",
+                      memberExpr(hasObjectExpression(
+                          hasType(pointsTo(recordDecl(hasName("S"))))))));
+  EXPECT_TRUE(matches("class X {}; struct S { X m; void f() { m; } };",
+                      memberExpr(hasObjectExpression(
+                          hasType(pointsTo(recordDecl(hasName("S"))))))));
 }
 
 TEST(Field, DoesNotMatchNonFieldMembers) {
@@ -1958,17 +1885,17 @@ TEST(Field, MatchesField) {
 }
 
 TEST(IsVolatileQualified, QualifiersMatch) {
-  EXPECT_TRUE(matches("volatile int i = 42;",
-                      varDecl(hasType(isVolatileQualified()))));
-  EXPECT_TRUE(notMatches("volatile int *i;",
-                         varDecl(hasType(isVolatileQualified()))));
+  EXPECT_TRUE(
+      matches("volatile int i = 42;", varDecl(hasType(isVolatileQualified()))));
+  EXPECT_TRUE(
+      notMatches("volatile int *i;", varDecl(hasType(isVolatileQualified()))));
   EXPECT_TRUE(matches("typedef volatile int v_int; v_int i = 42;",
                       varDecl(hasType(isVolatileQualified()))));
 }
 
 TEST(IsConstQualified, MatchesConstInt) {
-  EXPECT_TRUE(matches("const int i = 42;",
-                      varDecl(hasType(isConstQualified()))));
+  EXPECT_TRUE(
+      matches("const int i = 42;", varDecl(hasType(isConstQualified()))));
 }
 
 TEST(IsConstQualified, MatchesConstPointer) {
@@ -1986,43 +1913,41 @@ TEST(IsConstQualified, MatchesThroughTypedef) {
 TEST(IsConstQualified, DoesNotMatchInappropriately) {
   EXPECT_TRUE(notMatches("typedef int nonconst_int; nonconst_int i = 42;",
                          varDecl(hasType(isConstQualified()))));
-  EXPECT_TRUE(notMatches("int const* p;",
-                         varDecl(hasType(isConstQualified()))));
+  EXPECT_TRUE(
+      notMatches("int const* p;", varDecl(hasType(isConstQualified()))));
 }
 
 TEST(DeclCount, DeclCountIsCorrect) {
-  EXPECT_TRUE(matches("void f() {int i,j;}",
-                      declStmt(declCountIs(2))));
-  EXPECT_TRUE(notMatches("void f() {int i,j; int k;}",
-                         declStmt(declCountIs(3))));
-  EXPECT_TRUE(notMatches("void f() {int i,j, k, l;}",
-                         declStmt(declCountIs(3))));
+  EXPECT_TRUE(matches("void f() {int i,j;}", declStmt(declCountIs(2))));
+  EXPECT_TRUE(
+      notMatches("void f() {int i,j; int k;}", declStmt(declCountIs(3))));
+  EXPECT_TRUE(
+      notMatches("void f() {int i,j, k, l;}", declStmt(declCountIs(3))));
 }
 
-
 TEST(EachOf, TriggersForEachMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { int a; int b; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v")))),
-    std::make_unique>("v", 2)));
+      "class A { int a; int b; };",
+      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                        has(fieldDecl(hasName("b")).bind("v")))),
+      std::make_unique>("v", 2)));
 }
 
 TEST(EachOf, BehavesLikeAnyOfUnlessBothMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { int a; int c; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v")))),
-    std::make_unique>("v", 1)));
+      "class A { int a; int c; };",
+      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                        has(fieldDecl(hasName("b")).bind("v")))),
+      std::make_unique>("v", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { int c; int b; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v")))),
-    std::make_unique>("v", 1)));
-  EXPECT_TRUE(notMatches(
-    "class A { int c; int d; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v"))))));
+      "class A { int c; int b; };",
+      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                        has(fieldDecl(hasName("b")).bind("v")))),
+      std::make_unique>("v", 1)));
+  EXPECT_TRUE(
+      notMatches("class A { int c; int d; };",
+                 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                                   has(fieldDecl(hasName("b")).bind("v"))))));
 }
 
 TEST(Optionally, SubmatchersDoNotMatch) {
@@ -2056,29 +1981,30 @@ TEST(IsTemplateInstantiation, MatchesImplicitClassTemplateInstantiation) {
   // Make sure that we can both match the class by name (::X) and by the type
   // the template was instantiated with (via a field).
 
-  EXPECT_TRUE(matches(
-    "template  class X {}; class A {}; X x;",
-    cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      matches("template  class X {}; class A {}; X x;",
+              cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
 
   EXPECT_TRUE(matches(
-    "template  class X { T t; }; class A {}; X x;",
-    cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
-      fieldDecl(hasType(recordDecl(hasName("A"))))))));
+      "template  class X { T t; }; class A {}; X x;",
+      cxxRecordDecl(
+          isTemplateInstantiation(),
+          hasDescendant(fieldDecl(hasType(recordDecl(hasName("A"))))))));
 }
 
 TEST(IsTemplateInstantiation, MatchesImplicitFunctionTemplateInstantiation) {
   EXPECT_TRUE(matches(
-    "template  void f(T t) {} class A {}; void g() { f(A()); }",
-    functionDecl(hasParameter(0, hasType(recordDecl(hasName("A")))),
-                 isTemplateInstantiation())));
+      "template  void f(T t) {} class A {}; void g() { f(A()); }",
+      functionDecl(hasParameter(0, hasType(recordDecl(hasName("A")))),
+                   isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
-  EXPECT_TRUE(matches(
-    "template  class X { T t; }; class A {};"
-      "template class X;",
-    cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
-      fieldDecl(hasType(recordDecl(hasName("A"))))))));
+  EXPECT_TRUE(matches("template  class X { T t; }; class A {};"
+                      "template class X;",
+                      cxxRecordDecl(isTemplateInstantiation(),
+                                    hasDescendant(fieldDecl(
+                                        hasType(recordDecl(hasName("A"))))))));
 
   // Make sure that we match the instantiation instead of the template
   // definition by checking whether the member function is present.
@@ -2091,21 +2017,21 @@ TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
 
 TEST(IsTemplateInstantiation,
      MatchesInstantiationOfPartiallySpecializedClassTemplate) {
-  EXPECT_TRUE(matches(
-    "template  class X {};"
-      "template  class X {}; class A {}; X x;",
-    cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      matches("template  class X {};"
+              "template  class X {}; class A {}; X x;",
+              cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation,
      MatchesInstantiationOfClassTemplateNestedInNonTemplate) {
-  EXPECT_TRUE(matches(
-    "class A {};"
-      "class X {"
-      "  template  class Y { U u; };"
-      "  Y y;"
-      "};",
-    cxxRecordDecl(hasName("::X::Y"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      matches("class A {};"
+              "class X {"
+              "  template  class Y { U u; };"
+              "  Y y;"
+              "};",
+              cxxRecordDecl(hasName("::X::Y"), isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
@@ -2113,31 +2039,30 @@ TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
   // normal use case as long as the uppermost instantiation always is marked
   // as template instantiation, but it might be confusing as a predicate.
   EXPECT_TRUE(matches(
-    "class A {};"
+      "class A {};"
       "template  class X {"
       "  template  class Y { U u; };"
       "  Y y;"
       "}; X x;",
-    cxxRecordDecl(hasName("::X::Y"), unless(isTemplateInstantiation()))));
+      cxxRecordDecl(hasName("::X::Y"), unless(isTemplateInstantiation()))));
 }
 
 TEST(IsTemplateInstantiation, DoesNotMatchExplicitClassTemplateSpecialization) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {}; class A {};"
-      "template <> class X {}; X x;",
-    cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      notMatches("template  class X {}; class A {};"
+                 "template <> class X {}; X x;",
+                 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation, DoesNotMatchNonTemplate) {
-  EXPECT_TRUE(notMatches(
-    "class A {}; class Y { A a; };",
-    cxxRecordDecl(isTemplateInstantiation())));
+  EXPECT_TRUE(notMatches("class A {}; class Y { A a; };",
+                         cxxRecordDecl(isTemplateInstantiation())));
 }
 
 TEST(IsInstantiated, MatchesInstantiation) {
   EXPECT_TRUE(
-    matches("template class A { T i; }; class Y { A a; };",
-            cxxRecordDecl(isInstantiated())));
+      matches("template class A { T i; }; class Y { A a; };",
+              cxxRecordDecl(isInstantiated())));
 }
 
 TEST(IsInstantiated, NotMatchesDefinition) {
@@ -2147,7 +2072,7 @@ TEST(IsInstantiated, NotMatchesDefinition) {
 
 TEST(IsInTemplateInstantiation, MatchesInstantiationStmt) {
   EXPECT_TRUE(matches("template struct A { A() { T i; } };"
-                        "class Y { A a; }; Y y;",
+                      "class Y { A a; }; Y y;",
                       declStmt(isInTemplateInstantiation())));
 }
 
@@ -2158,8 +2083,8 @@ TEST(IsInTemplateInstantiation, NotMatchesDefinitionStmt) {
 
 TEST(IsInstantiated, MatchesFunctionInstantiation) {
   EXPECT_TRUE(
-    matches("template void A(T t) { T i; } void x() { A(0); }",
-            functionDecl(isInstantiated())));
+      matches("template void A(T t) { T i; } void x() { A(0); }",
+              functionDecl(isInstantiated())));
 }
 
 TEST(IsInstantiated, NotMatchesFunctionDefinition) {
@@ -2169,8 +2094,8 @@ TEST(IsInstantiated, NotMatchesFunctionDefinition) {
 
 TEST(IsInTemplateInstantiation, MatchesFunctionInstantiationStmt) {
   EXPECT_TRUE(
-    matches("template void A(T t) { T i; } void x() { A(0); }",
-            declStmt(isInTemplateInstantiation())));
+      matches("template void A(T t) { T i; } void x() { A(0); }",
+              declStmt(isInTemplateInstantiation())));
 }
 
 TEST(IsInTemplateInstantiation, NotMatchesFunctionDefinitionStmt) {
@@ -2183,11 +2108,11 @@ TEST(IsInTemplateInstantiation, Sharing) {
   // FIXME: Node sharing is an implementation detail, exposing it is ugly
   // and makes the matcher behave in non-obvious ways.
   EXPECT_TRUE(notMatches(
-    "int j; template void A(T t) { j += 42; } void x() { A(0); }",
-    Matcher));
+      "int j; template void A(T t) { j += 42; } void x() { A(0); }",
+      Matcher));
   EXPECT_TRUE(matches(
-    "int j; template void A(T t) { j += t; } void x() { A(0); }",
-    Matcher));
+      "int j; template void A(T t) { j += t; } void x() { A(0); }",
+      Matcher));
 }
 
 TEST(IsInstantiationDependent, MatchesNonValueTypeDependent) {
@@ -2232,48 +2157,41 @@ TEST(IsValueDependent, MatchesInstantiationDependent) {
       expr(isValueDependent())));
 }
 
-TEST(IsExplicitTemplateSpecialization,
-     DoesNotMatchPrimaryTemplate) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {};",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(notMatches(
-    "template  void f(T t);",
-    functionDecl(isExplicitTemplateSpecialization())));
+TEST(IsExplicitTemplateSpecialization, DoesNotMatchPrimaryTemplate) {
+  EXPECT_TRUE(notMatches("template  class X {};",
+                         cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(notMatches("template  void f(T t);",
+                         functionDecl(isExplicitTemplateSpecialization())));
 }
 
 TEST(IsExplicitTemplateSpecialization,
      DoesNotMatchExplicitTemplateInstantiations) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {};"
-      "template class X; extern template class X;",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(notMatches(
-    "template  void f(T t) {}"
-      "template void f(int t); extern template void f(long t);",
-    functionDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(
+      notMatches("template  class X {};"
+                 "template class X; extern template class X;",
+                 cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(
+      notMatches("template  void f(T t) {}"
+                 "template void f(int t); extern template void f(long t);",
+                 functionDecl(isExplicitTemplateSpecialization())));
 }
 
 TEST(IsExplicitTemplateSpecialization,
      DoesNotMatchImplicitTemplateInstantiations) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {}; X x;",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(notMatches(
-    "template  void f(T t); void g() { f(10); }",
-    functionDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(notMatches("template  class X {}; X x;",
+                         cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(
+      notMatches("template  void f(T t); void g() { f(10); }",
+                 functionDecl(isExplicitTemplateSpecialization())));
 }
 
-TEST(IsExplicitTemplateSpecialization,
-     MatchesExplicitTemplateSpecializations) {
-  EXPECT_TRUE(matches(
-    "template  class X {};"
-      "template<> class X {};",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(matches(
-    "template  void f(T t) {}"
-      "template<> void f(int t) {}",
-    functionDecl(isExplicitTemplateSpecialization())));
+TEST(IsExplicitTemplateSpecialization, MatchesExplicitTemplateSpecializations) {
+  EXPECT_TRUE(matches("template  class X {};"
+                      "template<> class X {};",
+                      cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(matches("template  void f(T t) {}"
+                      "template<> void f(int t) {}",
+                      functionDecl(isExplicitTemplateSpecialization())));
 }
 
 TEST(TypeMatching, MatchesNoReturn) {
@@ -2314,8 +2232,8 @@ TEST(TypeMatching, MatchesNoReturn) {
 
   EXPECT_TRUE(
       matches("struct S { [[noreturn]] S(); };", functionDecl(isNoReturn())));
-  EXPECT_TRUE(matches("struct S { [[noreturn]] S() {} };",
-                      functionDecl(isNoReturn())));
+  EXPECT_TRUE(
+      matches("struct S { [[noreturn]] S() {} };", functionDecl(isNoReturn())));
 
   // ---
 
@@ -2344,14 +2262,12 @@ TEST(TypeMatching, MatchesNoReturn) {
   // ---
 
   EXPECT_TRUE(matchesC("__attribute__((noreturn)) void func();",
-                      functionDecl(isNoReturn())));
+                       functionDecl(isNoReturn())));
   EXPECT_TRUE(matchesC("__attribute__((noreturn)) void func() {}",
-                      functionDecl(isNoReturn())));
+                       functionDecl(isNoReturn())));
 
-  EXPECT_TRUE(matchesC("_Noreturn void func();",
-                      functionDecl(isNoReturn())));
-  EXPECT_TRUE(matchesC("_Noreturn void func() {}",
-                      functionDecl(isNoReturn())));
+  EXPECT_TRUE(matchesC("_Noreturn void func();", functionDecl(isNoReturn())));
+  EXPECT_TRUE(matchesC("_Noreturn void func() {}", functionDecl(isNoReturn())));
 }
 
 TEST(TypeMatching, MatchesBool) {
@@ -2383,45 +2299,42 @@ TEST(TypeMatching, MatchesArrayTypes) {
   EXPECT_TRUE(notMatches("struct A {}; A a[7];",
                          arrayType(hasElementType(builtinType()))));
 
+  EXPECT_TRUE(matches("int const a[] = { 2, 3 };",
+                      qualType(arrayType(hasElementType(builtinType())))));
   EXPECT_TRUE(matches(
-    "int const a[] = { 2, 3 };",
-    qualType(arrayType(hasElementType(builtinType())))));
-  EXPECT_TRUE(matches(
-    "int const a[] = { 2, 3 };",
-    qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
-  EXPECT_TRUE(matches(
-    "typedef const int T; T x[] = { 1, 2 };",
-    qualType(isConstQualified(), arrayType())));
+      "int const a[] = { 2, 3 };",
+      qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
+  EXPECT_TRUE(matches("typedef const int T; T x[] = { 1, 2 };",
+                      qualType(isConstQualified(), arrayType())));
 
   EXPECT_TRUE(notMatches(
-    "int a[] = { 2, 3 };",
-    qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
-  EXPECT_TRUE(notMatches(
-    "int a[] = { 2, 3 };",
-    qualType(arrayType(hasElementType(isConstQualified(), builtinType())))));
+      "int a[] = { 2, 3 };",
+      qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
   EXPECT_TRUE(notMatches(
-    "int const a[] = { 2, 3 };",
-    qualType(arrayType(hasElementType(builtinType())),
-             unless(isConstQualified()))));
+      "int a[] = { 2, 3 };",
+      qualType(arrayType(hasElementType(isConstQualified(), builtinType())))));
+  EXPECT_TRUE(notMatches("int const a[] = { 2, 3 };",
+                         qualType(arrayType(hasElementType(builtinType())),
+                                  unless(isConstQualified()))));
 
-  EXPECT_TRUE(matches("int a[2];",
-                      constantArrayType(hasElementType(builtinType()))));
+  EXPECT_TRUE(
+      matches("int a[2];", constantArrayType(hasElementType(builtinType()))));
   EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger())));
 }
 
 TEST(TypeMatching, DecayedType) {
-  EXPECT_TRUE(matches("void f(int i[]);", valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))));
+  EXPECT_TRUE(
+      matches("void f(int i[]);",
+              valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))));
   EXPECT_TRUE(notMatches("int i[7];", decayedType()));
 }
 
 TEST(TypeMatching, MatchesComplexTypes) {
   EXPECT_TRUE(matches("_Complex float f;", complexType()));
-  EXPECT_TRUE(matches(
-    "_Complex float f;",
-    complexType(hasElementType(builtinType()))));
-  EXPECT_TRUE(notMatches(
-    "_Complex float f;",
-    complexType(hasElementType(isInteger()))));
+  EXPECT_TRUE(
+      matches("_Complex float f;", complexType(hasElementType(builtinType()))));
+  EXPECT_TRUE(notMatches("_Complex float f;",
+                         complexType(hasElementType(isInteger()))));
 }
 
 TEST(NS, Anonymous) {
@@ -2482,38 +2395,38 @@ TEST(DeclarationMatcher, InStdNamespace) {
 
 TEST(EqualsBoundNodeMatcher, QualType) {
   EXPECT_TRUE(matches(
-    "int i = 1;", varDecl(hasType(qualType().bind("type")),
-                          hasInitializer(ignoringParenImpCasts(
-                            hasType(qualType(equalsBoundNode("type"))))))));
+      "int i = 1;", varDecl(hasType(qualType().bind("type")),
+                            hasInitializer(ignoringParenImpCasts(
+                                hasType(qualType(equalsBoundNode("type"))))))));
   EXPECT_TRUE(notMatches("int i = 1.f;",
                          varDecl(hasType(qualType().bind("type")),
                                  hasInitializer(ignoringParenImpCasts(hasType(
-                                   qualType(equalsBoundNode("type"))))))));
+                                     qualType(equalsBoundNode("type"))))))));
 }
 
 TEST(EqualsBoundNodeMatcher, NonMatchingTypes) {
   EXPECT_TRUE(notMatches(
-    "int i = 1;", varDecl(namedDecl(hasName("i")).bind("name"),
-                          hasInitializer(ignoringParenImpCasts(
-                            hasType(qualType(equalsBoundNode("type"))))))));
+      "int i = 1;", varDecl(namedDecl(hasName("i")).bind("name"),
+                            hasInitializer(ignoringParenImpCasts(
+                                hasType(qualType(equalsBoundNode("type"))))))));
 }
 
 TEST(EqualsBoundNodeMatcher, Stmt) {
   EXPECT_TRUE(
-    matches("void f() { if(true) {} }",
-            stmt(allOf(ifStmt().bind("if"),
-                       hasParent(stmt(has(stmt(equalsBoundNode("if")))))))));
+      matches("void f() { if(true) {} }",
+              stmt(allOf(ifStmt().bind("if"),
+                         hasParent(stmt(has(stmt(equalsBoundNode("if")))))))));
 
   EXPECT_TRUE(notMatches(
-    "void f() { if(true) { if (true) {} } }",
-    stmt(allOf(ifStmt().bind("if"), has(stmt(equalsBoundNode("if")))))));
+      "void f() { if(true) { if (true) {} } }",
+      stmt(allOf(ifStmt().bind("if"), has(stmt(equalsBoundNode("if")))))));
 }
 
 TEST(EqualsBoundNodeMatcher, Decl) {
   EXPECT_TRUE(matches(
-    "class X { class Y {}; };",
-    decl(allOf(recordDecl(hasName("::X::Y")).bind("record"),
-               hasParent(decl(has(decl(equalsBoundNode("record")))))))));
+      "class X { class Y {}; };",
+      decl(allOf(recordDecl(hasName("::X::Y")).bind("record"),
+                 hasParent(decl(has(decl(equalsBoundNode("record")))))))));
 
   EXPECT_TRUE(notMatches("class X { class Y {}; };",
                          decl(allOf(recordDecl(hasName("::X")).bind("record"),
@@ -2522,21 +2435,21 @@ TEST(EqualsBoundNodeMatcher, Decl) {
 
 TEST(EqualsBoundNodeMatcher, Type) {
   EXPECT_TRUE(matches(
-    "class X { int a; int b; };",
-    recordDecl(
-      has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
-      has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
+      "class X { int a; int b; };",
+      recordDecl(
+          has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
+          has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
 
   EXPECT_TRUE(notMatches(
-    "class X { int a; double b; };",
-    recordDecl(
-      has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
-      has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
+      "class X { int a; double b; };",
+      recordDecl(
+          has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
+          has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
 }
 
 TEST(EqualsBoundNodeMatcher, UsingForEachDescendant) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "int f() {"
+      "int f() {"
       "  if (1) {"
       "    int i = 9;"
       "  }"
@@ -2546,63 +2459,65 @@ TEST(EqualsBoundNodeMatcher, UsingForEachDescendant) {
       "  }"
       "  return 0;"
       "}",
-    // Look for variable declarations within functions whose type is the same
-    // as the function return type.
-    functionDecl(returns(qualType().bind("type")),
-                 forEachDescendant(varDecl(hasType(
-                   qualType(equalsBoundNode("type")))).bind("decl"))),
-    // Only i and j should match, not k.
-    std::make_unique>("decl", 2)));
+      // Look for variable declarations within functions whose type is the same
+      // as the function return type.
+      functionDecl(
+          returns(qualType().bind("type")),
+          forEachDescendant(varDecl(hasType(qualType(equalsBoundNode("type"))))
+                                .bind("decl"))),
+      // Only i and j should match, not k.
+      std::make_unique>("decl", 2)));
 }
 
 TEST(EqualsBoundNodeMatcher, FiltersMatchedCombinations) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "void f() {"
+      "void f() {"
       "  int x;"
       "  double d;"
       "  x = d + x - d + x;"
       "}",
-    functionDecl(
-      hasName("f"), forEachDescendant(varDecl().bind("d")),
-      forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))),
-    std::make_unique>("d", 5)));
+      functionDecl(
+          hasName("f"), forEachDescendant(varDecl().bind("d")),
+          forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))),
+      std::make_unique>("d", 5)));
 }
 
 TEST(EqualsBoundNodeMatcher, UnlessDescendantsOfAncestorsMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "struct StringRef { int size() const; const char* data() const; };"
+      "struct StringRef { int size() const; const char* data() const; };"
       "void f(StringRef v) {"
       "  v.data();"
       "}",
-    cxxMemberCallExpr(
-      callee(cxxMethodDecl(hasName("data"))),
-      on(declRefExpr(to(
-        varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
-      unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
-        callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
-        on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
-      .bind("data"),
-    std::make_unique>("data", 1)));
+      cxxMemberCallExpr(
+          callee(cxxMethodDecl(hasName("data"))),
+          on(declRefExpr(to(
+              varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
+          unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
+              callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
+              on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
+          .bind("data"),
+      std::make_unique>("data", 1)));
 
   EXPECT_FALSE(matches(
-    "struct StringRef { int size() const; const char* data() const; };"
+      "struct StringRef { int size() const; const char* data() const; };"
       "void f(StringRef v) {"
       "  v.data();"
       "  v.size();"
       "}",
-    cxxMemberCallExpr(
-      callee(cxxMethodDecl(hasName("data"))),
-      on(declRefExpr(to(
-        varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
-      unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
-        callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
-        on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
-      .bind("data")));
+      cxxMemberCallExpr(
+          callee(cxxMethodDecl(hasName("data"))),
+          on(declRefExpr(to(
+              varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
+          unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
+              callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
+              on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
+          .bind("data")));
 }
 
 TEST(NullPointerConstants, Basic) {
   EXPECT_TRUE(matches("#define NULL ((void *)0)\n"
-                        "void *v1 = NULL;", expr(nullPointerConstant())));
+                      "void *v1 = NULL;",
+                      expr(nullPointerConstant())));
   EXPECT_TRUE(matches("void *v2 = nullptr;", expr(nullPointerConstant())));
   EXPECT_TRUE(matches("void *v3 = __null;", expr(nullPointerConstant())));
   EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant())));
@@ -2635,10 +2550,10 @@ TEST(HasExternalFormalLinkage, Basic) {
 }
 
 TEST(HasDefaultArgument, Basic) {
-  EXPECT_TRUE(matches("void x(int val = 0) {}",
-                      parmVarDecl(hasDefaultArgument())));
-  EXPECT_TRUE(notMatches("void x(int val) {}",
-                      parmVarDecl(hasDefaultArgument())));
+  EXPECT_TRUE(
+      matches("void x(int val = 0) {}", parmVarDecl(hasDefaultArgument())));
+  EXPECT_TRUE(
+      notMatches("void x(int val) {}", parmVarDecl(hasDefaultArgument())));
 }
 
 TEST(IsAtPosition, Basic) {
@@ -2691,24 +2606,18 @@ TEST(HasArraySize, Basic) {
 }
 
 TEST(HasDefinition, MatchesStructDefinition) {
-  EXPECT_TRUE(matches("struct x {};",
-                      cxxRecordDecl(hasDefinition())));
-  EXPECT_TRUE(notMatches("struct x;",
-                      cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(matches("struct x {};", cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(notMatches("struct x;", cxxRecordDecl(hasDefinition())));
 }
 
 TEST(HasDefinition, MatchesClassDefinition) {
-  EXPECT_TRUE(matches("class x {};",
-                      cxxRecordDecl(hasDefinition())));
-  EXPECT_TRUE(notMatches("class x;",
-                      cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(matches("class x {};", cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(notMatches("class x;", cxxRecordDecl(hasDefinition())));
 }
 
 TEST(HasDefinition, MatchesUnionDefinition) {
-  EXPECT_TRUE(matches("union x {};",
-                      cxxRecordDecl(hasDefinition())));
-  EXPECT_TRUE(notMatches("union x;",
-                      cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(matches("union x {};", cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(notMatches("union x;", cxxRecordDecl(hasDefinition())));
 }
 
 TEST(IsScopedEnum, MatchesScopedEnum) {
@@ -2727,19 +2636,19 @@ TEST(HasTrailingReturn, MatchesTrailingReturn) {
   EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
                       functionDecl(hasTrailingReturn())));
   EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn())));
-  EXPECT_TRUE(notMatches("int X() { return 0; }",
-                      functionDecl(hasTrailingReturn())));
+  EXPECT_TRUE(
+      notMatches("int X() { return 0; }", functionDecl(hasTrailingReturn())));
   EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn())));
   EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn())));
 }
 
 TEST(HasTrailingReturn, MatchesLambdaTrailingReturn) {
   EXPECT_TRUE(matches(
-          "auto lambda2 = [](double x, double y) -> double {return x + y;};",
-          functionDecl(hasTrailingReturn())));
-  EXPECT_TRUE(notMatches(
-          "auto lambda2 = [](double x, double y) {return x + y;};",
-          functionDecl(hasTrailingReturn())));
+      "auto lambda2 = [](double x, double y) -> double {return x + y;};",
+      functionDecl(hasTrailingReturn())));
+  EXPECT_TRUE(
+      notMatches("auto lambda2 = [](double x, double y) {return x + y;};",
+                 functionDecl(hasTrailingReturn())));
 }
 
 TEST(IsAssignmentOperator, Basic) {
@@ -2772,23 +2681,15 @@ TEST(IsComparisonOperator, Basic) {
 }
 
 TEST(HasInit, Basic) {
-  EXPECT_TRUE(
-    matches("int x{0};",
-            initListExpr(hasInit(0, expr()))));
-  EXPECT_FALSE(
-    matches("int x{0};",
-            initListExpr(hasInit(1, expr()))));
-  EXPECT_FALSE(
-    matches("int x;",
-            initListExpr(hasInit(0, expr()))));
+  EXPECT_TRUE(matches("int x{0};", initListExpr(hasInit(0, expr()))));
+  EXPECT_FALSE(matches("int x{0};", initListExpr(hasInit(1, expr()))));
+  EXPECT_FALSE(matches("int x;", initListExpr(hasInit(0, expr()))));
 }
 
 TEST(Matcher, isMain) {
-  EXPECT_TRUE(
-    matches("int main() {}", functionDecl(isMain())));
+  EXPECT_TRUE(matches("int main() {}", functionDecl(isMain())));
 
-  EXPECT_TRUE(
-    notMatches("int main2() {}", functionDecl(isMain())));
+  EXPECT_TRUE(notMatches("int main2() {}", functionDecl(isMain())));
 }
 
 TEST(OMPExecutableDirective, isStandaloneDirective) {
@@ -2867,11 +2768,18 @@ void x() {
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   StringRef Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  StringRef Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isNoneKind) {
@@ -2907,10 +2815,17 @@ void x() {
 
   StringRef Source4 = R"(
 void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isSharedKind) {
@@ -2946,10 +2861,63 @@ void x() {
 
   StringRef Source4 = R"(
 void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+}
+
+TEST(OMPDefaultClause, isFirstPrivateKind) {
+  auto Matcher = ompExecutableDirective(
+      hasAnyClause(ompDefaultClause(isFirstPrivateKind())));
+
+  const std::string Source0 = R"(
+void x() {
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+  const std::string Source1 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source1, Matcher));
+
+  const std::string Source2 = R"(
+void x() {
+#pragma omp parallel default(shared)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source2, Matcher));
+
+  const std::string Source3 = R"(
+void x() {
+#pragma omp parallel default(none)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source3, Matcher));
+
+  const std::string Source4 = R"(
+void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPExecutableDirective, isAllowedToContainClauseKind) {
@@ -2984,24 +2952,31 @@ void x() {
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   StringRef Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  StringRef Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 
-  StringRef Source5 = R"(
+  StringRef Source6 = R"(
 void x() {
 #pragma omp taskyield
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
 
-  StringRef Source6 = R"(
+  StringRef Source7 = R"(
 void x() {
 #pragma omp task
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source6, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source7, Matcher));
 }
 
 TEST(HasAnyBase, DirectBase) {

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 59e0f74b3910..895c8ae48adc 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -118,13 +118,13 @@ TEST_P(ASTMatchersTest, TranslationUnitDecl) {
                    "int MyVar2;\n"
                    "}  // namespace NameSpace\n";
   EXPECT_TRUE(matches(
-    Code, varDecl(hasName("MyVar1"), hasDeclContext(translationUnitDecl()))));
+      Code, varDecl(hasName("MyVar1"), hasDeclContext(translationUnitDecl()))));
   EXPECT_FALSE(matches(
-    Code, varDecl(hasName("MyVar2"), hasDeclContext(translationUnitDecl()))));
+      Code, varDecl(hasName("MyVar2"), hasDeclContext(translationUnitDecl()))));
   EXPECT_TRUE(matches(
-    Code,
-    varDecl(hasName("MyVar2"),
-            hasDeclContext(decl(hasDeclContext(translationUnitDecl()))))));
+      Code,
+      varDecl(hasName("MyVar2"),
+              hasDeclContext(decl(hasDeclContext(translationUnitDecl()))))));
 }
 
 TEST_P(ASTMatchersTest, LinkageSpecDecl) {
@@ -158,10 +158,10 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(notMatches("template class X { };"
-                           "template<> class X { int a; };",
-                         classTemplateDecl(hasName("X"),
-                                           hasDescendant(fieldDecl(hasName("a"))))));
+  EXPECT_TRUE(notMatches(
+      "template class X { };"
+      "template<> class X { int a; };",
+      classTemplateDecl(hasName("X"), hasDescendant(fieldDecl(hasName("a"))))));
 }
 
 TEST_P(ASTMatchersTest,
@@ -169,18 +169,17 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(notMatches("template class X { };"
-                           "template class X { int a; };",
-                         classTemplateDecl(hasName("X"),
-                                           hasDescendant(fieldDecl(hasName("a"))))));
+  EXPECT_TRUE(notMatches(
+      "template class X { };"
+      "template class X { int a; };",
+      classTemplateDecl(hasName("X"), hasDescendant(fieldDecl(hasName("a"))))));
 }
 
 TEST(ASTMatchersTestCUDA, CUDAKernelCallExpr) {
   EXPECT_TRUE(matchesWithCuda("__global__ void f() { }"
-                                "void g() { f<<<1, 2>>>(); }",
+                              "void g() { f<<<1, 2>>>(); }",
                               cudaKernelCallExpr()));
-  EXPECT_TRUE(notMatchesWithCuda("void f() {}",
-                                 cudaKernelCallExpr()));
+  EXPECT_TRUE(notMatchesWithCuda("void f() {}", cudaKernelCallExpr()));
 }
 
 TEST(ASTMatchersTestCUDA, HasAttrCUDA) {
@@ -316,56 +315,50 @@ TEST_P(ASTMatchersTest, CallExpr_CXX) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
   StatementMatcher MethodX =
-    callExpr(hasDeclaration(cxxMethodDecl(hasName("x"))));
+      callExpr(hasDeclaration(cxxMethodDecl(hasName("x"))));
 
   EXPECT_TRUE(matches("class Y { void x() { x(); } };", MethodX));
   EXPECT_TRUE(notMatches("class Y { void x() {} };", MethodX));
 
   StatementMatcher MethodOnY =
-    cxxMemberCallExpr(on(hasType(recordDecl(hasName("Y")))));
+      cxxMemberCallExpr(on(hasType(recordDecl(hasName("Y")))));
 
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
-               MethodOnY));
-  EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
-               MethodOnY));
-  EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
-               MethodOnY));
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
+                      MethodOnY));
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
+                      MethodOnY));
+  EXPECT_TRUE(notMatches(
+      "class Y { public: void x(); }; void z(Y *&y) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(notMatches(
+      "class Y { public: void x(); }; void z(Y y[]) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(notMatches(
+      "class Y { public: void x(); }; void z() { Y *y; y->x(); }", MethodOnY));
 
   StatementMatcher MethodOnYPointer =
-    cxxMemberCallExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))));
+      cxxMemberCallExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))));
 
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
-            MethodOnYPointer));
+      matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
+              MethodOnYPointer));
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
-            MethodOnYPointer));
+      matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
+              MethodOnYPointer));
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
-            MethodOnYPointer));
+      matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
+              MethodOnYPointer));
   EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
-               MethodOnYPointer));
+      notMatches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
+                 MethodOnYPointer));
   EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
-               MethodOnYPointer));
+      notMatches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
+                 MethodOnYPointer));
 }
 
 TEST_P(ASTMatchersTest, LambdaExpr) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  EXPECT_TRUE(matches("auto f = [] (int i) { return i; };",
-                      lambdaExpr()));
+  EXPECT_TRUE(matches("auto f = [] (int i) { return i; };", lambdaExpr()));
 }
 
 TEST_P(ASTMatchersTest, CXXForRangeStmt) {
@@ -378,7 +371,7 @@ TEST_P(ASTMatchersTest, CXXForRangeStmt_CXX11) {
     return;
   }
   EXPECT_TRUE(matches("int as[] = { 1, 2, 3 };"
-                        "void f() { for (auto &a : as); }",
+                      "void f() { for (auto &a : as); }",
                       cxxForRangeStmt()));
 }
 
@@ -387,15 +380,13 @@ TEST_P(ASTMatchersTest, SubstNonTypeTemplateParmExpr) {
     return;
   }
   EXPECT_FALSE(matches("template\n"
-                         "struct A {  static const int n = 0; };\n"
-                         "struct B : public A<42> {};",
-                         traverse(TK_AsIs,
-                       substNonTypeTemplateParmExpr())));
+                       "struct A {  static const int n = 0; };\n"
+                       "struct B : public A<42> {};",
+                       traverse(TK_AsIs, substNonTypeTemplateParmExpr())));
   EXPECT_TRUE(matches("template\n"
-                        "struct A {  static const int n = N; };\n"
-                        "struct B : public A<42> {};",
-                         traverse(TK_AsIs,
-                      substNonTypeTemplateParmExpr())));
+                      "struct A {  static const int n = N; };\n"
+                      "struct B : public A<42> {};",
+                      traverse(TK_AsIs, substNonTypeTemplateParmExpr())));
 }
 
 TEST_P(ASTMatchersTest, NonTypeTemplateParmDecl) {
@@ -405,7 +396,7 @@ TEST_P(ASTMatchersTest, NonTypeTemplateParmDecl) {
   EXPECT_TRUE(matches("template  void f();",
                       nonTypeTemplateParmDecl(hasName("N"))));
   EXPECT_TRUE(
-    notMatches("template  void f();", nonTypeTemplateParmDecl()));
+      notMatches("template  void f();", nonTypeTemplateParmDecl()));
 }
 
 TEST_P(ASTMatchersTest, TemplateTypeParmDecl) {
@@ -414,8 +405,7 @@ TEST_P(ASTMatchersTest, TemplateTypeParmDecl) {
   }
   EXPECT_TRUE(matches("template  void f();",
                       templateTypeParmDecl(hasName("T"))));
-  EXPECT_TRUE(
-    notMatches("template  void f();", templateTypeParmDecl()));
+  EXPECT_TRUE(notMatches("template  void f();", templateTypeParmDecl()));
 }
 
 TEST_P(ASTMatchersTest, UserDefinedLiteral) {
@@ -423,9 +413,9 @@ TEST_P(ASTMatchersTest, UserDefinedLiteral) {
     return;
   }
   EXPECT_TRUE(matches("constexpr char operator \"\" _inc (const char i) {"
-                        "  return i + 1;"
-                        "}"
-                        "char c = 'a'_inc;",
+                      "  return i + 1;"
+                      "}"
+                      "char c = 'a'_inc;",
                       userDefinedLiteral()));
 }
 
@@ -434,9 +424,7 @@ TEST_P(ASTMatchersTest, FlowControl) {
   EXPECT_TRUE(matches("void f() { while(1) { continue; } }", continueStmt()));
   EXPECT_TRUE(matches("void f() { goto FOO; FOO: ;}", gotoStmt()));
   EXPECT_TRUE(matches("void f() { goto FOO; FOO: ;}",
-                      labelStmt(
-                        hasDeclaration(
-                          labelDecl(hasName("FOO"))))));
+                      labelStmt(hasDeclaration(labelDecl(hasName("FOO"))))));
   EXPECT_TRUE(matches("void f() { FOO: ; void *ptr = &&FOO; goto *ptr; }",
                       addrLabelExpr()));
   EXPECT_TRUE(matches("void f() { return; }", returnStmt()));
@@ -450,8 +438,9 @@ TEST_P(ASTMatchersTest, CXXOperatorCallExpr) {
   StatementMatcher OpCall = cxxOperatorCallExpr();
   // Unary operator
   EXPECT_TRUE(matches("class Y { }; "
-                        "bool operator!(Y x) { return false; }; "
-                        "Y y; bool c = !y;", OpCall));
+                      "bool operator!(Y x) { return false; }; "
+                      "Y y; bool c = !y;",
+                      OpCall));
   // No match -- special operators like "new", "delete"
   // FIXME: operator new takes size_t, for which we need stddef.h, for which
   // we need to figure out include paths in the test.
@@ -460,12 +449,13 @@ TEST_P(ASTMatchersTest, CXXOperatorCallExpr) {
   //             "void *operator new(size_t size) { return 0; } "
   //             "Y *y = new Y;", OpCall));
   EXPECT_TRUE(notMatches("class Y { }; "
-                           "void operator delete(void *p) { } "
-                           "void a() {Y *y = new Y; delete y;}", OpCall));
+                         "void operator delete(void *p) { } "
+                         "void a() {Y *y = new Y; delete y;}",
+                         OpCall));
   // Binary operator
   EXPECT_TRUE(matches("class Y { }; "
-                        "bool operator&&(Y x, Y y) { return true; }; "
-                        "Y a; Y b; bool c = a && b;",
+                      "bool operator&&(Y x, Y y) { return true; }; "
+                      "Y a; Y b; bool c = a && b;",
                       OpCall));
   // No match -- normal operator, not an overloaded one.
   EXPECT_TRUE(notMatches("bool x = true, y = true; bool t = x && y;", OpCall));
@@ -481,30 +471,25 @@ TEST_P(ASTMatchersTest, ThisPointerType) {
       traverse(ast_type_traits::TK_AsIs,
                cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y")))));
 
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
-            MethodOnY));
-
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
+                      MethodOnY));
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
+                      MethodOnY));
   EXPECT_TRUE(matches(
-    "class Y {"
-      "  public: virtual void x();"
-      "};"
-      "class X : public Y {"
-      "  public: virtual void x();"
-      "};"
-      "void z() { X *x; x->Y::x(); }", MethodOnY));
+      "class Y { public: void x(); }; void z(Y *&y) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(matches(
+      "class Y { public: void x(); }; void z(Y y[]) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(matches(
+      "class Y { public: void x(); }; void z() { Y *y; y->x(); }", MethodOnY));
+
+  EXPECT_TRUE(matches("class Y {"
+                      "  public: virtual void x();"
+                      "};"
+                      "class X : public Y {"
+                      "  public: virtual void x();"
+                      "};"
+                      "void z() { X *x; x->Y::x(); }",
+                      MethodOnY));
 }
 
 TEST_P(ASTMatchersTest, DeclRefExpr) {
@@ -512,29 +497,27 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
     // FIXME: Add a test for `declRefExpr()` that does not depend on C++.
     return;
   }
-  StatementMatcher Reference =
-    declRefExpr(to(
-      varDecl(hasInitializer(
-        cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y"))))))));
+  StatementMatcher Reference = declRefExpr(to(varDecl(hasInitializer(
+      cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y"))))))));
 
-  EXPECT_TRUE(matches(
-    "class Y {"
-      " public:"
-      "  bool x() const;"
-      "};"
-      "void z(const Y &y) {"
-      "  bool b = y.x();"
-      "  if (b) {}"
-      "}", Reference));
+  EXPECT_TRUE(matches("class Y {"
+                      " public:"
+                      "  bool x() const;"
+                      "};"
+                      "void z(const Y &y) {"
+                      "  bool b = y.x();"
+                      "  if (b) {}"
+                      "}",
+                      Reference));
 
-  EXPECT_TRUE(notMatches(
-    "class Y {"
-      " public:"
-      "  bool x() const;"
-      "};"
-      "void z(const Y &y) {"
-      "  bool b = y.x();"
-      "}", Reference));
+  EXPECT_TRUE(notMatches("class Y {"
+                         " public:"
+                         "  bool x() const;"
+                         "};"
+                         "void z(const Y &y) {"
+                         "  bool b = y.x();"
+                         "}",
+                         Reference));
 }
 
 TEST_P(ASTMatchersTest, CXXMemberCallExpr) {
@@ -542,32 +525,32 @@ TEST_P(ASTMatchersTest, CXXMemberCallExpr) {
     return;
   }
   StatementMatcher CallOnVariableY =
-    cxxMemberCallExpr(on(declRefExpr(to(varDecl(hasName("y"))))));
-
-  EXPECT_TRUE(matches(
-    "class Y { public: void x() { Y y; y.x(); } };", CallOnVariableY));
-  EXPECT_TRUE(matches(
-    "class Y { public: void x() const { Y y; y.x(); } };", CallOnVariableY));
-  EXPECT_TRUE(matches(
-    "class Y { public: void x(); };"
-      "class X : public Y { void z() { X y; y.x(); } };", CallOnVariableY));
-  EXPECT_TRUE(matches(
-    "class Y { public: void x(); };"
-      "class X : public Y { void z() { X *y; y->x(); } };", CallOnVariableY));
+      cxxMemberCallExpr(on(declRefExpr(to(varDecl(hasName("y"))))));
+
+  EXPECT_TRUE(matches("class Y { public: void x() { Y y; y.x(); } };",
+                      CallOnVariableY));
+  EXPECT_TRUE(matches("class Y { public: void x() const { Y y; y.x(); } };",
+                      CallOnVariableY));
+  EXPECT_TRUE(matches("class Y { public: void x(); };"
+                      "class X : public Y { void z() { X y; y.x(); } };",
+                      CallOnVariableY));
+  EXPECT_TRUE(matches("class Y { public: void x(); };"
+                      "class X : public Y { void z() { X *y; y->x(); } };",
+                      CallOnVariableY));
   EXPECT_TRUE(notMatches(
-    "class Y { public: void x(); };"
+      "class Y { public: void x(); };"
       "class X : public Y { void z() { unsigned long y; ((X*)y)->x(); } };",
-    CallOnVariableY));
+      CallOnVariableY));
 }
 
 TEST_P(ASTMatchersTest, UnaryExprOrTypeTraitExpr) {
-  EXPECT_TRUE(matches("void x() { int a = sizeof(a); }",
-                      unaryExprOrTypeTraitExpr()));
+  EXPECT_TRUE(
+      matches("void x() { int a = sizeof(a); }", unaryExprOrTypeTraitExpr()));
 }
 
 TEST_P(ASTMatchersTest, AlignOfExpr) {
-  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
-                         alignOfExpr(anything())));
+  EXPECT_TRUE(
+      notMatches("void x() { int a = sizeof(a); }", alignOfExpr(anything())));
   // FIXME: Uncomment once alignof is enabled.
   // EXPECT_TRUE(matches("void x() { int a = alignof(a); }",
   //                     unaryExprOrTypeTraitExpr()));
@@ -603,11 +586,10 @@ TEST_P(ASTMatchersTest, MemberExpr_MatchesVariable) {
     return;
   }
   EXPECT_TRUE(
-    matches("class Y { void x() { this->y; } int y; };", memberExpr()));
-  EXPECT_TRUE(
-    matches("class Y { void x() { y; } int y; };", memberExpr()));
+      matches("class Y { void x() { this->y; } int y; };", memberExpr()));
+  EXPECT_TRUE(matches("class Y { void x() { y; } int y; };", memberExpr()));
   EXPECT_TRUE(
-    matches("class Y { void x() { Y y; y.y; } int y; };", memberExpr()));
+      matches("class Y { void x() { Y y; y.y; } int y; };", memberExpr()));
   EXPECT_TRUE(matches("template "
                       "class X : T { void f() { this->T::v; } };",
                       cxxDependentScopeMemberExpr()));
@@ -623,8 +605,8 @@ TEST_P(ASTMatchersTest, MemberExpr_MatchesStaticVariable) {
   }
   EXPECT_TRUE(matches("class Y { void x() { this->y; } static int y; };",
                       memberExpr()));
-  EXPECT_TRUE(notMatches("class Y { void x() { y; } static int y; };",
-                         memberExpr()));
+  EXPECT_TRUE(
+      notMatches("class Y { void x() { y; } static int y; };", memberExpr()));
   EXPECT_TRUE(notMatches("class Y { void x() { Y::y; } static int y; };",
                          memberExpr()));
 }
@@ -658,21 +640,21 @@ TEST_P(ASTMatchersTest, FunctionDecl_CXX) {
   if (!GetParam().hasDelayedTemplateParsing()) {
     // FIXME: Fix this test to work with delayed template parsing.
     // Dependent contexts, but a non-dependent call.
-    EXPECT_TRUE(matches("void f(); template  void g() { f(); }",
-                        CallFunctionF));
     EXPECT_TRUE(
-      matches("void f(); template  struct S { void g() { f(); } };",
-              CallFunctionF));
+        matches("void f(); template  void g() { f(); }", CallFunctionF));
+    EXPECT_TRUE(
+        matches("void f(); template  struct S { void g() { f(); } };",
+                CallFunctionF));
   }
 
   // Depedent calls don't match.
   EXPECT_TRUE(
-    notMatches("void f(int); template  void g(T t) { f(t); }",
-               CallFunctionF));
+      notMatches("void f(int); template  void g(T t) { f(t); }",
+                 CallFunctionF));
   EXPECT_TRUE(
-    notMatches("void f(int);"
+      notMatches("void f(int);"
                  "template  struct S { void g(T t) { f(t); } };",
-               CallFunctionF));
+                 CallFunctionF));
 
   EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic())));
   EXPECT_TRUE(matches("void f(...);", functionDecl(parameterCountIs(0))));
@@ -692,9 +674,8 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(
-    matches("template  void f(T t) {}",
-            functionTemplateDecl(hasName("f"))));
+  EXPECT_TRUE(matches("template  void f(T t) {}",
+                      functionTemplateDecl(hasName("f"))));
 }
 
 TEST_P(ASTMatchersTest, FunctionTemplate_DoesNotMatchFunctionDeclarations) {
@@ -709,12 +690,11 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(
-    notMatches("void g(); template  void f(T t) {}"
-                 "template <> void f(int t) { g(); }",
-               functionTemplateDecl(hasName("f"),
-                                    hasDescendant(declRefExpr(to(
-                                      functionDecl(hasName("g"))))))));
+  EXPECT_TRUE(notMatches(
+      "void g(); template  void f(T t) {}"
+      "template <> void f(int t) { g(); }",
+      functionTemplateDecl(hasName("f"), hasDescendant(declRefExpr(to(
+                                             functionDecl(hasName("g"))))))));
 }
 
 TEST_P(ASTMatchersTest, ClassTemplateSpecializationDecl) {
@@ -722,7 +702,7 @@ TEST_P(ASTMatchersTest, ClassTemplateSpecializationDecl) {
     return;
   }
   EXPECT_TRUE(matches("template struct A {};"
-                        "template<> struct A {};",
+                      "template<> struct A {};",
                       classTemplateSpecializationDecl()));
   EXPECT_TRUE(matches("template struct A {}; A a;",
                       classTemplateSpecializationDecl()));
@@ -756,13 +736,11 @@ TEST_P(ASTMatchersTest, Matcher_ConstructorCall) {
       traverse(ast_type_traits::TK_AsIs, cxxConstructExpr());
 
   EXPECT_TRUE(
-    matches("class X { public: X(); }; void x() { X x; }", Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(); }; void x() { X x = X(); }",
-            Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x = 0; }",
-            Constructor));
+      matches("class X { public: X(); }; void x() { X x; }", Constructor));
+  EXPECT_TRUE(matches("class X { public: X(); }; void x() { X x = X(); }",
+                      Constructor));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x = 0; }",
+                      Constructor));
   EXPECT_TRUE(matches("class X {}; void x(int) { X x; }", Constructor));
 }
 
@@ -779,9 +757,9 @@ TEST_P(ASTMatchersTest, Matcher_ThisExpr) {
     return;
   }
   EXPECT_TRUE(
-    matches("struct X { int a; int f () { return a; } };", cxxThisExpr()));
+      matches("struct X { int a; int f () { return a; } };", cxxThisExpr()));
   EXPECT_TRUE(
-    notMatches("struct X { int f () { int a; return a; } };", cxxThisExpr()));
+      notMatches("struct X { int f () { int a; return a; } };", cxxThisExpr()));
 }
 
 TEST_P(ASTMatchersTest, Matcher_BindTemporaryExpression) {
@@ -794,30 +772,27 @@ TEST_P(ASTMatchersTest, Matcher_BindTemporaryExpression) {
 
   StringRef ClassString = "class string { public: string(); ~string(); }; ";
 
-  EXPECT_TRUE(
-    matches(ClassString +
-              "string GetStringByValue();"
-                "void FunctionTakesString(string s);"
-                "void run() { FunctionTakesString(GetStringByValue()); }",
-            TempExpression));
+  EXPECT_TRUE(matches(
+      ClassString + "string GetStringByValue();"
+                    "void FunctionTakesString(string s);"
+                    "void run() { FunctionTakesString(GetStringByValue()); }",
+      TempExpression));
 
-  EXPECT_TRUE(
-    notMatches(ClassString +
-                 "string* GetStringPointer(); "
-                   "void FunctionTakesStringPtr(string* s);"
-                   "void run() {"
-                   "  string* s = GetStringPointer();"
-                   "  FunctionTakesStringPtr(GetStringPointer());"
-                   "  FunctionTakesStringPtr(s);"
-                   "}",
-               TempExpression));
+  EXPECT_TRUE(notMatches(ClassString +
+                             "string* GetStringPointer(); "
+                             "void FunctionTakesStringPtr(string* s);"
+                             "void run() {"
+                             "  string* s = GetStringPointer();"
+                             "  FunctionTakesStringPtr(GetStringPointer());"
+                             "  FunctionTakesStringPtr(s);"
+                             "}",
+                         TempExpression));
 
-  EXPECT_TRUE(
-    notMatches("class no_dtor {};"
-                 "no_dtor GetObjByValue();"
-                 "void ConsumeObj(no_dtor param);"
-                 "void run() { ConsumeObj(GetObjByValue()); }",
-               TempExpression));
+  EXPECT_TRUE(notMatches("class no_dtor {};"
+                         "no_dtor GetObjByValue();"
+                         "void ConsumeObj(no_dtor param);"
+                         "void run() { ConsumeObj(GetObjByValue()); }",
+                         TempExpression));
 }
 
 TEST_P(ASTMatchersTest, MaterializeTemporaryExpr_MatchesTemporaryCXX11CXX14) {
@@ -872,10 +847,9 @@ TEST_P(ASTMatchersTest, Matcher_NewExpression) {
   StatementMatcher New = cxxNewExpr();
 
   EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X; }", New));
+  EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X(); }", New));
   EXPECT_TRUE(
-    matches("class X { public: X(); }; void x() { new X(); }", New));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { new X(0); }", New));
+      matches("class X { public: X(int); }; void x() { new X(0); }", New));
   EXPECT_TRUE(matches("class X {}; void x(int) { new X; }", New));
 }
 
@@ -883,8 +857,8 @@ TEST_P(ASTMatchersTest, Matcher_DeleteExpression) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("struct A {}; void f(A* a) { delete a; }",
-                      cxxDeleteExpr()));
+  EXPECT_TRUE(
+      matches("struct A {}; void f(A* a) { delete a; }", cxxDeleteExpr()));
 }
 
 TEST_P(ASTMatchersTest, Matcher_NoexceptExpression) {
@@ -907,7 +881,7 @@ TEST_P(ASTMatchersTest, Matcher_DefaultArgument) {
   StatementMatcher Arg = cxxDefaultArgExpr();
   EXPECT_TRUE(matches("void x(int, int = 0) { int y; x(y); }", Arg));
   EXPECT_TRUE(
-    matches("class X { void x(int, int = 0) { int y; x(y); } };", Arg));
+      matches("class X { void x(int, int = 0) { int y; x(y); } };", Arg));
   EXPECT_TRUE(notMatches("void x(int, int = 0) { int y; x(y, 0); }", Arg));
 }
 
@@ -951,7 +925,7 @@ TEST_P(ASTMatchersTest, IntegerLiteral) {
 
   // Non-matching cases (character literals, float and double)
   EXPECT_TRUE(notMatches("int i = L'a';",
-                         HasIntLiteral));  // this is actually a character
+                         HasIntLiteral)); // this is actually a character
   // literal cast to int
   EXPECT_TRUE(notMatches("int i = 'a';", HasIntLiteral));
   EXPECT_TRUE(notMatches("int i = 1e10;", HasIntLiteral));
@@ -974,13 +948,13 @@ TEST_P(ASTMatchersTest, FloatLiteral) {
   EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0))));
   EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0f))));
   EXPECT_TRUE(
-    matches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(5.0)))));
+      matches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(5.0)))));
 
   EXPECT_TRUE(notMatches("float i = 10;", HasFloatLiteral));
   EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0))));
   EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0f))));
   EXPECT_TRUE(
-    notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0)))));
+      notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0)))));
 }
 
 TEST_P(ASTMatchersTest, CXXNullPtrLiteralExpr) {
@@ -1051,9 +1025,9 @@ TEST_P(ASTMatchersTest, ParenListExpr) {
     return;
   }
   EXPECT_TRUE(
-    matches("template class foo { void bar() { foo X(*this); } };"
+      matches("template class foo { void bar() { foo X(*this); } };"
               "template class foo;",
-            varDecl(hasInitializer(parenListExpr(has(unaryOperator()))))));
+              varDecl(hasInitializer(parenListExpr(has(unaryOperator()))))));
 }
 
 TEST_P(ASTMatchersTest, StmtExpr) {
@@ -1064,9 +1038,8 @@ TEST_P(ASTMatchersTest, StmtExpr) {
 TEST_P(ASTMatchersTest, PredefinedExpr) {
   // __func__ expands as StringLiteral("foo")
   EXPECT_TRUE(matches("void foo() { __func__; }",
-                      predefinedExpr(
-                        hasType(asString("const char [4]")),
-                        has(stringLiteral()))));
+                      predefinedExpr(hasType(asString("const char [4]")),
+                                     has(stringLiteral()))));
 }
 
 TEST_P(ASTMatchersTest, AsmStatement) {
@@ -1080,7 +1053,7 @@ TEST_P(ASTMatchersTest, HasCondition) {
   }
 
   StatementMatcher Condition =
-    ifStmt(hasCondition(cxxBoolLiteral(equals(true))));
+      ifStmt(hasCondition(cxxBoolLiteral(equals(true))));
 
   EXPECT_TRUE(matches("void x() { if (true) {} }", Condition));
   EXPECT_TRUE(notMatches("void x() { if (false) {} }", Condition));
@@ -1096,24 +1069,24 @@ TEST_P(ASTMatchersTest, ConditionalOperator) {
     return;
   }
 
-  StatementMatcher Conditional = conditionalOperator(
-    hasCondition(cxxBoolLiteral(equals(true))),
-    hasTrueExpression(cxxBoolLiteral(equals(false))));
+  StatementMatcher Conditional =
+      conditionalOperator(hasCondition(cxxBoolLiteral(equals(true))),
+                          hasTrueExpression(cxxBoolLiteral(equals(false))));
 
   EXPECT_TRUE(matches("void x() { true ? false : true; }", Conditional));
   EXPECT_TRUE(notMatches("void x() { false ? false : true; }", Conditional));
   EXPECT_TRUE(notMatches("void x() { true ? true : false; }", Conditional));
 
-  StatementMatcher ConditionalFalse = conditionalOperator(
-    hasFalseExpression(cxxBoolLiteral(equals(false))));
+  StatementMatcher ConditionalFalse =
+      conditionalOperator(hasFalseExpression(cxxBoolLiteral(equals(false))));
 
   EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
   EXPECT_TRUE(
-    notMatches("void x() { true ? false : true; }", ConditionalFalse));
+      notMatches("void x() { true ? false : true; }", ConditionalFalse));
 
   EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
   EXPECT_TRUE(
-    notMatches("void x() { true ? false : true; }", ConditionalFalse));
+      notMatches("void x() { true ? false : true; }", ConditionalFalse));
 }
 
 TEST_P(ASTMatchersTest, BinaryConditionalOperator) {
@@ -1132,18 +1105,17 @@ TEST_P(ASTMatchersTest, BinaryConditionalOperator) {
   EXPECT_TRUE(matches("void x() { 1 ?: 0; }", AlwaysOne));
 
   StatementMatcher FourNotFive = binaryConditionalOperator(
-    hasTrueExpression(opaqueValueExpr(
-      hasSourceExpression((integerLiteral(equals(4)))))),
-    hasFalseExpression(integerLiteral(equals(5))));
+      hasTrueExpression(
+          opaqueValueExpr(hasSourceExpression((integerLiteral(equals(4)))))),
+      hasFalseExpression(integerLiteral(equals(5))));
 
   EXPECT_TRUE(matches("void x() { 4 ?: 5; }", FourNotFive));
 }
 
 TEST_P(ASTMatchersTest, ArraySubscriptExpr) {
-  EXPECT_TRUE(matches("int i[2]; void f() { i[1] = 1; }",
-                      arraySubscriptExpr()));
-  EXPECT_TRUE(notMatches("int i; void f() { i = 1; }",
-                         arraySubscriptExpr()));
+  EXPECT_TRUE(
+      matches("int i[2]; void f() { i[1] = 1; }", arraySubscriptExpr()));
+  EXPECT_TRUE(notMatches("int i; void f() { i = 1; }", arraySubscriptExpr()));
 }
 
 TEST_P(ASTMatchersTest, ForStmt) {
@@ -1178,10 +1150,9 @@ TEST_P(ASTMatchersTest, CompoundStatement_DoesNotMatchEmptyStruct) {
   }
   // It's not a compound statement just because there's "{}" in the source
   // text. This is an AST search, not grep.
-  EXPECT_TRUE(notMatches("namespace n { struct S {}; }",
-                         compoundStmt()));
-  EXPECT_TRUE(matches("namespace n { struct S { void f() {{}} }; }",
-                      compoundStmt()));
+  EXPECT_TRUE(notMatches("namespace n { struct S {}; }", compoundStmt()));
+  EXPECT_TRUE(
+      matches("namespace n { struct S { void f() {{}} }; }", compoundStmt()));
 }
 
 TEST_P(ASTMatchersTest, CastExpr_MatchesExplicitCasts) {
@@ -1242,8 +1213,8 @@ TEST_P(ASTMatchersTest, CXXReinterpretCastExpr_DoesNotMatchOtherCasts) {
   EXPECT_TRUE(notMatches("void* p = static_cast(&p);",
                          cxxReinterpretCastExpr()));
   EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
-                           "B b;"
-                           "D* p = dynamic_cast(&b);",
+                         "B b;"
+                         "D* p = dynamic_cast(&b);",
                          cxxReinterpretCastExpr()));
 }
 
@@ -1262,11 +1233,10 @@ TEST_P(ASTMatchersTest, CXXFunctionalCastExpr_DoesNotMatchOtherCasts) {
   }
   StringRef FooClass = "class Foo { public: Foo(const char*); };";
   EXPECT_TRUE(
-    notMatches(FooClass + "void r() { Foo f = (Foo) \"hello world\"; }",
-               cxxFunctionalCastExpr()));
-  EXPECT_TRUE(
-    notMatches(FooClass + "void r() { Foo f = \"hello world\"; }",
-               cxxFunctionalCastExpr()));
+      notMatches(FooClass + "void r() { Foo f = (Foo) \"hello world\"; }",
+                 cxxFunctionalCastExpr()));
+  EXPECT_TRUE(notMatches(FooClass + "void r() { Foo f = \"hello world\"; }",
+                         cxxFunctionalCastExpr()));
 }
 
 TEST_P(ASTMatchersTest, CXXDynamicCastExpr) {
@@ -1274,8 +1244,8 @@ TEST_P(ASTMatchersTest, CXXDynamicCastExpr) {
     return;
   }
   EXPECT_TRUE(matches("struct B { virtual ~B() {} }; struct D : B {};"
-                        "B b;"
-                        "D* p = dynamic_cast(&b);",
+                      "B b;"
+                      "D* p = dynamic_cast(&b);",
                       cxxDynamicCastExpr()));
 }
 
@@ -1283,8 +1253,7 @@ TEST_P(ASTMatchersTest, CXXStaticCastExpr_MatchesSimpleCase) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("void* p(static_cast(&p));",
-                      cxxStaticCastExpr()));
+  EXPECT_TRUE(matches("void* p(static_cast(&p));", cxxStaticCastExpr()));
 }
 
 TEST_P(ASTMatchersTest, CXXStaticCastExpr_DoesNotMatchOtherCasts) {
@@ -1292,13 +1261,13 @@ TEST_P(ASTMatchersTest, CXXStaticCastExpr_DoesNotMatchOtherCasts) {
     return;
   }
   EXPECT_TRUE(notMatches("char* p = (char*)(&p);", cxxStaticCastExpr()));
-  EXPECT_TRUE(notMatches("char q, *p = const_cast(&q);",
-                         cxxStaticCastExpr()));
+  EXPECT_TRUE(
+      notMatches("char q, *p = const_cast(&q);", cxxStaticCastExpr()));
   EXPECT_TRUE(notMatches("void* p = reinterpret_cast(&p);",
                          cxxStaticCastExpr()));
   EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
-                           "B b;"
-                           "D* p = dynamic_cast(&b);",
+                         "B b;"
+                         "D* p = dynamic_cast(&b);",
                          cxxStaticCastExpr()));
 }
 
@@ -1311,11 +1280,11 @@ TEST_P(ASTMatchersTest, CStyleCastExpr_DoesNotMatchOtherCasts) {
     return;
   }
   EXPECT_TRUE(notMatches("char* p = static_cast(0);"
-                           "char q, *r = const_cast(&q);"
-                           "void* s = reinterpret_cast(&s);"
-                           "struct B { virtual ~B() {} }; struct D : B {};"
-                           "B b;"
-                           "D* t = dynamic_cast(&b);",
+                         "char q, *r = const_cast(&q);"
+                         "void* s = reinterpret_cast(&s);"
+                         "struct B { virtual ~B() {} }; struct D : B {};"
+                         "B b;"
+                         "D* t = dynamic_cast(&b);",
                          cStyleCastExpr()));
 }
 
@@ -1335,12 +1304,12 @@ TEST_P(ASTMatchersTest, ImplicitCastExpr_MatchesSimpleCase) {
 }
 
 TEST_P(ASTMatchersTest, ImplicitCastExpr_DoesNotMatchIncorrectly) {
-  // This test verifies that implicitCastExpr() matches exactly when implicit casts
-  // are present, and that it ignores explicit and paren casts.
+  // This test verifies that implicitCastExpr() matches exactly when implicit
+  // casts are present, and that it ignores explicit and paren casts.
 
   // These two test cases have no casts.
-  EXPECT_TRUE(notMatches("int x = 0;",
-                         varDecl(hasInitializer(implicitCastExpr()))));
+  EXPECT_TRUE(
+      notMatches("int x = 0;", varDecl(hasInitializer(implicitCastExpr()))));
   EXPECT_TRUE(
       notMatches("int x = (0);", varDecl(hasInitializer(implicitCastExpr()))));
   EXPECT_TRUE(notMatches("void f() { int x = 0; double d = (double) x; }",
@@ -1393,7 +1362,7 @@ TEST_P(ASTMatchersTest, InitListExpr) {
   EXPECT_TRUE(matches("struct B { int x, y; }; struct B b = { 5, 6 };",
                       initListExpr(hasType(recordDecl(hasName("B"))))));
   EXPECT_TRUE(
-    matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42))));
+      matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42))));
 }
 
 TEST_P(ASTMatchersTest, InitListExpr_CXX) {
@@ -1441,8 +1410,7 @@ TEST_P(ASTMatchersTest, UsingDecl_MatchesUsingDeclarations) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("namespace X { int x; } using X::x;",
-                      usingDecl()));
+  EXPECT_TRUE(matches("namespace X { int x; } using X::x;", usingDecl()));
 }
 
 TEST_P(ASTMatchersTest, UsingDecl_MatchesShadowUsingDelcarations) {
@@ -1460,7 +1428,7 @@ TEST_P(ASTMatchersTest, UsingDirectiveDecl_MatchesUsingNamespace) {
   EXPECT_TRUE(matches("namespace X { int x; } using namespace X;",
                       usingDirectiveDecl()));
   EXPECT_FALSE(
-    matches("namespace X { int x; } using X::x;", usingDirectiveDecl()));
+      matches("namespace X { int x; } using X::x;", usingDirectiveDecl()));
 }
 
 TEST_P(ASTMatchersTest, WhileStmt) {
@@ -1499,11 +1467,11 @@ TEST_P(ASTMatchersTest, CxxExceptionHandling_SimpleCases) {
   EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", cxxCatchStmt()));
   EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", cxxTryStmt()));
   EXPECT_TRUE(
-    notMatches("void foo() try { } catch(int X) { }", cxxThrowExpr()));
-  EXPECT_TRUE(matches("void foo() try { throw; } catch(int X) { }",
-                      cxxThrowExpr()));
-  EXPECT_TRUE(matches("void foo() try { throw 5;} catch(int X) { }",
-                      cxxThrowExpr()));
+      notMatches("void foo() try { } catch(int X) { }", cxxThrowExpr()));
+  EXPECT_TRUE(
+      matches("void foo() try { throw; } catch(int X) { }", cxxThrowExpr()));
+  EXPECT_TRUE(
+      matches("void foo() try { throw 5;} catch(int X) { }", cxxThrowExpr()));
   EXPECT_TRUE(matches("void foo() try { throw; } catch(...) { }",
                       cxxCatchStmt(isCatchAll())));
   EXPECT_TRUE(notMatches("void foo() try { throw; } catch(int) { }",
@@ -1542,9 +1510,8 @@ TEST_P(ASTMatchersTest, QualType) {
 
 TEST_P(ASTMatchersTest, ConstantArrayType) {
   EXPECT_TRUE(matches("int a[2];", constantArrayType()));
-  EXPECT_TRUE(notMatches(
-    "void f() { int a[] = { 2, 3 }; int b[a[0]]; }",
-    constantArrayType(hasElementType(builtinType()))));
+  EXPECT_TRUE(notMatches("void f() { int a[] = { 2, 3 }; int b[a[0]]; }",
+                         constantArrayType(hasElementType(builtinType()))));
 
   EXPECT_TRUE(matches("int a[42];", constantArrayType(hasSize(42))));
   EXPECT_TRUE(matches("int b[2*21];", constantArrayType(hasSize(42))));
@@ -1555,12 +1522,12 @@ TEST_P(ASTMatchersTest, DependentSizedArrayType) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches(
-    "template  class array { T data[Size]; };",
-    dependentSizedArrayType()));
-  EXPECT_TRUE(notMatches(
-    "int a[42]; int b[] = { 2, 3 }; void f() { int c[b[0]]; }",
-    dependentSizedArrayType()));
+  EXPECT_TRUE(
+      matches("template  class array { T data[Size]; };",
+              dependentSizedArrayType()));
+  EXPECT_TRUE(
+      notMatches("int a[42]; int b[] = { 2, 3 }; void f() { int c[b[0]]; }",
+                 dependentSizedArrayType()));
 }
 
 TEST_P(ASTMatchersTest, IncompleteArrayType) {
@@ -1575,22 +1542,21 @@ TEST_P(ASTMatchersTest, VariableArrayType) {
   EXPECT_TRUE(matches("void f(int b) { int a[b]; }", variableArrayType()));
   EXPECT_TRUE(notMatches("int a[] = {2, 3}; int b[42];", variableArrayType()));
 
-  EXPECT_TRUE(matches(
-    "void f(int b) { int a[b]; }",
-    variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
-      varDecl(hasName("b")))))))));
+  EXPECT_TRUE(matches("void f(int b) { int a[b]; }",
+                      variableArrayType(hasSizeExpr(ignoringImpCasts(
+                          declRefExpr(to(varDecl(hasName("b")))))))));
 }
 
 TEST_P(ASTMatchersTest, AtomicType) {
   if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).getOS() !=
-    llvm::Triple::Win32) {
+      llvm::Triple::Win32) {
     // FIXME: Make this work for MSVC.
     EXPECT_TRUE(matches("_Atomic(int) i;", atomicType()));
 
-    EXPECT_TRUE(matches("_Atomic(int) i;",
-                        atomicType(hasValueType(isInteger()))));
-    EXPECT_TRUE(notMatches("_Atomic(float) f;",
-                           atomicType(hasValueType(isInteger()))));
+    EXPECT_TRUE(
+        matches("_Atomic(int) i;", atomicType(hasValueType(isInteger()))));
+    EXPECT_TRUE(
+        notMatches("_Atomic(float) f;", atomicType(hasValueType(isInteger()))));
   }
 }
 
@@ -1608,9 +1574,9 @@ TEST_P(ASTMatchersTest, AutoType) {
 
   // FIXME: Matching against the type-as-written can't work here, because the
   //        type as written was not deduced.
-  //EXPECT_TRUE(matches("auto a = 1;",
+  // EXPECT_TRUE(matches("auto a = 1;",
   //                    autoType(hasDeducedType(isInteger()))));
-  //EXPECT_TRUE(notMatches("auto b = 2.0;",
+  // EXPECT_TRUE(notMatches("auto b = 2.0;",
   //                       autoType(hasDeducedType(isInteger()))));
 }
 
@@ -1657,48 +1623,43 @@ TEST_P(ASTMatchersTest, FunctionProtoType_CXX) {
 
 TEST_P(ASTMatchersTest, ParenType) {
   EXPECT_TRUE(
-    matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType())))));
+      matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType())))));
   EXPECT_TRUE(notMatches("int *array[4];", varDecl(hasType(parenType()))));
 
   EXPECT_TRUE(matches(
-    "int (*ptr_to_func)(int);",
-    varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
+      "int (*ptr_to_func)(int);",
+      varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
   EXPECT_TRUE(notMatches(
-    "int (*ptr_to_array)[4];",
-    varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
+      "int (*ptr_to_array)[4];",
+      varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
 }
 
 TEST_P(ASTMatchersTest, PointerType) {
   // FIXME: Reactive when these tests can be more specific (not matching
   // implicit code on certain platforms), likely when we have hasDescendant for
   // Types/TypeLocs.
-  //EXPECT_TRUE(matchAndVerifyResultTrue(
+  // EXPECT_TRUE(matchAndVerifyResultTrue(
   //    "int* a;",
   //    pointerTypeLoc(pointeeLoc(typeLoc().bind("loc"))),
   //    std::make_unique>("loc", 1)));
-  //EXPECT_TRUE(matchAndVerifyResultTrue(
+  // EXPECT_TRUE(matchAndVerifyResultTrue(
   //    "int* a;",
   //    pointerTypeLoc().bind("loc"),
   //    std::make_unique>("loc", 1)));
-  EXPECT_TRUE(matches(
-    "int** a;",
-    loc(pointerType(pointee(qualType())))));
-  EXPECT_TRUE(matches(
-    "int** a;",
-    loc(pointerType(pointee(pointerType())))));
-  EXPECT_TRUE(matches(
-    "int* b; int* * const a = &b;",
-    loc(qualType(isConstQualified(), pointerType()))));
+  EXPECT_TRUE(matches("int** a;", loc(pointerType(pointee(qualType())))));
+  EXPECT_TRUE(matches("int** a;", loc(pointerType(pointee(pointerType())))));
+  EXPECT_TRUE(matches("int* b; int* * const a = &b;",
+                      loc(qualType(isConstQualified(), pointerType()))));
 
   StringRef Fragment = "int *ptr;";
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
-                                           hasType(blockPointerType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
-                                           hasType(memberPointerType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"),
-                                        hasType(pointerType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
-                                           hasType(referenceType()))));
+  EXPECT_TRUE(notMatches(Fragment,
+                         varDecl(hasName("ptr"), hasType(blockPointerType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("ptr"), hasType(memberPointerType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("ptr"), hasType(pointerType()))));
+  EXPECT_TRUE(
+      notMatches(Fragment, varDecl(hasName("ptr"), hasType(referenceType()))));
 }
 
 TEST_P(ASTMatchersTest, PointerType_CXX) {
@@ -1763,28 +1724,28 @@ TEST_P(ASTMatchersTest, AutoRefTypes) {
                        "auto &c = a;"
                        "auto &&d = c;"
                        "auto &&e = 2;";
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("a"),
-                                           hasType(referenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("b"),
-                                           hasType(referenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
-                                        hasType(referenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
-                                        hasType(lValueReferenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("c"),
-                                           hasType(rValueReferenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
-                                        hasType(referenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
-                                        hasType(lValueReferenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("d"),
-                                           hasType(rValueReferenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("e"),
-                                        hasType(referenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("e"),
-                                           hasType(lValueReferenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("e"),
-                                        hasType(rValueReferenceType()))));
+  EXPECT_TRUE(
+      notMatches(Fragment, varDecl(hasName("a"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      notMatches(Fragment, varDecl(hasName("b"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("c"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("c"), hasType(lValueReferenceType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("c"), hasType(rValueReferenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("d"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("d"), hasType(lValueReferenceType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("d"), hasType(rValueReferenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("e"), hasType(referenceType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("e"), hasType(lValueReferenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("e"), hasType(rValueReferenceType()))));
 }
 
 TEST_P(ASTMatchersTest, EnumType) {
@@ -1796,34 +1757,29 @@ TEST_P(ASTMatchersTest, EnumType_CXX) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("enum Color { Green }; Color color;",
-                      loc(enumType())));
+  EXPECT_TRUE(matches("enum Color { Green }; Color color;", loc(enumType())));
 }
 
 TEST_P(ASTMatchersTest, EnumType_CXX11) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  EXPECT_TRUE(matches("enum class Color { Green }; Color color;",
-                      loc(enumType())));
+  EXPECT_TRUE(
+      matches("enum class Color { Green }; Color color;", loc(enumType())));
 }
 
 TEST_P(ASTMatchersTest, PointerType_MatchesPointersToConstTypes) {
-  EXPECT_TRUE(matches("int b; int * const a = &b;",
-                      loc(pointerType())));
-  EXPECT_TRUE(matches("int b; int * const a = &b;",
-                      loc(pointerType())));
-  EXPECT_TRUE(matches(
-    "int b; const int * a = &b;",
-    loc(pointerType(pointee(builtinType())))));
-  EXPECT_TRUE(matches(
-    "int b; const int * a = &b;",
-    pointerType(pointee(builtinType()))));
+  EXPECT_TRUE(matches("int b; int * const a = &b;", loc(pointerType())));
+  EXPECT_TRUE(matches("int b; int * const a = &b;", loc(pointerType())));
+  EXPECT_TRUE(matches("int b; const int * a = &b;",
+                      loc(pointerType(pointee(builtinType())))));
+  EXPECT_TRUE(matches("int b; const int * a = &b;",
+                      pointerType(pointee(builtinType()))));
 }
 
 TEST_P(ASTMatchersTest, TypedefType) {
-  EXPECT_TRUE(matches("typedef int X; X a;", varDecl(hasName("a"),
-                                                     hasType(typedefType()))));
+  EXPECT_TRUE(matches("typedef int X; X a;",
+                      varDecl(hasName("a"), hasType(typedefType()))));
 }
 
 TEST_P(ASTMatchersTest, TemplateSpecializationType) {
@@ -1864,13 +1820,13 @@ TEST_P(ASTMatchersTest, ElaboratedType) {
     // FIXME: Add a test for `elaboratedType()` that does not depend on C++.
     return;
   }
-  EXPECT_TRUE(matches(
-    "namespace N {"
-      "  namespace M {"
-      "    class D {};"
-      "  }"
-      "}"
-      "N::M::D d;", elaboratedType()));
+  EXPECT_TRUE(matches("namespace N {"
+                      "  namespace M {"
+                      "    class D {};"
+                      "  }"
+                      "}"
+                      "N::M::D d;",
+                      elaboratedType()));
   EXPECT_TRUE(matches("class C {} c;", elaboratedType()));
   EXPECT_TRUE(notMatches("class C {}; C c;", elaboratedType()));
 }
@@ -1885,30 +1841,29 @@ TEST_P(ASTMatchersTest, SubstTemplateTypeParmType) {
                    "}"
                    "int i = F();";
   EXPECT_FALSE(matches(code, binaryOperator(hasLHS(
-    expr(hasType(substTemplateTypeParmType()))))));
+                                 expr(hasType(substTemplateTypeParmType()))))));
   EXPECT_TRUE(matches(code, binaryOperator(hasRHS(
-    expr(hasType(substTemplateTypeParmType()))))));
+                                expr(hasType(substTemplateTypeParmType()))))));
 }
 
 TEST_P(ASTMatchersTest, NestedNameSpecifier) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;",
-                      nestedNameSpecifier()));
+  EXPECT_TRUE(
+      matches("namespace ns { struct A {}; } ns::A a;", nestedNameSpecifier()));
   EXPECT_TRUE(matches("template  class A { typename T::B b; };",
                       nestedNameSpecifier()));
-  EXPECT_TRUE(matches("struct A { void f(); }; void A::f() {}",
-                      nestedNameSpecifier()));
+  EXPECT_TRUE(
+      matches("struct A { void f(); }; void A::f() {}", nestedNameSpecifier()));
   EXPECT_TRUE(matches("namespace a { namespace b {} } namespace ab = a::b;",
                       nestedNameSpecifier()));
 
-  EXPECT_TRUE(matches(
-    "struct A { static void f() {} }; void g() { A::f(); }",
-    nestedNameSpecifier()));
-  EXPECT_TRUE(notMatches(
-    "struct A { static void f() {} }; void g(A* a) { a->f(); }",
-    nestedNameSpecifier()));
+  EXPECT_TRUE(matches("struct A { static void f() {} }; void g() { A::f(); }",
+                      nestedNameSpecifier()));
+  EXPECT_TRUE(
+      notMatches("struct A { static void f() {} }; void g(A* a) { a->f(); }",
+                 nestedNameSpecifier()));
 }
 
 TEST_P(ASTMatchersTest, NullStmt) {
@@ -1929,10 +1884,10 @@ TEST_P(ASTMatchersTest, NestedNameSpecifier_MatchesTypes) {
     return;
   }
   NestedNameSpecifierMatcher Matcher = nestedNameSpecifier(
-    specifiesType(hasDeclaration(recordDecl(hasName("A")))));
+      specifiesType(hasDeclaration(recordDecl(hasName("A")))));
   EXPECT_TRUE(matches("struct A { struct B {}; }; A::B b;", Matcher));
-  EXPECT_TRUE(matches("struct A { struct B { struct C {}; }; }; A::B::C c;",
-                      Matcher));
+  EXPECT_TRUE(
+      matches("struct A { struct B { struct C {}; }; }; A::B::C c;", Matcher));
   EXPECT_TRUE(notMatches("namespace A { struct B {}; } A::B b;", Matcher));
 }
 
@@ -1940,8 +1895,8 @@ TEST_P(ASTMatchersTest, NestedNameSpecifier_MatchesNamespaceDecls) {
   if (!GetParam().isCXX()) {
     return;
   }
-  NestedNameSpecifierMatcher Matcher = nestedNameSpecifier(
-    specifiesNamespace(hasName("ns")));
+  NestedNameSpecifierMatcher Matcher =
+      nestedNameSpecifier(specifiesNamespace(hasName("ns")));
   EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;", Matcher));
   EXPECT_TRUE(notMatches("namespace xx { struct A {}; } xx::A a;", Matcher));
   EXPECT_TRUE(notMatches("struct ns { struct A {}; }; ns::A a;", Matcher));
@@ -1953,16 +1908,15 @@ TEST_P(ASTMatchersTest,
     return;
   }
   EXPECT_TRUE(matches(
-    "struct A { struct B { struct C {}; }; }; A::B::C c;",
-    nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A"))))));
-  EXPECT_TRUE(matches(
-    "struct A { struct B { struct C {}; }; }; A::B::C c;",
-    nestedNameSpecifierLoc(hasPrefix(
-      specifiesTypeLoc(loc(qualType(asString("struct A"))))))));
+      "struct A { struct B { struct C {}; }; }; A::B::C c;",
+      nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A"))))));
+  EXPECT_TRUE(matches("struct A { struct B { struct C {}; }; }; A::B::C c;",
+                      nestedNameSpecifierLoc(hasPrefix(specifiesTypeLoc(
+                          loc(qualType(asString("struct A"))))))));
   EXPECT_TRUE(matches(
-    "namespace N { struct A { struct B { struct C {}; }; }; } N::A::B::C c;",
-    nestedNameSpecifierLoc(hasPrefix(
-      specifiesTypeLoc(loc(qualType(asString("struct N::A"))))))));
+      "namespace N { struct A { struct B { struct C {}; }; }; } N::A::B::C c;",
+      nestedNameSpecifierLoc(hasPrefix(
+          specifiesTypeLoc(loc(qualType(asString("struct N::A"))))))));
 }
 
 template 
@@ -1980,18 +1934,18 @@ class VerifyAncestorHasChildIsEqual : public BoundNodesCallback {
     // to equalsNode.
     const T *TypedNode = cast(Node);
     return selectFirst(
-      "", match(stmt(hasParent(
-        stmt(has(stmt(equalsNode(TypedNode)))).bind(""))),
-                *Node, Context)) != nullptr;
+               "", match(stmt(hasParent(
+                             stmt(has(stmt(equalsNode(TypedNode)))).bind(""))),
+                         *Node, Context)) != nullptr;
   }
   bool verify(const BoundNodes &Nodes, ASTContext &Context, const Decl *Node) {
     // Use the original typed pointer to verify we can pass pointers to subtypes
     // to equalsNode.
     const T *TypedNode = cast(Node);
     return selectFirst(
-      "", match(decl(hasParent(
-        decl(has(decl(equalsNode(TypedNode)))).bind(""))),
-                *Node, Context)) != nullptr;
+               "", match(decl(hasParent(
+                             decl(has(decl(equalsNode(TypedNode)))).bind(""))),
+                         *Node, Context)) != nullptr;
   }
   bool verify(const BoundNodes &Nodes, ASTContext &Context, const Type *Node) {
     // Use the original typed pointer to verify we can pass pointers to subtypes
@@ -1999,9 +1953,9 @@ class VerifyAncestorHasChildIsEqual : public BoundNodesCallback {
     const T *TypedNode = cast(Node);
     const auto *Dec = Nodes.getNodeAs("decl");
     return selectFirst(
-      "", match(fieldDecl(hasParent(decl(has(fieldDecl(
-        hasType(type(equalsNode(TypedNode)).bind(""))))))),
-                *Dec, Context)) != nullptr;
+               "", match(fieldDecl(hasParent(decl(has(fieldDecl(
+                             hasType(type(equalsNode(TypedNode)).bind(""))))))),
+                         *Dec, Context)) != nullptr;
   }
 };
 
@@ -2100,43 +2054,31 @@ TEST(ASTMatchersTestObjC, ObjCMessageExpr) {
                           "  Str *up = [text uppercaseString];"
                           "} "
                           "@end ";
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(anything())));
+  EXPECT_TRUE(matchesObjC(Objc1String, objcMessageExpr(anything())));
   EXPECT_TRUE(matchesObjC(Objc1String,
-                          objcMessageExpr(hasAnySelector({
-                                          "contents", "meth:"}))
+                          objcMessageExpr(hasAnySelector({"contents", "meth:"}))
 
-                         ));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"))));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasAnySelector("contents", "contentsA"))));
-  EXPECT_FALSE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasAnySelector("contentsB", "contentsC"))));
+                              ));
+  EXPECT_TRUE(
+      matchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"))));
   EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(matchesSelector("cont*"))));
+      Objc1String, objcMessageExpr(hasAnySelector("contents", "contentsA"))));
   EXPECT_FALSE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(matchesSelector("?cont*"))));
-  EXPECT_TRUE(notMatchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"), hasNullSelector())));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"), hasUnarySelector())));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"), numSelectorArgs(0))));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(matchesSelector("uppercase*"),
-                    argumentCountIs(0)
-    )));
+      Objc1String, objcMessageExpr(hasAnySelector("contentsB", "contentsC"))));
+  EXPECT_TRUE(
+      matchesObjC(Objc1String, objcMessageExpr(matchesSelector("cont*"))));
+  EXPECT_FALSE(
+      matchesObjC(Objc1String, objcMessageExpr(matchesSelector("?cont*"))));
+  EXPECT_TRUE(
+      notMatchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"),
+                                                  hasNullSelector())));
+  EXPECT_TRUE(matchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"),
+                                                       hasUnarySelector())));
+  EXPECT_TRUE(matchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"),
+                                                       numSelectorArgs(0))));
+  EXPECT_TRUE(
+      matchesObjC(Objc1String, objcMessageExpr(matchesSelector("uppercase*"),
+                                               argumentCountIs(0))));
 }
 
 TEST(ASTMatchersTestObjC, ObjCDecls) {
@@ -2157,33 +2099,17 @@ TEST(ASTMatchersTestObjC, ObjCDecls) {
                          "- (void)abc_doThing {} "
                          "@end ";
 
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcProtocolDecl(hasName("Proto"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcImplementationDecl(hasName("Thing"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcCategoryDecl(hasName("ABC"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcCategoryImplDecl(hasName("ABC"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcMethodDecl(hasName("protoDidThing"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcMethodDecl(hasName("abc_doThing"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcMethodDecl(hasName("anything"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcIvarDecl(hasName("_ivar"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcPropertyDecl(hasName("enabled"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcProtocolDecl(hasName("Proto"))));
+  EXPECT_TRUE(
+      matchesObjC(ObjCString, objcImplementationDecl(hasName("Thing"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcCategoryDecl(hasName("ABC"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcCategoryImplDecl(hasName("ABC"))));
+  EXPECT_TRUE(
+      matchesObjC(ObjCString, objcMethodDecl(hasName("protoDidThing"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcMethodDecl(hasName("abc_doThing"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcMethodDecl(hasName("anything"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcIvarDecl(hasName("_ivar"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcPropertyDecl(hasName("enabled"))));
 }
 
 TEST(ASTMatchersTestObjC, ObjCExceptionStmts) {
@@ -2194,18 +2120,10 @@ TEST(ASTMatchersTestObjC, ObjCExceptionStmts) {
                          "  } @finally {}"
                          "}";
 
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcTryStmt()));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcThrowStmt()));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcCatchStmt()));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcFinallyStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcTryStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcThrowStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcCatchStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcFinallyStmt()));
 }
 
 TEST(ASTMatchersTestObjC, ObjCAutoreleasePoolStmt) {
@@ -2274,11 +2192,18 @@ void x() {
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   StringRef Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  StringRef Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(ASTMatchersTest, Finder_DynamicOnlyAcceptsSomeMatchers) {

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h
index 8669ebd552c8..bde6297f82dd 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -20,10 +20,10 @@ namespace clang {
 namespace ast_matchers {
 
 using clang::tooling::buildASTFromCodeWithArgs;
+using clang::tooling::FileContentMappings;
+using clang::tooling::FrontendActionFactory;
 using clang::tooling::newFrontendActionFactory;
 using clang::tooling::runToolOnCodeWithArgs;
-using clang::tooling::FrontendActionFactory;
-using clang::tooling::FileContentMappings;
 
 class BoundNodesCallback {
 public:
@@ -38,7 +38,8 @@ class BoundNodesCallback {
 // If 'FindResultVerifier' is NULL, sets *Verified to true when Run is called.
 class VerifyMatch : public MatchFinder::MatchCallback {
 public:
-  VerifyMatch(std::unique_ptr FindResultVerifier, bool *Verified)
+  VerifyMatch(std::unique_ptr FindResultVerifier,
+              bool *Verified)
       : Verified(Verified), FindResultReviewer(std::move(FindResultVerifier)) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
@@ -124,17 +125,16 @@ testing::AssertionResult matchesConditionally(
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (Found != DynamicFound) {
-    return testing::AssertionFailure() << "Dynamic match result ("
-                                       << DynamicFound
-                                       << ") does not match static result ("
-                                       << Found << ")";
+    return testing::AssertionFailure()
+           << "Dynamic match result (" << DynamicFound
+           << ") does not match static result (" << Found << ")";
   }
   if (!Found && ExpectMatch) {
     return testing::AssertionFailure()
-      << "Could not find match in \"" << Code << "\"";
+           << "Could not find match in \"" << Code << "\"";
   } else if (Found && !ExpectMatch) {
     return testing::AssertionFailure()
-      << "Found unexpected match in \"" << Code << "\"";
+           << "Found unexpected match in \"" << Code << "\"";
   }
   return testing::AssertionSuccess();
 }
@@ -216,7 +216,8 @@ matchesConditionallyWithCuda(const Twine &Code, const T &AMatcher,
       "                      size_t sharedSize = 0,"
       "                      cudaStream_t stream = 0);"
       "extern \"C\" unsigned __cudaPushCallConfiguration("
-      "    dim3 gridDim, dim3 blockDim, size_t sharedMem = 0, void *stream = 0);";
+      "    dim3 gridDim, dim3 blockDim, size_t sharedMem = 0, void *stream = "
+      "0);";
 
   bool Found = false, DynamicFound = false;
   MatchFinder Finder;
@@ -233,22 +234,20 @@ matchesConditionallyWithCuda(const Twine &Code, const T &AMatcher,
   std::vector Args = {
       "-xcuda",  "-fno-ms-extensions",     "--cuda-host-only",     "-nocudainc",
       "-target", "x86_64-unknown-unknown", std::string(CompileArg)};
-  if (!runToolOnCodeWithArgs(Factory->create(),
-                             CudaHeader + Code, Args)) {
+  if (!runToolOnCodeWithArgs(Factory->create(), CudaHeader + Code, Args)) {
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (Found != DynamicFound) {
-    return testing::AssertionFailure() << "Dynamic match result ("
-                                       << DynamicFound
-                                       << ") does not match static result ("
-                                       << Found << ")";
+    return testing::AssertionFailure()
+           << "Dynamic match result (" << DynamicFound
+           << ") does not match static result (" << Found << ")";
   }
   if (!Found && ExpectMatch) {
     return testing::AssertionFailure()
-      << "Could not find match in \"" << Code << "\"";
+           << "Could not find match in \"" << Code << "\"";
   } else if (Found && !ExpectMatch) {
     return testing::AssertionFailure()
-      << "Found unexpected match in \"" << Code << "\"";
+           << "Found unexpected match in \"" << Code << "\"";
   }
   return testing::AssertionSuccess();
 }
@@ -276,13 +275,28 @@ testing::AssertionResult notMatchesWithOpenMP(const Twine &Code,
   return matchesConditionally(Code, AMatcher, false, {"-fopenmp=libomp"});
 }
 
+template 
+testing::AssertionResult matchesWithOpenMP51(const Twine &Code,
+                                             const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, true,
+                              {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
+template 
+testing::AssertionResult notMatchesWithOpenMP51(const Twine &Code,
+                                                const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, false,
+                              {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
 template 
 testing::AssertionResult matchAndVerifyResultConditionally(
     const Twine &Code, const T &AMatcher,
     std::unique_ptr FindResultVerifier, bool ExpectResult) {
   bool VerifiedResult = false;
   MatchFinder Finder;
-  VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier), &VerifiedResult);
+  VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier),
+                                   &VerifiedResult);
   Finder.addMatcher(AMatcher, &VerifyVerifiedResult);
   std::unique_ptr Factory(
       newFrontendActionFactory(&Finder));
@@ -296,10 +310,10 @@ testing::AssertionResult matchAndVerifyResultConditionally(
   }
   if (!VerifiedResult && ExpectResult) {
     return testing::AssertionFailure()
-      << "Could not verify result in \"" << Code << "\"";
+           << "Could not verify result in \"" << Code << "\"";
   } else if (VerifiedResult && !ExpectResult) {
     return testing::AssertionFailure()
-      << "Verified unexpected result in \"" << Code << "\"";
+           << "Verified unexpected result in \"" << Code << "\"";
   }
 
   VerifiedResult = false;
@@ -307,15 +321,15 @@ testing::AssertionResult matchAndVerifyResultConditionally(
   std::unique_ptr AST(
       buildASTFromCodeWithArgs(Code.toStringRef(Buffer), Args));
   if (!AST.get())
-    return testing::AssertionFailure() << "Parsing error in \"" << Code
-                                       << "\" while building AST";
+    return testing::AssertionFailure()
+           << "Parsing error in \"" << Code << "\" while building AST";
   Finder.matchAST(AST->getASTContext());
   if (!VerifiedResult && ExpectResult) {
     return testing::AssertionFailure()
-      << "Could not verify result in \"" << Code << "\" with AST";
+           << "Could not verify result in \"" << Code << "\" with AST";
   } else if (VerifiedResult && !ExpectResult) {
     return testing::AssertionFailure()
-      << "Verified unexpected result in \"" << Code << "\" with AST";
+           << "Verified unexpected result in \"" << Code << "\" with AST";
   }
 
   return testing::AssertionSuccess();
@@ -327,8 +341,8 @@ template 
 testing::AssertionResult matchAndVerifyResultTrue(
     const Twine &Code, const T &AMatcher,
     std::unique_ptr FindResultVerifier) {
-  return matchAndVerifyResultConditionally(
-      Code, AMatcher, std::move(FindResultVerifier), true);
+  return matchAndVerifyResultConditionally(Code, AMatcher,
+                                           std::move(FindResultVerifier), true);
 }
 
 template 
@@ -342,8 +356,7 @@ testing::AssertionResult matchAndVerifyResultFalse(
 // Implements a run method that returns whether BoundNodes contains a
 // Decl bound to Id that can be dynamically cast to T.
 // Optionally checks that the check succeeded a specific number of times.
-template 
-class VerifyIdIsBoundTo : public BoundNodesCallback {
+template  class VerifyIdIsBoundTo : public BoundNodesCallback {
 public:
   // Create an object that checks that a node of type \c T was bound to \c Id.
   // Does not check for a certain number of matches.
@@ -386,7 +399,7 @@ class VerifyIdIsBoundTo : public BoundNodesCallback {
       if (const NamedDecl *Named = Nodes->getNodeAs(Id)) {
         Name = Named->getNameAsString();
       } else if (const NestedNameSpecifier *NNS =
-        Nodes->getNodeAs(Id)) {
+                     Nodes->getNodeAs(Id)) {
         llvm::raw_string_ostream OS(Name);
         NNS->print(OS, PrintingPolicy(LangOptions()));
       }
@@ -398,7 +411,7 @@ class VerifyIdIsBoundTo : public BoundNodesCallback {
       return true;
     }
     EXPECT_TRUE(M.count(Id) == 0 ||
-      M.find(Id)->second.template get() == nullptr);
+                M.find(Id)->second.template get() == nullptr);
     return false;
   }
 
@@ -437,4 +450,4 @@ class ASTMatchersTest : public ::testing::Test,
 } // namespace ast_matchers
 } // namespace clang
 
-#endif  // LLVM_CLANG_UNITTESTS_AST_MATCHERS_AST_MATCHERS_TEST_H
+#endif // LLVM_CLANG_UNITTESTS_AST_MATCHERS_AST_MATCHERS_TEST_H

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index bf799a781ae1..93ea63c1c2e6 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -982,6 +982,7 @@ __OMP_CANCEL_KIND(taskgroup, 4)
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND


        

From cfe-commits at lists.llvm.org  Sun Jul 12 21:03:56 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via cfe-commits)
Date: Sun, 12 Jul 2020 21:03:56 -0700 (PDT)
Subject: [clang-tools-extra] 7844366 - [OpenMP] Add firstprivate as a default
 data-sharing attribute to clang
Message-ID: <5f0bdd2c.1c69fb81.692b4.cc92@mx.google.com>


Author: Atmn Patel
Date: 2020-07-12T23:01:40-05:00
New Revision: 78443666bc18a6957d279a0f58319c8a3e57771a

URL: https://github.com/llvm/llvm-project/commit/78443666bc18a6957d279a0f58319c8a3e57771a
DIFF: https://github.com/llvm/llvm-project/commit/78443666bc18a6957d279a0f58319c8a3e57771a.diff

LOG: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

This implements the default(firstprivate) clause as defined in OpenMP
Technical Report 8 (2.22.4).

Reviewed By: jdoerfert, ABataev

Differential Revision: https://reviews.llvm.org/D75591

Added: 
    

Modified: 
    clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
    clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
    clang/docs/LibASTMatchersReference.html
    clang/include/clang/ASTMatchers/ASTMatchers.h
    clang/include/clang/Basic/DiagnosticParseKinds.td
    clang/lib/ASTMatchers/Dynamic/Registry.cpp
    clang/lib/Parse/ParseOpenMP.cpp
    clang/lib/Sema/SemaOpenMP.cpp
    clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
    clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
    clang/test/OpenMP/driver.c
    clang/test/OpenMP/parallel_default_messages.cpp
    clang/test/OpenMP/parallel_for_default_messages.cpp
    clang/test/OpenMP/parallel_for_simd_default_messages.cpp
    clang/test/OpenMP/parallel_master_codegen.cpp
    clang/test/OpenMP/parallel_master_default_messages.cpp
    clang/test/OpenMP/parallel_sections_default_messages.cpp
    clang/test/OpenMP/target_parallel_default_messages.cpp
    clang/test/OpenMP/target_parallel_for_default_messages.cpp
    clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
    clang/test/OpenMP/target_teams_default_messages.cpp
    clang/test/OpenMP/target_teams_distribute_default_messages.cpp
    clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
    clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
    clang/test/OpenMP/task_default_messages.cpp
    clang/test/OpenMP/task_messages.cpp
    clang/test/OpenMP/teams_default_messages.cpp
    clang/test/OpenMP/teams_distribute_default_messages.cpp
    clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
    clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
    clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
    clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
    clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
    clang/unittests/ASTMatchers/ASTMatchersTest.h
    llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst b/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
index 4223a10bd6e9..77114100ba1c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
@@ -51,3 +51,12 @@ Example
     // WARNING: OpenMP directive ``parallel`` specifies ``default(shared)``
     //          clause. Consider using ``default(none)`` clause instead.
   }
+
+  // ``parallel`` directive can have ``default`` clause, and said clause is
+  // specified, but with ``firstprivate`` kind, which is not ``none``, diagnose.
+  void p0_3() {
+  #pragma omp parallel default(firstprivate)
+    ;
+    // WARNING: OpenMP directive ``parallel`` specifies ``default(firstprivate)``
+    //          clause. Consider using ``default(none)`` clause instead.
+  }

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp b/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
index 35d2d17b1e0e..d1d3b0e441f3 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
@@ -1,5 +1,5 @@
-// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -fopenmp=libomp -fopenmp-version=40
-// RUN: %check_clang_tidy -std=c11 %s openmp-use-default-none %t -- -- -x c -fopenmp=libomp -fopenmp-version=40
+// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -fopenmp=libomp -fopenmp-version=51
+// RUN: %check_clang_tidy -std=c11 %s openmp-use-default-none %t -- -- -x c -fopenmp=libomp -fopenmp-version=51
 
 //----------------------------------------------------------------------------//
 // Null cases.
@@ -42,6 +42,15 @@ void p0_2() {
   // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified here
 }
 
+// 'parallel' directive can have 'default' clause, and said clause specified,
+// but with 'firstprivate' kind, which is not 'none', diagnose.
+void p0_3() {
+#pragma omp parallel default(firstprivate)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified here
+}
+
 // 'task' directive.
 
 // 'task' directive can have 'default' clause, but said clause is not
@@ -68,6 +77,15 @@ void p1_2() {
   // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified here
 }
 
+// 'task' directive can have 'default' clause, and said clause specified,
+// but with 'firstprivate' kind, which is not 'none', diagnose.
+void p1_3() {
+#pragma omp task default(firstprivate)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified here
+}
+
 // 'teams' directive. (has to be inside of 'target' directive)
 
 // 'teams' directive can have 'default' clause, but said clause is not
@@ -97,6 +115,16 @@ void p2_2() {
   // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified here
 }
 
+// 'teams' directive can have 'default' clause, and said clause specified,
+// but with 'firstprivate' kind, which is not 'none', diagnose.
+void p2_3() {
+#pragma omp target
+#pragma omp teams default(firstprivate)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified here
+}
+
 // 'taskloop' directive.
 
 // 'taskloop' directive can have 'default' clause, but said clause is not
@@ -126,6 +154,16 @@ void p3_2(const int a) {
   // CHECK-NOTES: :[[@LINE-4]]:22: note: existing 'default' clause specified here
 }
 
+// 'taskloop' directive can have 'default' clause, and said clause specified,
+// but with 'firstprivate' kind, which is not 'none', diagnose.
+void p3_3(const int a) {
+#pragma omp taskloop default(firstprivate)
+  for (int b = 0; b < a; b++)
+    ;
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-4]]:22: note: existing 'default' clause specified here
+}
+
 //----------------------------------------------------------------------------//
 // Combined directives.
 // Let's not test every single possible permutation/combination of directives,
@@ -158,3 +196,13 @@ void p4_2(const int a) {
   // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'parallel for' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
   // CHECK-NOTES: :[[@LINE-4]]:26: note: existing 'default' clause specified here
 }
+
+// 'parallel' directive can have 'default' clause, and said clause specified,
+// but with 'firstprivate' kind, which is not 'none', diagnose.
+void p4_3(const int a) {
+#pragma omp parallel for default(firstprivate)
+  for (int b = 0; b < a; b++)
+    ;
+  // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'parallel for' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
+  // CHECK-NOTES: :[[@LINE-4]]:26: note: existing 'default' clause specified here
+}

diff  --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index 2256cbf71869..60ff6ffe6056 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -676,9 +676,10 @@ 

Node Matchers

#pragma omp parallel default(none) #pragma omp parallel default(shared) + #pragma omp parallel default(firstprivate) #pragma omp parallel -``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``. +``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and ``default(firstprivate)``.
@@ -3783,6 +3784,7 @@

Narrowing Matchers

#pragma omp parallel #pragma omp parallel default(none) #pragma omp parallel default(shared) + #pragma omp parallel default(firstprivate) ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``. @@ -3796,11 +3798,26 @@

Narrowing Matchers

#pragma omp parallel #pragma omp parallel default(none) #pragma omp parallel default(shared) + #pragma omp parallel default(firstprivate) ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``. +Matcher<
OMPDefaultClause>isSharedKind +
Matches if the OpenMP ``default`` clause has ``firstprivate`` kind specified.
+
+Given
+
+  #pragma omp parallel
+  #pragma omp parallel default(none)
+  #pragma omp parallel default(shared)
+  #pragma omp parallel default(firstprivate)
+
+``ompDefaultClause(isFirstPrivateKind())`` matches only ``default(firstprivate)``.
+
+ + Matcher<OMPExecutableDirective>isAllowedToContainClauseKindOpenMPClauseKind CKind
Matches if the OpenMP directive is allowed to contain the specified OpenMP
 clause kind.

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index f16fb876cdd3..643419743a11 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7190,10 +7190,12 @@ AST_MATCHER_P(OMPExecutableDirective, hasAnyClause,
 /// \code
 ///   #pragma omp parallel default(none)
 ///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
 ///   #pragma omp parallel
 /// \endcode
 ///
-/// ``ompDefaultClause()`` matches ``default(none)`` and ``default(shared)``.
+/// ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
+/// ``default(firstprivate)``
 extern const internal::VariadicDynCastAllOfMatcher
     ompDefaultClause;
 
@@ -7205,6 +7207,7 @@ extern const internal::VariadicDynCastAllOfMatcher
 ///   #pragma omp parallel
 ///   #pragma omp parallel default(none)
 ///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
 /// \endcode
 ///
 /// ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
@@ -7220,6 +7223,7 @@ AST_MATCHER(OMPDefaultClause, isNoneKind) {
 ///   #pragma omp parallel
 ///   #pragma omp parallel default(none)
 ///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
 /// \endcode
 ///
 /// ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
@@ -7227,6 +7231,24 @@ AST_MATCHER(OMPDefaultClause, isSharedKind) {
   return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_shared;
 }
 
+/// Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
+/// specified.
+///
+/// Given
+///
+/// \code
+///   #pragma omp parallel
+///   #pragma omp parallel default(none)
+///   #pragma omp parallel default(shared)
+///   #pragma omp parallel default(firstprivate)
+/// \endcode
+///
+/// ``ompDefaultClause(isFirstPrivateKind())`` matches only
+/// ``default(firstprivate)``.
+AST_MATCHER(OMPDefaultClause, isFirstPrivateKind) {
+  return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_firstprivate;
+}
+
 /// Matches if the OpenMP directive is allowed to contain the specified OpenMP
 /// clause kind.
 ///

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index f5b32a6ba5fa..1038a4119d4c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1334,6 +1334,8 @@ def warn_omp_more_one_device_type_clause
       InGroup;
 def err_omp_variant_ctx_second_match_extension : Error<
   "only a single match extension allowed per OpenMP context selector">;
+def err_omp_invalid_dsa: Error<
+  "data-sharing attribute '%0' in '%1' clause requires OpenMP version %2 or above">;
 
 // Pragma loop support.
 def err_pragma_loop_missing_argument : Error<

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index a0a65092a92b..ec2215804c09 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -389,6 +389,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isExpr);
   REGISTER_MATCHER(isExternC);
   REGISTER_MATCHER(isFinal);
+  REGISTER_MATCHER(isFirstPrivateKind);
   REGISTER_MATCHER(isImplicit);
   REGISTER_MATCHER(isInStdNamespace);
   REGISTER_MATCHER(isInTemplateInstantiation);

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index afcef3043843..5223755c8fdf 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -1441,7 +1441,7 @@ bool Parser::parseOMPDeclareVariantMatchClause(SourceLocation Loc,
 /// Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
 ///
 ///    default-clause:
-///         'default' '(' 'none' | 'shared' ')
+///         'default' '(' 'none' | 'shared'  | 'firstprivate' ')
 ///
 ///    proc_bind-clause:
 ///         'proc_bind' '(' 'master' | 'close' | 'spread' ')
@@ -2772,7 +2772,7 @@ OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind,
 /// Parsing of simple OpenMP clauses like 'default' or 'proc_bind'.
 ///
 ///    default-clause:
-///         'default' '(' 'none' | 'shared' ')'
+///         'default' '(' 'none' | 'shared' | 'firstprivate' ')'
 ///
 ///    proc_bind-clause:
 ///         'proc_bind' '(' 'master' | 'close' | 'spread' ')'
@@ -2785,6 +2785,14 @@ OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind,
   llvm::Optional Val = parseOpenMPSimpleClause(*this, Kind);
   if (!Val || ParseOnly)
     return nullptr;
+  if (getLangOpts().OpenMP < 51 && Kind == OMPC_default &&
+      static_cast(Val.getValue().Type) ==
+          OMP_DEFAULT_firstprivate) {
+    Diag(Val.getValue().LOpen, diag::err_omp_invalid_dsa)
+        << getOpenMPClauseName(OMPC_firstprivate)
+        << getOpenMPClauseName(OMPC_default) << "5.1";
+    return nullptr;
+  }
   return Actions.ActOnOpenMPSimpleClause(
       Kind, Val.getValue().Type, Val.getValue().TypeLoc, Val.getValue().LOpen,
       Val.getValue().Loc, Val.getValue().RLoc);

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b27abb54c170..920463da4027 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -53,9 +53,10 @@ static const Expr *checkMapClauseExpressionBase(
 namespace {
 /// Default data sharing attributes, which can be applied to directive.
 enum DefaultDataSharingAttributes {
-  DSA_unspecified = 0, /// Data sharing attribute not specified.
-  DSA_none = 1 << 0,   /// Default data sharing attribute 'none'.
-  DSA_shared = 1 << 1, /// Default data sharing attribute 'shared'.
+  DSA_unspecified = 0,       /// Data sharing attribute not specified.
+  DSA_none = 1 << 0,         /// Default data sharing attribute 'none'.
+  DSA_shared = 1 << 1,       /// Default data sharing attribute 'shared'.
+  DSA_firstprivate = 1 << 2, /// Default data sharing attribute 'firstprivate'.
 };
 
 /// Stack for tracking declarations used in OpenMP directives and
@@ -684,6 +685,11 @@ class DSAStackTy {
     getTopOfStack().DefaultAttr = DSA_shared;
     getTopOfStack().DefaultAttrLoc = Loc;
   }
+  /// Set default data sharing attribute to firstprivate.
+  void setDefaultDSAFirstPrivate(SourceLocation Loc) {
+    getTopOfStack().DefaultAttr = DSA_firstprivate;
+    getTopOfStack().DefaultAttrLoc = Loc;
+  }
   /// Set default data mapping attribute to Modifier:Kind
   void setDefaultDMAAttr(OpenMPDefaultmapClauseModifier M,
                          OpenMPDefaultmapClauseKind Kind,
@@ -1183,6 +1189,15 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
     return DVar;
   case DSA_none:
     return DVar;
+  case DSA_firstprivate:
+    if (VD->getStorageDuration() == SD_Static &&
+        VD->getDeclContext()->isFileContext()) {
+      DVar.CKind = OMPC_unknown;
+    } else {
+      DVar.CKind = OMPC_firstprivate;
+    }
+    DVar.ImplicitDSALoc = Iter->DefaultAttrLoc;
+    return DVar;
   case DSA_unspecified:
     // OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
     // in a Construct, implicitly determined, p.2]
@@ -2058,7 +2073,13 @@ bool Sema::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
         // If the variable is artificial and must be captured by value - try to
         // capture by value.
         !(isa(D) && !D->hasAttr() &&
-          !cast(D)->getInit()->isGLValue());
+          !cast(D)->getInit()->isGLValue()) &&
+        // If the variable is implicitly firstprivate and scalar - capture by
+        // copy
+        !(DSAStack->getDefaultDSA() == DSA_firstprivate &&
+          !DSAStack->hasExplicitDSA(
+              D, [](OpenMPClauseKind K) { return K != OMPC_unknown; }, Level) &&
+          !DSAStack->isLoopControlVariable(D, Level).first);
   }
 
   // When passing data by copy, we need to make sure it fits the uintptr size
@@ -2185,10 +2206,13 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo,
         DSAStack->isClauseParsingMode());
     // Global shared must not be captured.
     if (VD && !VD->hasLocalStorage() && DVarPrivate.CKind == OMPC_unknown &&
-        (DSAStack->getDefaultDSA() != DSA_none || DVarTop.CKind == OMPC_shared))
+        ((DSAStack->getDefaultDSA() != DSA_none &&
+          DSAStack->getDefaultDSA() != DSA_firstprivate) ||
+         DVarTop.CKind == OMPC_shared))
       return nullptr;
     if (DVarPrivate.CKind != OMPC_unknown ||
-        (VD && DSAStack->getDefaultDSA() == DSA_none))
+        (VD && (DSAStack->getDefaultDSA() == DSA_none ||
+                DSAStack->getDefaultDSA() == DSA_firstprivate)))
       return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
   }
   return nullptr;
@@ -3333,10 +3357,19 @@ class DSAAttrChecker final : public StmtVisitor {
       // in the construct, and does not have a predetermined data-sharing
       // attribute, must have its data-sharing attribute explicitly determined
       // by being listed in a data-sharing attribute clause.
-      if (DVar.CKind == OMPC_unknown && Stack->getDefaultDSA() == DSA_none &&
+      if (DVar.CKind == OMPC_unknown &&
+          (Stack->getDefaultDSA() == DSA_none ||
+           Stack->getDefaultDSA() == DSA_firstprivate) &&
           isImplicitOrExplicitTaskingRegion(DKind) &&
           VarsWithInheritedDSA.count(VD) == 0) {
-        VarsWithInheritedDSA[VD] = E;
+        bool InheritedDSA = Stack->getDefaultDSA() == DSA_none;
+        if (!InheritedDSA && Stack->getDefaultDSA() == DSA_firstprivate) {
+          DSAStackTy::DSAVarData DVar =
+              Stack->getImplicitDSA(VD, /*FromParent=*/false);
+          InheritedDSA = DVar.CKind == OMPC_unknown;
+        }
+        if (InheritedDSA)
+          VarsWithInheritedDSA[VD] = E;
         return;
       }
 
@@ -3438,7 +3471,9 @@ class DSAAttrChecker final : public StmtVisitor {
 
       // Define implicit data-sharing attributes for task.
       DVar = Stack->getImplicitDSA(VD, /*FromParent=*/false);
-      if (isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared &&
+      if (((isOpenMPTaskingDirective(DKind) && DVar.CKind != OMPC_shared) ||
+           (Stack->getDefaultDSA() == DSA_firstprivate &&
+            DVar.CKind == OMPC_firstprivate && !DVar.RefExpr)) &&
           !Stack->isLoopControlVariable(VD).first) {
         ImplicitFirstprivate.push_back(E);
         return;
@@ -5342,8 +5377,10 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 
   ErrorFound = Res.isInvalid() || ErrorFound;
 
-  // Check variables in the clauses if default(none) was specified.
-  if (DSAStack->getDefaultDSA() == DSA_none) {
+  // Check variables in the clauses if default(none) or
+  // default(firstprivate) was specified.
+  if (DSAStack->getDefaultDSA() == DSA_none ||
+      DSAStack->getDefaultDSA() == DSA_firstprivate) {
     DSAAttrChecker DSAChecker(DSAStack, *this, nullptr);
     for (OMPClause *C : Clauses) {
       switch (C->getClauseKind()) {
@@ -5454,7 +5491,8 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
     if (P.getFirst()->isImplicit() || isa(P.getFirst()))
       continue;
     ErrorFound = true;
-    if (DSAStack->getDefaultDSA() == DSA_none) {
+    if (DSAStack->getDefaultDSA() == DSA_none ||
+        DSAStack->getDefaultDSA() == DSA_firstprivate) {
       Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable)
           << P.first << P.second->getSourceRange();
       Diag(DSAStack->getDefaultDSALocation(), diag::note_omp_default_dsa_none);
@@ -12932,10 +12970,20 @@ OMPClause *Sema::ActOnOpenMPDefaultClause(DefaultKind Kind,
         << getOpenMPClauseName(OMPC_default);
     return nullptr;
   }
-  if (Kind == OMP_DEFAULT_none)
+
+  switch (Kind) {
+  case OMP_DEFAULT_none:
     DSAStack->setDefaultDSANone(KindKwLoc);
-  else if (Kind == OMP_DEFAULT_shared)
+    break;
+  case OMP_DEFAULT_shared:
     DSAStack->setDefaultDSAShared(KindKwLoc);
+    break;
+  case OMP_DEFAULT_firstprivate:
+    DSAStack->setDefaultDSAFirstPrivate(KindKwLoc);
+    break;
+  default:
+    llvm_unreachable("DSA unexpected in OpenMP default clause");
+  }
 
   return new (Context)
       OMPDefaultClause(Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);

diff  --git a/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
index 0629ba096d0c..67e4615ae8c0 100644
--- a/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
@@ -2,8 +2,17 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 template 
 T tmain(T argc) {
   int i;
@@ -14,12 +23,12 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -34,7 +43,7 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -62,12 +71,12 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -82,7 +91,7 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -98,5 +107,15 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return (tmain(argc) + tmain(argv[0][0])); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }

diff  --git a/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
index b9c5546ec5d9..9aab00f16c48 100644
--- a/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
@@ -2,8 +2,17 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized -DOMP51 -fopenmp-version=51
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized -DOMP51 -fopenmp-version=51
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 template 
 T tmain(T argc) {
   int i;
@@ -14,12 +23,12 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -34,7 +43,7 @@ T tmain(T argc) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -62,12 +71,12 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -82,7 +91,7 @@ int main(int argc, char **argv) {
     foo();
 #pragma omp target
 #pragma omp teams
-#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target
@@ -90,6 +99,15 @@ int main(int argc, char **argv) {
 #pragma omp distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (i = 0; i < argc; ++i)  // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
+#ifdef OpenMP51
+#pragma omp target
+#pragma omp teams
+#pragma omp distribute parallel for simd default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
 
 #pragma omp parallel default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
 #pragma omp target

diff  --git a/clang/test/OpenMP/driver.c b/clang/test/OpenMP/driver.c
index fa5bd1a8b5f8..047478256f9f 100644
--- a/clang/test/OpenMP/driver.c
+++ b/clang/test/OpenMP/driver.c
@@ -47,6 +47,7 @@
 // RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=31 | FileCheck --check-prefix=CHECK-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=40 | FileCheck --check-prefix=CHECK-VERSION %s
 // RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=45 | FileCheck --check-prefix=CHECK-VERSION %s
+// RUN: %clang %s -c -E -dM -fopenmp-simd -fopenmp-version=51 | FileCheck --check-prefix=CHECK-VERSION %s
 
 // CHECK-VERSION-NOT: #define _OPENMP
 

diff  --git a/clang/test/OpenMP/parallel_default_messages.cpp b/clang/test/OpenMP/parallel_default_messages.cpp
index 6b8ad6705185..b098c43852a8 100644
--- a/clang/test/OpenMP/parallel_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_default_messages.cpp
@@ -4,18 +4,25 @@
 // RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=40 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-version=31 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify -fopenmp-version=30 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=51 -fopenmp -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,ge40 -fopenmp-version=51 -fopenmp-simd -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
 
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   const int c = 0;
 
   #pragma omp parallel default // expected-error {{expected '(' after 'default'}}
-  #pragma omp parallel default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp parallel default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
-  #pragma omp parallel default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp parallel default (shared), default(shared) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'default' clause}}
-  #pragma omp parallel default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel default(  // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
+#pragma omp parallel default(none                     // expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel default(shared), default(shared) // expected-error {{directive '#pragma omp parallel' cannot contain more than one 'default' clause}}
+#pragma omp parallel default(x)                       // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
   #pragma omp parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -27,5 +34,14 @@ int main(int argc, char **argv) {
 
   #pragma omp parallel default(none) // ge40-note {{explicit data sharing attribute requested here}}
   (void)c; // ge40-error {{variable 'c' must have explicitly specified data sharing attributes}}
+
+#ifdef OMP51
+#pragma omp parallel default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_for_default_messages.cpp b/clang/test/OpenMP/parallel_for_default_messages.cpp
index b02fa8803a3b..c64b76948c01 100644
--- a/clang/test/OpenMP/parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp parallel for default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel for default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp parallel for default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifdef OMP51
+#pragma omp parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
index 570ee14bbc84..6368d280de5d 100644
--- a/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_for_simd_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} expected-error {{variable 'i' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifdef OMP51
+#pragma omp parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (i = 0; i < argc; ++i) {
+    x++; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    y++; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_master_codegen.cpp b/clang/test/OpenMP/parallel_master_codegen.cpp
index 9ffa941314b9..82e18c80f103 100644
--- a/clang/test/OpenMP/parallel_master_codegen.cpp
+++ b/clang/test/OpenMP/parallel_master_codegen.cpp
@@ -118,6 +118,162 @@ void parallel_master_private() {
 
 #endif
 
+#ifdef CK31
+///==========================================================================///
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK31
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK31
+
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK31 -fopenmp-version=51 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK31-DAG:   %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK31-DAG:   [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+
+void parallel_master_default_firstprivate() {
+  int a;
+#pragma omp parallel master default(firstprivate)
+  a++;
+}
+
+// CK31-LABEL: define void @{{.+}}parallel_master{{.+}}
+// CK31:       [[A_VAL:%.+]] = alloca i32{{.+}}
+// CK31:       [[A_CASTED:%.+]] = alloca i64
+// CK31:       [[ZERO_VAL:%.+]] = load i32, i32* [[A_VAL]]
+// CK31:       [[CONV:%.+]] = bitcast i64* [[A_CASTED]] to i32*
+// CK31:       store i32 [[ZERO_VAL]], i32* [[CONV]]
+// CK31:       [[ONE_VAL:%.+]] = load i64, i64* [[A_CASTED]]
+// CK31:       call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @0, i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, i64)* @.omp_outlined. to void (i32*, i32*, ...)*), i64 [[ONE_VAL]])
+// CK31:       ret void
+
+// CK31:       [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK31:       [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK31:       [[A_ADDR:%.+]] = alloca i64{{.+}}
+// CK31:       store i32* [[GLOBAL_TID:%.+]], i32** [[GLOBAL_TID_ADDR]]{{.+}}
+// CK31:       store i32* [[BOUND_TID:%.+]], i32** [[BOUND_TID_ADDR]]
+// CK31:       store i64 [[A_VAL]], i64* [[A_ADDR]]
+// CK31:       [[CONV]] = bitcast i64* [[A_ADDR]]
+// CK31:       [[ZERO_VAL]] = load i32*, i32** [[GLOBAL_TID_ADDR]]
+// CK31:       [[ONE_VAL]] = load i32, i32* [[ZERO_VAL]]
+// CK31:       [[TWO_VAL:%.+]] = call i32 @__kmpc_master(%struct.ident_t* @0, i32 [[ONE_VAL]])
+// CK31:       [[THREE:%.+]] = icmp ne i32 [[TWO_VAL]], 0
+// CK31:       br i1 %3, label [[OMP_IF_THEN:%.+]], label [[OMP_IF_END:%.+]]
+
+// CK31:       [[FOUR:%.+]] = load i32, i32* [[CONV:%.+]]
+// CK31:       [[INC:%.+]] = add nsw i32 [[FOUR]]
+// CK31:       store i32 [[INC]], i32* [[CONV]]
+// CK31:       call void @__kmpc_end_master(%struct.ident_t* @0, i32 [[ONE_VAL]])
+// CK31:       br label [[OMP_IF_END]]
+
+// CK31:       ret void
+
+#endif
+
+#ifdef CK32
+///==========================================================================///
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK32
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK32
+
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -DCK32 -fopenmp-version=51 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// CK32-DAG:   %struct.ident_t = type { i32, i32, i32, i32, i8* }
+// CK32-DAG:   [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+
+struct St {
+  int a, b;
+  static int y;
+  St() : a(0), b(0) {}
+  ~St() {}
+};
+int St::y = 0;
+
+void parallel_master_default_firstprivate() {
+  St a = St();
+  static int y = 0;
+#pragma omp parallel master default(firstprivate)
+  {
+    a.a += 1;
+    a.b += 1;
+    y++;
+    a.y++;
+  }
+}
+
+// CK32-LABEL: define {{.+}} @{{.+}}parallel_master_default_firstprivate{{.+}}
+// CK32: [[A_VAL:%.+]] = alloca %struct.St{{.+}}
+// CK32: [[Y_CASTED:%.+]] = alloca i64
+// CK32: call void @[[CTOR:.+]](%struct.St* [[A_VAL]])
+// CK32: [[ZERO:%.+]] = load i32, i32* @{{.+}}parallel_master_default_firstprivate{{.+}}
+// CK32: [[CONV:%.+]] = bitcast i64* [[Y_CASTED]] to i32*
+// CK32: store i32 [[ZERO]], i32* [[CONV]]
+// CK32: [[ONE:%.+]] = load i64, i64* [[Y_CASTED]]
+// CK32: call void {{.+}}@{{.+}} %struct.St* [[A_VAL]], i64 [[ONE]])
+// CK32: call void [[DTOR:@.+]](%struct.St* [[A_VAL]])
+
+// CK32: [[THIS_ADDR:%.+]] = alloca %struct.St*
+// CK32: store %struct.St* [[THIS:%.+]], %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE:%.+]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+// CK32: call void [[CTOR_2:.+]](%struct.St* [[THIS_ONE]])
+// CK32: ret void
+
+// CK32: [[GLOBAL_TID_ADDR:%.+]] = alloca i32*
+// CK32: [[BOUND_TID_ADDR:%.+]] = alloca i32*
+// CK32: [[A_ADDR:%.+]] = alloca %struct.St
+// CK32: [[Y_ADDR:%.+]] = alloca i64
+// CK32: store i32* [[GLOBAL_TID:%.+]], i32** [[GLOBAL_TID_ADDR]]
+// CK32: store i32* %.bound_tid., i32** [[BOUND_TID_ADDR]]
+// CK32: store %struct.St* [[A_VAL]], %struct.St** [[A_ADDR]]{{.+}}
+// CK32: store i64 [[Y:%.+]], i64* [[Y_ADDR]]
+// CK32: [[ONE:%.+]] = load i32*, i32** [[GLOBAL_TID_ADDR]]
+// CK32: [[TWO:%.+]] = load i32, i32* [[ONE]]
+// CK32: [[THREE:%.+]] = call i32 @{{.+}} i32 [[TWO]])
+// CK32: [[FOUR:%.+]] = icmp ne i32 [[THREE]], 0
+// CK32: br i1 [[FOUR]], label [[IF_THEN:%.+]], label [[IF_END:%.+]]
+
+// CK32: [[A_1:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[ZERO]], i32 0, i32 0
+// CK32: [[FIVE:%.+]] = load i32, i32* [[A_1]]
+// CK32: [[ADD:%.+]] = add nsw i32 [[FIVE]], 1
+// CK32: store i32 [[ADD]], i32* [[A_1]]
+// CK32: [[B:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[ZERO]], i32 0, i32 1
+// CK32: [[SIX:%.+]] = load i32, i32* [[B]]
+// CK32: [[ADD_2:%.+]] = add nsw i32 [[SIX]], 1
+// CK32: store i32 [[ADD_2]], i32* [[B]]
+// CK32: [[SEVEN:%.+]] = load i32, i32* [[CONV]]
+// CK32: [[INC:%.+]] = add nsw i32 [[SEVEN]], 1
+// CK32: store i32 [[INC]], i32* [[CONV]]
+// CK32: [[EIGHT:%.+]] = load i32, i32* [[FUNC:@.+]]
+// CK32: [[INC_3:%.+]] = add nsw i32 [[EIGHT]], 1
+// CK32: store i32 [[INC_3]], i32* @{{.+}}
+// CK32: call void @{{.+}} i32 [[TWO]])
+// CK32: br label [[IF_END]]
+
+// CK32: [[DTOR]](%struct.St* [[THIS]])
+// CK32: [[THIS_ADDR]] = alloca %struct.St*
+// CK32: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+// CK32: call void @_ZN2StD2Ev(%struct.St* [[THIS_ONE]])
+
+// CK32: [[THIS_ADDR]] = alloca %struct.St*
+// CK32: store %struct.St* [[THIS]], %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+// CK32: [[A_VAL]] = getelementptr inbounds %struct.St, %struct.St* [[THIS_ONE]], i32 0, i32 0
+// CK32: store i32 0, i32* [[A_VAL]]
+// CK32: [[B_VAL:%.+]] = getelementptr inbounds %struct.St, %struct.St* [[THIS_ONE]], i32 0, i32 1
+// CK32: store i32 0, i32* [[B_VAL]]
+// CK32: ret void
+
+// CK32: [[THIS_ADDR:%.+]] = alloca %struct.St*
+// CK32: store %struct.St* %this, %struct.St** [[THIS_ADDR]]
+// CK32: [[THIS_ONE]] = load %struct.St*, %struct.St** [[THIS_ADDR]]
+
+#endif
+
 #ifdef CK4
 ///==========================================================================///
 // RUN: %clang_cc1 -DCK4 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefix CK4

diff  --git a/clang/test/OpenMP/parallel_master_default_messages.cpp b/clang/test/OpenMP/parallel_master_default_messages.cpp
index 557cba5aa322..39f78ea53ae1 100644
--- a/clang/test/OpenMP/parallel_master_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_master_default_messages.cpp
@@ -2,20 +2,29 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp parallel master default // expected-error {{expected '(' after 'default'}}
   {
-#pragma omp parallel master default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel master default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     {
-#pragma omp parallel master default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel master default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
       {
 #pragma omp parallel master default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
         {
 #pragma omp parallel master default(shared), default(shared) // expected-error {{directive '#pragma omp parallel master' cannot contain more than one 'default' clause}}
           {
-#pragma omp parallel master default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel master default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
             {
               foo();
             }
@@ -37,5 +46,14 @@ int main(int argc, char **argv) {
       ++argc;  // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     }
   }
+
+#ifdef OMP51
+#pragma omp parallel master default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/parallel_sections_default_messages.cpp b/clang/test/OpenMP/parallel_sections_default_messages.cpp
index d6a10fe56b34..cfa95445fb53 100644
--- a/clang/test/OpenMP/parallel_sections_default_messages.cpp
+++ b/clang/test/OpenMP/parallel_sections_default_messages.cpp
@@ -7,15 +7,15 @@ void foo();
 int main(int argc, char **argv) {
 #pragma omp parallel sections default // expected-error {{expected '(' after 'default'}}
   {
-#pragma omp parallel sections default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp parallel sections default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     {
-#pragma omp parallel sections default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel sections default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
       {
 #pragma omp parallel sections default(none // expected-error {{expected ')'}} expected-note {{to match this '('}}
         {
 #pragma omp parallel sections default(shared), default(shared) // expected-error {{directive '#pragma omp parallel sections' cannot contain more than one 'default' clause}}
           {
-#pragma omp parallel sections default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp parallel sections default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
             {
               foo();
             }

diff  --git a/clang/test/OpenMP/target_parallel_default_messages.cpp b/clang/test/OpenMP/target_parallel_default_messages.cpp
index 0691cdf37e4e..c8f68659438f 100644
--- a/clang/test/OpenMP/target_parallel_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_default_messages.cpp
@@ -2,20 +2,29 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target parallel default // expected-error {{expected '(' after 'default'}}
   foo();
-  #pragma omp target parallel default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
-  #pragma omp target parallel default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
   #pragma omp target parallel default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
   #pragma omp target parallel default (shared), default(shared) // expected-error {{directive '#pragma omp target parallel' cannot contain more than one 'default' clause}}
   foo();
-  #pragma omp target parallel default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
   #pragma omp target parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -28,5 +37,14 @@ int main(int argc, char **argv) {
   #pragma omp target parallel default(none) // expected-note {{explicit data sharing attribute requested here}}
   #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifndef OMP51
+#pragma omp target parallel default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_parallel_for_default_messages.cpp b/clang/test/OpenMP/target_parallel_for_default_messages.cpp
index fc6ba43138d7..4a3aae68e086 100644
--- a/clang/test/OpenMP/target_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp target parallel for default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target parallel for default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp target parallel for default(shared), default(shared) // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifndef OMP51
+#pragma omp target parallel for default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (i = 0; i < argc; ++i) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
index daa93b9c9050..48489309ef03 100644
--- a/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   int i;
 #pragma omp target parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for simd default( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for simd default() // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 #pragma omp target parallel for simd default(none // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-note {{explicit data sharing attribute requested here}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
 #pragma omp target parallel for simd default(shared), default(shared) // expected-error {{directive '#pragma omp target parallel for simd' cannot contain more than one 'default' clause}}
   for (i = 0; i < argc; ++i)
     foo();
-#pragma omp target parallel for simd default(x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (i = 0; i < argc; ++i)
     foo();
 
@@ -34,5 +43,13 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) // expected-error {{variable 'i' must have explicitly specified data sharing attributes}} expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     foo();
 
+#ifndef OMP51
+#pragma omp target parallel for simd default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < argc; i++) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_default_messages.cpp b/clang/test/OpenMP/target_teams_default_messages.cpp
index 21fa8270ef6a..85c417f8f985 100644
--- a/clang/test/OpenMP/target_teams_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_default_messages.cpp
@@ -2,20 +2,29 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp target teams default // expected-error {{expected '(' after 'default'}}
   foo();
-#pragma omp target teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
-#pragma omp target teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 #pragma omp target teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
 #pragma omp target teams default (shared), default(shared) // expected-error {{directive '#pragma omp target teams' cannot contain more than one 'default' clause}}
   foo();
-#pragma omp target teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -24,5 +33,14 @@ int main(int argc, char **argv) {
 #pragma omp target teams default(none) // expected-note {{explicit data sharing attribute requested here}}
 #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifndef OMP51
+#pragma omp target teams default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_distribute_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
index fd834e7cba32..a490ad61385f 100644
--- a/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_default_messages.cpp
@@ -2,24 +2,41 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -DOMP51 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -DOMP51 %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target teams distribute default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
-  #pragma omp target teams distribute default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
-  #pragma omp target teams distribute default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
-  #pragma omp target teams distribute default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target teams distribute default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifndef OMP51
+#pragma omp target teams distribute default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < 200; i++) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
index 00e0704a6cca..2fe793136961 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
@@ -2,24 +2,41 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
- #pragma omp target teams distribute parallel for default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 #pragma omp target teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
 #pragma omp target teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
-#pragma omp target teams distribute parallel for default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
 #pragma omp target teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifndef OMP51
+#pragma omp target teams distribute parallel for default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < 200; i++) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
index 7c46c964d2ec..e5ff85622250 100644
--- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
@@ -2,16 +2,25 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
 
-#pragma omp target teams distribute parallel for simd default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp target teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
 
-#pragma omp target teams distribute parallel for simd default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
 #pragma omp target teams distribute parallel for simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -20,11 +29,19 @@ int main(int argc, char **argv) {
 #pragma omp target teams distribute parallel for simd default (shared), default(shared) // expected-error {{directive '#pragma omp target teams distribute parallel for simd' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
 
-#pragma omp target teams distribute parallel for simd default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp target teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
 #pragma omp target teams distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifndef OMP51
+#pragma omp target teams distribute parallel for simd default(firstprivate) // expected-error {{data-sharing attribute 'firstprivate' in 'default' clause requires OpenMP version 5.1 or above}}
+  for (int i = 0; i < argc; ++i) {
+    ++x;
+    ++y;
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/task_default_messages.cpp b/clang/test/OpenMP/task_default_messages.cpp
index 4826c253aa04..8b6809ee05d5 100644
--- a/clang/test/OpenMP/task_default_messages.cpp
+++ b/clang/test/OpenMP/task_default_messages.cpp
@@ -2,15 +2,24 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
 #pragma omp task default                          // expected-error {{expected '(' after 'default'}}
-#pragma omp task default(                         // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-#pragma omp task default()                        // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp task default(                         // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp task default()                        // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
 #pragma omp task default(none                     // expected-error {{expected ')'}} expected-note {{to match this '('}}
 #pragma omp task default(shared), default(shared) // expected-error {{directive '#pragma omp task' cannot contain more than one 'default' clause}}
-#pragma omp task default(x)                       // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp task default(x)                       // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
@@ -19,5 +28,13 @@ int main(int argc, char **argv) {
 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
 #pragma omp task default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifdef OMP51
+#pragma omp task default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
   return 0;
 }

diff  --git a/clang/test/OpenMP/task_messages.cpp b/clang/test/OpenMP/task_messages.cpp
index 8b3183e0bd93..13cbfb6c4569 100644
--- a/clang/test/OpenMP/task_messages.cpp
+++ b/clang/test/OpenMP/task_messages.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=51 -DOMP51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=51 -DOMP51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
+
 void xxx(int argc) {
   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
 #pragma omp task
@@ -16,6 +19,10 @@ void foo() {
 }
 
 typedef unsigned long omp_event_handle_t;
+namespace {
+static int y = 0;
+}
+static int x = 0;
 
 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
 
@@ -52,6 +59,15 @@ int foo() {
 #pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
 #pragma omp task default(shared)
   ++a; // expected-error 2 {{variable 'a' must have explicitly specified data sharing attributes}}
+#ifdef OMP51
+#pragma omp task default(firstprivate) // expected-note 4 {{explicit data sharing attribute requested here}}
+#pragma omp task
+  {
+    ++x; // expected-error 2 {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error 2 {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
 #pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
 #pragma omp task
   // expected-error at +1 {{calling a private constructor of class 'S'}}

diff  --git a/clang/test/OpenMP/teams_default_messages.cpp b/clang/test/OpenMP/teams_default_messages.cpp
index a02505040600..b117ef4948a0 100644
--- a/clang/test/OpenMP/teams_default_messages.cpp
+++ b/clang/test/OpenMP/teams_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -o - %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp -o - %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd -o - %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams default // expected-error {{expected '(' after 'default'}}
   foo();
   #pragma omp target
-  #pragma omp teams default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   foo();
   #pragma omp target
-  #pragma omp teams default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
   #pragma omp target
   #pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,7 +30,7 @@ int main(int argc, char **argv) {
   #pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
   foo();
   #pragma omp target
-  #pragma omp teams default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   foo();
 
   #pragma omp target
@@ -32,5 +41,14 @@ int main(int argc, char **argv) {
   #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}
   #pragma omp parallel default(shared)
   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
+
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_default_messages.cpp b/clang/test/OpenMP/teams_distribute_default_messages.cpp
index 7f000208303b..1d5fd40c53a6 100644
--- a/clang/test/OpenMP/teams_distribute_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +30,21 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams distribute default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp b/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
index 2c4662398507..3a414543be80 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-version=51 -DOMP51 -fopenmp-simd %s -Wuninitialized
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute parallel for default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute parallel for default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +30,21 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute parallel for default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifdef OMP51
+#pragma omp target
+#pragma omp teams distribute parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp b/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
index 93017a8233ff..ce7f35b47959 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
@@ -2,17 +2,26 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
 
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized -fopenmp-version=51 -DOMP51
+
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized -fopenmp-version=51 -DOMP51
+
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute parallel for simd default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for simd default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute parallel for simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for simd default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute parallel for simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +30,20 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute parallel for simd default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute parallel for simd default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute parallel for simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#ifdef OpenMP51
+#pragma omp teams distribute parallel for default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++) {
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+  }
+#endif
+
   return 0;
 }

diff  --git a/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp b/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
index 2775210ae048..11f5d1cd1fc8 100644
--- a/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
+++ b/clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
@@ -1,18 +1,23 @@
-// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized -fopenmp-version=51
 
-// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized -fopenmp-version=51
 
 void foo();
 
+namespace {
+static int y = 0;
+}
+static int x = 0;
+
 int main(int argc, char **argv) {
   #pragma omp target
   #pragma omp teams distribute simd default // expected-error {{expected '(' after 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute simd default ( // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+#pragma omp teams distribute simd default( // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute simd default () // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute simd default() // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
   #pragma omp teams distribute simd default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
@@ -21,12 +26,22 @@ int main(int argc, char **argv) {
   #pragma omp teams distribute simd default (shared), default(shared) // expected-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'default' clause}}
   for (int i=0; i<200; i++) foo();
   #pragma omp target
-  #pragma omp teams distribute simd default (x) // expected-error {{expected 'none' or 'shared' in OpenMP clause 'default'}}
+#pragma omp teams distribute simd default(x) // expected-error {{expected 'none', 'shared' or 'firstprivate' in OpenMP clause 'default'}}
   for (int i=0; i<200; i++) foo();
 
   #pragma omp target
   #pragma omp teams distribute simd default(none) // expected-note {{explicit data sharing attribute requested here}}
   for (int i=0; i<200; i++) ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
 
+#pragma omp target
+#pragma omp teams distribute simd default(firstprivate) // expected-note {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++)
+    ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
+
+#pragma omp target
+#pragma omp teams distribute simd default(firstprivate) // expected-note {{explicit data sharing attribute requested here}}
+  for (int i = 0; i < 200; i++)
+    ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
+
   return 0;
 }

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index aeb4fd098d22..687908043a8d 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -103,9 +103,9 @@ TEST(IsExpandedFromMacro, ShouldMatchFromCommandLine) {
   StringRef input = R"cc(
     void Test() { FOUR_PLUS_FOUR; }
   )cc";
-  EXPECT_TRUE(matchesConditionally(input,
-                                   binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")),
-                                   true, {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
+  EXPECT_TRUE(matchesConditionally(
+      input, binaryOperator(isExpandedFromMacro("FOUR_PLUS_FOUR")), true,
+      {"-std=c++11", "-DFOUR_PLUS_FOUR=4+4"}));
 }
 
 TEST(IsExpandedFromMacro, ShouldNotMatchBeginOnly) {
@@ -143,31 +143,31 @@ TEST(IsExpandedFromMacro, ShouldNotMatchDifferentInstances) {
 }
 
 TEST(AllOf, AllOverloadsWork) {
-  const char Program[] =
-      "struct T { };"
-      "int f(int, T*, int, int);"
-      "void g(int x) { T t; f(x, &t, 3, 4); }";
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl())))))));
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl()))),
-                     hasArgument(1, hasType(pointsTo(
-                                        recordDecl(hasName("T")))))))));
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl()))),
-                     hasArgument(1, hasType(pointsTo(
-                                        recordDecl(hasName("T"))))),
-                     hasArgument(2, integerLiteral(equals(3)))))));
-  EXPECT_TRUE(matches(Program,
-      callExpr(allOf(callee(functionDecl(hasName("f"))),
-                     hasArgument(0, declRefExpr(to(varDecl()))),
-                     hasArgument(1, hasType(pointsTo(
-                                        recordDecl(hasName("T"))))),
-                     hasArgument(2, integerLiteral(equals(3))),
-                     hasArgument(3, integerLiteral(equals(4)))))));
+  const char Program[] = "struct T { };"
+                         "int f(int, T*, int, int);"
+                         "void g(int x) { T t; f(x, &t, 3, 4); }";
+  EXPECT_TRUE(matches(
+      Program, callExpr(allOf(callee(functionDecl(hasName("f"))),
+                              hasArgument(0, declRefExpr(to(varDecl())))))));
+  EXPECT_TRUE(matches(
+      Program,
+      callExpr(
+          allOf(callee(functionDecl(hasName("f"))),
+                hasArgument(0, declRefExpr(to(varDecl()))),
+                hasArgument(1, hasType(pointsTo(recordDecl(hasName("T")))))))));
+  EXPECT_TRUE(matches(
+      Program, callExpr(allOf(
+                   callee(functionDecl(hasName("f"))),
+                   hasArgument(0, declRefExpr(to(varDecl()))),
+                   hasArgument(1, hasType(pointsTo(recordDecl(hasName("T"))))),
+                   hasArgument(2, integerLiteral(equals(3)))))));
+  EXPECT_TRUE(matches(
+      Program, callExpr(allOf(
+                   callee(functionDecl(hasName("f"))),
+                   hasArgument(0, declRefExpr(to(varDecl()))),
+                   hasArgument(1, hasType(pointsTo(recordDecl(hasName("T"))))),
+                   hasArgument(2, integerLiteral(equals(3))),
+                   hasArgument(3, integerLiteral(equals(4)))))));
 }
 
 TEST(DeclarationMatcher, MatchHas) {
@@ -176,127 +176,103 @@ TEST(DeclarationMatcher, MatchHas) {
   EXPECT_TRUE(matches("class X {};", HasClassX));
 
   DeclarationMatcher YHasClassX =
-    recordDecl(hasName("Y"), has(recordDecl(hasName("X"))));
+      recordDecl(hasName("Y"), has(recordDecl(hasName("X"))));
   EXPECT_TRUE(matches("class Y { class X {}; };", YHasClassX));
   EXPECT_TRUE(notMatches("class X {};", YHasClassX));
-  EXPECT_TRUE(
-    notMatches("class Y { class Z { class X {}; }; };", YHasClassX));
+  EXPECT_TRUE(notMatches("class Y { class Z { class X {}; }; };", YHasClassX));
 }
 
 TEST(DeclarationMatcher, MatchHasRecursiveAllOf) {
   DeclarationMatcher Recursive =
-    recordDecl(
-      has(recordDecl(
-        has(recordDecl(hasName("X"))),
-        has(recordDecl(hasName("Y"))),
-        hasName("Z"))),
-      has(recordDecl(
-        has(recordDecl(hasName("A"))),
-        has(recordDecl(hasName("B"))),
-        hasName("C"))),
-      hasName("F"));
-
-  EXPECT_TRUE(matches(
-    "class F {"
-      "  class Z {"
-      "    class X {};"
-      "    class Y {};"
-      "  };"
-      "  class C {"
-      "    class A {};"
-      "    class B {};"
-      "  };"
-      "};", Recursive));
-
-  EXPECT_TRUE(matches(
-    "class F {"
-      "  class Z {"
-      "    class A {};"
-      "    class X {};"
-      "    class Y {};"
-      "  };"
-      "  class C {"
-      "    class X {};"
-      "    class A {};"
-      "    class B {};"
-      "  };"
-      "};", Recursive));
-
-  EXPECT_TRUE(matches(
-    "class O1 {"
-      "  class O2 {"
-      "    class F {"
-      "      class Z {"
-      "        class A {};"
-      "        class X {};"
-      "        class Y {};"
-      "      };"
-      "      class C {"
-      "        class X {};"
-      "        class A {};"
-      "        class B {};"
-      "      };"
-      "    };"
-      "  };"
-      "};", Recursive));
+      recordDecl(has(recordDecl(has(recordDecl(hasName("X"))),
+                                has(recordDecl(hasName("Y"))), hasName("Z"))),
+                 has(recordDecl(has(recordDecl(hasName("A"))),
+                                has(recordDecl(hasName("B"))), hasName("C"))),
+                 hasName("F"));
+
+  EXPECT_TRUE(matches("class F {"
+                      "  class Z {"
+                      "    class X {};"
+                      "    class Y {};"
+                      "  };"
+                      "  class C {"
+                      "    class A {};"
+                      "    class B {};"
+                      "  };"
+                      "};",
+                      Recursive));
+
+  EXPECT_TRUE(matches("class F {"
+                      "  class Z {"
+                      "    class A {};"
+                      "    class X {};"
+                      "    class Y {};"
+                      "  };"
+                      "  class C {"
+                      "    class X {};"
+                      "    class A {};"
+                      "    class B {};"
+                      "  };"
+                      "};",
+                      Recursive));
+
+  EXPECT_TRUE(matches("class O1 {"
+                      "  class O2 {"
+                      "    class F {"
+                      "      class Z {"
+                      "        class A {};"
+                      "        class X {};"
+                      "        class Y {};"
+                      "      };"
+                      "      class C {"
+                      "        class X {};"
+                      "        class A {};"
+                      "        class B {};"
+                      "      };"
+                      "    };"
+                      "  };"
+                      "};",
+                      Recursive));
 }
 
 TEST(DeclarationMatcher, MatchHasRecursiveAnyOf) {
-  DeclarationMatcher Recursive =
-    recordDecl(
-      anyOf(
-        has(recordDecl(
-          anyOf(
-            has(recordDecl(
-              hasName("X"))),
-            has(recordDecl(
-              hasName("Y"))),
-            hasName("Z")))),
-        has(recordDecl(
-          anyOf(
-            hasName("C"),
-            has(recordDecl(
-              hasName("A"))),
-            has(recordDecl(
-              hasName("B")))))),
-        hasName("F")));
+  DeclarationMatcher Recursive = recordDecl(
+      anyOf(has(recordDecl(anyOf(has(recordDecl(hasName("X"))),
+                                 has(recordDecl(hasName("Y"))), hasName("Z")))),
+            has(recordDecl(anyOf(hasName("C"), has(recordDecl(hasName("A"))),
+                                 has(recordDecl(hasName("B")))))),
+            hasName("F")));
 
   EXPECT_TRUE(matches("class F {};", Recursive));
   EXPECT_TRUE(matches("class Z {};", Recursive));
   EXPECT_TRUE(matches("class C {};", Recursive));
   EXPECT_TRUE(matches("class M { class N { class X {}; }; };", Recursive));
   EXPECT_TRUE(matches("class M { class N { class B {}; }; };", Recursive));
-  EXPECT_TRUE(
-    matches("class O1 { class O2 {"
-              "  class M { class N { class B {}; }; }; "
-              "}; };", Recursive));
+  EXPECT_TRUE(matches("class O1 { class O2 {"
+                      "  class M { class N { class B {}; }; }; "
+                      "}; };",
+                      Recursive));
 }
 
 TEST(DeclarationMatcher, MatchNot) {
   DeclarationMatcher NotClassX =
-    cxxRecordDecl(
-      isDerivedFrom("Y"),
-      unless(hasName("X")));
+      cxxRecordDecl(isDerivedFrom("Y"), unless(hasName("X")));
   EXPECT_TRUE(notMatches("", NotClassX));
   EXPECT_TRUE(notMatches("class Y {};", NotClassX));
   EXPECT_TRUE(matches("class Y {}; class Z : public Y {};", NotClassX));
   EXPECT_TRUE(notMatches("class Y {}; class X : public Y {};", NotClassX));
   EXPECT_TRUE(
-    notMatches("class Y {}; class Z {}; class X : public Y {};",
-               NotClassX));
+      notMatches("class Y {}; class Z {}; class X : public Y {};", NotClassX));
 
   DeclarationMatcher ClassXHasNotClassY =
-    recordDecl(
-      hasName("X"),
-      has(recordDecl(hasName("Z"))),
-      unless(
-        has(recordDecl(hasName("Y")))));
+      recordDecl(hasName("X"), has(recordDecl(hasName("Z"))),
+                 unless(has(recordDecl(hasName("Y")))));
   EXPECT_TRUE(matches("class X { class Z {}; };", ClassXHasNotClassY));
-  EXPECT_TRUE(notMatches("class X { class Y {}; class Z {}; };",
-                         ClassXHasNotClassY));
+  EXPECT_TRUE(
+      notMatches("class X { class Y {}; class Z {}; };", ClassXHasNotClassY));
 
   DeclarationMatcher NamedNotRecord =
-    namedDecl(hasName("Foo"), unless(recordDecl()));
+      namedDecl(hasName("Foo"), unless(recordDecl()));
   EXPECT_TRUE(matches("void Foo(){}", NamedNotRecord));
   EXPECT_TRUE(notMatches("struct Foo {};", NamedNotRecord));
 }
@@ -318,67 +294,61 @@ TEST(CastExpression, HasCastKind) {
 
 TEST(DeclarationMatcher, HasDescendant) {
   DeclarationMatcher ZDescendantClassX =
-    recordDecl(
-      hasDescendant(recordDecl(hasName("X"))),
-      hasName("Z"));
+      recordDecl(hasDescendant(recordDecl(hasName("X"))), hasName("Z"));
   EXPECT_TRUE(matches("class Z { class X {}; };", ZDescendantClassX));
   EXPECT_TRUE(
-    matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
+      matches("class Z { class Y { class X {}; }; };", ZDescendantClassX));
+  EXPECT_TRUE(matches("class Z { class A { class Y { class X {}; }; }; };",
+                      ZDescendantClassX));
   EXPECT_TRUE(
-    matches("class Z { class A { class Y { class X {}; }; }; };",
-            ZDescendantClassX));
-  EXPECT_TRUE(
-    matches("class Z { class A { class B { class Y { class X {}; }; }; }; };",
-            ZDescendantClassX));
+      matches("class Z { class A { class B { class Y { class X {}; }; }; }; };",
+              ZDescendantClassX));
   EXPECT_TRUE(notMatches("class Z {};", ZDescendantClassX));
 
-  DeclarationMatcher ZDescendantClassXHasClassY =
-    recordDecl(
-      hasDescendant(recordDecl(has(recordDecl(hasName("Y"))),
-                               hasName("X"))),
+  DeclarationMatcher ZDescendantClassXHasClassY = recordDecl(
+      hasDescendant(recordDecl(has(recordDecl(hasName("Y"))), hasName("X"))),
       hasName("Z"));
   EXPECT_TRUE(matches("class Z { class X { class Y {}; }; };",
                       ZDescendantClassXHasClassY));
   EXPECT_TRUE(
-    matches("class Z { class A { class B { class X { class Y {}; }; }; }; };",
-            ZDescendantClassXHasClassY));
-  EXPECT_TRUE(notMatches(
-    "class Z {"
-      "  class A {"
-      "    class B {"
-      "      class X {"
-      "        class C {"
-      "          class Y {};"
-      "        };"
-      "      };"
-      "    }; "
-      "  };"
-      "};", ZDescendantClassXHasClassY));
+      matches("class Z { class A { class B { class X { class Y {}; }; }; }; };",
+              ZDescendantClassXHasClassY));
+  EXPECT_TRUE(notMatches("class Z {"
+                         "  class A {"
+                         "    class B {"
+                         "      class X {"
+                         "        class C {"
+                         "          class Y {};"
+                         "        };"
+                         "      };"
+                         "    }; "
+                         "  };"
+                         "};",
+                         ZDescendantClassXHasClassY));
 
   DeclarationMatcher ZDescendantClassXDescendantClassY =
-    recordDecl(
-      hasDescendant(recordDecl(hasDescendant(recordDecl(hasName("Y"))),
-                               hasName("X"))),
-      hasName("Z"));
-  EXPECT_TRUE(
-    matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
-            ZDescendantClassXDescendantClassY));
-  EXPECT_TRUE(matches(
-    "class Z {"
-      "  class A {"
-      "    class X {"
-      "      class B {"
-      "        class Y {};"
-      "      };"
-      "      class Y {};"
-      "    };"
-      "  };"
-      "};", ZDescendantClassXDescendantClassY));
+      recordDecl(hasDescendant(recordDecl(
+                     hasDescendant(recordDecl(hasName("Y"))), hasName("X"))),
+                 hasName("Z"));
+  EXPECT_TRUE(
+      matches("class Z { class A { class X { class B { class Y {}; }; }; }; };",
+              ZDescendantClassXDescendantClassY));
+  EXPECT_TRUE(matches("class Z {"
+                      "  class A {"
+                      "    class X {"
+                      "      class B {"
+                      "        class Y {};"
+                      "      };"
+                      "      class Y {};"
+                      "    };"
+                      "  };"
+                      "};",
+                      ZDescendantClassXDescendantClassY));
 }
 
 TEST(DeclarationMatcher, HasDescendantMemoization) {
   DeclarationMatcher CannotMemoize =
-    decl(hasDescendant(typeLoc().bind("x")), has(decl()));
+      decl(hasDescendant(typeLoc().bind("x")), has(decl()));
   EXPECT_TRUE(matches("void f() { int i; }", CannotMemoize));
 }
 
@@ -401,39 +371,36 @@ TEST(DeclarationMatcher, HasAncestorMemoization) {
   // That node can't be memoized so we have to check for it before trying to put
   // it on the cache.
   DeclarationMatcher CannotMemoize = classTemplateSpecializationDecl(
-    hasAnyTemplateArgument(templateArgument().bind("targ")),
-    forEach(fieldDecl(hasAncestor(forStmt()))));
+      hasAnyTemplateArgument(templateArgument().bind("targ")),
+      forEach(fieldDecl(hasAncestor(forStmt()))));
 
   EXPECT_TRUE(notMatches("template  struct S;"
-                           "template <> struct S{ int i; int j; };",
+                         "template <> struct S{ int i; int j; };",
                          CannotMemoize));
 }
 
 TEST(DeclarationMatcher, HasAttr) {
   EXPECT_TRUE(matches("struct __attribute__((warn_unused)) X {};",
                       decl(hasAttr(clang::attr::WarnUnused))));
-  EXPECT_FALSE(matches("struct X {};",
-                       decl(hasAttr(clang::attr::WarnUnused))));
+  EXPECT_FALSE(matches("struct X {};", decl(hasAttr(clang::attr::WarnUnused))));
 }
 
-
 TEST(DeclarationMatcher, MatchAnyOf) {
   DeclarationMatcher YOrZDerivedFromX = cxxRecordDecl(
-    anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
+      anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
   EXPECT_TRUE(matches("class X {}; class Z : public X {};", YOrZDerivedFromX));
   EXPECT_TRUE(matches("class Y {};", YOrZDerivedFromX));
   EXPECT_TRUE(
-    notMatches("class X {}; class W : public X {};", YOrZDerivedFromX));
+      notMatches("class X {}; class W : public X {};", YOrZDerivedFromX));
   EXPECT_TRUE(notMatches("class Z {};", YOrZDerivedFromX));
 
   DeclarationMatcher XOrYOrZOrU =
-    recordDecl(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U")));
+      recordDecl(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U")));
   EXPECT_TRUE(matches("class X {};", XOrYOrZOrU));
   EXPECT_TRUE(notMatches("class V {};", XOrYOrZOrU));
 
-  DeclarationMatcher XOrYOrZOrUOrV =
-    recordDecl(anyOf(hasName("X"), hasName("Y"), hasName("Z"), hasName("U"),
-                     hasName("V")));
+  DeclarationMatcher XOrYOrZOrUOrV = recordDecl(anyOf(
+      hasName("X"), hasName("Y"), hasName("Z"), hasName("U"), hasName("V")));
   EXPECT_TRUE(matches("class X {};", XOrYOrZOrUOrV));
   EXPECT_TRUE(matches("class Y {};", XOrYOrZOrUOrV));
   EXPECT_TRUE(matches("class Z {};", XOrYOrZOrUOrV));
@@ -447,8 +414,8 @@ TEST(DeclarationMatcher, MatchAnyOf) {
   EXPECT_TRUE(notMatches("int F() { return 1; }", MixedTypes));
 
   EXPECT_TRUE(
-    matches("void f() try { } catch (int) { } catch (...) { }",
-            cxxCatchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
+      matches("void f() try { } catch (int) { } catch (...) { }",
+              cxxCatchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
 }
 
 TEST(DeclarationMatcher, ClassIsDerived) {
@@ -460,19 +427,17 @@ TEST(DeclarationMatcher, ClassIsDerived) {
   EXPECT_TRUE(notMatches("class Y;", IsDerivedFromX));
   EXPECT_TRUE(notMatches("", IsDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Y : Y, X {};",
-    IsDerivedFromX));
+                      IsDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Y : X, Y {};",
-    IsDerivedFromX));
+                      IsDerivedFromX));
 
-  DeclarationMatcher IsZDerivedFromX = cxxRecordDecl(hasName("Z"),
-    isDerivedFrom("X"));
-  EXPECT_TRUE(
-    matches(
-      "class X {};"
-      "template class Y : Y {};"
-      "template<> class Y<0> : X {};"
-      "class Z : Y<1> {};",
-      IsZDerivedFromX));
+  DeclarationMatcher IsZDerivedFromX =
+      cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+  EXPECT_TRUE(matches("class X {};"
+                      "template class Y : Y {};"
+                      "template<> class Y<0> : X {};"
+                      "class Z : Y<1> {};",
+                      IsZDerivedFromX));
 
   DeclarationMatcher IsDirectlyDerivedFromX =
       cxxRecordDecl(isDirectlyDerivedFrom("X"));
@@ -493,145 +458,138 @@ TEST(DeclarationMatcher, ClassIsDerived) {
   EXPECT_TRUE(notMatches("", IsAX));
 
   DeclarationMatcher ZIsDerivedFromX =
-    cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
+      cxxRecordDecl(hasName("Z"), isDerivedFrom("X"));
   DeclarationMatcher ZIsDirectlyDerivedFromX =
       cxxRecordDecl(hasName("Z"), isDirectlyDerivedFrom("X"));
   EXPECT_TRUE(
-    matches("class X {}; class Y : public X {}; class Z : public Y {};",
-            ZIsDerivedFromX));
+      matches("class X {}; class Y : public X {}; class Z : public Y {};",
+              ZIsDerivedFromX));
   EXPECT_TRUE(
       notMatches("class X {}; class Y : public X {}; class Z : public Y {};",
                  ZIsDirectlyDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {};"
-              "template class Y : public X {};"
-              "class Z : public Y {};", ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {};"
+                      "template class Y : public X {};"
+                      "class Z : public Y {};",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(notMatches("class X {};"
                          "template class Y : public X {};"
                          "class Z : public Y {};",
                          ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matches("class X {}; template class Z : public X {};",
                       ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X {}; "
+                      "template class Z : public X {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X {}; "
+                      "template class Z : public X {};",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class X {}; "
-              "template class Z : public X {};",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template class X {}; "
-              "template class Z : public X {};",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template class A { class Z : public X {}; };",
-               ZIsDerivedFromX));
+      notMatches("template class A { class Z : public X {}; };",
+                 ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class A { public: class Z : public X {}; }; "
-              "class X{}; void y() { A::Z z; }", ZIsDerivedFromX));
+      matches("template class A { public: class Z : public X {}; }; "
+              "class X{}; void y() { A::Z z; }",
+              ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template  class X {}; "
+      matches("template  class X {}; "
               "template class A { class Z : public X {}; };",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template class X> class A { "
-                 "  class Z : public X {}; };", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template class X> class A { "
-              "  public: class Z : public X {}; }; "
-              "template class X {}; void y() { A::Z z; }",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template class A { class Z : public X::D {}; };",
-               ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template class A { public: "
-              "  class Z : public X::D {}; }; "
-              "class Y { public: class X {}; typedef X D; }; "
-              "void y() { A::Z z; }", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; typedef X Y; class Z : public Y {};",
-            ZIsDerivedFromX));
+              ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("template class X> class A { "
+                         "  class Z : public X {}; };",
+                         ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class X> class A { "
+                      "  public: class Z : public X {}; }; "
+                      "template class X {}; void y() { A::Z z; }",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class Y { typedef typename T::U X; "
-              "  class Z : public X {}; };", ZIsDerivedFromX));
-  EXPECT_TRUE(matches("class X {}; class Z : public ::X {};",
+      notMatches("template class A { class Z : public X::D {}; };",
+                 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class A { public: "
+                      "  class Z : public X::D {}; }; "
+                      "class Y { public: class X {}; typedef X D; }; "
+                      "void y() { A::Z z; }",
                       ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; typedef X Y; class Z : public Y {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("template class Y { typedef typename T::U X; "
+                      "  class Z : public X {}; };",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; class Z : public ::X {};", ZIsDerivedFromX));
   EXPECT_TRUE(
-    notMatches("template class X {}; "
+      notMatches("template class X {}; "
                  "template class A { class Z : public X::D {}; };",
-               ZIsDerivedFromX));
+                 ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("template class X { public: typedef X D; }; "
+      matches("template class X { public: typedef X D; }; "
               "template class A { public: "
               "  class Z : public X::D {}; }; void y() { A::Z z; }",
-            ZIsDerivedFromX));
+              ZIsDerivedFromX));
   EXPECT_TRUE(
-    notMatches("template class A { class Z : public X::D::E {}; };",
-               ZIsDerivedFromX));
+      notMatches("template class A { class Z : public X::D::E {}; };",
+                 ZIsDerivedFromX));
   EXPECT_TRUE(
-    matches("class X {}; typedef X V; typedef V W; class Z : public W {};",
-            ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; class Y : public X {}; "
-              "typedef Y V; typedef V W; class Z : public W {};",
-            ZIsDerivedFromX));
+      matches("class X {}; typedef X V; typedef V W; class Z : public W {};",
+              ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; class Y : public X {}; "
+                      "typedef Y V; typedef V W; class Z : public W {};",
+                      ZIsDerivedFromX));
   EXPECT_TRUE(notMatches("class X {}; class Y : public X {}; "
                          "typedef Y V; typedef V W; class Z : public W {};",
                          ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(
-    matches("template class X {}; "
+      matches("template class X {}; "
               "template class A { class Z : public X {}; };",
-            ZIsDerivedFromX));
+              ZIsDerivedFromX));
   EXPECT_TRUE(
-    notMatches("template class D { typedef X A; typedef A B; "
+      notMatches("template class D { typedef X A; typedef A B; "
                  "  typedef B C; class Z : public C {}; };",
-               ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; typedef X A; typedef A B; "
-              "class Z : public B {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class X {}; typedef X A; typedef A B; typedef B C; "
-              "class Z : public C {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class U {}; typedef U X; typedef X V; "
-              "class Z : public V {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class Base {}; typedef Base X; "
-              "class Z : public Base {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class Base {}; typedef Base Base2; typedef Base2 X; "
-              "class Z : public Base {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("class Base {}; class Base2 {}; typedef Base2 X; "
-                 "class Z : public Base {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    matches("class A {}; typedef A X; typedef A Y; "
-              "class Z : public Y {};", ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template  class Z;"
-                 "template <> class Z {};"
-                 "template  class Z : public Z {};",
-               IsDerivedFromX));
-  EXPECT_TRUE(
-    matches("template  class X;"
-              "template <> class X {};"
-              "template  class X : public X {};",
-            IsDerivedFromX));
-  EXPECT_TRUE(matches(
-    "class X {};"
-      "template  class Z;"
-      "template <> class Z {};"
-      "template  class Z : public Z, public X {};",
-    ZIsDerivedFromX));
-  EXPECT_TRUE(
-    notMatches("template struct X;"
+                 ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; typedef X A; typedef A B; "
+                      "class Z : public B {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class X {}; typedef X A; typedef A B; typedef B C; "
+                      "class Z : public C {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class U {}; typedef U X; typedef X V; "
+                      "class Z : public V {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class Base {}; typedef Base X; "
+                      "class Z : public Base {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class Base {}; typedef Base Base2; typedef Base2 X; "
+                      "class Z : public Base {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("class Base {}; class Base2 {}; typedef Base2 X; "
+                         "class Z : public Base {};",
+                         ZIsDerivedFromX));
+  EXPECT_TRUE(matches("class A {}; typedef A X; typedef A Y; "
+                      "class Z : public Y {};",
+                      ZIsDerivedFromX));
+  EXPECT_TRUE(notMatches("template  class Z;"
+                         "template <> class Z {};"
+                         "template  class Z : public Z {};",
+                         IsDerivedFromX));
+  EXPECT_TRUE(matches("template  class X;"
+                      "template <> class X {};"
+                      "template  class X : public X {};",
+                      IsDerivedFromX));
+  EXPECT_TRUE(
+      matches("class X {};"
+              "template  class Z;"
+              "template <> class Z {};"
+              "template  class Z : public Z, public X {};",
+              ZIsDerivedFromX));
+  EXPECT_TRUE(
+      notMatches("template struct X;"
                  "template struct X : public X {};",
-               cxxRecordDecl(isDerivedFrom(recordDecl(hasName("Some"))))));
+                 cxxRecordDecl(isDerivedFrom(recordDecl(hasName("Some"))))));
   EXPECT_TRUE(matches(
-    "struct A {};"
+      "struct A {};"
       "template struct X;"
       "template struct X : public X {};"
       "template<> struct X<0> : public A {};"
       "struct B : public X<42> {};",
-    cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"))))));
+      cxxRecordDecl(hasName("B"), isDerivedFrom(recordDecl(hasName("A"))))));
   EXPECT_TRUE(notMatches(
       "struct A {};"
       "template struct X;"
@@ -645,7 +603,7 @@ TEST(DeclarationMatcher, ClassIsDerived) {
   // get rid of the Variable(...) matching and match the right template
   // declarations directly.
   const char *RecursiveTemplateOneParameter =
-    "class Base1 {}; class Base2 {};"
+      "class Base1 {}; class Base2 {};"
       "template  class Z;"
       "template <> class Z : public Base1 {};"
       "template <> class Z : public Base2 {};"
@@ -654,21 +612,21 @@ TEST(DeclarationMatcher, ClassIsDerived) {
       "template  class Z : public Z, public Z {};"
       "void f() { Z z_float; Z z_double; Z z_char; }";
   EXPECT_TRUE(matches(
-    RecursiveTemplateOneParameter,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
+      RecursiveTemplateOneParameter,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
   EXPECT_TRUE(notMatches(
-    RecursiveTemplateOneParameter,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
-  EXPECT_TRUE(matches(
-    RecursiveTemplateOneParameter,
-    varDecl(hasName("z_char"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1"),
-                                                 isDerivedFrom("Base2")))))));
+      RecursiveTemplateOneParameter,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
+  EXPECT_TRUE(
+      matches(RecursiveTemplateOneParameter,
+              varDecl(hasName("z_char"),
+                      hasInitializer(hasType(cxxRecordDecl(
+                          isDerivedFrom("Base1"), isDerivedFrom("Base2")))))));
 
   const char *RecursiveTemplateTwoParameters =
-    "class Base1 {}; class Base2 {};"
+      "class Base1 {}; class Base2 {};"
       "template  class Z;"
       "template  class Z : public Base1 {};"
       "template  class Z : public Base2 {};"
@@ -679,34 +637,31 @@ TEST(DeclarationMatcher, ClassIsDerived) {
       "void f() { Z z_float; Z z_double; "
       "           Z z_char; }";
   EXPECT_TRUE(matches(
-    RecursiveTemplateTwoParameters,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
-  EXPECT_TRUE(notMatches(
-    RecursiveTemplateTwoParameters,
-    varDecl(hasName("z_float"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
-  EXPECT_TRUE(matches(
-    RecursiveTemplateTwoParameters,
-    varDecl(hasName("z_char"),
-            hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1"),
-                                                 isDerivedFrom("Base2")))))));
-  EXPECT_TRUE(matches(
-    "namespace ns { class X {}; class Y : public X {}; }",
-    cxxRecordDecl(isDerivedFrom("::ns::X"))));
+      RecursiveTemplateTwoParameters,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base1")))))));
   EXPECT_TRUE(notMatches(
-    "class X {}; class Y : public X {};",
-    cxxRecordDecl(isDerivedFrom("::ns::X"))));
+      RecursiveTemplateTwoParameters,
+      varDecl(hasName("z_float"),
+              hasInitializer(hasType(cxxRecordDecl(isDerivedFrom("Base2")))))));
+  EXPECT_TRUE(
+      matches(RecursiveTemplateTwoParameters,
+              varDecl(hasName("z_char"),
+                      hasInitializer(hasType(cxxRecordDecl(
+                          isDerivedFrom("Base1"), isDerivedFrom("Base2")))))));
+  EXPECT_TRUE(matches("namespace ns { class X {}; class Y : public X {}; }",
+                      cxxRecordDecl(isDerivedFrom("::ns::X"))));
+  EXPECT_TRUE(notMatches("class X {}; class Y : public X {};",
+                         cxxRecordDecl(isDerivedFrom("::ns::X"))));
 
   EXPECT_TRUE(matches(
-    "class X {}; class Y : public X {};",
-    cxxRecordDecl(isDerivedFrom(recordDecl(hasName("X")).bind("test")))));
+      "class X {}; class Y : public X {};",
+      cxxRecordDecl(isDerivedFrom(recordDecl(hasName("X")).bind("test")))));
 
-  EXPECT_TRUE(matches(
-    "template class X {};"
-      "template using Z = X;"
-      "template  class Y : Z {};",
-    cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
+  EXPECT_TRUE(matches("template class X {};"
+                      "template using Z = X;"
+                      "template  class Y : Z {};",
+                      cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"))))));
 }
 
 TEST(DeclarationMatcher, IsDerivedFromEmptyName) {
@@ -737,24 +692,24 @@ TEST(DeclarationMatcher, ObjCClassIsDerived) {
 
   DeclarationMatcher IsDirectlyDerivedFromX =
       objcInterfaceDecl(isDirectlyDerivedFrom("X"));
-  EXPECT_TRUE(
-      matchesObjC("@interface X @end @interface Y : X @end", IsDirectlyDerivedFromX));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end",
+                          IsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface X @end @interface Y<__covariant ObjectType> : X @end",
       IsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface X @end @compatibility_alias Y X; @interface Z : Y @end",
       IsDirectlyDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface X @end typedef X Y; @interface Z : Y @end",
-      IsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface X @end typedef X Y; @interface Z : Y @end",
+                  IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@interface X @end", IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@class X;", IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@class Y;", IsDirectlyDerivedFromX));
   EXPECT_TRUE(notMatchesObjC("@interface X @end @compatibility_alias Y X;",
                              IsDirectlyDerivedFromX));
-  EXPECT_TRUE(notMatchesObjC("@interface X @end typedef X Y;",
-                             IsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      notMatchesObjC("@interface X @end typedef X Y;", IsDirectlyDerivedFromX));
 
   DeclarationMatcher IsAX = objcInterfaceDecl(isSameOrDerivedFrom("X"));
   EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end", IsAX));
@@ -775,9 +730,9 @@ TEST(DeclarationMatcher, ObjCClassIsDerived) {
                           ZIsDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface X @end typedef X Y; @interface Z : Y @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface X @end typedef X Y; @interface Z : Y @end",
-      ZIsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface X @end typedef X Y; @interface Z : Y @end",
+                  ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface A @end typedef A X; typedef A Y; @interface Z : Y @end",
       ZIsDerivedFromX));
@@ -798,27 +753,33 @@ TEST(DeclarationMatcher, ObjCClassIsDerived) {
       ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface A @end @compatibility_alias X A; @compatibility_alias Y A;"
-      "@interface Z : Y @end", ZIsDerivedFromX));
+      "@interface Z : Y @end",
+      ZIsDerivedFromX));
   EXPECT_TRUE(matchesObjC(
       "@interface A @end @compatibility_alias X A; @compatibility_alias Y A;"
-      "@interface Z : Y @end", ZIsDirectlyDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface Y @end typedef Y X; @interface Z : X @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface Y @end typedef Y X; @interface Z : X @end",
+      "@interface Z : Y @end",
       ZIsDirectlyDerivedFromX));
   EXPECT_TRUE(matchesObjC(
-      "@interface A @end @compatibility_alias Y A; typedef Y X;"
-      "@interface Z : A @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface A @end @compatibility_alias Y A; typedef Y X;"
-      "@interface Z : A @end", ZIsDirectlyDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface A @end typedef A Y; @compatibility_alias X Y;"
-      "@interface Z : A @end", ZIsDerivedFromX));
-  EXPECT_TRUE(matchesObjC(
-      "@interface A @end typedef A Y; @compatibility_alias X Y;"
-      "@interface Z : A @end", ZIsDirectlyDerivedFromX));
+      "@interface Y @end typedef Y X; @interface Z : X @end", ZIsDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface Y @end typedef Y X; @interface Z : X @end",
+                  ZIsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end @compatibility_alias Y A; typedef Y X;"
+                  "@interface Z : A @end",
+                  ZIsDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end @compatibility_alias Y A; typedef Y X;"
+                  "@interface Z : A @end",
+                  ZIsDirectlyDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end typedef A Y; @compatibility_alias X Y;"
+                  "@interface Z : A @end",
+                  ZIsDerivedFromX));
+  EXPECT_TRUE(
+      matchesObjC("@interface A @end typedef A Y; @compatibility_alias X Y;"
+                  "@interface Z : A @end",
+                  ZIsDirectlyDerivedFromX));
 }
 
 TEST(DeclarationMatcher, IsLambda) {
@@ -830,42 +791,41 @@ TEST(DeclarationMatcher, IsLambda) {
 TEST(Matcher, BindMatchedNodes) {
   DeclarationMatcher ClassX = has(recordDecl(hasName("::X")).bind("x"));
 
-  EXPECT_TRUE(matchAndVerifyResultTrue("class X {};",
-                                       ClassX, std::make_unique>("x")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "class X {};", ClassX,
+      std::make_unique>("x")));
 
-  EXPECT_TRUE(matchAndVerifyResultFalse("class X {};",
-                                        ClassX, std::make_unique>("other-id")));
+  EXPECT_TRUE(matchAndVerifyResultFalse(
+      "class X {};", ClassX,
+      std::make_unique>("other-id")));
 
   TypeMatcher TypeAHasClassB = hasDeclaration(
-    recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b"))));
+      recordDecl(hasName("A"), has(recordDecl(hasName("B")).bind("b"))));
 
-  EXPECT_TRUE(matchAndVerifyResultTrue("class A { public: A *a; class B {}; };",
-                                       TypeAHasClassB,
-                                       std::make_unique>("b")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "class A { public: A *a; class B {}; };", TypeAHasClassB,
+      std::make_unique>("b")));
 
   StatementMatcher MethodX =
-    callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x");
+      callExpr(callee(cxxMethodDecl(hasName("x")))).bind("x");
 
-  EXPECT_TRUE(matchAndVerifyResultTrue("class A { void x() { x(); } };",
-                                       MethodX,
-                                       std::make_unique>("x")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "class A { void x() { x(); } };", MethodX,
+      std::make_unique>("x")));
 }
 
 TEST(Matcher, BindTheSameNameInAlternatives) {
   StatementMatcher matcher = anyOf(
-    binaryOperator(hasOperatorName("+"),
-                   hasLHS(expr().bind("x")),
-                   hasRHS(integerLiteral(equals(0)))),
-    binaryOperator(hasOperatorName("+"),
-                   hasLHS(integerLiteral(equals(0))),
-                   hasRHS(expr().bind("x"))));
+      binaryOperator(hasOperatorName("+"), hasLHS(expr().bind("x")),
+                     hasRHS(integerLiteral(equals(0)))),
+      binaryOperator(hasOperatorName("+"), hasLHS(integerLiteral(equals(0))),
+                     hasRHS(expr().bind("x"))));
 
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    // The first branch of the matcher binds x to 0 but then fails.
-    // The second branch binds x to f() and succeeds.
-    "int f() { return 0 + f(); }",
-    matcher,
-    std::make_unique>("x")));
+      // The first branch of the matcher binds x to 0 but then fails.
+      // The second branch binds x to f() and succeeds.
+      "int f() { return 0 + f(); }", matcher,
+      std::make_unique>("x")));
 }
 
 TEST(Matcher, BindsIDForMemoizedResults) {
@@ -873,48 +833,48 @@ TEST(Matcher, BindsIDForMemoizedResults) {
   // kick in.
   DeclarationMatcher ClassX = recordDecl(hasName("X")).bind("x");
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { class B { class X {}; }; };",
-    DeclarationMatcher(anyOf(
-      recordDecl(hasName("A"), hasDescendant(ClassX)),
-      recordDecl(hasName("B"), hasDescendant(ClassX)))),
-    std::make_unique>("x", 2)));
+      "class A { class B { class X {}; }; };",
+      DeclarationMatcher(
+          anyOf(recordDecl(hasName("A"), hasDescendant(ClassX)),
+                recordDecl(hasName("B"), hasDescendant(ClassX)))),
+      std::make_unique>("x", 2)));
 }
 
 TEST(HasType, MatchesAsString) {
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
-            cxxMemberCallExpr(on(hasType(asString("class Y *"))))));
+      matches("class Y { public: void x(); }; void z() {Y* y; y->x(); }",
+              cxxMemberCallExpr(on(hasType(asString("class Y *"))))));
   EXPECT_TRUE(
-    matches("class X { void x(int x) {} };",
-            cxxMethodDecl(hasParameter(0, hasType(asString("int"))))));
+      matches("class X { void x(int x) {} };",
+              cxxMethodDecl(hasParameter(0, hasType(asString("int"))))));
   EXPECT_TRUE(matches("namespace ns { struct A {}; }  struct B { ns::A a; };",
                       fieldDecl(hasType(asString("ns::A")))));
-  EXPECT_TRUE(matches("namespace { struct A {}; }  struct B { A a; };",
-                      fieldDecl(hasType(asString("struct (anonymous namespace)::A")))));
+  EXPECT_TRUE(
+      matches("namespace { struct A {}; }  struct B { A a; };",
+              fieldDecl(hasType(asString("struct (anonymous namespace)::A")))));
 }
 
 TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
   StatementMatcher OpCallAndAnd =
-    cxxOperatorCallExpr(hasOverloadedOperatorName("&&"));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("&&"));
   EXPECT_TRUE(matches("class Y { }; "
-                        "bool operator&&(Y x, Y y) { return true; }; "
-                        "Y a; Y b; bool c = a && b;", OpCallAndAnd));
+                      "bool operator&&(Y x, Y y) { return true; }; "
+                      "Y a; Y b; bool c = a && b;",
+                      OpCallAndAnd));
   StatementMatcher OpCallLessLess =
-    cxxOperatorCallExpr(hasOverloadedOperatorName("<<"));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("<<"));
   EXPECT_TRUE(notMatches("class Y { }; "
-                           "bool operator&&(Y x, Y y) { return true; }; "
-                           "Y a; Y b; bool c = a && b;",
+                         "bool operator&&(Y x, Y y) { return true; }; "
+                         "Y a; Y b; bool c = a && b;",
                          OpCallLessLess));
   StatementMatcher OpStarCall =
-    cxxOperatorCallExpr(hasOverloadedOperatorName("*"));
-  EXPECT_TRUE(matches("class Y; int operator*(Y &); void f(Y &y) { *y; }",
-                      OpStarCall));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("*"));
+  EXPECT_TRUE(
+      matches("class Y; int operator*(Y &); void f(Y &y) { *y; }", OpStarCall));
   DeclarationMatcher ClassWithOpStar =
-    cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")));
-  EXPECT_TRUE(matches("class Y { int operator*(); };",
-                      ClassWithOpStar));
-  EXPECT_TRUE(notMatches("class Y { void myOperator(); };",
-                         ClassWithOpStar)) ;
+      cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")));
+  EXPECT_TRUE(matches("class Y { int operator*(); };", ClassWithOpStar));
+  EXPECT_TRUE(notMatches("class Y { void myOperator(); };", ClassWithOpStar));
   DeclarationMatcher AnyOpStar = functionDecl(hasOverloadedOperatorName("*"));
   EXPECT_TRUE(matches("class Y; int operator*(Y &);", AnyOpStar));
   EXPECT_TRUE(matches("class Y { int operator*(); };", AnyOpStar));
@@ -926,23 +886,22 @@ TEST(Matcher, HasOperatorNameForOverloadedOperatorCall) {
   EXPECT_TRUE(matches("class Y { Y operator&&(Y &); };", AnyAndOp));
 }
 
-
 TEST(Matcher, NestedOverloadedOperatorCalls) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class Y { }; "
+      "class Y { }; "
       "Y& operator&&(Y& x, Y& y) { return x; }; "
       "Y a; Y b; Y c; Y d = a && b && c;",
-    cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
-    std::make_unique>("x", 2)));
+      cxxOperatorCallExpr(hasOverloadedOperatorName("&&")).bind("x"),
+      std::make_unique>("x", 2)));
   EXPECT_TRUE(matches("class Y { }; "
-                        "Y& operator&&(Y& x, Y& y) { return x; }; "
-                        "Y a; Y b; Y c; Y d = a && b && c;",
+                      "Y& operator&&(Y& x, Y& y) { return x; }; "
+                      "Y a; Y b; Y c; Y d = a && b && c;",
                       cxxOperatorCallExpr(hasParent(cxxOperatorCallExpr()))));
   EXPECT_TRUE(
-    matches("class Y { }; "
+      matches("class Y { }; "
               "Y& operator&&(Y& x, Y& y) { return x; }; "
               "Y a; Y b; Y c; Y d = a && b && c;",
-            cxxOperatorCallExpr(hasDescendant(cxxOperatorCallExpr()))));
+              cxxOperatorCallExpr(hasDescendant(cxxOperatorCallExpr()))));
 }
 
 TEST(Matcher, VarDecl_Storage) {
@@ -971,9 +930,9 @@ TEST(Matcher, VarDecl_StorageDuration) {
 
   EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration())));
   EXPECT_TRUE(
-    notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration())));
+      notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration())));
   EXPECT_TRUE(
-    notMatches(T, varDecl(hasName("a"), hasAutomaticStorageDuration())));
+      notMatches(T, varDecl(hasName("a"), hasAutomaticStorageDuration())));
 
   EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration())));
   EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration())));
@@ -991,48 +950,48 @@ TEST(Matcher, VarDecl_StorageDuration) {
 }
 
 TEST(Matcher, FindsVarDeclInFunctionParameter) {
-  EXPECT_TRUE(matches(
-    "void f(int i) {}",
-    varDecl(hasName("i"))));
+  EXPECT_TRUE(matches("void f(int i) {}", varDecl(hasName("i"))));
 }
 
 TEST(UnaryExpressionOrTypeTraitExpression, MatchesCorrectType) {
-  EXPECT_TRUE(matches("void x() { int a = sizeof(a); }", sizeOfExpr(
-    hasArgumentOfType(asString("int")))));
-  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }", sizeOfExpr(
-    hasArgumentOfType(asString("float")))));
+  EXPECT_TRUE(matches("void x() { int a = sizeof(a); }",
+                      sizeOfExpr(hasArgumentOfType(asString("int")))));
+  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
+                         sizeOfExpr(hasArgumentOfType(asString("float")))));
   EXPECT_TRUE(matches(
-    "struct A {}; void x() { A a; int b = sizeof(a); }",
-    sizeOfExpr(hasArgumentOfType(hasDeclaration(recordDecl(hasName("A")))))));
-  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }", sizeOfExpr(
-    hasArgumentOfType(hasDeclaration(recordDecl(hasName("string")))))));
+      "struct A {}; void x() { A a; int b = sizeof(a); }",
+      sizeOfExpr(hasArgumentOfType(hasDeclaration(recordDecl(hasName("A")))))));
+  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
+                         sizeOfExpr(hasArgumentOfType(
+                             hasDeclaration(recordDecl(hasName("string")))))));
 }
 
 TEST(IsInteger, MatchesIntegers) {
   EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isInteger()))));
-  EXPECT_TRUE(matches(
-    "long long i = 0; void f(long long) { }; void g() {f(i);}",
-    callExpr(hasArgument(0, declRefExpr(
-      to(varDecl(hasType(isInteger()))))))));
+  EXPECT_TRUE(
+      matches("long long i = 0; void f(long long) { }; void g() {f(i);}",
+              callExpr(hasArgument(
+                  0, declRefExpr(to(varDecl(hasType(isInteger()))))))));
 }
 
 TEST(IsInteger, ReportsNoFalsePositives) {
   EXPECT_TRUE(notMatches("int *i;", varDecl(hasType(isInteger()))));
-  EXPECT_TRUE(notMatches("struct T {}; T t; void f(T *) { }; void g() {f(&t);}",
-                         callExpr(hasArgument(0, declRefExpr(
-                           to(varDecl(hasType(isInteger()))))))));
+  EXPECT_TRUE(
+      notMatches("struct T {}; T t; void f(T *) { }; void g() {f(&t);}",
+                 callExpr(hasArgument(
+                     0, declRefExpr(to(varDecl(hasType(isInteger()))))))));
 }
 
 TEST(IsSignedInteger, MatchesSignedIntegers) {
   EXPECT_TRUE(matches("int i = 0;", varDecl(hasType(isSignedInteger()))));
-  EXPECT_TRUE(notMatches("unsigned i = 0;",
-                         varDecl(hasType(isSignedInteger()))));
+  EXPECT_TRUE(
+      notMatches("unsigned i = 0;", varDecl(hasType(isSignedInteger()))));
 }
 
 TEST(IsUnsignedInteger, MatchesUnsignedIntegers) {
   EXPECT_TRUE(notMatches("int i = 0;", varDecl(hasType(isUnsignedInteger()))));
-  EXPECT_TRUE(matches("unsigned i = 0;",
-                      varDecl(hasType(isUnsignedInteger()))));
+  EXPECT_TRUE(
+      matches("unsigned i = 0;", varDecl(hasType(isUnsignedInteger()))));
 }
 
 TEST(IsAnyPointer, MatchesPointers) {
@@ -1059,8 +1018,8 @@ TEST(IsAnyCharacter, ReportsNoFalsePositives) {
 TEST(IsArrow, MatchesMemberVariablesViaArrow) {
   EXPECT_TRUE(matches("class Y { void x() { this->y; } int y; };",
                       memberExpr(isArrow())));
-  EXPECT_TRUE(matches("class Y { void x() { y; } int y; };",
-                      memberExpr(isArrow())));
+  EXPECT_TRUE(
+      matches("class Y { void x() { y; } int y; };", memberExpr(isArrow())));
   EXPECT_TRUE(notMatches("class Y { void x() { (*this).y; } int y; };",
                          memberExpr(isArrow())));
   EXPECT_TRUE(matches("template  class Y { void x() { this->m; } };",
@@ -1080,10 +1039,9 @@ TEST(IsArrow, MatchesStaticMemberVariablesViaArrow) {
 }
 
 TEST(IsArrow, MatchesMemberCallsViaArrow) {
-  EXPECT_TRUE(matches("class Y { void x() { this->x(); } };",
-                      memberExpr(isArrow())));
-  EXPECT_TRUE(matches("class Y { void x() { x(); } };",
-                      memberExpr(isArrow())));
+  EXPECT_TRUE(
+      matches("class Y { void x() { this->x(); } };", memberExpr(isArrow())));
+  EXPECT_TRUE(matches("class Y { void x() { x(); } };", memberExpr(isArrow())));
   EXPECT_TRUE(notMatches("class Y { void x() { Y y; y.x(); } };",
                          memberExpr(isArrow())));
   EXPECT_TRUE(
@@ -1128,20 +1086,18 @@ TEST(Matcher, ParameterCount) {
 }
 
 TEST(Matcher, References) {
-  DeclarationMatcher ReferenceClassX = varDecl(
-    hasType(references(recordDecl(hasName("X")))));
-  EXPECT_TRUE(matches("class X {}; void y(X y) { X &x = y; }",
-                      ReferenceClassX));
+  DeclarationMatcher ReferenceClassX =
+      varDecl(hasType(references(recordDecl(hasName("X")))));
   EXPECT_TRUE(
-    matches("class X {}; void y(X y) { const X &x = y; }", ReferenceClassX));
+      matches("class X {}; void y(X y) { X &x = y; }", ReferenceClassX));
+  EXPECT_TRUE(
+      matches("class X {}; void y(X y) { const X &x = y; }", ReferenceClassX));
   // The match here is on the implicit copy constructor code for
   // class X, not on code 'X x = y'.
+  EXPECT_TRUE(matches("class X {}; void y(X y) { X x = y; }", ReferenceClassX));
+  EXPECT_TRUE(notMatches("class X {}; extern X x;", ReferenceClassX));
   EXPECT_TRUE(
-    matches("class X {}; void y(X y) { X x = y; }", ReferenceClassX));
-  EXPECT_TRUE(
-    notMatches("class X {}; extern X x;", ReferenceClassX));
-  EXPECT_TRUE(
-    notMatches("class X {}; void y(X *y) { X *&x = y; }", ReferenceClassX));
+      notMatches("class X {}; void y(X *y) { X *&x = y; }", ReferenceClassX));
 }
 
 TEST(QualType, hasLocalQualifiers) {
@@ -1149,16 +1105,15 @@ TEST(QualType, hasLocalQualifiers) {
                          varDecl(hasType(hasLocalQualifiers()))));
   EXPECT_TRUE(matches("int *const j = nullptr;",
                       varDecl(hasType(hasLocalQualifiers()))));
-  EXPECT_TRUE(matches("int *volatile k;",
-                      varDecl(hasType(hasLocalQualifiers()))));
-  EXPECT_TRUE(notMatches("int m;",
-                         varDecl(hasType(hasLocalQualifiers()))));
+  EXPECT_TRUE(
+      matches("int *volatile k;", varDecl(hasType(hasLocalQualifiers()))));
+  EXPECT_TRUE(notMatches("int m;", varDecl(hasType(hasLocalQualifiers()))));
 }
 
 TEST(IsExternC, MatchesExternCFunctionDeclarations) {
   EXPECT_TRUE(matches("extern \"C\" void f() {}", functionDecl(isExternC())));
-  EXPECT_TRUE(matches("extern \"C\" { void f() {} }",
-                      functionDecl(isExternC())));
+  EXPECT_TRUE(
+      matches("extern \"C\" { void f() {} }", functionDecl(isExternC())));
   EXPECT_TRUE(notMatches("void f() {}", functionDecl(isExternC())));
 }
 
@@ -1186,7 +1141,7 @@ TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
 
 TEST(IsDeleted, MatchesDeletedFunctionDeclarations) {
   EXPECT_TRUE(
-    notMatches("void Func();", functionDecl(hasName("Func"), isDeleted())));
+      notMatches("void Func();", functionDecl(hasName("Func"), isDeleted())));
   EXPECT_TRUE(matches("void Func() = delete;",
                       functionDecl(hasName("Func"), isDeleted())));
 }
@@ -1195,14 +1150,15 @@ TEST(IsNoThrow, MatchesNoThrowFunctionDeclarations) {
   EXPECT_TRUE(notMatches("void f();", functionDecl(isNoThrow())));
   EXPECT_TRUE(notMatches("void f() throw(int);", functionDecl(isNoThrow())));
   EXPECT_TRUE(
-    notMatches("void f() noexcept(false);", functionDecl(isNoThrow())));
+      notMatches("void f() noexcept(false);", functionDecl(isNoThrow())));
   EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow())));
   EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow())));
 
   EXPECT_TRUE(notMatches("void f();", functionProtoType(isNoThrow())));
-  EXPECT_TRUE(notMatches("void f() throw(int);", functionProtoType(isNoThrow())));
   EXPECT_TRUE(
-    notMatches("void f() noexcept(false);", functionProtoType(isNoThrow())));
+      notMatches("void f() throw(int);", functionProtoType(isNoThrow())));
+  EXPECT_TRUE(
+      notMatches("void f() noexcept(false);", functionProtoType(isNoThrow())));
   EXPECT_TRUE(matches("void f() throw();", functionProtoType(isNoThrow())));
   EXPECT_TRUE(matches("void f() noexcept;", functionProtoType(isNoThrow())));
 }
@@ -1249,41 +1205,41 @@ TEST(hasInitStatement, MatchesRangeForInitializers) {
 
 TEST(TemplateArgumentCountIs, Matches) {
   EXPECT_TRUE(
-    matches("template struct C {}; C c;",
-            classTemplateSpecializationDecl(templateArgumentCountIs(1))));
+      matches("template struct C {}; C c;",
+              classTemplateSpecializationDecl(templateArgumentCountIs(1))));
   EXPECT_TRUE(
-    notMatches("template struct C {}; C c;",
-               classTemplateSpecializationDecl(templateArgumentCountIs(2))));
+      notMatches("template struct C {}; C c;",
+                 classTemplateSpecializationDecl(templateArgumentCountIs(2))));
 
   EXPECT_TRUE(matches("template struct C {}; C c;",
                       templateSpecializationType(templateArgumentCountIs(1))));
   EXPECT_TRUE(
-    notMatches("template struct C {}; C c;",
-               templateSpecializationType(templateArgumentCountIs(2))));
+      notMatches("template struct C {}; C c;",
+                 templateSpecializationType(templateArgumentCountIs(2))));
 }
 
 TEST(IsIntegral, Matches) {
-  EXPECT_TRUE(matches("template struct C {}; C<42> c;",
-                      classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(isIntegral()))));
+  EXPECT_TRUE(matches(
+      "template struct C {}; C<42> c;",
+      classTemplateSpecializationDecl(hasAnyTemplateArgument(isIntegral()))));
   EXPECT_TRUE(notMatches("template struct C {}; C c;",
                          classTemplateSpecializationDecl(hasAnyTemplateArgument(
-                           templateArgument(isIntegral())))));
+                             templateArgument(isIntegral())))));
 }
 
 TEST(EqualsIntegralValue, Matches) {
   EXPECT_TRUE(matches("template struct C {}; C<42> c;",
                       classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(equalsIntegralValue("42")))));
+                          hasAnyTemplateArgument(equalsIntegralValue("42")))));
   EXPECT_TRUE(matches("template struct C {}; C<-42> c;",
                       classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(equalsIntegralValue("-42")))));
+                          hasAnyTemplateArgument(equalsIntegralValue("-42")))));
   EXPECT_TRUE(matches("template struct C {}; C<-0042> c;",
                       classTemplateSpecializationDecl(
-                        hasAnyTemplateArgument(equalsIntegralValue("-34")))));
+                          hasAnyTemplateArgument(equalsIntegralValue("-34")))));
   EXPECT_TRUE(notMatches("template struct C {}; C<42> c;",
                          classTemplateSpecializationDecl(hasAnyTemplateArgument(
-                           equalsIntegralValue("0042")))));
+                             equalsIntegralValue("0042")))));
 }
 
 TEST(Matcher, MatchesAccessSpecDecls) {
@@ -1304,7 +1260,7 @@ TEST(Matcher, MatchesFinal) {
                       cxxMethodDecl(isFinal())));
   EXPECT_TRUE(notMatches("class X {};", cxxRecordDecl(isFinal())));
   EXPECT_TRUE(
-    notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal())));
+      notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal())));
 }
 
 TEST(Matcher, MatchesVirtualMethod) {
@@ -1315,12 +1271,12 @@ TEST(Matcher, MatchesVirtualMethod) {
 
 TEST(Matcher, MatchesVirtualAsWrittenMethod) {
   EXPECT_TRUE(matches("class A { virtual int f(); };"
-                        "class B : public A { int f(); };",
+                      "class B : public A { int f(); };",
                       cxxMethodDecl(isVirtualAsWritten(), hasName("::A::f"))));
   EXPECT_TRUE(
-    notMatches("class A { virtual int f(); };"
+      notMatches("class A { virtual int f(); };"
                  "class B : public A { int f(); };",
-               cxxMethodDecl(isVirtualAsWritten(), hasName("::B::f"))));
+                 cxxMethodDecl(isVirtualAsWritten(), hasName("::B::f"))));
 }
 
 TEST(Matcher, MatchesPureMethod) {
@@ -1358,26 +1314,26 @@ TEST(Matcher, MatchesMoveAssignmentOperator) {
 
 TEST(Matcher, MatchesConstMethod) {
   EXPECT_TRUE(
-    matches("struct A { void foo() const; };", cxxMethodDecl(isConst())));
+      matches("struct A { void foo() const; };", cxxMethodDecl(isConst())));
   EXPECT_TRUE(
-    notMatches("struct A { void foo(); };", cxxMethodDecl(isConst())));
+      notMatches("struct A { void foo(); };", cxxMethodDecl(isConst())));
 }
 
 TEST(Matcher, MatchesOverridingMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); }; "
-                        "class Y : public X { int f(); };",
+                      "class Y : public X { int f(); };",
                       cxxMethodDecl(isOverride(), hasName("::Y::f"))));
   EXPECT_TRUE(notMatches("class X { virtual int f(); }; "
-                           "class Y : public X { int f(); };",
+                         "class Y : public X { int f(); };",
                          cxxMethodDecl(isOverride(), hasName("::X::f"))));
   EXPECT_TRUE(notMatches("class X { int f(); }; "
-                           "class Y : public X { int f(); };",
+                         "class Y : public X { int f(); };",
                          cxxMethodDecl(isOverride())));
   EXPECT_TRUE(notMatches("class X { int f(); int f(int); }; ",
                          cxxMethodDecl(isOverride())));
   EXPECT_TRUE(
-    matches("template  struct Y : Base { void f() override;};",
-            cxxMethodDecl(isOverride(), hasName("::Y::f"))));
+      matches("template  struct Y : Base { void f() override;};",
+              cxxMethodDecl(isOverride(), hasName("::Y::f"))));
 }
 
 TEST(Matcher, ConstructorArgument) {
@@ -1385,44 +1341,38 @@ TEST(Matcher, ConstructorArgument) {
       ast_type_traits::TK_AsIs,
       cxxConstructExpr(hasArgument(0, declRefExpr(to(varDecl(hasName("y")))))));
 
+  EXPECT_TRUE(matches(
+      "class X { public: X(int); }; void x() { int y; X x(y); }", Constructor));
   EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { int y; X x(y); }",
-            Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { int y; X x = X(y); }",
-            Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { int y; X x = y; }",
-            Constructor));
+      matches("class X { public: X(int); }; void x() { int y; X x = X(y); }",
+              Constructor));
   EXPECT_TRUE(
-    notMatches("class X { public: X(int); }; void x() { int z; X x(z); }",
-               Constructor));
+      matches("class X { public: X(int); }; void x() { int y; X x = y; }",
+              Constructor));
+  EXPECT_TRUE(notMatches(
+      "class X { public: X(int); }; void x() { int z; X x(z); }", Constructor));
 
   StatementMatcher WrongIndex =
       traverse(ast_type_traits::TK_AsIs,
                cxxConstructExpr(
                    hasArgument(42, declRefExpr(to(varDecl(hasName("y")))))));
-  EXPECT_TRUE(
-    notMatches("class X { public: X(int); }; void x() { int y; X x(y); }",
-               WrongIndex));
+  EXPECT_TRUE(notMatches(
+      "class X { public: X(int); }; void x() { int y; X x(y); }", WrongIndex));
 }
 
 TEST(Matcher, ConstructorArgumentCount) {
   auto Constructor1Arg =
       traverse(ast_type_traits::TK_AsIs, cxxConstructExpr(argumentCountIs(1)));
 
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x(0); }",
+                      Constructor1Arg));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x = X(0); }",
+                      Constructor1Arg));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x = 0; }",
+                      Constructor1Arg));
   EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x(0); }",
-            Constructor1Arg));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x = X(0); }",
-            Constructor1Arg));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x = 0; }",
-            Constructor1Arg));
-  EXPECT_TRUE(
-    notMatches("class X { public: X(int, int); }; void x() { X x(0, 0); }",
-               Constructor1Arg));
+      notMatches("class X { public: X(int, int); }; void x() { X x(0, 0); }",
+                 Constructor1Arg));
 }
 
 TEST(Matcher, ConstructorListInitialization) {
@@ -1430,19 +1380,16 @@ TEST(Matcher, ConstructorListInitialization) {
       traverse(ast_type_traits::TK_AsIs,
                varDecl(has(cxxConstructExpr(isListInitialization()))));
 
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x{0}; }",
-            ConstructorListInit));
-  EXPECT_FALSE(
-    matches("class X { public: X(int); }; void x() { X x(0); }",
-            ConstructorListInit));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x{0}; }",
+                      ConstructorListInit));
+  EXPECT_FALSE(matches("class X { public: X(int); }; void x() { X x(0); }",
+                       ConstructorListInit));
 }
 
 TEST(ConstructorDeclaration, IsImplicit) {
   // This one doesn't match because the constructor is not added by the
   // compiler (it is not needed).
-  EXPECT_TRUE(notMatches("class Foo { };",
-                         cxxConstructorDecl(isImplicit())));
+  EXPECT_TRUE(notMatches("class Foo { };", cxxConstructorDecl(isImplicit())));
   // The compiler added the implicit default constructor.
   EXPECT_TRUE(matches("class Foo { }; Foo* f = new Foo();",
                       cxxConstructorDecl(isImplicit())));
@@ -1456,8 +1403,8 @@ TEST(ConstructorDeclaration, IsImplicit) {
 TEST(ConstructorDeclaration, IsExplicit) {
   EXPECT_TRUE(matches("struct S { explicit S(int); };",
                       cxxConstructorDecl(isExplicit())));
-  EXPECT_TRUE(notMatches("struct S { S(int); };",
-                         cxxConstructorDecl(isExplicit())));
+  EXPECT_TRUE(
+      notMatches("struct S { S(int); };", cxxConstructorDecl(isExplicit())));
   EXPECT_TRUE(notMatches("template struct S { explicit(b) S(int);};",
                          cxxConstructorDecl(isExplicit()), langCxx20OrLater()));
   EXPECT_TRUE(matches("struct S { explicit(true) S(int);};",
@@ -1488,9 +1435,9 @@ TEST(DeductionGuideDeclaration, IsExplicit) {
 }
 
 TEST(ConstructorDeclaration, Kinds) {
-  EXPECT_TRUE(matches(
-      "struct S { S(); };",
-      cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit()))));
+  EXPECT_TRUE(
+      matches("struct S { S(); };", cxxConstructorDecl(isDefaultConstructor(),
+                                                       unless(isImplicit()))));
   EXPECT_TRUE(notMatches(
       "struct S { S(); };",
       cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
@@ -1501,9 +1448,9 @@ TEST(ConstructorDeclaration, Kinds) {
   EXPECT_TRUE(notMatches(
       "struct S { S(const S&); };",
       cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit()))));
-  EXPECT_TRUE(matches(
-      "struct S { S(const S&); };",
-      cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
+  EXPECT_TRUE(
+      matches("struct S { S(const S&); };",
+              cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
   EXPECT_TRUE(notMatches(
       "struct S { S(const S&); };",
       cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))));
@@ -1514,9 +1461,9 @@ TEST(ConstructorDeclaration, Kinds) {
   EXPECT_TRUE(notMatches(
       "struct S { S(S&&); };",
       cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))));
-  EXPECT_TRUE(matches(
-      "struct S { S(S&&); };",
-      cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))));
+  EXPECT_TRUE(
+      matches("struct S { S(S&&); };",
+              cxxConstructorDecl(isMoveConstructor(), unless(isImplicit()))));
 }
 
 TEST(ConstructorDeclaration, IsUserProvided) {
@@ -1527,7 +1474,7 @@ TEST(ConstructorDeclaration, IsUserProvided) {
   EXPECT_TRUE(notMatches("struct S { S() = delete; };",
                          cxxConstructorDecl(isUserProvided())));
   EXPECT_TRUE(
-    matches("struct S { S(); };", cxxConstructorDecl(isUserProvided())));
+      matches("struct S { S(); };", cxxConstructorDecl(isUserProvided())));
   EXPECT_TRUE(matches("struct S { S(); }; S::S(){}",
                       cxxConstructorDecl(isUserProvided())));
 }
@@ -1538,11 +1485,11 @@ TEST(ConstructorDeclaration, IsDelegatingConstructor) {
   EXPECT_TRUE(notMatches("struct S { S(){} S(int X) : X(X) {} int X; };",
                          cxxConstructorDecl(isDelegatingConstructor())));
   EXPECT_TRUE(matches(
-    "struct S { S() : S(0) {} S(int X) : X(X) {} int X; };",
-    cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(0))));
+      "struct S { S() : S(0) {} S(int X) : X(X) {} int X; };",
+      cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(0))));
   EXPECT_TRUE(matches(
-    "struct S { S(); S(int X); int X; }; S::S(int X) : S() {}",
-    cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1))));
+      "struct S { S(); S(int X); int X; }; S::S(int X) : S() {}",
+      cxxConstructorDecl(isDelegatingConstructor(), parameterCountIs(1))));
 }
 
 TEST(StringLiteral, HasSize) {
@@ -1584,38 +1531,28 @@ TEST(Matcher, HasNameSupportsNamespaces) {
 }
 
 TEST(Matcher, HasNameSupportsOuterClasses) {
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("A::B::C"))));
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("::A::B::C"))));
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("B::C"))));
-  EXPECT_TRUE(
-    matches("class A { class B { class C; }; };",
-            recordDecl(hasName("C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("c::B::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("A::c::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("A::B::A"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("::B::C"))));
+  EXPECT_TRUE(matches("class A { class B { class C; }; };",
+                      recordDecl(hasName("A::B::C"))));
+  EXPECT_TRUE(matches("class A { class B { class C; }; };",
+                      recordDecl(hasName("::A::B::C"))));
+  EXPECT_TRUE(matches("class A { class B { class C; }; };",
+                      recordDecl(hasName("B::C"))));
+  EXPECT_TRUE(
+      matches("class A { class B { class C; }; };", recordDecl(hasName("C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("c::B::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("A::c::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("A::B::A"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("::B::C"))));
   EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
                          recordDecl(hasName("z::A::B::C"))));
-  EXPECT_TRUE(
-    notMatches("class A { class B { class C; }; };",
-               recordDecl(hasName("A+B::C"))));
+  EXPECT_TRUE(notMatches("class A { class B { class C; }; };",
+                         recordDecl(hasName("A+B::C"))));
 }
 
 TEST(Matcher, HasNameSupportsInlinedNamespaces) {
@@ -1629,10 +1566,10 @@ TEST(Matcher, HasNameSupportsInlinedNamespaces) {
 TEST(Matcher, HasNameSupportsAnonymousNamespaces) {
   StringRef code = "namespace a { namespace { class C; } }";
   EXPECT_TRUE(
-    matches(code, recordDecl(hasName("a::(anonymous namespace)::C"))));
+      matches(code, recordDecl(hasName("a::(anonymous namespace)::C"))));
   EXPECT_TRUE(matches(code, recordDecl(hasName("a::C"))));
   EXPECT_TRUE(
-    matches(code, recordDecl(hasName("::a::(anonymous namespace)::C"))));
+      matches(code, recordDecl(hasName("::a::(anonymous namespace)::C"))));
   EXPECT_TRUE(matches(code, recordDecl(hasName("::a::C"))));
 }
 
@@ -1689,7 +1626,7 @@ TEST(Matcher, HasAnyName) {
 
   EXPECT_TRUE(notMatches(Code, recordDecl(hasAnyName("::C", "::b::C"))));
   EXPECT_TRUE(
-    matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C"))));
+      matches(Code, recordDecl(hasAnyName("::C", "::b::C", "::a::b::C"))));
 
   std::vector Names = {"::C", "::b::C", "::a::b::C"};
   EXPECT_TRUE(matches(Code, recordDecl(hasAnyName(Names))));
@@ -1697,27 +1634,27 @@ TEST(Matcher, HasAnyName) {
 
 TEST(Matcher, IsDefinition) {
   DeclarationMatcher DefinitionOfClassA =
-    recordDecl(hasName("A"), isDefinition());
+      recordDecl(hasName("A"), isDefinition());
   EXPECT_TRUE(matches("class A {};", DefinitionOfClassA));
   EXPECT_TRUE(notMatches("class A;", DefinitionOfClassA));
 
   DeclarationMatcher DefinitionOfVariableA =
-    varDecl(hasName("a"), isDefinition());
+      varDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("int a;", DefinitionOfVariableA));
   EXPECT_TRUE(notMatches("extern int a;", DefinitionOfVariableA));
 
   DeclarationMatcher DefinitionOfMethodA =
-    cxxMethodDecl(hasName("a"), isDefinition());
+      cxxMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matches("class A { void a() {} };", DefinitionOfMethodA));
   EXPECT_TRUE(notMatches("class A { void a(); };", DefinitionOfMethodA));
 
   DeclarationMatcher DefinitionOfObjCMethodA =
-    objcMethodDecl(hasName("a"), isDefinition());
+      objcMethodDecl(hasName("a"), isDefinition());
   EXPECT_TRUE(matchesObjC("@interface A @end "
                           "@implementation A; -(void)a {} @end",
                           DefinitionOfObjCMethodA));
-  EXPECT_TRUE(notMatchesObjC("@interface A; - (void)a; @end",
-                             DefinitionOfObjCMethodA));
+  EXPECT_TRUE(
+      notMatchesObjC("@interface A; - (void)a; @end", DefinitionOfObjCMethodA));
 }
 
 TEST(Matcher, HandlesNullQualTypes) {
@@ -1728,7 +1665,7 @@ TEST(Matcher, HandlesNullQualTypes) {
   // We don't really care whether this matcher succeeds; we're testing that
   // it completes without crashing.
   EXPECT_TRUE(matches(
-    "struct A { };"
+      "struct A { };"
       "template "
       "void f(T t) {"
       "  T local_t(t /* this becomes a null QualType in the AST */);"
@@ -1736,13 +1673,10 @@ TEST(Matcher, HandlesNullQualTypes) {
       "void g() {"
       "  f(0);"
       "}",
-    expr(hasType(TypeMatcher(
-      anyOf(
-        TypeMatcher(hasDeclaration(anything())),
-        pointsTo(AnyType),
-        references(AnyType)
-        // Other QualType matchers should go here.
-      ))))));
+      expr(hasType(TypeMatcher(anyOf(TypeMatcher(hasDeclaration(anything())),
+                                     pointsTo(AnyType), references(AnyType)
+                                     // Other QualType matchers should go here.
+                                     ))))));
 }
 
 TEST(ObjCIvarRefExprMatcher, IvarExpr) {
@@ -1750,10 +1684,10 @@ TEST(ObjCIvarRefExprMatcher, IvarExpr) {
       "@interface A @end "
       "@implementation A { A *x; } - (void) func { x = 0; } @end";
   EXPECT_TRUE(matchesObjC(ObjCString, objcIvarRefExpr()));
-  EXPECT_TRUE(matchesObjC(ObjCString, objcIvarRefExpr(
-        hasDeclaration(namedDecl(hasName("x"))))));
-  EXPECT_FALSE(matchesObjC(ObjCString, objcIvarRefExpr(
-        hasDeclaration(namedDecl(hasName("y"))))));
+  EXPECT_TRUE(matchesObjC(
+      ObjCString, objcIvarRefExpr(hasDeclaration(namedDecl(hasName("x"))))));
+  EXPECT_FALSE(matchesObjC(
+      ObjCString, objcIvarRefExpr(hasDeclaration(namedDecl(hasName("y"))))));
 }
 
 TEST(BlockExprMatcher, BlockExpr) {
@@ -1761,24 +1695,19 @@ TEST(BlockExprMatcher, BlockExpr) {
 }
 
 TEST(StatementCountIs, FindsNoStatementsInAnEmptyCompoundStatement) {
-  EXPECT_TRUE(matches("void f() { }",
-                      compoundStmt(statementCountIs(0))));
-  EXPECT_TRUE(notMatches("void f() {}",
-                         compoundStmt(statementCountIs(1))));
+  EXPECT_TRUE(matches("void f() { }", compoundStmt(statementCountIs(0))));
+  EXPECT_TRUE(notMatches("void f() {}", compoundStmt(statementCountIs(1))));
 }
 
 TEST(StatementCountIs, AppearsToMatchOnlyOneCount) {
-  EXPECT_TRUE(matches("void f() { 1; }",
-                      compoundStmt(statementCountIs(1))));
-  EXPECT_TRUE(notMatches("void f() { 1; }",
-                         compoundStmt(statementCountIs(0))));
-  EXPECT_TRUE(notMatches("void f() { 1; }",
-                         compoundStmt(statementCountIs(2))));
+  EXPECT_TRUE(matches("void f() { 1; }", compoundStmt(statementCountIs(1))));
+  EXPECT_TRUE(notMatches("void f() { 1; }", compoundStmt(statementCountIs(0))));
+  EXPECT_TRUE(notMatches("void f() { 1; }", compoundStmt(statementCountIs(2))));
 }
 
 TEST(StatementCountIs, WorksWithMultipleStatements) {
-  EXPECT_TRUE(matches("void f() { 1; 2; 3; }",
-                      compoundStmt(statementCountIs(3))));
+  EXPECT_TRUE(
+      matches("void f() { 1; 2; 3; }", compoundStmt(statementCountIs(3))));
 }
 
 TEST(StatementCountIs, WorksWithNestedCompoundStatements) {
@@ -1806,19 +1735,19 @@ TEST(Member, DoesNotMatchTheBaseExpression) {
 
 TEST(Member, MatchesInMemberFunctionCall) {
   EXPECT_TRUE(matches("void f() {"
-                        "  struct { void first() {}; } s;"
-                        "  s.first();"
-                        "};",
+                      "  struct { void first() {}; } s;"
+                      "  s.first();"
+                      "};",
                       memberExpr(member(hasName("first")))));
 }
 
 TEST(Member, MatchesMember) {
-  EXPECT_TRUE(matches(
-    "struct A { int i; }; void f() { A a; a.i = 2; }",
-    memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
-  EXPECT_TRUE(notMatches(
-    "struct A { float f; }; void f() { A a; a.f = 2.0f; }",
-    memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
+  EXPECT_TRUE(
+      matches("struct A { int i; }; void f() { A a; a.i = 2; }",
+              memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
+  EXPECT_TRUE(
+      notMatches("struct A { float f; }; void f() { A a; a.f = 2.0f; }",
+                 memberExpr(hasDeclaration(fieldDecl(hasType(isInteger()))))));
 }
 
 TEST(Member, BitFields) {
@@ -1841,26 +1770,26 @@ TEST(Member, InClassInitializer) {
 }
 
 TEST(Member, UnderstandsAccess) {
-  EXPECT_TRUE(matches(
-    "struct A { int i; };", fieldDecl(isPublic(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "struct A { int i; };", fieldDecl(isProtected(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "struct A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
+  EXPECT_TRUE(
+      matches("struct A { int i; };", fieldDecl(isPublic(), hasName("i"))));
+  EXPECT_TRUE(notMatches("struct A { int i; };",
+                         fieldDecl(isProtected(), hasName("i"))));
+  EXPECT_TRUE(
+      notMatches("struct A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
 
-  EXPECT_TRUE(notMatches(
-    "class A { int i; };", fieldDecl(isPublic(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "class A { int i; };", fieldDecl(isProtected(), hasName("i"))));
-  EXPECT_TRUE(matches(
-    "class A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
+  EXPECT_TRUE(
+      notMatches("class A { int i; };", fieldDecl(isPublic(), hasName("i"))));
+  EXPECT_TRUE(notMatches("class A { int i; };",
+                         fieldDecl(isProtected(), hasName("i"))));
+  EXPECT_TRUE(
+      matches("class A { int i; };", fieldDecl(isPrivate(), hasName("i"))));
 
-  EXPECT_TRUE(notMatches(
-    "class A { protected: int i; };", fieldDecl(isPublic(), hasName("i"))));
+  EXPECT_TRUE(notMatches("class A { protected: int i; };",
+                         fieldDecl(isPublic(), hasName("i"))));
   EXPECT_TRUE(matches("class A { protected: int i; };",
                       fieldDecl(isProtected(), hasName("i"))));
-  EXPECT_TRUE(notMatches(
-    "class A { protected: int i; };", fieldDecl(isPrivate(), hasName("i"))));
+  EXPECT_TRUE(notMatches("class A { protected: int i; };",
+                         fieldDecl(isPrivate(), hasName("i"))));
 
   // Non-member decls have the AccessSpecifier AS_none and thus aren't matched.
   EXPECT_TRUE(notMatches("int i;", varDecl(isPublic(), hasName("i"))));
@@ -1883,35 +1812,35 @@ TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) {
   EXPECT_TRUE(
       matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec())));
 
-  EXPECT_TRUE(notMatches("void f();", functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(
+      notMatches("void f();", functionProtoType(hasDynamicExceptionSpec())));
   EXPECT_TRUE(notMatches("void g() noexcept;",
                          functionProtoType(hasDynamicExceptionSpec())));
   EXPECT_TRUE(notMatches("void h() noexcept(true);",
                          functionProtoType(hasDynamicExceptionSpec())));
   EXPECT_TRUE(notMatches("void i() noexcept(false);",
                          functionProtoType(hasDynamicExceptionSpec())));
-  EXPECT_TRUE(
-      matches("void j() throw();", functionProtoType(hasDynamicExceptionSpec())));
-  EXPECT_TRUE(
-      matches("void k() throw(int);", functionProtoType(hasDynamicExceptionSpec())));
-  EXPECT_TRUE(
-      matches("void l() throw(...);", functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(matches("void j() throw();",
+                      functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(matches("void k() throw(int);",
+                      functionProtoType(hasDynamicExceptionSpec())));
+  EXPECT_TRUE(matches("void l() throw(...);",
+                      functionProtoType(hasDynamicExceptionSpec())));
 }
 
 TEST(HasObjectExpression, DoesNotMatchMember) {
   EXPECT_TRUE(notMatches(
-    "class X {}; struct Z { X m; }; void f(Z z) { z.m; }",
-    memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
+      "class X {}; struct Z { X m; }; void f(Z z) { z.m; }",
+      memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
 }
 
 TEST(HasObjectExpression, MatchesBaseOfVariable) {
   EXPECT_TRUE(matches(
-    "struct X { int m; }; void f(X x) { x.m; }",
-    memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
-  EXPECT_TRUE(matches(
-    "struct X { int m; }; void f(X* x) { x->m; }",
-    memberExpr(hasObjectExpression(
-      hasType(pointsTo(recordDecl(hasName("X"))))))));
+      "struct X { int m; }; void f(X x) { x.m; }",
+      memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))));
+  EXPECT_TRUE(matches("struct X { int m; }; void f(X* x) { x->m; }",
+                      memberExpr(hasObjectExpression(
+                          hasType(pointsTo(recordDecl(hasName("X"))))))));
   EXPECT_TRUE(matches("template  struct X { void f() { T t; t.m; } };",
                       cxxDependentScopeMemberExpr(hasObjectExpression(
                           declRefExpr(to(namedDecl(hasName("t"))))))));
@@ -1936,14 +1865,12 @@ TEST(HasObjectExpression, MatchesBaseOfMemberFunc) {
 
 TEST(HasObjectExpression,
      MatchesObjectExpressionOfImplicitlyFormedMemberExpression) {
-  EXPECT_TRUE(matches(
-    "class X {}; struct S { X m; void f() { this->m; } };",
-    memberExpr(hasObjectExpression(
-      hasType(pointsTo(recordDecl(hasName("S"))))))));
-  EXPECT_TRUE(matches(
-    "class X {}; struct S { X m; void f() { m; } };",
-    memberExpr(hasObjectExpression(
-      hasType(pointsTo(recordDecl(hasName("S"))))))));
+  EXPECT_TRUE(matches("class X {}; struct S { X m; void f() { this->m; } };",
+                      memberExpr(hasObjectExpression(
+                          hasType(pointsTo(recordDecl(hasName("S"))))))));
+  EXPECT_TRUE(matches("class X {}; struct S { X m; void f() { m; } };",
+                      memberExpr(hasObjectExpression(
+                          hasType(pointsTo(recordDecl(hasName("S"))))))));
 }
 
 TEST(Field, DoesNotMatchNonFieldMembers) {
@@ -1958,17 +1885,17 @@ TEST(Field, MatchesField) {
 }
 
 TEST(IsVolatileQualified, QualifiersMatch) {
-  EXPECT_TRUE(matches("volatile int i = 42;",
-                      varDecl(hasType(isVolatileQualified()))));
-  EXPECT_TRUE(notMatches("volatile int *i;",
-                         varDecl(hasType(isVolatileQualified()))));
+  EXPECT_TRUE(
+      matches("volatile int i = 42;", varDecl(hasType(isVolatileQualified()))));
+  EXPECT_TRUE(
+      notMatches("volatile int *i;", varDecl(hasType(isVolatileQualified()))));
   EXPECT_TRUE(matches("typedef volatile int v_int; v_int i = 42;",
                       varDecl(hasType(isVolatileQualified()))));
 }
 
 TEST(IsConstQualified, MatchesConstInt) {
-  EXPECT_TRUE(matches("const int i = 42;",
-                      varDecl(hasType(isConstQualified()))));
+  EXPECT_TRUE(
+      matches("const int i = 42;", varDecl(hasType(isConstQualified()))));
 }
 
 TEST(IsConstQualified, MatchesConstPointer) {
@@ -1986,43 +1913,41 @@ TEST(IsConstQualified, MatchesThroughTypedef) {
 TEST(IsConstQualified, DoesNotMatchInappropriately) {
   EXPECT_TRUE(notMatches("typedef int nonconst_int; nonconst_int i = 42;",
                          varDecl(hasType(isConstQualified()))));
-  EXPECT_TRUE(notMatches("int const* p;",
-                         varDecl(hasType(isConstQualified()))));
+  EXPECT_TRUE(
+      notMatches("int const* p;", varDecl(hasType(isConstQualified()))));
 }
 
 TEST(DeclCount, DeclCountIsCorrect) {
-  EXPECT_TRUE(matches("void f() {int i,j;}",
-                      declStmt(declCountIs(2))));
-  EXPECT_TRUE(notMatches("void f() {int i,j; int k;}",
-                         declStmt(declCountIs(3))));
-  EXPECT_TRUE(notMatches("void f() {int i,j, k, l;}",
-                         declStmt(declCountIs(3))));
+  EXPECT_TRUE(matches("void f() {int i,j;}", declStmt(declCountIs(2))));
+  EXPECT_TRUE(
+      notMatches("void f() {int i,j; int k;}", declStmt(declCountIs(3))));
+  EXPECT_TRUE(
+      notMatches("void f() {int i,j, k, l;}", declStmt(declCountIs(3))));
 }
 
-
 TEST(EachOf, TriggersForEachMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { int a; int b; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v")))),
-    std::make_unique>("v", 2)));
+      "class A { int a; int b; };",
+      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                        has(fieldDecl(hasName("b")).bind("v")))),
+      std::make_unique>("v", 2)));
 }
 
 TEST(EachOf, BehavesLikeAnyOfUnlessBothMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { int a; int c; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v")))),
-    std::make_unique>("v", 1)));
+      "class A { int a; int c; };",
+      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                        has(fieldDecl(hasName("b")).bind("v")))),
+      std::make_unique>("v", 1)));
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "class A { int c; int b; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v")))),
-    std::make_unique>("v", 1)));
-  EXPECT_TRUE(notMatches(
-    "class A { int c; int d; };",
-    recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
-                      has(fieldDecl(hasName("b")).bind("v"))))));
+      "class A { int c; int b; };",
+      recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                        has(fieldDecl(hasName("b")).bind("v")))),
+      std::make_unique>("v", 1)));
+  EXPECT_TRUE(
+      notMatches("class A { int c; int d; };",
+                 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
+                                   has(fieldDecl(hasName("b")).bind("v"))))));
 }
 
 TEST(Optionally, SubmatchersDoNotMatch) {
@@ -2056,29 +1981,30 @@ TEST(IsTemplateInstantiation, MatchesImplicitClassTemplateInstantiation) {
   // Make sure that we can both match the class by name (::X) and by the type
   // the template was instantiated with (via a field).
 
-  EXPECT_TRUE(matches(
-    "template  class X {}; class A {}; X x;",
-    cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      matches("template  class X {}; class A {}; X x;",
+              cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
 
   EXPECT_TRUE(matches(
-    "template  class X { T t; }; class A {}; X x;",
-    cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
-      fieldDecl(hasType(recordDecl(hasName("A"))))))));
+      "template  class X { T t; }; class A {}; X x;",
+      cxxRecordDecl(
+          isTemplateInstantiation(),
+          hasDescendant(fieldDecl(hasType(recordDecl(hasName("A"))))))));
 }
 
 TEST(IsTemplateInstantiation, MatchesImplicitFunctionTemplateInstantiation) {
   EXPECT_TRUE(matches(
-    "template  void f(T t) {} class A {}; void g() { f(A()); }",
-    functionDecl(hasParameter(0, hasType(recordDecl(hasName("A")))),
-                 isTemplateInstantiation())));
+      "template  void f(T t) {} class A {}; void g() { f(A()); }",
+      functionDecl(hasParameter(0, hasType(recordDecl(hasName("A")))),
+                   isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
-  EXPECT_TRUE(matches(
-    "template  class X { T t; }; class A {};"
-      "template class X;",
-    cxxRecordDecl(isTemplateInstantiation(), hasDescendant(
-      fieldDecl(hasType(recordDecl(hasName("A"))))))));
+  EXPECT_TRUE(matches("template  class X { T t; }; class A {};"
+                      "template class X;",
+                      cxxRecordDecl(isTemplateInstantiation(),
+                                    hasDescendant(fieldDecl(
+                                        hasType(recordDecl(hasName("A"))))))));
 
   // Make sure that we match the instantiation instead of the template
   // definition by checking whether the member function is present.
@@ -2091,21 +2017,21 @@ TEST(IsTemplateInstantiation, MatchesExplicitClassTemplateInstantiation) {
 
 TEST(IsTemplateInstantiation,
      MatchesInstantiationOfPartiallySpecializedClassTemplate) {
-  EXPECT_TRUE(matches(
-    "template  class X {};"
-      "template  class X {}; class A {}; X x;",
-    cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      matches("template  class X {};"
+              "template  class X {}; class A {}; X x;",
+              cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation,
      MatchesInstantiationOfClassTemplateNestedInNonTemplate) {
-  EXPECT_TRUE(matches(
-    "class A {};"
-      "class X {"
-      "  template  class Y { U u; };"
-      "  Y y;"
-      "};",
-    cxxRecordDecl(hasName("::X::Y"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      matches("class A {};"
+              "class X {"
+              "  template  class Y { U u; };"
+              "  Y y;"
+              "};",
+              cxxRecordDecl(hasName("::X::Y"), isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
@@ -2113,31 +2039,30 @@ TEST(IsTemplateInstantiation, DoesNotMatchInstantiationsInsideOfInstantiation) {
   // normal use case as long as the uppermost instantiation always is marked
   // as template instantiation, but it might be confusing as a predicate.
   EXPECT_TRUE(matches(
-    "class A {};"
+      "class A {};"
       "template  class X {"
       "  template  class Y { U u; };"
       "  Y y;"
       "}; X x;",
-    cxxRecordDecl(hasName("::X::Y"), unless(isTemplateInstantiation()))));
+      cxxRecordDecl(hasName("::X::Y"), unless(isTemplateInstantiation()))));
 }
 
 TEST(IsTemplateInstantiation, DoesNotMatchExplicitClassTemplateSpecialization) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {}; class A {};"
-      "template <> class X {}; X x;",
-    cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
+  EXPECT_TRUE(
+      notMatches("template  class X {}; class A {};"
+                 "template <> class X {}; X x;",
+                 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())));
 }
 
 TEST(IsTemplateInstantiation, DoesNotMatchNonTemplate) {
-  EXPECT_TRUE(notMatches(
-    "class A {}; class Y { A a; };",
-    cxxRecordDecl(isTemplateInstantiation())));
+  EXPECT_TRUE(notMatches("class A {}; class Y { A a; };",
+                         cxxRecordDecl(isTemplateInstantiation())));
 }
 
 TEST(IsInstantiated, MatchesInstantiation) {
   EXPECT_TRUE(
-    matches("template class A { T i; }; class Y { A a; };",
-            cxxRecordDecl(isInstantiated())));
+      matches("template class A { T i; }; class Y { A a; };",
+              cxxRecordDecl(isInstantiated())));
 }
 
 TEST(IsInstantiated, NotMatchesDefinition) {
@@ -2147,7 +2072,7 @@ TEST(IsInstantiated, NotMatchesDefinition) {
 
 TEST(IsInTemplateInstantiation, MatchesInstantiationStmt) {
   EXPECT_TRUE(matches("template struct A { A() { T i; } };"
-                        "class Y { A a; }; Y y;",
+                      "class Y { A a; }; Y y;",
                       declStmt(isInTemplateInstantiation())));
 }
 
@@ -2158,8 +2083,8 @@ TEST(IsInTemplateInstantiation, NotMatchesDefinitionStmt) {
 
 TEST(IsInstantiated, MatchesFunctionInstantiation) {
   EXPECT_TRUE(
-    matches("template void A(T t) { T i; } void x() { A(0); }",
-            functionDecl(isInstantiated())));
+      matches("template void A(T t) { T i; } void x() { A(0); }",
+              functionDecl(isInstantiated())));
 }
 
 TEST(IsInstantiated, NotMatchesFunctionDefinition) {
@@ -2169,8 +2094,8 @@ TEST(IsInstantiated, NotMatchesFunctionDefinition) {
 
 TEST(IsInTemplateInstantiation, MatchesFunctionInstantiationStmt) {
   EXPECT_TRUE(
-    matches("template void A(T t) { T i; } void x() { A(0); }",
-            declStmt(isInTemplateInstantiation())));
+      matches("template void A(T t) { T i; } void x() { A(0); }",
+              declStmt(isInTemplateInstantiation())));
 }
 
 TEST(IsInTemplateInstantiation, NotMatchesFunctionDefinitionStmt) {
@@ -2183,11 +2108,11 @@ TEST(IsInTemplateInstantiation, Sharing) {
   // FIXME: Node sharing is an implementation detail, exposing it is ugly
   // and makes the matcher behave in non-obvious ways.
   EXPECT_TRUE(notMatches(
-    "int j; template void A(T t) { j += 42; } void x() { A(0); }",
-    Matcher));
+      "int j; template void A(T t) { j += 42; } void x() { A(0); }",
+      Matcher));
   EXPECT_TRUE(matches(
-    "int j; template void A(T t) { j += t; } void x() { A(0); }",
-    Matcher));
+      "int j; template void A(T t) { j += t; } void x() { A(0); }",
+      Matcher));
 }
 
 TEST(IsInstantiationDependent, MatchesNonValueTypeDependent) {
@@ -2232,48 +2157,41 @@ TEST(IsValueDependent, MatchesInstantiationDependent) {
       expr(isValueDependent())));
 }
 
-TEST(IsExplicitTemplateSpecialization,
-     DoesNotMatchPrimaryTemplate) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {};",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(notMatches(
-    "template  void f(T t);",
-    functionDecl(isExplicitTemplateSpecialization())));
+TEST(IsExplicitTemplateSpecialization, DoesNotMatchPrimaryTemplate) {
+  EXPECT_TRUE(notMatches("template  class X {};",
+                         cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(notMatches("template  void f(T t);",
+                         functionDecl(isExplicitTemplateSpecialization())));
 }
 
 TEST(IsExplicitTemplateSpecialization,
      DoesNotMatchExplicitTemplateInstantiations) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {};"
-      "template class X; extern template class X;",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(notMatches(
-    "template  void f(T t) {}"
-      "template void f(int t); extern template void f(long t);",
-    functionDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(
+      notMatches("template  class X {};"
+                 "template class X; extern template class X;",
+                 cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(
+      notMatches("template  void f(T t) {}"
+                 "template void f(int t); extern template void f(long t);",
+                 functionDecl(isExplicitTemplateSpecialization())));
 }
 
 TEST(IsExplicitTemplateSpecialization,
      DoesNotMatchImplicitTemplateInstantiations) {
-  EXPECT_TRUE(notMatches(
-    "template  class X {}; X x;",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(notMatches(
-    "template  void f(T t); void g() { f(10); }",
-    functionDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(notMatches("template  class X {}; X x;",
+                         cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(
+      notMatches("template  void f(T t); void g() { f(10); }",
+                 functionDecl(isExplicitTemplateSpecialization())));
 }
 
-TEST(IsExplicitTemplateSpecialization,
-     MatchesExplicitTemplateSpecializations) {
-  EXPECT_TRUE(matches(
-    "template  class X {};"
-      "template<> class X {};",
-    cxxRecordDecl(isExplicitTemplateSpecialization())));
-  EXPECT_TRUE(matches(
-    "template  void f(T t) {}"
-      "template<> void f(int t) {}",
-    functionDecl(isExplicitTemplateSpecialization())));
+TEST(IsExplicitTemplateSpecialization, MatchesExplicitTemplateSpecializations) {
+  EXPECT_TRUE(matches("template  class X {};"
+                      "template<> class X {};",
+                      cxxRecordDecl(isExplicitTemplateSpecialization())));
+  EXPECT_TRUE(matches("template  void f(T t) {}"
+                      "template<> void f(int t) {}",
+                      functionDecl(isExplicitTemplateSpecialization())));
 }
 
 TEST(TypeMatching, MatchesNoReturn) {
@@ -2314,8 +2232,8 @@ TEST(TypeMatching, MatchesNoReturn) {
 
   EXPECT_TRUE(
       matches("struct S { [[noreturn]] S(); };", functionDecl(isNoReturn())));
-  EXPECT_TRUE(matches("struct S { [[noreturn]] S() {} };",
-                      functionDecl(isNoReturn())));
+  EXPECT_TRUE(
+      matches("struct S { [[noreturn]] S() {} };", functionDecl(isNoReturn())));
 
   // ---
 
@@ -2344,14 +2262,12 @@ TEST(TypeMatching, MatchesNoReturn) {
   // ---
 
   EXPECT_TRUE(matchesC("__attribute__((noreturn)) void func();",
-                      functionDecl(isNoReturn())));
+                       functionDecl(isNoReturn())));
   EXPECT_TRUE(matchesC("__attribute__((noreturn)) void func() {}",
-                      functionDecl(isNoReturn())));
+                       functionDecl(isNoReturn())));
 
-  EXPECT_TRUE(matchesC("_Noreturn void func();",
-                      functionDecl(isNoReturn())));
-  EXPECT_TRUE(matchesC("_Noreturn void func() {}",
-                      functionDecl(isNoReturn())));
+  EXPECT_TRUE(matchesC("_Noreturn void func();", functionDecl(isNoReturn())));
+  EXPECT_TRUE(matchesC("_Noreturn void func() {}", functionDecl(isNoReturn())));
 }
 
 TEST(TypeMatching, MatchesBool) {
@@ -2383,45 +2299,42 @@ TEST(TypeMatching, MatchesArrayTypes) {
   EXPECT_TRUE(notMatches("struct A {}; A a[7];",
                          arrayType(hasElementType(builtinType()))));
 
+  EXPECT_TRUE(matches("int const a[] = { 2, 3 };",
+                      qualType(arrayType(hasElementType(builtinType())))));
   EXPECT_TRUE(matches(
-    "int const a[] = { 2, 3 };",
-    qualType(arrayType(hasElementType(builtinType())))));
-  EXPECT_TRUE(matches(
-    "int const a[] = { 2, 3 };",
-    qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
-  EXPECT_TRUE(matches(
-    "typedef const int T; T x[] = { 1, 2 };",
-    qualType(isConstQualified(), arrayType())));
+      "int const a[] = { 2, 3 };",
+      qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
+  EXPECT_TRUE(matches("typedef const int T; T x[] = { 1, 2 };",
+                      qualType(isConstQualified(), arrayType())));
 
   EXPECT_TRUE(notMatches(
-    "int a[] = { 2, 3 };",
-    qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
-  EXPECT_TRUE(notMatches(
-    "int a[] = { 2, 3 };",
-    qualType(arrayType(hasElementType(isConstQualified(), builtinType())))));
+      "int a[] = { 2, 3 };",
+      qualType(isConstQualified(), arrayType(hasElementType(builtinType())))));
   EXPECT_TRUE(notMatches(
-    "int const a[] = { 2, 3 };",
-    qualType(arrayType(hasElementType(builtinType())),
-             unless(isConstQualified()))));
+      "int a[] = { 2, 3 };",
+      qualType(arrayType(hasElementType(isConstQualified(), builtinType())))));
+  EXPECT_TRUE(notMatches("int const a[] = { 2, 3 };",
+                         qualType(arrayType(hasElementType(builtinType())),
+                                  unless(isConstQualified()))));
 
-  EXPECT_TRUE(matches("int a[2];",
-                      constantArrayType(hasElementType(builtinType()))));
+  EXPECT_TRUE(
+      matches("int a[2];", constantArrayType(hasElementType(builtinType()))));
   EXPECT_TRUE(matches("const int a = 0;", qualType(isInteger())));
 }
 
 TEST(TypeMatching, DecayedType) {
-  EXPECT_TRUE(matches("void f(int i[]);", valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))));
+  EXPECT_TRUE(
+      matches("void f(int i[]);",
+              valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))));
   EXPECT_TRUE(notMatches("int i[7];", decayedType()));
 }
 
 TEST(TypeMatching, MatchesComplexTypes) {
   EXPECT_TRUE(matches("_Complex float f;", complexType()));
-  EXPECT_TRUE(matches(
-    "_Complex float f;",
-    complexType(hasElementType(builtinType()))));
-  EXPECT_TRUE(notMatches(
-    "_Complex float f;",
-    complexType(hasElementType(isInteger()))));
+  EXPECT_TRUE(
+      matches("_Complex float f;", complexType(hasElementType(builtinType()))));
+  EXPECT_TRUE(notMatches("_Complex float f;",
+                         complexType(hasElementType(isInteger()))));
 }
 
 TEST(NS, Anonymous) {
@@ -2482,38 +2395,38 @@ TEST(DeclarationMatcher, InStdNamespace) {
 
 TEST(EqualsBoundNodeMatcher, QualType) {
   EXPECT_TRUE(matches(
-    "int i = 1;", varDecl(hasType(qualType().bind("type")),
-                          hasInitializer(ignoringParenImpCasts(
-                            hasType(qualType(equalsBoundNode("type"))))))));
+      "int i = 1;", varDecl(hasType(qualType().bind("type")),
+                            hasInitializer(ignoringParenImpCasts(
+                                hasType(qualType(equalsBoundNode("type"))))))));
   EXPECT_TRUE(notMatches("int i = 1.f;",
                          varDecl(hasType(qualType().bind("type")),
                                  hasInitializer(ignoringParenImpCasts(hasType(
-                                   qualType(equalsBoundNode("type"))))))));
+                                     qualType(equalsBoundNode("type"))))))));
 }
 
 TEST(EqualsBoundNodeMatcher, NonMatchingTypes) {
   EXPECT_TRUE(notMatches(
-    "int i = 1;", varDecl(namedDecl(hasName("i")).bind("name"),
-                          hasInitializer(ignoringParenImpCasts(
-                            hasType(qualType(equalsBoundNode("type"))))))));
+      "int i = 1;", varDecl(namedDecl(hasName("i")).bind("name"),
+                            hasInitializer(ignoringParenImpCasts(
+                                hasType(qualType(equalsBoundNode("type"))))))));
 }
 
 TEST(EqualsBoundNodeMatcher, Stmt) {
   EXPECT_TRUE(
-    matches("void f() { if(true) {} }",
-            stmt(allOf(ifStmt().bind("if"),
-                       hasParent(stmt(has(stmt(equalsBoundNode("if")))))))));
+      matches("void f() { if(true) {} }",
+              stmt(allOf(ifStmt().bind("if"),
+                         hasParent(stmt(has(stmt(equalsBoundNode("if")))))))));
 
   EXPECT_TRUE(notMatches(
-    "void f() { if(true) { if (true) {} } }",
-    stmt(allOf(ifStmt().bind("if"), has(stmt(equalsBoundNode("if")))))));
+      "void f() { if(true) { if (true) {} } }",
+      stmt(allOf(ifStmt().bind("if"), has(stmt(equalsBoundNode("if")))))));
 }
 
 TEST(EqualsBoundNodeMatcher, Decl) {
   EXPECT_TRUE(matches(
-    "class X { class Y {}; };",
-    decl(allOf(recordDecl(hasName("::X::Y")).bind("record"),
-               hasParent(decl(has(decl(equalsBoundNode("record")))))))));
+      "class X { class Y {}; };",
+      decl(allOf(recordDecl(hasName("::X::Y")).bind("record"),
+                 hasParent(decl(has(decl(equalsBoundNode("record")))))))));
 
   EXPECT_TRUE(notMatches("class X { class Y {}; };",
                          decl(allOf(recordDecl(hasName("::X")).bind("record"),
@@ -2522,21 +2435,21 @@ TEST(EqualsBoundNodeMatcher, Decl) {
 
 TEST(EqualsBoundNodeMatcher, Type) {
   EXPECT_TRUE(matches(
-    "class X { int a; int b; };",
-    recordDecl(
-      has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
-      has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
+      "class X { int a; int b; };",
+      recordDecl(
+          has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
+          has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
 
   EXPECT_TRUE(notMatches(
-    "class X { int a; double b; };",
-    recordDecl(
-      has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
-      has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
+      "class X { int a; double b; };",
+      recordDecl(
+          has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
+          has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))));
 }
 
 TEST(EqualsBoundNodeMatcher, UsingForEachDescendant) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "int f() {"
+      "int f() {"
       "  if (1) {"
       "    int i = 9;"
       "  }"
@@ -2546,63 +2459,65 @@ TEST(EqualsBoundNodeMatcher, UsingForEachDescendant) {
       "  }"
       "  return 0;"
       "}",
-    // Look for variable declarations within functions whose type is the same
-    // as the function return type.
-    functionDecl(returns(qualType().bind("type")),
-                 forEachDescendant(varDecl(hasType(
-                   qualType(equalsBoundNode("type")))).bind("decl"))),
-    // Only i and j should match, not k.
-    std::make_unique>("decl", 2)));
+      // Look for variable declarations within functions whose type is the same
+      // as the function return type.
+      functionDecl(
+          returns(qualType().bind("type")),
+          forEachDescendant(varDecl(hasType(qualType(equalsBoundNode("type"))))
+                                .bind("decl"))),
+      // Only i and j should match, not k.
+      std::make_unique>("decl", 2)));
 }
 
 TEST(EqualsBoundNodeMatcher, FiltersMatchedCombinations) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "void f() {"
+      "void f() {"
       "  int x;"
       "  double d;"
       "  x = d + x - d + x;"
       "}",
-    functionDecl(
-      hasName("f"), forEachDescendant(varDecl().bind("d")),
-      forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))),
-    std::make_unique>("d", 5)));
+      functionDecl(
+          hasName("f"), forEachDescendant(varDecl().bind("d")),
+          forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))),
+      std::make_unique>("d", 5)));
 }
 
 TEST(EqualsBoundNodeMatcher, UnlessDescendantsOfAncestorsMatch) {
   EXPECT_TRUE(matchAndVerifyResultTrue(
-    "struct StringRef { int size() const; const char* data() const; };"
+      "struct StringRef { int size() const; const char* data() const; };"
       "void f(StringRef v) {"
       "  v.data();"
       "}",
-    cxxMemberCallExpr(
-      callee(cxxMethodDecl(hasName("data"))),
-      on(declRefExpr(to(
-        varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
-      unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
-        callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
-        on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
-      .bind("data"),
-    std::make_unique>("data", 1)));
+      cxxMemberCallExpr(
+          callee(cxxMethodDecl(hasName("data"))),
+          on(declRefExpr(to(
+              varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
+          unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
+              callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
+              on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
+          .bind("data"),
+      std::make_unique>("data", 1)));
 
   EXPECT_FALSE(matches(
-    "struct StringRef { int size() const; const char* data() const; };"
+      "struct StringRef { int size() const; const char* data() const; };"
       "void f(StringRef v) {"
       "  v.data();"
       "  v.size();"
       "}",
-    cxxMemberCallExpr(
-      callee(cxxMethodDecl(hasName("data"))),
-      on(declRefExpr(to(
-        varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
-      unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
-        callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
-        on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
-      .bind("data")));
+      cxxMemberCallExpr(
+          callee(cxxMethodDecl(hasName("data"))),
+          on(declRefExpr(to(
+              varDecl(hasType(recordDecl(hasName("StringRef")))).bind("var")))),
+          unless(hasAncestor(stmt(hasDescendant(cxxMemberCallExpr(
+              callee(cxxMethodDecl(anyOf(hasName("size"), hasName("length")))),
+              on(declRefExpr(to(varDecl(equalsBoundNode("var")))))))))))
+          .bind("data")));
 }
 
 TEST(NullPointerConstants, Basic) {
   EXPECT_TRUE(matches("#define NULL ((void *)0)\n"
-                        "void *v1 = NULL;", expr(nullPointerConstant())));
+                      "void *v1 = NULL;",
+                      expr(nullPointerConstant())));
   EXPECT_TRUE(matches("void *v2 = nullptr;", expr(nullPointerConstant())));
   EXPECT_TRUE(matches("void *v3 = __null;", expr(nullPointerConstant())));
   EXPECT_TRUE(matches("char *cp = (char *)0;", expr(nullPointerConstant())));
@@ -2635,10 +2550,10 @@ TEST(HasExternalFormalLinkage, Basic) {
 }
 
 TEST(HasDefaultArgument, Basic) {
-  EXPECT_TRUE(matches("void x(int val = 0) {}",
-                      parmVarDecl(hasDefaultArgument())));
-  EXPECT_TRUE(notMatches("void x(int val) {}",
-                      parmVarDecl(hasDefaultArgument())));
+  EXPECT_TRUE(
+      matches("void x(int val = 0) {}", parmVarDecl(hasDefaultArgument())));
+  EXPECT_TRUE(
+      notMatches("void x(int val) {}", parmVarDecl(hasDefaultArgument())));
 }
 
 TEST(IsAtPosition, Basic) {
@@ -2691,24 +2606,18 @@ TEST(HasArraySize, Basic) {
 }
 
 TEST(HasDefinition, MatchesStructDefinition) {
-  EXPECT_TRUE(matches("struct x {};",
-                      cxxRecordDecl(hasDefinition())));
-  EXPECT_TRUE(notMatches("struct x;",
-                      cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(matches("struct x {};", cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(notMatches("struct x;", cxxRecordDecl(hasDefinition())));
 }
 
 TEST(HasDefinition, MatchesClassDefinition) {
-  EXPECT_TRUE(matches("class x {};",
-                      cxxRecordDecl(hasDefinition())));
-  EXPECT_TRUE(notMatches("class x;",
-                      cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(matches("class x {};", cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(notMatches("class x;", cxxRecordDecl(hasDefinition())));
 }
 
 TEST(HasDefinition, MatchesUnionDefinition) {
-  EXPECT_TRUE(matches("union x {};",
-                      cxxRecordDecl(hasDefinition())));
-  EXPECT_TRUE(notMatches("union x;",
-                      cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(matches("union x {};", cxxRecordDecl(hasDefinition())));
+  EXPECT_TRUE(notMatches("union x;", cxxRecordDecl(hasDefinition())));
 }
 
 TEST(IsScopedEnum, MatchesScopedEnum) {
@@ -2727,19 +2636,19 @@ TEST(HasTrailingReturn, MatchesTrailingReturn) {
   EXPECT_TRUE(matches("auto Y() -> int { return 0; }",
                       functionDecl(hasTrailingReturn())));
   EXPECT_TRUE(matches("auto X() -> int;", functionDecl(hasTrailingReturn())));
-  EXPECT_TRUE(notMatches("int X() { return 0; }",
-                      functionDecl(hasTrailingReturn())));
+  EXPECT_TRUE(
+      notMatches("int X() { return 0; }", functionDecl(hasTrailingReturn())));
   EXPECT_TRUE(notMatches("int X();", functionDecl(hasTrailingReturn())));
   EXPECT_TRUE(notMatchesC("void X();", functionDecl(hasTrailingReturn())));
 }
 
 TEST(HasTrailingReturn, MatchesLambdaTrailingReturn) {
   EXPECT_TRUE(matches(
-          "auto lambda2 = [](double x, double y) -> double {return x + y;};",
-          functionDecl(hasTrailingReturn())));
-  EXPECT_TRUE(notMatches(
-          "auto lambda2 = [](double x, double y) {return x + y;};",
-          functionDecl(hasTrailingReturn())));
+      "auto lambda2 = [](double x, double y) -> double {return x + y;};",
+      functionDecl(hasTrailingReturn())));
+  EXPECT_TRUE(
+      notMatches("auto lambda2 = [](double x, double y) {return x + y;};",
+                 functionDecl(hasTrailingReturn())));
 }
 
 TEST(IsAssignmentOperator, Basic) {
@@ -2772,23 +2681,15 @@ TEST(IsComparisonOperator, Basic) {
 }
 
 TEST(HasInit, Basic) {
-  EXPECT_TRUE(
-    matches("int x{0};",
-            initListExpr(hasInit(0, expr()))));
-  EXPECT_FALSE(
-    matches("int x{0};",
-            initListExpr(hasInit(1, expr()))));
-  EXPECT_FALSE(
-    matches("int x;",
-            initListExpr(hasInit(0, expr()))));
+  EXPECT_TRUE(matches("int x{0};", initListExpr(hasInit(0, expr()))));
+  EXPECT_FALSE(matches("int x{0};", initListExpr(hasInit(1, expr()))));
+  EXPECT_FALSE(matches("int x;", initListExpr(hasInit(0, expr()))));
 }
 
 TEST(Matcher, isMain) {
-  EXPECT_TRUE(
-    matches("int main() {}", functionDecl(isMain())));
+  EXPECT_TRUE(matches("int main() {}", functionDecl(isMain())));
 
-  EXPECT_TRUE(
-    notMatches("int main2() {}", functionDecl(isMain())));
+  EXPECT_TRUE(notMatches("int main2() {}", functionDecl(isMain())));
 }
 
 TEST(OMPExecutableDirective, isStandaloneDirective) {
@@ -2867,11 +2768,18 @@ void x() {
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   StringRef Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  StringRef Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isNoneKind) {
@@ -2907,10 +2815,17 @@ void x() {
 
   StringRef Source4 = R"(
 void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPDefaultClause, isSharedKind) {
@@ -2946,10 +2861,63 @@ void x() {
 
   StringRef Source4 = R"(
 void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+}
+
+TEST(OMPDefaultClause, isFirstPrivateKind) {
+  auto Matcher = ompExecutableDirective(
+      hasAnyClause(ompDefaultClause(isFirstPrivateKind())));
+
+  const std::string Source0 = R"(
+void x() {
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source0, Matcher));
+
+  const std::string Source1 = R"(
+void x() {
+#pragma omp parallel
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source1, Matcher));
+
+  const std::string Source2 = R"(
+void x() {
+#pragma omp parallel default(shared)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source2, Matcher));
+
+  const std::string Source3 = R"(
+void x() {
+#pragma omp parallel default(none)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source3, Matcher));
+
+  const std::string Source4 = R"(
+void x(int x) {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
+void x(int x) {
+#pragma omp parallel num_threads(x)
+;
+})";
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(OMPExecutableDirective, isAllowedToContainClauseKind) {
@@ -2984,24 +2952,31 @@ void x() {
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   StringRef Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  StringRef Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 
-  StringRef Source5 = R"(
+  StringRef Source6 = R"(
 void x() {
 #pragma omp taskyield
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source6, Matcher));
 
-  StringRef Source6 = R"(
+  StringRef Source7 = R"(
 void x() {
 #pragma omp task
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source6, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source7, Matcher));
 }
 
 TEST(HasAnyBase, DirectBase) {

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 59e0f74b3910..895c8ae48adc 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -118,13 +118,13 @@ TEST_P(ASTMatchersTest, TranslationUnitDecl) {
                    "int MyVar2;\n"
                    "}  // namespace NameSpace\n";
   EXPECT_TRUE(matches(
-    Code, varDecl(hasName("MyVar1"), hasDeclContext(translationUnitDecl()))));
+      Code, varDecl(hasName("MyVar1"), hasDeclContext(translationUnitDecl()))));
   EXPECT_FALSE(matches(
-    Code, varDecl(hasName("MyVar2"), hasDeclContext(translationUnitDecl()))));
+      Code, varDecl(hasName("MyVar2"), hasDeclContext(translationUnitDecl()))));
   EXPECT_TRUE(matches(
-    Code,
-    varDecl(hasName("MyVar2"),
-            hasDeclContext(decl(hasDeclContext(translationUnitDecl()))))));
+      Code,
+      varDecl(hasName("MyVar2"),
+              hasDeclContext(decl(hasDeclContext(translationUnitDecl()))))));
 }
 
 TEST_P(ASTMatchersTest, LinkageSpecDecl) {
@@ -158,10 +158,10 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(notMatches("template class X { };"
-                           "template<> class X { int a; };",
-                         classTemplateDecl(hasName("X"),
-                                           hasDescendant(fieldDecl(hasName("a"))))));
+  EXPECT_TRUE(notMatches(
+      "template class X { };"
+      "template<> class X { int a; };",
+      classTemplateDecl(hasName("X"), hasDescendant(fieldDecl(hasName("a"))))));
 }
 
 TEST_P(ASTMatchersTest,
@@ -169,18 +169,17 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(notMatches("template class X { };"
-                           "template class X { int a; };",
-                         classTemplateDecl(hasName("X"),
-                                           hasDescendant(fieldDecl(hasName("a"))))));
+  EXPECT_TRUE(notMatches(
+      "template class X { };"
+      "template class X { int a; };",
+      classTemplateDecl(hasName("X"), hasDescendant(fieldDecl(hasName("a"))))));
 }
 
 TEST(ASTMatchersTestCUDA, CUDAKernelCallExpr) {
   EXPECT_TRUE(matchesWithCuda("__global__ void f() { }"
-                                "void g() { f<<<1, 2>>>(); }",
+                              "void g() { f<<<1, 2>>>(); }",
                               cudaKernelCallExpr()));
-  EXPECT_TRUE(notMatchesWithCuda("void f() {}",
-                                 cudaKernelCallExpr()));
+  EXPECT_TRUE(notMatchesWithCuda("void f() {}", cudaKernelCallExpr()));
 }
 
 TEST(ASTMatchersTestCUDA, HasAttrCUDA) {
@@ -316,56 +315,50 @@ TEST_P(ASTMatchersTest, CallExpr_CXX) {
   // FIXME: Do we want to overload Call() to directly take
   // Matcher, too?
   StatementMatcher MethodX =
-    callExpr(hasDeclaration(cxxMethodDecl(hasName("x"))));
+      callExpr(hasDeclaration(cxxMethodDecl(hasName("x"))));
 
   EXPECT_TRUE(matches("class Y { void x() { x(); } };", MethodX));
   EXPECT_TRUE(notMatches("class Y { void x() {} };", MethodX));
 
   StatementMatcher MethodOnY =
-    cxxMemberCallExpr(on(hasType(recordDecl(hasName("Y")))));
+      cxxMemberCallExpr(on(hasType(recordDecl(hasName("Y")))));
 
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
-               MethodOnY));
-  EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
-               MethodOnY));
-  EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
-               MethodOnY));
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
+                      MethodOnY));
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
+                      MethodOnY));
+  EXPECT_TRUE(notMatches(
+      "class Y { public: void x(); }; void z(Y *&y) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(notMatches(
+      "class Y { public: void x(); }; void z(Y y[]) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(notMatches(
+      "class Y { public: void x(); }; void z() { Y *y; y->x(); }", MethodOnY));
 
   StatementMatcher MethodOnYPointer =
-    cxxMemberCallExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))));
+      cxxMemberCallExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))));
 
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
-            MethodOnYPointer));
+      matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
+              MethodOnYPointer));
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
-            MethodOnYPointer));
+      matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
+              MethodOnYPointer));
   EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
-            MethodOnYPointer));
+      matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
+              MethodOnYPointer));
   EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
-               MethodOnYPointer));
+      notMatches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
+                 MethodOnYPointer));
   EXPECT_TRUE(
-    notMatches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
-               MethodOnYPointer));
+      notMatches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
+                 MethodOnYPointer));
 }
 
 TEST_P(ASTMatchersTest, LambdaExpr) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  EXPECT_TRUE(matches("auto f = [] (int i) { return i; };",
-                      lambdaExpr()));
+  EXPECT_TRUE(matches("auto f = [] (int i) { return i; };", lambdaExpr()));
 }
 
 TEST_P(ASTMatchersTest, CXXForRangeStmt) {
@@ -378,7 +371,7 @@ TEST_P(ASTMatchersTest, CXXForRangeStmt_CXX11) {
     return;
   }
   EXPECT_TRUE(matches("int as[] = { 1, 2, 3 };"
-                        "void f() { for (auto &a : as); }",
+                      "void f() { for (auto &a : as); }",
                       cxxForRangeStmt()));
 }
 
@@ -387,15 +380,13 @@ TEST_P(ASTMatchersTest, SubstNonTypeTemplateParmExpr) {
     return;
   }
   EXPECT_FALSE(matches("template\n"
-                         "struct A {  static const int n = 0; };\n"
-                         "struct B : public A<42> {};",
-                         traverse(TK_AsIs,
-                       substNonTypeTemplateParmExpr())));
+                       "struct A {  static const int n = 0; };\n"
+                       "struct B : public A<42> {};",
+                       traverse(TK_AsIs, substNonTypeTemplateParmExpr())));
   EXPECT_TRUE(matches("template\n"
-                        "struct A {  static const int n = N; };\n"
-                        "struct B : public A<42> {};",
-                         traverse(TK_AsIs,
-                      substNonTypeTemplateParmExpr())));
+                      "struct A {  static const int n = N; };\n"
+                      "struct B : public A<42> {};",
+                      traverse(TK_AsIs, substNonTypeTemplateParmExpr())));
 }
 
 TEST_P(ASTMatchersTest, NonTypeTemplateParmDecl) {
@@ -405,7 +396,7 @@ TEST_P(ASTMatchersTest, NonTypeTemplateParmDecl) {
   EXPECT_TRUE(matches("template  void f();",
                       nonTypeTemplateParmDecl(hasName("N"))));
   EXPECT_TRUE(
-    notMatches("template  void f();", nonTypeTemplateParmDecl()));
+      notMatches("template  void f();", nonTypeTemplateParmDecl()));
 }
 
 TEST_P(ASTMatchersTest, TemplateTypeParmDecl) {
@@ -414,8 +405,7 @@ TEST_P(ASTMatchersTest, TemplateTypeParmDecl) {
   }
   EXPECT_TRUE(matches("template  void f();",
                       templateTypeParmDecl(hasName("T"))));
-  EXPECT_TRUE(
-    notMatches("template  void f();", templateTypeParmDecl()));
+  EXPECT_TRUE(notMatches("template  void f();", templateTypeParmDecl()));
 }
 
 TEST_P(ASTMatchersTest, UserDefinedLiteral) {
@@ -423,9 +413,9 @@ TEST_P(ASTMatchersTest, UserDefinedLiteral) {
     return;
   }
   EXPECT_TRUE(matches("constexpr char operator \"\" _inc (const char i) {"
-                        "  return i + 1;"
-                        "}"
-                        "char c = 'a'_inc;",
+                      "  return i + 1;"
+                      "}"
+                      "char c = 'a'_inc;",
                       userDefinedLiteral()));
 }
 
@@ -434,9 +424,7 @@ TEST_P(ASTMatchersTest, FlowControl) {
   EXPECT_TRUE(matches("void f() { while(1) { continue; } }", continueStmt()));
   EXPECT_TRUE(matches("void f() { goto FOO; FOO: ;}", gotoStmt()));
   EXPECT_TRUE(matches("void f() { goto FOO; FOO: ;}",
-                      labelStmt(
-                        hasDeclaration(
-                          labelDecl(hasName("FOO"))))));
+                      labelStmt(hasDeclaration(labelDecl(hasName("FOO"))))));
   EXPECT_TRUE(matches("void f() { FOO: ; void *ptr = &&FOO; goto *ptr; }",
                       addrLabelExpr()));
   EXPECT_TRUE(matches("void f() { return; }", returnStmt()));
@@ -450,8 +438,9 @@ TEST_P(ASTMatchersTest, CXXOperatorCallExpr) {
   StatementMatcher OpCall = cxxOperatorCallExpr();
   // Unary operator
   EXPECT_TRUE(matches("class Y { }; "
-                        "bool operator!(Y x) { return false; }; "
-                        "Y y; bool c = !y;", OpCall));
+                      "bool operator!(Y x) { return false; }; "
+                      "Y y; bool c = !y;",
+                      OpCall));
   // No match -- special operators like "new", "delete"
   // FIXME: operator new takes size_t, for which we need stddef.h, for which
   // we need to figure out include paths in the test.
@@ -460,12 +449,13 @@ TEST_P(ASTMatchersTest, CXXOperatorCallExpr) {
   //             "void *operator new(size_t size) { return 0; } "
   //             "Y *y = new Y;", OpCall));
   EXPECT_TRUE(notMatches("class Y { }; "
-                           "void operator delete(void *p) { } "
-                           "void a() {Y *y = new Y; delete y;}", OpCall));
+                         "void operator delete(void *p) { } "
+                         "void a() {Y *y = new Y; delete y;}",
+                         OpCall));
   // Binary operator
   EXPECT_TRUE(matches("class Y { }; "
-                        "bool operator&&(Y x, Y y) { return true; }; "
-                        "Y a; Y b; bool c = a && b;",
+                      "bool operator&&(Y x, Y y) { return true; }; "
+                      "Y a; Y b; bool c = a && b;",
                       OpCall));
   // No match -- normal operator, not an overloaded one.
   EXPECT_TRUE(notMatches("bool x = true, y = true; bool t = x && y;", OpCall));
@@ -481,30 +471,25 @@ TEST_P(ASTMatchersTest, ThisPointerType) {
       traverse(ast_type_traits::TK_AsIs,
                cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y")))));
 
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y *&y) { y->x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z(Y y[]) { y->x(); }",
-            MethodOnY));
-  EXPECT_TRUE(
-    matches("class Y { public: void x(); }; void z() { Y *y; y->x(); }",
-            MethodOnY));
-
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z() { Y y; y.x(); }",
+                      MethodOnY));
+  EXPECT_TRUE(matches("class Y { public: void x(); }; void z(Y &y) { y.x(); }",
+                      MethodOnY));
   EXPECT_TRUE(matches(
-    "class Y {"
-      "  public: virtual void x();"
-      "};"
-      "class X : public Y {"
-      "  public: virtual void x();"
-      "};"
-      "void z() { X *x; x->Y::x(); }", MethodOnY));
+      "class Y { public: void x(); }; void z(Y *&y) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(matches(
+      "class Y { public: void x(); }; void z(Y y[]) { y->x(); }", MethodOnY));
+  EXPECT_TRUE(matches(
+      "class Y { public: void x(); }; void z() { Y *y; y->x(); }", MethodOnY));
+
+  EXPECT_TRUE(matches("class Y {"
+                      "  public: virtual void x();"
+                      "};"
+                      "class X : public Y {"
+                      "  public: virtual void x();"
+                      "};"
+                      "void z() { X *x; x->Y::x(); }",
+                      MethodOnY));
 }
 
 TEST_P(ASTMatchersTest, DeclRefExpr) {
@@ -512,29 +497,27 @@ TEST_P(ASTMatchersTest, DeclRefExpr) {
     // FIXME: Add a test for `declRefExpr()` that does not depend on C++.
     return;
   }
-  StatementMatcher Reference =
-    declRefExpr(to(
-      varDecl(hasInitializer(
-        cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y"))))))));
+  StatementMatcher Reference = declRefExpr(to(varDecl(hasInitializer(
+      cxxMemberCallExpr(thisPointerType(recordDecl(hasName("Y"))))))));
 
-  EXPECT_TRUE(matches(
-    "class Y {"
-      " public:"
-      "  bool x() const;"
-      "};"
-      "void z(const Y &y) {"
-      "  bool b = y.x();"
-      "  if (b) {}"
-      "}", Reference));
+  EXPECT_TRUE(matches("class Y {"
+                      " public:"
+                      "  bool x() const;"
+                      "};"
+                      "void z(const Y &y) {"
+                      "  bool b = y.x();"
+                      "  if (b) {}"
+                      "}",
+                      Reference));
 
-  EXPECT_TRUE(notMatches(
-    "class Y {"
-      " public:"
-      "  bool x() const;"
-      "};"
-      "void z(const Y &y) {"
-      "  bool b = y.x();"
-      "}", Reference));
+  EXPECT_TRUE(notMatches("class Y {"
+                         " public:"
+                         "  bool x() const;"
+                         "};"
+                         "void z(const Y &y) {"
+                         "  bool b = y.x();"
+                         "}",
+                         Reference));
 }
 
 TEST_P(ASTMatchersTest, CXXMemberCallExpr) {
@@ -542,32 +525,32 @@ TEST_P(ASTMatchersTest, CXXMemberCallExpr) {
     return;
   }
   StatementMatcher CallOnVariableY =
-    cxxMemberCallExpr(on(declRefExpr(to(varDecl(hasName("y"))))));
-
-  EXPECT_TRUE(matches(
-    "class Y { public: void x() { Y y; y.x(); } };", CallOnVariableY));
-  EXPECT_TRUE(matches(
-    "class Y { public: void x() const { Y y; y.x(); } };", CallOnVariableY));
-  EXPECT_TRUE(matches(
-    "class Y { public: void x(); };"
-      "class X : public Y { void z() { X y; y.x(); } };", CallOnVariableY));
-  EXPECT_TRUE(matches(
-    "class Y { public: void x(); };"
-      "class X : public Y { void z() { X *y; y->x(); } };", CallOnVariableY));
+      cxxMemberCallExpr(on(declRefExpr(to(varDecl(hasName("y"))))));
+
+  EXPECT_TRUE(matches("class Y { public: void x() { Y y; y.x(); } };",
+                      CallOnVariableY));
+  EXPECT_TRUE(matches("class Y { public: void x() const { Y y; y.x(); } };",
+                      CallOnVariableY));
+  EXPECT_TRUE(matches("class Y { public: void x(); };"
+                      "class X : public Y { void z() { X y; y.x(); } };",
+                      CallOnVariableY));
+  EXPECT_TRUE(matches("class Y { public: void x(); };"
+                      "class X : public Y { void z() { X *y; y->x(); } };",
+                      CallOnVariableY));
   EXPECT_TRUE(notMatches(
-    "class Y { public: void x(); };"
+      "class Y { public: void x(); };"
       "class X : public Y { void z() { unsigned long y; ((X*)y)->x(); } };",
-    CallOnVariableY));
+      CallOnVariableY));
 }
 
 TEST_P(ASTMatchersTest, UnaryExprOrTypeTraitExpr) {
-  EXPECT_TRUE(matches("void x() { int a = sizeof(a); }",
-                      unaryExprOrTypeTraitExpr()));
+  EXPECT_TRUE(
+      matches("void x() { int a = sizeof(a); }", unaryExprOrTypeTraitExpr()));
 }
 
 TEST_P(ASTMatchersTest, AlignOfExpr) {
-  EXPECT_TRUE(notMatches("void x() { int a = sizeof(a); }",
-                         alignOfExpr(anything())));
+  EXPECT_TRUE(
+      notMatches("void x() { int a = sizeof(a); }", alignOfExpr(anything())));
   // FIXME: Uncomment once alignof is enabled.
   // EXPECT_TRUE(matches("void x() { int a = alignof(a); }",
   //                     unaryExprOrTypeTraitExpr()));
@@ -603,11 +586,10 @@ TEST_P(ASTMatchersTest, MemberExpr_MatchesVariable) {
     return;
   }
   EXPECT_TRUE(
-    matches("class Y { void x() { this->y; } int y; };", memberExpr()));
-  EXPECT_TRUE(
-    matches("class Y { void x() { y; } int y; };", memberExpr()));
+      matches("class Y { void x() { this->y; } int y; };", memberExpr()));
+  EXPECT_TRUE(matches("class Y { void x() { y; } int y; };", memberExpr()));
   EXPECT_TRUE(
-    matches("class Y { void x() { Y y; y.y; } int y; };", memberExpr()));
+      matches("class Y { void x() { Y y; y.y; } int y; };", memberExpr()));
   EXPECT_TRUE(matches("template "
                       "class X : T { void f() { this->T::v; } };",
                       cxxDependentScopeMemberExpr()));
@@ -623,8 +605,8 @@ TEST_P(ASTMatchersTest, MemberExpr_MatchesStaticVariable) {
   }
   EXPECT_TRUE(matches("class Y { void x() { this->y; } static int y; };",
                       memberExpr()));
-  EXPECT_TRUE(notMatches("class Y { void x() { y; } static int y; };",
-                         memberExpr()));
+  EXPECT_TRUE(
+      notMatches("class Y { void x() { y; } static int y; };", memberExpr()));
   EXPECT_TRUE(notMatches("class Y { void x() { Y::y; } static int y; };",
                          memberExpr()));
 }
@@ -658,21 +640,21 @@ TEST_P(ASTMatchersTest, FunctionDecl_CXX) {
   if (!GetParam().hasDelayedTemplateParsing()) {
     // FIXME: Fix this test to work with delayed template parsing.
     // Dependent contexts, but a non-dependent call.
-    EXPECT_TRUE(matches("void f(); template  void g() { f(); }",
-                        CallFunctionF));
     EXPECT_TRUE(
-      matches("void f(); template  struct S { void g() { f(); } };",
-              CallFunctionF));
+        matches("void f(); template  void g() { f(); }", CallFunctionF));
+    EXPECT_TRUE(
+        matches("void f(); template  struct S { void g() { f(); } };",
+                CallFunctionF));
   }
 
   // Depedent calls don't match.
   EXPECT_TRUE(
-    notMatches("void f(int); template  void g(T t) { f(t); }",
-               CallFunctionF));
+      notMatches("void f(int); template  void g(T t) { f(t); }",
+                 CallFunctionF));
   EXPECT_TRUE(
-    notMatches("void f(int);"
+      notMatches("void f(int);"
                  "template  struct S { void g(T t) { f(t); } };",
-               CallFunctionF));
+                 CallFunctionF));
 
   EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic())));
   EXPECT_TRUE(matches("void f(...);", functionDecl(parameterCountIs(0))));
@@ -692,9 +674,8 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(
-    matches("template  void f(T t) {}",
-            functionTemplateDecl(hasName("f"))));
+  EXPECT_TRUE(matches("template  void f(T t) {}",
+                      functionTemplateDecl(hasName("f"))));
 }
 
 TEST_P(ASTMatchersTest, FunctionTemplate_DoesNotMatchFunctionDeclarations) {
@@ -709,12 +690,11 @@ TEST_P(ASTMatchersTest,
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(
-    notMatches("void g(); template  void f(T t) {}"
-                 "template <> void f(int t) { g(); }",
-               functionTemplateDecl(hasName("f"),
-                                    hasDescendant(declRefExpr(to(
-                                      functionDecl(hasName("g"))))))));
+  EXPECT_TRUE(notMatches(
+      "void g(); template  void f(T t) {}"
+      "template <> void f(int t) { g(); }",
+      functionTemplateDecl(hasName("f"), hasDescendant(declRefExpr(to(
+                                             functionDecl(hasName("g"))))))));
 }
 
 TEST_P(ASTMatchersTest, ClassTemplateSpecializationDecl) {
@@ -722,7 +702,7 @@ TEST_P(ASTMatchersTest, ClassTemplateSpecializationDecl) {
     return;
   }
   EXPECT_TRUE(matches("template struct A {};"
-                        "template<> struct A {};",
+                      "template<> struct A {};",
                       classTemplateSpecializationDecl()));
   EXPECT_TRUE(matches("template struct A {}; A a;",
                       classTemplateSpecializationDecl()));
@@ -756,13 +736,11 @@ TEST_P(ASTMatchersTest, Matcher_ConstructorCall) {
       traverse(ast_type_traits::TK_AsIs, cxxConstructExpr());
 
   EXPECT_TRUE(
-    matches("class X { public: X(); }; void x() { X x; }", Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(); }; void x() { X x = X(); }",
-            Constructor));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { X x = 0; }",
-            Constructor));
+      matches("class X { public: X(); }; void x() { X x; }", Constructor));
+  EXPECT_TRUE(matches("class X { public: X(); }; void x() { X x = X(); }",
+                      Constructor));
+  EXPECT_TRUE(matches("class X { public: X(int); }; void x() { X x = 0; }",
+                      Constructor));
   EXPECT_TRUE(matches("class X {}; void x(int) { X x; }", Constructor));
 }
 
@@ -779,9 +757,9 @@ TEST_P(ASTMatchersTest, Matcher_ThisExpr) {
     return;
   }
   EXPECT_TRUE(
-    matches("struct X { int a; int f () { return a; } };", cxxThisExpr()));
+      matches("struct X { int a; int f () { return a; } };", cxxThisExpr()));
   EXPECT_TRUE(
-    notMatches("struct X { int f () { int a; return a; } };", cxxThisExpr()));
+      notMatches("struct X { int f () { int a; return a; } };", cxxThisExpr()));
 }
 
 TEST_P(ASTMatchersTest, Matcher_BindTemporaryExpression) {
@@ -794,30 +772,27 @@ TEST_P(ASTMatchersTest, Matcher_BindTemporaryExpression) {
 
   StringRef ClassString = "class string { public: string(); ~string(); }; ";
 
-  EXPECT_TRUE(
-    matches(ClassString +
-              "string GetStringByValue();"
-                "void FunctionTakesString(string s);"
-                "void run() { FunctionTakesString(GetStringByValue()); }",
-            TempExpression));
+  EXPECT_TRUE(matches(
+      ClassString + "string GetStringByValue();"
+                    "void FunctionTakesString(string s);"
+                    "void run() { FunctionTakesString(GetStringByValue()); }",
+      TempExpression));
 
-  EXPECT_TRUE(
-    notMatches(ClassString +
-                 "string* GetStringPointer(); "
-                   "void FunctionTakesStringPtr(string* s);"
-                   "void run() {"
-                   "  string* s = GetStringPointer();"
-                   "  FunctionTakesStringPtr(GetStringPointer());"
-                   "  FunctionTakesStringPtr(s);"
-                   "}",
-               TempExpression));
+  EXPECT_TRUE(notMatches(ClassString +
+                             "string* GetStringPointer(); "
+                             "void FunctionTakesStringPtr(string* s);"
+                             "void run() {"
+                             "  string* s = GetStringPointer();"
+                             "  FunctionTakesStringPtr(GetStringPointer());"
+                             "  FunctionTakesStringPtr(s);"
+                             "}",
+                         TempExpression));
 
-  EXPECT_TRUE(
-    notMatches("class no_dtor {};"
-                 "no_dtor GetObjByValue();"
-                 "void ConsumeObj(no_dtor param);"
-                 "void run() { ConsumeObj(GetObjByValue()); }",
-               TempExpression));
+  EXPECT_TRUE(notMatches("class no_dtor {};"
+                         "no_dtor GetObjByValue();"
+                         "void ConsumeObj(no_dtor param);"
+                         "void run() { ConsumeObj(GetObjByValue()); }",
+                         TempExpression));
 }
 
 TEST_P(ASTMatchersTest, MaterializeTemporaryExpr_MatchesTemporaryCXX11CXX14) {
@@ -872,10 +847,9 @@ TEST_P(ASTMatchersTest, Matcher_NewExpression) {
   StatementMatcher New = cxxNewExpr();
 
   EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X; }", New));
+  EXPECT_TRUE(matches("class X { public: X(); }; void x() { new X(); }", New));
   EXPECT_TRUE(
-    matches("class X { public: X(); }; void x() { new X(); }", New));
-  EXPECT_TRUE(
-    matches("class X { public: X(int); }; void x() { new X(0); }", New));
+      matches("class X { public: X(int); }; void x() { new X(0); }", New));
   EXPECT_TRUE(matches("class X {}; void x(int) { new X; }", New));
 }
 
@@ -883,8 +857,8 @@ TEST_P(ASTMatchersTest, Matcher_DeleteExpression) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("struct A {}; void f(A* a) { delete a; }",
-                      cxxDeleteExpr()));
+  EXPECT_TRUE(
+      matches("struct A {}; void f(A* a) { delete a; }", cxxDeleteExpr()));
 }
 
 TEST_P(ASTMatchersTest, Matcher_NoexceptExpression) {
@@ -907,7 +881,7 @@ TEST_P(ASTMatchersTest, Matcher_DefaultArgument) {
   StatementMatcher Arg = cxxDefaultArgExpr();
   EXPECT_TRUE(matches("void x(int, int = 0) { int y; x(y); }", Arg));
   EXPECT_TRUE(
-    matches("class X { void x(int, int = 0) { int y; x(y); } };", Arg));
+      matches("class X { void x(int, int = 0) { int y; x(y); } };", Arg));
   EXPECT_TRUE(notMatches("void x(int, int = 0) { int y; x(y, 0); }", Arg));
 }
 
@@ -951,7 +925,7 @@ TEST_P(ASTMatchersTest, IntegerLiteral) {
 
   // Non-matching cases (character literals, float and double)
   EXPECT_TRUE(notMatches("int i = L'a';",
-                         HasIntLiteral));  // this is actually a character
+                         HasIntLiteral)); // this is actually a character
   // literal cast to int
   EXPECT_TRUE(notMatches("int i = 'a';", HasIntLiteral));
   EXPECT_TRUE(notMatches("int i = 1e10;", HasIntLiteral));
@@ -974,13 +948,13 @@ TEST_P(ASTMatchersTest, FloatLiteral) {
   EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0))));
   EXPECT_TRUE(matches("double i = 5.0;", floatLiteral(equals(5.0f))));
   EXPECT_TRUE(
-    matches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(5.0)))));
+      matches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(5.0)))));
 
   EXPECT_TRUE(notMatches("float i = 10;", HasFloatLiteral));
   EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0))));
   EXPECT_TRUE(notMatches("double i = 5.0;", floatLiteral(equals(6.0f))));
   EXPECT_TRUE(
-    notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0)))));
+      notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0)))));
 }
 
 TEST_P(ASTMatchersTest, CXXNullPtrLiteralExpr) {
@@ -1051,9 +1025,9 @@ TEST_P(ASTMatchersTest, ParenListExpr) {
     return;
   }
   EXPECT_TRUE(
-    matches("template class foo { void bar() { foo X(*this); } };"
+      matches("template class foo { void bar() { foo X(*this); } };"
               "template class foo;",
-            varDecl(hasInitializer(parenListExpr(has(unaryOperator()))))));
+              varDecl(hasInitializer(parenListExpr(has(unaryOperator()))))));
 }
 
 TEST_P(ASTMatchersTest, StmtExpr) {
@@ -1064,9 +1038,8 @@ TEST_P(ASTMatchersTest, StmtExpr) {
 TEST_P(ASTMatchersTest, PredefinedExpr) {
   // __func__ expands as StringLiteral("foo")
   EXPECT_TRUE(matches("void foo() { __func__; }",
-                      predefinedExpr(
-                        hasType(asString("const char [4]")),
-                        has(stringLiteral()))));
+                      predefinedExpr(hasType(asString("const char [4]")),
+                                     has(stringLiteral()))));
 }
 
 TEST_P(ASTMatchersTest, AsmStatement) {
@@ -1080,7 +1053,7 @@ TEST_P(ASTMatchersTest, HasCondition) {
   }
 
   StatementMatcher Condition =
-    ifStmt(hasCondition(cxxBoolLiteral(equals(true))));
+      ifStmt(hasCondition(cxxBoolLiteral(equals(true))));
 
   EXPECT_TRUE(matches("void x() { if (true) {} }", Condition));
   EXPECT_TRUE(notMatches("void x() { if (false) {} }", Condition));
@@ -1096,24 +1069,24 @@ TEST_P(ASTMatchersTest, ConditionalOperator) {
     return;
   }
 
-  StatementMatcher Conditional = conditionalOperator(
-    hasCondition(cxxBoolLiteral(equals(true))),
-    hasTrueExpression(cxxBoolLiteral(equals(false))));
+  StatementMatcher Conditional =
+      conditionalOperator(hasCondition(cxxBoolLiteral(equals(true))),
+                          hasTrueExpression(cxxBoolLiteral(equals(false))));
 
   EXPECT_TRUE(matches("void x() { true ? false : true; }", Conditional));
   EXPECT_TRUE(notMatches("void x() { false ? false : true; }", Conditional));
   EXPECT_TRUE(notMatches("void x() { true ? true : false; }", Conditional));
 
-  StatementMatcher ConditionalFalse = conditionalOperator(
-    hasFalseExpression(cxxBoolLiteral(equals(false))));
+  StatementMatcher ConditionalFalse =
+      conditionalOperator(hasFalseExpression(cxxBoolLiteral(equals(false))));
 
   EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
   EXPECT_TRUE(
-    notMatches("void x() { true ? false : true; }", ConditionalFalse));
+      notMatches("void x() { true ? false : true; }", ConditionalFalse));
 
   EXPECT_TRUE(matches("void x() { true ? true : false; }", ConditionalFalse));
   EXPECT_TRUE(
-    notMatches("void x() { true ? false : true; }", ConditionalFalse));
+      notMatches("void x() { true ? false : true; }", ConditionalFalse));
 }
 
 TEST_P(ASTMatchersTest, BinaryConditionalOperator) {
@@ -1132,18 +1105,17 @@ TEST_P(ASTMatchersTest, BinaryConditionalOperator) {
   EXPECT_TRUE(matches("void x() { 1 ?: 0; }", AlwaysOne));
 
   StatementMatcher FourNotFive = binaryConditionalOperator(
-    hasTrueExpression(opaqueValueExpr(
-      hasSourceExpression((integerLiteral(equals(4)))))),
-    hasFalseExpression(integerLiteral(equals(5))));
+      hasTrueExpression(
+          opaqueValueExpr(hasSourceExpression((integerLiteral(equals(4)))))),
+      hasFalseExpression(integerLiteral(equals(5))));
 
   EXPECT_TRUE(matches("void x() { 4 ?: 5; }", FourNotFive));
 }
 
 TEST_P(ASTMatchersTest, ArraySubscriptExpr) {
-  EXPECT_TRUE(matches("int i[2]; void f() { i[1] = 1; }",
-                      arraySubscriptExpr()));
-  EXPECT_TRUE(notMatches("int i; void f() { i = 1; }",
-                         arraySubscriptExpr()));
+  EXPECT_TRUE(
+      matches("int i[2]; void f() { i[1] = 1; }", arraySubscriptExpr()));
+  EXPECT_TRUE(notMatches("int i; void f() { i = 1; }", arraySubscriptExpr()));
 }
 
 TEST_P(ASTMatchersTest, ForStmt) {
@@ -1178,10 +1150,9 @@ TEST_P(ASTMatchersTest, CompoundStatement_DoesNotMatchEmptyStruct) {
   }
   // It's not a compound statement just because there's "{}" in the source
   // text. This is an AST search, not grep.
-  EXPECT_TRUE(notMatches("namespace n { struct S {}; }",
-                         compoundStmt()));
-  EXPECT_TRUE(matches("namespace n { struct S { void f() {{}} }; }",
-                      compoundStmt()));
+  EXPECT_TRUE(notMatches("namespace n { struct S {}; }", compoundStmt()));
+  EXPECT_TRUE(
+      matches("namespace n { struct S { void f() {{}} }; }", compoundStmt()));
 }
 
 TEST_P(ASTMatchersTest, CastExpr_MatchesExplicitCasts) {
@@ -1242,8 +1213,8 @@ TEST_P(ASTMatchersTest, CXXReinterpretCastExpr_DoesNotMatchOtherCasts) {
   EXPECT_TRUE(notMatches("void* p = static_cast(&p);",
                          cxxReinterpretCastExpr()));
   EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
-                           "B b;"
-                           "D* p = dynamic_cast(&b);",
+                         "B b;"
+                         "D* p = dynamic_cast(&b);",
                          cxxReinterpretCastExpr()));
 }
 
@@ -1262,11 +1233,10 @@ TEST_P(ASTMatchersTest, CXXFunctionalCastExpr_DoesNotMatchOtherCasts) {
   }
   StringRef FooClass = "class Foo { public: Foo(const char*); };";
   EXPECT_TRUE(
-    notMatches(FooClass + "void r() { Foo f = (Foo) \"hello world\"; }",
-               cxxFunctionalCastExpr()));
-  EXPECT_TRUE(
-    notMatches(FooClass + "void r() { Foo f = \"hello world\"; }",
-               cxxFunctionalCastExpr()));
+      notMatches(FooClass + "void r() { Foo f = (Foo) \"hello world\"; }",
+                 cxxFunctionalCastExpr()));
+  EXPECT_TRUE(notMatches(FooClass + "void r() { Foo f = \"hello world\"; }",
+                         cxxFunctionalCastExpr()));
 }
 
 TEST_P(ASTMatchersTest, CXXDynamicCastExpr) {
@@ -1274,8 +1244,8 @@ TEST_P(ASTMatchersTest, CXXDynamicCastExpr) {
     return;
   }
   EXPECT_TRUE(matches("struct B { virtual ~B() {} }; struct D : B {};"
-                        "B b;"
-                        "D* p = dynamic_cast(&b);",
+                      "B b;"
+                      "D* p = dynamic_cast(&b);",
                       cxxDynamicCastExpr()));
 }
 
@@ -1283,8 +1253,7 @@ TEST_P(ASTMatchersTest, CXXStaticCastExpr_MatchesSimpleCase) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("void* p(static_cast(&p));",
-                      cxxStaticCastExpr()));
+  EXPECT_TRUE(matches("void* p(static_cast(&p));", cxxStaticCastExpr()));
 }
 
 TEST_P(ASTMatchersTest, CXXStaticCastExpr_DoesNotMatchOtherCasts) {
@@ -1292,13 +1261,13 @@ TEST_P(ASTMatchersTest, CXXStaticCastExpr_DoesNotMatchOtherCasts) {
     return;
   }
   EXPECT_TRUE(notMatches("char* p = (char*)(&p);", cxxStaticCastExpr()));
-  EXPECT_TRUE(notMatches("char q, *p = const_cast(&q);",
-                         cxxStaticCastExpr()));
+  EXPECT_TRUE(
+      notMatches("char q, *p = const_cast(&q);", cxxStaticCastExpr()));
   EXPECT_TRUE(notMatches("void* p = reinterpret_cast(&p);",
                          cxxStaticCastExpr()));
   EXPECT_TRUE(notMatches("struct B { virtual ~B() {} }; struct D : B {};"
-                           "B b;"
-                           "D* p = dynamic_cast(&b);",
+                         "B b;"
+                         "D* p = dynamic_cast(&b);",
                          cxxStaticCastExpr()));
 }
 
@@ -1311,11 +1280,11 @@ TEST_P(ASTMatchersTest, CStyleCastExpr_DoesNotMatchOtherCasts) {
     return;
   }
   EXPECT_TRUE(notMatches("char* p = static_cast(0);"
-                           "char q, *r = const_cast(&q);"
-                           "void* s = reinterpret_cast(&s);"
-                           "struct B { virtual ~B() {} }; struct D : B {};"
-                           "B b;"
-                           "D* t = dynamic_cast(&b);",
+                         "char q, *r = const_cast(&q);"
+                         "void* s = reinterpret_cast(&s);"
+                         "struct B { virtual ~B() {} }; struct D : B {};"
+                         "B b;"
+                         "D* t = dynamic_cast(&b);",
                          cStyleCastExpr()));
 }
 
@@ -1335,12 +1304,12 @@ TEST_P(ASTMatchersTest, ImplicitCastExpr_MatchesSimpleCase) {
 }
 
 TEST_P(ASTMatchersTest, ImplicitCastExpr_DoesNotMatchIncorrectly) {
-  // This test verifies that implicitCastExpr() matches exactly when implicit casts
-  // are present, and that it ignores explicit and paren casts.
+  // This test verifies that implicitCastExpr() matches exactly when implicit
+  // casts are present, and that it ignores explicit and paren casts.
 
   // These two test cases have no casts.
-  EXPECT_TRUE(notMatches("int x = 0;",
-                         varDecl(hasInitializer(implicitCastExpr()))));
+  EXPECT_TRUE(
+      notMatches("int x = 0;", varDecl(hasInitializer(implicitCastExpr()))));
   EXPECT_TRUE(
       notMatches("int x = (0);", varDecl(hasInitializer(implicitCastExpr()))));
   EXPECT_TRUE(notMatches("void f() { int x = 0; double d = (double) x; }",
@@ -1393,7 +1362,7 @@ TEST_P(ASTMatchersTest, InitListExpr) {
   EXPECT_TRUE(matches("struct B { int x, y; }; struct B b = { 5, 6 };",
                       initListExpr(hasType(recordDecl(hasName("B"))))));
   EXPECT_TRUE(
-    matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42))));
+      matches("int i[1] = {42, [0] = 43};", integerLiteral(equals(42))));
 }
 
 TEST_P(ASTMatchersTest, InitListExpr_CXX) {
@@ -1441,8 +1410,7 @@ TEST_P(ASTMatchersTest, UsingDecl_MatchesUsingDeclarations) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("namespace X { int x; } using X::x;",
-                      usingDecl()));
+  EXPECT_TRUE(matches("namespace X { int x; } using X::x;", usingDecl()));
 }
 
 TEST_P(ASTMatchersTest, UsingDecl_MatchesShadowUsingDelcarations) {
@@ -1460,7 +1428,7 @@ TEST_P(ASTMatchersTest, UsingDirectiveDecl_MatchesUsingNamespace) {
   EXPECT_TRUE(matches("namespace X { int x; } using namespace X;",
                       usingDirectiveDecl()));
   EXPECT_FALSE(
-    matches("namespace X { int x; } using X::x;", usingDirectiveDecl()));
+      matches("namespace X { int x; } using X::x;", usingDirectiveDecl()));
 }
 
 TEST_P(ASTMatchersTest, WhileStmt) {
@@ -1499,11 +1467,11 @@ TEST_P(ASTMatchersTest, CxxExceptionHandling_SimpleCases) {
   EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", cxxCatchStmt()));
   EXPECT_TRUE(matches("void foo() try { } catch(int X) { }", cxxTryStmt()));
   EXPECT_TRUE(
-    notMatches("void foo() try { } catch(int X) { }", cxxThrowExpr()));
-  EXPECT_TRUE(matches("void foo() try { throw; } catch(int X) { }",
-                      cxxThrowExpr()));
-  EXPECT_TRUE(matches("void foo() try { throw 5;} catch(int X) { }",
-                      cxxThrowExpr()));
+      notMatches("void foo() try { } catch(int X) { }", cxxThrowExpr()));
+  EXPECT_TRUE(
+      matches("void foo() try { throw; } catch(int X) { }", cxxThrowExpr()));
+  EXPECT_TRUE(
+      matches("void foo() try { throw 5;} catch(int X) { }", cxxThrowExpr()));
   EXPECT_TRUE(matches("void foo() try { throw; } catch(...) { }",
                       cxxCatchStmt(isCatchAll())));
   EXPECT_TRUE(notMatches("void foo() try { throw; } catch(int) { }",
@@ -1542,9 +1510,8 @@ TEST_P(ASTMatchersTest, QualType) {
 
 TEST_P(ASTMatchersTest, ConstantArrayType) {
   EXPECT_TRUE(matches("int a[2];", constantArrayType()));
-  EXPECT_TRUE(notMatches(
-    "void f() { int a[] = { 2, 3 }; int b[a[0]]; }",
-    constantArrayType(hasElementType(builtinType()))));
+  EXPECT_TRUE(notMatches("void f() { int a[] = { 2, 3 }; int b[a[0]]; }",
+                         constantArrayType(hasElementType(builtinType()))));
 
   EXPECT_TRUE(matches("int a[42];", constantArrayType(hasSize(42))));
   EXPECT_TRUE(matches("int b[2*21];", constantArrayType(hasSize(42))));
@@ -1555,12 +1522,12 @@ TEST_P(ASTMatchersTest, DependentSizedArrayType) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches(
-    "template  class array { T data[Size]; };",
-    dependentSizedArrayType()));
-  EXPECT_TRUE(notMatches(
-    "int a[42]; int b[] = { 2, 3 }; void f() { int c[b[0]]; }",
-    dependentSizedArrayType()));
+  EXPECT_TRUE(
+      matches("template  class array { T data[Size]; };",
+              dependentSizedArrayType()));
+  EXPECT_TRUE(
+      notMatches("int a[42]; int b[] = { 2, 3 }; void f() { int c[b[0]]; }",
+                 dependentSizedArrayType()));
 }
 
 TEST_P(ASTMatchersTest, IncompleteArrayType) {
@@ -1575,22 +1542,21 @@ TEST_P(ASTMatchersTest, VariableArrayType) {
   EXPECT_TRUE(matches("void f(int b) { int a[b]; }", variableArrayType()));
   EXPECT_TRUE(notMatches("int a[] = {2, 3}; int b[42];", variableArrayType()));
 
-  EXPECT_TRUE(matches(
-    "void f(int b) { int a[b]; }",
-    variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
-      varDecl(hasName("b")))))))));
+  EXPECT_TRUE(matches("void f(int b) { int a[b]; }",
+                      variableArrayType(hasSizeExpr(ignoringImpCasts(
+                          declRefExpr(to(varDecl(hasName("b")))))))));
 }
 
 TEST_P(ASTMatchersTest, AtomicType) {
   if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).getOS() !=
-    llvm::Triple::Win32) {
+      llvm::Triple::Win32) {
     // FIXME: Make this work for MSVC.
     EXPECT_TRUE(matches("_Atomic(int) i;", atomicType()));
 
-    EXPECT_TRUE(matches("_Atomic(int) i;",
-                        atomicType(hasValueType(isInteger()))));
-    EXPECT_TRUE(notMatches("_Atomic(float) f;",
-                           atomicType(hasValueType(isInteger()))));
+    EXPECT_TRUE(
+        matches("_Atomic(int) i;", atomicType(hasValueType(isInteger()))));
+    EXPECT_TRUE(
+        notMatches("_Atomic(float) f;", atomicType(hasValueType(isInteger()))));
   }
 }
 
@@ -1608,9 +1574,9 @@ TEST_P(ASTMatchersTest, AutoType) {
 
   // FIXME: Matching against the type-as-written can't work here, because the
   //        type as written was not deduced.
-  //EXPECT_TRUE(matches("auto a = 1;",
+  // EXPECT_TRUE(matches("auto a = 1;",
   //                    autoType(hasDeducedType(isInteger()))));
-  //EXPECT_TRUE(notMatches("auto b = 2.0;",
+  // EXPECT_TRUE(notMatches("auto b = 2.0;",
   //                       autoType(hasDeducedType(isInteger()))));
 }
 
@@ -1657,48 +1623,43 @@ TEST_P(ASTMatchersTest, FunctionProtoType_CXX) {
 
 TEST_P(ASTMatchersTest, ParenType) {
   EXPECT_TRUE(
-    matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType())))));
+      matches("int (*array)[4];", varDecl(hasType(pointsTo(parenType())))));
   EXPECT_TRUE(notMatches("int *array[4];", varDecl(hasType(parenType()))));
 
   EXPECT_TRUE(matches(
-    "int (*ptr_to_func)(int);",
-    varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
+      "int (*ptr_to_func)(int);",
+      varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
   EXPECT_TRUE(notMatches(
-    "int (*ptr_to_array)[4];",
-    varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
+      "int (*ptr_to_array)[4];",
+      varDecl(hasType(pointsTo(parenType(innerType(functionType())))))));
 }
 
 TEST_P(ASTMatchersTest, PointerType) {
   // FIXME: Reactive when these tests can be more specific (not matching
   // implicit code on certain platforms), likely when we have hasDescendant for
   // Types/TypeLocs.
-  //EXPECT_TRUE(matchAndVerifyResultTrue(
+  // EXPECT_TRUE(matchAndVerifyResultTrue(
   //    "int* a;",
   //    pointerTypeLoc(pointeeLoc(typeLoc().bind("loc"))),
   //    std::make_unique>("loc", 1)));
-  //EXPECT_TRUE(matchAndVerifyResultTrue(
+  // EXPECT_TRUE(matchAndVerifyResultTrue(
   //    "int* a;",
   //    pointerTypeLoc().bind("loc"),
   //    std::make_unique>("loc", 1)));
-  EXPECT_TRUE(matches(
-    "int** a;",
-    loc(pointerType(pointee(qualType())))));
-  EXPECT_TRUE(matches(
-    "int** a;",
-    loc(pointerType(pointee(pointerType())))));
-  EXPECT_TRUE(matches(
-    "int* b; int* * const a = &b;",
-    loc(qualType(isConstQualified(), pointerType()))));
+  EXPECT_TRUE(matches("int** a;", loc(pointerType(pointee(qualType())))));
+  EXPECT_TRUE(matches("int** a;", loc(pointerType(pointee(pointerType())))));
+  EXPECT_TRUE(matches("int* b; int* * const a = &b;",
+                      loc(qualType(isConstQualified(), pointerType()))));
 
   StringRef Fragment = "int *ptr;";
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
-                                           hasType(blockPointerType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
-                                           hasType(memberPointerType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("ptr"),
-                                        hasType(pointerType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("ptr"),
-                                           hasType(referenceType()))));
+  EXPECT_TRUE(notMatches(Fragment,
+                         varDecl(hasName("ptr"), hasType(blockPointerType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("ptr"), hasType(memberPointerType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("ptr"), hasType(pointerType()))));
+  EXPECT_TRUE(
+      notMatches(Fragment, varDecl(hasName("ptr"), hasType(referenceType()))));
 }
 
 TEST_P(ASTMatchersTest, PointerType_CXX) {
@@ -1763,28 +1724,28 @@ TEST_P(ASTMatchersTest, AutoRefTypes) {
                        "auto &c = a;"
                        "auto &&d = c;"
                        "auto &&e = 2;";
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("a"),
-                                           hasType(referenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("b"),
-                                           hasType(referenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
-                                        hasType(referenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("c"),
-                                        hasType(lValueReferenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("c"),
-                                           hasType(rValueReferenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
-                                        hasType(referenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("d"),
-                                        hasType(lValueReferenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("d"),
-                                           hasType(rValueReferenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("e"),
-                                        hasType(referenceType()))));
-  EXPECT_TRUE(notMatches(Fragment, varDecl(hasName("e"),
-                                           hasType(lValueReferenceType()))));
-  EXPECT_TRUE(matches(Fragment, varDecl(hasName("e"),
-                                        hasType(rValueReferenceType()))));
+  EXPECT_TRUE(
+      notMatches(Fragment, varDecl(hasName("a"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      notMatches(Fragment, varDecl(hasName("b"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("c"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("c"), hasType(lValueReferenceType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("c"), hasType(rValueReferenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("d"), hasType(referenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("d"), hasType(lValueReferenceType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("d"), hasType(rValueReferenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("e"), hasType(referenceType()))));
+  EXPECT_TRUE(notMatches(
+      Fragment, varDecl(hasName("e"), hasType(lValueReferenceType()))));
+  EXPECT_TRUE(
+      matches(Fragment, varDecl(hasName("e"), hasType(rValueReferenceType()))));
 }
 
 TEST_P(ASTMatchersTest, EnumType) {
@@ -1796,34 +1757,29 @@ TEST_P(ASTMatchersTest, EnumType_CXX) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("enum Color { Green }; Color color;",
-                      loc(enumType())));
+  EXPECT_TRUE(matches("enum Color { Green }; Color color;", loc(enumType())));
 }
 
 TEST_P(ASTMatchersTest, EnumType_CXX11) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  EXPECT_TRUE(matches("enum class Color { Green }; Color color;",
-                      loc(enumType())));
+  EXPECT_TRUE(
+      matches("enum class Color { Green }; Color color;", loc(enumType())));
 }
 
 TEST_P(ASTMatchersTest, PointerType_MatchesPointersToConstTypes) {
-  EXPECT_TRUE(matches("int b; int * const a = &b;",
-                      loc(pointerType())));
-  EXPECT_TRUE(matches("int b; int * const a = &b;",
-                      loc(pointerType())));
-  EXPECT_TRUE(matches(
-    "int b; const int * a = &b;",
-    loc(pointerType(pointee(builtinType())))));
-  EXPECT_TRUE(matches(
-    "int b; const int * a = &b;",
-    pointerType(pointee(builtinType()))));
+  EXPECT_TRUE(matches("int b; int * const a = &b;", loc(pointerType())));
+  EXPECT_TRUE(matches("int b; int * const a = &b;", loc(pointerType())));
+  EXPECT_TRUE(matches("int b; const int * a = &b;",
+                      loc(pointerType(pointee(builtinType())))));
+  EXPECT_TRUE(matches("int b; const int * a = &b;",
+                      pointerType(pointee(builtinType()))));
 }
 
 TEST_P(ASTMatchersTest, TypedefType) {
-  EXPECT_TRUE(matches("typedef int X; X a;", varDecl(hasName("a"),
-                                                     hasType(typedefType()))));
+  EXPECT_TRUE(matches("typedef int X; X a;",
+                      varDecl(hasName("a"), hasType(typedefType()))));
 }
 
 TEST_P(ASTMatchersTest, TemplateSpecializationType) {
@@ -1864,13 +1820,13 @@ TEST_P(ASTMatchersTest, ElaboratedType) {
     // FIXME: Add a test for `elaboratedType()` that does not depend on C++.
     return;
   }
-  EXPECT_TRUE(matches(
-    "namespace N {"
-      "  namespace M {"
-      "    class D {};"
-      "  }"
-      "}"
-      "N::M::D d;", elaboratedType()));
+  EXPECT_TRUE(matches("namespace N {"
+                      "  namespace M {"
+                      "    class D {};"
+                      "  }"
+                      "}"
+                      "N::M::D d;",
+                      elaboratedType()));
   EXPECT_TRUE(matches("class C {} c;", elaboratedType()));
   EXPECT_TRUE(notMatches("class C {}; C c;", elaboratedType()));
 }
@@ -1885,30 +1841,29 @@ TEST_P(ASTMatchersTest, SubstTemplateTypeParmType) {
                    "}"
                    "int i = F();";
   EXPECT_FALSE(matches(code, binaryOperator(hasLHS(
-    expr(hasType(substTemplateTypeParmType()))))));
+                                 expr(hasType(substTemplateTypeParmType()))))));
   EXPECT_TRUE(matches(code, binaryOperator(hasRHS(
-    expr(hasType(substTemplateTypeParmType()))))));
+                                expr(hasType(substTemplateTypeParmType()))))));
 }
 
 TEST_P(ASTMatchersTest, NestedNameSpecifier) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;",
-                      nestedNameSpecifier()));
+  EXPECT_TRUE(
+      matches("namespace ns { struct A {}; } ns::A a;", nestedNameSpecifier()));
   EXPECT_TRUE(matches("template  class A { typename T::B b; };",
                       nestedNameSpecifier()));
-  EXPECT_TRUE(matches("struct A { void f(); }; void A::f() {}",
-                      nestedNameSpecifier()));
+  EXPECT_TRUE(
+      matches("struct A { void f(); }; void A::f() {}", nestedNameSpecifier()));
   EXPECT_TRUE(matches("namespace a { namespace b {} } namespace ab = a::b;",
                       nestedNameSpecifier()));
 
-  EXPECT_TRUE(matches(
-    "struct A { static void f() {} }; void g() { A::f(); }",
-    nestedNameSpecifier()));
-  EXPECT_TRUE(notMatches(
-    "struct A { static void f() {} }; void g(A* a) { a->f(); }",
-    nestedNameSpecifier()));
+  EXPECT_TRUE(matches("struct A { static void f() {} }; void g() { A::f(); }",
+                      nestedNameSpecifier()));
+  EXPECT_TRUE(
+      notMatches("struct A { static void f() {} }; void g(A* a) { a->f(); }",
+                 nestedNameSpecifier()));
 }
 
 TEST_P(ASTMatchersTest, NullStmt) {
@@ -1929,10 +1884,10 @@ TEST_P(ASTMatchersTest, NestedNameSpecifier_MatchesTypes) {
     return;
   }
   NestedNameSpecifierMatcher Matcher = nestedNameSpecifier(
-    specifiesType(hasDeclaration(recordDecl(hasName("A")))));
+      specifiesType(hasDeclaration(recordDecl(hasName("A")))));
   EXPECT_TRUE(matches("struct A { struct B {}; }; A::B b;", Matcher));
-  EXPECT_TRUE(matches("struct A { struct B { struct C {}; }; }; A::B::C c;",
-                      Matcher));
+  EXPECT_TRUE(
+      matches("struct A { struct B { struct C {}; }; }; A::B::C c;", Matcher));
   EXPECT_TRUE(notMatches("namespace A { struct B {}; } A::B b;", Matcher));
 }
 
@@ -1940,8 +1895,8 @@ TEST_P(ASTMatchersTest, NestedNameSpecifier_MatchesNamespaceDecls) {
   if (!GetParam().isCXX()) {
     return;
   }
-  NestedNameSpecifierMatcher Matcher = nestedNameSpecifier(
-    specifiesNamespace(hasName("ns")));
+  NestedNameSpecifierMatcher Matcher =
+      nestedNameSpecifier(specifiesNamespace(hasName("ns")));
   EXPECT_TRUE(matches("namespace ns { struct A {}; } ns::A a;", Matcher));
   EXPECT_TRUE(notMatches("namespace xx { struct A {}; } xx::A a;", Matcher));
   EXPECT_TRUE(notMatches("struct ns { struct A {}; }; ns::A a;", Matcher));
@@ -1953,16 +1908,15 @@ TEST_P(ASTMatchersTest,
     return;
   }
   EXPECT_TRUE(matches(
-    "struct A { struct B { struct C {}; }; }; A::B::C c;",
-    nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A"))))));
-  EXPECT_TRUE(matches(
-    "struct A { struct B { struct C {}; }; }; A::B::C c;",
-    nestedNameSpecifierLoc(hasPrefix(
-      specifiesTypeLoc(loc(qualType(asString("struct A"))))))));
+      "struct A { struct B { struct C {}; }; }; A::B::C c;",
+      nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A"))))));
+  EXPECT_TRUE(matches("struct A { struct B { struct C {}; }; }; A::B::C c;",
+                      nestedNameSpecifierLoc(hasPrefix(specifiesTypeLoc(
+                          loc(qualType(asString("struct A"))))))));
   EXPECT_TRUE(matches(
-    "namespace N { struct A { struct B { struct C {}; }; }; } N::A::B::C c;",
-    nestedNameSpecifierLoc(hasPrefix(
-      specifiesTypeLoc(loc(qualType(asString("struct N::A"))))))));
+      "namespace N { struct A { struct B { struct C {}; }; }; } N::A::B::C c;",
+      nestedNameSpecifierLoc(hasPrefix(
+          specifiesTypeLoc(loc(qualType(asString("struct N::A"))))))));
 }
 
 template 
@@ -1980,18 +1934,18 @@ class VerifyAncestorHasChildIsEqual : public BoundNodesCallback {
     // to equalsNode.
     const T *TypedNode = cast(Node);
     return selectFirst(
-      "", match(stmt(hasParent(
-        stmt(has(stmt(equalsNode(TypedNode)))).bind(""))),
-                *Node, Context)) != nullptr;
+               "", match(stmt(hasParent(
+                             stmt(has(stmt(equalsNode(TypedNode)))).bind(""))),
+                         *Node, Context)) != nullptr;
   }
   bool verify(const BoundNodes &Nodes, ASTContext &Context, const Decl *Node) {
     // Use the original typed pointer to verify we can pass pointers to subtypes
     // to equalsNode.
     const T *TypedNode = cast(Node);
     return selectFirst(
-      "", match(decl(hasParent(
-        decl(has(decl(equalsNode(TypedNode)))).bind(""))),
-                *Node, Context)) != nullptr;
+               "", match(decl(hasParent(
+                             decl(has(decl(equalsNode(TypedNode)))).bind(""))),
+                         *Node, Context)) != nullptr;
   }
   bool verify(const BoundNodes &Nodes, ASTContext &Context, const Type *Node) {
     // Use the original typed pointer to verify we can pass pointers to subtypes
@@ -1999,9 +1953,9 @@ class VerifyAncestorHasChildIsEqual : public BoundNodesCallback {
     const T *TypedNode = cast(Node);
     const auto *Dec = Nodes.getNodeAs("decl");
     return selectFirst(
-      "", match(fieldDecl(hasParent(decl(has(fieldDecl(
-        hasType(type(equalsNode(TypedNode)).bind(""))))))),
-                *Dec, Context)) != nullptr;
+               "", match(fieldDecl(hasParent(decl(has(fieldDecl(
+                             hasType(type(equalsNode(TypedNode)).bind(""))))))),
+                         *Dec, Context)) != nullptr;
   }
 };
 
@@ -2100,43 +2054,31 @@ TEST(ASTMatchersTestObjC, ObjCMessageExpr) {
                           "  Str *up = [text uppercaseString];"
                           "} "
                           "@end ";
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(anything())));
+  EXPECT_TRUE(matchesObjC(Objc1String, objcMessageExpr(anything())));
   EXPECT_TRUE(matchesObjC(Objc1String,
-                          objcMessageExpr(hasAnySelector({
-                                          "contents", "meth:"}))
+                          objcMessageExpr(hasAnySelector({"contents", "meth:"}))
 
-                         ));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"))));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasAnySelector("contents", "contentsA"))));
-  EXPECT_FALSE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasAnySelector("contentsB", "contentsC"))));
+                              ));
+  EXPECT_TRUE(
+      matchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"))));
   EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(matchesSelector("cont*"))));
+      Objc1String, objcMessageExpr(hasAnySelector("contents", "contentsA"))));
   EXPECT_FALSE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(matchesSelector("?cont*"))));
-  EXPECT_TRUE(notMatchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"), hasNullSelector())));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"), hasUnarySelector())));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(hasSelector("contents"), numSelectorArgs(0))));
-  EXPECT_TRUE(matchesObjC(
-    Objc1String,
-    objcMessageExpr(matchesSelector("uppercase*"),
-                    argumentCountIs(0)
-    )));
+      Objc1String, objcMessageExpr(hasAnySelector("contentsB", "contentsC"))));
+  EXPECT_TRUE(
+      matchesObjC(Objc1String, objcMessageExpr(matchesSelector("cont*"))));
+  EXPECT_FALSE(
+      matchesObjC(Objc1String, objcMessageExpr(matchesSelector("?cont*"))));
+  EXPECT_TRUE(
+      notMatchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"),
+                                                  hasNullSelector())));
+  EXPECT_TRUE(matchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"),
+                                                       hasUnarySelector())));
+  EXPECT_TRUE(matchesObjC(Objc1String, objcMessageExpr(hasSelector("contents"),
+                                                       numSelectorArgs(0))));
+  EXPECT_TRUE(
+      matchesObjC(Objc1String, objcMessageExpr(matchesSelector("uppercase*"),
+                                               argumentCountIs(0))));
 }
 
 TEST(ASTMatchersTestObjC, ObjCDecls) {
@@ -2157,33 +2099,17 @@ TEST(ASTMatchersTestObjC, ObjCDecls) {
                          "- (void)abc_doThing {} "
                          "@end ";
 
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcProtocolDecl(hasName("Proto"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcImplementationDecl(hasName("Thing"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcCategoryDecl(hasName("ABC"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcCategoryImplDecl(hasName("ABC"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcMethodDecl(hasName("protoDidThing"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcMethodDecl(hasName("abc_doThing"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcMethodDecl(hasName("anything"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcIvarDecl(hasName("_ivar"))));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcPropertyDecl(hasName("enabled"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcProtocolDecl(hasName("Proto"))));
+  EXPECT_TRUE(
+      matchesObjC(ObjCString, objcImplementationDecl(hasName("Thing"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcCategoryDecl(hasName("ABC"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcCategoryImplDecl(hasName("ABC"))));
+  EXPECT_TRUE(
+      matchesObjC(ObjCString, objcMethodDecl(hasName("protoDidThing"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcMethodDecl(hasName("abc_doThing"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcMethodDecl(hasName("anything"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcIvarDecl(hasName("_ivar"))));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcPropertyDecl(hasName("enabled"))));
 }
 
 TEST(ASTMatchersTestObjC, ObjCExceptionStmts) {
@@ -2194,18 +2120,10 @@ TEST(ASTMatchersTestObjC, ObjCExceptionStmts) {
                          "  } @finally {}"
                          "}";
 
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcTryStmt()));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcThrowStmt()));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcCatchStmt()));
-  EXPECT_TRUE(matchesObjC(
-    ObjCString,
-    objcFinallyStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcTryStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcThrowStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcCatchStmt()));
+  EXPECT_TRUE(matchesObjC(ObjCString, objcFinallyStmt()));
 }
 
 TEST(ASTMatchersTestObjC, ObjCAutoreleasePoolStmt) {
@@ -2274,11 +2192,18 @@ void x() {
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   StringRef Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  StringRef Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(ASTMatchersTest, Finder_DynamicOnlyAcceptsSomeMatchers) {

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersTest.h b/clang/unittests/ASTMatchers/ASTMatchersTest.h
index 8669ebd552c8..bde6297f82dd 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -20,10 +20,10 @@ namespace clang {
 namespace ast_matchers {
 
 using clang::tooling::buildASTFromCodeWithArgs;
+using clang::tooling::FileContentMappings;
+using clang::tooling::FrontendActionFactory;
 using clang::tooling::newFrontendActionFactory;
 using clang::tooling::runToolOnCodeWithArgs;
-using clang::tooling::FrontendActionFactory;
-using clang::tooling::FileContentMappings;
 
 class BoundNodesCallback {
 public:
@@ -38,7 +38,8 @@ class BoundNodesCallback {
 // If 'FindResultVerifier' is NULL, sets *Verified to true when Run is called.
 class VerifyMatch : public MatchFinder::MatchCallback {
 public:
-  VerifyMatch(std::unique_ptr FindResultVerifier, bool *Verified)
+  VerifyMatch(std::unique_ptr FindResultVerifier,
+              bool *Verified)
       : Verified(Verified), FindResultReviewer(std::move(FindResultVerifier)) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
@@ -124,17 +125,16 @@ testing::AssertionResult matchesConditionally(
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (Found != DynamicFound) {
-    return testing::AssertionFailure() << "Dynamic match result ("
-                                       << DynamicFound
-                                       << ") does not match static result ("
-                                       << Found << ")";
+    return testing::AssertionFailure()
+           << "Dynamic match result (" << DynamicFound
+           << ") does not match static result (" << Found << ")";
   }
   if (!Found && ExpectMatch) {
     return testing::AssertionFailure()
-      << "Could not find match in \"" << Code << "\"";
+           << "Could not find match in \"" << Code << "\"";
   } else if (Found && !ExpectMatch) {
     return testing::AssertionFailure()
-      << "Found unexpected match in \"" << Code << "\"";
+           << "Found unexpected match in \"" << Code << "\"";
   }
   return testing::AssertionSuccess();
 }
@@ -216,7 +216,8 @@ matchesConditionallyWithCuda(const Twine &Code, const T &AMatcher,
       "                      size_t sharedSize = 0,"
       "                      cudaStream_t stream = 0);"
       "extern \"C\" unsigned __cudaPushCallConfiguration("
-      "    dim3 gridDim, dim3 blockDim, size_t sharedMem = 0, void *stream = 0);";
+      "    dim3 gridDim, dim3 blockDim, size_t sharedMem = 0, void *stream = "
+      "0);";
 
   bool Found = false, DynamicFound = false;
   MatchFinder Finder;
@@ -233,22 +234,20 @@ matchesConditionallyWithCuda(const Twine &Code, const T &AMatcher,
   std::vector Args = {
       "-xcuda",  "-fno-ms-extensions",     "--cuda-host-only",     "-nocudainc",
       "-target", "x86_64-unknown-unknown", std::string(CompileArg)};
-  if (!runToolOnCodeWithArgs(Factory->create(),
-                             CudaHeader + Code, Args)) {
+  if (!runToolOnCodeWithArgs(Factory->create(), CudaHeader + Code, Args)) {
     return testing::AssertionFailure() << "Parsing error in \"" << Code << "\"";
   }
   if (Found != DynamicFound) {
-    return testing::AssertionFailure() << "Dynamic match result ("
-                                       << DynamicFound
-                                       << ") does not match static result ("
-                                       << Found << ")";
+    return testing::AssertionFailure()
+           << "Dynamic match result (" << DynamicFound
+           << ") does not match static result (" << Found << ")";
   }
   if (!Found && ExpectMatch) {
     return testing::AssertionFailure()
-      << "Could not find match in \"" << Code << "\"";
+           << "Could not find match in \"" << Code << "\"";
   } else if (Found && !ExpectMatch) {
     return testing::AssertionFailure()
-      << "Found unexpected match in \"" << Code << "\"";
+           << "Found unexpected match in \"" << Code << "\"";
   }
   return testing::AssertionSuccess();
 }
@@ -276,13 +275,28 @@ testing::AssertionResult notMatchesWithOpenMP(const Twine &Code,
   return matchesConditionally(Code, AMatcher, false, {"-fopenmp=libomp"});
 }
 
+template 
+testing::AssertionResult matchesWithOpenMP51(const Twine &Code,
+                                             const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, true,
+                              {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
+template 
+testing::AssertionResult notMatchesWithOpenMP51(const Twine &Code,
+                                                const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, false,
+                              {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
 template 
 testing::AssertionResult matchAndVerifyResultConditionally(
     const Twine &Code, const T &AMatcher,
     std::unique_ptr FindResultVerifier, bool ExpectResult) {
   bool VerifiedResult = false;
   MatchFinder Finder;
-  VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier), &VerifiedResult);
+  VerifyMatch VerifyVerifiedResult(std::move(FindResultVerifier),
+                                   &VerifiedResult);
   Finder.addMatcher(AMatcher, &VerifyVerifiedResult);
   std::unique_ptr Factory(
       newFrontendActionFactory(&Finder));
@@ -296,10 +310,10 @@ testing::AssertionResult matchAndVerifyResultConditionally(
   }
   if (!VerifiedResult && ExpectResult) {
     return testing::AssertionFailure()
-      << "Could not verify result in \"" << Code << "\"";
+           << "Could not verify result in \"" << Code << "\"";
   } else if (VerifiedResult && !ExpectResult) {
     return testing::AssertionFailure()
-      << "Verified unexpected result in \"" << Code << "\"";
+           << "Verified unexpected result in \"" << Code << "\"";
   }
 
   VerifiedResult = false;
@@ -307,15 +321,15 @@ testing::AssertionResult matchAndVerifyResultConditionally(
   std::unique_ptr AST(
       buildASTFromCodeWithArgs(Code.toStringRef(Buffer), Args));
   if (!AST.get())
-    return testing::AssertionFailure() << "Parsing error in \"" << Code
-                                       << "\" while building AST";
+    return testing::AssertionFailure()
+           << "Parsing error in \"" << Code << "\" while building AST";
   Finder.matchAST(AST->getASTContext());
   if (!VerifiedResult && ExpectResult) {
     return testing::AssertionFailure()
-      << "Could not verify result in \"" << Code << "\" with AST";
+           << "Could not verify result in \"" << Code << "\" with AST";
   } else if (VerifiedResult && !ExpectResult) {
     return testing::AssertionFailure()
-      << "Verified unexpected result in \"" << Code << "\" with AST";
+           << "Verified unexpected result in \"" << Code << "\" with AST";
   }
 
   return testing::AssertionSuccess();
@@ -327,8 +341,8 @@ template 
 testing::AssertionResult matchAndVerifyResultTrue(
     const Twine &Code, const T &AMatcher,
     std::unique_ptr FindResultVerifier) {
-  return matchAndVerifyResultConditionally(
-      Code, AMatcher, std::move(FindResultVerifier), true);
+  return matchAndVerifyResultConditionally(Code, AMatcher,
+                                           std::move(FindResultVerifier), true);
 }
 
 template 
@@ -342,8 +356,7 @@ testing::AssertionResult matchAndVerifyResultFalse(
 // Implements a run method that returns whether BoundNodes contains a
 // Decl bound to Id that can be dynamically cast to T.
 // Optionally checks that the check succeeded a specific number of times.
-template 
-class VerifyIdIsBoundTo : public BoundNodesCallback {
+template  class VerifyIdIsBoundTo : public BoundNodesCallback {
 public:
   // Create an object that checks that a node of type \c T was bound to \c Id.
   // Does not check for a certain number of matches.
@@ -386,7 +399,7 @@ class VerifyIdIsBoundTo : public BoundNodesCallback {
       if (const NamedDecl *Named = Nodes->getNodeAs(Id)) {
         Name = Named->getNameAsString();
       } else if (const NestedNameSpecifier *NNS =
-        Nodes->getNodeAs(Id)) {
+                     Nodes->getNodeAs(Id)) {
         llvm::raw_string_ostream OS(Name);
         NNS->print(OS, PrintingPolicy(LangOptions()));
       }
@@ -398,7 +411,7 @@ class VerifyIdIsBoundTo : public BoundNodesCallback {
       return true;
     }
     EXPECT_TRUE(M.count(Id) == 0 ||
-      M.find(Id)->second.template get() == nullptr);
+                M.find(Id)->second.template get() == nullptr);
     return false;
   }
 
@@ -437,4 +450,4 @@ class ASTMatchersTest : public ::testing::Test,
 } // namespace ast_matchers
 } // namespace clang
 
-#endif  // LLVM_CLANG_UNITTESTS_AST_MATCHERS_AST_MATCHERS_TEST_H
+#endif // LLVM_CLANG_UNITTESTS_AST_MATCHERS_AST_MATCHERS_TEST_H

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index bf799a781ae1..93ea63c1c2e6 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -982,6 +982,7 @@ __OMP_CANCEL_KIND(taskgroup, 4)
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND


        

From cfe-commits at lists.llvm.org  Sun Jul 12 21:04:06 2020
From: cfe-commits at lists.llvm.org (Johannes Doerfert via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 04:04:06 +0000 (UTC)
Subject: [PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing
 attribute to clang
In-Reply-To: 
References: 
Message-ID: 

This revision was automatically updated to reflect the committed changes.
Closed by commit rG78443666bc18: [OpenMP] Add firstprivate as a default data-sharing attribute to clang (authored by atmnpatel, committed by jdoerfert).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75591/new/

https://reviews.llvm.org/D75591

Files:
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/driver.c
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/target_teams_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/task_default_messages.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/teams_default_messages.cpp
  clang/test/OpenMP/teams_distribute_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75591.277321.patch
Type: text/x-patch
Size: 274251 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Sun Jul 12 22:59:38 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 05:59:38 +0000 (UTC)
Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it
 as a DriverOption
In-Reply-To: 
References: 
Message-ID: <088c29fdb912a1b7ad8786b154f3b061@localhost.localdomain>

MaskRay added a comment.

In D83648#2146472 , @pzheng wrote:

> Actually, this patch won't change --help because it just reduced some duplication by extracting the common part (" the integrated assembler") of the help message into the "help" of "OptOutFFlag". Sorry for the confusion.
>
> The real fix here is to restore "integrated_as" as a DriverOption. Without this, when we have -fintegrated-as on a link line, it will be passed to the linker and cause the linker to fail because it is not a valid linker flag.


The description is not correct. The actual difference is:

  static bool forwardToGCC(const Option &O) {
    // Don't forward inputs from the original command line.  They are added from
    // InputInfoList.
    return O.getKind() != Option::InputClass &&
           !O.hasFlag(options::DriverOption) && !O.hasFlag(options::LinkerInput);
  }

If `clang::driver::tools::gcc::Common` is selected, DriverOption modified options are not forwarded to gcc.

`clang -target x86_64-linux -fintegrated-as a.o '-###'` => no -fintegrated-as

`clang -target x86_64 -fintegrated-as a.o '-###'` => `"/usr/bin/gcc" "-fintegrated-as" "-m64" "-o" "a.out" "a.o"`

In this sense, all -f options not recognized by GCC should have a DriverOption tag.... I don't think we have properly tagged all options.



================
Comment at: clang/test/Driver/integrated-as.c:10
 
+// RUN: %clang -### -fintegrated-as %s 2>&1 | FileCheck %s -check-prefix FIAS-LINK
+
----------------
This test is incorrect. You need a specific target triple to select bare-metal like GCC driver.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83648/new/

https://reviews.llvm.org/D83648




From cfe-commits at lists.llvm.org  Sun Jul 12 23:02:16 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 06:02:16 +0000 (UTC)
Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it
 as a DriverOption
In-Reply-To: 
References: 
Message-ID: <7e27be72af7a70f9db23df752d75d7f2@localhost.localdomain>

MaskRay added inline comments.


================
Comment at: clang/test/Driver/integrated-as.c:10
 
+// RUN: %clang -### -fintegrated-as %s 2>&1 | FileCheck %s -check-prefix FIAS-LINK
+
----------------
MaskRay wrote:
> This test is incorrect. You need a specific target triple to select bare-metal like GCC driver.
There are so many clang specific options. I think we just need a centralized test file to test options in patch, instead of adding random `-NOT` check lines to random files.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83648/new/

https://reviews.llvm.org/D83648




From cfe-commits at lists.llvm.org  Sun Jul 12 23:05:17 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 06:05:17 +0000 (UTC)
Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it
 as a DriverOption
In-Reply-To: 
References: 
Message-ID: <4a66a51707a062e334e81737b5a57872@localhost.localdomain>

MaskRay added a comment.

Actually, the way we tag options recognized by GCC is wrong. We should use a more specific group instead of `DriverOption`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83648/new/

https://reviews.llvm.org/D83648




From cfe-commits at lists.llvm.org  Sun Jul 12 23:34:11 2020
From: cfe-commits at lists.llvm.org (Fangrui Song via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 06:34:11 +0000 (UTC)
Subject: [PATCH] D83648: [Driver] Fix integrated_as definition by setting it
 as a DriverOption
In-Reply-To: 
References: 
Message-ID: 

MaskRay added a comment.

Created http://lists.llvm.org/pipermail/cfe-dev/2020-July/066245.html [cfe-dev] Usage of clang::driver::options::DriverOption (-Xarch_ & gcc toolchain)
to ask about the use case.

When I get time, I'll work on a patch fixing the whole class of options instead of just -fintegrated-as. I will call the class `GCCLinkOption`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83648/new/

https://reviews.llvm.org/D83648




From cfe-commits at lists.llvm.org  Sun Jul 12 23:39:59 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 06:39:59 +0000 (UTC)
Subject: [PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.
In-Reply-To: 
References: 
Message-ID: <2a48425f12923a83f3724d7a2c66e9b9@localhost.localdomain>

hokein updated this revision to Diff 277332.
hokein marked 12 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83213/new/

https://reviews.llvm.org/D83213

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/Sema/SemaExpr.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83213.277332.patch
Type: text/x-patch
Size: 9504 bytes
Desc: not available
URL: 

From cfe-commits at lists.llvm.org  Sun Jul 12 23:44:05 2020
From: cfe-commits at lists.llvm.org (Haojian Wu via Phabricator via cfe-commits)
Date: Mon, 13 Jul 2020 06:44:05 +0000 (UTC)
Subject: [PATCH] D83213: [clang][RecoveryExpr] Clarify the dependence-bits
 documentation.
In-Reply-To: 
References: 
Message-ID: 

hokein added inline comments.


================
Comment at: clang/lib/AST/ComputeDependence.cpp:502
+  //     dependent type), or the type is known and dependent, or it has
+  //     type-dependent subexpressions
   auto D = toExprDependence(E->getType()->getDependence()) |
----------------
sammccall wrote:
> hmm, I'd missed the type-dependent subexpressions question.
> If there are type-dependent subexpressions, but a non-dependent type was specified for the RecoveryExpr, is the expr type-dependent?
> 
> This is the part that I think we have discretion over.
> The definition of type-dependent does say "any type-dependent subexpression" but then lays out a list of exceptions such as casts, which are not type-dependent even if their argument is. What these have in common is that the type is known.
> 
> So I think this comes down to whether it's the caller's job to work this out, or we want to conservatively call these expressions dependent.
> 
> I think the former is probably better - marking the expression as type-dependent but not having its actual type be dependent doesn't serve any purpose I'm aware of. It's also inconsistent with the informal definition of type-dependence described earlier in this patch.
> 
> So the comment should describe the current state, but maybe a FIXME to remove the type-dependent subexpressions clause?
yeah, I think we should respect to actual type of RecoveryExpr, added a fixme.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83213/new/

https://reviews.llvm.org/D83213




From cfe-commits at lists.llvm.org  Fri Jul 10 15:33:50 2020
From: cfe-commits at lists.llvm.org (Chris Lattner via Phabricator via cfe-commits)
Date: Fri, 10 Jul 2020 22:33:50 +0000 (UTC)
Subject: [PATCH] D81728: [InstCombine] Add target-specific inst combining
In-Reply-To: 
References: 
Message-ID: <30c1e42316f35db021f77f92f69bc156@localhost.localdomain>

lattner resigned from this revision.
lattner added a comment.

Please don't consider me a blocker on this patch, thank you for pushing on it!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81728/new/

https://reviews.llvm.org/D81728




From cfe-commits at lists.llvm.org  Sun Jul 12 12:41:41 2020
From: cfe-commits at lists.llvm.org (=?UTF-8?B?QWxleGV5IExhcHNoaW4=?= via cfe-commits)
Date: Sun, 12 Jul 2020 22:41:41 +0300
Subject: =?UTF-8?B?UmU6IFtQQVRDSF0gRDgyMDg1OiBbVFJFXSBhbGxvdyBUUkUgZm9yIG5vbi1j?=
 =?UTF-8?B?YXB0dXJpbmcgY2FsbHMu?=
In-Reply-To: <294696123008e665e0b813c136c34d09@localhost.localdomain>
References: 
 <294696123008e665e0b813c136c34d09@localhost.localdomain>
Message-ID: <1594582901.988822064@f313.i.mail.ru>



Hi David,
 
Thank you for the information. I would revert that commit and work on the fix.
 
Thank you, Alexey. 
>Воскресенье, 12 июля 2020, 12:44 +03:00 от David Zarzycki via Phabricator :
> 
>davezarzycki added a comment.
>
>Hello. I have an auto-bisecting multi-stage bot that is failing on two after this change. Can we please revert this or commit a quick fix?
>
>  FAIL: Clang :: CXX/class/class.compare/class.spaceship/p1.cpp (6232 of 64222)
>  ******************** TEST 'Clang :: CXX/class/class.compare/class.spaceship/p1.cpp' FAILED ********************
>  Script:
>  --
>  : 'RUN: at line 1'; /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp -fcxx-exceptions
>  --
>  Exit Code: 134
>  
>  Command Output (stderr):
>  --
>  clang: /home/dave/s/lp/clang/lib/Basic/SourceManager.cpp:917: clang::FileID clang::SourceManager::getFileIDLoaded(unsigned int) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
>  PLEASE submit a bug report to  https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
>  Stack dump:
>  0. Program arguments: /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp -fcxx-exceptions
>  1. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:127:38: current parser token ','
>  2. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:39:1: parsing namespace 'Deletedness'
>  3. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:123:12: parsing function body 'Deletedness::g'
>  4. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp:123:12: in compound statement ('{}')
>   #0 0x000000000359273f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/_update_lc/t/bin/clang+0x359273f)
>   #1 0x0000000003590912 llvm::sys::RunSignalHandlers() (/tmp/_update_lc/t/bin/clang+0x3590912)
>   #2 0x0000000003592bb5 SignalHandler(int) (/tmp/_update_lc/t/bin/clang+0x3592bb5)
>   #3 0x00007ffff7fa6a90 __restore_rt (/lib64/libpthread.so.0+0x14a90)
>   #4 0x00007ffff7b3da25 raise (/lib64/libc.so.6+0x3ca25)
>   #5 0x00007ffff7b26895 abort (/lib64/libc.so.6+0x25895)
>   #6 0x00007ffff7b26769 _nl_load_domain.cold (/lib64/libc.so.6+0x25769)
>   #7 0x00007ffff7b35e86 (/lib64/libc.so.6+0x34e86)
>   #8 0x000000000375636c clang::SourceManager::getFileIDLoaded(unsigned int) const (/tmp/_update_lc/t/bin/clang+0x375636c)
>   #9 0x0000000003ee0bbb clang::VerifyDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/tmp/_update_lc/t/bin/clang+0x3ee0bbb)
>  #10 0x00000000037501ab clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/tmp/_update_lc/t/bin/clang+0x37501ab)
>  #11 0x0000000003749fca clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/tmp/_update_lc/t/bin/clang+0x3749fca)
>  #12 0x0000000004df0c60 clang::Sema::EmitCurrentDiagnostic(unsigned int) (/tmp/_update_lc/t/bin/clang+0x4df0c60)
>  #13 0x0000000005092783 (anonymous namespace)::DefaultedComparisonAnalyzer::visitBinaryOperator(clang::OverloadedOperatorKind, llvm::ArrayRef, (anonymous namespace)::DefaultedComparisonSubobject, clang::OverloadCandidateSet*) (/tmp/_update_lc/t/bin/clang+0x5092783)
>  #14 0x0000000005091dba (anonymous namespace)::DefaultedComparisonAnalyzer::visitExpandedSubobject(clang::QualType, (anonymous namespace)::DefaultedComparisonSubobject) (/tmp/_update_lc/t/bin/clang+0x5091dba)
>  #15 0x0000000005091b86 (anonymous namespace)::DefaultedComparisonVisitor<(anonymous namespace)::DefaultedComparisonAnalyzer, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonSubobject>::visitSubobjects((anonymous namespace)::DefaultedComparisonInfo&, clang::CXXRecordDecl*, clang::Qualifiers) (/tmp/_update_lc/t/bin/clang+0x5091b86)
>  #16 0x0000000005058c8c (anonymous namespace)::DefaultedComparisonAnalyzer::visit() (/tmp/_update_lc/t/bin/clang+0x5058c8c)
>  #17 0x000000000505ab22 clang::Sema::DiagnoseDeletedDefaultedFunction(clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x505ab22)
>  #18 0x00000000053e60ed clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x53e60ed)
>  #19 0x000000000514270a BuildOverloadedBinOp(clang::Sema&, clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x514270a)
>  #20 0x00000000050fbf49 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x50fbf49)
>  #21 0x0000000004d52ccc clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult, clang::prec::Level) (/tmp/_update_lc/t/bin/clang+0x4d52ccc)
>  #22 0x0000000004d51be9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51be9)
>  #23 0x0000000004d60dba clang::Parser::ParseExpressionList(llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, llvm::function_ref) (/tmp/_update_lc/t/bin/clang+0x4d60dba)
>  #24 0x0000000004d542d9 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult) (/tmp/_update_lc/t/bin/clang+0x4d542d9)
>  #25 0x0000000004d55b95 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/tmp/_update_lc/t/bin/clang+0x4d55b95)
>  #26 0x0000000004d51b89 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51b89)
>  #27 0x0000000004d51ac9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51ac9)
>  #28 0x0000000004d78368 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/tmp/_update_lc/t/bin/clang+0x4d78368)
>  #29 0x0000000004d76ba0 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/tmp/_update_lc/t/bin/clang+0x4d76ba0)
>  #30 0x0000000004d76614 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/tmp/_update_lc/t/bin/clang+0x4d76614)
>  #31 0x0000000004d7ecd2 clang::Parser::ParseCompoundStatementBody(bool) (/tmp/_update_lc/t/bin/clang+0x4d7ecd2)
>  #32 0x0000000004d7fcd0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/tmp/_update_lc/t/bin/clang+0x4d7fcd0)
>  #33 0x0000000004cfacc0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/tmp/_update_lc/t/bin/clang+0x4cfacc0)
>  #34 0x0000000004d28f2d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/tmp/_update_lc/t/bin/clang+0x4d28f2d)
>  #35 0x0000000004cf9f32 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9f32)
>  #36 0x0000000004cf9938 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9938)
>  #37 0x0000000004cf86fc clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/tmp/_update_lc/t/bin/clang+0x4cf86fc)
>  #38 0x0000000004d02c15 clang::Parser::ParseInnerNamespace(llvm::SmallVector const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&) (/tmp/_update_lc/t/bin/clang+0x4d02c15)
>  #39 0x0000000004d0251a clang::Parser::ParseNamespace(clang::DeclaratorContext, clang::SourceLocation&, clang::SourceLocation) (/tmp/_update_lc/t/bin/clang+0x4d0251a)
>  #40 0x0000000004d22f0a clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, clang::SourceLocation*) (/tmp/_update_lc/t/bin/clang+0x4d22f0a)
>  #41 0x0000000004cf7e39 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/tmp/_update_lc/t/bin/clang+0x4cf7e39)
>  #42 0x0000000004cf6858 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) (/tmp/_update_lc/t/bin/clang+0x4cf6858)
>  #43 0x0000000004cf16ed clang::ParseAST(clang::Sema&, bool, bool) (/tmp/_update_lc/t/bin/clang+0x4cf16ed)
>  #44 0x0000000003e3eb21 clang::FrontendAction::Execute() (/tmp/_update_lc/t/bin/clang+0x3e3eb21)
>  #45 0x0000000003dba0e3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/tmp/_update_lc/t/bin/clang+0x3dba0e3)
>  #46 0x0000000003ee796b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/tmp/_update_lc/t/bin/clang+0x3ee796b)
>  #47 0x0000000002244636 cc1_main(llvm::ArrayRef, char const*, void*) (/tmp/_update_lc/t/bin/clang+0x2244636)
>  #48 0x000000000224297d ExecuteCC1Tool(llvm::SmallVectorImpl&) (/tmp/_update_lc/t/bin/clang+0x224297d)
>  #49 0x0000000002242619 main (/tmp/_update_lc/t/bin/clang+0x2242619)
>  #50 0x00007ffff7b28042 __libc_start_main (/lib64/libc.so.6+0x27042)
>  #51 0x000000000223f8ce _start (/tmp/_update_lc/t/bin/clang+0x223f8ce)
>  /tmp/_update_lc/t/tools/clang/test/CXX/class/class.compare/class.spaceship/Output/p1.cpp.script: line 1: 4146089 Aborted /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.spaceship/p1.cpp -fcxx-exceptions
>  
>  --
>  
>  ********************
>  Testing: 0..
>  FAIL: Clang :: CXX/class/class.compare/class.eq/p2.cpp (6242 of 64222)
>  ******************** TEST 'Clang :: CXX/class/class.compare/class.eq/p2.cpp' FAILED ********************
>  Script:
>  --
>  : 'RUN: at line 1'; /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp
>  --
>  Exit Code: 134
>  
>  Command Output (stderr):
>  --
>  clang: /home/dave/s/lp/clang/lib/Basic/SourceManager.cpp:917: clang::FileID clang::SourceManager::getFileIDLoaded(unsigned int) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
>  PLEASE submit a bug report to  https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
>  Stack dump:
>  0. Program arguments: /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp
>  1. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp:47:30: current parser token ')'
>  2. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp:30:13: parsing function body 'test'
>  3. /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp:30:13: in compound statement ('{}')
>   #0 0x000000000359273f llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/tmp/_update_lc/t/bin/clang+0x359273f)
>   #1 0x0000000003590912 llvm::sys::RunSignalHandlers() (/tmp/_update_lc/t/bin/clang+0x3590912)
>   #2 0x0000000003592bb5 SignalHandler(int) (/tmp/_update_lc/t/bin/clang+0x3592bb5)
>   #3 0x00007ffff7fa6a90 __restore_rt (/lib64/libpthread.so.0+0x14a90)
>   #4 0x00007ffff7b3da25 raise (/lib64/libc.so.6+0x3ca25)
>   #5 0x00007ffff7b26895 abort (/lib64/libc.so.6+0x25895)
>   #6 0x00007ffff7b26769 _nl_load_domain.cold (/lib64/libc.so.6+0x25769)
>   #7 0x00007ffff7b35e86 (/lib64/libc.so.6+0x34e86)
>   #8 0x000000000375636c clang::SourceManager::getFileIDLoaded(unsigned int) const (/tmp/_update_lc/t/bin/clang+0x375636c)
>   #9 0x0000000003ee0bbb clang::VerifyDiagnosticConsumer::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/tmp/_update_lc/t/bin/clang+0x3ee0bbb)
>  #10 0x00000000037501ab clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/tmp/_update_lc/t/bin/clang+0x37501ab)
>  #11 0x0000000003749fca clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/tmp/_update_lc/t/bin/clang+0x3749fca)
>  #12 0x0000000004df0c60 clang::Sema::EmitCurrentDiagnostic(unsigned int) (/tmp/_update_lc/t/bin/clang+0x4df0c60)
>  #13 0x00000000050928b7 (anonymous namespace)::DefaultedComparisonAnalyzer::visitBinaryOperator(clang::OverloadedOperatorKind, llvm::ArrayRef, (anonymous namespace)::DefaultedComparisonSubobject, clang::OverloadCandidateSet*) (/tmp/_update_lc/t/bin/clang+0x50928b7)
>  #14 0x0000000005091dba (anonymous namespace)::DefaultedComparisonAnalyzer::visitExpandedSubobject(clang::QualType, (anonymous namespace)::DefaultedComparisonSubobject) (/tmp/_update_lc/t/bin/clang+0x5091dba)
>  #15 0x0000000005091b86 (anonymous namespace)::DefaultedComparisonVisitor<(anonymous namespace)::DefaultedComparisonAnalyzer, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonInfo, (anonymous namespace)::DefaultedComparisonSubobject>::visitSubobjects((anonymous namespace)::DefaultedComparisonInfo&, clang::CXXRecordDecl*, clang::Qualifiers) (/tmp/_update_lc/t/bin/clang+0x5091b86)
>  #16 0x0000000005058c8c (anonymous namespace)::DefaultedComparisonAnalyzer::visit() (/tmp/_update_lc/t/bin/clang+0x5058c8c)
>  #17 0x000000000505ab22 clang::Sema::DiagnoseDeletedDefaultedFunction(clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x505ab22)
>  #18 0x00000000053e60ed clang::Sema::CreateOverloadedBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, clang::Expr*, bool, bool, clang::FunctionDecl*) (/tmp/_update_lc/t/bin/clang+0x53e60ed)
>  #19 0x000000000514270a BuildOverloadedBinOp(clang::Sema&, clang::Scope*, clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x514270a)
>  #20 0x00000000050fbf49 clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) (/tmp/_update_lc/t/bin/clang+0x50fbf49)
>  #21 0x0000000004d52ccc clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult, clang::prec::Level) (/tmp/_update_lc/t/bin/clang+0x4d52ccc)
>  #22 0x0000000004d51be9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51be9)
>  #23 0x0000000004d60dba clang::Parser::ParseExpressionList(llvm::SmallVectorImpl&, llvm::SmallVectorImpl&, llvm::function_ref) (/tmp/_update_lc/t/bin/clang+0x4d60dba)
>  #24 0x0000000004d4b29c clang::Parser::ParseCXXTypeConstructExpression(clang::DeclSpec const&) (/tmp/_update_lc/t/bin/clang+0x4d4b29c)
>  #25 0x0000000004d57617 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/tmp/_update_lc/t/bin/clang+0x4d57617)
>  #26 0x0000000004d51b89 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51b89)
>  #27 0x0000000004d51ac9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/tmp/_update_lc/t/bin/clang+0x4d51ac9)
>  #28 0x0000000004d78368 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/tmp/_update_lc/t/bin/clang+0x4d78368)
>  #29 0x0000000004d76ba0 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/tmp/_update_lc/t/bin/clang+0x4d76ba0)
>  #30 0x0000000004d76614 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/tmp/_update_lc/t/bin/clang+0x4d76614)
>  #31 0x0000000004d7ecd2 clang::Parser::ParseCompoundStatementBody(bool) (/tmp/_update_lc/t/bin/clang+0x4d7ecd2)
>  #32 0x0000000004d7fcd0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/tmp/_update_lc/t/bin/clang+0x4d7fcd0)
>  #33 0x0000000004cfacc0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/tmp/_update_lc/t/bin/clang+0x4cfacc0)
>  #34 0x0000000004d28f2d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/tmp/_update_lc/t/bin/clang+0x4d28f2d)
>  #35 0x0000000004cf9f32 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9f32)
>  #36 0x0000000004cf9938 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/tmp/_update_lc/t/bin/clang+0x4cf9938)
>  #37 0x0000000004cf86fc clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/tmp/_update_lc/t/bin/clang+0x4cf86fc)
>  #38 0x0000000004cf6858 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) (/tmp/_update_lc/t/bin/clang+0x4cf6858)
>  #39 0x0000000004cf16ed clang::ParseAST(clang::Sema&, bool, bool) (/tmp/_update_lc/t/bin/clang+0x4cf16ed)
>  #40 0x0000000003e3eb21 clang::FrontendAction::Execute() (/tmp/_update_lc/t/bin/clang+0x3e3eb21)
>  #41 0x0000000003dba0e3 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/tmp/_update_lc/t/bin/clang+0x3dba0e3)
>  #42 0x0000000003ee796b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/tmp/_update_lc/t/bin/clang+0x3ee796b)
>  #43 0x0000000002244636 cc1_main(llvm::ArrayRef, char const*, void*) (/tmp/_update_lc/t/bin/clang+0x2244636)
>  #44 0x000000000224297d ExecuteCC1Tool(llvm::SmallVectorImpl&) (/tmp/_update_lc/t/bin/clang+0x224297d)
>  #45 0x0000000002242619 main (/tmp/_update_lc/t/bin/clang+0x2242619)
>  #46 0x00007ffff7b28042 __libc_start_main (/lib64/libc.so.6+0x27042)
>  #47 0x000000000223f8ce _start (/tmp/_update_lc/t/bin/clang+0x223f8ce)
>  /tmp/_update_lc/t/tools/clang/test/CXX/class/class.compare/class.eq/Output/p2.cpp.script: line 1: 4146047 Aborted /tmp/_update_lc/t/bin/clang -cc1 -internal-isystem /tmp/_update_lc/t/lib/clang/11.0.0/include -nostdsysteminc -std=c++2a -verify /home/dave/s/lp/clang/test/CXX/class/class.compare/class.eq/p2.cpp
>  
>  --
>  
>  ********************
>  Testing: 0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
>  ********************
>  Failed Tests (2):
>    Clang :: CXX/class/class.compare/class.eq/p2.cpp
>    Clang :: CXX/class/class.compare/class.spaceship/p1.cpp
>  
>  
>  Testing Time: 117.51s
>    Unsupported : 12906
>    Passed : 51214
>    Expectedly Failed: 100
>    Failed : 2
>  FAILED: CMakeFiles/check-all
>  cd /tmp/_update_lc/t && /usr/bin/python3.8 /tmp/_update_lc/t/./bin/llvm-lit -sv --param USE_Z3_SOLVER=0 /tmp/_update_lc/t/tools/clang/test /tmp/_update_lc/t/tools/lld/test /tmp/_update_lc/t/tools/lldb/test /tmp/_update_lc/t/utils/lit /tmp/_update_lc/t/test
>  ninja: build stopped: subcommand failed.
>  + do_error 'FAILURE -- STAGE TWO BUILD of LLVM' 12
>  + echo FAILURE -- STAGE TWO BUILD of LLVM
>  FAILURE -- STAGE TWO BUILD of LLVM
>  + exit 12
>
>
>Repository:
>  rG LLVM Github Monorepo
>
>CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D82085/new/
>
>https://reviews.llvm.org/D82085
>
>
>  
 
 
--
Alexey Lapshin
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: