Re: [libcxx] r284214 - XFAIL aligned allocation tests for older Clang versions
Hi All, Sorry about the delay. I'll unbreak the tests tomorrow afternoon (I have a midterm in the morning) /Eric On Oct 18, 2016 9:00 PM, "Tim Northover" wrote: > On 15 October 2016 at 13:08, Eric Fiselier via cfe-commits > wrote: > > Are these tests still broken for you? > > They're still breaking multiple Green Dragon bots (e.g. the basic > "make check" at > http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/)[1]. > What do you need to help fix the issue? > > Cheers. > > Tim. > > [1] Becoming more important now that we think we've fixed the hardware > problem in their lab and want to re-enable notifications. > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"
On 17/10/16 17:07, Benjamin Kramer wrote: I'm running into something else and your patch doesn't fix it. It boils down to 'std::is_nothrow_move_constructible' from libstdc++ not compiling because Foo is not visible inside the noexcept specification of that template. I failed to come up with a small test case so far as it involves at least 2 modules :[ Sigh... :( Did you have the time to find a reproducer for this issue, we are very interested in relanding this patch. On Mon, Oct 17, 2016 at 4:44 PM, Vassil Vassilev wrote: On 17/10/16 16:40, Benjamin Kramer wrote: Too slow ;) Do you have the fix somewhere, so I can try it? That would be https://reviews.llvm.org/D25678 Do you run into something else than what I have as a test case (merging templated constexpr variables)? On Mon, Oct 17, 2016 at 4:38 PM, Vassil Vassilev wrote: I was just to commit a fix :( On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote: Author: d0k Date: Mon Oct 17 08:00:44 2016 New Revision: 284382 URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev Log: Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of" This reverts commit r284176. It still marks some modules as invisible that should be visible. Will follow up with the author with a test case. Removed: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap cfe/trunk/test/Modules/merge-var-template-def.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 2016 @@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase /// merged into. llvm::DenseMap MergedDecls; - /// The modules into which a definition has been merged, or a map from a - /// merged definition to its canonical definition. This is really a union of - /// a NamedDecl* and a vector of Module*. - struct MergedModulesOrCanonicalDef { -llvm::TinyPtrVector MergedModules; -NamedDecl *CanonicalDef = nullptr; - }; - /// \brief A mapping from a defining declaration to a list of modules (other /// than the owning module of the declaration) that contain merged /// definitions of that entity. - llvm::DenseMap MergedDefModules; + llvm::DenseMap> MergedDefModules; /// \brief Initializers for a module, in order. Each Decl will be either /// something that has a semantic effect on startup (such as a variable with @@ -891,7 +883,6 @@ public: /// and should be visible whenever \p M is visible. void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners = true); - void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other); /// \brief Clean up the merged definition list. Call this if you might have /// added duplicates into the list. void deduplicateMergedDefinitonsFor(NamedDecl *ND); @@ -902,9 +893,7 @@ public: auto MergedIt = MergedDefModules.find(Def); if (MergedIt == MergedDefModules.end()) return None; -if (auto *CanonDef = MergedIt->second.CanonicalDef) - return getModulesWithMergedDefinition(CanonDef); -return MergedIt->second.MergedModules; +return MergedIt->second; } /// Add a declaration to the list of declarations that are initialized Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016 @@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu if (auto *Listener = getASTMutationListener()) Listener->RedefinedHiddenDefinition(ND, M); - auto *Merged = &MergedDefModules[ND]; - if (auto *CanonDef = Merged->CanonicalDef) { -ND = CanonDef; -Merged = &MergedDefModules[ND]; - } - assert(!Merged->CanonicalDef &
r284573 - [clang-format] Add comment manipulation header
Author: ioeric Date: Wed Oct 19 03:19:46 2016 New Revision: 284573 URL: http://llvm.org/viewvc/llvm-project?rev=284573&view=rev Log: [clang-format] Add comment manipulation header Summary: Introduces a separate target for comment manipulation. Currently, comment manipulation is in BreakableComment.cpp. Towards implementing comment reflowing, we want to factor out the comment-related functionality, so it can be reused. Start simple by just moving out getLineCommentIndentPrefix. Patch by Krasimir Georgiev! Reviewers: djasper Subscribers: klimek, beanz, mgorny, modocache Differential Revision: https://reviews.llvm.org/D25725 Added: cfe/trunk/lib/Format/Comments.cpp cfe/trunk/lib/Format/Comments.h Modified: cfe/trunk/lib/Format/BreakableToken.cpp cfe/trunk/lib/Format/CMakeLists.txt Modified: cfe/trunk/lib/Format/BreakableToken.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=284573&r1=284572&r2=284573&view=diff == --- cfe/trunk/lib/Format/BreakableToken.cpp (original) +++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Oct 19 03:19:46 2016 @@ -14,6 +14,7 @@ //===--===// #include "BreakableToken.h" +#include "Comments.h" #include "clang/Basic/CharInfo.h" #include "clang/Format/Format.h" #include "llvm/ADT/STLExtras.h" @@ -182,21 +183,6 @@ void BreakableStringLiteral::insertBreak Prefix, InPPDirective, 1, IndentLevel, LeadingSpaces); } -static StringRef getLineCommentIndentPrefix(StringRef Comment) { - static const char *const KnownPrefixes[] = {"///", "//", "//!"}; - StringRef LongestPrefix; - for (StringRef KnownPrefix : KnownPrefixes) { -if (Comment.startswith(KnownPrefix)) { - size_t PrefixLength = KnownPrefix.size(); - while (PrefixLength < Comment.size() && Comment[PrefixLength] == ' ') -++PrefixLength; - if (PrefixLength > LongestPrefix.size()) -LongestPrefix = Comment.substr(0, PrefixLength); -} - } - return LongestPrefix; -} - BreakableLineComment::BreakableLineComment( const FormatToken &Token, unsigned IndentLevel, unsigned StartColumn, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) Modified: cfe/trunk/lib/Format/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/CMakeLists.txt?rev=284573&r1=284572&r2=284573&view=diff == --- cfe/trunk/lib/Format/CMakeLists.txt (original) +++ cfe/trunk/lib/Format/CMakeLists.txt Wed Oct 19 03:19:46 2016 @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support) add_clang_library(clangFormat AffectedRangeManager.cpp BreakableToken.cpp + Comments.cpp ContinuationIndenter.cpp Format.cpp FormatToken.cpp Added: cfe/trunk/lib/Format/Comments.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Comments.cpp?rev=284573&view=auto == --- cfe/trunk/lib/Format/Comments.cpp (added) +++ cfe/trunk/lib/Format/Comments.cpp Wed Oct 19 03:19:46 2016 @@ -0,0 +1,36 @@ +//===--- Comments.cpp - Comment Manipulation ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +/// +/// \file +/// \brief Implements comment manipulation. +/// +//===--===// + +#include "Comments.h" + +namespace clang { +namespace format { + +StringRef getLineCommentIndentPrefix(StringRef Comment) { + static const char *const KnownPrefixes[] = {"///", "//", "//!"}; + StringRef LongestPrefix; + for (StringRef KnownPrefix : KnownPrefixes) { +if (Comment.startswith(KnownPrefix)) { + size_t PrefixLength = KnownPrefix.size(); + while (PrefixLength < Comment.size() && Comment[PrefixLength] == ' ') +++PrefixLength; + if (PrefixLength > LongestPrefix.size()) +LongestPrefix = Comment.substr(0, PrefixLength); +} + } + return LongestPrefix; +} + +} // namespace format +} // namespace clang Added: cfe/trunk/lib/Format/Comments.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Comments.h?rev=284573&view=auto == --- cfe/trunk/lib/Format/Comments.h (added) +++ cfe/trunk/lib/Format/Comments.h Wed Oct 19 03:19:46 2016 @@ -0,0 +1,33 @@ +//===--- Comments.cpp - Comment manipulation -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details.
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
srhines created this revision. srhines added a reviewer: cfe-commits. srhines added subscribers: danalbert, pirama. Herald added subscribers: tberghammer, rengolin, aemerson. This is only forced on if there is no non-Cortex-A53 CPU specified as well. Android's platform and NDK builds need to assume that the code can be run on Cortex-A53 devices, so we always enable the fix unless we know specifically that the code is only running on a different kind of CPU. https://reviews.llvm.org/D25761 Files: lib/Driver/Tools.cpp Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -9677,6 +9677,14 @@ if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) arm::appendEBLinkFlags(Args, CmdArgs, Triple); + // Most Android ARM64 targets should enable the linker fix for erratum + // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. + if (Arch == llvm::Triple::aarch64 && isAndroid) { +std::string CPU = getCPUName(Args, Triple); +if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53") + CmdArgs.push_back("--fix-cortex-a53-843419"); + } + for (const auto &Opt : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -9677,6 +9677,14 @@ if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) arm::appendEBLinkFlags(Args, CmdArgs, Triple); + // Most Android ARM64 targets should enable the linker fix for erratum + // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. + if (Arch == llvm::Triple::aarch64 && isAndroid) { +std::string CPU = getCPUName(Args, Triple); +if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53") + CmdArgs.push_back("--fix-cortex-a53-843419"); + } + for (const auto &Opt : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
jmolloy accepted this revision. jmolloy added a reviewer: jmolloy. jmolloy added a comment. This revision is now accepted and ready to land. LGTM. https://reviews.llvm.org/D25761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
srhines added a comment. From what I can tell, there is no nice way to generate tests for Clang's driver when producing linker flags. -### only works for the -cc1 command line (which won't see this flag, since it is only for linking, and not compilation). If there is a suggestion for how to automatically test this, I am listening, but all my local tests looked fine (for generating/suppressing the flag). :) https://reviews.llvm.org/D25761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25762: [clang-move] Move using-decl in old cc.
hokein created this revision. hokein added a reviewer: ioeric. hokein added a subscriber: cfe-commits. Another fix is to move the whole anonymous namespace declaration completely instead of moving fun/var declarations only. https://reviews.llvm.org/D25762 Files: clang-move/ClangMove.cpp test/clang-move/Inputs/multiple_class_test.cpp test/clang-move/move-multiple-classes.cpp Index: test/clang-move/move-multiple-classes.cpp === --- test/clang-move/move-multiple-classes.cpp +++ test/clang-move/move-multiple-classes.cpp @@ -18,6 +18,10 @@ // CHECK-OLD-TEST-H: } // namespace c // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h" +// CHECK-OLD-TEST-CPP: namespace { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: static int k = 0; +// CHECK-OLD-TEST-CPP: } // CHECK-OLD-TEST-CPP: namespace c { // CHECK-OLD-TEST-CPP: int NoMove::f() { // CHECK-OLD-TEST-CPP: return 0; @@ -62,7 +66,12 @@ // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace a +// CHECK-NEW-TEST-CPP: namespace { +// CHECK-NEW-TEST-CPP: using a::Move1; +// CHECK-NEW-TEST-CPP: static int k = 0; +// CHECK-NEW-TEST-CPP: } // CHECK-NEW-TEST-CPP: namespace b { +// CHECK-NEW-TEST-CPP: using a::Move1; // CHECK-NEW-TEST-CPP: int Move2::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace b // CHECK-NEW-TEST-CPP: namespace c { Index: test/clang-move/Inputs/multiple_class_test.cpp === --- test/clang-move/Inputs/multiple_class_test.cpp +++ test/clang-move/Inputs/multiple_class_test.cpp @@ -6,7 +6,13 @@ } } // namespace a +namespace { +using a::Move1; +static int k = 0; +} + namespace b { +using a::Move1; int Move2::f() { return 0; } Index: clang-move/ClangMove.cpp === --- clang-move/ClangMove.cpp +++ clang-move/ClangMove.cpp @@ -351,20 +351,22 @@ .bind("class_static_var_decl"), this); - auto inAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); - // Match functions/variables definitions which are defined in anonymous - // namespace in old cc. + auto InAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), -inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + usingDecl(InOldCC, unless(InAnonymousNamespace)).bind("using_decl"), this); + // Match anonymous namespace decl in old cc. + Finder->addMatcher(namespaceDecl(isAnonymous(), InOldCC).bind("anonymous_ns"), + this); + // Match static functions/variabale definitions in old cc. Finder->addMatcher( namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), + unless(InAnonymousNamespace), isStaticStorageClass(), InOldCC), varDecl(isDefinition(), unless(InMovedClass), + unless(InAnonymousNamespace), isStaticStorageClass(), InOldCC))) .bind("static_decls"), this); @@ -398,12 +400,15 @@ // Skip all forwad declarations which appear after moved class declaration. if (RemovedDecls.empty()) MovedDecls.emplace_back(FWD, &Result.Context->getSourceManager()); - } else if (const auto *FD = Result.Nodes.getNodeAs( - "decls_in_anonymous_ns")) { -MovedDecls.emplace_back(FD, &Result.Context->getSourceManager()); + } else if (const auto *ANS = Result.Nodes.getNodeAs( + "anonymous_ns")) { +MovedDecls.emplace_back(ANS, &Result.Context->getSourceManager()); } else if (const auto *ND = Result.Nodes.getNodeAs("static_decls")) { MovedDecls.emplace_back(ND, &Result.Context->getSourceManager()); + } else if (const auto *UD = + Result.Nodes.getNodeAs("using_decl")) { +MovedDecls.emplace_back(UD, &Result.Context->getSourceManager()); } } Index: test/clang-move/move-multiple-classes.cpp === --- test/clang-move/move-multiple-classes.cpp +++ test/clang-move/move-multiple-classes.cpp @@ -18,6 +18,10 @@ // CHECK-OLD-TEST-H: } // namespace c // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h" +// CHECK-OLD-TEST-CPP: namespace { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: static int k = 0; +// CHECK-OLD-TEST-CPP: } // CHECK-OLD-TEST-CPP: namespace c { // CHECK-OLD-TEST-CPP: int NoMove::f() { // CHECK-OLD-TEST-CPP: return 0; @@ -62,7 +66,12 @@ // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace a +// CHECK-NEW-T
[PATCH] D25762: [clang-move] Move using-decl in old cc.
ioeric added inline comments. Comment at: clang-move/ClangMove.cpp:356 Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), -inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + usingDecl(InOldCC, unless(InAnonymousNamespace)).bind("using_decl"), this); Is `UsingDirectiveDecl`, i.e. using namespace decl, included in this case? Comment at: clang-move/ClangMove.cpp:366 namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), + unless(InAnonymousNamespace), isStaticStorageClass(), InOldCC), Seems that filters for `functionDecl` and `varDecl` are the same? Maybe apply them on `namedDecl`? Comment at: test/clang-move/Inputs/multiple_class_test.cpp:9 +namespace { +using a::Move1; Can you also add tests where using decls are in classes/functions? https://reviews.llvm.org/D25762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
rengolin added a comment. In https://reviews.llvm.org/D25761#573892, @srhines wrote: > From what I can tell, there is no nice way to generate tests for Clang's > driver when producing linker flags. -### only works for the -cc1 command line > (which won't see this flag, since it is only for linking, and not > compilation). If there is a suggestion for how to automatically test this, I > am listening, but all my local tests looked fine (for generating/suppressing > the flag). :) I think "clang -v" will show the linker invocation, with all its flags. https://reviews.llvm.org/D25761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
srhines added a comment. In https://reviews.llvm.org/D25761#573902, @rengolin wrote: > In https://reviews.llvm.org/D25761#573892, @srhines wrote: > > > From what I can tell, there is no nice way to generate tests for Clang's > > driver when producing linker flags. -### only works for the -cc1 command > > line (which won't see this flag, since it is only for linking, and not > > compilation). If there is a suggestion for how to automatically test this, > > I am listening, but all my local tests looked fine (for > > generating/suppressing the flag). :) > > > I think "clang -v" will show the linker invocation, with all its flags. But is there a way to get a dry-run of the linker? I don't want to run /usr/bin/ld for ARM targets. It seems like all of the other linker flag-related tests in tests/Driver/ only work for x86. https://reviews.llvm.org/D25761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
rengolin added a comment. In https://reviews.llvm.org/D25761#573903, @srhines wrote: > > I think "clang -v" will show the linker invocation, with all its flags. > > But is there a way to get a dry-run of the linker? I don't want to run > /usr/bin/ld for ARM targets. It seems like all of the other linker > flag-related tests in tests/Driver/ only work for x86. I think the combination of -v and -### does that, no? https://reviews.llvm.org/D25761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25305: [OpenCL] Setting constant address space for array initializers
bader accepted this revision. bader added a comment. LGTM https://reviews.llvm.org/D25305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284577 - [modules] Do not report missing definitions of demoted constexpr variable templates.
Author: vvassilev Date: Wed Oct 19 06:19:30 2016 New Revision: 284577 URL: http://llvm.org/viewvc/llvm-project?rev=284577&view=rev Log: [modules] Do not report missing definitions of demoted constexpr variable templates. This is a followup to regression introduced in r284284. This should fix our libstdc++ modules builds. https://reviews.llvm.org/D25678 Reviewed by Richard Smith! Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap cfe/trunk/test/Modules/merge-var-template-def.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284577&r1=284576&r2=284577&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 19 06:19:30 2016 @@ -10124,7 +10124,11 @@ void Sema::ActOnUninitializedDecl(Decl * // C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only to // the definition of a variable [...] or the declaration of a static data // member. -if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) { +if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() && +!Var->isThisDeclarationADemotedDefinition()) { + assert((!Var->isThisDeclarationADemotedDefinition() || + getLangOpts().Modules) && + "Demoting decls is only in the contest of modules!"); if (Var->isStaticDataMember()) { // C++1z removes the relevant rule; the in-class declaration is always // a definition there. Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h?rev=284577&view=auto == --- cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h (added) +++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h Wed Oct 19 06:19:30 2016 @@ -0,0 +1,8 @@ +#ifndef A_H +#define A_H +template +struct S { static constexpr T value = v; }; +template +constexpr T S::value; + +#endif Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h?rev=284577&view=auto == --- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h (added) +++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h Wed Oct 19 06:19:30 2016 @@ -0,0 +1,9 @@ +#ifndef B1_H +#define B1_H +template +struct S { static constexpr T value = v; }; +template +constexpr T S::value; + +#include "a.h" +#endif Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h?rev=284577&view=auto == --- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h (added) +++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h Wed Oct 19 06:19:30 2016 @@ -0,0 +1,9 @@ +#ifndef B2_H +#define B2_H + +template +struct S { static constexpr T value = v; }; +template +constexpr T S::value; + +#endif Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap?rev=284577&view=auto == --- cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap (added) +++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap Wed Oct 19 06:19:30 2016 @@ -0,0 +1,5 @@ +module a { header "a.h" export * } +module b { + module b1 { header "b1.h" export * } + module b2 { header "b2.h" export * } +} Added: cfe/trunk/test/Modules/merge-var-template-def.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-var-template-def.cpp?rev=284577&view=auto == --- cfe/trunk/test/Modules/merge-var-template-def.cpp (added) +++ cfe/trunk/test/Modules/merge-var-template-def.cpp Wed Oct 19 06:19:30 2016 @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s +// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s +// expected-no-diagnostics + +#include "b2.h" +const bool *y = &S::value;
[PATCH] D25678: [modules] Do not report missing definitions of demoted constexpr variable templates.This is a followup to regression introduced in r284284.This should fix our libstdc++ modules builds.
v.g.vassilev closed this revision. v.g.vassilev added a comment. Landed in r284577. https://reviews.llvm.org/D25678 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r284382 - Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of"
I totally misinterpreted this revert. I was confused it reverted r284284. Sorry for the noise. With the fix introduced in r284577 our bots should be happy. On 19/10/16 09:50, Vassil Vassilev wrote: On 17/10/16 17:07, Benjamin Kramer wrote: I'm running into something else and your patch doesn't fix it. It boils down to 'std::is_nothrow_move_constructible' from libstdc++ not compiling because Foo is not visible inside the noexcept specification of that template. I failed to come up with a small test case so far as it involves at least 2 modules :[ Sigh... :( Did you have the time to find a reproducer for this issue, we are very interested in relanding this patch. On Mon, Oct 17, 2016 at 4:44 PM, Vassil Vassilev wrote: On 17/10/16 16:40, Benjamin Kramer wrote: Too slow ;) Do you have the fix somewhere, so I can try it? That would be https://reviews.llvm.org/D25678 Do you run into something else than what I have as a test case (merging templated constexpr variables)? On Mon, Oct 17, 2016 at 4:38 PM, Vassil Vassilev wrote: I was just to commit a fix :( On 17/10/16 15:00, Benjamin Kramer via cfe-commits wrote: Author: d0k Date: Mon Oct 17 08:00:44 2016 New Revision: 284382 URL: http://llvm.org/viewvc/llvm-project?rev=284382&view=rev Log: Revert "Reinstate r281429, reverted in r281452, with a fix for its mishandling of" This reverts commit r284176. It still marks some modules as invisible that should be visible. Will follow up with the author with a test case. Removed: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap cfe/trunk/test/Modules/merge-var-template-def.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/c.h cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/d.h cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=284382&r1=284381&r2=284382&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Oct 17 08:00:44 2016 @@ -308,18 +308,10 @@ class ASTContext : public RefCountedBase /// merged into. llvm::DenseMap MergedDecls; - /// The modules into which a definition has been merged, or a map from a - /// merged definition to its canonical definition. This is really a union of - /// a NamedDecl* and a vector of Module*. - struct MergedModulesOrCanonicalDef { -llvm::TinyPtrVector MergedModules; -NamedDecl *CanonicalDef = nullptr; - }; - /// \brief A mapping from a defining declaration to a list of modules (other /// than the owning module of the declaration) that contain merged /// definitions of that entity. - llvm::DenseMap MergedDefModules; + llvm::DenseMap> MergedDefModules; /// \brief Initializers for a module, in order. Each Decl will be either /// something that has a semantic effect on startup (such as a variable with @@ -891,7 +883,6 @@ public: /// and should be visible whenever \p M is visible. void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners = true); - void mergeDefinitionIntoModulesOf(NamedDecl *ND, NamedDecl *Other); /// \brief Clean up the merged definition list. Call this if you might have /// added duplicates into the list. void deduplicateMergedDefinitonsFor(NamedDecl *ND); @@ -902,9 +893,7 @@ public: auto MergedIt = MergedDefModules.find(Def); if (MergedIt == MergedDefModules.end()) return None; -if (auto *CanonDef = MergedIt->second.CanonicalDef) - return getModulesWithMergedDefinition(CanonDef); -return MergedIt->second.MergedModules; +return MergedIt->second; } /// Add a declaration to the list of declarations that are initialized Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=284382&r1=284381&r2=284382&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 17 08:00:44 2016 @@ -888,74 +888,18 @@ void ASTContext::mergeDefinitionIntoModu if (auto *Listener = getASTMutationListener()) Listener->RedefinedHiddenD
r284579 - [Sema] Gcc compatibility of vector shift
Author: asbokhan Date: Wed Oct 19 07:06:10 2016 New Revision: 284579 URL: http://llvm.org/viewvc/llvm-project?rev=284579&view=rev Log: [Sema] Gcc compatibility of vector shift Gcc prints error if elements of left and right parts of a shift have different sizes. This patch is provided the GCC compatibility. Patch by Vladimir Yakovlev. Differential Revision: https://reviews.llvm.org/D24669 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/CodeGen/vecshift.c cfe/trunk/test/Sema/vecshift.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284579&r1=284578&r2=284579&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Oct 19 07:06:10 2016 @@ -2305,6 +2305,9 @@ def err_typecheck_vector_not_convertable "cannot convert between vector and non-scalar values (%0 and %1)">; def err_typecheck_vector_lengths_not_equal : Error< "vector operands do not have the same number of elements (%0 and %1)">; +def warn_typecheck_vector_element_sizes_not_equal : Warning< + "vector operands do not have the same elements sizes (%0 and %1)">, + InGroup>, DefaultError; def err_ext_vector_component_exceeds_length : Error< "vector component access exceeds type %0">; def err_ext_vector_component_name_illegal : Error< Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=284579&r1=284578&r2=284579&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Oct 19 07:06:10 2016 @@ -8790,6 +8790,16 @@ static QualType checkVectorShift(Sema &S << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); return QualType(); } +if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) { + const BuiltinType *LHSBT = LHSEleType->getAs(); + const BuiltinType *RHSBT = RHSEleType->getAs(); + if (LHSBT != RHSBT && + S.Context.getTypeSize(LHSBT) != S.Context.getTypeSize(RHSBT)) { +S.Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal) +<< LHS.get()->getType() << RHS.get()->getType() +<< LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); + } +} } else { // ...else expand RHS to match the number of elements in LHS. QualType VecTy = Modified: cfe/trunk/test/CodeGen/vecshift.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vecshift.c?rev=284579&r1=284578&r2=284579&view=diff == --- cfe/trunk/test/CodeGen/vecshift.c (original) +++ cfe/trunk/test/CodeGen/vecshift.c Wed Oct 19 07:06:10 2016 @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -Wno-error-vec-elem-size -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -Wno-error-vec-elem-size -DEXT -emit-llvm %s -o - | FileCheck %s +#ifdef EXT typedef __attribute__((__ext_vector_type__(8))) char vector_char8; typedef __attribute__((__ext_vector_type__(8))) short vector_short8; typedef __attribute__((__ext_vector_type__(8))) int vector_int8; @@ -12,6 +14,20 @@ typedef __attribute__((__ext_vector_type typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4; typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4; typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4; +#else +typedef __attribute__((vector_size(8))) char vector_char8; +typedef __attribute__((vector_size(16))) short vector_short8; +typedef __attribute__((vector_size(32))) int vector_int8; +typedef __attribute__((vector_size(8))) unsigned char vector_uchar8; +typedef __attribute__((vector_size(16))) unsigned short vector_ushort8; +typedef __attribute__((vector_size(32))) unsigned int vector_uint8; +typedef __attribute__((vector_size(4))) char vector_char4; +typedef __attribute__((vector_size(4))) short vector_short4; +typedef __attribute__((vector_size(16))) int vector_int4; +typedef __attribute__((vector_size(4))) unsigned char vector_uchar4; +typedef __attribute__((vector_size(8))) unsigned short vector_ushort4; +typedef __attribute__((vector_size(16))) unsigned int vector_uint4; +#endif char c; short s; Modified: cfe/trunk/test/Sema/vecshift.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vecshift.c?rev=284579&r1=284578&r2=284579&view=diff == --- cfe/trunk/test/Sema/vecshift.c (original) +++ cfe/trunk/test/Sema/vecshift.c Wed Oct 19 07:06:10 2016 @@ -1,5 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-on
[PATCH] D24669: {Sema] Gcc compatibility of vector shift.
This revision was automatically updated to reflect the committed changes. Closed by commit rL284579: [Sema] Gcc compatibility of vector shift (authored by asbokhan). Changed prior to commit: https://reviews.llvm.org/D24669?vs=74269&id=75130#toc Repository: rL LLVM https://reviews.llvm.org/D24669 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/CodeGen/vecshift.c cfe/trunk/test/Sema/vecshift.c Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -2305,6 +2305,9 @@ "cannot convert between vector and non-scalar values (%0 and %1)">; def err_typecheck_vector_lengths_not_equal : Error< "vector operands do not have the same number of elements (%0 and %1)">; +def warn_typecheck_vector_element_sizes_not_equal : Warning< + "vector operands do not have the same elements sizes (%0 and %1)">, + InGroup>, DefaultError; def err_ext_vector_component_exceeds_length : Error< "vector component access exceeds type %0">; def err_ext_vector_component_name_illegal : Error< Index: cfe/trunk/test/Sema/vecshift.c === --- cfe/trunk/test/Sema/vecshift.c +++ cfe/trunk/test/Sema/vecshift.c @@ -1,5 +1,9 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -DERR -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-error-vec-elem-size -verify %s +// RUN: %clang_cc1 -fsyntax-only -DEXT -DERR -verify %s +// RUN: %clang_cc1 -fsyntax-only -DEXT -Wno-error-vec-elem-size -verify %s +#ifdef EXT typedef __attribute__((__ext_vector_type__(8))) char vector_char8; typedef __attribute__((__ext_vector_type__(8))) short vector_short8; typedef __attribute__((__ext_vector_type__(8))) int vector_int8; @@ -12,6 +16,20 @@ typedef __attribute__((__ext_vector_type__(4))) unsigned char vector_uchar4; typedef __attribute__((__ext_vector_type__(4))) unsigned short vector_ushort4; typedef __attribute__((__ext_vector_type__(4))) unsigned int vector_uint4; +#else +typedef __attribute__((vector_size(8))) char vector_char8; +typedef __attribute__((vector_size(16))) short vector_short8; +typedef __attribute__((vector_size(32))) int vector_int8; +typedef __attribute__((vector_size(8))) unsigned char vector_uchar8; +typedef __attribute__((vector_size(16))) unsigned short vector_ushort8; +typedef __attribute__((vector_size(32))) unsigned int vector_uint8; +typedef __attribute__((vector_size(4))) char vector_char4; +typedef __attribute__((vector_size(4))) short vector_short4; +typedef __attribute__((vector_size(16))) int vector_int4; +typedef __attribute__((vector_size(4))) unsigned char vector_uchar4; +typedef __attribute__((vector_size(8))) unsigned short vector_ushort4; +typedef __attribute__((vector_size(16))) unsigned int vector_uint4; +#endif char c; short s; @@ -48,16 +66,30 @@ vus8 = 1 << vus8; vc8 = vc8 << vc8; - vi8 = vi8 << vuc8; - vuc8 = vuc8 << vi8; - vus8 = vus8 << vui8; - vui8 = vui8 << vs8; +#ifdef ERR + vi8 = vi8 << vuc8; // expected-error {{vector operands do not have the same elements sizes}} + vuc8 = vuc8 << vi8; // expected-error {{vector operands do not have the same elements sizes}} + vus8 = vus8 << vui8; // expected-error {{vector operands do not have the same elements sizes}} + vui8 = vui8 << vs8; // expected-error {{vector operands do not have the same elements sizes}} +#else + vi8 = vi8 << vuc8; // expected-warning {{vector operands do not have the same elements sizes}} + vuc8 = vuc8 << vi8; // expected-warning {{vector operands do not have the same elements sizes}} + vus8 = vus8 << vui8; // expected-warning {{vector operands do not have the same elements sizes}} + vui8 = vui8 << vs8; // expected-warning {{vector operands do not have the same elements sizes}} +#endif vc8 <<= vc8; - vi8 <<= vuc8; - vuc8 <<= vi8; - vus8 <<= vui8; - vui8 <<= vs8; +#ifdef ERR + vi8 <<= vuc8; // expected-error {{vector operands do not have the same elements sizes}} + vuc8 <<= vi8; // expected-error {{vector operands do not have the same elements sizes}} + vus8 <<= vui8; // expected-error {{vector operands do not have the same elements sizes}} + vui8 <<= vs8; // expected-error {{vector operands do not have the same elements sizes}} +#else + vi8 <<= vuc8; // expected-warning {{vector operands do not have the same elements sizes}} + vuc8 <<= vi8; // expected-warning {{vector operands do not have the same elements sizes}} + vus8 <<= vui8; // expected-warning {{vector operands do not have the same elements sizes}} + vui8 <<= vs8; // expected-warning {{vector operands do not have the same elements sizes}} +#endif c <<= vc8; // expected-error {{assigning to 'char' from incompatible type}} i <<= vuc8; // expected-error {{assigning to 'int' from incompat
r284582 - [cmake] Use LLVM_CMAKE_PATH for GetSVN script
Author: mgorny Date: Wed Oct 19 07:21:39 2016 New Revision: 284582 URL: http://llvm.org/viewvc/llvm-project?rev=284582&view=rev Log: [cmake] Use LLVM_CMAKE_PATH for GetSVN script Use the LLVM_CMAKE_PATH variable to locate the GetSVN.cmake script. The variable was already available in stand-alone builds, and is also set by LLVM since r284581. Modified: cfe/trunk/lib/Basic/CMakeLists.txt Modified: cfe/trunk/lib/Basic/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/CMakeLists.txt?rev=284582&r1=284581&r2=284582&view=diff == --- cfe/trunk/lib/Basic/CMakeLists.txt (original) +++ cfe/trunk/lib/Basic/CMakeLists.txt Wed Oct 19 07:21:39 2016 @@ -28,7 +28,7 @@ find_first_existing_vc_file(clang_vc "${ # The VC revision include that we want to generate. set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/SVNVersion.inc") -set(get_svn_script "${LLVM_MAIN_SRC_DIR}/cmake/modules/GetSVN.cmake") +set(get_svn_script "${LLVM_CMAKE_PATH}/GetSVN.cmake") if(DEFINED llvm_vc AND DEFINED clang_vc) # Create custom target to generate the VC revision include. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r284583 - [cmake] Allow testing against installed LLVM with no sources
Author: mgorny Date: Wed Oct 19 07:34:17 2016 New Revision: 284583 URL: http://llvm.org/viewvc/llvm-project?rev=284583&view=rev Log: [cmake] Allow testing against installed LLVM with no sources Adjust the stand-alone build files to accept either CMake files from LLVM_CMAKE_PATH or from LLVM_MAIN_SRC_DIR instead of requiring both. This makes it possible to run libcxx tests on top of installed LLVM and lit, without having to unpack a copy of LLVM sources. Furthermore, it avoids adding duplicate paths. Differential Revision: https://reviews.llvm.org/D25093 Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=284583&r1=284582&r2=284583&view=diff == --- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original) +++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Wed Oct 19 07:34:17 2016 @@ -43,21 +43,16 @@ macro(find_llvm_parts) return() endif() - if (NOT EXISTS ${LLVM_MAIN_SRC_DIR}) + if (EXISTS "${LLVM_CMAKE_PATH}") +list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules") +list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") + else() set(LLVM_FOUND OFF) -message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}") +message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found") return() endif() - if(NOT EXISTS ${LLVM_CMAKE_PATH}) -set(LLVM_FOUND OFF) -message(WARNING "Not found: ${LLVM_CMAKE_PATH}") -return() - endif() - - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") - list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") - set(LLVM_FOUND ON) endmacro(find_llvm_parts) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources
mgorny added a comment. Thanks for the review. Committed now. Repository: rL LLVM https://reviews.llvm.org/D25093 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources
This revision was automatically updated to reflect the committed changes. Closed by commit rL284583: [cmake] Allow testing against installed LLVM with no sources (authored by mgorny). Changed prior to commit: https://reviews.llvm.org/D25093?vs=73048&id=75132#toc Repository: rL LLVM https://reviews.llvm.org/D25093 Files: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Index: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake === --- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -43,21 +43,16 @@ return() endif() - if (NOT EXISTS ${LLVM_MAIN_SRC_DIR}) -set(LLVM_FOUND OFF) -message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}") -return() - endif() - - if(NOT EXISTS ${LLVM_CMAKE_PATH}) + if (EXISTS "${LLVM_CMAKE_PATH}") +list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules") +list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") + else() set(LLVM_FOUND OFF) -message(WARNING "Not found: ${LLVM_CMAKE_PATH}") +message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found") return() endif() - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") - list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") - set(LLVM_FOUND ON) endmacro(find_llvm_parts) Index: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake === --- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -43,21 +43,16 @@ return() endif() - if (NOT EXISTS ${LLVM_MAIN_SRC_DIR}) -set(LLVM_FOUND OFF) -message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}") -return() - endif() - - if(NOT EXISTS ${LLVM_CMAKE_PATH}) + if (EXISTS "${LLVM_CMAKE_PATH}") +list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules") +list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") + else() set(LLVM_FOUND OFF) -message(WARNING "Not found: ${LLVM_CMAKE_PATH}") +message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found") return() endif() - list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") - list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") - set(LLVM_FOUND ON) endmacro(find_llvm_parts) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25764: Add end location of loop to loop metadata.
fhahn created this revision. fhahn added a reviewer: hfinkel. fhahn added a subscriber: cfe-commits. The patch adds the loop end location to the loop metadata. This additional information can be used to improve the locations when generating remarks for loops. The patch depends on the companion LLVM patch https://reviews.llvm.org/D25763 (https://reviews.llvm.org/D25763). https://reviews.llvm.org/D25764 Files: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGLoopInfo.cpp lib/CodeGen/CGLoopInfo.h lib/CodeGen/CGStmt.cpp lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenFunction.h test/CodeGenCXX/debug-info-line-if.cpp test/CodeGenCXX/debug-info-loops.cpp Index: test/CodeGenCXX/debug-info-loops.cpp === --- /dev/null +++ test/CodeGenCXX/debug-info-loops.cpp @@ -0,0 +1,49 @@ +// RUN: %clang -g -gcolumn-info -std=c++11 -S -emit-llvm %s -o - | FileCheck %s +extern int v[2]; +int a = 0, b = 0; +int main() { +#line 100 + for (int x : v) { +if (x) + ++b; +else + ++a; + } + + // CHECK: br label {{.*}}, !dbg [[DBG1:![0-9]*]], !llvm.loop [[L1:![0-9]*]] + +#line 200 + while (a) +if (b) + ++b; +else + ++a; + // CHECK: br label {{.*}}, !dbg [[DBG2:![0-9]*]], !llvm.loop [[L2:![0-9]*]] + +#line 300 + for (unsigned i = 0; i < 100; i++) { +a++; +for (int y : v) + ++b; + } + + // CHECK: br label {{.*}}, !dbg [[DBG3:![0-9]*]], !llvm.loop [[L3:![0-9]*]] + // CHECK: br label {{.*}}, !dbg [[DBG3:![0-9]*]], !llvm.loop [[L4:![0-9]*]] + + + // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[SLDBG1:![0-9]*]], [[ELDBG1:![0-9]*]]} + // CHECK-DAG: [[SLDBG1]] = !DILocation(line: 100, column: 3, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG1]] = !DILocation(line: 105, column: 3, scope: !{{.*}}) + + // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[SLDBG2:![0-9]*]], [[ELDBG2:![0-9]*]]} + // CHECK-DAG: [[SLDBG2]] = !DILocation(line: 200, column: 3, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG2]] = !DILocation(line: 204, column: 9, scope: !{{.*}}) + + // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[SLDBG3:![0-9]*]], [[ELDBG3:![0-9]*]]} + // CHECK-DAG: [[SLDBG3]] = !DILocation(line: 302, column: 5, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG3]] = !DILocation(line: 303, column: 9, scope: !{{.*}}) + // + // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[SLDBG4:![0-9]*]], [[ELDBG4:![0-9]*]]} + // CHECK-DAG: [[SLDBG4]] = !DILocation(line: 300, column: 3, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG4]] = !DILocation(line: 304, column: 3, scope: !{{.*}}) +} Index: test/CodeGenCXX/debug-info-line-if.cpp === --- test/CodeGenCXX/debug-info-line-if.cpp +++ test/CodeGenCXX/debug-info-line-if.cpp @@ -53,15 +53,19 @@ // CHECK-DAG: [[DBG3]] = !DILocation(line: 300, scope: !{{.*}}) // CHECK-DAG: [[DBG4]] = !DILocation(line: 401, scope: !{{.*}}) - // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[LDBG1:![0-9]*]]} - // CHECK-DAG: [[LDBG1]] = !DILocation(line: 100, scope: !{{.*}}) + // CHECK-DAG: [[L1]] = distinct !{[[L1]], [[SLDBG1:![0-9]*]], [[ELDBG1:![0-9]*]]} + // CHECK-DAG: [[SLDBG1]] = !DILocation(line: 100, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG1]] = !DILocation(line: 104, scope: !{{.*}}) - // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[LDBG2:![0-9]*]]} - // CHECK-DAG: [[LDBG2]] = !DILocation(line: 200, scope: !{{.*}}) + // CHECK-DAG: [[L2]] = distinct !{[[L2]], [[SLDBG2:![0-9]*]], [[ELDBG2:![0-9]*]]} + // CHECK-DAG: [[SLDBG2]] = !DILocation(line: 200, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG2]] = !DILocation(line: 204, scope: !{{.*}}) - // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[LDBG3:![0-9]*]]} - // CHECK-DAG: [[LDBG3]] = !DILocation(line: 300, scope: !{{.*}}) + // CHECK-DAG: [[L3]] = distinct !{[[L3]], [[SLDBG3:![0-9]*]], [[ELDBG3:![0-9]*]]} + // CHECK-DAG: [[SLDBG3]] = !DILocation(line: 300, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG3]] = !DILocation(line: 304, scope: !{{.*}}) - // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[LDBG4:![0-9]*]]} - // CHECK-DAG: [[LDBG4]] = !DILocation(line: 401, scope: !{{.*}}) + // CHECK-DAG: [[L4]] = distinct !{[[L4]], [[SLDBG4:![0-9]*]], [[ELDBG4:![0-9]*]]} + // CHECK-DAG: [[SLDBG4]] = !DILocation(line: 401, scope: !{{.*}}) + // CHECK-DAG: [[ELDBG4]] = !DILocation(line: 405, scope: !{{.*}}) } Index: lib/CodeGen/CodeGenFunction.h === --- lib/CodeGen/CodeGenFunction.h +++ lib/CodeGen/CodeGenFunction.h @@ -2103,6 +2103,10 @@ OffsetValue); } + /// Converts Location to a DebugLoc, if debug information is enabled. + llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location); + + //======// //Declaration Emission //======// Inde
[PATCH] D25760: [AVX512][Clang] Adding missing instructions' variations
coby created this revision. coby added reviewers: m_zuckerman, igorb, AsafBadouh, craig.topper. coby added a subscriber: cfe-commits. coby set the repository for this revision to rL LLVM. The following patch introduces the following alternations: 1. correcting the 'vpmulshiftqb' instruction, along with the respective intrinsics 2. Adding AVX512 missing instructions variants. llvm part: https://reviews.llvm.org/D25759 Repository: rL LLVM https://reviews.llvm.org/D25760 Files: include/clang/Basic/BuiltinsX86.def lib/Headers/avx512vbmiintrin.h lib/Headers/avx512vbmivlintrin.h test/CodeGen/avx512vbmi-builtins.c Index: lib/Headers/avx512vbmiintrin.h === --- lib/Headers/avx512vbmiintrin.h +++ lib/Headers/avx512vbmiintrin.h @@ -105,30 +105,30 @@ } static __inline__ __m512i __DEFAULT_FN_ATTRS -_mm512_mask_multishift_epi64_epi8 (__m512i __W, __mmask64 __M, __m512i __X, __m512i __Y) +_mm512_mask_multishift_epi64_epi8 (__m512i __W, __mmask8 __M, __m512i __X, __m512i __Y) { - return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X, -(__v64qi) __Y, -(__v64qi) __W, -(__mmask64) __M); + return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v8di) __X, +(__v8di) __Y, +(__v8di) __W, +(__mmask8) __M); } static __inline__ __m512i __DEFAULT_FN_ATTRS -_mm512_maskz_multishift_epi64_epi8 (__mmask64 __M, __m512i __X, __m512i __Y) +_mm512_maskz_multishift_epi64_epi8 (__mmask8 __M, __m512i __X, __m512i __Y) { - return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X, -(__v64qi) __Y, -(__v64qi) _mm512_setzero_si512 (), -(__mmask64) __M); + return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v8di) __X, +(__v8di) __Y, +(__v8di) _mm512_setzero_si512 (), +(__mmask8) __M); } static __inline__ __m512i __DEFAULT_FN_ATTRS _mm512_multishift_epi64_epi8 (__m512i __X, __m512i __Y) { - return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v64qi) __X, -(__v64qi) __Y, -(__v64qi) _mm512_undefined_epi32 (), -(__mmask64) -1); + return (__m512i) __builtin_ia32_vpmultishiftqb512_mask ((__v8di) __X, +(__v8di) __Y, +(__v8di) _mm512_undefined_epi32 (), +(__mmask8) -1); } Index: lib/Headers/avx512vbmivlintrin.h === --- lib/Headers/avx512vbmivlintrin.h +++ lib/Headers/avx512vbmivlintrin.h @@ -184,61 +184,61 @@ } static __inline__ __m128i __DEFAULT_FN_ATTRS -_mm_mask_multishift_epi64_epi8 (__m128i __W, __mmask16 __M, __m128i __X, __m128i __Y) +_mm_mask_multishift_epi64_epi8 (__m128i __W, __mmask8 __M, __m128i __X, __m128i __Y) { - return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X, -(__v16qi) __Y, -(__v16qi) __W, -(__mmask16) __M); + return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v2di) __X, +(__v2di) __Y, +(__v2di) __W, +(__mmask8) __M); } static __inline__ __m128i __DEFAULT_FN_ATTRS -_mm_maskz_multishift_epi64_epi8 (__mmask16 __M, __m128i __X, __m128i __Y) +_mm_maskz_multishift_epi64_epi8 (__mmask8 __M, __m128i __X, __m128i __Y) { - return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X, -(__v16qi) __Y, -(__v16qi) + return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v2di) __X, +(__v2di) __Y, +(__v2di) _mm_setzero_si128 (), -(__mmask16) __M); +(__mmask8) __M); } static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_multishift_epi64_epi8 (__m128i __X, __m128i __Y) { - return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v16qi) __X, -(__v16qi) __Y, -(__v16qi) + return (__m128i) __builtin_ia32_vpmultishiftqb128_mask ((__v2di) __X, +(__v2di) __Y, +(__v2di) _mm_undefined_si128 (), -(__mmask16) -1); +(__mmask8) -1); } static __inline__ __m256i __DEFAULT_FN_ATTRS -_mm256_mask_multishift_epi64_epi8 (__m256i __W, __mmask32 __M, __m256i __X, __m256i __Y) +_mm256_mask_multishift_epi64_epi8 (__m256i __W, __mmask8 __M, __m256i __X, __m256i __Y) { - return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v32qi) __X, -(__v32qi) __Y, -(__v32qi) __W, -(__mmask32) __M); + return (__m256i) __builtin_ia32_vpmultishiftqb256_mask ((__v4di) __X, +(__v4di) __Y, +(__v4di) __W, +(__mmask8) __M); } static __inline__ __m256i __DEFAULT_FN_ATTRS -_mm256_maskz_multishift_epi64_epi8 (__mmask32
[PATCH] D25337: [Modules] Add a command line option for enabling the modules feature exclusively for the Clang builtins.
eladcohen added a comment. In https://reviews.llvm.org/D25337#571845, @bruno wrote: > > The long answer is that there is a history of problems regarding the > > intrinsic files: > > http://lists.llvm.org/pipermail/cfe-dev/2016-May/048837.html > > http://lists.llvm.org/pipermail/cfe-dev/2016-September/050943.html > > Mainly compatibility issues because MSVC makes all the intrinsics > > available all the time, while in clang this is not always the case (On > > Windows the different h files are not-included unless asked for explicitly > > since AVX512 was added which impacted compile-time). > > Thinking a bit more about this: did you ever consider a solution where > "immintrin.h" (or any similar other) would use "#include_next" and > "__has_include_next" to point to a second level (user specified) immintrin.h, > which then could use ifdefs to only include what's relevant? I don't think we really want the users to have to maintain an updated user specific version of immintrin.h. Moreover, I think that at the end we actually do want clang to always include all the intrinsics same as MSVC. >> A suggestion was made to try and mitigate this by reducing the compile time >> using modules (only for the x86 intrinsics). This patch aims at adding this >> option. The new compile flag is just a milestone - if all goes well, we can >> turn this on by default (Then we won't actually need to use a specific >> compile flag, and we could always include all the intrinsic h files without >> their long compile time). > > The speedup sounds nice, but it seems awkward IMO to have such specific > behavior for x86 intrinsics only. The feature itself is not x86 specific. It can be used for all the clang builtins. As for enabling it by default, I did have only x86 in mind but it can be done for all targets as well. (will probably require checking that all the other intrinsic headers are modular and that the modulemap is up to date). https://reviews.llvm.org/D25337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25767: [Modules] Add a command line option for loading the clang builtins modulemap file.
eladcohen created this revision. eladcohen added reviewers: rsmith, bruno, zvi. eladcohen added a subscriber: cfe-commits. -fbuiltin-module-map loads the clang builtins modulemap file. (This is equivalent to -fmodule-map-file=/include/module.modulemap) It can be used for enabling clang's 'modules' feature for the clang intrinsics headers files. https://reviews.llvm.org/D25767 Files: docs/Modules.rst include/clang/Driver/Options.td lib/Driver/Tools.cpp test/Driver/modules.m test/Modules/compiler_builtins.m test/Modules/compiler_builtins_x86.c test/lit.cfg Index: test/lit.cfg === --- test/lit.cfg +++ test/lit.cfg @@ -268,6 +268,7 @@ config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + '/utils/test_debuginfo.pl ') ) config.substitutions.append( ('%itanium_abi_triple', makeItaniumABITriple(config.target_triple)) ) config.substitutions.append( ('%ms_abi_triple', makeMSABITriple(config.target_triple)) ) +config.substitutions.append( ('%resource_dir', getClangBuiltinIncludeDir(config.clang)) ) # The host triple might not be set, at least if we're compiling clang from # an already installed llvm. Index: test/Modules/compiler_builtins_x86.c === --- test/Modules/compiler_builtins_x86.c +++ test/Modules/compiler_builtins_x86.c @@ -1,5 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding +// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding // expected-no-diagnostics #include Index: test/Modules/compiler_builtins.m === --- test/Modules/compiler_builtins.m +++ test/Modules/compiler_builtins.m @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify // RUN: %clang_cc1 -fsyntax-only -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify +// RUN: %clang_cc1 -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -I%S/Inputs/System/usr/include -verify // expected-no-diagnostics #ifdef __SSE__ Index: test/Driver/modules.m === --- test/Driver/modules.m +++ test/Driver/modules.m @@ -51,6 +51,10 @@ // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map" // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=bar.map" +// RUN: %clang -fmodules -fbuiltin-module-map -### %s 2>&1 | FileCheck -check-prefix=CHECK-BUILTIN-MODULE-MAP %s +// CHECK-BUILTIN-MODULE-MAP: "-fmodules" +// CHECK-BUILTIN-MODULE-MAP: "-fmodule-map-file={{.*}}include{{/|}}module.modulemap" + // RUN: %clang -fmodules -fmodule-file=foo.pcm -fmodule-file=bar.pcm -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-FILES %s // CHECK-MODULE-FILES: "-fmodules" // CHECK-MODULE-FILES: "-fmodule-file=foo.pcm" Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -5533,6 +5533,18 @@ // definitions. Args.AddAllArgs(CmdArgs, options::OPT_fmodule_map_file); + // -fbuiltin-module-map can be used to load the clang + // builtin headers modulemap file. + if (Args.hasArg(options::OPT_fbuiltin_module_map)) { +SmallString<128> BuiltinModuleMap(getToolChain().getDriver().ResourceDir); +llvm::sys::path::append(BuiltinModuleMap, "include"); +llvm::sys::path::append(BuiltinModuleMap, "module.modulemap"); +if (llvm::sys::fs::exists(BuiltinModuleMap)) { + CmdArgs.push_back(Args.MakeArgString("-fmodule-map-file=" + + BuiltinModuleMap)); +} + } + // -fmodule-file can be used to specify files containing precompiled modules. if (HaveAnyModules) Args.AddAllArgs(CmdArgs, options::OPT_fmodule_file); Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -553,6 +553,8 @@ def fborland_extensions : Flag<["-"], "fborland-extensions">, Group, Flags<[CC1Option]>, HelpText<"Accept non-standard constructs supported by the Borland compiler">; def fbuiltin : Flag<["-"], "fbuiltin">, Group; +def fbuiltin_module_map : Flag <["-"], "fbuiltin-module-map">, Group, + Flags<[DriverOption]>, HelpText<"Load the clang builtins module map file.">; def fcaret_diagnostics : Flag<["-"], "fcaret-diagnostics">, Group; def fclasspath_EQ : Joined<["-"], "fclasspath=">, Group; def fcolor_diagnostics : Flag<["-"], "fcolor-diagnostics">, Group, I
[PATCH] D25337: [Modules] Add a command line option for enabling the modules feature exclusively for the Clang builtins.
eladcohen added a comment. In https://reviews.llvm.org/D25337#571877, @rsmith wrote: > I really don't like the command-line interface you're proposing here. It > seems like it will be extremely confusing what something like `-fmodules > -fexclusive-builtin-modules` means, for instance (usually, later `-f` flags > override earlier ones, so does this *turn off* modules for everything other > than builtin headers?). Instead, we should use a command-line interface that > more naturally / obviously composes with other flags. > > It seems like the behavior you want here is precisely: > > `-fmodules -fno-implicit-module-maps -fmodule-map-file= dir>/include/module.modulemap` > > > (The `-fmodules-validate-system-headers` part would only make sense for > people using clang directly from their build area; installed / released > versions of clang should not need this. Adding it makes your flag compose > poorly with other uses of modules.) > > I'd be happy with you adding a flag that is equivalent to > `-fmodule-map-file=/include/module.modulemap`. You are right, this is the behavior I was aiming at. I just hoped I could get a single flag to achieve it instead of 3, but I agree that it doesn't behave well with the other module flags. I uploaded the new flag in a separate review: https://reviews.llvm.org/D25767 > Also, it seems unlikely to me that we would ever turn this on by default. It > will cause havoc for distributed builds, especially ones that run compilation > actions in 'clean' environments, as (for instance) it will cause the complete > set of intrinsics headers to be compiled into a module on every compile. So > if this is your proposed solution for slow compiles using intrinsics headers, > you should be aware that this is not a complete solution to that problem. What do you mean by 'clean' environments? As in no intermediate artifacts (such as the .pcm files) could be cached? Do you have any thoughts or suggestions on how we can make the solution more complete? I guess one possibility to handle this matter (IIRC mentioned by Chandler in one of the discussions) is to pre-compile the actual builtins module as part of the build system. But IIUC this is not feasible since there could be a huge matrix of all the different configurations we will have to maintain, right? https://reviews.llvm.org/D25337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser
v.g.vassilev added inline comments. Comment at: clang-tidy/utils/UsingInserter.cpp:58 + if (AlreadyHasUsingDecl) { +AddedUsing.emplace(NameInFunction(Function, QualifiedName.str())); +return None; Using emplace seems to break our modules libstdc++ 4.7 builds: http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/6066 . Doesn't that break other 4.7 or earlier builds? https://reviews.llvm.org/D24997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25768: [Format] Cleanup after replacing constructor body with = default
malcolm.parsons created this revision. malcolm.parsons added a reviewer: djasper. malcolm.parsons added a subscriber: cfe-commits. Herald added a subscriber: klimek. Remove colon and commas after replacing constructor body with = default. Fix annotation of TT_CtorInitializerColon when preceded by a comment. https://reviews.llvm.org/D25768 Files: lib/Format/Format.cpp lib/Format/TokenAnnotator.cpp unittests/Format/CleanupTest.cpp Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -151,6 +151,16 @@ EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); } +TEST_F(CleanupTest, CtorInitializationSimpleRedundantColon) { + std::string Code = "class A {\nA() : =default; };"; + std::string Expected = "class A {\nA() =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); + + Code = "class A {\nA() : , =default; };"; + Expected = "class A {\nA() =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); +} + TEST_F(CleanupTest, ListRedundantComma) { std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }"; std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }"; @@ -239,6 +249,14 @@ Code = "class A {\nA() : , // comment\n y(1),{} };"; Expected = "class A {\nA() : // comment\n y(1){} };"; EXPECT_EQ(Expected, cleanupAroundOffsets({17}, Code)); + + Code = "class A {\nA() // comment\n : ,,{} };"; + Expected = "class A {\nA() // comment\n {} };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code)); + + Code = "class A {\nA() // comment\n : ,,=default; };"; + Expected = "class A {\nA() // comment\n =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code)); } TEST_F(CleanupTest, CtorInitializerInNamespace) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -520,7 +520,8 @@ Tok->Type = TT_BitFieldColon; } else if (Contexts.size() == 1 && !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) { -if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept)) +if (Tok->getPreviousNonComment()->isOneOf(tok::r_paren, + tok::kw_noexcept)) Tok->Type = TT_CtorInitializerColon; else Tok->Type = TT_InheritanceColon; Index: lib/Format/Format.cpp === --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1024,6 +1024,7 @@ cleanupLeft(Line->First, tok::comma, tok::r_paren); cleanupLeft(Line->First, TT_CtorInitializerComma, tok::l_brace); cleanupLeft(Line->First, TT_CtorInitializerColon, tok::l_brace); +cleanupLeft(Line->First, TT_CtorInitializerColon, tok::equal); } } Index: unittests/Format/CleanupTest.cpp === --- unittests/Format/CleanupTest.cpp +++ unittests/Format/CleanupTest.cpp @@ -151,6 +151,16 @@ EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); } +TEST_F(CleanupTest, CtorInitializationSimpleRedundantColon) { + std::string Code = "class A {\nA() : =default; };"; + std::string Expected = "class A {\nA() =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); + + Code = "class A {\nA() : , =default; };"; + Expected = "class A {\nA() =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({15}, Code)); +} + TEST_F(CleanupTest, ListRedundantComma) { std::string Code = "void f() { std::vector v = {1,2,,,3,{4,5}}; }"; std::string Expected = "void f() { std::vector v = {1,2,3,{4,5}}; }"; @@ -239,6 +249,14 @@ Code = "class A {\nA() : , // comment\n y(1),{} };"; Expected = "class A {\nA() : // comment\n y(1){} };"; EXPECT_EQ(Expected, cleanupAroundOffsets({17}, Code)); + + Code = "class A {\nA() // comment\n : ,,{} };"; + Expected = "class A {\nA() // comment\n {} };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code)); + + Code = "class A {\nA() // comment\n : ,,=default; };"; + Expected = "class A {\nA() // comment\n =default; };"; + EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code)); } TEST_F(CleanupTest, CtorInitializerInNamespace) { Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -520,7 +520,8 @@ Tok->Type = TT_BitFieldColon; } else if (Contexts.size() == 1 && !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) { -if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept)) +if (Tok->getPreviousNonComment()->isOneOf(tok::r_paren, + tok::kw_noexcept)) Tok->Type
[PATCH] D25762: [clang-move] Move using-decl in old cc.
hokein updated this revision to Diff 75139. hokein marked 2 inline comments as done. hokein added a comment. Address comments. - Cover type alias declarations. - Fix an issue of moving function-scope static definitions in non-moved classes. https://reviews.llvm.org/D25762 Files: clang-move/ClangMove.cpp test/clang-move/Inputs/multiple_class_test.cpp test/clang-move/move-multiple-classes.cpp Index: test/clang-move/move-multiple-classes.cpp === --- test/clang-move/move-multiple-classes.cpp +++ test/clang-move/move-multiple-classes.cpp @@ -18,8 +18,19 @@ // CHECK-OLD-TEST-H: } // namespace c // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h" +// CHECK-OLD-TEST-CPP: namespace { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: using namespace a; +// CHECK-OLD-TEST-CPP: static int k = 0; +// CHECK-OLD-TEST-CPP: } // anonymous namespace +// CHECK-OLD-TEST-CPP: namespace b { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: using namespace a; +// CHECK-OLD-TEST-CPP: using T = a::Move1; +// CHECK-OLD-TEST-CPP: } // namespace b // CHECK-OLD-TEST-CPP: namespace c { // CHECK-OLD-TEST-CPP: int NoMove::f() { +// CHECK-OLD-TEST-CPP: static int F = 0; // CHECK-OLD-TEST-CPP: return 0; // CHECK-OLD-TEST-CPP: } // CHECK-OLD-TEST-CPP: } // namespace c @@ -62,11 +73,23 @@ // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace a +// CHECK-NEW-TEST-CPP: namespace { +// CHECK-NEW-TEST-CPP: using a::Move1; +// CHECK-NEW-TEST-CPP: using namespace a; +// CHECK-NEW-TEST-CPP: static int k = 0; +// CHECK-NEW-TEST-CPP: } // anonymous namespace // CHECK-NEW-TEST-CPP: namespace b { +// CHECK-NEW-TEST-CPP: using a::Move1; +// CHECK-NEW-TEST-CPP: using namespace a; +// CHECK-NEW-TEST-CPP: using T = a::Move1; // CHECK-NEW-TEST-CPP: int Move2::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace b // CHECK-NEW-TEST-CPP: namespace c { -// CHECK-NEW-TEST-CPP: int Move3::f() { return 0; } +// CHECK-NEW-TEST-CPP: int Move3::f() { +// CHECK-NEW-TEST-CPP: using a::Move1; +// CHECK-NEW-TEST-CPP: using namespace b; +// CHECK-NEW-TEST-CPP: return 0; +// CHECK-NEW-TEST-CPP: } // CHECK-NEW-TEST-CPP: int Move4::f() { return 0; } // CHECK-NEW-TEST-CPP: int EnclosingMove5::a = 1; // CHECK-NEW-TEST-CPP: int EnclosingMove5::Nested::f() { return 0; } Index: test/clang-move/Inputs/multiple_class_test.cpp === --- test/clang-move/Inputs/multiple_class_test.cpp +++ test/clang-move/Inputs/multiple_class_test.cpp @@ -6,14 +6,25 @@ } } // namespace a +namespace { +using a::Move1; +using namespace a; +static int k = 0; +} // anonymous namespace + namespace b { +using a::Move1; +using namespace a; +using T = a::Move1; int Move2::f() { return 0; } } // namespace b namespace c { int Move3::f() { + using a::Move1; + using namespace b; return 0; } @@ -30,6 +41,7 @@ int EnclosingMove5::Nested::b = 1; int NoMove::f() { + static int F = 0; return 0; } } // namespace c Index: clang-move/ClangMove.cpp === --- clang-move/ClangMove.cpp +++ clang-move/ClangMove.cpp @@ -351,21 +351,31 @@ .bind("class_static_var_decl"), this); - auto inAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); - // Match functions/variables definitions which are defined in anonymous - // namespace in old cc. + auto InOldCCNamedNamespace = + allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC); + // Matching using decls/type alias decls which are in named namespace. Those + // in classes, functions and anonymous namespaces are covered in other + // matchers. Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), -inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + namedDecl( + anyOf(usingDecl(InOldCCNamedNamespace), +usingDirectiveDecl(InOldCC, InOldCCNamedNamespace), +typeAliasDecl(InOldCC, InOldCCNamedNamespace))) + .bind("using_decl"), this); - // Match static functions/variabale definitions in old cc. + // Match anonymous namespace decl in old cc. + Finder->addMatcher(namespaceDecl(isAnonymous(), InOldCC).bind("anonymous_ns"), + this); + + // Match static functions/variabale definitions which are defined in named + // spaces. + auto IsOldCCStaticDefinition = + allOf(isDefinition(), unless(InMovedClass), InOldCCNamedNamespace, +isStaticStorageClass()); Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), - isStaticStorageClass(), InOldCC), - varDecl(isDefinition(), unle
[PATCH] D25762: [clang-move] Move using-decl in old cc.
hokein marked an inline comment as done. hokein added inline comments. Comment at: clang-move/ClangMove.cpp:356 Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), -inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + usingDecl(InOldCC, unless(InAnonymousNamespace)).bind("using_decl"), this); ioeric wrote: > Is `UsingDirectiveDecl`, i.e. using namespace decl, included in this case? Also covered type alias declarations. Comment at: clang-move/ClangMove.cpp:366 namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), + unless(InAnonymousNamespace), isStaticStorageClass(), InOldCC), ioeric wrote: > Seems that filters for `functionDecl` and `varDecl` are the same? Maybe apply > them on `namedDecl`? I tried it before, but some ast matchers are not available on `nameDecl`. I simplified the code a little bit by pulling out these filters. https://reviews.llvm.org/D25762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25762: [clang-move] Move using-decl in old cc.
ioeric accepted this revision. ioeric added a comment. This revision is now accepted and ready to land. Lg Comment at: clang-move/ClangMove.cpp:372 + // Match static functions/variabale definitions which are defined in named + // spaces. + auto IsOldCCStaticDefinition = s/named spaces/named namespaces/ ? https://reviews.llvm.org/D25762 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser
bkramer added inline comments. Comment at: clang-tidy/utils/UsingInserter.cpp:58 + if (AlreadyHasUsingDecl) { +AddedUsing.emplace(NameInFunction(Function, QualifiedName.str())); +return None; v.g.vassilev wrote: > Using emplace seems to break our modules libstdc++ 4.7 builds: > http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/6066 > . Doesn't that break other 4.7 or earlier builds? GCC 4.7 isn't supported anymore by LLVM (rL284497) can we update that bot to a newer version of GCC? https://reviews.llvm.org/D24997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25769: [clang-tidy] Simplify modernize-use-default
malcolm.parsons created this revision. malcolm.parsons added reviewers: angelgarcia, aaron.ballman, alexfh. malcolm.parsons added a subscriber: cfe-commits. clang-tidy now cleans up after replacements, so leave colon and comma removal to that. https://reviews.llvm.org/D25769 Files: clang-tidy/modernize/UseDefaultCheck.cpp test/clang-tidy/modernize-use-default-copy.cpp Index: test/clang-tidy/modernize-use-default-copy.cpp === --- test/clang-tidy/modernize-use-default-copy.cpp +++ test/clang-tidy/modernize-use-default-copy.cpp @@ -8,7 +8,7 @@ }; OL::OL(const OL &Other) : Field(Other.Field) {} // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor [modernize-use-default] -// CHECK-FIXES: OL::OL(const OL &Other) = default; +// CHECK-FIXES: OL::OL(const OL &Other) = default; OL &OL::operator=(const OL &Other) { Field = Other.Field; return *this; @@ -20,7 +20,7 @@ struct IL { IL(const IL &Other) : Field(Other.Field) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: IL(const IL &Other) = default; + // CHECK-FIXES: IL(const IL &Other) = default; IL &operator=(const IL &Other) { Field = Other.Field; return *this; @@ -43,7 +43,8 @@ Mutable(Other.Mutable), Reference(Other.Reference), Const(Other.Const) {} // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default' - // CHECK-FIXES: Qual(const Qual &Other) = default; + // CHECK-FIXES: Qual(const Qual &Other) + // CHECK-FIXES: = default; int Field; volatile char Volatile; @@ -80,6 +81,8 @@ struct Comments { Comments(const Comments &Other) /* don't delete */ : /* this comment */ Field(Other.Field) {} + // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default' + // CHECK-FIXES: /* don't delete */ = default; int Field; }; @@ -95,7 +98,7 @@ struct ColonInComment { ColonInComment(const ColonInComment &Other) /* : */ : Field(Other.Field) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: ColonInComment(const ColonInComment &Other) /* : */ = default; + // CHECK-FIXES: ColonInComment(const ColonInComment &Other) /* : */ = default; int Field; }; @@ -116,7 +119,8 @@ BF(const BF &Other) : Field1(Other.Field1), Field2(Other.Field2), Field3(Other.Field3), Field4(Other.Field4) {} // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default' - // CHECK-FIXES: BF(const BF &Other) = default; + // CHECK-FIXES: BF(const BF &Other) {{$}} + // CHECK-FIXES: = default; BF &operator=(const BF &); unsigned Field1 : 3; @@ -140,7 +144,7 @@ struct BC : IL, OL, BF { BC(const BC &Other) : IL(Other), OL(Other), BF(Other) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: BC(const BC &Other) = default; + // CHECK-FIXES: BC(const BC &Other) = default; BC &operator=(const BC &Other); }; BC &BC::operator=(const BC &Other) { @@ -156,7 +160,7 @@ struct BCWM : IL, OL { BCWM(const BCWM &Other) : IL(Other), OL(Other), Bf(Other.Bf) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: BCWM(const BCWM &Other) = default; + // CHECK-FIXES: BCWM(const BCWM &Other) = default; BCWM &operator=(const BCWM &); BF Bf; }; @@ -200,7 +204,7 @@ // is a virtual OL at the beginning of VA (which is the same). VBC(const VBC &Other) : OL(Other), VA(Other), VB(Other) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: VBC(const VBC &Other) = default; + // CHECK-FIXES: VBC(const VBC &Other) = default; VBC &operator=(const VBC &Other); }; VBC &VBC::operator=(const VBC &Other) { @@ -335,7 +339,7 @@ struct NCRef { NCRef(NCRef &Other) : Field1(Other.Field1), Field2(Other.Field2) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' - // CHECK-FIXES: NCRef(NCRef &Other) = default; + // CHECK-FIXES: NCRef(NCRef &Other) = default; NCRef &operator=(NCRef &); int Field1, Field2; }; Index: clang-tidy/modernize/UseDefaultCheck.cpp === --- clang-tidy/modernize/UseDefaultCheck.cpp +++ clang-tidy/modernize/UseDefaultCheck.cpp @@ -20,37 +20,6 @@ static const char SpecialFunction[] = "SpecialFunction"; -/// \brief Finds the SourceLocation of the colon ':' before the initialization -/// list in the definition of a constructor. -static SourceLocation getColonLoc(const ASTContext *Context, - const CXXConstructorDecl *Ctor) { - // FIXME: First init is the first initialization that is going to be - // performed, no matter what was the real order in the source code. If the - // order of the inits is wrong in the code, it may result in a false negative. - SourceLocation FirstInit = (*Ctor->ini
[PATCH] D25768: [Format] Cleanup after replacing constructor body with = default
djasper accepted this revision. djasper added a comment. This revision is now accepted and ready to land. Looks good. https://reviews.llvm.org/D25768 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25208: [libc++] Make _LIBCPP_TYPE_VIS export members
smeenai added a comment. Ping. The way I see it, this doesn't change anything for people not building with hidden visibility (which should be most people, including the buildbots), but it does make `_LIBCPP_TYPE_VIS` more useful (and consistent with the existing Windows behavior) for people building (or attempting to build) with hidden visibility. https://reviews.llvm.org/D25208 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25769: [clang-tidy] Simplify modernize-use-default
malcolm.parsons added inline comments. Comment at: test/clang-tidy/modernize-use-default-copy.cpp:85 + // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default' + // CHECK-FIXES: /* don't delete */ = default; int Field; I don't know why cleanup removes this comment, but there are format units tests that check that it does. https://reviews.llvm.org/D25769 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25741: [libc++] Add configuration define for off_t functions
smeenai updated this revision to Diff 75142. smeenai added a comment. Addressing @mclow.lists's comment https://reviews.llvm.org/D25741 Files: include/__config include/fstream Index: include/fstream === --- include/fstream +++ include/fstream @@ -813,7 +813,7 @@ default: return pos_type(off_type(-1)); } -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) return pos_type(off_type(-1)); pos_type __r = ftell(__file_); @@ -832,7 +832,7 @@ { if (__file_ == 0 || sync()) return pos_type(off_type(-1)); -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) if (fseek(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); #else @@ -896,7 +896,7 @@ } } } -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) if (fseek(__file_, -__c, SEEK_CUR)) return -1; #else Index: include/__config === --- include/__config +++ include/__config @@ -908,6 +908,12 @@ #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF #endif +#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) +#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS +#endif +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG Index: include/fstream === --- include/fstream +++ include/fstream @@ -813,7 +813,7 @@ default: return pos_type(off_type(-1)); } -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) return pos_type(off_type(-1)); pos_type __r = ftell(__file_); @@ -832,7 +832,7 @@ { if (__file_ == 0 || sync()) return pos_type(off_type(-1)); -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) if (fseek(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); #else @@ -896,7 +896,7 @@ } } } -#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) if (fseek(__file_, -__c, SEEK_CUR)) return -1; #else Index: include/__config === --- include/__config +++ include/__config @@ -908,6 +908,12 @@ #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF #endif +#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) +#if defined(_WIN32) || defined(_NEWLIB_VERSION) +#define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS +#endif +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25621: DebugInfo: use uin32_t for alignment
vleschuk updated this revision to Diff 75143. vleschuk added a comment. - Removed all changes non-related to CGDebugInfo: will post them in separate NFC patch which will switch all unsigned alignment entries to uint32_t. https://reviews.llvm.org/D25621 Files: lib/CodeGen/CGDebugInfo.cpp Index: lib/CodeGen/CGDebugInfo.cpp === --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -596,7 +596,7 @@ } // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(BT); - uint64_t Align = CGM.getContext().getTypeAlign(BT); + uint32_t Align = CGM.getContext().getTypeAlign(BT); return DBuilder.createBasicType(BTName, Size, Align, Encoding); } @@ -607,7 +607,7 @@ Encoding = llvm::dwarf::DW_ATE_lo_user; uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + uint32_t Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createBasicType("complex", Size, Align, Encoding); } @@ -721,7 +721,7 @@ StringRef RDName = getClassName(RD); uint64_t Size = 0; - uint64_t Align = 0; + uint32_t Align = 0; const RecordDecl *D = RD->getDefinition(); if (D && D->isCompleteDefinition()) { @@ -749,7 +749,7 @@ // because that does not return the correct value for references. unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy); uint64_t Size = CGM.getTarget().getPointerWidth(AS); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + uint32_t Align = CGM.getContext().getTypeAlign(Ty); if (Tag == llvm::dwarf::DW_TAG_reference_type || Tag == llvm::dwarf::DW_TAG_rvalue_reference_type) @@ -776,7 +776,7 @@ SmallVector EltTys; QualType FType; uint64_t FieldSize, FieldOffset; - unsigned FieldAlign; + uint32_t FieldAlign; llvm::DINodeArray Elements; FieldOffset = 0; @@ -965,7 +965,7 @@ CGM.getTypes().getCGRecordLayout(RD).getBitFieldInfo(BitFieldDecl); uint64_t SizeInBits = BitFieldInfo.Size; assert(SizeInBits > 0 && "found named 0-width bitfield"); - unsigned AlignInBits = CGM.getContext().getTypeAlign(Ty); + uint32_t AlignInBits = CGM.getContext().getTypeAlign(Ty); uint64_t StorageOffsetInBits = CGM.getContext().toBits(BitFieldInfo.StorageOffset); uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset; @@ -987,7 +987,7 @@ unsigned line = getLineNumber(loc); uint64_t SizeInBits = 0; - unsigned AlignInBits = 0; + uint32_t AlignInBits = 0; if (!type->isIncompleteArrayType()) { TypeInfo TI = CGM.getContext().getTypeInfo(type); SizeInBits = TI.Width; @@ -1181,7 +1181,7 @@ QualType PointeeTy = ThisPtrTy->getPointeeType(); unsigned AS = CGM.getContext().getTargetAddressSpace(PointeeTy); uint64_t Size = CGM.getTarget().getPointerWidth(AS); -uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy); +uint32_t Align = CGM.getContext().getTypeAlign(ThisPtrTy); llvm::DIType *PointeeType = getOrCreateType(PointeeTy, Unit); llvm::DIType *ThisPtrType = DBuilder.createPointerType(PointeeType, Size, Align); @@ -1968,7 +1968,7 @@ // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + uint32_t Align = CGM.getContext().getTypeAlign(Ty); llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero; if (ID->getImplementation()) @@ -2052,7 +2052,7 @@ unsigned FieldLine = getLineNumber(Field->getLocation()); QualType FType = Field->getType(); uint64_t FieldSize = 0; -unsigned FieldAlign = 0; +uint32_t FieldAlign = 0; if (!FType->isIncompleteArrayType()) { @@ -2134,14 +2134,14 @@ llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript); uint64_t Size = CGM.getContext().getTypeSize(Ty); - uint64_t Align = CGM.getContext().getTypeAlign(Ty); + uint32_t Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); } llvm::DIType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile *Unit) { uint64_t Size; - uint64_t Align; + uint32_t Align; // FIXME: make getTypeAlign() aware of VLAs and incomplete array types if (const auto *VAT = dyn_cast(Ty)) { @@ -2264,7 +2264,7 @@ const EnumDecl *ED = Ty->getDecl(); uint64_t Size = 0; - uint64_t Align = 0; + uint32_t Align = 0; if (!ED->getTypeForDecl()->isIncompleteType()) { Size = CGM.getContext().getTypeSize(ED->getTypeForDecl()); Align = CGM.getContext().getTypeAlign(ED->getTypeForDecl()); @@ -2307,7 +2307,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { const EnumDecl *ED = Ty->getDecl(); uint64_t Size = 0; - uint64_t Align = 0; + uint32_t Align = 0; if (!ED->getTypeForDecl()->isIncompleteType()) { Size = CGM.getContext().getTypeSize(ED->getTypeForDecl());
[PATCH] D25621: DebugInfo: use uin32_t for alignment
vleschuk added a comment. In https://reviews.llvm.org/D25621#573671, @aprantl wrote: > This patch is conflating two set of changes: > (1) NFC: rename all occurrences of unsigned for alignment purposes in the > frontend with uint32_t > (2) shrink all debug-info-related alignment variables from uint64_t -> > unint32_t. > > I think this patch should only be doing the changes in (2). Agreed. Update this one. The (1) will come as separate NFC review along with corresponding LLVM patch. https://reviews.llvm.org/D25621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284589 - Don't copy replacements in for-range loop. NFC.
Author: d0k Date: Wed Oct 19 08:50:17 2016 New Revision: 284589 URL: http://llvm.org/viewvc/llvm-project?rev=284589&view=rev Log: Don't copy replacements in for-range loop. NFC. Modified: cfe/trunk/lib/Format/TokenAnalyzer.cpp Modified: cfe/trunk/lib/Format/TokenAnalyzer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnalyzer.cpp?rev=284589&r1=284588&r2=284589&view=diff == --- cfe/trunk/lib/Format/TokenAnalyzer.cpp (original) +++ cfe/trunk/lib/Format/TokenAnalyzer.cpp Wed Oct 19 08:50:17 2016 @@ -120,7 +120,7 @@ tooling::Replacements TokenAnalyzer::pro for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) { delete AnnotatedLines[i]; } -for (auto R : RunResult) { +for (const auto &R : RunResult) { auto Err = Result.add(R); // FIXME: better error handling here. For now, simply return an empty // Replacements to indicate failure. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r284589 - Don't copy replacements in for-range loop. NFC.
Author: d0k Date: Wed Oct 19 08:50:17 2016 New Revision: 284589 URL: http://llvm.org/viewvc/llvm-project?rev=284589&view=rev Log: Don't copy replacements in for-range loop. NFC. Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=284589&r1=284588&r2=284589&view=diff == --- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original) +++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Wed Oct 19 08:50:17 2016 @@ -416,7 +416,7 @@ int includeFixerMain(int argc, const cha // Write replacements to disk. Rewriter Rewrites(SM, LangOptions()); - for (const auto Replacement : FixerReplacements) { + for (const auto &Replacement : FixerReplacements) { if (!tooling::applyAllReplacements(Replacement, Rewrites)) { llvm::errs() << "Failed to apply replacements.\n"; return 1; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25770: [clang-tidy] Add cert-err09-cpp check alias.
curdeius created this revision. curdeius added reviewers: alexfh, hokein. curdeius added a subscriber: cfe-commits. This adds cert-err09-cpp alias for completeness, similar to cert-err61-cpp. https://reviews.llvm.org/D25770 Files: clang-tidy/cert/CERTTidyModule.cpp docs/clang-tidy/checks/cert-err09-cpp.rst docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst Index: docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst === --- docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst +++ docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst @@ -3,6 +3,7 @@ misc-throw-by-value-catch-by-reference == +"cert-err09-cpp" redirects here as an alias for this check. "cert-err61-cpp" redirects here as an alias for this check. Finds violations of the rule "Throw by value, catch by reference" presented for Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -10,6 +10,7 @@ cert-dcl54-cpp (redirects to misc-new-delete-overloads) cert-dcl59-cpp (redirects to google-build-namespaces) cert-env33-c + cert-err09-cpp (redirects to misc-throw-by-value-catch-by-reference) cert-err34-c cert-err52-cpp cert-err58-cpp Index: docs/clang-tidy/checks/cert-err09-cpp.rst === --- /dev/null +++ docs/clang-tidy/checks/cert-err09-cpp.rst @@ -0,0 +1,10 @@ +.. title:: clang-tidy - cert-err09-cpp +.. meta:: + :http-equiv=refresh: 5;URL=misc-throw-by-value-catch-by-reference.html + +cert-err09-cpp +== + +The cert-err09-cpp check is an alias, please see +`misc-throw-by-value-catch-by-reference `_ +for more information. Index: clang-tidy/cert/CERTTidyModule.cpp === --- clang-tidy/cert/CERTTidyModule.cpp +++ clang-tidy/cert/CERTTidyModule.cpp @@ -43,6 +43,8 @@ CheckFactories.registerCheck( "cert-oop11-cpp"); // ERR +CheckFactories.registerCheck( +"cert-err09-cpp"); CheckFactories.registerCheck( "cert-err52-cpp"); CheckFactories.registerCheck( Index: docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst === --- docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst +++ docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst @@ -3,6 +3,7 @@ misc-throw-by-value-catch-by-reference == +"cert-err09-cpp" redirects here as an alias for this check. "cert-err61-cpp" redirects here as an alias for this check. Finds violations of the rule "Throw by value, catch by reference" presented for Index: docs/clang-tidy/checks/list.rst === --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -10,6 +10,7 @@ cert-dcl54-cpp (redirects to misc-new-delete-overloads) cert-dcl59-cpp (redirects to google-build-namespaces) cert-env33-c + cert-err09-cpp (redirects to misc-throw-by-value-catch-by-reference) cert-err34-c cert-err52-cpp cert-err58-cpp Index: docs/clang-tidy/checks/cert-err09-cpp.rst === --- /dev/null +++ docs/clang-tidy/checks/cert-err09-cpp.rst @@ -0,0 +1,10 @@ +.. title:: clang-tidy - cert-err09-cpp +.. meta:: + :http-equiv=refresh: 5;URL=misc-throw-by-value-catch-by-reference.html + +cert-err09-cpp +== + +The cert-err09-cpp check is an alias, please see +`misc-throw-by-value-catch-by-reference `_ +for more information. Index: clang-tidy/cert/CERTTidyModule.cpp === --- clang-tidy/cert/CERTTidyModule.cpp +++ clang-tidy/cert/CERTTidyModule.cpp @@ -43,6 +43,8 @@ CheckFactories.registerCheck( "cert-oop11-cpp"); // ERR +CheckFactories.registerCheck( +"cert-err09-cpp"); CheckFactories.registerCheck( "cert-err52-cpp"); CheckFactories.registerCheck( ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24997: [ClangTidy] Add UsingInserter and NamespaceAliaser
v.g.vassilev added a subscriber: rsmith. v.g.vassilev added inline comments. Comment at: clang-tidy/utils/UsingInserter.cpp:58 + if (AlreadyHasUsingDecl) { +AddedUsing.emplace(NameInFunction(Function, QualifiedName.str())); +return None; bkramer wrote: > v.g.vassilev wrote: > > Using emplace seems to break our modules libstdc++ 4.7 builds: > > http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/6066 > > . Doesn't that break other 4.7 or earlier builds? > GCC 4.7 isn't supported anymore by LLVM (rL284497) can we update that bot to > a newer version of GCC? It is managed by @rsmith . He should be able to tell. https://reviews.llvm.org/D24997 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25770: [clang-tidy] Add cert-err09-cpp check alias.
hokein accepted this revision. hokein added a comment. This revision is now accepted and ready to land. LGTM, thanks. https://reviews.llvm.org/D25770 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r284592 - [clang-move] Move using-decl in old cc.
Author: hokein Date: Wed Oct 19 09:13:21 2016 New Revision: 284592 URL: http://llvm.org/viewvc/llvm-project?rev=284592&view=rev Log: [clang-move] Move using-decl in old cc. Summary: Another fix is to move the whole anonymous namespace declaration completely instead of moving fun/var declarations only. Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25762 Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=284592&r1=284591&r2=284592&view=diff == --- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original) +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Wed Oct 19 09:13:21 2016 @@ -351,21 +351,31 @@ void ClangMoveTool::registerMatchers(ast .bind("class_static_var_decl"), this); - auto inAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); - // Match functions/variables definitions which are defined in anonymous - // namespace in old cc. + auto InOldCCNamedNamespace = + allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC); + // Matching using decls/type alias decls which are in named namespace. Those + // in classes, functions and anonymous namespaces are covered in other + // matchers. Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), -inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + namedDecl( + anyOf(usingDecl(InOldCCNamedNamespace), +usingDirectiveDecl(InOldCC, InOldCCNamedNamespace), +typeAliasDecl(InOldCC, InOldCCNamedNamespace))) + .bind("using_decl"), this); - // Match static functions/variabale definitions in old cc. + // Match anonymous namespace decl in old cc. + Finder->addMatcher(namespaceDecl(isAnonymous(), InOldCC).bind("anonymous_ns"), + this); + + // Match static functions/variable definitions which are defined in named + // namespaces. + auto IsOldCCStaticDefinition = + allOf(isDefinition(), unless(InMovedClass), InOldCCNamedNamespace, +isStaticStorageClass()); Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), - isStaticStorageClass(), InOldCC), - varDecl(isDefinition(), unless(InMovedClass), - isStaticStorageClass(), InOldCC))) + namedDecl(anyOf(functionDecl(IsOldCCStaticDefinition), + varDecl(IsOldCCStaticDefinition))) .bind("static_decls"), this); @@ -398,12 +408,15 @@ void ClangMoveTool::run(const ast_matche // Skip all forwad declarations which appear after moved class declaration. if (RemovedDecls.empty()) MovedDecls.emplace_back(FWD, &Result.Context->getSourceManager()); - } else if (const auto *FD = Result.Nodes.getNodeAs( - "decls_in_anonymous_ns")) { -MovedDecls.emplace_back(FD, &Result.Context->getSourceManager()); + } else if (const auto *ANS = Result.Nodes.getNodeAs( + "anonymous_ns")) { +MovedDecls.emplace_back(ANS, &Result.Context->getSourceManager()); } else if (const auto *ND = Result.Nodes.getNodeAs("static_decls")) { MovedDecls.emplace_back(ND, &Result.Context->getSourceManager()); + } else if (const auto *UD = + Result.Nodes.getNodeAs("using_decl")) { +MovedDecls.emplace_back(UD, &Result.Context->getSourceManager()); } } Modified: clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp?rev=284592&r1=284591&r2=284592&view=diff == --- clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp (original) +++ clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp Wed Oct 19 09:13:21 2016 @@ -6,7 +6,16 @@ int Move1::f() { } } // namespace a +namespace { +using a::Move1; +using namespace a; +static int k = 0; +} // anonymous namespace + namespace b { +using a::Move1; +using namespace a; +using T = a::Move1; int Move2::f() { return 0; } @@ -14,6 +23,8 @@ int Move2::f() { namespace c { int Move3::f() { + using a::Move1; + using namespace b; return 0; } @@ -30,6 +41,7 @@ int EnclosingMove5::Nested::f() { int EnclosingMove5::Nested::b = 1; int NoMove::f() { + static int F = 0; return 0; } } // namespace c Modified: clang-tools-e
[PATCH] D25762: [clang-move] Move using-decl in old cc.
This revision was automatically updated to reflect the committed changes. hokein marked 2 inline comments as done. Closed by commit rL284592: [clang-move] Move using-decl in old cc. (authored by hokein). Changed prior to commit: https://reviews.llvm.org/D25762?vs=75139&id=75146#toc Repository: rL LLVM https://reviews.llvm.org/D25762 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/test/clang-move/Inputs/multiple_class_test.cpp clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp === --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -351,21 +351,31 @@ .bind("class_static_var_decl"), this); - auto inAnonymousNamespace = hasParent(namespaceDecl(isAnonymous())); - // Match functions/variables definitions which are defined in anonymous - // namespace in old cc. + auto InOldCCNamedNamespace = + allOf(hasParent(namespaceDecl(unless(isAnonymous(, InOldCC); + // Matching using decls/type alias decls which are in named namespace. Those + // in classes, functions and anonymous namespaces are covered in other + // matchers. Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())), -inAnonymousNamespace) - .bind("decls_in_anonymous_ns"), + namedDecl( + anyOf(usingDecl(InOldCCNamedNamespace), +usingDirectiveDecl(InOldCC, InOldCCNamedNamespace), +typeAliasDecl(InOldCC, InOldCCNamedNamespace))) + .bind("using_decl"), this); - // Match static functions/variabale definitions in old cc. + // Match anonymous namespace decl in old cc. + Finder->addMatcher(namespaceDecl(isAnonymous(), InOldCC).bind("anonymous_ns"), + this); + + // Match static functions/variable definitions which are defined in named + // namespaces. + auto IsOldCCStaticDefinition = + allOf(isDefinition(), unless(InMovedClass), InOldCCNamedNamespace, +isStaticStorageClass()); Finder->addMatcher( - namedDecl(anyOf(functionDecl(isDefinition(), unless(InMovedClass), - isStaticStorageClass(), InOldCC), - varDecl(isDefinition(), unless(InMovedClass), - isStaticStorageClass(), InOldCC))) + namedDecl(anyOf(functionDecl(IsOldCCStaticDefinition), + varDecl(IsOldCCStaticDefinition))) .bind("static_decls"), this); @@ -398,12 +408,15 @@ // Skip all forwad declarations which appear after moved class declaration. if (RemovedDecls.empty()) MovedDecls.emplace_back(FWD, &Result.Context->getSourceManager()); - } else if (const auto *FD = Result.Nodes.getNodeAs( - "decls_in_anonymous_ns")) { -MovedDecls.emplace_back(FD, &Result.Context->getSourceManager()); + } else if (const auto *ANS = Result.Nodes.getNodeAs( + "anonymous_ns")) { +MovedDecls.emplace_back(ANS, &Result.Context->getSourceManager()); } else if (const auto *ND = Result.Nodes.getNodeAs("static_decls")) { MovedDecls.emplace_back(ND, &Result.Context->getSourceManager()); + } else if (const auto *UD = + Result.Nodes.getNodeAs("using_decl")) { +MovedDecls.emplace_back(UD, &Result.Context->getSourceManager()); } } Index: clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp === --- clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp +++ clang-tools-extra/trunk/test/clang-move/move-multiple-classes.cpp @@ -18,8 +18,19 @@ // CHECK-OLD-TEST-H: } // namespace c // CHECK-OLD-TEST-CPP: #include "{{.*}}multiple_class_test.h" +// CHECK-OLD-TEST-CPP: namespace { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: using namespace a; +// CHECK-OLD-TEST-CPP: static int k = 0; +// CHECK-OLD-TEST-CPP: } // anonymous namespace +// CHECK-OLD-TEST-CPP: namespace b { +// CHECK-OLD-TEST-CPP: using a::Move1; +// CHECK-OLD-TEST-CPP: using namespace a; +// CHECK-OLD-TEST-CPP: using T = a::Move1; +// CHECK-OLD-TEST-CPP: } // namespace b // CHECK-OLD-TEST-CPP: namespace c { // CHECK-OLD-TEST-CPP: int NoMove::f() { +// CHECK-OLD-TEST-CPP: static int F = 0; // CHECK-OLD-TEST-CPP: return 0; // CHECK-OLD-TEST-CPP: } // CHECK-OLD-TEST-CPP: } // namespace c @@ -62,11 +73,23 @@ // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Move1::f() { return 0; } // CHECK-NEW-TEST-CPP: } // namespace a +// CHECK-NEW-TEST-CPP: namespace { +// CHECK-NEW-TEST-CPP: using a::Move1; +// CHECK-NEW-TEST-CPP: using namespace a; +// CHECK-NEW-TEST-CPP: static int k = 0; +// CHECK-NEW-TEST-CPP: } // anonymous namespace // CHECK
r284595 - Remove unused diagnostics. NFC.
Author: d0k Date: Wed Oct 19 09:22:38 2016 New Revision: 284595 URL: http://llvm.org/viewvc/llvm-project?rev=284595&view=rev Log: Remove unused diagnostics. NFC. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284595&r1=284594&r2=284595&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Oct 19 09:22:38 2016 @@ -2377,11 +2377,6 @@ def err_swift_param_attr_not_swiftcall : "'%0' parameter can only be used with swiftcall calling convention">; def err_swift_indirect_result_not_first : Error< "'swift_indirect_result' parameters must be first parameters of function">; -def err_swift_context_not_before_swift_error_result : Error< - "'swift_context' parameter can only be followed by 'swift_error_result' " - "parameter">; -def err_swift_error_result_not_last : Error< - "'swift_error_result' parameter must be last parameter of function">; def err_swift_error_result_not_after_swift_context : Error< "'swift_error_result' parameter must follow 'swift_context' parameter">; def err_swift_abi_parameter_wrong_type : Error< ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r284596 - [clang-tidy] Add cert-err09-cpp check alias.
Author: mkurdej Date: Wed Oct 19 09:28:19 2016 New Revision: 284596 URL: http://llvm.org/viewvc/llvm-project?rev=284596&view=rev Log: [clang-tidy] Add cert-err09-cpp check alias. Summary: This adds cert-err09-cpp alias for completeness, similar to cert-err61-cpp. Reviewers: alexfh, hokein Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25770 Added: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=284596&r1=284595&r2=284596&view=diff == --- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Wed Oct 19 09:28:19 2016 @@ -43,6 +43,8 @@ public: CheckFactories.registerCheck( "cert-oop11-cpp"); // ERR +CheckFactories.registerCheck( +"cert-err09-cpp"); CheckFactories.registerCheck( "cert-err52-cpp"); CheckFactories.registerCheck( Added: clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst?rev=284596&view=auto == --- clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst (added) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/cert-err09-cpp.rst Wed Oct 19 09:28:19 2016 @@ -0,0 +1,10 @@ +.. title:: clang-tidy - cert-err09-cpp +.. meta:: + :http-equiv=refresh: 5;URL=misc-throw-by-value-catch-by-reference.html + +cert-err09-cpp +== + +The cert-err09-cpp check is an alias, please see +`misc-throw-by-value-catch-by-reference `_ +for more information. Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=284596&r1=284595&r2=284596&view=diff == --- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Wed Oct 19 09:28:19 2016 @@ -10,6 +10,7 @@ Clang-Tidy Checks cert-dcl54-cpp (redirects to misc-new-delete-overloads) cert-dcl59-cpp (redirects to google-build-namespaces) cert-env33-c + cert-err09-cpp (redirects to misc-throw-by-value-catch-by-reference) cert-err34-c cert-err52-cpp cert-err58-cpp Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst?rev=284596&r1=284595&r2=284596&view=diff == --- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst (original) +++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst Wed Oct 19 09:28:19 2016 @@ -3,6 +3,7 @@ misc-throw-by-value-catch-by-reference == +"cert-err09-cpp" redirects here as an alias for this check. "cert-err61-cpp" redirects here as an alias for this check. Finds violations of the rule "Throw by value, catch by reference" presented for ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
ioeric created this revision. ioeric added a reviewer: hokein. ioeric added a subscriber: cfe-commits. when replacing symbol references in moved namespaces, trying to make the replace name as short as possible by considering UsingDecl (i.e. UsingShadow) and UsingDirectiveDecl (i.e. using namespace decl). https://reviews.llvm.org/D25771 Files: change-namespace/ChangeNamespace.cpp change-namespace/ChangeNamespace.h unittests/change-namespace/ChangeNamespaceTests.cpp Index: unittests/change-namespace/ChangeNamespaceTests.cpp === --- unittests/change-namespace/ChangeNamespaceTests.cpp +++ unittests/change-namespace/ChangeNamespaceTests.cpp @@ -272,8 +272,8 @@ "}\n" "namespace nb {\n" "using nc::SAME;\n" - "using YO = nc::SAME;\n" - "typedef nc::SAME IDENTICAL;\n" + "using YO = nd::SAME;\n" + "typedef nd::SAME IDENTICAL;\n" "void f(nd::SAME Same) {}\n" "} // namespace nb\n" "} // namespace na\n"; @@ -292,93 +292,14 @@ "namespace x {\n" "namespace y {\n" "using ::na::nc::SAME;\n" - "using YO = na::nc::SAME;\n" - "typedef na::nc::SAME IDENTICAL;\n" + "using YO = na::nd::SAME;\n" + "typedef na::nd::SAME IDENTICAL;\n" "void f(na::nd::SAME Same) {}\n" "} // namespace y\n" "} // namespace x\n"; EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); } -TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "namespace na {\n" - "namespace nb {\n" - "void f() {\n" - " using glob::Glob;\n" - " Glob g;\n" - "}\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is UsingShadowDecl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() {\n" - " using ::glob::Glob;\n" - " glob::Glob g;\n" - "}\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - -TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using glob::Glob;\n" - "namespace na {\n" - "namespace nb {\n" - "void f() { Glob g; }\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is UsingShadowDecl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using glob::Glob;\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() { glob::Glob g; }\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - -TEST_F(ChangeNamespaceTest, UsingNamespace) { - std::string Code = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using namespace glob;\n" - "namespace na {\n" - "namespace nb {\n" - "void f() { Glob g; }\n" - "} // namespace nb\n" - "} // namespace na\n"; - - // FIXME: don't add namespace qualifier when there is "using namespace" decl. - std::string Expected = "namespace glob {\n" - "class Glob {};\n" - "}\n" - "using namespace glob;\n" - "\n" - "namespace x {\n" - "namespace y {\n" - "void f() { glob::Glob g; }\n" - "} // namespace y\n" - "} // namespace x\n"; - EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code)); -} - TES
[PATCH] D25597: Try to fix buildbot failure in VirtualFileSystem caused by r284129.
ioeric abandoned this revision. ioeric added a comment. Thanks all! https://reviews.llvm.org/D25597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25621: DebugInfo: use uin32_t for alignment
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Thanks, this LGTM! https://reviews.llvm.org/D25621 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r284602 - Implement constexpr support for reverse_iterator. Reviewed as https://reviews.llvm.org/D25534
Author: marshall Date: Wed Oct 19 10:12:50 2016 New Revision: 284602 URL: http://llvm.org/viewvc/llvm-project?rev=284602&view=rev Log: Implement constexpr support for reverse_iterator. Reviewed as https://reviews.llvm.org/D25534 Modified: libcxx/trunk/include/iterator libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp libcxx/trunk/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp libcxx/trunk/www/cxx1z_status.html Modified: libcxx/trunk/include/iterator URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=284602&r1=284601&r2=284602&view=diff == --- libcxx/trunk/include/iterator (original) +++ libcxx/trunk/include/iterator Wed Oct 19 10:12:50 2016 @@ -89,57 +89,60 @@ public: typedef typename iterator_traits::reference reference; typedef typename iterator_traits::pointer pointer; -reverse_iterator(); -explicit reverse_iterator(Iterator x); -template reverse_iterator(const reverse_iterator& u); -Iterator base() const; -reference operator*() const; -pointer operator->() const; -reverse_iterator& operator++(); -reverse_iterator operator++(int); -reverse_iterator& operator--(); -reverse_iterator operator--(int); -reverse_iterator operator+ (difference_type n) const; -reverse_iterator& operator+=(difference_type n); -reverse_iterator operator- (difference_type n) const; -reverse_iterator& operator-=(difference_type n); -reference operator[](difference_type n) const; +constexpr reverse_iterator(); +constexpr explicit reverse_iterator(Iterator x); +template constexpr reverse_iterator(const reverse_iterator& u); +template constexpr reverse_iterator& operator=(const reverse_iterator& u); +constexpr Iterator base() const; +constexpr reference operator*() const; +constexpr pointer operator->() const; +constexpr reverse_iterator& operator++(); +constexpr reverse_iterator operator++(int); +constexpr reverse_iterator& operator--(); +constexpr reverse_iterator operator--(int); +constexpr reverse_iterator operator+ (difference_type n)
[PATCH] D25534: Implement part of P0031; adding `constexpr` to `reverse_iterator`
mclow.lists closed this revision. mclow.lists marked 3 inline comments as done. mclow.lists added a comment. Landed as revision 284602 https://reviews.llvm.org/D25534 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25062: [x86][inline-asm][AVX512][llvm][PART-2] Introducing "k" and "Yk" constraints for extended inline assembly, enabling use of AVX512 masked vectorized instructions.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: lib/Target/X86/X86ISelLowering.cpp:32315 +} + // Else fall through (handle "Y" constraint). case 'v': Use LLVM_FALLTHROUGH here to avoid warnings in some compilers. Repository: rL LLVM https://reviews.llvm.org/D25062 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25703: [AST] Add CanonicalDeclPtr.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm https://reviews.llvm.org/D25703 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25702: [CUDA] Emit errors for wrong-side calls made on the same line as non-wrong-side calls.
rnk accepted this revision. rnk added a reviewer: rnk. rnk added a comment. This revision is now accepted and ready to land. lgtm I'm assuming you're going to follow this up with CanonicalDeclPtr usage. https://reviews.llvm.org/D25702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25702: [CUDA] Emit errors for wrong-side calls made on the same line as non-wrong-side calls.
jlebar added a comment. In https://reviews.llvm.org/D25702#574289, @rnk wrote: > lgtm > > I'm assuming you're going to follow this up with CanonicalDeclPtr usage. Yes, that's in https://reviews.llvm.org/D25704. https://reviews.llvm.org/D25702 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25704: [CUDA] When we emit an error that might have been deferred, also print a callstack.
rnk added inline comments. Comment at: clang/include/clang/Sema/Sema.h:9292 + llvm::DenseMap, + /* Callees = */ llvm::SetVector> + CUDACallGraph; Rather than having a custom key type, maybe it would be better to phrase this as a `MapVector, SourceLocation>` ? Despite all the comments, I assumed FunctionDeclAndLoc was hashed by both elements for a long time. Comment at: clang/include/clang/Sema/Sema.h:9322 + /// it's attached to is codegen'ed. Also emit a call stack as with + /// K_ImmedaiteWithCallStack. K_Deferred typo on "immediate" https://reviews.llvm.org/D25704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25777: [Sema][TreeTransform] Re-create DesignatedInitExpr when it has a field designator with a valid FieldDecl
arphaman created this revision. arphaman added reviewers: rjmccall, manmanren. arphaman added a subscriber: cfe-commits. arphaman set the repository for this revision to rL LLVM. This patch fixes an invalid `Winitializer-overrides` warning that's shown for a piece of code like this: template struct Foo { struct SubFoo { int bar1; int bar2; }; static void Test() { SubFoo sf = {.bar1 = 10, // Incorrect "initializer overrides prior initialization" warning shown on the line below when instantiating Foo .bar2 = 20}; } }; void foo() { Foo::Test(); Foo::Test(); } The invalid warning is shown because in the second instantiation of `Foo::Test` the `DesignatedInitExpr` that corresponds to the initializer for `sf` has a field designator with a pointer to the `FieldDecl` from the first instantiation of `Foo::SubFoo`, which is incorrect in the context of the second instantiation. This means that `InitListChecker::CheckDesignatedInitializer` isn't able to find the correct `FieldIndex` for the correct field in the initialized record, leading to an incorrect warning. This patch fixes this bug by ensuring that a `DesignatedInitExpr` is re-created by the tree-transformer when it has a field designator with a `FieldDecl` that has been already been set. This means that in the example above the `DesignatedInitExpr` won't be re-created by the tree-transformer in the first instantiation, but it will be re-created in the second instantiation, thus ensuring that the second instantiation doesn't have the incorrect `FieldDecl` pointers. Repository: rL LLVM https://reviews.llvm.org/D25777 Files: lib/Sema/TreeTransform.h test/SemaCXX/designated-initializers.cpp Index: test/SemaCXX/designated-initializers.cpp === --- /dev/null +++ test/SemaCXX/designated-initializers.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s + +template struct Foo { + struct SubFoo { +int bar1; +int bar2; + }; + + static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no warning +}; + +void foo() { + Foo::Test(); + Foo::Test(); + Foo::Test(); +} + +template struct Bar { + struct SubFoo { +int bar1; +int bar2; + }; + + static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 {{previous initialization is here}} +.bar1 = 20}; } // expected-warning 2 {{initializer overrides prior initialization of this subobject}} +}; + +void bar() { + Bar::Test(); // expected-note {{in instantiation of member function 'Bar::Test' requested here}} + Bar::Test(); // expected-note {{in instantiation of member function 'Bar::Test' requested here}} +} Index: lib/Sema/TreeTransform.h === --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -8923,6 +8923,8 @@ Desig.AddDesignator(Designator::getField(D.getFieldName(), D.getDotLoc(), D.getFieldLoc())); + if (D.getField()) +ExprChanged = true; continue; } Index: test/SemaCXX/designated-initializers.cpp === --- /dev/null +++ test/SemaCXX/designated-initializers.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s + +template struct Foo { + struct SubFoo { +int bar1; +int bar2; + }; + + static void Test() { SubFoo sf = {.bar1 = 10, .bar2 = 20}; } // Expected no warning +}; + +void foo() { + Foo::Test(); + Foo::Test(); + Foo::Test(); +} + +template struct Bar { + struct SubFoo { +int bar1; +int bar2; + }; + + static void Test() { SubFoo sf = {.bar1 = 10,// expected-note 2 {{previous initialization is here}} +.bar1 = 20}; } // expected-warning 2 {{initializer overrides prior initialization of this subobject}} +}; + +void bar() { + Bar::Test(); // expected-note {{in instantiation of member function 'Bar::Test' requested here}} + Bar::Test(); // expected-note {{in instantiation of member function 'Bar::Test' requested here}} +} Index: lib/Sema/TreeTransform.h === --- lib/Sema/TreeTransform.h +++ lib/Sema/TreeTransform.h @@ -8923,6 +8923,8 @@ Desig.AddDesignator(Designator::getField(D.getFieldName(), D.getDotLoc(), D.getFieldLoc())); + if (D.getField()) +ExprChanged = true; continue; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25305: [OpenCL] Setting constant address space for array initializers
Anastasia added inline comments. Comment at: lib/CodeGen/CGDecl.cpp:1272 +if (getLangOpts().OpenCL) { + UA = llvm::GlobalValue::UnnamedAddr::None; + AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); Why this change? https://reviews.llvm.org/D25305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25448: [ubsan] Use the object pointer's type info for devirtualized calls
vsk updated this revision to Diff 75168. vsk added a comment. Thanks for the feedback! Patch update: - Pass in the right CalleeDecl to EmitCXXMemberOrOperatorCall. This lets us drop the unnecessary 'DevirtualizedClassTy' optional parameter. - Extend the test case with John's example (devirt for methods marked 'final'). Since this hasn't yet been implemented in clang, make the checks depend on the relevant bug (PR13127). Tested with check-ubsan and check-clang. https://reviews.llvm.org/D25448 Files: lib/CodeGen/CGExprCXX.cpp test/CodeGenCXX/ubsan-devirtualized-calls.cpp Index: test/CodeGenCXX/ubsan-devirtualized-calls.cpp === --- /dev/null +++ test/CodeGenCXX/ubsan-devirtualized-calls.cpp @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm -fsanitize=vptr %s -o - | FileCheck %s + +struct Base1 { + virtual void f1() {} +}; + +struct Base2 { + virtual void f1() {} +}; + +struct Derived1 final : Base1 { + void f1() override {} +}; + +struct Derived2 final : Base1, Base2 { + void f1() override {} +}; + +// PR13127 documents some missed devirtualization opportunities, including +// devirt for methods marked 'final'. We can enable the checks marked 'PR13127' +// if we implement this in the frontend. +struct Derived3 : Base1 { + void f1() override /* nofinal */ {} +}; + +struct Derived4 final : Base1 { + void f1() override final {} +}; + +// CHECK: [[UBSAN_TI_DERIVED1_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived1 to i8* +// CHECK: [[UBSAN_TI_DERIVED2_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8* +// CHECK: [[UBSAN_TI_DERIVED2_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8* +// PR13127: [[UBSAN_TI_DERIVED3:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived3 to i8* +// PR13127: [[UBSAN_TI_BASE1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI5Base1 to i8* +// PR13127: [[UBSAN_TI_DERIVED4_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8* +// PR13127: [[UBSAN_TI_DERIVED4_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8* + +// CHECK-LABEL: define void @_Z2t1v +void t1() { + Derived1 d1; + static_cast(&d1)->f1(); //< Devirt Base1::f1 to Derived1::f1. + // CHECK: handler.dynamic_type_cache_miss: + // CHECK-NEXT: %[[D1:[0-9]+]] = ptrtoint %struct.Derived1* %d1 to i64, !nosanitize + // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED1_1]] {{.*}}, i64 %[[D1]] +} + +// CHECK-LABEL: define void @_Z2t2v +void t2() { + Derived2 d2; + static_cast(&d2)->f1(); //< Devirt Base1::f1 to Derived2::f1. + // CHECK: handler.dynamic_type_cache_miss: + // CHECK-NEXT: %[[D2_1:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize + // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED2_1]] {{.*}}, i64 %[[D2_1]] +} + +// CHECK-LABEL: define void @_Z2t3v +void t3() { + Derived2 d2; + static_cast(&d2)->f1(); //< Devirt Base2::f1 to Derived2::f1. + // CHECK: handler.dynamic_type_cache_miss: + // CHECK-NEXT: %[[D2_2:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize + // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED2_2]] {{.*}}, i64 %[[D2_2]] +} + +// PR13127-LABEL: define void @_Z2t4v +void t4() { + Base1 p; + Derived3 *badp = static_cast(&p); //< Check that &p isa Derived3. + // PR13127: handler.dynamic_type_cache_miss + // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived3* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED3]] {{.*}}, i64 %[[P1]] + + static_cast(badp)->f1(); //< No devirt, test 'badp isa Base1'. + // PR13127: handler.dynamic_type_cache_miss + // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Base1* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_BASE1]] {{.*}}, i64 %[[BADP1]] +} + +// PR13127-LABEL: define void @_Z2t5v +void t5() { + Base1 p; + Derived4 *badp = static_cast(&p); //< Check that &p isa Derived4. + // PR13127: handler.dynamic_type_cache_miss: + // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived4* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED4_1]] {{.*}}, i64 %[[P1]] + + static_cast(badp)->f1(); //< Devirt Base1::f1 to Derived4::f1. + // PR13127: handler.dynamic_type_cache_miss1: + // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Derived4* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED4_2]] {{.*}}, i64 %[[BADP1]] +} Index: lib/CodeGen/CGExprCXX.cpp === --- lib/CodeGen/CGExprCXX.cpp +++ lib/CodeGen/CGExprCXX.cpp @@ -241,6 +241,9 @@ llvm::FunctionType *Ty = CGM.getTypes().GetFunctionType(*FInfo)
[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null
mclow.lists added a comment. In https://reviews.llvm.org/D25595#572043, @timshen wrote: > BTW, `re.const/re.matchflag/match_flag_type.pass.cpp` contains match_not_bow, > but it doesn't actually test the functionality. It tests that it exists and that it has a sane value - which are a good things to test. But there are no tests that show that when passed to `regex_search` it does the right thing. https://reviews.llvm.org/D25595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284617 - [Myriad] Find libc++ headers next to clang binary
Author: dougk Date: Wed Oct 19 12:30:40 2016 New Revision: 284617 URL: http://llvm.org/viewvc/llvm-project?rev=284617&view=rev Log: [Myriad] Find libc++ headers next to clang binary Modified: cfe/trunk/lib/Driver/ToolChains.cpp cfe/trunk/test/Driver/myriad-toolchain.c Modified: cfe/trunk/lib/Driver/ToolChains.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=284617&r1=284616&r2=284617&view=diff == --- cfe/trunk/lib/Driver/ToolChains.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Oct 19 12:30:40 2016 @@ -5130,15 +5130,19 @@ void MyriadToolChain::AddClangCXXStdlibI DriverArgs.hasArg(options::OPT_nostdincxx)) return; - // Only libstdc++, for now. - StringRef LibDir = GCCInstallation.getParentLibPath(); - const GCCVersion &Version = GCCInstallation.getVersion(); - StringRef TripleStr = GCCInstallation.getTriple().str(); - const Multilib &Multilib = GCCInstallation.getMultilib(); - - addLibStdCXXIncludePaths( - LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, - "", TripleStr, "", "", Multilib.includeSuffix(), DriverArgs, CC1Args); + if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx) { +std::string Path(getDriver().getInstalledDir()); +Path += "/../include/c++/v1"; +addSystemInclude(DriverArgs, CC1Args, Path); + } else { +StringRef LibDir = GCCInstallation.getParentLibPath(); +const GCCVersion &Version = GCCInstallation.getVersion(); +StringRef TripleStr = GCCInstallation.getTriple().str(); +const Multilib &Multilib = GCCInstallation.getMultilib(); +addLibStdCXXIncludePaths( +LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text, +"", TripleStr, "", "", Multilib.includeSuffix(), DriverArgs, CC1Args); + } } // MyriadToolChain handles several triples: Modified: cfe/trunk/test/Driver/myriad-toolchain.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=284617&r1=284616&r2=284617&view=diff == --- cfe/trunk/test/Driver/myriad-toolchain.c (original) +++ cfe/trunk/test/Driver/myriad-toolchain.c Wed Oct 19 12:30:40 2016 @@ -69,8 +69,11 @@ // RUN: | FileCheck %s -check-prefix=PREPROCESS // PREPROCESS: "-E" "-DMYRIAD2" "-I" "foo" -// RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck %s --check-prefix=STDLIBCXX -// STDLIBCXX: "-lstdc++" "-lc" "-lgcc" +// RUN: %clang -target sparc-myriad -### --driver-mode=g++ %s 2>&1 | FileCheck %s --check-prefix=LIBSTDCXX +// LIBSTDCXX: "-lstdc++" "-lc" "-lgcc" + +// RUN: %clang -stdlib=libc++ -### -target sparcel-myriad -S -x c++ %s 2>&1 | FileCheck %s -check-prefix=LIBCXX +// LIBCXX: "-internal-isystem" "{{.*}}/../include/c++/v1" // RUN: %clang -target sparc-myriad -### -nostdlib %s 2>&1 | FileCheck %s --check-prefix=NOSTDLIB // NOSTDLIB-NOT: crtbegin.o ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null
mclow.lists added a comment. Do we need to test calling `regex_match` with `match_not_null`? If not, then I think this is good to go. Do you have commit access, or would you rather I committed it? https://reviews.llvm.org/D25595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h
Anastasia added a comment. In https://reviews.llvm.org/D25343#567374, @tstellarAMD wrote: > In https://reviews.llvm.org/D25343#565288, @Anastasia wrote: > > > Do you have any code example where Clang/LLVM performs wrong optimizations > > with respect to the control flow of SPMD execution? > > > > My understanding from the earlier discussion we have had: > > https://www.mail-archive.com/cfe-commits@lists.llvm.org/msg22643.html that > > noduplicate is essentially enough for the frontend to prevent erroneous > > optimizations. Because in general compiler can't do much with unknown > > function calls. > > > noduplicate is enough for correctness, but it prevents legal optimizations, > like unrolling loops with barriers. The convergent attribute was added > specifically for these kinds of builtins, so we should be using it here > instead of noduplicate. Should we deprecate noduplicate then as convergent should cover both use cases for OpenCL I believe? As far as I understand noduplicate was added specifically for SPMD use cases... Comment at: include/clang/Basic/AttrDocs.td:630 + void convfunc(void) __attribute__((convergent)); + // Setting it as a C++11 attribute is also valid in a C++ program. + // void convfunc(void) [[clang::convergent]]; Did you mean "in an OpenCL program"? Comment at: test/CodeGenOpenCL/convergent.cl:17 +//} else { +// non_conffun(); +//} -> non_convfun(); https://reviews.llvm.org/D25343 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25779: MS ABI: Don't assert when generating virtual function call with virtual bases and -flto (PR30731)
hans created this revision. hans added a reviewer: pcc. hans added a subscriber: cfe-commits. Herald added a subscriber: mehdi_amini. getClassAtVTableLocation() was calling ASTRecordLayout::getBaseClassOffset() on a virtual base, causing an assert. https://reviews.llvm.org/D25779 Files: lib/CodeGen/MicrosoftCXXABI.cpp test/CodeGenCXX/pr30731.cpp Index: test/CodeGenCXX/pr30731.cpp === --- /dev/null +++ test/CodeGenCXX/pr30731.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -flto -std=c++11 -o - %s | FileCheck %s + +struct A { + virtual ~A(); +}; + +struct B {}; + +struct C { + virtual void f(); +}; + +struct S : A, virtual B, C { + void f() override; +}; + +void f(S* s) { s->f(); } + +// CHECK-LABEL: define void @"\01?f@@YAXPAUS@@@Z" +// CHECK: call +// CHECK: ret void Index: lib/CodeGen/MicrosoftCXXABI.cpp === --- lib/CodeGen/MicrosoftCXXABI.cpp +++ lib/CodeGen/MicrosoftCXXABI.cpp @@ -1773,15 +1773,8 @@ CharUnits MaxBaseOffset; for (auto &&B : RD->bases()) { const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getBaseClassOffset(Base); -if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { - MaxBase = Base; - MaxBaseOffset = BaseOffset; -} - } - for (auto &&B : RD->vbases()) { -const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getVBaseClassOffset(Base); +CharUnits BaseOffset = B.isVirtual() ? Layout.getVBaseClassOffset(Base) + : Layout.getBaseClassOffset(Base); if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { MaxBase = Base; MaxBaseOffset = BaseOffset; Index: test/CodeGenCXX/pr30731.cpp === --- /dev/null +++ test/CodeGenCXX/pr30731.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -flto -std=c++11 -o - %s | FileCheck %s + +struct A { + virtual ~A(); +}; + +struct B {}; + +struct C { + virtual void f(); +}; + +struct S : A, virtual B, C { + void f() override; +}; + +void f(S* s) { s->f(); } + +// CHECK-LABEL: define void @"\01?f@@YAXPAUS@@@Z" +// CHECK: call +// CHECK: ret void Index: lib/CodeGen/MicrosoftCXXABI.cpp === --- lib/CodeGen/MicrosoftCXXABI.cpp +++ lib/CodeGen/MicrosoftCXXABI.cpp @@ -1773,15 +1773,8 @@ CharUnits MaxBaseOffset; for (auto &&B : RD->bases()) { const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getBaseClassOffset(Base); -if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { - MaxBase = Base; - MaxBaseOffset = BaseOffset; -} - } - for (auto &&B : RD->vbases()) { -const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getVBaseClassOffset(Base); +CharUnits BaseOffset = B.isVirtual() ? Layout.getVBaseClassOffset(Base) + : Layout.getBaseClassOffset(Base); if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { MaxBase = Base; MaxBaseOffset = BaseOffset; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25779: MS ABI: Don't assert when generating virtual function call with virtual bases and -flto (PR30731)
pcc accepted this revision. pcc added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D25779 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284620 - [mips][msa] Range check MSA intrinsics with immediates
Author: sdardis Date: Wed Oct 19 12:50:52 2016 New Revision: 284620 URL: http://llvm.org/viewvc/llvm-project?rev=284620&view=rev Log: [mips][msa] Range check MSA intrinsics with immediates This patch teaches clang to range check immediates for MIPS MSA instrinsics. This checking is done strictly in comparison to some existing GCC implementations. E.g. msa_andvi_b(var, 257) does not result in andvi $wX, 1. Similarily msa_ldi_b takes a range of -128 to 127. As part of this effort, correct the existing MSA test as it has both illegal types and immediates. Reviewers: vkalintiris Differential Revision: https://reviews.llvm.org/D25017 Added: cfe/trunk/test/CodeGen/builtins-mips-msa-error.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-mips-msa.c Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284620&r1=284619&r2=284620&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Oct 19 12:50:52 2016 @@ -7752,6 +7752,8 @@ def err_invalid_neon_type_code : Error< "incompatible constant for this __builtin_neon function">; def err_argument_invalid_range : Error< "argument should be a value from %0 to %1">; +def err_argument_not_multiple : Error< + "argument should be a multiple of %0">; def warn_neon_vector_initializer_non_portable : Warning< "vector initializers are not compatible with NEON intrinsics in big endian " "mode">, InGroup>; Modified: cfe/trunk/include/clang/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=284620&r1=284619&r2=284620&view=diff == --- cfe/trunk/include/clang/Sema/Sema.h (original) +++ cfe/trunk/include/clang/Sema/Sema.h Wed Oct 19 12:50:52 2016 @@ -9715,6 +9715,8 @@ private: llvm::APSInt &Result); bool SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High); + bool SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, + unsigned Multiple); bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, int ArgNum, unsigned ExpectedFieldNum, bool AllowName); Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=284620&r1=284619&r2=284620&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Oct 19 12:50:52 2016 @@ -1455,8 +1455,17 @@ bool Sema::CheckAArch64BuiltinFunctionCa return SemaBuiltinConstantArgRange(TheCall, i, l, u + l); } +// CheckMipsBuiltinFunctionCall - Checks the constant value passed to the +// intrinsic is correct. The switch statement is ordered by DSP, MSA. The +// ordering for DSP is unspecified. MSA is ordered by the data format used +// by the underlying instruction i.e., df/m, df/n and then by size. +// +// FIXME: The size tests here should instead be tablegen'd along with the +//definitions from include/clang/Basic/BuiltinsMips.def. +// FIXME: GCC is strict on signedness for some of these intrinsics, we should +//be too. bool Sema::CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { - unsigned i = 0, l = 0, u = 0; + unsigned i = 0, l = 0, u = 0, m = 0; switch (BuiltinID) { default: return false; case Mips::BI__builtin_mips_wrdsp: i = 1; l = 0; u = 63; break; @@ -1466,9 +1475,168 @@ bool Sema::CheckMipsBuiltinFunctionCall( case Mips::BI__builtin_mips_precr_sra_ph_w: i = 2; l = 0; u = 31; break; case Mips::BI__builtin_mips_precr_sra_r_ph_w: i = 2; l = 0; u = 31; break; case Mips::BI__builtin_mips_prepend: i = 2; l = 0; u = 31; break; + // MSA instrinsics. Instructions (which the intrinsics maps to) which use the + // df/m field. + // These intrinsics take an unsigned 3 bit immediate. + case Mips::BI__builtin_msa_bclri_b: + case Mips::BI__builtin_msa_bnegi_b: + case Mips::BI__builtin_msa_bseti_b: + case Mips::BI__builtin_msa_sat_s_b: + case Mips::BI__builtin_msa_sat_u_b: + case Mips::BI__builtin_msa_slli_b: + case Mips::BI__builtin_msa_srai_b: + case Mips::BI__builtin_msa_srari_b: + case Mips::BI__builtin_msa_srli_b: + case Mips::BI__builtin_msa_srlri_b: i = 1; l = 0; u = 7; break; + case Mips::BI__builtin_msa_binsli_b: + case Mips::BI__builtin_msa_binsri_b: i = 2; l = 0; u = 7; break; + // These intrinsics take an unsigned 4 bit immedia
[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.
srhines updated this revision to Diff 75174. srhines added a comment. Added a test for this behavior. I missed that "-### -v" was actually working correctly last night. Tests added so I am more satisfied that this won't break accidentally in the future. https://reviews.llvm.org/D25761 Files: lib/Driver/Tools.cpp test/Driver/android-aarch64-link.cpp Index: test/Driver/android-aarch64-link.cpp === --- /dev/null +++ test/Driver/android-aarch64-link.cpp @@ -0,0 +1,17 @@ +// Check that we automatically add relevant linker flags for Android aarch64. + +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -### -v %s 2> %t +// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s +// +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -mcpu=cortex-a53 -### -v %s 2> %t +// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s +// +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -mcpu=cortex-a57 -### -v %s 2> %t +// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s +// +// GENERIC-ARM: --fix-cortex-a53-843419 +// CORTEX-A53: --fix-cortex-a53-843419 +// CORTEX-A57-NOT: --fix-cortex-a53-843419 Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -9677,6 +9677,14 @@ if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) arm::appendEBLinkFlags(Args, CmdArgs, Triple); + // Most Android ARM64 targets should enable the linker fix for erratum + // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. + if (Arch == llvm::Triple::aarch64 && isAndroid) { +std::string CPU = getCPUName(Args, Triple); +if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53") + CmdArgs.push_back("--fix-cortex-a53-843419"); + } + for (const auto &Opt : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); Index: test/Driver/android-aarch64-link.cpp === --- /dev/null +++ test/Driver/android-aarch64-link.cpp @@ -0,0 +1,17 @@ +// Check that we automatically add relevant linker flags for Android aarch64. + +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -### -v %s 2> %t +// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s +// +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -mcpu=cortex-a53 -### -v %s 2> %t +// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s +// +// RUN: %clang -target aarch64-none-linux-android \ +// RUN: -mcpu=cortex-a57 -### -v %s 2> %t +// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s +// +// GENERIC-ARM: --fix-cortex-a53-843419 +// CORTEX-A53: --fix-cortex-a53-843419 +// CORTEX-A57-NOT: --fix-cortex-a53-843419 Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -9677,6 +9677,14 @@ if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb) arm::appendEBLinkFlags(Args, CmdArgs, Triple); + // Most Android ARM64 targets should enable the linker fix for erratum + // 843419. Only non-Cortex-A53 devices are allowed to skip this flag. + if (Arch == llvm::Triple::aarch64 && isAndroid) { +std::string CPU = getCPUName(Args, Triple); +if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53") + CmdArgs.push_back("--fix-cortex-a53-843419"); + } + for (const auto &Opt : ToolChain.ExtraOpts) CmdArgs.push_back(Opt.c_str()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25017: [mips][msa] Range check MSA intrinsics with immediates
This revision was automatically updated to reflect the committed changes. Closed by commit rL284620: [mips][msa] Range check MSA intrinsics with immediates (authored by sdardis). Changed prior to commit: https://reviews.llvm.org/D25017?vs=74499&id=75173#toc Repository: rL LLVM https://reviews.llvm.org/D25017 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/include/clang/Sema/Sema.h cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGen/builtins-mips-msa-error.c cfe/trunk/test/CodeGen/builtins-mips-msa.c Index: cfe/trunk/include/clang/Sema/Sema.h === --- cfe/trunk/include/clang/Sema/Sema.h +++ cfe/trunk/include/clang/Sema/Sema.h @@ -9715,6 +9715,8 @@ llvm::APSInt &Result); bool SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low, int High); + bool SemaBuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum, + unsigned Multiple); bool SemaBuiltinARMSpecialReg(unsigned BuiltinID, CallExpr *TheCall, int ArgNum, unsigned ExpectedFieldNum, bool AllowName); Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -7752,6 +7752,8 @@ "incompatible constant for this __builtin_neon function">; def err_argument_invalid_range : Error< "argument should be a value from %0 to %1">; +def err_argument_not_multiple : Error< + "argument should be a multiple of %0">; def warn_neon_vector_initializer_non_portable : Warning< "vector initializers are not compatible with NEON intrinsics in big endian " "mode">, InGroup>; Index: cfe/trunk/test/CodeGen/builtins-mips-msa.c === --- cfe/trunk/test/CodeGen/builtins-mips-msa.c +++ cfe/trunk/test/CodeGen/builtins-mips-msa.c @@ -138,28 +138,28 @@ v4i32_r = __msa_bclr_w(v4i32_a, v4i32_b); // CHECK: call <4 x i32> @llvm.mips.bclr.w( v2i64_r = __msa_bclr_d(v2i64_a, v2i64_b); // CHECK: call <2 x i64> @llvm.mips.bclr.d( - v16i8_r = __msa_bclri_b(v16i8_a, 25); // CHECK: call <16 x i8> @llvm.mips.bclri.b( - v8i16_r = __msa_bclri_h(v8i16_a, 25); // CHECK: call <8 x i16> @llvm.mips.bclri.h( + v16i8_r = __msa_bclri_b(v16i8_a, 3); // CHECK: call <16 x i8> @llvm.mips.bclri.b( + v8i16_r = __msa_bclri_h(v8i16_a, 8); // CHECK: call <8 x i16> @llvm.mips.bclri.h( v4i32_r = __msa_bclri_w(v4i32_a, 25); // CHECK: call <4 x i32> @llvm.mips.bclri.w( v2i64_r = __msa_bclri_d(v2i64_a, 25); // CHECK: call <2 x i64> @llvm.mips.bclri.d( v16i8_r = __msa_binsl_b(v16i8_r, v16i8_a, v16i8_b); // CHECK: call <16 x i8> @llvm.mips.binsl.b( v8i16_r = __msa_binsl_h(v8i16_r, v8i16_a, v8i16_b); // CHECK: call <8 x i16> @llvm.mips.binsl.h( v4i32_r = __msa_binsl_w(v4i32_r, v4i32_a, v4i32_b); // CHECK: call <4 x i32> @llvm.mips.binsl.w( v2i64_r = __msa_binsl_d(v2i64_r, v2i64_a, v2i64_b); // CHECK: call <2 x i64> @llvm.mips.binsl.d( - v16i8_r = __msa_binsli_b(v16i8_r, v16i8_a, 25); // CHECK: call <16 x i8> @llvm.mips.binsli.b( - v8i16_r = __msa_binsli_h(v8i16_r, v8i16_a, 25); // CHECK: call <8 x i16> @llvm.mips.binsli.h( + v16i8_r = __msa_binsli_b(v16i8_r, v16i8_a, 3); // CHECK: call <16 x i8> @llvm.mips.binsli.b( + v8i16_r = __msa_binsli_h(v8i16_r, v8i16_a, 8); // CHECK: call <8 x i16> @llvm.mips.binsli.h( v4i32_r = __msa_binsli_w(v4i32_r, v4i32_a, 25); // CHECK: call <4 x i32> @llvm.mips.binsli.w( v2i64_r = __msa_binsli_d(v2i64_r, v2i64_a, 25); // CHECK: call <2 x i64> @llvm.mips.binsli.d( v16i8_r = __msa_binsr_b(v16i8_r, v16i8_a, v16i8_b); // CHECK: call <16 x i8> @llvm.mips.binsr.b( v8i16_r = __msa_binsr_h(v8i16_r, v8i16_a, v8i16_b); // CHECK: call <8 x i16> @llvm.mips.binsr.h( v4i32_r = __msa_binsr_w(v4i32_r, v4i32_a, v4i32_b); // CHECK: call <4 x i32> @llvm.mips.binsr.w( v2i64_r = __msa_binsr_d(v2i64_r, v2i64_a, v2i64_b); // CHECK: call <2 x i64> @llvm.mips.binsr.d( - v16i8_r = __msa_binsri_b(v16i8_r, v16i8_a, 25); // CHECK: call <16 x i8> @llvm.mips.binsri.b( - v8i16_r = __msa_binsri_h(v8i16_r, v8i16_a, 25); // CHECK: call <8 x i16> @llvm.mips.binsri.h( + v16i8_r = __msa_binsri_b(v16i8_r, v16i8_a, 5); // CHECK: call <16 x i8> @llvm.mips.binsri.b( + v8i16_r = __msa_binsri_h(v8i16_r, v8i16_a, 15); // CHECK: call <8 x i16> @llvm.mips.binsri.h( v4i32_r = __msa_binsri_w(v4i32_r, v4i32_a, 25); // CHECK: call <4 x i32> @llvm.mips.binsri.w( v2i64_r = __msa_binsri_d(v2i64_r, v2i64_a, 25); // CHECK: call <2 x i64> @llvm.mips.binsri.d( @@ -182,8 +182,8 @@ v4i32_r = __msa_bneg_w(v4i32_a, v4i32_b); // CHECK: call <4 x i32> @llvm.mips.bneg.w( v2i64_r = __msa_bneg_d(v2i64_a, v
[PATCH] D25624: Added 'inline' attribute to basic_string's destructor
mclow.lists added a comment. I don't have a problem with this being marked as inline, as long as it doesn't disappear out of the dylib. There *has* to be a version of `basic_string, Allocator>::~basic_string` in the dylib - existing applications depend upon it. (same for `wchar_t`). https://reviews.llvm.org/D25624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25779: MS ABI: Don't assert when generating virtual function call with virtual bases and -flto (PR30731)
This revision was automatically updated to reflect the committed changes. Closed by commit rL284624: MS ABI: Fix assert when generating virtual function call with virtual bases and… (authored by hans). Changed prior to commit: https://reviews.llvm.org/D25779?vs=75171&id=75177#toc Repository: rL LLVM https://reviews.llvm.org/D25779 Files: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/test/CodeGenCXX/pr30731.cpp Index: cfe/trunk/test/CodeGenCXX/pr30731.cpp === --- cfe/trunk/test/CodeGenCXX/pr30731.cpp +++ cfe/trunk/test/CodeGenCXX/pr30731.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -flto -std=c++11 -o - %s | FileCheck %s + +struct A { + virtual ~A(); +}; + +struct B {}; + +struct C { + virtual void f(); +}; + +struct S : A, virtual B, C { + void f() override; +}; + +void f(S* s) { s->f(); } + +// CHECK-LABEL: define void @"\01?f@@YAXPAUS@@@Z" +// CHECK: call +// CHECK: ret void Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp === --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1773,15 +1773,8 @@ CharUnits MaxBaseOffset; for (auto &&B : RD->bases()) { const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getBaseClassOffset(Base); -if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { - MaxBase = Base; - MaxBaseOffset = BaseOffset; -} - } - for (auto &&B : RD->vbases()) { -const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getVBaseClassOffset(Base); +CharUnits BaseOffset = B.isVirtual() ? Layout.getVBaseClassOffset(Base) + : Layout.getBaseClassOffset(Base); if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { MaxBase = Base; MaxBaseOffset = BaseOffset; Index: cfe/trunk/test/CodeGenCXX/pr30731.cpp === --- cfe/trunk/test/CodeGenCXX/pr30731.cpp +++ cfe/trunk/test/CodeGenCXX/pr30731.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -flto -std=c++11 -o - %s | FileCheck %s + +struct A { + virtual ~A(); +}; + +struct B {}; + +struct C { + virtual void f(); +}; + +struct S : A, virtual B, C { + void f() override; +}; + +void f(S* s) { s->f(); } + +// CHECK-LABEL: define void @"\01?f@@YAXPAUS@@@Z" +// CHECK: call +// CHECK: ret void Index: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp === --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp @@ -1773,15 +1773,8 @@ CharUnits MaxBaseOffset; for (auto &&B : RD->bases()) { const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getBaseClassOffset(Base); -if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { - MaxBase = Base; - MaxBaseOffset = BaseOffset; -} - } - for (auto &&B : RD->vbases()) { -const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getVBaseClassOffset(Base); +CharUnits BaseOffset = B.isVirtual() ? Layout.getVBaseClassOffset(Base) + : Layout.getBaseClassOffset(Base); if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { MaxBase = Base; MaxBaseOffset = BaseOffset; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284624 - MS ABI: Fix assert when generating virtual function call with virtual bases and -flto (PR30731)
Author: hans Date: Wed Oct 19 13:04:27 2016 New Revision: 284624 URL: http://llvm.org/viewvc/llvm-project?rev=284624&view=rev Log: MS ABI: Fix assert when generating virtual function call with virtual bases and -flto (PR30731) getClassAtVTableLocation() was calling ASTRecordLayout::getBaseClassOffset() on a virtual base, causing an assert. Differential Revision: https://reviews.llvm.org/D25779 Added: cfe/trunk/test/CodeGenCXX/pr30731.cpp Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=284624&r1=284623&r2=284624&view=diff == --- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original) +++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Oct 19 13:04:27 2016 @@ -1773,15 +1773,8 @@ static const CXXRecordDecl *getClassAtVT CharUnits MaxBaseOffset; for (auto &&B : RD->bases()) { const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getBaseClassOffset(Base); -if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { - MaxBase = Base; - MaxBaseOffset = BaseOffset; -} - } - for (auto &&B : RD->vbases()) { -const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl(); -CharUnits BaseOffset = Layout.getVBaseClassOffset(Base); +CharUnits BaseOffset = B.isVirtual() ? Layout.getVBaseClassOffset(Base) + : Layout.getBaseClassOffset(Base); if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) { MaxBase = Base; MaxBaseOffset = BaseOffset; Added: cfe/trunk/test/CodeGenCXX/pr30731.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr30731.cpp?rev=284624&view=auto == --- cfe/trunk/test/CodeGenCXX/pr30731.cpp (added) +++ cfe/trunk/test/CodeGenCXX/pr30731.cpp Wed Oct 19 13:04:27 2016 @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -flto -std=c++11 -o - %s | FileCheck %s + +struct A { + virtual ~A(); +}; + +struct B {}; + +struct C { + virtual void f(); +}; + +struct S : A, virtual B, C { + void f() override; +}; + +void f(S* s) { s->f(); } + +// CHECK-LABEL: define void @"\01?f@@YAXPAUS@@@Z" +// CHECK: call +// CHECK: ret void ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25624: Added 'inline' attribute to basic_string's destructor
mclow.lists added a comment. This is the same problem as is facing https://reviews.llvm.org/D24991 https://reviews.llvm.org/D25624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types
aaron.ballman added inline comments. Comment at: include/clang/AST/TypeLoc.h:513 struct BuiltinLocInfo { - SourceLocation BuiltinLoc; + SourceRange BuiltinRange; }; malcolm.parsons wrote: > aaron.ballman wrote: > > malcolm.parsons wrote: > > > aaron.ballman wrote: > > > > Since this doubles the size of the type loc for builtin types, do you > > > > happen to have any data on what practical impact this has on RAM usage, > > > > say for bootstrapping LLVM (or compiling any large source base, > > > > really)? Hopefully it's not a lot, but it would be nice to know if it's > > > > a .1%, 1%, 10%, etc increase in usage (or does the change get lost in > > > > the noise). > > > I don't have any data. > > > I'm not sure how to collect that data. > > It's likely platform dependent, but I was thinking something as simple as > > looking at peak RAM usage between two different builds of the compiler. > > Something like `top` would probably work if you're on Linux (unless someone > > knows of a better way, I'm not strong on Linux). > Before: > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp > 5.56user 0.13system 0:05.91elapsed 96%CPU (0avgtext+0avgdata > 256820maxresident)k > > After: > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp > 5.67user 0.12system 0:05.98elapsed 97%CPU (0avgtext+0avgdata > 256940maxresident)k > > ((256940 - 256820) / 256820) * 100 = 0.05% Thank you for this -- is there a bigger delta for compilation of LLVM as a whole? ExprConstant.cpp is an interesting case, but not really representative of the project as a whole (for instance, there's not a lot of template metaprogramming in ExprConstant.cpp). https://reviews.llvm.org/D25363 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25704: [CUDA] When we emit an error that might have been deferred, also print a callstack.
jlebar updated this revision to Diff 75178. jlebar marked 2 inline comments as done. jlebar added a comment. Address rnk's comments. https://reviews.llvm.org/D25704 Files: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaCUDA.cpp clang/test/SemaCUDA/bad-calls-on-same-line.cu clang/test/SemaCUDA/call-device-fn-from-host.cu clang/test/SemaCUDA/call-host-fn-from-device.cu clang/test/SemaCUDA/call-stack-for-deferred-err.cu clang/test/SemaCUDA/exceptions-host-device.cu clang/test/SemaCUDA/no-call-stack-for-immediate-errs.cu clang/test/SemaCUDA/trace-through-global.cu Index: clang/test/SemaCUDA/trace-through-global.cu === --- clang/test/SemaCUDA/trace-through-global.cu +++ clang/test/SemaCUDA/trace-through-global.cu @@ -35,10 +35,16 @@ template void launch_kernel() { kernel<<<0, 0>>>(T()); - hd1(); - hd3(T()); + + // Notice that these two diagnostics are different: Because the call to hd1 + // is not dependent on T, the call to hd1 comes from 'launch_kernel', while + // the call to hd3, being dependent, comes from 'launch_kernel'. + hd1(); // expected-note {{called by 'launch_kernel'}} + hd3(T()); // expected-note {{called by 'launch_kernel'}} } void host_fn() { launch_kernel(); + // expected-note@-1 {{called by 'host_fn'}} + // expected-note@-2 {{called by 'host_fn'}} } Index: clang/test/SemaCUDA/no-call-stack-for-immediate-errs.cu === --- /dev/null +++ clang/test/SemaCUDA/no-call-stack-for-immediate-errs.cu @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s + +#include "Inputs/cuda.h" + +// Here we should dump an error about the VLA in device_fn, but we should not +// print a callstack indicating how device_fn becomes known-emitted, because +// it's an error to use a VLA in any __device__ function, even one that doesn't +// get emitted. + +inline __device__ void device_fn(int n); +inline __device__ void device_fn2() { device_fn(42); } + +__global__ void kernel() { device_fn2(); } + +inline __device__ void device_fn(int n) { + int vla[n]; // expected-error {{variable-length array}} +} Index: clang/test/SemaCUDA/exceptions-host-device.cu === --- clang/test/SemaCUDA/exceptions-host-device.cu +++ clang/test/SemaCUDA/exceptions-host-device.cu @@ -36,3 +36,6 @@ #endif } __device__ void call_hd3() { hd3(); } +#ifndef HOST +// expected-note@-2 {{called by 'call_hd3'}} +#endif Index: clang/test/SemaCUDA/call-stack-for-deferred-err.cu === --- /dev/null +++ clang/test/SemaCUDA/call-stack-for-deferred-err.cu @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s + +#include "Inputs/cuda.h" + +// We should emit an error for hd_fn's use of a VLA. This would have been +// legal if hd_fn were never codegen'ed on the device, so we should also print +// out a callstack showing how we determine that hd_fn is known-emitted. +// +// Compare to no-call-stack-for-deferred-err.cu. + +inline __host__ __device__ void hd_fn(int n); +inline __device__ void device_fn2() { hd_fn(42); } // expected-note {{called by 'device_fn2'}} + +__global__ void kernel() { device_fn2(); } // expected-note {{called by 'kernel'}} + +inline __host__ __device__ void hd_fn(int n) { + int vla[n]; // expected-error {{variable-length array}} +} Index: clang/test/SemaCUDA/call-host-fn-from-device.cu === --- clang/test/SemaCUDA/call-host-fn-from-device.cu +++ clang/test/SemaCUDA/call-host-fn-from-device.cu @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s --std=c++11 -triple nvptx-unknown-unknown -fcuda-is-device \ -// RUN: -emit-llvm -o /dev/null -verify +// RUN: -emit-llvm -o /dev/null -verify -verify-ignore-unexpected=note // Note: This test won't work with -fsyntax-only, because some of these errors // are emitted during codegen. Index: clang/test/SemaCUDA/call-device-fn-from-host.cu === --- clang/test/SemaCUDA/call-device-fn-from-host.cu +++ clang/test/SemaCUDA/call-device-fn-from-host.cu @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - -verify +// RUN: %clang_cc1 %s --std=c++11 -triple x86_64-unknown-linux -emit-llvm -o - \ +// RUN: -verify -verify-ignore-unexpected=note // Note: This test won't work with -fsyntax-only, because some of these errors // are emitted during codegen. Index: clang/test/SemaCUDA/bad-calls-on-same-line.cu === --- clang/test/SemaCUDA/bad-calls-on-same-line.cu +++ clang/test/SemaCUDA/bad-calls-on-same-line.cu @@ -35,5 +35,7 @@ void host_fn() { hd(); hd(); // expected-note {{function t
[PATCH] D25017: [mips][msa] Range check MSA intrinsics with immediates
sdardis added a comment. Thanks. Repository: rL LLVM https://reviews.llvm.org/D25017 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25704: [CUDA] When we emit an error that might have been deferred, also print a callstack.
jlebar added inline comments. Comment at: clang/include/clang/Sema/Sema.h:9292 + llvm::DenseMap, + /* Callees = */ llvm::SetVector> + CUDACallGraph; rnk wrote: > Rather than having a custom key type, maybe it would be better to phrase this > as a `MapVector, SourceLocation>` ? Despite > all the comments, I assumed FunctionDeclAndLoc was hashed by both elements > for a long time. That's much better; thank you. https://reviews.llvm.org/D25704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
rnk added a comment. In https://reviews.llvm.org/D19996#422906, @rafael wrote: > Is there a gcc option or they just assume they are targeting the > linker that was around when gcc was built? IIRC there's no GCC option. They base their decision on the configure-time check like you suggested. Comment at: include/clang/Driver/Options.td:1696 + Flags<[CC1Option]>, + HelpText<"Copy Relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, I agree with Rafael, this needs a verb, like "Use copy relocations in PIE builds" or something. Comment at: include/clang/Driver/Options.td:1698 +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"No Copy Relocations support for PIE builds">; The "no" option variants don't need to be CC1 options. Comment at: include/clang/Driver/Options.td:1699 + Flags<[CC1Option]>, + HelpText<"No Copy Relocations support for PIE builds">; def mx87 : Flag<["-"], "mx87">, Group; I don't think we need help text for the "no" variant. I think we add help text to "no" flags when the flag is on by default, for example `-fno-exceptions`. https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram updated this revision to Diff 75179. tmsriram added a comment. - Changed help text to "Avail copy relocations support for PIE builds" - Removed mno-pie... as a CC1 option - Removed help text from mno-pie.. https://reviews.llvm.org/D19996 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,11 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1691,6 +1691,10 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Avail copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,11 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = C
[PATCH] D25448: [ubsan] Use the object pointer's type info for devirtualized calls
rjmccall accepted this revision. rjmccall added a comment. This revision is now accepted and ready to land. Looks great, thanks. https://reviews.llvm.org/D25448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25704: [CUDA] When we emit an error that might have been deferred, also print a callstack.
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6707 +def note_called_by : Note<"called by %0">; def err_kern_type_not_void_return : Error< Do you think it's worth trying to indicate why the root of the "called by" notes must be emitted? I'm not suggesting we do it in this patch, just wondering. Comment at: clang/include/clang/Sema/Sema.h:9259 /// use this to avoid emitting the same deferred diag twice. - llvm::DenseSet> LocsWithCUDACallDiags; + llvm::DenseSet, unsigned>> + LocsWithCUDACallDiags; So, part of me wants to use FunctionDeclAndLoc here instead of std::pair, but then you'd have to bring back all the hashing machinery instead of getting it for free. Up to you, I guess. Comment at: clang/include/clang/Sema/Sema.h:9274 + llvm::DenseMap, + /* Caller = */ FunctionDeclAndLoc> + CUDAKnownEmittedFns; I guess there can be many callers, but we always record the first one that caused this function to be emitted. https://reviews.llvm.org/D25704 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
rnk accepted this revision. rnk added a comment. This revision is now accepted and ready to land. lgtm Comment at: include/clang/Driver/Options.td:1696 + Flags<[CC1Option]>, + HelpText<"Copy Relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group, rnk wrote: > I agree with Rafael, this needs a verb, like "Use copy relocations in PIE > builds" or something. I guess "avail" is a verb, but I've never seen anyone use it. I'd really rather use "use". :) https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
mgrang added inline comments. Comment at: lib/Driver/Tools.cpp:4502 + if (Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, + false)) { Please fix indentation. Comment at: lib/Frontend/CompilerInvocation.cpp:589 Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); You should also check for the negative flag here: Opts.PIECopyRelocations = Args.hasFlag(options::OPT_mpie_copy_relocations, options::OPT_mno_pie_copy_relocations, false); https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram added inline comments. Comment at: lib/Frontend/CompilerInvocation.cpp:589 Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); mgrang wrote: > You should also check for the negative flag here: > > Opts.PIECopyRelocations = Args.hasFlag(options::OPT_mpie_copy_relocations, > options::OPT_mno_pie_copy_relocations, false); mpie_copy_relocations is the only CC1 flag here and that is pushed into CC1 command after checking for the negative. https://reviews.llvm.org/D19996 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null
timshen added a comment. In https://reviews.llvm.org/D25595#574364, @mclow.lists wrote: > Do we need to test calling `regex_match` with `match_not_null`? > If not, then I think this is good to go. Done. > Do you have commit access, or would you rather I committed it? Yes, I have the commit access. Thanks for reviewing! https://reviews.llvm.org/D25595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
tmsriram updated this revision to Diff 75189. tmsriram added a comment. - Fix Help text. - Fix indentation. https://reviews.llvm.org/D19996 Files: include/clang/Driver/Options.td include/clang/Frontend/CodeGenOptions.def lib/CodeGen/BackendUtil.cpp lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,12 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: include/clang/Frontend/CodeGenOptions.def === --- include/clang/Frontend/CodeGenOptions.def +++ include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1691,6 +1691,10 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Use copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: lib/Frontend/CompilerInvocation.cpp === --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -4499,6 +4499,12 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompat
[PATCH] D25595: [libcxx] Support std::regex_constants::match_not_null
timshen updated this revision to Diff 75186. timshen added a comment. Add tests for regex_match. https://reviews.llvm.org/D25595 Files: libcxx/include/regex libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp === --- /dev/null +++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp @@ -0,0 +1,46 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// match_not_null: +// The regular expression shall not match an empty sequence. + +#include "test_macros.h" +#include +#include + +int main() +{ + // When match_not_null is on, the regex engine should reject empty matches and + // move on to try other solutions. + std::cmatch m; + assert(!std::regex_search("a", m, std::regex("b*"), +std::regex_constants::match_not_null)); + assert(std::regex_search("aa", m, std::regex("a*?"), + std::regex_constants::match_not_null)); + assert(m[0].length() == 1); + assert(!std::regex_search("a", m, std::regex("b*", std::regex::extended), +std::regex_constants::match_not_null)); + assert(!std::regex_search( + "a", m, + std::regex("b*", std::regex::extended | std::regex_constants::nosubs), + std::regex_constants::match_not_null)); + + assert(!std::regex_match("", m, std::regex("a*"), + std::regex_constants::match_not_null)); + assert(!std::regex_match("", m, std::regex("a*", std::regex::extended), + std::regex_constants::match_not_null)); + assert(!std::regex_match( + "", m, + std::regex("a*", std::regex::extended | std::regex_constants::nosubs), + std::regex_constants::match_not_null)); + + return 0; +} Index: libcxx/include/regex === --- libcxx/include/regex +++ libcxx/include/regex @@ -,6 +,12 @@ switch (__s.__do_) { case __state::__end_state: +if (__flags & regex_constants::match_not_null && +__s.__current_ == __first) +{ + __states.pop_back(); + break; +} __m.__matches_[0].first = __first; __m.__matches_[0].second = _VSTD::next(__first, __s.__current_ - __first); __m.__matches_[0].matched = true; @@ -5618,6 +5624,12 @@ switch (__s.__do_) { case __state::__end_state: +if (__flags & regex_constants::match_not_null && +__s.__current_ == __first) +{ + __states.pop_back(); + break; +} if (!__matched || __highest_j < __s.__current_ - __s.__first_) __highest_j = __s.__current_ - __s.__first_; __matched = true; @@ -5703,6 +5715,12 @@ switch (__s.__do_) { case __state::__end_state: +if (__flags & regex_constants::match_not_null && +__s.__current_ == __first) +{ + __states.pop_back(); + break; +} if (!__matched || __highest_j < __s.__current_ - __s.__first_) { __highest_j = __s.__current_ - __s.__first_; Index: libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp === --- /dev/null +++ libcxx/test/std/re/re.const/re.matchflag/match_not_null.pass.cpp @@ -0,0 +1,46 @@ +//===--===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===--===// + +// + +// match_not_null: +// The regular expression shall not match an empty sequence. + +#include "test_macros.h" +#include +#include + +int main() +{ + // When match_not_null is on, the regex engine should reject empty matches and + // move on to try other solutions. + std::cmatch m; + assert(!std::regex_search("a", m, std::regex("b*"), +std::regex_constants::match_not_null)); + assert(std::regex_search("aa", m, std::regex("a*?"), + std::regex_constants::match_n
[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types
malcolm.parsons added inline comments. Comment at: include/clang/AST/TypeLoc.h:513 struct BuiltinLocInfo { - SourceLocation BuiltinLoc; + SourceRange BuiltinRange; }; aaron.ballman wrote: > malcolm.parsons wrote: > > aaron.ballman wrote: > > > malcolm.parsons wrote: > > > > aaron.ballman wrote: > > > > > Since this doubles the size of the type loc for builtin types, do you > > > > > happen to have any data on what practical impact this has on RAM > > > > > usage, say for bootstrapping LLVM (or compiling any large source > > > > > base, really)? Hopefully it's not a lot, but it would be nice to know > > > > > if it's a .1%, 1%, 10%, etc increase in usage (or does the change get > > > > > lost in the noise). > > > > I don't have any data. > > > > I'm not sure how to collect that data. > > > It's likely platform dependent, but I was thinking something as simple as > > > looking at peak RAM usage between two different builds of the compiler. > > > Something like `top` would probably work if you're on Linux (unless > > > someone knows of a better way, I'm not strong on Linux). > > Before: > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp > > 5.56user 0.13system 0:05.91elapsed 96%CPU (0avgtext+0avgdata > > 256820maxresident)k > > > > After: > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp > > 5.67user 0.12system 0:05.98elapsed 97%CPU (0avgtext+0avgdata > > 256940maxresident)k > > > > ((256940 - 256820) / 256820) * 100 = 0.05% > Thank you for this -- is there a bigger delta for compilation of LLVM as a > whole? ExprConstant.cpp is an interesting case, but not really representative > of the project as a whole (for instance, there's not a lot of template > metaprogramming in ExprConstant.cpp). I can try running time on a full build. For every file I sampled the increase was 0.05%. Do TypeLocs increase when using TMP? https://reviews.llvm.org/D25363 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25779: MS ABI: Don't assert when generating virtual function call with virtual bases and -flto (PR30731)
majnemer added a comment. Why did this only fail with -flto? Seems strange. Repository: rL LLVM https://reviews.llvm.org/D25779 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25779: MS ABI: Don't assert when generating virtual function call with virtual bases and -flto (PR30731)
hans added a comment. In https://reviews.llvm.org/D25779#574630, @majnemer wrote: > Why did this only fail with -flto? Seems strange. I was asking myself the same thing :-) It's because of this code in MicrosoftCXXABI::getVirtualFunctionPointer: if (CGM.getCodeGenOpts().PrepareForLTO) // XXX: Aha! CGF.EmitTypeMetadataCodeForVCall( getClassAtVTableLocation(getContext(), GD, ML), VTable, Loc); Repository: rL LLVM https://reviews.llvm.org/D25779 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h
yaxunl updated this revision to Diff 75203. yaxunl marked 4 inline comments as done. yaxunl added a comment. Fix typo in test. https://reviews.llvm.org/D25343 Files: include/clang/Basic/Attr.td include/clang/Basic/AttrDocs.td lib/CodeGen/CGCall.cpp lib/Headers/opencl-c.h lib/Sema/SemaDeclAttr.cpp test/CodeGenOpenCL/convergent.cl test/SemaOpenCL/convergent.cl Index: test/SemaOpenCL/convergent.cl === --- /dev/null +++ test/SemaOpenCL/convergent.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple spir-unknown-unknown -fsyntax-only -verify %s + +void f1(void) __attribute__((convergent)); + +void f2(void) __attribute__((convergent(1))); // expected-error {{'convergent' attribute takes no arguments}} + +void f3(int a __attribute__((convergent))); // expected-warning {{'convergent' attribute only applies to functions}} + +void f4(void) { + int var1 __attribute__((convergent)); // expected-warning {{'convergent' attribute only applies to functions}} +} + Index: test/CodeGenOpenCL/convergent.cl === --- /dev/null +++ test/CodeGenOpenCL/convergent.cl @@ -0,0 +1,118 @@ +// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | FileCheck %s + +void convfun(void) __attribute__((convergent)); +void non_convfun(void); +void nodupfun(void) __attribute__((noduplicate)); + +void f(void); +void g(void); + +// Test two if's are merged and non_convfun duplicated. +// The LLVM IR is equivalent to: +//if (a) { +// f(); +// non_convfun(); +// g(); +//} else { +// non_convfun(); +//} +// +// CHECK: define spir_func void @test_merge_if(i32 %[[a:.+]]) +// CHECK: %[[tobool:.+]] = icmp eq i32 %[[a]], 0 +// CHECK: br i1 %[[tobool]], label %[[if_end3_critedge:.+]], label %[[if_then:.+]] +// CHECK: [[if_then]]: +// CHECK: tail call spir_func void @f() +// CHECK: tail call spir_func void @non_convfun() +// CHECK: tail call spir_func void @g() +// CHECK: br label %[[if_end3:.+]] +// CHECK: [[if_end3_critedge]]: +// CHECK: tail call spir_func void @non_convfun() +// CHECK: br label %[[if_end3]] +// CHECK: [[if_end3]]: +// CHECK-LABEL: ret void + +void test_merge_if(int a) { + if (a) { +f(); + } + non_convfun(); + if (a) { +g(); + } +} + +// CHECK-DAG: declare spir_func void @f() +// CHECK-DAG: declare spir_func void @non_convfun() +// CHECK-DAG: declare spir_func void @g() + +// Test two if's are not merged. +// CHECK: define spir_func void @test_no_merge_if(i32 %[[a:.+]]) +// CHECK: %[[tobool:.+]] = icmp eq i32 %[[a]], 0 +// CHECK: br i1 %[[tobool]], label %[[if_end:.+]], label %[[if_then:.+]] +// CHECK: [[if_then]]: +// CHECK: tail call spir_func void @f() +// CHECK-NOT: call spir_func void @non_convfun() +// CHECK-NOT: call spir_func void @g() +// CHECK: br label %[[if_end]] +// CHECK: [[if_end]]: +// CHECK: %[[tobool_pr:.+]] = phi i1 [ true, %[[if_then]] ], [ false, %{{.+}} ] +// CHECK: tail call spir_func void @convfun() #[[attr5:.+]] +// CHECK: br i1 %[[tobool_pr]], label %[[if_then2:.+]], label %[[if_end3:.+]] +// CHECK: [[if_then2]]: +// CHECK: tail call spir_func void @g() +// CHECK: br label %[[if_end3:.+]] +// CHECK: [[if_end3]]: +// CHECK-LABEL: ret void + +void test_no_merge_if(int a) { + if (a) { +f(); + } + convfun(); + if(a) { +g(); + } +} + +// CHECK: declare spir_func void @convfun(){{[^#]*}} #[[attr2:[0-9]+]] + +// Test loop is unrolled for convergent function. +// CHECK-LABEL: define spir_func void @test_unroll() +// CHECK: tail call spir_func void @convfun() #[[attr5:[0-9]+]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK: tail call spir_func void @convfun() #[[attr5]] +// CHECK-LABEL: ret void + +void test_unroll() { + for (int i = 0; i < 10; i++) +convfun(); +} + +// Test loop is not unrolled for noduplicate function. +// CHECK-LABEL: define spir_func void @test_not_unroll() +// CHECK: br label %[[for_body:.+]] +// CHECK: [[for_cond_cleanup:.+]]: +// CHECK: ret void +// CHECK: [[for_body]]: +// CHECK: tail call spir_func void @nodupfun() #[[attr6:[0-9]+]] +// CHECK-NOT: call spir_func void @nodupfun() +// CHECK: br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]] + +void test_not_unroll() { + for (int i = 0; i < 10; i++) +nodupfun(); +} + +// CHECK: declare spir_func void @nodupfun(){{[^#]*}} #[[attr3:[0-9]+]] + +// CHECK-DAG: attributes #[[attr2]] = { {{[^}]*}}convergent{{[^}]*}} } +// CHECK-DAG: attributes #[[attr3]] = { {{[^}]*}}noduplicate{{[^}]
[PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h
yaxunl added a comment. > Should we deprecate noduplicate then as convergent should cover both use > cases for OpenCL I believe? As far as I understand noduplicate was added > specifically for SPMD use cases... noduplicate has different semantics than convergent. Although it is proposed for SPMD originally, it could be used by non-SPMD programs to forbid duplicate of functions. There may be applications using this attribute. I would suggest to leave this question for future. Probably ask llvm-dev first since the attribute is also in LLVM. Comment at: include/clang/Basic/AttrDocs.td:630 + void convfunc(void) __attribute__((convergent)); + // Setting it as a C++11 attribute is also valid in a C++ program. + // void convfunc(void) [[clang::convergent]]; Anastasia wrote: > Did you mean "in an OpenCL program"? No. In C++ program only, it is also valid to set it as C++11 attribute. OpenCL does not support C++11 attribute. https://reviews.llvm.org/D25343 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25363: [Sema] Store a SourceRange for multi-token builtin types
aaron.ballman added inline comments. Comment at: include/clang/AST/TypeLoc.h:513 struct BuiltinLocInfo { - SourceLocation BuiltinLoc; + SourceRange BuiltinRange; }; malcolm.parsons wrote: > aaron.ballman wrote: > > malcolm.parsons wrote: > > > aaron.ballman wrote: > > > > malcolm.parsons wrote: > > > > > aaron.ballman wrote: > > > > > > Since this doubles the size of the type loc for builtin types, do > > > > > > you happen to have any data on what practical impact this has on > > > > > > RAM usage, say for bootstrapping LLVM (or compiling any large > > > > > > source base, really)? Hopefully it's not a lot, but it would be > > > > > > nice to know if it's a .1%, 1%, 10%, etc increase in usage (or does > > > > > > the change get lost in the noise). > > > > > I don't have any data. > > > > > I'm not sure how to collect that data. > > > > It's likely platform dependent, but I was thinking something as simple > > > > as looking at peak RAM usage between two different builds of the > > > > compiler. Something like `top` would probably work if you're on Linux > > > > (unless someone knows of a better way, I'm not strong on Linux). > > > Before: > > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp > > > 5.56user 0.13system 0:05.91elapsed 96%CPU (0avgtext+0avgdata > > > 256820maxresident)k > > > > > > After: > > > /usr/bin/time clang++ ... -c llvm/tools/clang/lib/AST/ExprConstant.cpp > > > 5.67user 0.12system 0:05.98elapsed 97%CPU (0avgtext+0avgdata > > > 256940maxresident)k > > > > > > ((256940 - 256820) / 256820) * 100 = 0.05% > > Thank you for this -- is there a bigger delta for compilation of LLVM as a > > whole? ExprConstant.cpp is an interesting case, but not really > > representative of the project as a whole (for instance, there's not a lot > > of template metaprogramming in ExprConstant.cpp). > I can try running time on a full build. > For every file I sampled the increase was 0.05%. > Do TypeLocs increase when using TMP? I *think* that template arguments use TypeLocs, but I could be remembering incorrectly (and I unfortunately won't have the chance to check until next week sometime). I was asking for the whole project just in case there is some construct that has a heavier use of them. Your findings of .05% are really promising though. https://reviews.llvm.org/D25363 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23752: cmake: Supporting overriding runtime libdir via CLANG_LIBDIR_SUFFIX
mgorny added a comment. Do you think I should just focus on the suffix, or maybe try to make the whole path configurable? https://reviews.llvm.org/D23752 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284636 - [ubsan] Use the object pointer's type info for devirtualized calls
Author: vedantk Date: Wed Oct 19 15:21:16 2016 New Revision: 284636 URL: http://llvm.org/viewvc/llvm-project?rev=284636&view=rev Log: [ubsan] Use the object pointer's type info for devirtualized calls ubsan reports a false positive 'invalid member call' diagnostic on the following example (PR30478): struct Base1 { virtual int f1() { return 1; } }; struct Base2 { virtual int f1() { return 2; } }; struct Derived2 final : Base1, Base2 { int f1() override { return 3; } }; int t1() { Derived2 d; return static_cast(&d)->f1(); } Adding the "final" attribute to a most-derived class allows clang to devirtualize member calls into an instance of that class. We should pass along the type info of the object pointer to avoid the FP. In this case, that means passing along the type info for 'Derived2' instead of 'Base2' when checking the dynamic type of static_cast(&d2). Differential Revision: https://reviews.llvm.org/D25448 Added: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=284636&r1=284635&r2=284636&view=diff == --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Oct 19 15:21:16 2016 @@ -241,6 +241,9 @@ RValue CodeGenFunction::EmitCXXMemberOrO llvm::FunctionType *Ty = CGM.getTypes().GetFunctionType(*FInfo); + // FIXME: Uses of 'MD' past this point need to be audited. We may need to use + // 'CalleeDecl' instead. + // C++ [class.virtual]p12: // Explicit qualification with the scope operator (5.1) suppresses the // virtual call mechanism. @@ -268,9 +271,9 @@ RValue CodeGenFunction::EmitCXXMemberOrO cast(DevirtualizedMethod); Callee = CGM.GetAddrOfFunction(GlobalDecl(DDtor, Dtor_Complete), Ty); } - EmitCXXMemberOrOperatorCall(MD, Callee, ReturnValue, This.getPointer(), - /*ImplicitParam=*/nullptr, QualType(), CE, - nullptr); + EmitCXXMemberOrOperatorCall( + CalleeDecl, Callee, ReturnValue, This.getPointer(), + /*ImplicitParam=*/nullptr, QualType(), CE, nullptr); } return RValue::get(nullptr); } @@ -302,9 +305,9 @@ RValue CodeGenFunction::EmitCXXMemberOrO *this, CalleeDecl, This, UseVirtualCall); } - return EmitCXXMemberOrOperatorCall(MD, Callee, ReturnValue, This.getPointer(), - /*ImplicitParam=*/nullptr, QualType(), CE, - RtlArgs); + return EmitCXXMemberOrOperatorCall( + CalleeDecl, Callee, ReturnValue, This.getPointer(), + /*ImplicitParam=*/nullptr, QualType(), CE, RtlArgs); } RValue Added: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp?rev=284636&view=auto == --- cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp (added) +++ cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp Wed Oct 19 15:21:16 2016 @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm -fsanitize=vptr %s -o - | FileCheck %s + +struct Base1 { + virtual void f1() {} +}; + +struct Base2 { + virtual void f1() {} +}; + +struct Derived1 final : Base1 { + void f1() override {} +}; + +struct Derived2 final : Base1, Base2 { + void f1() override {} +}; + +// PR13127 documents some missed devirtualization opportunities, including +// devirt for methods marked 'final'. We can enable the checks marked 'PR13127' +// if we implement this in the frontend. +struct Derived3 : Base1 { + void f1() override /* nofinal */ {} +}; + +struct Derived4 final : Base1 { + void f1() override final {} +}; + +// CHECK: [[UBSAN_TI_DERIVED1_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived1 to i8* +// CHECK: [[UBSAN_TI_DERIVED2_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8* +// CHECK: [[UBSAN_TI_DERIVED2_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8* +// PR13127: [[UBSAN_TI_DERIVED3:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived3 to i8* +// PR13127: [[UBSAN_TI_BASE1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI5Base1 to i8* +// PR13127: [[UBSAN_TI_DERIVED4_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8* +// PR13127: [[UBSAN_TI_DERIVED4_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8* + +// CHECK-LABEL: define void @_Z2t1v +void t1() { + Derived1 d1; + static_cast(&d1)->f1(); //< Devirt
r284638 - New clang option -mpie-copy-relocations to use copy relocations for PIE builds.
Author: tmsriram Date: Wed Oct 19 15:24:06 2016 New Revision: 284638 URL: http://llvm.org/viewvc/llvm-project?rev=284638&view=rev Log: New clang option -mpie-copy-relocations to use copy relocations for PIE builds. Differential Revision: https://reviews.llvm.org/D19996 Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=284638&r1=284637&r2=284638&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Wed Oct 19 15:24:06 2016 @@ -1691,6 +1691,10 @@ def mno_implicit_float : Flag<["-"], "mn def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Use copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=284638&r1=284637&r2=284638&view=diff == --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original) +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Wed Oct 19 15:24:06 2016 @@ -252,6 +252,9 @@ VALUE_CODEGENOPT(EmitCheckPathComponents /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=284638&r1=284637&r2=284638&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Oct 19 15:24:06 2016 @@ -595,6 +595,8 @@ void EmitAssemblyHelper::CreateTargetMac Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284638&r1=284637&r2=284638&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Wed Oct 19 15:24:06 2016 @@ -4499,6 +4499,12 @@ void Clang::ConstructJob(Compilation &C, CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=284638&r1=284637&r2=284638&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Oct 19 15:24:06 2016 @@ -586,6 +586,8 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); ___ cfe-commits mailing list cfe-commits@lists.llvm.org htt
[PATCH] D19996: New clang option -mpie-copy-relocationss to indicate support for linker copy relocations when linking as PIE
This revision was automatically updated to reflect the committed changes. Closed by commit rL284638: New clang option -mpie-copy-relocations to use copy relocations for PIE builds. (authored by tmsriram). Changed prior to commit: https://reviews.llvm.org/D19996?vs=75189&id=75212#toc Repository: rL LLVM https://reviews.llvm.org/D19996 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/Driver/Tools.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp === --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocations; Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings; Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose; Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments; Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -4499,6 +4499,12 @@ CmdArgs.push_back("-mms-bitfields"); } + if (Args.hasFlag(options::OPT_mpie_copy_relocations, + options::OPT_mno_pie_copy_relocations, + false)) { +CmdArgs.push_back("-mpie-copy-relocations"); + } + // This is a coarse approximation of what llvm-gcc actually does, both // -fasynchronous-unwind-tables and -fnon-call-exceptions interact in more // complicated ways. Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -1691,6 +1691,10 @@ def mimplicit_float : Flag<["-"], "mimplicit-float">, Group; def mrecip : Flag<["-"], "mrecip">, Group; def mrecip_EQ : CommaJoined<["-"], "mrecip=">, Group, Flags<[CC1Option]>; +def mpie_copy_relocations : Flag<["-"], "mpie-copy-relocations">, Group, + Flags<[CC1Option]>, + HelpText<"Use copy relocations support for PIE builds">; +def mno_pie_copy_relocations : Flag<["-"], "mno-pie-copy-relocations">, Group; def mx87 : Flag<["-"], "mx87">, Group; def m80387 : Flag<["-"], "m80387">, Alias; def msse2 : Flag<["-"], "msse2">, Group; Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def === --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def +++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def @@ -252,6 +252,9 @@ /// Whether to report the hotness of the code region for optimization remarks. CODEGENOPT(DiagnosticsWithHotness, 1, 0) +/// Whether copy relocations support is available when building as PIE. +CODEGENOPT(PIECopyRelocations, 1, 0) + #undef CODEGENOPT #undef ENUM_CODEGENOPT #undef VALUE_CODEGENOPT Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp === --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp @@ -586,6 +586,8 @@ Opts.RelaxAll = Args.hasArg(OPT_mrelax_all); Opts.IncrementalLinkerCompatible = Args.hasArg(OPT_mincremental_linker_compatible); + Opts.PIECopyRelocations = + Args.hasArg(OPT_mpie_copy_relocations); Opts.OmitLeafFramePointer = Args.hasArg(OPT_momit_leaf_frame_pointer); Opts.SaveTempLabels = Args.hasArg(OPT_msave_temp_labels); Opts.NoDwarfDirectoryAsm = Args.hasArg(OPT_fno_dwarf_directory_asm); Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp === --- cfe/trunk/lib/CodeGen/BackendUtil.cpp +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp @@ -595,6 +595,8 @@ Options.MCOptions.MCNoExecStack = CodeGenOpts.NoExecStack; Options.MCOptions.MCIncrementalLinkerCompatible = CodeGenOpts.IncrementalLinkerCompatible; + Options.MCOptions.MCPIECopyRelocations = + CodeGenOpts.PIECopyRelocation
[PATCH] D25448: [ubsan] Use the object pointer's type info for devirtualized calls
This revision was automatically updated to reflect the committed changes. Closed by commit rL284636: [ubsan] Use the object pointer's type info for devirtualized calls (authored by vedantk). Changed prior to commit: https://reviews.llvm.org/D25448?vs=75168&id=75211#toc Repository: rL LLVM https://reviews.llvm.org/D25448 Files: cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp Index: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp === --- cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp +++ cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp @@ -0,0 +1,91 @@ +// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -emit-llvm -fsanitize=vptr %s -o - | FileCheck %s + +struct Base1 { + virtual void f1() {} +}; + +struct Base2 { + virtual void f1() {} +}; + +struct Derived1 final : Base1 { + void f1() override {} +}; + +struct Derived2 final : Base1, Base2 { + void f1() override {} +}; + +// PR13127 documents some missed devirtualization opportunities, including +// devirt for methods marked 'final'. We can enable the checks marked 'PR13127' +// if we implement this in the frontend. +struct Derived3 : Base1 { + void f1() override /* nofinal */ {} +}; + +struct Derived4 final : Base1 { + void f1() override final {} +}; + +// CHECK: [[UBSAN_TI_DERIVED1_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived1 to i8* +// CHECK: [[UBSAN_TI_DERIVED2_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8* +// CHECK: [[UBSAN_TI_DERIVED2_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived2 to i8* +// PR13127: [[UBSAN_TI_DERIVED3:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived3 to i8* +// PR13127: [[UBSAN_TI_BASE1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI5Base1 to i8* +// PR13127: [[UBSAN_TI_DERIVED4_1:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8* +// PR13127: [[UBSAN_TI_DERIVED4_2:@[0-9]+]] = private unnamed_addr global {{.*}} i8* bitcast {{.*}} @_ZTI8Derived4 to i8* + +// CHECK-LABEL: define void @_Z2t1v +void t1() { + Derived1 d1; + static_cast(&d1)->f1(); //< Devirt Base1::f1 to Derived1::f1. + // CHECK: handler.dynamic_type_cache_miss: + // CHECK-NEXT: %[[D1:[0-9]+]] = ptrtoint %struct.Derived1* %d1 to i64, !nosanitize + // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED1_1]] {{.*}}, i64 %[[D1]] +} + +// CHECK-LABEL: define void @_Z2t2v +void t2() { + Derived2 d2; + static_cast(&d2)->f1(); //< Devirt Base1::f1 to Derived2::f1. + // CHECK: handler.dynamic_type_cache_miss: + // CHECK-NEXT: %[[D2_1:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize + // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED2_1]] {{.*}}, i64 %[[D2_1]] +} + +// CHECK-LABEL: define void @_Z2t3v +void t3() { + Derived2 d2; + static_cast(&d2)->f1(); //< Devirt Base2::f1 to Derived2::f1. + // CHECK: handler.dynamic_type_cache_miss: + // CHECK-NEXT: %[[D2_2:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize + // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED2_2]] {{.*}}, i64 %[[D2_2]] +} + +// PR13127-LABEL: define void @_Z2t4v +void t4() { + Base1 p; + Derived3 *badp = static_cast(&p); //< Check that &p isa Derived3. + // PR13127: handler.dynamic_type_cache_miss + // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived3* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED3]] {{.*}}, i64 %[[P1]] + + static_cast(badp)->f1(); //< No devirt, test 'badp isa Base1'. + // PR13127: handler.dynamic_type_cache_miss + // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Base1* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_BASE1]] {{.*}}, i64 %[[BADP1]] +} + +// PR13127-LABEL: define void @_Z2t5v +void t5() { + Base1 p; + Derived4 *badp = static_cast(&p); //< Check that &p isa Derived4. + // PR13127: handler.dynamic_type_cache_miss: + // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived4* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED4_1]] {{.*}}, i64 %[[P1]] + + static_cast(badp)->f1(); //< Devirt Base1::f1 to Derived4::f1. + // PR13127: handler.dynamic_type_cache_miss1: + // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Derived4* {{%[0-9]+}} to i64, !nosanitize + // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED4_2]] {{.*}}, i64 %[[BADP1]] +} Index: cfe/trunk/lib/CodeGen/CGExprCXX.cpp === --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp @@ -241,6 +241,9 @@ llvm::FunctionType *Ty = CGM.getTypes().GetFunctionType(*FInfo); + // FIXME: Uses of 'MD' past this point need to be aud
r284639 - [ubsan] Re-work check lines to try to appease a bot (NFC)
Author: vedantk Date: Wed Oct 19 15:28:35 2016 New Revision: 284639 URL: http://llvm.org/viewvc/llvm-project?rev=284639&view=rev Log: [ubsan] Re-work check lines to try to appease a bot (NFC) This bot does not produce the IR I expect -- it's missing some 'handler.dynamic_type_cache_miss:' labels. We don't need to rely on those labels, so get rid of them in hopes of making the bot happy. http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55493 Modified: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp Modified: cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp?rev=284639&r1=284638&r2=284639&view=diff == --- cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp (original) +++ cfe/trunk/test/CodeGenCXX/ubsan-devirtualized-calls.cpp Wed Oct 19 15:28:35 2016 @@ -39,53 +39,46 @@ struct Derived4 final : Base1 { void t1() { Derived1 d1; static_cast(&d1)->f1(); //< Devirt Base1::f1 to Derived1::f1. - // CHECK: handler.dynamic_type_cache_miss: - // CHECK-NEXT: %[[D1:[0-9]+]] = ptrtoint %struct.Derived1* %d1 to i64, !nosanitize - // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED1_1]] {{.*}}, i64 %[[D1]] + // CHECK: %[[D1:[0-9]+]] = ptrtoint %struct.Derived1* %d1 to i64, !nosanitize + // CHECK-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED1_1]] {{.*}}, i64 %[[D1]] } // CHECK-LABEL: define void @_Z2t2v void t2() { Derived2 d2; static_cast(&d2)->f1(); //< Devirt Base1::f1 to Derived2::f1. - // CHECK: handler.dynamic_type_cache_miss: - // CHECK-NEXT: %[[D2_1:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize - // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED2_1]] {{.*}}, i64 %[[D2_1]] + // CHECK: %[[D2_1:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize + // CHECK-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED2_1]] {{.*}}, i64 %[[D2_1]] } // CHECK-LABEL: define void @_Z2t3v void t3() { Derived2 d2; static_cast(&d2)->f1(); //< Devirt Base2::f1 to Derived2::f1. - // CHECK: handler.dynamic_type_cache_miss: - // CHECK-NEXT: %[[D2_2:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize - // CHECK-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED2_2]] {{.*}}, i64 %[[D2_2]] + // CHECK: %[[D2_2:[0-9]+]] = ptrtoint %struct.Derived2* %d2 to i64, !nosanitize + // CHECK-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED2_2]] {{.*}}, i64 %[[D2_2]] } // PR13127-LABEL: define void @_Z2t4v void t4() { Base1 p; Derived3 *badp = static_cast(&p); //< Check that &p isa Derived3. - // PR13127: handler.dynamic_type_cache_miss // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived3* {{%[0-9]+}} to i64, !nosanitize - // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED3]] {{.*}}, i64 %[[P1]] + // PR13127-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED3]] {{.*}}, i64 %[[P1]] static_cast(badp)->f1(); //< No devirt, test 'badp isa Base1'. - // PR13127: handler.dynamic_type_cache_miss // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Base1* {{%[0-9]+}} to i64, !nosanitize - // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_BASE1]] {{.*}}, i64 %[[BADP1]] + // PR13127-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_BASE1]] {{.*}}, i64 %[[BADP1]] } // PR13127-LABEL: define void @_Z2t5v void t5() { Base1 p; Derived4 *badp = static_cast(&p); //< Check that &p isa Derived4. - // PR13127: handler.dynamic_type_cache_miss: // PR13127: %[[P1:[0-9]+]] = ptrtoint %struct.Derived4* {{%[0-9]+}} to i64, !nosanitize - // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED4_1]] {{.*}}, i64 %[[P1]] + // PR13127-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED4_1]] {{.*}}, i64 %[[P1]] static_cast(badp)->f1(); //< Devirt Base1::f1 to Derived4::f1. - // PR13127: handler.dynamic_type_cache_miss1: // PR13127: %[[BADP1:[0-9]+]] = ptrtoint %struct.Derived4* {{%[0-9]+}} to i64, !nosanitize - // PR13127-NEXT: call void @{{[_a-z]+}}({{.*}} [[UBSAN_TI_DERIVED4_2]] {{.*}}, i64 %[[BADP1]] + // PR13127-NEXT: call void @__ubsan_handle_dynamic_type_cache{{[_a-z]*}}({{.*}} [[UBSAN_TI_DERIVED4_2]] {{.*}}, i64 %[[BADP1]] } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits