RE: r295474 - [OpenMP] Fix cancellation point in task with no cancel

2017-02-27 Thread Hahnfeld, Jonas via cfe-commits
Thanks!

Jonas

> -Original Message-
> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf
> Of Hans Wennborg
> Sent: Friday, February 24, 2017 6:39 PM
> To: Hahnfeld, Jonas
> Cc: cfe-commits
> Subject: Re: r295474 - [OpenMP] Fix cancellation point in task with no 
> cancel
>
> Merged to 4.0 in r296139 as requested on the r295473 commit thread.
>
> On Fri, Feb 17, 2017 at 10:32 AM, Jonas Hahnfeld via cfe-commits  comm...@lists.llvm.org> wrote:
> > Author: hahnfeld
> > Date: Fri Feb 17 12:32:58 2017
> > New Revision: 295474
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=295474&view=rev
> > Log:
> > [OpenMP] Fix cancellation point in task with no cancel
> >
> > With tasks, the cancel may happen in another task. This has a
> > different region info which means that we can't find it here.
> >
> > Differential Revision: https://reviews.llvm.org/D30091
> >
> > Modified:
> > cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> > cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
> >
> > Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-
> project/cfe/trunk/lib/CodeGen/CGOpenMPRunt
> > ime.cpp?rev=295474&r1=295473&r2=295474&view=diff
> >
> ==
> 
> > 
> > --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Feb 17 12:32:58
> 2017
> > @@ -4716,7 +4716,9 @@ void CGOpenMPRuntime::emitCancellationPo
> >// global_tid, kmp_int32 cncl_kind);
> >if (auto *OMPRegionInfo =
> >dyn_cast_or_null(CGF.CapturedStmtInfo)) {
> > -if (OMPRegionInfo->hasCancel()) {
> > +// For 'cancellation point taskgroup', the task region info may not 
> > have a
> > +// cancel. This may instead happen in another adjacent task.
> > +if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel())
> > + {
> >llvm::Value *Args[] = {
> >emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
> >CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
> >
> > Modified: cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancellation
> > _point_codegen.cpp?rev=295474&r1=295473&r2=295474&view=diff
> >
> ==
> 
> > 
> > --- cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp (original)
> > +++ cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp Fri Feb 17
> > +++ 12:32:58 2017
> > @@ -78,6 +78,12 @@ for (int i = 0; i < argc; ++i) {  }  // CHECK: call
> > i8* @__kmpc_omp_task_alloc(  // CHECK: call i32 @__kmpc_omp_task(
> > +#pragma omp task
> > +{
> > +#pragma omp cancellation point taskgroup } // CHECK: call i8*
> > +@__kmpc_omp_task_alloc( // CHECK: call i32 @__kmpc_omp_task(
> >  #pragma omp parallel sections
> >  {
> >{
> > @@ -118,6 +124,15 @@ for (int i = 0; i < argc; ++i) {
> >
> >  // CHECK: define internal i32 @{{[^(]+}}(i32
> >  // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t*
> {{[^,]+}}, i32 {{[^,]+}}, i32 4)
> > +// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
> > +// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
> > +// CHECK: [[EXIT]]
> > +// CHECK: br label %[[RETURN:.+]]
> > +// CHECK: [[RETURN]]
> > +// CHECK: ret i32 0
> > +
> > +// CHECK: define internal i32 @{{[^(]+}}(i32
> > +// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t*
> {{[^,]+}}, i32 {{[^,]+}}, i32 4)
> >  // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
> >  // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
> >  // CHECK: [[EXIT]]
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


smime.p7s
Description: S/MIME cryptographic signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30372: [Driver] Consolidate tools and toolchains by target platform. (NFC)

2017-02-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D30372#687060, @ahatanak wrote:

> In https://reviews.llvm.org/D30372#687054, @dlj wrote:
>
> > In https://reviews.llvm.org/D30372#686871, @ahatanak wrote:
> >
> > > Have you considered using "include_directories" in CMakeLists.txt to 
> > > avoid including "../Something.h"?
> >
> >
> > I don't want to take that approach, and there's a specific reason why: my 
> > concern isn't with three extra bytes, it's the fact that the headers are in 
> > an unusual place. It's typical to include headers from a subdirectory, or 
> > from the includes directory, but far less common to include from a parent 
> > lib directory. Hiding that fact seems strictly worse to me.
>
>
> OK. I was suggesting that only because LLVM already uses include_directories 
> to include a header that exists in the parent directory in some cases. 
> Apparently that's not what you wanted.


Yes it seems "common" in LLVM to do this in CMake: `include_directories( 
${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )`


https://reviews.llvm.org/D30372



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25556: [Sema] Add variable captured by a block to the enclosing lambda's potential capture list

2017-02-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Well, I was hoping that Richard would weigh in, but absent that, I don't have 
any objections.  Since it fixes a known bug, let's just go ahead and do it.  
LGTM.


https://reviews.llvm.org/D25556



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The C++98 behavior here is not really vital to test precisely; it's just minor 
differences in what gets instantiated and when.  I think it's fine to just 
update the run line to -std=c++11 for things like this.  But if you really want 
to test both configurations, this LGTM, although please leave a comment in the 
test explaining that it's just trying to account for differences in 
instantiation order between C++98 and C++11.


https://reviews.llvm.org/D30430



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30345: [CodeGen][Blocks] Refactor capture handling in code that generates block copy/destroy routines

2017-02-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

You're doing this refactor to... support doing another refactor of the same 
code?  Why are these patches separate?


Repository:
  rL LLVM

https://reviews.llvm.org/D30345



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30373: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-02-27 Thread Dominic Chen via Phabricator via cfe-commits
ddcc reopened this revision.
ddcc added a comment.
This revision is now accepted and ready to land.

It looks like there's some sort of pickling-related test failure when lit tries 
to fork, because it can't find the class `lit.TestingConfig.AnalyzerTest`: 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6154/steps/test/logs/stdio
 . I'm guessing that this has something to do with the `AnalyzerTest` class 
being loaded dynamically from `lit.local.cfg` , but short of moving it out into 
`llvm/utils/lit/lit/formats`, I have no idea how to fix this. Also, I can't 
reproduce this problem locally with `ninja -j4 check-clang`. @dcoughlin ydo you 
have any suggestions?


Repository:
  rL LLVM

https://reviews.llvm.org/D30373



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296430 - Set ABIs correctly for OpenBSD/arm; soft float and aapcs-linux.

2017-02-27 Thread Brad Smith via cfe-commits
Author: brad
Date: Mon Feb 27 21:20:26 2017
New Revision: 296430

URL: http://llvm.org/viewvc/llvm-project?rev=296430&view=rev
Log:
Set ABIs correctly for OpenBSD/arm; soft float and aapcs-linux.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Arch/ARM.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/arm-abi.c
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=296430&r1=296429&r2=296430&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Feb 27 21:20:26 2017
@@ -5166,6 +5166,8 @@ public:
   default:
 if (Triple.getOS() == llvm::Triple::NetBSD)
   setABI("apcs-gnu");
+else if (Triple.getOS() == llvm::Triple::OpenBSD)
+  setABI("aapcs-linux");
 else
   setABI("aapcs");
 break;

Modified: cfe/trunk/lib/Driver/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Arch/ARM.cpp?rev=296430&r1=296429&r2=296430&view=diff
==
--- cfe/trunk/lib/Driver/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/Arch/ARM.cpp Mon Feb 27 21:20:26 2017
@@ -191,6 +191,10 @@ arm::FloatABI arm::getARMFloatABI(const
   }
   break;
 
+case llvm::Triple::OpenBSD:
+  ABI = FloatABI::Soft;
+  break;
+
 default:
   switch (Triple.getEnvironment()) {
   case llvm::Triple::GNUEABIHF:

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=296430&r1=296429&r2=296430&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Feb 27 21:20:26 2017
@@ -787,6 +787,8 @@ void Clang::AddARMTargetArgs(const llvm:
 default:
   if (Triple.getOS() == llvm::Triple::NetBSD)
 ABIName = "apcs-gnu";
+  else if (Triple.getOS() == llvm::Triple::OpenBSD)
+ABIName = "aapcs-linux";
   else
 ABIName = "aapcs";
   break;

Modified: cfe/trunk/test/Driver/arm-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-abi.c?rev=296430&r1=296429&r2=296430&view=diff
==
--- cfe/trunk/test/Driver/arm-abi.c (original)
+++ cfe/trunk/test/Driver/arm-abi.c Mon Feb 27 21:20:26 2017
@@ -28,6 +28,10 @@
 // RUN: %clang -target arm--netbsd-eabihf %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-AAPCS %s
 
+// OpenBSD defaults to aapcs-linux
+// RUN: %clang -target arm--openbsd- %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s
+
 // Otherwise, ABI is selected based on environment
 // RUN: %clang -target arm---android %s -### -o %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-AAPCS-LINUX %s

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=296430&r1=296429&r2=296430&view=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Mon Feb 27 21:20:26 2017
@@ -96,3 +96,8 @@
 // CHECK-STATIC-PIE: "{{.*}}rcrt0.o"
 // CHECK-STATIC-PIE-NOT: "-nopie"
 // CHECK-NOPIE: "-nopie" "{{.*}}crt0.o"
+
+// Check ARM float ABI
+// RUN: %clang -target arm-unknown-openbsd -### -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s
+// CHECK-ARM-FLOAT-ABI: "-mfloat-abi" "soft"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-27 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D29221#687438, @amaiorano wrote:

> In https://reviews.llvm.org/D29221#687425, @hans wrote:
>
> > In https://reviews.llvm.org/D29221#686865, @amaiorano wrote:
> >
> > > Made changes based on @hans 's feedback.
> > >
> > > I looked again at the categories, and I think it makes sense with my 
> > > changes. Here's an updated screenshot that shows what the options menu in 
> > > Visual Studio looks like with these changes with the top-level category 
> > > name ("LLVM/Clang") and page name ("Clang Format") highlighted, as well 
> > > as the category names for the page items ("Format Options" and "Format On 
> > > Save") highlighted:
> > >
> > > F3117958: pasted_file 
> > >
> > > It would be nice if "Format On Save" was _below_ "Format Options", but 
> > > Visual Studio always orders the page categories in alphabetical order, so 
> > > this is pretty standard.
> >
> >
> > The screenshot looks good.
> >
> > My only nit is that I'd prefer "clang-format" instead of "ClangFormat".
> >
> > Manuel: the menu options under Tools currently say "Clang Format 
> > {Selection,Document}". What do you think about using "clang-format" here 
> > instead? That is the name of the tool after all, and I think it also works 
> > nicely as a verb.
> >
> > I realize the actual extension is called ClangFormat, but maybe there were 
> > reasons for that, or we have to live with it?
>
>
> I would also like clang-format in there rather than ClangFormat. One thing to 
> validate is whether this change would mean people would lose their changes to 
> the defaults in the configuration panel. I'll run some tests and see if this 
> is indeed the case. Maybe there's a way to keep the internal name the same 
> for config purposes, but change the displayed name instead. Will get back to 
> you.


Okay, I looked into it, and the good news is that changing the name of the 
category from ClangFormat to clang-format doesn't reset the previously saved 
changes made in the options menu. I also changed the menu item names. Here's 
what both would look like:

F3119242: pasted_file 

F3119244: pasted_file 

Now having said that, I'm not sure if this is the best change because of a few 
things:

1. The extension's name itself is ClangFormat, which was recently added to the 
Visual Studio market place here: 
https://marketplace.visualstudio.com/items?itemName=HansWennborg.ClangFormat . 
Consequently, the extension appears with this name in the Visual Studio 
extensions dialog: F3119249: pasted_file . I 
don't think it would be easy to change this. You cannot really take down an 
extension page on the marketplace once it's there; you'd have to document that 
it has been deprecated and provide a link to a new page. When searching for it 
in the Extensions dialog in VS, though, both the old and new extension would 
show up.

2. Although the name of the executable is indeed "clang-format", the 
documentation here  uses the name 
ClangFormat: F3119251: pasted_file 

So I leave it up to you whether you really want this change or not. We can also 
decide later rather than fold it into this change.


https://reviews.llvm.org/D29221



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-02-27 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 89957.
spyffe added a comment.

• Applied Adrian's suggestion to move comments before the line they apply to.
• Got to 100% coverage by changing a test and making an assert for something I 
couldn't make happen in a test.

I did not take Adrian's suggestion to remove braces around a single-statement 
`if` because (as far as I can tell) the LLVM coding standard is silent on the 
topic and I prefer to have the braces there.


Repository:
  rL LLVM

https://reviews.llvm.org/D30435

Files:
  test/Import/forward-declared-struct/Inputs/S1.c
  test/Import/forward-declared-struct/Inputs/S2.c
  test/Import/forward-declared-struct/test.c
  test/Import/member-in-struct/Inputs/S.c
  test/Import/member-in-struct/test.c
  test/Import/multiple-forward-declarations/Inputs/S1.c
  test/Import/multiple-forward-declarations/Inputs/S2.c
  test/Import/multiple-forward-declarations/test.c
  test/Import/overloaded-function/Inputs/F1.c
  test/Import/overloaded-function/Inputs/F2.c
  test/Import/overloaded-function/test.c
  test/Import/struct-in-namespace/Inputs/N1.cpp
  test/Import/struct-in-namespace/Inputs/N2.cpp
  test/Import/struct-in-namespace/Inputs/N3.cpp
  test/Import/struct-in-namespace/test.cpp
  test/Import/template-specialization/Inputs/T.cpp
  test/Import/template-specialization/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -9,6 +9,7 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTImporter.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -189,19 +190,77 @@
 } // end namespace
 
 namespace {
+class TestASTImporter : public ASTImporter {
+public:
+  TestASTImporter(ASTContext &ToContext, FileManager &ToFileManager,
+  ASTContext &FromContext, FileManager &FromFileManager,
+  bool MinimalImport)
+  : ASTImporter(ToContext, ToFileManager, FromContext, FromFileManager,
+MinimalImport) {}
+  Decl *Imported(Decl *From, Decl *To) override {
+if (auto ToTag = llvm::dyn_cast(To)) {
+  ToTag->setHasExternalLexicalStorage();
+} else if (auto ToNamespace = llvm::dyn_cast(To)) {
+  ToNamespace->setHasExternalVisibleStorage();
+}
+return ASTImporter::Imported(From, To);
+  }
+};
+
+const DeclContext *LookupSameContext(const TranslationUnitDecl *SearchTU,
+ const DeclContext *SourceDC,
+ ASTImporter &SourceToSearchImporter) {
+  if (SourceDC->isTranslationUnit()) {
+return SearchTU;
+  }
+  const DeclContext *SearchParentDC =
+  LookupSameContext(SearchTU, SourceDC->getParent(), SourceToSearchImporter);
+  if (!SearchParentDC) {
+// If we couldn't find the parent DC in this TranslationUnit, give up.
+return nullptr;
+  }
+  auto SourceNamedDecl = cast(SourceDC);
+  DeclarationName SourceName = SourceNamedDecl->getDeclName();
+  DeclarationName SearchName = SourceToSearchImporter.Import(SourceName);
+  DeclContext::lookup_result SearchResult = SearchParentDC->lookup(SearchName);
+  size_t SearchResultSize = SearchResult.size();
+  // Handle multiple candidates once we have a test for it.
+  // This may turn up when we import template specializations correctly.
+  assert(SearchResultSize < 2); 
+  if (SearchResultSize == 0) {
+// couldn't find the name, so we have to give up
+return nullptr;
+  } else {
+NamedDecl *SearchResultDecl = SearchResult[0];
+return dyn_cast(SearchResultDecl);
+  }
+}
+
+bool IsForwardDeclaration(Decl *D) {
+  assert(!isa(D)); // TODO handle this case
+  if (auto TD = dyn_cast(D)) {
+return !TD->isThisDeclarationADefinition();
+  } else if (auto FD = dyn_cast(D)) {
+return !FD->isThisDeclarationADefinition();
+  } else {
+return false;
+  }
+}
+
 class TestExternalASTSource : public ExternalASTSource {
 private:
   llvm::ArrayRef> ImportCIs;
-  std::map> ForwardImporters;
+  std::map>
+  ForwardImporters;
   std::map> ReverseImporters;
 
 public:
   TestExternalASTSource(
   CompilerInstance &ExpressionCI,
   llvm::ArrayRef> ImportCIs)
   : ImportCIs(ImportCIs) {
 for (const std::unique_ptr &ImportCI : ImportCIs) {
-  ForwardImporters[ImportCI.get()] = llvm::make_unique(
+  ForwardImporters[ImportCI.get()] = llvm::make_unique(
   ExpressionCI.getASTContext(), ExpressionCI.getFileManager(),
   ImportCI->getASTContext(), ImportCI->getFileManager(),
   /*MinimalImport=*/true);
@@ -212,29 +271,88 @@
 }
   }
 
+  void ForEachMatchingDC(const DeclContext *DC,
+ std::function
+ Callback) {
+for (const std::unique_ptr &I : Imp

RE: r296414 - Reland: [analyzer] NFC: Update test infrastructure to support multiple constraint managers

2017-02-27 Thread Yung, Douglas via cfe-commits
Hi Dominic,

Did you forget to submit something to get this patch to work?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6154/steps/test/logs/stdio:

pickle.PicklingError: Can't pickle : 
it's not found as lit.TestingConfig.AnalyzerTest

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Dominic Chen via cfe-commits
> Sent: Monday, February 27, 2017 16:03
> To: cfe-commits@lists.llvm.org
> Subject: r296414 - Reland: [analyzer] NFC: Update test infrastructure to
> support multiple constraint managers
> 
> Author: ddcc
> Date: Mon Feb 27 18:02:36 2017
> New Revision: 296414
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296414&view=rev
> Log:
> Reland: [analyzer] NFC: Update test infrastructure to support multiple
> constraint managers
> 
> Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when
> invoking static analyzer, and perform runtime substitution to select the
> appropriate constraint manager, per D28952.
> 
> Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin
> 
> Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D30373
> 
> Modified:
> cfe/trunk/test/Analysis/CFContainers-invalid.c
> cfe/trunk/test/Analysis/CFContainers.mm
> cfe/trunk/test/Analysis/CFDateGC.m
> cfe/trunk/test/Analysis/CFNumber.c
> cfe/trunk/test/Analysis/CFRetainRelease_NSAssertionHandler.m
> cfe/trunk/test/Analysis/CGColorSpace.c
> cfe/trunk/test/Analysis/CheckNSError.m
> cfe/trunk/test/Analysis/DeallocMissingRelease.m
> cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
> cfe/trunk/test/Analysis/DynamicTypePropagation.m
> cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
> cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp
> cfe/trunk/test/Analysis/Malloc+NewDelete_intersections.cpp
> cfe/trunk/test/Analysis/MemRegion.cpp
> cfe/trunk/test/Analysis/MismatchedDeallocator-checker-test.mm
> cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp
> cfe/trunk/test/Analysis/MissingDealloc.m
> cfe/trunk/test/Analysis/NSContainers.m
> cfe/trunk/test/Analysis/NSPanel.m
> cfe/trunk/test/Analysis/NSString.m
> cfe/trunk/test/Analysis/NSWindow.m
> cfe/trunk/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
> cfe/trunk/test/Analysis/NewDelete-checker-test.cpp
> cfe/trunk/test/Analysis/NewDelete-custom.cpp
> cfe/trunk/test/Analysis/NewDelete-intersections.mm
> cfe/trunk/test/Analysis/NewDelete-path-notes.cpp
> cfe/trunk/test/Analysis/NewDelete-variadic.cpp
> cfe/trunk/test/Analysis/NewDeleteLeaks-PR18394.cpp
> cfe/trunk/test/Analysis/NewDeleteLeaks-PR19102.cpp
> cfe/trunk/test/Analysis/NoReturn.m
> cfe/trunk/test/Analysis/OSAtomic_mac.cpp
> cfe/trunk/test/Analysis/ObjCProperties.m
> cfe/trunk/test/Analysis/ObjCPropertiesSyntaxChecks.m
> cfe/trunk/test/Analysis/ObjCRetSigs.m
> cfe/trunk/test/Analysis/PR12905.c
> cfe/trunk/test/Analysis/PR24184.cpp
> cfe/trunk/test/Analysis/PR2599.m
> cfe/trunk/test/Analysis/PR2978.m
> cfe/trunk/test/Analysis/PR3991.m
> cfe/trunk/test/Analysis/PR7218.c
> cfe/trunk/test/Analysis/additive-folding-range-constraints.c
> cfe/trunk/test/Analysis/additive-folding.cpp
> cfe/trunk/test/Analysis/analyzeOneFunction.m
> cfe/trunk/test/Analysis/analyzer-checker-config.c
> cfe/trunk/test/Analysis/analyzer-config.c
> cfe/trunk/test/Analysis/analyzer-config.cpp
> cfe/trunk/test/Analysis/analyzer-display-progress.cpp
> cfe/trunk/test/Analysis/analyzer-display-progress.m
> cfe/trunk/test/Analysis/analyzer-enabled-checkers.c
> cfe/trunk/test/Analysis/analyzer-stats.c
> cfe/trunk/test/Analysis/array-struct-region.c
> cfe/trunk/test/Analysis/array-struct-region.cpp
> cfe/trunk/test/Analysis/array-struct.c
> cfe/trunk/test/Analysis/atomics.c
> cfe/trunk/test/Analysis/auto-obj-dtors-cfg-output.cpp
> cfe/trunk/test/Analysis/base-init.cpp
> cfe/trunk/test/Analysis/bitwise-ops.c
> cfe/trunk/test/Analysis/block-in-critical-section.cpp
> cfe/trunk/test/Analysis/blocks-no-inline.c
> cfe/trunk/test/Analysis/blocks.m
> cfe/trunk/test/Analysis/blocks.mm
> cfe/trunk/test/Analysis/bool-assignment.c
> cfe/trunk/test/Analysis/bstring.c
> cfe/trunk/test/Analysis/bstring.cpp
> cfe/trunk/test/Analysis/bug_hash_test.cpp
> cfe/trunk/test/Analysis/bug_hash_test.m
> cfe/trunk/test/Analysis/builtin-functions.cpp
> cfe/trunk/test/Analysis/call-invalidation.cpp
> cfe/trunk/test/Analysis/cast-to-struct.cpp
> cfe/trunk/test/Analysis/castexpr-callback.c
> cfe/trunk/test/Analysis/casts.c
> cfe/trunk/test/Analysis/casts.cpp
> cfe/trunk/test/Analysis/casts.m
> cfe/trunk/test/Analysis/cfg.cpp
> cfe/trunk/test/Analys

Re: r296408 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Galina Kistanova via cfe-commits
Hello Nico,

This commit broke test on one of our builders:

Clang :: Format/inplace.cpp

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6151/steps/test/logs/stdio

Please have a look.

Thanks

Galina

On Mon, Feb 27, 2017 at 2:59 PM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nico
> Date: Mon Feb 27 16:59:58 2017
> New Revision: 296408
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296408&view=rev
> Log:
> clang-format: Don't leave behind temp files in -i mode on Windows,
> PR26125, reloaded
>
> Second attempt after http://llvm.org/viewvc/llvm-
> project?rev=296166&view=rev
>
> In the first attempt, Code (the memory buffer backing the input file) was
> reset
> before overwriteChangedFiles() was called, but overwriteChangedFiles()
> still
> reads from it.  This time, load the whole input file into memory instead of
> using mmap when formatting in-place.
>
> (Since the test is identical to what was in the repo before chapuni's
> revert,
> svn diff doesn't show it – see the above link for the test.)
>
> https://reviews.llvm.org/D30385
>
> Added:
> cfe/trunk/test/Format/inplace.cpp
>   - copied unchanged from r296236, cfe/trunk/test/Format/inplace.cpp
> Modified:
> cfe/trunk/tools/clang-format/ClangFormat.cpp
>
> Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-
> format/ClangFormat.cpp?rev=296408&r1=296407&r2=296408&view=diff
> 
> ==
> --- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
> +++ cfe/trunk/tools/clang-format/ClangFormat.cpp Mon Feb 27 16:59:58 2017
> @@ -236,8 +236,15 @@ static void outputReplacementsXML(const
>
>  // Returns true on error.
>  static bool format(StringRef FileName) {
> +  if (!OutputXML && Inplace && FileName == "-") {
> +errs() << "error: cannot use -i when reading from stdin.\n";
> +return false;
> +  }
> +  // On Windows, overwriting a file with an open file mapping doesn't
> work,
> +  // so read the whole file into memory when formatting in-place.
>ErrorOr> CodeOrErr =
> -  MemoryBuffer::getFileOrSTDIN(FileName);
> +  !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
> +  MemoryBuffer::getFileOrSTDIN(FileName);
>if (std::error_code EC = CodeOrErr.getError()) {
>  errs() << EC.message() << "\n";
>  return true;
> @@ -297,9 +304,7 @@ static bool format(StringRef FileName) {
>  Rewriter Rewrite(Sources, LangOptions());
>  tooling::applyAllReplacements(Replaces, Rewrite);
>  if (Inplace) {
> -  if (FileName == "-")
> -errs() << "error: cannot use -i when reading from stdin.\n";
> -  else if (Rewrite.overwriteChangedFiles())
> +  if (Rewrite.overwriteChangedFiles())
>  return true;
>  } else {
>if (Cursor.getNumOccurrences() != 0)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r296110 - [change-namepsace] make it possible to whitelist symbols so they don't get updated.

2017-02-27 Thread Galina Kistanova via cfe-commits
Hello Eric,

This commit broke test on one of our builders:

Clang Tools :: change-namespace/white-list.cpp

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6153/steps/test/logs/stdio

Please have a look.

Thanks

Galina


On Fri, Feb 24, 2017 at 3:54 AM, Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ioeric
> Date: Fri Feb 24 05:54:45 2017
> New Revision: 296110
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296110&view=rev
> Log:
> [change-namepsace] make it possible to whitelist symbols so they don't get
> updated.
>
> Reviewers: hokein
>
> Reviewed By: hokein
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D30328
>
> Added:
> clang-tools-extra/trunk/test/change-namespace/Inputs/
> clang-tools-extra/trunk/test/change-namespace/Inputs/fake-std.h
> clang-tools-extra/trunk/test/change-namespace/white-list.cpp
> Modified:
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> clang-tools-extra/trunk/unittests/change-namespace/
> ChangeNamespaceTests.cpp
>
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/change-namespace/ChangeNamespace.cpp?rev=296110&r1=296109&r2=296110&
> view=diff
> 
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
> (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Fri Feb
> 24 05:54:45 2017
> @@ -290,6 +290,7 @@ AST_MATCHER(EnumDecl, isScoped) {
>
>  ChangeNamespaceTool::ChangeNamespaceTool(
>  llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +llvm::ArrayRef WhiteListedSymbolPatterns,
>  std::map *FileToReplacements,
>  llvm::StringRef FallbackStyle)
>  : FallbackStyle(FallbackStyle), FileToReplacements(*
> FileToReplacements),
> @@ -308,6 +309,9 @@ ChangeNamespaceTool::ChangeNamespaceTool
>}
>DiffOldNamespace = joinNamespaces(OldNsSplitted);
>DiffNewNamespace = joinNamespaces(NewNsSplitted);
> +
> +  for (const auto &Pattern : WhiteListedSymbolPatterns)
> +WhiteListedSymbolRegexes.emplace_back(Pattern);
>  }
>
>  void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder
> *Finder) {
> @@ -736,6 +740,9 @@ void ChangeNamespaceTool::replaceQualifi
>Result.SourceManager->getSpellingLoc(End)),
>*Result.SourceManager, Result.Context->getLangOpts());
>std::string FromDeclName = FromDecl->getQualifiedNameAsString();
> +  for (llvm::Regex &RE : WhiteListedSymbolRegexes)
> +if (RE.match(FromDeclName))
> +  return;
>std::string ReplaceName =
>getShortestQualifiedNameInNamespace(FromDeclName, NewNs);
>// Checks if there is any using namespace declarations that can shorten
> the
>
> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/change-namespace/ChangeNamespace.h?rev=296110&
> r1=296109&r2=296110&view=diff
> 
> ==
> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h (original)
> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h Fri Feb 24
> 05:54:45 2017
> @@ -50,6 +50,7 @@ public:
>// files matching `FilePattern`.
>ChangeNamespaceTool(
>llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef
> FilePattern,
> +  llvm::ArrayRef WhiteListedSymbolPatterns,
>std::map *FileToReplacements,
>llvm::StringRef FallbackStyle = "LLVM");
>
> @@ -164,6 +165,9 @@ private:
>// CallExpr and one as DeclRefExpr), we record all DeclRefExpr's that
> have
>// been processed so that we don't handle them twice.
>llvm::SmallPtrSet ProcessedFuncRefs;
> +  // Patterns of symbol names whose references are not expected to be
> updated
> +  // when changing namespaces around them.
> +  std::vector WhiteListedSymbolRegexes;
>  };
>
>  } // namespace change_namespace
>
> Modified: clang-tools-extra/trunk/change-namespace/tool/
> ClangChangeNamespace.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=
> 296110&r1=296109&r2=296110&view=diff
> 
> ==
> --- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> (original)
> +++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
> Fri Feb 24 05:54:45 2017
> @@ -73,6 +73,25 @@ cl::opt Style("style",
> cl::desc("The style name used for
> reformatting."),
> cl::init("LLVM"), cl::cat(
> ChangeNa

[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-02-27 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

A few stylistic issues inline.
It also wouldn't hurt to document what is being tested, either in the 
clang-import-test sources or in the input files. Otherwise this looks fine. 
More tests are always great!




Comment at: tools/clang-import-test/clang-import-test.cpp:213
+ ASTImporter &SourceToSearchImporter) {
+  if (SourceDC->isTranslationUnit()) {
+return SearchTU;

Sort of an irrelevant nitpick, but we don't typically use curly braces on 
single statements.



Comment at: tools/clang-import-test/clang-import-test.cpp:228
+if (SearchResultSize == 0) {
+  return nullptr; // couldn't find the name, so we have to give up
+} else if (SearchResultSize > 1) {

->

// Couldn't find the name, so we have to give up.
return nullptr;


Repository:
  rL LLVM

https://reviews.llvm.org/D30435



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-02-27 Thread Sean Callanan via Phabricator via cfe-commits
spyffe created this revision.
Herald added a subscriber: jgosnell.

clang-import-test has until now been only able to report top-level entities.  
This is clearly insufficient; we should be able to look inside structs and 
namespaces also.
This patch adds new test cases for a variety of lookups inside existing 
entities, and adds the functionality necessary to make most of these testcases 
work.
One testcase is known to fail because of ASTImporter limitations when importing 
templates; this will be addressed separately.


Repository:
  rL LLVM

https://reviews.llvm.org/D30435

Files:
  test/Import/forward-declared-struct/Inputs/S1.c
  test/Import/forward-declared-struct/Inputs/S2.c
  test/Import/forward-declared-struct/test.c
  test/Import/member-in-struct/Inputs/S.c
  test/Import/member-in-struct/test.c
  test/Import/multiple-forward-declarations/Inputs/S1.c
  test/Import/multiple-forward-declarations/Inputs/S2.c
  test/Import/multiple-forward-declarations/test.c
  test/Import/overloaded-function/Inputs/F1.c
  test/Import/overloaded-function/Inputs/F2.c
  test/Import/overloaded-function/test.c
  test/Import/struct-in-namespace/Inputs/N1.cpp
  test/Import/struct-in-namespace/Inputs/N2.cpp
  test/Import/struct-in-namespace/test.cpp
  test/Import/template-specialization/Inputs/T.cpp
  test/Import/template-specialization/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -9,6 +9,7 @@
 
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTImporter.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/SourceLocation.h"
@@ -189,19 +190,80 @@
 } // end namespace
 
 namespace {
+class TestASTImporter : public ASTImporter {
+public:
+  TestASTImporter(ASTContext &ToContext, FileManager &ToFileManager,
+  ASTContext &FromContext, FileManager &FromFileManager,
+  bool MinimalImport)
+  : ASTImporter(ToContext, ToFileManager, FromContext, FromFileManager,
+MinimalImport) {}
+  Decl *Imported(Decl *From, Decl *To) override {
+if (auto ToTag = llvm::dyn_cast(To)) {
+  ToTag->setHasExternalLexicalStorage();
+} else if (auto ToNamespace = llvm::dyn_cast(To)) {
+  ToNamespace->setHasExternalVisibleStorage();
+}
+return ASTImporter::Imported(From, To);
+  }
+};
+
+const DeclContext *LookupSameContext(const TranslationUnitDecl *SearchTU,
+ const DeclContext *SourceDC,
+ ASTImporter &SourceToSearchImporter) {
+  if (SourceDC->isTranslationUnit()) {
+return SearchTU;
+  }
+  const DeclContext *SearchParentDC =
+  LookupSameContext(SearchTU, SourceDC->getParent(), SourceToSearchImporter);
+  if (!SearchParentDC) {
+return nullptr;
+  }
+  if (auto SourceNamedDecl = dyn_cast(SourceDC)) {
+DeclarationName SourceName = SourceNamedDecl->getDeclName();
+DeclarationName SearchName = SourceToSearchImporter.Import(SourceName);
+DeclContext::lookup_result SearchResult =
+SearchParentDC->lookup(SearchName);
+size_t SearchResultSize = SearchResult.size();
+if (SearchResultSize == 0) {
+  return nullptr; // couldn't find the name, so we have to give up
+} else if (SearchResultSize > 1) {
+  return nullptr; // unhandled case; here we need to perform overload
+  // resolution
+} else {
+  NamedDecl *SearchResultDecl = SearchResult[0];
+  return dyn_cast(SearchResultDecl);
+}
+  } else {
+return nullptr; // unhandled case; here we need to handle e.g.
+// NamespaceDecls
+  }
+}
+
+bool IsForwardDeclaration(Decl *D) {
+  assert(!isa(D)); // TODO handle this case
+  if (auto TD = dyn_cast(D)) {
+return !TD->isThisDeclarationADefinition();
+  } else if (auto FD = dyn_cast(D)) {
+return !FD->isThisDeclarationADefinition();
+  } else {
+return false;
+  }
+}
+
 class TestExternalASTSource : public ExternalASTSource {
 private:
   llvm::ArrayRef> ImportCIs;
-  std::map> ForwardImporters;
+  std::map>
+  ForwardImporters;
   std::map> ReverseImporters;
 
 public:
   TestExternalASTSource(
   CompilerInstance &ExpressionCI,
   llvm::ArrayRef> ImportCIs)
   : ImportCIs(ImportCIs) {
 for (const std::unique_ptr &ImportCI : ImportCIs) {
-  ForwardImporters[ImportCI.get()] = llvm::make_unique(
+  ForwardImporters[ImportCI.get()] = llvm::make_unique(
   ExpressionCI.getASTContext(), ExpressionCI.getFileManager(),
   ImportCI->getASTContext(), ImportCI->getFileManager(),
   /*MinimalImport=*/true);
@@ -212,29 +274,88 @@
 }
   }
 
+  void ForEachMatchingDC(const DeclContext *DC,
+ std::function
+ 

[PATCH] D30166: Honor __unaligned in codegen for declarations and expressions

2017-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: majnemer.
aaron.ballman added inline comments.



Comment at: include/clang/AST/ASTContext.h:1909
+// the unqualified type.
+if (T.getQualifiers().hasUnaligned())
+  TI.Align = getCharWidth();

This makes me a bit uncomfortable -- wouldn't we rather have the distinction 
between unqualified and qualified types instead of a mixture of both when 
calling `getTypeInfo()`?


https://reviews.llvm.org/D30166



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Parse/ParseDecl.cpp:1161
+} else {
+  assert(Keyword == Ident_defined_in);
+  if (HadDefinedIn) {

Add a string literal to the assert?



Comment at: lib/Parse/ParseDeclCXX.cpp:3818-3819
+  if (ScopeName && (ScopeName->getName() == "gnu" ||
+(ScopeName->getName() == "clang" &&
+ AttrName->isStr("external_source_symbol"
 // GNU-scoped attributes have some special cases to handle GNU-specific

aaron.ballman wrote:
> I don't really like hard-coding a list of attributes like this. I think you 
> should handle clang-namespaced attributes with a separate helper function.
This still isn't quite what I was looking for -- the helper function I was 
talking about was a replacement for `ParseGNUAttributeArgs()`. I'm sorry if I 
was unclear.

I think we should have a `ParseClangAttributeArgs()` that handles your custom 
parsing; it can then call through to `ParseAttributeArgsCommon()` for common 
argument handling in the same way `ParseGNUAttributeArgs()` does. So the 
predicate would be `else if (ScopeName && ScopeName->getName() == "clang")`.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r296171 - Try to unbreak tests after r296166

2017-02-27 Thread Yung, Douglas via cfe-commits
Thanks Nico. I think your suggestion is the right one, I am just trying to 
determine if there is a reason why we are not using that version internally 
(since our internal bot also failied for the same reason) before we recommend 
upgrading the bot.

Douglas Yung

From: Nico Weber [mailto:tha...@google.com]
Sent: Monday, February 27, 2017 15:13
To: Yung, Douglas
Cc: cfe-commits; nicolaswe...@gmx.de
Subject: Re: r296171 - Try to unbreak tests after r296166

I relanded the test in r296408. Since this deletes temp files created by the OS 
following an unpredictable pattern, exactly specifying the filename to delete 
isn't possible. Let me know if putting a functional rm on your bots is a 
problem and then we can see if we can think of something else, but fixing your 
bots's rm seems easiest to me :-)

On Sat, Feb 25, 2017 at 10:39 AM, Nico Weber 
mailto:tha...@google.com>> wrote:
Can't you just put gnuwin rm on your bot? Our Windows bots are happy with the 
test, and having to support an rm without wildcard support seems pretty 
strange. (Https://is.gd/chromeclang -> tools -> gnuwin-6.zip are the 
executables our bot uses to run llvm tests)

On Feb 24, 2017 8:13 PM, "Yung, Douglas via cfe-commits" 
mailto:cfe-commits@lists.llvm.org>> wrote:
Hi Nico,

The test you added is causing a failure on the PS4 Windows bot. The root of the 
cause is that the Windows version of rm does not accept wildcards 
unfortunately. To fix make it work on Windows, you likely need to specify 
exactly what files/directories you want to delete without using a wildcard:

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6030:

$ "rm" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Format\Output/*"
# command stderr:
rm: cannot remove 
`C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\test\\Format\\Output/*':
 Invalid argument

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/6031:

$ "rm" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\test\Format\Output/inplace*"
# command stderr:
rm: cannot remove 
`C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\clang\\test\\Format\\Output/inplace*':
 Invalid argument

Can you fix the test?

Douglas Yung

> -Original Message-
> From: cfe-commits 
> [mailto:cfe-commits-boun...@lists.llvm.org]
>  On Behalf Of
> Nico Weber via cfe-commits
> Sent: Friday, February 24, 2017 13:02
> To: cfe-commits@lists.llvm.org
> Subject: r296171 - Try to unbreak tests after r296166
>
> Author: nico
> Date: Fri Feb 24 15:01:43 2017
> New Revision: 296171
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296171&view=rev
> Log:
> Try to unbreak tests after r296166
>
> Looks like %T isn't per-test but per-test-directory, and the rm was deleting
> temp files written by other tests in test/Format.  Limit the rm's scope a bit.
>
> Modified:
> cfe/trunk/test/Format/inplace.cpp
>
> Modified: cfe/trunk/test/Format/inplace.cpp
> URL: http://llvm.org/viewvc/llvm-
> project/cfe/trunk/test/Format/inplace.cpp?rev=296171&r1=296170&r2=296171&view=
> diff
> ==
> --- cfe/trunk/test/Format/inplace.cpp (original)
> +++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 15:01:43 2017
> @@ -1,6 +1,6 @@
>  // Regression test to check that clang-format does not leave behind temporary
> // files on Windows when doing in-place formatting.
> -// RUN: rm %T/*
> +// RUN: rm %T/inplace*
>  // RUN: cp %s %T/inplace.cpp
>  // RUN: clang-format -style=LLVM -i %T/inplace.cpp  // RUN: ls %T >
> %T/files.txt
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.

2017-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:25
+static const StringRef ReplaceMessage =
+"do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'.";
+

Diagnostics are not full sentences. This should probably be: 
`'std::random_shuffle' has been removed in C++17; use 'std::shuffle' instead`.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:27
+
+static const StringRef RandomFunctionMessage =
+" The old user defined 'RandomFunction' is not usable for 'shuffle'. You "

I'd feel more comfortable if both of these were `const char[]` rather than 
`StringRef`, because `StringRef` doesn't typically own the underlying memory 
and should not be long-lived.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:28
+static const StringRef RandomFunctionMessage =
+" The old user defined 'RandomFunction' is not usable for 'shuffle'. You "
+"need to make additional changes if you want a specific random function.";

Instead of adding additional text in this case, would it make sense to use a 
different diagnostic? e.g., `'std::random_shuffle' has been removed in C++17; 
use an alternative mechanism instead` (or something along those lines). 
Regardless, it shouldn't be using full sentences.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:71
+  const auto *MatchedCallExpr = Result.Nodes.getNodeAs("match");
+  SourceManager &SM = *Result.SourceManager;
+  LangOptions LangOpts = getLangOpts();

No need for this to be a separate variable.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:72
+  SourceManager &SM = *Result.SourceManager;
+  LangOptions LangOpts = getLangOpts();
+

No need for this to be a separate variable.



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:77
+
+  auto Diag = [=]() {
+std::string Message = ReplaceMessage;

Is there a reason this needs to capture everything by copy? Also, no need for 
the empty parens. Actually, is the lambda even necessary at all?



Comment at: clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp:105
+
+  if (auto IncludeFixit = IncludeInserter->CreateIncludeInsertion(
+  Result.Context->getSourceManager().getFileID(

Please don't use `auto` as the type is not specified in the initialization.



Comment at: docs/clang-tidy/checks/modernize-replace-random-shuffle.rst:8
+
+Below is two examples of what kind of occurrences will be found and two 
examples of what it will be replaced with.
+

is -> are



Comment at: docs/clang-tidy/checks/modernize-replace-random-shuffle.rst:20
+
+Both these examples will be replaced with
+

Both these -> Both of these
with -> with:


https://reviews.llvm.org/D30158



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r296408, thanks!


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r296171 - Try to unbreak tests after r296166

2017-02-27 Thread Nico Weber via cfe-commits
I relanded the test in r296408. Since this deletes temp files created by
the OS following an unpredictable pattern, exactly specifying the filename
to delete isn't possible. Let me know if putting a functional rm on your
bots is a problem and then we can see if we can think of something else,
but fixing your bots's rm seems easiest to me :-)

On Sat, Feb 25, 2017 at 10:39 AM, Nico Weber  wrote:

> Can't you just put gnuwin rm on your bot? Our Windows bots are happy with
> the test, and having to support an rm without wildcard support seems pretty
> strange. (Https://is.gd/chromeclang -> tools -> gnuwin-6.zip are the
> executables our bot uses to run llvm tests)
>
> On Feb 24, 2017 8:13 PM, "Yung, Douglas via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi Nico,
>>
>> The test you added is causing a failure on the PS4 Windows bot. The root
>> of the cause is that the Windows version of rm does not accept wildcards
>> unfortunately. To fix make it work on Windows, you likely need to specify
>> exactly what files/directories you want to delete without using a wildcard:
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast/builds/6030:
>>
>> $ "rm" "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10p
>> ro-fast\llvm.obj\tools\clang\test\Format\Output/*"
>> # command stderr:
>> rm: cannot remove `C:\\Buildbot\\Slave\\llvm-cla
>> ng-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\
>> clang\\test\\Format\\Output/*': Invalid argument
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast/builds/6031:
>>
>> $ "rm" "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10p
>> ro-fast\llvm.obj\tools\clang\test\Format\Output/inplace*"
>> # command stderr:
>> rm: cannot remove `C:\\Buildbot\\Slave\\llvm-cla
>> ng-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\
>> clang\\test\\Format\\Output/inplace*': Invalid argument
>>
>> Can you fix the test?
>>
>> Douglas Yung
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>> Behalf Of
>> > Nico Weber via cfe-commits
>> > Sent: Friday, February 24, 2017 13:02
>> > To: cfe-commits@lists.llvm.org
>> > Subject: r296171 - Try to unbreak tests after r296166
>> >
>> > Author: nico
>> > Date: Fri Feb 24 15:01:43 2017
>> > New Revision: 296171
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=296171&view=rev
>> > Log:
>> > Try to unbreak tests after r296166
>> >
>> > Looks like %T isn't per-test but per-test-directory, and the rm was
>> deleting
>> > temp files written by other tests in test/Format.  Limit the rm's scope
>> a bit.
>> >
>> > Modified:
>> > cfe/trunk/test/Format/inplace.cpp
>> >
>> > Modified: cfe/trunk/test/Format/inplace.cpp
>> > URL: http://llvm.org/viewvc/llvm-
>> > project/cfe/trunk/test/Format/inplace.cpp?rev=296171&r1=2961
>> 70&r2=296171&view=
>> > diff
>> > 
>> ==
>> > --- cfe/trunk/test/Format/inplace.cpp (original)
>> > +++ cfe/trunk/test/Format/inplace.cpp Fri Feb 24 15:01:43 2017
>> > @@ -1,6 +1,6 @@
>> >  // Regression test to check that clang-format does not leave behind
>> temporary
>> > // files on Windows when doing in-place formatting.
>> > -// RUN: rm %T/*
>> > +// RUN: rm %T/inplace*
>> >  // RUN: cp %s %T/inplace.cpp
>> >  // RUN: clang-format -style=LLVM -i %T/inplace.cpp  // RUN: ls %T >
>> > %T/files.txt
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27627: [WIP] Supporting C++ based kernel languages on AMDGPU Target

2017-02-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 89944.
yaxunl added a comment.

Fixed invalid bitcasts due to vtable.
Added run line for amdgcn target to more Cuda lit tests.


https://reviews.llvm.org/D27627

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGVTT.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCUDA/address-spaces.cu
  test/CodeGenCUDA/convergent.cu
  test/CodeGenCUDA/device-var-init.cu
  test/CodeGenCUDA/device-vtable.cu
  test/CodeGenCUDA/filter-decl.cu
  test/CodeGenCUDA/function-overload.cu
  test/CodeGenCUDA/kernel-args-alignment.cu
  test/OpenMP/nvptx_parallel_codegen.cpp

Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=amdgcn -emit-llvm-bc %s -o %t-x86-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
 // RUN: %clang_cc1 -verify -fopenmp -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
 // expected-no-diagnostics
Index: test/CodeGenCUDA/kernel-args-alignment.cu
===
--- test/CodeGenCUDA/kernel-args-alignment.cu
+++ test/CodeGenCUDA/kernel-args-alignment.cu
@@ -1,8 +1,11 @@
 // RUN: %clang_cc1 --std=c++11 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | \
-// RUN:  FileCheck -check-prefix HOST -check-prefix CHECK %s
+// RUN:  FileCheck -check-prefixes=HOST,CHECK %s
 
 // RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple nvptx64-nvidia-cuda \
-// RUN:   -emit-llvm -o - %s | FileCheck -check-prefix DEVICE -check-prefix CHECK %s
+// RUN:   -emit-llvm -o - %s | FileCheck -check-prefixes=DEVICE,CHECK,NVPTX %s
+
+// RUN: %clang_cc1 --std=c++11 -fcuda-is-device -triple amdgcn-amd-amdhsa \
+// RUN:   -emit-llvm -o - %s -DAMDGCN| FileCheck -check-prefixes=DEVICE,CHECK,AMDGCN %s
 
 #include "Inputs/cuda.h"
 
@@ -18,9 +21,17 @@
 
 // Clang should generate a packed LLVM struct for S (denoted by the <>s),
 // otherwise this test isn't interesting.
-// CHECK: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
-
+// HOST: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+// NVPTX: %struct.S = type <{ i32*, i8, %struct.U, [5 x i8] }>
+// ToDo: Fix padding on amdgcn target to be the same as host
+// AMDGCN: %struct.S = type <{ i32 addrspace(4)*, i8, %struct.U, i8 }>
+
+// ToDo: Fix struct padding on amdgcn so that alignof(S) == 8
+#ifdef AMDGCN
+static_assert(alignof(S) == 4, "Unexpected alignment.");
+#else
 static_assert(alignof(S) == 8, "Unexpected alignment.");
+#endif
 
 // HOST-LABEL: @_Z6kernelc1SPi
 // Marshalled kernel args should be:
@@ -32,5 +43,7 @@
 // HOST: call i32 @cudaSetupArgument({{[^,]*}}, i64 8, i64 24)
 
 // DEVICE-LABEL: @_Z6kernelc1SPi
-// DEVICE-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+// NVPTX-SAME: i8{{[^,]*}}, %struct.S* byval align 8{{[^,]*}}, i32*
+// ToDo: Fix amdgcn so that align of struct.S is 8
+// AMDGCN-SAME: i8{{[^,]*}}, %struct.S* byval align 4{{[^,]*}}, i32 addrspace(4)*
 __global__ void kernel(char a, S s, int *b) {}
Index: test/CodeGenCUDA/function-overload.cu
===
--- test/CodeGenCUDA/function-overload.cu
+++ test/CodeGenCUDA/function-overload.cu
@@ -8,6 +8,8 @@
 // RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-HOST %s
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -o - %s \
 // RUN: | FileCheck -check-prefix=CHECK-BO

r296408 - clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Feb 27 16:59:58 2017
New Revision: 296408

URL: http://llvm.org/viewvc/llvm-project?rev=296408&view=rev
Log:
clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, 
reloaded

Second attempt after http://llvm.org/viewvc/llvm-project?rev=296166&view=rev

In the first attempt, Code (the memory buffer backing the input file) was reset
before overwriteChangedFiles() was called, but overwriteChangedFiles() still
reads from it.  This time, load the whole input file into memory instead of
using mmap when formatting in-place.

(Since the test is identical to what was in the repo before chapuni's revert,
svn diff doesn't show it – see the above link for the test.)

https://reviews.llvm.org/D30385

Added:
cfe/trunk/test/Format/inplace.cpp
  - copied unchanged from r296236, cfe/trunk/test/Format/inplace.cpp
Modified:
cfe/trunk/tools/clang-format/ClangFormat.cpp

Modified: cfe/trunk/tools/clang-format/ClangFormat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/ClangFormat.cpp?rev=296408&r1=296407&r2=296408&view=diff
==
--- cfe/trunk/tools/clang-format/ClangFormat.cpp (original)
+++ cfe/trunk/tools/clang-format/ClangFormat.cpp Mon Feb 27 16:59:58 2017
@@ -236,8 +236,15 @@ static void outputReplacementsXML(const
 
 // Returns true on error.
 static bool format(StringRef FileName) {
+  if (!OutputXML && Inplace && FileName == "-") {
+errs() << "error: cannot use -i when reading from stdin.\n";
+return false;
+  }
+  // On Windows, overwriting a file with an open file mapping doesn't work,
+  // so read the whole file into memory when formatting in-place.
   ErrorOr> CodeOrErr =
-  MemoryBuffer::getFileOrSTDIN(FileName);
+  !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
+  MemoryBuffer::getFileOrSTDIN(FileName);
   if (std::error_code EC = CodeOrErr.getError()) {
 errs() << EC.message() << "\n";
 return true;
@@ -297,9 +304,7 @@ static bool format(StringRef FileName) {
 Rewriter Rewrite(Sources, LangOptions());
 tooling::applyAllReplacements(Replaces, Rewrite);
 if (Inplace) {
-  if (FileName == "-")
-errs() << "error: cannot use -i when reading from stdin.\n";
-  else if (Rewrite.overwriteChangedFiles())
+  if (Rewrite.overwriteChangedFiles())
 return true;
 } else {
   if (Cursor.getNumOccurrences() != 0)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30375: Function with unparsed body is a definition

2017-02-27 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

This doesn't look wrong to me, but I feel utterly unqualified to review this.


https://reviews.llvm.org/D30375



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

We should file a bug against the Rewriter interface. It should really take 
MemoryBuffers from the caller and handle this for them.


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30430: Make Lit tests C++11 compatible - IR ordering

2017-02-27 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge created this revision.

This test failure is caused by difference in IR ordering when compiling at 
C++98 vs C++11
Because there was a CHECK-NOT between the two CHECKs, just changing the CHECKs 
to CHECK-DAG would not work.

So to make FileCheck more flexible.
I have changed the CHECK to CHECK-DAG.
I have changed CHECK-NOT to go under a new check-prefix CHECK2 so they are 
CHECK2-NOT.

IR in C++98
@_ZN5test022implicit_instantiationE = global 
%"struct.test0::stdio_sync_filebuf.2" zeroinitializer, align 8
@__dso_handle = external hidden global i8
@_ZN7PR100011xE = global i32 0, align 4
@_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant { [5 x 
i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* 
@_ZTIN5test018stdio_sync_filebufIA3_iEE to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.1"*)* 
@_ZN5test018stdio_sync_filebufIA3_iED1Ev to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.1"*)* 
@_ZN5test018stdio_sync_filebufIA3_iED0Ev to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.1"*)* 
@_ZN5test018stdio_sync_filebufIA3_iE6xsgetnEv to i8*)] }, align 8
@_ZTVN10__cxxabiv120__si_class_type_infoE = external global i8*
@_ZTSN5test018stdio_sync_filebufIA3_iEE = weak_odr constant [35 x i8] 
c"N5test018stdio_sync_filebufIA3_iEE\00"
@_ZTIN5test015basic_streambufE = external constant i8*
@_ZTIN5test018stdio_sync_filebufIA3_iEE = weak_odr constant { i8*, i8*, i8* } { 
i8* bitcast (i8** getelementptr inbounds (i8*, i8** 
@_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr 
inbounds ([35 x i8], [35 x i8]* @_ZTSN5test018stdio_sync_filebufIA3_iEE, i32 0, 
i32 0), i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*) }
@_ZN7PR100011SIiE3arrE = linkonce_odr global [3 x i32] zeroinitializer, align 4
@_ZGVN7PR100011SIiE3arrE = linkonce_odr global i64 0, align 8
@_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant { 
[5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* 
@_ZTIN5test018stdio_sync_filebufIA4_iEE to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.2"*)* 
@_ZN5test018stdio_sync_filebufIA4_iED1Ev to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.2"*)* 
@_ZN5test018stdio_sync_filebufIA4_iED0Ev to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.2"*)* 
@_ZN5test018stdio_sync_filebufIA4_iE6xsgetnEv to i8*)] }, align 8
@_ZTSN5test018stdio_sync_filebufIA4_iEE = linkonce_odr constant [35 x i8] 
c"N5test018stdio_sync_filebufIA4_iEE\00"
@_ZTIN5test018stdio_sync_filebufIA4_iEE = linkonce_odr constant { i8*, i8*, i8* 
} { i8* bitcast (i8** getelementptr inbounds (i8*, i8** 
@_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2) to i8*), i8* getelementptr 
inbounds ([35 x i8], [35 x i8]* @_ZTSN5test018stdio_sync_filebufIA4_iEE, i32 0, 
i32 0), i8* bitcast (i8** @_ZTIN5test015basic_streambufE to i8*) }
@_ZTVN5test015basic_streambufE = available_externally unnamed_addr constant { 
[4 x i8*] } { [4 x i8*] [i8* null, i8* bitcast (i8** 
@_ZTIN5test015basic_streambufE to i8*), i8* bitcast (void 
(%"struct.test0::basic_streambuf"*)* @_ZN5test015basic_streambufD1Ev to i8*), 
i8* bitcast (void (%"struct.test0::basic_streambuf"*)* 
@_ZN5test015basic_streambufD0Ev to i8*)] }, align 8
@_ZTVN5test21CIiEE = available_externally unnamed_addr constant { [4 x i8*] } { 
[4 x i8*] [i8* null, i8* bitcast (i8** @_ZTIN5test21CIiEE to i8*), i8* bitcast 
(void (%"class.test2::C"*)* @_ZN5test21CIiED1Ev to i8*), i8* bitcast (void 
(%"class.test2::C"*)* @_ZN5test21CIiED0Ev to i8*)] }, align 8
@_ZTIN5test21CIiEE = external constant i8*
@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void 
()*, i8* } { i32 65535, void ()* @__cxx_global_var_init.2, i8* null }, { i32, 
void ()*, i8* } { i32 65535, void ()* 
@_GLOBAL__sub_I_template_instantiation.cpp, i8* null }]

IR in C++11
@_ZTVN5test018stdio_sync_filebufIA4_iEE = linkonce_odr unnamed_addr constant { 
[5 x i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* 
@_ZTIN5test018stdio_sync_filebufIA4_iEE to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.2"*)* 
@_ZN5test018stdio_sync_filebufIA4_iED1Ev to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.2"*)* 
@_ZN5test018stdio_sync_filebufIA4_iED0Ev to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.2"*)* 
@_ZN5test018stdio_sync_filebufIA4_iE6xsgetnEv to i8*)] }, align 8
@_ZN5test022implicit_instantiationE = global { i8** } { i8** getelementptr 
inbounds ({ [5 x i8*] }, { [5 x i8*] }* 
@_ZTVN5test018stdio_sync_filebufIA4_iEE, i32 0, inrange i32 0, i32 2) }, align 8
@__dso_handle = external hidden global i8
@_ZN7PR100011xE = global i32 0, align 4
@_ZTVN5test018stdio_sync_filebufIA3_iEE = weak_odr unnamed_addr constant { [5 x 
i8*] } { [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8*, i8* }* 
@_ZTIN5test018stdio_sync_filebufIA3_iEE to i8*), i8* bitcast (void 
(%"struct.test0::stdio_sync_filebuf.1"*)* 
@_ZN5test018

[PATCH] D29901: Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen

2017-02-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 89931.
dblaikie added a comment.

- Simplify ModuleFile lookup
- Build ModularCodegenDecls list from the same place the modular codegen bit is 
set on the decl
- Cleanup no-longer-needed changes to DeclMustBeEmitted/isRequiredDecl


https://reviews.llvm.org/D29901

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/ExternalASTSource.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Serialization/ASTReader.h
  lib/AST/ASTContext.cpp
  lib/AST/ExternalASTSource.cpp
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/codegen/foo.h
  test/Modules/Inputs/codegen/use.cpp
  test/Modules/codegen.test

Index: test/Modules/codegen.test
===
--- test/Modules/codegen.test
+++ test/Modules/codegen.test
@@ -3,8 +3,23 @@
 
 RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
 
-RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
 
-CHECK: $_Z2f1PKcz = comdat any
-CHECK: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
-CHECK:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+FOO: $_Z2f1PKcz = comdat any
+FOO: $_ZN13implicit_dtorD1Ev = comdat any
+USE: $_Z4instIiEvv = comdat any
+FOO: $_ZN13implicit_dtorD2Ev = comdat any
+FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
+FOO:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+
+Test that implicit special members (like this dtor) are emitted into both module (if they're used there) and user.
+FIXME: Proactively instantiate any valid implicit special members to emit them into the module object.
+
+FOO: define weak_odr void @_ZN13implicit_dtorD1Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+FOO: define weak_odr void @_Z4instIfEvv() #0 comdat {
+FOO: define weak_odr void @_ZN13implicit_dtorD2Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+USE: define linkonce_odr void @_Z4instIiEvv() #0 comdat {
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
Index: test/Modules/Inputs/codegen/use.cpp
===
--- /dev/null
+++ test/Modules/Inputs/codegen/use.cpp
@@ -0,0 +1,8 @@
+#include "foo.h"
+void non_modular_use_of_implicit_dtor() {
+  implicit_dtor d1;
+  uninst_implicit_dtor d2;
+}
+void use_of_instantiated_declaration_without_definition() {
+  inst();
+}
Index: test/Modules/Inputs/codegen/foo.h
===
--- test/Modules/Inputs/codegen/foo.h
+++ test/Modules/Inputs/codegen/foo.h
@@ -2,3 +2,29 @@
   __builtin_va_list args;
   __builtin_va_start(args, fmt);
 }
+
+struct non_trivial_dtor {
+  ~non_trivial_dtor();
+};
+
+struct implicit_dtor {
+  non_trivial_dtor d;
+};
+
+struct uninst_implicit_dtor {
+  non_trivial_dtor d;
+};
+
+inline void use_implicit_dtor() {
+  implicit_dtor d;
+}
+
+template
+void inst() {
+}
+
+inline void inst_decl() {
+  // cause inst's declaration to be instantiated, without a definition.
+  (void)sizeof(&inst);
+  inst();
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -2158,7 +2158,7 @@
 /// relatively painless since they would presumably only do it for top-level
 /// decls.
 static bool isRequiredDecl(const Decl *D, ASTContext &Context,
-   bool WritingModule, bool ModularCode) {
+   bool WritingModule) {
   // An ObjCMethodDecl is never considered as "required" because its
   // implementation container always is.
 
@@ -2174,7 +2174,7 @@
 return false;
   }
 
-  return Context.DeclMustBeEmitted(D, ModularCode);
+  return Context.DeclMustBeEmitted(D);
 }
 
 void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
@@ -2218,18 +2218,20 @@
 
   // Note declarations that should be deserialized eagerly so that we can add
   // them to a record in the AST file later.
-  if (isRequiredDecl(D, Context, WritingModule, false))
+  if (isRequiredDecl(D, Context, WritingModule))
 EagerlyDeserializedDecls.push_back(ID);
-  else if (Context.getLangOpts().ModularCodegen && WritingModule &&
- 

[clang-tools-extra] r296390 - [clangd] Make clangd install to bin

2017-02-27 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb 27 15:40:35 2017
New Revision: 296390

URL: http://llvm.org/viewvc/llvm-project?rev=296390&view=rev
Log:
[clangd] Make clangd install to bin

This allows the install target to also install clangd to bin, so that
it can be deployed and used outside the build tree.

Patch by Marc-Andre Laperle!
Differential Revision: https://reviews.llvm.org/D30425

Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=296390&r1=296389&r2=296390&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Feb 27 15:40:35 2017
@@ -6,6 +6,8 @@ add_clang_executable(clangd
   ProtocolHandlers.cpp
   )
 
+install(TARGETS clangd RUNTIME DESTINATION bin)
+
 target_link_libraries(clangd
   clangBasic
   clangFormat


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30210: [include-fixer] Add usage count to find-all-symbols.

2017-02-27 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

lg




Comment at: include-fixer/SymbolIndexManager.cpp:156
+  for (const auto &SymAndSig : MatchedSymbols)
+Res.push_back(SymAndSig.Symbol);
+  return Res;

std::move



Comment at: include-fixer/find-all-symbols/FindAllMacros.cpp:67
+  FileSymbols);
+  FileSymbols = {};
 }

Call me oldschool, but I still prefer `FileSymbols.clear()`


https://reviews.llvm.org/D30210



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296388 - PR32042: Create inlined debug info for EmitInlinedInheritingCXXConstructorCall.

2017-02-27 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Feb 27 15:30:05 2017
New Revision: 296388

URL: http://llvm.org/viewvc/llvm-project?rev=296388&view=rev
Log:
PR32042: Create inlined debug info for EmitInlinedInheritingCXXConstructorCall.

When clang emits an inheriting C++ constructor it may inline code
during the CodeGen phase. This patch ensures that any debug info in
this inlined code gets a proper inlined location. Otherwise we can end
up with invalid debug info metadata, since all inlined local variables
and function arguments would be reparented into the call site.

Analogous to ApplyInlineLocation this patch introduces a
ApplyInlineDebugLocation scoped helper to facilitate entering an
inlined scope and cleaning up afterwards.

This fixes one of the issues discovered in PR32042.

rdar://problem/30679307

Added:
cfe/trunk/test/CodeGenCXX/debug-info-inheriting-constructor.cpp
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=296388&r1=296387&r2=296388&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Feb 27 15:30:05 2017
@@ -2128,7 +2128,9 @@ void CodeGenFunction::EmitInheritedCXXCo
 void CodeGenFunction::EmitInlinedInheritingCXXConstructorCall(
 const CXXConstructorDecl *Ctor, CXXCtorType CtorType, bool ForVirtualBase,
 bool Delegating, CallArgList &Args) {
-  InlinedInheritingConstructorScope Scope(*this, GlobalDecl(Ctor, CtorType));
+  GlobalDecl GD(Ctor, CtorType);
+  InlinedInheritingConstructorScope Scope(*this, GD);
+  ApplyInlineDebugLocation DebugScope(*this, GD);
 
   // Save the arguments to be passed to the inherited constructor.
   CXXInheritedCtorInitExprArgs = Args;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=296388&r1=296387&r2=296388&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Feb 27 15:30:05 2017
@@ -107,8 +107,8 @@ void ApplyDebugLocation::init(SourceLoca
 
   // Construct a location that has a valid scope, but no line info.
   assert(!DI->LexicalBlockStack.empty());
-  CGF->Builder.SetCurrentDebugLocation(
-  llvm::DebugLoc::get(0, 0, DI->LexicalBlockStack.back()));
+  CGF->Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(
+  0, 0, DI->LexicalBlockStack.back(), DI->getInlinedAt()));
 }
 
 ApplyDebugLocation::ApplyDebugLocation(CodeGenFunction &CGF, const Expr *E)
@@ -134,6 +134,30 @@ ApplyDebugLocation::~ApplyDebugLocation(
 CGF->Builder.SetCurrentDebugLocation(std::move(OriginalLocation));
 }
 
+ApplyInlineDebugLocation::ApplyInlineDebugLocation(CodeGenFunction &CGF,
+   GlobalDecl InlinedFn)
+: CGF(&CGF) {
+  if (!CGF.getDebugInfo()) {
+this->CGF = nullptr;
+return;
+  }
+  auto &DI = *CGF.getDebugInfo();
+  SavedLocation = DI.getLocation();
+  assert((DI.getInlinedAt() ==
+  CGF.Builder.getCurrentDebugLocation()->getInlinedAt()) &&
+ "CGDebugInfo and IRBuilder are out of sync");
+
+  DI.EmitInlineFunctionStart(CGF.Builder, InlinedFn);
+}
+
+ApplyInlineDebugLocation::~ApplyInlineDebugLocation() {
+  if (!CGF)
+return;
+  auto &DI = *CGF->getDebugInfo();
+  DI.EmitInlineFunctionEnd(CGF->Builder);
+  DI.EmitLocation(CGF->Builder, SavedLocation);
+}
+
 void CGDebugInfo::setLocation(SourceLocation Loc) {
   // If the new location isn't valid return.
   if (Loc.isInvalid())
@@ -2871,28 +2895,40 @@ void CGDebugInfo::collectVarDeclProps(co
  VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
 }
 
-llvm::DISubprogram *
-CGDebugInfo::getFunctionForwardDeclaration(const FunctionDecl *FD) {
+llvm::DISubprogram *CGDebugInfo::getFunctionFwdDeclOrStub(GlobalDecl GD,
+  bool Stub) {
   llvm::DINodeArray TParamsArray;
   StringRef Name, LinkageName;
   llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
-  SourceLocation Loc = FD->getLocation();
+  SourceLocation Loc = GD.getDecl()->getLocation();
   llvm::DIFile *Unit = getOrCreateFile(Loc);
   llvm::DIScope *DContext = Unit;
   unsigned Line = getLineNumber(Loc);
-
-  collectFunctionDeclProps(FD, Unit, Name, LinkageName, DContext,
+  collectFunctionDeclProps(GD, Unit, Name, LinkageName, DContext,
TParamsArray, Flags);
+  auto *FD = dyn_cast(GD.getDecl());
+
   // Build function type.
   SmallVector ArgTypes;
-  for (const ParmVarDecl *Parm: FD->parameters())
-ArgTypes.push_back(Parm->getType());
+  if (FD)
+for (const ParmVarDecl *Parm : FD->parameters())
+  ArgTypes.push_back(Parm->getType());
   

[PATCH] D27455: UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.

2017-02-27 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

296387.


https://reviews.llvm.org/D27455



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296387 - UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.

2017-02-27 Thread Nico Weber via cfe-commits
Author: nico
Date: Mon Feb 27 15:27:07 2017
New Revision: 296387

URL: http://llvm.org/viewvc/llvm-project?rev=296387&view=rev
Log:
UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does 
not catch UB.

https://reviews.llvm.org/D27455

Modified:
cfe/trunk/docs/UndefinedBehaviorSanitizer.rst

Modified: cfe/trunk/docs/UndefinedBehaviorSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UndefinedBehaviorSanitizer.rst?rev=296387&r1=296386&r2=296387&view=diff
==
--- cfe/trunk/docs/UndefinedBehaviorSanitizer.rst (original)
+++ cfe/trunk/docs/UndefinedBehaviorSanitizer.rst Mon Feb 27 15:27:07 2017
@@ -117,7 +117,9 @@ Available checks are:
   -  ``-fsanitize=unreachable``: If control flow reaches
  ``__builtin_unreachable``.
   -  ``-fsanitize=unsigned-integer-overflow``: Unsigned integer
- overflows.
+ overflows. Note that unlike signed integer overflow, unsigned integer
+ is not undefined behavior. However, while it has well-defined semantics,
+ it is often unintentional, so UBSan offers to catch it.
   -  ``-fsanitize=vla-bound``: A variable-length array whose bound
  does not evaluate to a positive value.
   -  ``-fsanitize=vptr``: Use of an object whose vptr indicates that


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30378: [DebugInfo] [DWARFv5] Collect calling convention info for C++ types during codegen

2017-02-27 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:955-957
+// DWARFv5 doesn't specify explicit DW_CC_* value for this case,
+// thus we just return 'normal' here.
+return llvm::dwarf::DW_CC_normal;

dblaikie wrote:
> Could you file a bug/feature request with the DWARF committee? & maybe we 
> could/should use an implementation defined extension value here? (assuming 
> the DW_CC set has an implementation defined space - which I really hope it 
> does)
Plenty:
DW_CC_lo_user   0x40
DW_CC_hi_user   0xff


https://reviews.llvm.org/D30378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296386 - Remove unused variable

2017-02-27 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Feb 27 15:14:42 2017
New Revision: 296386

URL: http://llvm.org/viewvc/llvm-project?rev=296386&view=rev
Log:
Remove unused variable

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=296386&r1=296385&r2=296386&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Feb 27 15:14:42 2017
@@ -715,8 +715,6 @@ private:
   /// the consumer eagerly.
   SmallVector EagerlyDeserializedDecls;
 
-  SmallVector ModularCodegenDecls;
-
   /// \brief The IDs of all tentative definitions stored in the chain.
   ///
   /// Sema keeps track of all tentative definitions in a TU because it has to


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30415: Fix -mno-altivec cannot overwrite -maltivec option

2017-02-27 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: lib/Driver/Tools.cpp:5436
+
 Args.AddLastArg(CmdArgs, options::OPT_fzvector);
   }

If -fno-zvector has the same problem we should fix it as well.


https://reviews.llvm.org/D30415



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r295417 - Work around Clang assertion when testing C++17 deduction guides with '-g'.

2017-02-27 Thread Steven Wu via cfe-commits
For those watch the bots, Eric upgrade the bots with the new compiler and I 
remove the XFAIL in r296385.

Thanks

Steven

> On Feb 23, 2017, at 11:48 AM, Steven Wu via cfe-commits 
>  wrote:
> 
> Hi Eric
> 
> Looks like the issue is fixed in r295794? Now green dragon is failing due to 
> XPASS.
> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/3018/testReport/
> 
> Can we remove that XFAILs in these two files?
> std/strings/basic_string/string_cons.implicit_deduction_guides.pass.cpp
> std/strings/string_view/string_view_cons.implicit_deduction_guides.pass.cpp
> 
> Thanks
> 
> Steven
> 
>> On Feb 16, 2017, at 9:04 PM, Eric Fiselier via cfe-commits 
>>  wrote:
>> 
>> Author: ericwf
>> Date: Thu Feb 16 23:04:09 2017
>> New Revision: 295417
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=295417&view=rev
>> Log:
>> Work around Clang assertion when testing C++17  deduction guides with '-g'.
>> 
>> Modified:
>>   
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>> 
>> Modified: 
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp?rev=295417&r1=295416&r2=295417&view=diff
>> ==
>> --- 
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>>  (original)
>> +++ 
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>>  Thu Feb 16 23:04:09 2017
>> @@ -10,6 +10,10 @@
>> // UNSUPPORTED: c++98, c++03, c++11, c++14
>> // UNSUPPORTED: libcpp-no-deduction-guides
>> 
>> +// FIXME(EricWF): As of 16/Feb/2017 Clang hits an assertion when compiling 
>> this
>> +// test with '-g' (as the sanitizers do).
>> +// XFAIL: ubsan, asan, msan, tsan
>> +
>> // 
>> 
>> // Test that the constructors offered by std::basic_string are formulated
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: lib/Rewrite/Rewriter.cpp:455
   I->second.write(File.getStream());
+  prewrite(I->first);
 }

amccarth wrote:
> I'm not familiar with the structure of this code, but it seems odd to me that 
> the callback is called `prewrite` when it happens _after_ the write.
obsolete now, but while it's true that it's called after the write to the temp 
file, it's called before the temp file is moved to the final location -- and 
for the client code of this function, the temp file is an implementation detail 
it doesn't know about, so it's really called before "the" write.


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r296385 - Remove XFAIL in implicit_deduction_guides tests

2017-02-27 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Mon Feb 27 15:10:41 2017
New Revision: 296385

URL: http://llvm.org/viewvc/llvm-project?rev=296385&view=rev
Log:
Remove XFAIL in implicit_deduction_guides tests

The clang assertion causing these tests failing with sanitizer is fixed
in r295794. All the bots running libcxx tests should be upgraded and
running the compiler with the fix.

Modified:

libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp

libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp?rev=296385&r1=296384&r2=296385&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
 Mon Feb 27 15:10:41 2017
@@ -10,10 +10,6 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-deduction-guides
 
-// FIXME(EricWF): As of 16/Feb/2017 Clang hits an assertion when compiling this
-// test with '-g' (as the sanitizers do).
-// XFAIL: ubsan, asan, msan, tsan
-
 // 
 
 // Test that the constructors offered by std::basic_string are formulated

Modified: 
libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp?rev=296385&r1=296384&r2=296385&view=diff
==
--- 
libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/string.view/string.view.cons/implicit_deduction_guides.pass.cpp
 Mon Feb 27 15:10:41 2017
@@ -10,10 +10,6 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: libcpp-no-deduction-guides
 
-// FIXME(EricWF): As of 16/Feb/2017 Clang hits an assertion when compiling this
-// test with '-g' (as the sanitizers do).
-// XFAIL: ubsan, asan, msan, tsan
-
 // 
 
 // Test that the constructors offered by std::basic_string_view are formulated


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 89923.
thakis edited the summary of this revision.
thakis added a comment.

Here's a simpler fix, suggested by rnk.


https://reviews.llvm.org/D30385

Files:
  tools/clang-format/ClangFormat.cpp


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -236,8 +236,15 @@
 
 // Returns true on error.
 static bool format(StringRef FileName) {
+  if (!OutputXML && Inplace && FileName == "-") {
+errs() << "error: cannot use -i when reading from stdin.\n";
+return false;
+  }
+  // On Windows, overwriting a file with an open file mapping doesn't work,
+  // so read the whole file into memory when formatting in-place.
   ErrorOr> CodeOrErr =
-  MemoryBuffer::getFileOrSTDIN(FileName);
+  !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
+  MemoryBuffer::getFileOrSTDIN(FileName);
   if (std::error_code EC = CodeOrErr.getError()) {
 errs() << EC.message() << "\n";
 return true;
@@ -297,9 +304,7 @@
 Rewriter Rewrite(Sources, LangOptions());
 tooling::applyAllReplacements(Replaces, Rewrite);
 if (Inplace) {
-  if (FileName == "-")
-errs() << "error: cannot use -i when reading from stdin.\n";
-  else if (Rewrite.overwriteChangedFiles())
+  if (Rewrite.overwriteChangedFiles())
 return true;
 } else {
   if (Cursor.getNumOccurrences() != 0)


Index: tools/clang-format/ClangFormat.cpp
===
--- tools/clang-format/ClangFormat.cpp
+++ tools/clang-format/ClangFormat.cpp
@@ -236,8 +236,15 @@
 
 // Returns true on error.
 static bool format(StringRef FileName) {
+  if (!OutputXML && Inplace && FileName == "-") {
+errs() << "error: cannot use -i when reading from stdin.\n";
+return false;
+  }
+  // On Windows, overwriting a file with an open file mapping doesn't work,
+  // so read the whole file into memory when formatting in-place.
   ErrorOr> CodeOrErr =
-  MemoryBuffer::getFileOrSTDIN(FileName);
+  !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) :
+  MemoryBuffer::getFileOrSTDIN(FileName);
   if (std::error_code EC = CodeOrErr.getError()) {
 errs() << EC.message() << "\n";
 return true;
@@ -297,9 +304,7 @@
 Rewriter Rewrite(Sources, LangOptions());
 tooling::applyAllReplacements(Replaces, Rewrite);
 if (Inplace) {
-  if (FileName == "-")
-errs() << "error: cannot use -i when reading from stdin.\n";
-  else if (Rewrite.overwriteChangedFiles())
+  if (Rewrite.overwriteChangedFiles())
 return true;
 } else {
   if (Cursor.getNumOccurrences() != 0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28266: Transparent_union attribute should be possible in front of union (rework)

2017-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Some minor nits, but I think this is generally correct.




Comment at: include/clang/Sema/Sema.h:3059
   void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
+  // Helper for delayed proccessing TransparentUnion attribute.
+  void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList);

I would remove the mention of TransparentUnion -- this is generalized for other 
uses already.



Comment at: lib/Parse/ParseDeclCXX.cpp:1889
+  if (!TagOrTempResult.isInvalid())
+// Delayed proccessing TransparentUnion attribute.
+Actions.ProcessDeclAttributeDelayed(TagOrTempResult.get(), 
attrs.getList());

I'd remove mention of TransparentUnion here as well.



Comment at: lib/Sema/SemaDecl.cpp:13499
+  if (Attr)
+ProcessDeclAttributeList(S, New, Attr);
+

erichkeane wrote:
> I wasn't sure if this was the correct change in here.  My other option was to 
> move the above 2 lines (13495/13496) above these line's original spot, but 
> moving it here seems to have correctly passed all tests.  Anyone with more 
> knowledge here want to chime in?
I think this change is reasonable.



Comment at: lib/Sema/SemaDeclAttr.cpp:6201
+void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) 
{
+  for (const AttributeList* l = AttrList; l; l = l->getNext())
+if (l->getKind() == AttributeList::AT_TransparentUnion) {

Nit: the `*` should bind to `l` and `l` should be `L` by our usual naming 
conventions (but a name better than `L` wouldn't be amiss).


https://reviews.llvm.org/D28266



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added inline comments.



Comment at: lib/Rewrite/Rewriter.cpp:455
   I->second.write(File.getStream());
+  prewrite(I->first);
 }

I'm not familiar with the structure of this code, but it seems odd to me that 
the callback is called `prewrite` when it happens _after_ the write.


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r296374 - [ubsan] Factor out logic to emit a range check. NFC.

2017-02-27 Thread Dmitry Vyukov via cfe-commits
Ivan, you are listed as admin of
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf
Please issue a clobber for it.

If it does not help, the bot runs the following script:
https://github.com/llvm-mirror/zorg/blob/master/zorg/buildbot/builders/sanitizers/buildbot_standard.sh
It builds clang with clang, but the first clang is just a normal
clang, it's not build tsan or anything as far as I see.


On Mon, Feb 27, 2017 at 10:00 PM, Vedant Kumar  wrote:
> Hm, still can't reproduce this with a normal stage2-RA build of 
> clang+compiler_rt.
>
> And it looks like the next build on the job has the same issue:
>
>   
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5468/steps/annotate/logs/stdio
>
> Do you think there could be stale build products on the machine? Could we try 
> to run a 'make clean' in the top-level build dir?
>
> vedant
>
>> On Feb 27, 2017, at 12:51 PM, Dmitry Vyukov  wrote:
>>
>> Does not seem to be related to tsan. It's just that somebody called a
>> directory with compiler tsan_release_build, but that seems to be the
>> only relation to tsan. Otherwise looks like a violated assertion in
>> clang.
>>
>>
>> On Mon, Feb 27, 2017 at 9:46 PM, Ivan Krasin  wrote:
>>> Hi Vedant,
>>>
>>> not on top of my head. Dmitriy, can you please take a look?
>>>
>>> krasin
>>>
>>> On Mon, Feb 27, 2017 at 12:43 PM, Vedant Kumar  wrote:

 Hi Ivan,

 I saw a bot failure on your job after this commit:


 http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/tsan%20analyze/logs/stdio

 http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/build%20release%20tsan%20with%20clang/logs/stdio

 However, I cannot reproduce it locally with a stage2 TSAN build.

 After staring at my diff I couldn't find anything that would explain the
 failure. No other bots seem upset.

 Do you have any idea about what's going on? Let me know if you want me to
 revert...

 vedant

> On Feb 27, 2017, at 11:46 AM, Vedant Kumar via cfe-commits
>  wrote:
>
> Author: vedantk
> Date: Mon Feb 27 13:46:19 2017
> New Revision: 296374
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296374&view=rev
> Log:
> [ubsan] Factor out logic to emit a range check. NFC.
>
> This is a readability improvement, but it will also help prep an
> upcoming patch to detect UB loads from bitfields.
>
> Modified:
>   cfe/trunk/lib/CodeGen/CGExpr.cpp
>   cfe/trunk/lib/CodeGen/CodeGenFunction.h
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=296374&r1=296373&r2=296374&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 27 13:46:19 2017
> @@ -1301,6 +1301,46 @@ llvm::MDNode *CodeGenFunction::getRangeF
>  return MDHelper.createRange(Min, End);
> }
>
> +bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType
> Ty,
> +   SourceLocation Loc) {
> +  bool HasBoolCheck = SanOpts.has(SanitizerKind::Bool);
> +  bool HasEnumCheck = SanOpts.has(SanitizerKind::Enum);
> +  if (!HasBoolCheck && !HasEnumCheck)
> +return false;
> +
> +  bool IsBool = hasBooleanRepresentation(Ty) ||
> +NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
> +  bool NeedsBoolCheck = HasBoolCheck && IsBool;
> +  bool NeedsEnumCheck = HasEnumCheck && Ty->getAs();
> +  if (!NeedsBoolCheck && !NeedsEnumCheck)
> +return false;
> +
> +  llvm::APInt Min, End;
> +  if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true,
> IsBool))
> +return true;
> +
> +  SanitizerScope SanScope(this);
> +  llvm::Value *Check;
> +  --End;
> +  if (!Min) {
> +Check = Builder.CreateICmpULE(
> +Value, llvm::ConstantInt::get(getLLVMContext(), End));
> +  } else {
> +llvm::Value *Upper = Builder.CreateICmpSLE(
> +Value, llvm::ConstantInt::get(getLLVMContext(), End));
> +llvm::Value *Lower = Builder.CreateICmpSGE(
> +Value, llvm::ConstantInt::get(getLLVMContext(), Min));
> +Check = Builder.CreateAnd(Upper, Lower);
> +  }
> +  llvm::Constant *StaticArgs[] = {EmitCheckSourceLocation(Loc),
> +  EmitCheckTypeDescriptor(Ty)};
> +  SanitizerMask Kind =
> +  NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
> +  EmitCheck(std::make_pair(Check, Kind),
> SanitizerHandler::LoadInvalidValue,
> +StaticArgs, EmitCheckValue(Value));
> +  return true;
> +}
> +
> llvm::Value *CodeGenFunction::EmitLoad

Re: r296374 - [ubsan] Factor out logic to emit a range check. NFC.

2017-02-27 Thread Vedant Kumar via cfe-commits
Hm, still can't reproduce this with a normal stage2-RA build of 
clang+compiler_rt.

And it looks like the next build on the job has the same issue:

  
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5468/steps/annotate/logs/stdio

Do you think there could be stale build products on the machine? Could we try 
to run a 'make clean' in the top-level build dir?

vedant

> On Feb 27, 2017, at 12:51 PM, Dmitry Vyukov  wrote:
> 
> Does not seem to be related to tsan. It's just that somebody called a
> directory with compiler tsan_release_build, but that seems to be the
> only relation to tsan. Otherwise looks like a violated assertion in
> clang.
> 
> 
> On Mon, Feb 27, 2017 at 9:46 PM, Ivan Krasin  wrote:
>> Hi Vedant,
>> 
>> not on top of my head. Dmitriy, can you please take a look?
>> 
>> krasin
>> 
>> On Mon, Feb 27, 2017 at 12:43 PM, Vedant Kumar  wrote:
>>> 
>>> Hi Ivan,
>>> 
>>> I saw a bot failure on your job after this commit:
>>> 
>>> 
>>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/tsan%20analyze/logs/stdio
>>> 
>>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/build%20release%20tsan%20with%20clang/logs/stdio
>>> 
>>> However, I cannot reproduce it locally with a stage2 TSAN build.
>>> 
>>> After staring at my diff I couldn't find anything that would explain the
>>> failure. No other bots seem upset.
>>> 
>>> Do you have any idea about what's going on? Let me know if you want me to
>>> revert...
>>> 
>>> vedant
>>> 
 On Feb 27, 2017, at 11:46 AM, Vedant Kumar via cfe-commits
  wrote:
 
 Author: vedantk
 Date: Mon Feb 27 13:46:19 2017
 New Revision: 296374
 
 URL: http://llvm.org/viewvc/llvm-project?rev=296374&view=rev
 Log:
 [ubsan] Factor out logic to emit a range check. NFC.
 
 This is a readability improvement, but it will also help prep an
 upcoming patch to detect UB loads from bitfields.
 
 Modified:
   cfe/trunk/lib/CodeGen/CGExpr.cpp
   cfe/trunk/lib/CodeGen/CodeGenFunction.h
 
 Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=296374&r1=296373&r2=296374&view=diff
 
 ==
 --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 27 13:46:19 2017
 @@ -1301,6 +1301,46 @@ llvm::MDNode *CodeGenFunction::getRangeF
  return MDHelper.createRange(Min, End);
 }
 
 +bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType
 Ty,
 +   SourceLocation Loc) {
 +  bool HasBoolCheck = SanOpts.has(SanitizerKind::Bool);
 +  bool HasEnumCheck = SanOpts.has(SanitizerKind::Enum);
 +  if (!HasBoolCheck && !HasEnumCheck)
 +return false;
 +
 +  bool IsBool = hasBooleanRepresentation(Ty) ||
 +NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
 +  bool NeedsBoolCheck = HasBoolCheck && IsBool;
 +  bool NeedsEnumCheck = HasEnumCheck && Ty->getAs();
 +  if (!NeedsBoolCheck && !NeedsEnumCheck)
 +return false;
 +
 +  llvm::APInt Min, End;
 +  if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true,
 IsBool))
 +return true;
 +
 +  SanitizerScope SanScope(this);
 +  llvm::Value *Check;
 +  --End;
 +  if (!Min) {
 +Check = Builder.CreateICmpULE(
 +Value, llvm::ConstantInt::get(getLLVMContext(), End));
 +  } else {
 +llvm::Value *Upper = Builder.CreateICmpSLE(
 +Value, llvm::ConstantInt::get(getLLVMContext(), End));
 +llvm::Value *Lower = Builder.CreateICmpSGE(
 +Value, llvm::ConstantInt::get(getLLVMContext(), Min));
 +Check = Builder.CreateAnd(Upper, Lower);
 +  }
 +  llvm::Constant *StaticArgs[] = {EmitCheckSourceLocation(Loc),
 +  EmitCheckTypeDescriptor(Ty)};
 +  SanitizerMask Kind =
 +  NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
 +  EmitCheck(std::make_pair(Check, Kind),
 SanitizerHandler::LoadInvalidValue,
 +StaticArgs, EmitCheckValue(Value));
 +  return true;
 +}
 +
 llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool
 Volatile,
   QualType Ty,
   SourceLocation Loc,
 @@ -1353,35 +1393,9 @@ llvm::Value *CodeGenFunction::EmitLoadOf
  false /*ConvertTypeToTag*/);
  }
 
 -  bool IsBool = hasBooleanRepresentation(Ty) ||
 -NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
 -  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
 -  bool NeedsEnumCheck =
 -  SanOpts

Re: r296374 - [ubsan] Factor out logic to emit a range check. NFC.

2017-02-27 Thread Dmitry Vyukov via cfe-commits
Does not seem to be related to tsan. It's just that somebody called a
directory with compiler tsan_release_build, but that seems to be the
only relation to tsan. Otherwise looks like a violated assertion in
clang.


On Mon, Feb 27, 2017 at 9:46 PM, Ivan Krasin  wrote:
> Hi Vedant,
>
> not on top of my head. Dmitriy, can you please take a look?
>
> krasin
>
> On Mon, Feb 27, 2017 at 12:43 PM, Vedant Kumar  wrote:
>>
>> Hi Ivan,
>>
>> I saw a bot failure on your job after this commit:
>>
>>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/tsan%20analyze/logs/stdio
>>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/build%20release%20tsan%20with%20clang/logs/stdio
>>
>> However, I cannot reproduce it locally with a stage2 TSAN build.
>>
>> After staring at my diff I couldn't find anything that would explain the
>> failure. No other bots seem upset.
>>
>> Do you have any idea about what's going on? Let me know if you want me to
>> revert...
>>
>> vedant
>>
>> > On Feb 27, 2017, at 11:46 AM, Vedant Kumar via cfe-commits
>> >  wrote:
>> >
>> > Author: vedantk
>> > Date: Mon Feb 27 13:46:19 2017
>> > New Revision: 296374
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=296374&view=rev
>> > Log:
>> > [ubsan] Factor out logic to emit a range check. NFC.
>> >
>> > This is a readability improvement, but it will also help prep an
>> > upcoming patch to detect UB loads from bitfields.
>> >
>> > Modified:
>> >cfe/trunk/lib/CodeGen/CGExpr.cpp
>> >cfe/trunk/lib/CodeGen/CodeGenFunction.h
>> >
>> > Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=296374&r1=296373&r2=296374&view=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
>> > +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 27 13:46:19 2017
>> > @@ -1301,6 +1301,46 @@ llvm::MDNode *CodeGenFunction::getRangeF
>> >   return MDHelper.createRange(Min, End);
>> > }
>> >
>> > +bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType
>> > Ty,
>> > +   SourceLocation Loc) {
>> > +  bool HasBoolCheck = SanOpts.has(SanitizerKind::Bool);
>> > +  bool HasEnumCheck = SanOpts.has(SanitizerKind::Enum);
>> > +  if (!HasBoolCheck && !HasEnumCheck)
>> > +return false;
>> > +
>> > +  bool IsBool = hasBooleanRepresentation(Ty) ||
>> > +NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
>> > +  bool NeedsBoolCheck = HasBoolCheck && IsBool;
>> > +  bool NeedsEnumCheck = HasEnumCheck && Ty->getAs();
>> > +  if (!NeedsBoolCheck && !NeedsEnumCheck)
>> > +return false;
>> > +
>> > +  llvm::APInt Min, End;
>> > +  if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true,
>> > IsBool))
>> > +return true;
>> > +
>> > +  SanitizerScope SanScope(this);
>> > +  llvm::Value *Check;
>> > +  --End;
>> > +  if (!Min) {
>> > +Check = Builder.CreateICmpULE(
>> > +Value, llvm::ConstantInt::get(getLLVMContext(), End));
>> > +  } else {
>> > +llvm::Value *Upper = Builder.CreateICmpSLE(
>> > +Value, llvm::ConstantInt::get(getLLVMContext(), End));
>> > +llvm::Value *Lower = Builder.CreateICmpSGE(
>> > +Value, llvm::ConstantInt::get(getLLVMContext(), Min));
>> > +Check = Builder.CreateAnd(Upper, Lower);
>> > +  }
>> > +  llvm::Constant *StaticArgs[] = {EmitCheckSourceLocation(Loc),
>> > +  EmitCheckTypeDescriptor(Ty)};
>> > +  SanitizerMask Kind =
>> > +  NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
>> > +  EmitCheck(std::make_pair(Check, Kind),
>> > SanitizerHandler::LoadInvalidValue,
>> > +StaticArgs, EmitCheckValue(Value));
>> > +  return true;
>> > +}
>> > +
>> > llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool
>> > Volatile,
>> >QualType Ty,
>> >SourceLocation Loc,
>> > @@ -1353,35 +1393,9 @@ llvm::Value *CodeGenFunction::EmitLoadOf
>> >   false /*ConvertTypeToTag*/);
>> >   }
>> >
>> > -  bool IsBool = hasBooleanRepresentation(Ty) ||
>> > -NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
>> > -  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
>> > -  bool NeedsEnumCheck =
>> > -  SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
>> > -  if (NeedsBoolCheck || NeedsEnumCheck) {
>> > -SanitizerScope SanScope(this);
>> > -llvm::APInt Min, End;
>> > -if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true,
>> > IsBool)) {
>> > -  --End;
>> > -  llvm::Value *Check;
>> > -  if (!Min)
>> > -Check = Builder.CreateICmpULE(
>> > -  Load, llvm::ConstantInt::get(getLLVMContext(), End));
>> > -  else {
>> > -llvm::Value *Upper = Builder.Create

[PATCH] D30192: [Sema] Detecting more array index out of bounds

2017-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

A few minor nits that can be resolved when you commit, but aside from those, 
LGTM.




Comment at: lib/Sema/SemaChecking.cpp:10613
+  case Stmt::CXXOperatorCallExprClass: {
+const CXXOperatorCallExpr *OCE = cast(expr);
+for (auto Arg : OCE->arguments())

You can use `const auto *` here.



Comment at: lib/Sema/SemaChecking.cpp:10614
+const CXXOperatorCallExpr *OCE = cast(expr);
+for (auto Arg : OCE->arguments())
+  CheckArrayAccess(Arg);

`const auto *` instead of just `auto`.


Repository:
  rL LLVM

https://reviews.llvm.org/D30192



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r296374 - [ubsan] Factor out logic to emit a range check. NFC.

2017-02-27 Thread Ivan Krasin via cfe-commits
Hi Vedant,

not on top of my head. Dmitriy, can you please take a look?

krasin

On Mon, Feb 27, 2017 at 12:43 PM, Vedant Kumar  wrote:

> Hi Ivan,
>
> I saw a bot failure on your job after this commit:
>
>   http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-autoconf/builds/5467/steps/tsan%20analyze/logs/stdio
>   http://lab.llvm.org:8011/builders/sanitizer-x86_64-
> linux-autoconf/builds/5467/steps/build%20release%20tsan%
> 20with%20clang/logs/stdio
>
> However, I cannot reproduce it locally with a stage2 TSAN build.
>
> After staring at my diff I couldn't find anything that would explain the
> failure. No other bots seem upset.
>
> Do you have any idea about what's going on? Let me know if you want me to
> revert...
>
> vedant
>
> > On Feb 27, 2017, at 11:46 AM, Vedant Kumar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: vedantk
> > Date: Mon Feb 27 13:46:19 2017
> > New Revision: 296374
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=296374&view=rev
> > Log:
> > [ubsan] Factor out logic to emit a range check. NFC.
> >
> > This is a readability improvement, but it will also help prep an
> > upcoming patch to detect UB loads from bitfields.
> >
> > Modified:
> >cfe/trunk/lib/CodeGen/CGExpr.cpp
> >cfe/trunk/lib/CodeGen/CodeGenFunction.h
> >
> > Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=296374&r1=296373&r2=296374&view=diff
> > 
> ==
> > --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 27 13:46:19 2017
> > @@ -1301,6 +1301,46 @@ llvm::MDNode *CodeGenFunction::getRangeF
> >   return MDHelper.createRange(Min, End);
> > }
> >
> > +bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value,
> QualType Ty,
> > +   SourceLocation Loc) {
> > +  bool HasBoolCheck = SanOpts.has(SanitizerKind::Bool);
> > +  bool HasEnumCheck = SanOpts.has(SanitizerKind::Enum);
> > +  if (!HasBoolCheck && !HasEnumCheck)
> > +return false;
> > +
> > +  bool IsBool = hasBooleanRepresentation(Ty) ||
> > +NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
> > +  bool NeedsBoolCheck = HasBoolCheck && IsBool;
> > +  bool NeedsEnumCheck = HasEnumCheck && Ty->getAs();
> > +  if (!NeedsBoolCheck && !NeedsEnumCheck)
> > +return false;
> > +
> > +  llvm::APInt Min, End;
> > +  if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true,
> IsBool))
> > +return true;
> > +
> > +  SanitizerScope SanScope(this);
> > +  llvm::Value *Check;
> > +  --End;
> > +  if (!Min) {
> > +Check = Builder.CreateICmpULE(
> > +Value, llvm::ConstantInt::get(getLLVMContext(), End));
> > +  } else {
> > +llvm::Value *Upper = Builder.CreateICmpSLE(
> > +Value, llvm::ConstantInt::get(getLLVMContext(), End));
> > +llvm::Value *Lower = Builder.CreateICmpSGE(
> > +Value, llvm::ConstantInt::get(getLLVMContext(), Min));
> > +Check = Builder.CreateAnd(Upper, Lower);
> > +  }
> > +  llvm::Constant *StaticArgs[] = {EmitCheckSourceLocation(Loc),
> > +  EmitCheckTypeDescriptor(Ty)};
> > +  SanitizerMask Kind =
> > +  NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
> > +  EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::
> LoadInvalidValue,
> > +StaticArgs, EmitCheckValue(Value));
> > +  return true;
> > +}
> > +
> > llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool
> Volatile,
> >QualType Ty,
> >SourceLocation Loc,
> > @@ -1353,35 +1393,9 @@ llvm::Value *CodeGenFunction::EmitLoadOf
> >   false /*ConvertTypeToTag*/);
> >   }
> >
> > -  bool IsBool = hasBooleanRepresentation(Ty) ||
> > -NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
> > -  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
> > -  bool NeedsEnumCheck =
> > -  SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
> > -  if (NeedsBoolCheck || NeedsEnumCheck) {
> > -SanitizerScope SanScope(this);
> > -llvm::APInt Min, End;
> > -if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true,
> IsBool)) {
> > -  --End;
> > -  llvm::Value *Check;
> > -  if (!Min)
> > -Check = Builder.CreateICmpULE(
> > -  Load, llvm::ConstantInt::get(getLLVMContext(), End));
> > -  else {
> > -llvm::Value *Upper = Builder.CreateICmpSLE(
> > -  Load, llvm::ConstantInt::get(getLLVMContext(), End));
> > -llvm::Value *Lower = Builder.CreateICmpSGE(
> > -  Load, llvm::ConstantInt::get(getLLVMContext(), Min));
> > -Check = Builder.CreateAnd(Upper, Lower);
> > -  }
> > -  llvm::Constant *StaticArgs[] = {
> > -EmitCheckSourceLocation(Loc),
> > -Em

Re: r296374 - [ubsan] Factor out logic to emit a range check. NFC.

2017-02-27 Thread Vedant Kumar via cfe-commits
Hi Ivan,

I saw a bot failure on your job after this commit:

  
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/tsan%20analyze/logs/stdio
  
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/5467/steps/build%20release%20tsan%20with%20clang/logs/stdio

However, I cannot reproduce it locally with a stage2 TSAN build.

After staring at my diff I couldn't find anything that would explain the 
failure. No other bots seem upset.

Do you have any idea about what's going on? Let me know if you want me to 
revert...

vedant

> On Feb 27, 2017, at 11:46 AM, Vedant Kumar via cfe-commits 
>  wrote:
> 
> Author: vedantk
> Date: Mon Feb 27 13:46:19 2017
> New Revision: 296374
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=296374&view=rev
> Log:
> [ubsan] Factor out logic to emit a range check. NFC.
> 
> This is a readability improvement, but it will also help prep an
> upcoming patch to detect UB loads from bitfields.
> 
> Modified:
>cfe/trunk/lib/CodeGen/CGExpr.cpp
>cfe/trunk/lib/CodeGen/CodeGenFunction.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=296374&r1=296373&r2=296374&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 27 13:46:19 2017
> @@ -1301,6 +1301,46 @@ llvm::MDNode *CodeGenFunction::getRangeF
>   return MDHelper.createRange(Min, End);
> }
> 
> +bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
> +   SourceLocation Loc) {
> +  bool HasBoolCheck = SanOpts.has(SanitizerKind::Bool);
> +  bool HasEnumCheck = SanOpts.has(SanitizerKind::Enum);
> +  if (!HasBoolCheck && !HasEnumCheck)
> +return false;
> +
> +  bool IsBool = hasBooleanRepresentation(Ty) ||
> +NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
> +  bool NeedsBoolCheck = HasBoolCheck && IsBool;
> +  bool NeedsEnumCheck = HasEnumCheck && Ty->getAs();
> +  if (!NeedsBoolCheck && !NeedsEnumCheck)
> +return false;
> +
> +  llvm::APInt Min, End;
> +  if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool))
> +return true;
> +
> +  SanitizerScope SanScope(this);
> +  llvm::Value *Check;
> +  --End;
> +  if (!Min) {
> +Check = Builder.CreateICmpULE(
> +Value, llvm::ConstantInt::get(getLLVMContext(), End));
> +  } else {
> +llvm::Value *Upper = Builder.CreateICmpSLE(
> +Value, llvm::ConstantInt::get(getLLVMContext(), End));
> +llvm::Value *Lower = Builder.CreateICmpSGE(
> +Value, llvm::ConstantInt::get(getLLVMContext(), Min));
> +Check = Builder.CreateAnd(Upper, Lower);
> +  }
> +  llvm::Constant *StaticArgs[] = {EmitCheckSourceLocation(Loc),
> +  EmitCheckTypeDescriptor(Ty)};
> +  SanitizerMask Kind =
> +  NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
> +  EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::LoadInvalidValue,
> +StaticArgs, EmitCheckValue(Value));
> +  return true;
> +}
> +
> llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
>QualType Ty,
>SourceLocation Loc,
> @@ -1353,35 +1393,9 @@ llvm::Value *CodeGenFunction::EmitLoadOf
>   false /*ConvertTypeToTag*/);
>   }
> 
> -  bool IsBool = hasBooleanRepresentation(Ty) ||
> -NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
> -  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
> -  bool NeedsEnumCheck =
> -  SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
> -  if (NeedsBoolCheck || NeedsEnumCheck) {
> -SanitizerScope SanScope(this);
> -llvm::APInt Min, End;
> -if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool)) {
> -  --End;
> -  llvm::Value *Check;
> -  if (!Min)
> -Check = Builder.CreateICmpULE(
> -  Load, llvm::ConstantInt::get(getLLVMContext(), End));
> -  else {
> -llvm::Value *Upper = Builder.CreateICmpSLE(
> -  Load, llvm::ConstantInt::get(getLLVMContext(), End));
> -llvm::Value *Lower = Builder.CreateICmpSGE(
> -  Load, llvm::ConstantInt::get(getLLVMContext(), Min));
> -Check = Builder.CreateAnd(Upper, Lower);
> -  }
> -  llvm::Constant *StaticArgs[] = {
> -EmitCheckSourceLocation(Loc),
> -EmitCheckTypeDescriptor(Ty)
> -  };
> -  SanitizerMask Kind = NeedsEnumCheck ? SanitizerKind::Enum : 
> SanitizerKind::Bool;
> -  EmitCheck(std::make_pair(Check, Kind), 
> SanitizerHandler::LoadInvalidValue,
> -StaticArgs, EmitCheckValue(Load));
> -}
> +  if (EmitScalarRangeCheck(Load, Ty, Loc)) {
> +// In order to prevent the optimizer from throwing away the ch

[PATCH] D30158: [clang-tidy] modernize: Find usage of random_shuffle and replace it with shuffle.

2017-02-27 Thread Mads Ravn via Phabricator via cfe-commits
madsravn updated this revision to Diff 89919.
madsravn added a comment.

Minor update to fix spelling mistake.


https://reviews.llvm.org/D30158

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tidy/modernize/ReplaceRandomShuffleCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-replace-random-shuffle.rst
  test/clang-tidy/modernize-replace-random-shuffle.cpp

Index: test/clang-tidy/modernize-replace-random-shuffle.cpp
===
--- test/clang-tidy/modernize-replace-random-shuffle.cpp
+++ test/clang-tidy/modernize-replace-random-shuffle.cpp
@@ -0,0 +1,58 @@
+// RUN: %check_clang_tidy %s modernize-replace-random-shuffle %t -- -- -std=c++11
+
+//CHECK-FIXES: #include 
+
+namespace std {
+template  struct vec_iterator {
+  T *ptr;
+  vec_iterator operator++(int);
+};
+
+template  struct vector {
+  typedef vec_iterator iterator;
+
+  iterator begin();
+  iterator end();
+};
+
+template 
+void random_shuffle(FwIt begin, FwIt end);
+
+template 
+void random_shuffle(FwIt begin, FwIt end, randomFunc& randomfunc);
+
+template 
+void shuffle(FwIt begin, FwIt end);
+} // namespace std
+
+// Random Func
+int myrandom (int i) { return i;}
+
+using namespace std;
+
+int main() {
+  std::vector vec;
+
+  std::random_shuffle(vec.begin(), vec.end());
+  // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'
+  // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
+
+
+  std::shuffle(vec.begin(), vec.end());
+
+  random_shuffle(vec.begin(), vec.end());
+  // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'
+  // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
+  
+  std::random_shuffle(vec.begin(), vec.end(), myrandom);
+  // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'. The old user defined 'RandomFunction' is not usable for shuffle. You need to make additional changes if you want a specific random function
+  // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
+
+  random_shuffle(vec.begin(), vec.end(), myrandom);
+  // CHECK-MESSAGE: [[@LINE-1]]:3: warning: do not use 'random_shuffle'. It is deprecated and replaced by 'shuffle'. The old user defined 'RandomFunction' is not usable for shuffle. You need to make additional changes if you want a specific random function
+  // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
+
+  shuffle(vec.begin(), vec.end());
+
+  return 0;
+}
Index: docs/clang-tidy/checks/modernize-replace-random-shuffle.rst
===
--- docs/clang-tidy/checks/modernize-replace-random-shuffle.rst
+++ docs/clang-tidy/checks/modernize-replace-random-shuffle.rst
@@ -0,0 +1,28 @@
+.. title:: clang-tidy - modernize-replace-random-shuffle
+
+modernize-replace-random-shuffle
+
+
+This check will find occurrences of ``std::random_shuffle`` and replace it with ``std::shuffle``. In C++17 ``std::random_shuffle`` will no longer be available and thus we need to replace it.
+
+Below is two examples of what kind of occurrences will be found and two examples of what it will be replaced with.
+
+.. code-block:: c++
+
+  std::vector v;
+
+  // First example
+  std::random_shuffle(vec.begin(), vec.end());
+
+  // Second example
+  std::random_shuffle(vec.begin(), vec.end(), randomFun);
+
+Both these examples will be replaced with
+
+.. code-block:: c++
+
+  std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
+
+The second example will also receive a warning that ``randomFunc`` is no longer supported in the same way as before so if the user wants the same functionality, the user will need to change the implementation of the ``randomFunc``.
+
+One thing to be aware of here is that ``std::random_device`` is quite expensive to initialize. So if you are using the code in a performance critical place, you probably want to initialize it elsewhere. 
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -110,6 +110,7 @@
modernize-raw-string-literal
modernize-redundant-void-arg
modernize-replace-auto-ptr
+   modernize-replace-random-shuffle
modernize-return-braced-init-list
modernize-shrink-to-fit
modernize-use-auto
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -72,6 +72,11 @@
 
   Finds uses of inline assembler.
 
+- New `moder

[PATCH] D30427: Fix whitespace before token-paste of an argument.

2017-02-27 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.

The whitespace should come from the argument name in the macro
expansion, rather than from the token passed to the macro (same as it
does when not pasting).

Added a new test case for the change in behavior to stringize_space.c.

FileCheck'ized macro_paste_commaext.c, tweaked the test case, and
added a comment; no behavioral change to this test.


https://reviews.llvm.org/D30427

Files:
  lib/Lex/TokenLexer.cpp
  test/Preprocessor/macro_paste_commaext.c
  test/Preprocessor/stringize_space.c

Index: test/Preprocessor/stringize_space.c
===
--- test/Preprocessor/stringize_space.c
+++ test/Preprocessor/stringize_space.c
@@ -18,3 +18,14 @@
 1)
 
 // CHECK: {{^}}"-1"
+
+#define paste(a,b) str(a ".foo" not ". foo".
 if (i != 0 && !Tokens[i-1].is(tok::hashhash) && CurTok.hasLeadingSpace())
   NextTokGetsSpace = true;
 
@@ -317,14 +323,16 @@
 const Token *ArgToks = ActualArgs->getUnexpArgument(ArgNo);
 unsigned NumToks = MacroArgs::getArgLength(ArgToks);
 if (NumToks) {  // Not an empty argument?
+  bool VaArgsPseudoPaste = false;
   // If this is the GNU ", ## __VA_ARGS__" extension, and we just learned
   // that __VA_ARGS__ expands to multiple tokens, avoid a pasting error when
   // the expander trys to paste ',' with the first token of the __VA_ARGS__
   // expansion.
   if (NonEmptyPasteBefore && ResultToks.size() >= 2 &&
   ResultToks[ResultToks.size()-2].is(tok::comma) &&
   (unsigned)ArgNo == Macro->getNumArgs()-1 &&
   Macro->isVariadic()) {
+VaArgsPseudoPaste = true;
 // Remove the paste operator, report use of the extension.
 PP.Diag(ResultToks.pop_back_val().getLocation(), diag::ext_paste_comma);
   }
@@ -344,18 +352,16 @@
ResultToks.end()-NumToks, ResultToks.end());
   }
 
-  // If this token (the macro argument) was supposed to get leading
-  // whitespace, transfer this information onto the first token of the
-  // expansion.
-  //
-  // Do not do this if the paste operator occurs before the macro argument,
-  // as in "A ## MACROARG".  In valid code, the first token will get
-  // smooshed onto the preceding one anyway (forming AMACROARG).  In
-  // assembler-with-cpp mode, invalid pastes are allowed through: in this
-  // case, we do not want the extra whitespace to be added.  For example,
-  // we want ". ## foo" -> ".foo" not ". foo".
-  if (NextTokGetsSpace)
-ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace);
+  // Transfer the leading whitespace information from the token
+  // (the macro argument) onto the first token of the
+  // expansion. Note that we don't do this for the GNU
+  // pseudo-paste extension ", ## __VA_ARGS__".
+  if (!VaArgsPseudoPaste) {
+ResultToks[ResultToks.size()-NumToks].setFlagValue(Token::StartOfLine,
+   false);
+ResultToks[ResultToks.size()-NumToks].setFlagValue(Token::LeadingSpace,
+   NextTokGetsSpace);
+  }
 
   NextTokGetsSpace = false;
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-02-27 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich added a comment.

Here's an example 3 file report from the Linux source: 
https://cdn.rawgit.com/vlad902/73bd32181151f2f0b07fa501a0f0b627/raw/0106f09cdb0d045b757de3d71ddc58072d33/report2.html

It's not as immediately clear this is a multi-file output. Ideas to improve 
this could include anchor tags in the header for every file included, or 
augmenting the line count to something like '$FILE:$LINE' instead. I'm open to 
suggestions on this front.


https://reviews.llvm.org/D30406



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296374 - [ubsan] Factor out logic to emit a range check. NFC.

2017-02-27 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Feb 27 13:46:19 2017
New Revision: 296374

URL: http://llvm.org/viewvc/llvm-project?rev=296374&view=rev
Log:
[ubsan] Factor out logic to emit a range check. NFC.

This is a readability improvement, but it will also help prep an
upcoming patch to detect UB loads from bitfields.

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=296374&r1=296373&r2=296374&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Feb 27 13:46:19 2017
@@ -1301,6 +1301,46 @@ llvm::MDNode *CodeGenFunction::getRangeF
   return MDHelper.createRange(Min, End);
 }
 
+bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
+   SourceLocation Loc) {
+  bool HasBoolCheck = SanOpts.has(SanitizerKind::Bool);
+  bool HasEnumCheck = SanOpts.has(SanitizerKind::Enum);
+  if (!HasBoolCheck && !HasEnumCheck)
+return false;
+
+  bool IsBool = hasBooleanRepresentation(Ty) ||
+NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
+  bool NeedsBoolCheck = HasBoolCheck && IsBool;
+  bool NeedsEnumCheck = HasEnumCheck && Ty->getAs();
+  if (!NeedsBoolCheck && !NeedsEnumCheck)
+return false;
+
+  llvm::APInt Min, End;
+  if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool))
+return true;
+
+  SanitizerScope SanScope(this);
+  llvm::Value *Check;
+  --End;
+  if (!Min) {
+Check = Builder.CreateICmpULE(
+Value, llvm::ConstantInt::get(getLLVMContext(), End));
+  } else {
+llvm::Value *Upper = Builder.CreateICmpSLE(
+Value, llvm::ConstantInt::get(getLLVMContext(), End));
+llvm::Value *Lower = Builder.CreateICmpSGE(
+Value, llvm::ConstantInt::get(getLLVMContext(), Min));
+Check = Builder.CreateAnd(Upper, Lower);
+  }
+  llvm::Constant *StaticArgs[] = {EmitCheckSourceLocation(Loc),
+  EmitCheckTypeDescriptor(Ty)};
+  SanitizerMask Kind =
+  NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
+  EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::LoadInvalidValue,
+StaticArgs, EmitCheckValue(Value));
+  return true;
+}
+
 llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
QualType Ty,
SourceLocation Loc,
@@ -1353,35 +1393,9 @@ llvm::Value *CodeGenFunction::EmitLoadOf
   false /*ConvertTypeToTag*/);
   }
 
-  bool IsBool = hasBooleanRepresentation(Ty) ||
-NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
-  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
-  bool NeedsEnumCheck =
-  SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
-  if (NeedsBoolCheck || NeedsEnumCheck) {
-SanitizerScope SanScope(this);
-llvm::APInt Min, End;
-if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool)) {
-  --End;
-  llvm::Value *Check;
-  if (!Min)
-Check = Builder.CreateICmpULE(
-  Load, llvm::ConstantInt::get(getLLVMContext(), End));
-  else {
-llvm::Value *Upper = Builder.CreateICmpSLE(
-  Load, llvm::ConstantInt::get(getLLVMContext(), End));
-llvm::Value *Lower = Builder.CreateICmpSGE(
-  Load, llvm::ConstantInt::get(getLLVMContext(), Min));
-Check = Builder.CreateAnd(Upper, Lower);
-  }
-  llvm::Constant *StaticArgs[] = {
-EmitCheckSourceLocation(Loc),
-EmitCheckTypeDescriptor(Ty)
-  };
-  SanitizerMask Kind = NeedsEnumCheck ? SanitizerKind::Enum : 
SanitizerKind::Bool;
-  EmitCheck(std::make_pair(Check, Kind), 
SanitizerHandler::LoadInvalidValue,
-StaticArgs, EmitCheckValue(Load));
-}
+  if (EmitScalarRangeCheck(Load, Ty, Loc)) {
+// In order to prevent the optimizer from throwing away the check, don't
+// attach range metadata to the load.
   } else if (CGM.getCodeGenOpts().OptimizationLevel > 0)
 if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
   Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=296374&r1=296373&r2=296374&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Feb 27 13:46:19 2017
@@ -2866,6 +2866,13 @@ public:
   /// representation to its value representation.
   llvm::Value *EmitFromMemory(llvm::Value *Value, QualType Ty);
 
+  /// Check if the scalar \p Value is within the valid range for the given
+  /// type 

[PATCH] D30423: [ubsan] Detect UB loads from bitfields

2017-02-27 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

We frequently run into user bugs caused by UB loads of out-of-range values from 
enum / BOOL bitfields. Teach UBSan to diagnose the issue.


https://reviews.llvm.org/D30423

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/ubsan-bitfields.cpp
  test/CodeGenObjC/ubsan-bool.m

Index: test/CodeGenObjC/ubsan-bool.m
===
--- test/CodeGenObjC/ubsan-bool.m
+++ test/CodeGenObjC/ubsan-bool.m
@@ -10,4 +10,22 @@
   // C-NOT: call void @__ubsan_handle_load_invalid_value
   BOOL a = 2;
   return a + 1;
+  // SHARED: ret i8
+}
+
+struct S1 {
+  BOOL b1 : 1;
+};
+
+// SHARED-LABEL: f2
+BOOL f2(struct S1 *s) {
+  // OBJC:  [[LOAD:%.*]] = load i8, i8* {{.*}}
+  // OBJC:  [[SHL:%.*]] = shl i8 [[LOAD]], 7
+  // OBJC:  [[ASHR:%.*]] = ashr i8 [[SHL]], 7
+  // OBJC:  [[ICMP:%.*]] = icmp ule i8 [[ASHR]], 1, !nosanitize
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+
+  // C-NOT: call void @__ubsan_handle_load_invalid_value
+  return s->b1;
+  // SHARED: ret i8
 }
Index: test/CodeGenCXX/ubsan-bitfields.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-bitfields.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=enum | FileCheck %s
+
+enum E {
+  a = 1,
+  b = 2,
+  c = 3
+};
+
+struct S {
+  E e1 : 10;
+};
+
+// CHECK-LABEL: define i32 @_Z4loadP1S
+E load(S *s) {
+  // CHECK: [[LOAD:%.*]] = load i16, i16* {{.*}}
+  // CHECK: [[CLEAR:%.*]] = and i16 [[LOAD]], 1023
+  // CHECK: [[CAST:%.*]] = zext i16 [[CLEAR]] to i32
+  // CHECK: [[ICMP:%.*]] = icmp ule i32 [[CAST]], 3, !nosanitize
+  // CHECK: br i1 [[ICMP]], {{.*}}, !nosanitize
+  // CHECK: call void @__ubsan_handle_load_invalid_value
+  return s->e1;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2913,7 +2913,7 @@
   /// rvalue, returning the rvalue.
   RValue EmitLoadOfLValue(LValue V, SourceLocation Loc);
   RValue EmitLoadOfExtVectorElementLValue(LValue V);
-  RValue EmitLoadOfBitfieldLValue(LValue LV);
+  RValue EmitLoadOfBitfieldLValue(LValue LV, SourceLocation Loc);
   RValue EmitLoadOfGlobalRegLValue(LValue LV);
 
   /// EmitStoreThroughLValue - Store the specified rvalue into the specified
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1540,10 +1540,11 @@
 return EmitLoadOfGlobalRegLValue(LV);
 
   assert(LV.isBitField() && "Unknown LValue type!");
-  return EmitLoadOfBitfieldLValue(LV);
+  return EmitLoadOfBitfieldLValue(LV, Loc);
 }
 
-RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV) {
+RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV,
+ SourceLocation Loc) {
   const CGBitFieldInfo &Info = LV.getBitFieldInfo();
 
   // Get the output type.
@@ -1568,7 +1569,7 @@
   "bf.clear");
   }
   Val = Builder.CreateIntCast(Val, ResLTy, Info.IsSigned, "bf.cast");
-
+  EmitScalarRangeCheck(Val, LV.getType(), Loc);
   return RValue::get(Val);
 }
 
Index: lib/CodeGen/CGAtomic.cpp
===
--- lib/CodeGen/CGAtomic.cpp
+++ lib/CodeGen/CGAtomic.cpp
@@ -1181,7 +1181,7 @@
   if (LVal.isBitField())
 return CGF.EmitLoadOfBitfieldLValue(
 LValue::MakeBitfield(addr, LVal.getBitFieldInfo(), LVal.getType(),
- LVal.getAlignmentSource()));
+ LVal.getAlignmentSource()), loc);
   if (LVal.isVectorElt())
 return CGF.EmitLoadOfLValue(
 LValue::MakeVectorElt(addr, LVal.getVectorIdx(), LVal.getType(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30239: enable -flto=thin in clang-cl

2017-02-27 Thread Bob Haarman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296373: enable -flto=thin in clang-cl (authored by 
inglorion).

Changed prior to commit:
  https://reviews.llvm.org/D30239?vs=89598&id=89913#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30239

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cl-options.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -957,7 +957,7 @@
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;
-def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group,
+def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -133,6 +133,7 @@
 "invalid output type '%0' for use with gcc tool">;
 def err_drv_cc_print_options_failure : Error<
 "unable to open CC_PRINT_OPTIONS file: %0">;
+def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
 def err_drv_conflicting_deployment_targets : Error<
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -522,6 +522,15 @@
 
 // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
 
+// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
+// LTO: -flto
+
+// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck 
-check-prefix=LTO-THIN %s
+// LTO-THIN: -flto=thin
+
+// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck 
-check-prefix=LTO-WITHOUT-LLD %s
+// LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2353,8 +2353,12 @@
   Arg *FinalPhaseArg;
   phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg);
 
-  if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) {
-Diag(clang::diag::err_drv_emit_llvm_link);
+  if (FinalPhase == phases::Link) {
+if (Args.hasArg(options::OPT_emit_llvm))
+  Diag(clang::diag::err_drv_emit_llvm_link);
+if (IsCLMode() && LTOMode != LTOK_None &&
+!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld"))
+  Diag(clang::diag::err_drv_lto_without_lld);
   }
 
   // Reject -Z* at the top level, these options should never have been exposed


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -957,7 +957,7 @@
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group;
-def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group,
+def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -133,6 +133,7 @@
 "invalid output type '%0' for use with gcc tool">;
 def err_drv_cc_print_options_failure : Error<
 "unable to open CC_PRINT_OPTIONS file: %0">;
+def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
 def err_drv_conflicting_deployment_targets : Error<
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Dr

[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

2017-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaLambda.cpp:1458
+
+  return false;
+}

I think this is missing one more case: capturing a `volatile` variable by copy 
does have a side effect in that the variable is read when the capture occurs. 
e.g., this should not diagnose either:
```
void f(volatile int v) {
  [v]{}();
}
```


https://reviews.llvm.org/D30327



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296373 - enable -flto=thin in clang-cl

2017-02-27 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Feb 27 13:40:19 2017
New Revision: 296373

URL: http://llvm.org/viewvc/llvm-project?rev=296373&view=rev
Log:
enable -flto=thin in clang-cl

Summary: This enables LTO to be used with the clang-cl frontend.

Reviewers: rnk, hans

Reviewed By: hans

Subscribers: pcc, cfe-commits, mehdi_amini, Prazek

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Feb 27 13:40:19 
2017
@@ -133,6 +133,7 @@ def err_drv_invalid_gcc_output_type : Er
 "invalid output type '%0' for use with gcc tool">;
 def err_drv_cc_print_options_failure : Error<
 "unable to open CC_PRINT_OPTIONS file: %0">;
+def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
 def err_drv_conflicting_deployment_targets : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 27 13:40:19 2017
@@ -957,7 +957,7 @@ def fxray_instruction_threshold_ :
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;
-def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group,
+def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Feb 27 13:40:19 2017
@@ -2353,8 +2353,12 @@ void Driver::BuildActions(Compilation &C
   Arg *FinalPhaseArg;
   phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg);
 
-  if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) {
-Diag(clang::diag::err_drv_emit_llvm_link);
+  if (FinalPhase == phases::Link) {
+if (Args.hasArg(options::OPT_emit_llvm))
+  Diag(clang::diag::err_drv_emit_llvm_link);
+if (IsCLMode() && LTOMode != LTOK_None &&
+!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld"))
+  Diag(clang::diag::err_drv_lto_without_lld);
   }
 
   // Reject -Z* at the top level, these options should never have been exposed

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Feb 27 13:40:19 2017
@@ -522,6 +522,15 @@
 
 // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
 
+// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
+// LTO: -flto
+
+// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck 
-check-prefix=LTO-THIN %s
+// LTO-THIN: -flto=thin
+
+// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck 
-check-prefix=LTO-WITHOUT-LLD %s
+// LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30378: [DebugInfo] [DWARFv5] Collect calling convention info for C++ types during codegen

2017-02-27 Thread Victor Leschuk via Phabricator via cfe-commits
vleschuk added inline comments.



Comment at: test/CodeGenCXX/debug-info-type-calling-conventions.cpp:11-12
+
+class UserDtor {
+public:
+  ~UserDtor() {}

dblaikie wrote:
> I'd probably make this a struct (and drop the 'public:' section since it'll 
> be the default then) - since it doesn't seem to matter here.
Will do when I fix this bug: 
http://lists.llvm.org/pipermail/llvm-dev/2017-February/110557.html


https://reviews.llvm.org/D30378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27455: UBSan docs: Explicitly mention that `-fsanitize=unsigned-integer-overflow` does not catch UB.

2017-02-27 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

LGTM, fwiw. (IIRC kcc mentioned that samsonov no longer works on the 
sanitizers.)


https://reviews.llvm.org/D27455



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via cfe-commits
Is that a "this patch is good" or a "please rewrite"?

On Mon, Feb 27, 2017 at 1:50 PM, Reid Kleckner via Phabricator <
revi...@reviews.llvm.org> wrote:

> rnk added a comment.
>
> My understanding is that Windows doesn't allow you to delete a file that
> has been opened and mapped into any process, even if it has been opened
> with FILE_SHARE_DELETE. One way to work around this would be to avoid
> memory mapping files in the SourceManager when using the Rewriter. Then
> FILE_SHARE_DELETE will do what you want. There should be a parameter to
> MemoryBuffer::getFile to control this. However, I think it really would be
> cleaner if we unmapped all of our MemoryBuffers of inputs before
> overwriting them in place. Keeping those buffers around feels like having
> dangling references.
>
>
> https://reviews.llvm.org/D30385
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

My understanding is that Windows doesn't allow you to delete a file that has 
been opened and mapped into any process, even if it has been opened with 
FILE_SHARE_DELETE. One way to work around this would be to avoid memory mapping 
files in the SourceManager when using the Rewriter. Then FILE_SHARE_DELETE will 
do what you want. There should be a parameter to MemoryBuffer::getFile to 
control this. However, I think it really would be cleaner if we unmapped all of 
our MemoryBuffers of inputs before overwriting them in place. Keeping those 
buffers around feels like having dangling references.


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r296296 - [X86] DAZ Macros Relocation

2017-02-27 Thread Ben Simhon, Oren via cfe-commits
Hi Craig,

All compilers will be updated accordingly including the documentation.

Thanks,
Oren

From: Craig Topper [mailto:craig.top...@gmail.com]
Sent: Sunday, February 26, 2017 22:57
To: Ben Simhon, Oren 
Cc: cfe-commits 
Subject: Re: r296296 - [X86] DAZ Macros Relocation

Doesn't Intel's own documentation say these are in pmmintrin.h?  gcc has them 
there as well.

https://software.intel.com/en-us/node/683881

~Craig

On Sun, Feb 26, 2017 at 3:58 AM, Oren Ben Simhon via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: orenb
Date: Sun Feb 26 05:58:15 2017
New Revision: 296296

URL: http://llvm.org/viewvc/llvm-project?rev=296296&view=rev
Log:
[X86] DAZ Macros Relocation

The DAZ feature introduces the denormal zero support for x86.
Currently the definitions are located under SSE3 header, however there are some 
SSE2 targets that support the feature as well.

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


Modified:
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/pmmintrin.h

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=296296&r1=296295&r2=296296&view=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Sun Feb 26 05:58:15 2017
@@ -4810,4 +4810,12 @@ void _mm_pause(void);

 #define _MM_SHUFFLE2(x, y) (((x) << 1) | (y))

+#define _MM_DENORMALS_ZERO_ON   (0x0040)
+#define _MM_DENORMALS_ZERO_OFF  (0x)
+
+#define _MM_DENORMALS_ZERO_MASK (0x0040)
+
+#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
+#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & 
~_MM_DENORMALS_ZERO_MASK) | (x)))
+
 #endif /* __EMMINTRIN_H */

Modified: cfe/trunk/lib/Headers/pmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/pmmintrin.h?rev=296296&r1=296295&r2=296296&view=diff
==
--- cfe/trunk/lib/Headers/pmmintrin.h (original)
+++ cfe/trunk/lib/Headers/pmmintrin.h Sun Feb 26 05:58:15 2017
@@ -257,14 +257,6 @@ _mm_movedup_pd(__m128d __a)
   return __builtin_shufflevector((__v2df)__a, (__v2df)__a, 0, 0);
 }

-#define _MM_DENORMALS_ZERO_ON   (0x0040)
-#define _MM_DENORMALS_ZERO_OFF  (0x)
-
-#define _MM_DENORMALS_ZERO_MASK (0x0040)
-
-#define _MM_GET_DENORMALS_ZERO_MODE() (_mm_getcsr() & _MM_DENORMALS_ZERO_MASK)
-#define _MM_SET_DENORMALS_ZERO_MODE(x) (_mm_setcsr((_mm_getcsr() & 
~_MM_DENORMALS_ZERO_MASK) | (x)))
-
 /// \brief Establishes a linear address memory range to be monitored and puts
 ///the processor in the monitor event pending state. Data stored in the
 ///monitored address range causes the processor to exit the pending state.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

-
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30378: [DebugInfo] [DWARFv5] Collect calling convention info for C++ types during codegen

2017-02-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Be best to avoid having to 'fixup' the argabi after the fact - and instead 
build the type with the right argabi from the get-go.




Comment at: lib/CodeGen/CGDebugInfo.cpp:955-957
+// DWARFv5 doesn't specify explicit DW_CC_* value for this case,
+// thus we just return 'normal' here.
+return llvm::dwarf::DW_CC_normal;

Could you file a bug/feature request with the DWARF committee? & maybe we 
could/should use an implementation defined extension value here? (assuming the 
DW_CC set has an implementation defined space - which I really hope it does)



Comment at: test/CodeGenCXX/debug-info-type-calling-conventions.cpp:11-12
+
+class UserDtor {
+public:
+  ~UserDtor() {}

I'd probably make this a struct (and drop the 'public:' section since it'll be 
the default then) - since it doesn't seem to matter here.


https://reviews.llvm.org/D30378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libunwind] r296358 - Add libcxxabi's LICENSE.TXT to libunwind.

2017-02-27 Thread Hans Wennborg via cfe-commits
Merged together with r296359 to 4.0 in r296364.

On Mon, Feb 27, 2017 at 9:33 AM, Arnaud A. de Grandmaison via
cfe-commits  wrote:
> Author: aadg
> Date: Mon Feb 27 11:33:20 2017
> New Revision: 296358
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296358&view=rev
> Log:
> Add libcxxabi's LICENSE.TXT to libunwind.
>
> When libunwind was spinned off libcxxabi, most file were copied from
> libcxxabi to libunwind.  However, libc++abi's toplevel LICENSE.TXT was
> forgotten in the copying. It's considered a good practice to have the
> license file at the root of the project, and making linunwind a separate
> project was not supposed to change its licensing. Besides, several
> header files refer to the LICENSE.TXT, so copy the one from libc++abi.
>
> Added:
> libunwind/trunk/LICENSE.TXT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27627: [WIP] Supporting C++ based kernel languages on AMDGPU Target

2017-02-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 89899.
yaxunl retitled this revision from "[WIP] Specify default address space for C++ 
on AMDGPU Target" to "[WIP] Supporting C++ based kernel languages on AMDGPU 
Target".
yaxunl edited the summary of this revision.
yaxunl added a comment.

Fix invalid bitcast for global variables.
Add run line for amdgcn target for a Cuda lit test.


https://reviews.llvm.org/D27627

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGVTT.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCUDA/function-overload.cu

Index: test/CodeGenCUDA/function-overload.cu
===
--- test/CodeGenCUDA/function-overload.cu
+++ test/CodeGenCUDA/function-overload.cu
@@ -1,13 +1,16 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
+// REQUIRES: amdgcn-registered-target
 
 // Make sure we handle target overloads correctly.  Most of this is checked in
 // sema, but special functions like constructors and destructors are here.
 //
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s \
 // RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-HOST %s
 // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -o - %s \
 // RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-DEVICE %s
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefix=CHECK-BOTH -check-prefix=CHECK-DEVICE %s
 
 #include "Inputs/cuda.h"
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -1108,7 +1108,7 @@
 if (!Record->hasTrivialDestructor()) {
   CXXDestructorDecl *DtorD = Record->getDestructor();
   Dtor = CGM.getAddrOfCXXStructor(DtorD, StructorType::Complete);
-  Dtor = llvm::ConstantExpr::getBitCast(Dtor, CGM.Int8PtrTy);
+  Dtor = llvm::ConstantExpr::getPointerCast(Dtor, CGM.Int8PtrTy);
 }
   }
   if (!Dtor) Dtor = llvm::Constant::getNullValue(CGM.Int8PtrTy);
@@ -2171,7 +2171,7 @@
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
-llvm::ConstantExpr::getBitCast(addr, CGF.Int8PtrTy),
+llvm::ConstantExpr::getPointerCast(addr, CGF.Int8PtrTy),
 handle
   };
   CGF.EmitNounwindRuntimeCall(atexit, args);
@@ -2584,7 +2584,7 @@
 }
   }
 
-  return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
+  return llvm::ConstantExpr::getPointerCast(GV, CGM.Int8PtrTy);
 }
 
 /// TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type
@@ -2913,7 +2913,7 @@
   llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
   VTable =
   llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.Int8PtrTy, VTable, Two);
-  VTable = llvm::ConstantExpr::getBitCast(VTable, CGM.Int8PtrTy);
+  VTable = llvm::ConstantExpr::getPointerCast(VTable, CGM.Int8PtrTy);
 
   Fields.push_back(VTable);
 }
@@ -2986,7 +2986,7 @@
 assert(!OldGV->hasAvailableExternallyLinkage() &&
"available_externally typeinfos not yet implemented");
 
-return llvm::ConstantExpr::getBitCast(OldGV, CGM.Int8PtrTy);
+return llvm::ConstantExpr::getPointerCast(OldGV, CGM.Int8PtrTy);
   }
 
   // Check if there is already an external RTTI descriptor for this type.
@@ -3022,7 +3022,7 @@
 TypeNameField =
 llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.Int8PtrTy);
   } else {
-TypeNameField = llvm::ConstantExpr::getBitCast(TypeName, CGM.Int8PtrTy);
+TypeNameField = llvm::ConstantExpr::getPointerCast(TypeName, CGM.Int8PtrTy);
   }
   Fields.push_back(TypeNameField);
 
@@ -3177,7 +3177,7 @@
 }
   }
 
-  return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
+  return llvm::ConstantExpr::getPointerCast(GV, CGM.Int8PtrTy);
 }
 
 /// BuildObjCObjectTypeInfo - Build the appropriate kind of type_info
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -47,6 +47,7 @@
 #include "llvm/ADT/Triple.h"
 #include "llvm/IR/CallSite.h"
 #include "llvm/IR/CallingConv.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
@@ -90,6 +91,7 @@
   VMContext(M.getContext()), Types(*this), VTables(*this),
   SanitizerMD(new SanitizerMetadata(*this)) {
 
+  unsigned DefaultTargetAddressSpace = Target.getDefaultTargetAddres

[libunwind] r296364 - Merging r296358 and r296359:

2017-02-27 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Feb 27 12:03:07 2017
New Revision: 296364

URL: http://llvm.org/viewvc/llvm-project?rev=296364&view=rev
Log:
Merging r296358 and r296359:

r296358 | aadg | 2017-02-27 09:33:20 -0800 (Mon, 27 Feb 2017) | 8 lines

Add libcxxabi's LICENSE.TXT to libunwind.

When libunwind was spinned off libcxxabi, most file were copied from
libcxxabi to libunwind.  However, libc++abi's toplevel LICENSE.TXT was
forgotten in the copying. It's considered a good practice to have the
license file at the root of the project, and making linunwind a separate
project was not supposed to change its licensing. Besides, several
header files refer to the LICENSE.TXT, so copy the one from libc++abi.



r296359 | aadg | 2017-02-27 09:47:58 -0800 (Mon, 27 Feb 2017) | 1 line

Fix the project name in the license file.


Added:
libunwind/branches/release_40/LICENSE.TXT
  - copied, changed from r296358, libunwind/trunk/LICENSE.TXT
Modified:
libunwind/branches/release_40/   (props changed)

Propchange: libunwind/branches/release_40/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Feb 27 12:03:07 2017
@@ -1 +1 @@
-/libunwind/trunk:292723
+/libunwind/trunk:292723,296358-296359

Copied: libunwind/branches/release_40/LICENSE.TXT (from r296358, 
libunwind/trunk/LICENSE.TXT)
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_40/LICENSE.TXT?p2=libunwind/branches/release_40/LICENSE.TXT&p1=libunwind/trunk/LICENSE.TXT&r1=296358&r2=296364&rev=296364&view=diff
==
--- libunwind/trunk/LICENSE.TXT (original)
+++ libunwind/branches/release_40/LICENSE.TXT Mon Feb 27 12:03:07 2017
@@ -1,8 +1,8 @@
 ==
-libc++abi License
+libunwind License
 ==
 
-The libc++abi library is dual licensed under both the University of Illinois
+The libunwind library is dual licensed under both the University of Illinois
 "BSD-Like" license and the MIT license.  As a user of this code you may choose
 to use it under either license.  As a contributor, you agree to allow your code
 to be used under both.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r296359 - Fix the project name in the license file.

2017-02-27 Thread Arnaud A. de Grandmaison via cfe-commits
Author: aadg
Date: Mon Feb 27 11:47:58 2017
New Revision: 296359

URL: http://llvm.org/viewvc/llvm-project?rev=296359&view=rev
Log:
Fix the project name in the license file.

Modified:
libunwind/trunk/LICENSE.TXT

Modified: libunwind/trunk/LICENSE.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/LICENSE.TXT?rev=296359&r1=296358&r2=296359&view=diff
==
--- libunwind/trunk/LICENSE.TXT (original)
+++ libunwind/trunk/LICENSE.TXT Mon Feb 27 11:47:58 2017
@@ -1,8 +1,8 @@
 ==
-libc++abi License
+libunwind License
 ==
 
-The libc++abi library is dual licensed under both the University of Illinois
+The libunwind library is dual licensed under both the University of Illinois
 "BSD-Like" license and the MIT license.  As a user of this code you may choose
 to use it under either license.  As a contributor, you agree to allow your code
 to be used under both.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r296358 - Add libcxxabi's LICENSE.TXT to libunwind.

2017-02-27 Thread Arnaud A. de Grandmaison via cfe-commits
Author: aadg
Date: Mon Feb 27 11:33:20 2017
New Revision: 296358

URL: http://llvm.org/viewvc/llvm-project?rev=296358&view=rev
Log:
Add libcxxabi's LICENSE.TXT to libunwind.

When libunwind was spinned off libcxxabi, most file were copied from
libcxxabi to libunwind.  However, libc++abi's toplevel LICENSE.TXT was
forgotten in the copying. It's considered a good practice to have the
license file at the root of the project, and making linunwind a separate
project was not supposed to change its licensing. Besides, several
header files refer to the LICENSE.TXT, so copy the one from libc++abi.

Added:
libunwind/trunk/LICENSE.TXT

Added: libunwind/trunk/LICENSE.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/LICENSE.TXT?rev=296358&view=auto
==
--- libunwind/trunk/LICENSE.TXT (added)
+++ libunwind/trunk/LICENSE.TXT Mon Feb 27 11:33:20 2017
@@ -0,0 +1,76 @@
+==
+libc++abi License
+==
+
+The libc++abi library is dual licensed under both the University of Illinois
+"BSD-Like" license and the MIT license.  As a user of this code you may choose
+to use it under either license.  As a contributor, you agree to allow your code
+to be used under both.
+
+Full text of the relevant licenses is included below.
+
+==
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2009-2017 by the contributors listed in CREDITS.TXT
+
+All rights reserved.
+
+Developed by:
+
+LLVM Team
+
+University of Illinois at Urbana-Champaign
+
+http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal with
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+* Redistributions of source code must retain the above copyright notice,
+  this list of conditions and the following disclaimers.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+  this list of conditions and the following disclaimers in the
+  documentation and/or other materials provided with the distribution.
+
+* Neither the names of the LLVM Team, University of Illinois at
+  Urbana-Champaign, nor the names of its contributors may be used to
+  endorse or promote products derived from this Software without specific
+  prior written permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
+SOFTWARE.
+
+==
+
+Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30326: [MS-ABI] Allow #pragma section to choose for ZI data

2017-02-27 Thread Javed Absar via Phabricator via cfe-commits
javed.absar updated this revision to Diff 89897.
javed.absar added a comment.

Hi Roger:
Thanks for the review. I have extended the test and fixed driver flag passing 
that you pointed out.

Regarding the check in Sema::DeclarationIsZeroInitialized, the check if to keep 
the function return value consistent, in case function is called with a 
declaration that is without an initializer.
Best Regards, 
Javed


https://reviews.llvm.org/D30326

Files:
  include/clang/AST/APValue.h
  include/clang/AST/Expr.h
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Sema/Sema.h
  lib/AST/APValue.cpp
  lib/AST/Expr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCXX/zi-sections.cpp
  test/Driver/always-use-bss.c

Index: test/Driver/always-use-bss.c
===
--- /dev/null
+++ test/Driver/always-use-bss.c
@@ -0,0 +1,3 @@
+// RUN: %clang -### -target i686-pc-windows -fms-extensions -falways-use-bss %s 2>&1 | FileCheck %s
+// CHECK: "-falways-use-bss"
+void f() {}
Index: test/CodeGenCXX/zi-sections.cpp
===
--- /dev/null
+++ test/CodeGenCXX/zi-sections.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ZI-DATA
+// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -falways-use-bss -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ZI-BSS
+// Test that when '-falways-use-bss' is specified, variables initialized with zero are assigned to bss_seg.
+#pragma bss_seg(".bss.1")
+#pragma data_seg(".data.1")
+extern "C" {
+short ShortZero = 0;
+short ShortTwo = 2;
+short ShortMinusTwo = -2;
+short ShortUnInit;
+
+int IntZero = 0;
+int IntTwo = 2;
+int IntMinusTwo = -2;
+int IntUnInit;
+
+float FloatZero = 0.0;
+float FloatMinusZero = -0.0;
+float FloatTwo = 2.0;
+float FloatUnInit;
+
+double DoubleZero = 0.0;
+double DoubleMinusZero = -0.0;
+double DoubleTwo = 2.0;
+double DoubleUnInit;
+
+struct S {
+  int x, y;
+  int z;
+};
+struct S StructZero = { 0, 0, 0 };
+struct S StructTwo = { 0, 0, 2};
+struct S StructMinusTwo = {0, -2, 0};
+struct S StructUnInit;
+
+int ArrayZero[] = {0, 0, 0};
+int ArrayTwo[] = {0, 2, 0};
+int ArrayMinusTwo[] = {0, -2, 0};
+int ArrayUnInit;
+
+int ArrayWithFillerZero[10] = { 0 };
+int ArrayWithFillerTwo[10] = { 0, 2 };
+int ArrayWithAllFiller[10] = { };
+
+// CHECK-ZI-DATA: @ShortZero = global i16 0, section ".data.1", align 2
+// CHECK-ZI-BSS: @ShortZero = global i16 0, section ".bss.1", align 2
+// CHECK: @ShortTwo = global i16 2, section ".data.1", align 2
+// CHECK: @ShortMinusTwo = global i16 -2, section ".data.1", align 2
+// CHECK: @ShortUnInit = global i16 0, section ".bss.1", align 2
+//
+// CHECK-ZI-DATA: @IntZero = global i32 0, section ".data.1", align 4
+// CHECK-ZI-BSS: @IntZero = global i32 0, section ".bss.1", align 4
+// CHECK: @IntTwo = global i32 2, section ".data.1", align 4
+// CHECK: @IntMinusTwo = global i32 -2, section ".data.1", align 4
+// CHECK: @IntUnInit = global i32 0, section ".bss.1", align 4
+//
+// CHECK-ZI-DATA: @FloatZero = global float 0.00e+00, section ".data.1", align 4
+// CHECK-ZI-BSS: @FloatZero = global float 0.00e+00, section ".bss.1", align 4
+// CHECK: @FloatMinusZero = global float -0.00e+00, section ".data.1", align 4
+// CHECK: @FloatTwo = global float 2.00e+00, section ".data.1", align 4
+// CHECK: @FloatUnInit = global float 0.00e+00, section ".bss.1", align 4
+//
+// CHECK-ZI-DATA: @DoubleZero = global double 0.00e+00, section ".data.1", align 8
+// CHECK-ZI-BSS: @DoubleZero = global double 0.00e+00, section ".bss.1", align 8
+// CHECK: @DoubleMinusZero = global double -0.00e+00, section ".data.1", align 8
+// CHECK: @DoubleTwo = global double 2.00e+00, section ".data.1", align 8
+// CHECK: @DoubleUnInit = global double 0.00e+00, section ".bss.1", align 8
+//
+// CHECK-ZI-DATA: @StructZero = global %struct.S zeroinitializer, section ".data.1", align 4
+// CHECK-ZI-BSS: @StructZero = global %struct.S zeroinitializer, section ".bss.1", align 4
+// CHECK: @StructTwo = global %struct.S { i32 0, i32 0, i32 2 }, section ".data.1", align 4
+// CHECK: @StructMinusTwo = global %struct.S { i32 0, i32 -2, i32 0 }, section ".data.1", align 4
+// CHECK: @StructUnInit = global %struct.S zeroinitializer, section ".data.1", align 4
+//
+// CHECK-ZI-DATA: @ArrayZero = global [3 x i32] zeroinitializer, section ".data.1", align 4
+// CHECK-ZI-BSS: @ArrayZero = global [3 x i32] zeroinitializer, section ".bss.1", align 4
+// CHECK: @ArrayTwo = global [3 x i32] [i32 0, i32 2, i32 0], section ".data.1", align 4
+// CHECK: @ArrayMinusTwo = global [3 x i32] [i32 0, i32 -2, i32 0], section ".data.1", align 4
+// CHECK: @ArrayUnInit = global i32 0, section ".bss.1", align 4
+//
+// CHECK-ZI-DATA: @Arr

[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-27 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D29221#687425, @hans wrote:

> In https://reviews.llvm.org/D29221#686865, @amaiorano wrote:
>
> > Made changes based on @hans 's feedback.
> >
> > I looked again at the categories, and I think it makes sense with my 
> > changes. Here's an updated screenshot that shows what the options menu in 
> > Visual Studio looks like with these changes with the top-level category 
> > name ("LLVM/Clang") and page name ("Clang Format") highlighted, as well as 
> > the category names for the page items ("Format Options" and "Format On 
> > Save") highlighted:
> >
> > F3117958: pasted_file 
> >
> > It would be nice if "Format On Save" was _below_ "Format Options", but 
> > Visual Studio always orders the page categories in alphabetical order, so 
> > this is pretty standard.
>
>
> The screenshot looks good.
>
> My only nit is that I'd prefer "clang-format" instead of "ClangFormat".
>
> Manuel: the menu options under Tools currently say "Clang Format 
> {Selection,Document}". What do you think about using "clang-format" here 
> instead? That is the name of the tool after all, and I think it also works 
> nicely as a verb.
>
> I realize the actual extension is called ClangFormat, but maybe there were 
> reasons for that, or we have to live with it?


I would also like clang-format in there rather than ClangFormat. One thing to 
validate is whether this change would mean people would lose their changes to 
the defaults in the configuration panel. I'll run some tests and see if this is 
indeed the case. Maybe there's a way to keep the internal name the same for 
config purposes, but change the displayed name instead. Will get back to you.


https://reviews.llvm.org/D29221



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r295417 - Work around Clang assertion when testing C++17 deduction guides with '-g'.

2017-02-27 Thread Steven Wu via cfe-commits
Hi Eric

This has been failing for one week on green dragon. I think all the bots 
running sanitizer should pick up the clang with the fix already if they are 
building from trunk. Should I try remove the XFAIL?

Steven

> On Feb 23, 2017, at 11:48 AM, Steven Wu  wrote:
> 
> Hi Eric
> 
> Looks like the issue is fixed in r295794? Now green dragon is failing due to 
> XPASS.
> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/3018/testReport/
> 
> Can we remove that XFAILs in these two files?
> std/strings/basic_string/string_cons.implicit_deduction_guides.pass.cpp
> std/strings/string_view/string_view_cons.implicit_deduction_guides.pass.cpp
> 
> Thanks
> 
> Steven
> 
>> On Feb 16, 2017, at 9:04 PM, Eric Fiselier via cfe-commits 
>>  wrote:
>> 
>> Author: ericwf
>> Date: Thu Feb 16 23:04:09 2017
>> New Revision: 295417
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=295417&view=rev
>> Log:
>> Work around Clang assertion when testing C++17  deduction guides with '-g'.
>> 
>> Modified:
>>   
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>> 
>> Modified: 
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp?rev=295417&r1=295416&r2=295417&view=diff
>> ==
>> --- 
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>>  (original)
>> +++ 
>> libcxx/trunk/test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
>>  Thu Feb 16 23:04:09 2017
>> @@ -10,6 +10,10 @@
>> // UNSUPPORTED: c++98, c++03, c++11, c++14
>> // UNSUPPORTED: libcpp-no-deduction-guides
>> 
>> +// FIXME(EricWF): As of 16/Feb/2017 Clang hits an assertion when compiling 
>> this
>> +// test with '-g' (as the sanitizers do).
>> +// XFAIL: ubsan, asan, msan, tsan
>> +
>> // 
>> 
>> // Test that the constructors offered by std::basic_string are formulated
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D29221#686865, @amaiorano wrote:

> Made changes based on @hans 's feedback.
>
> I looked again at the categories, and I think it makes sense with my changes. 
> Here's an updated screenshot that shows what the options menu in Visual 
> Studio looks like with these changes with the top-level category name 
> ("LLVM/Clang") and page name ("Clang Format") highlighted, as well as the 
> category names for the page items ("Format Options" and "Format On Save") 
> highlighted:
>
> F3117958: pasted_file 
>
> It would be nice if "Format On Save" was _below_ "Format Options", but Visual 
> Studio always orders the page categories in alphabetical order, so this is 
> pretty standard.


The screenshot looks good.

My only nit is that I'd prefer "clang-format" instead of "ClangFormat".

Manuel: the menu options under Tools currently say "Clang Format 
{Selection,Document}". What do you think about using "clang-format" here 
instead? That is the name of the tool after all, and I think it also works 
nicely as a verb.

I realize the actual extension is called ClangFormat, but maybe there were 
reasons for that, or we have to live with it?


https://reviews.llvm.org/D29221



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30412: [clang-tidy] Fix a false positive on modernize-use-nullptr check.

2017-02-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: JDevlieghere.

The false positive happens on two neighbour CXXDefaultArgExpr AST nodes.
like below:

CXXFunctionalCastExpr 0x85c9670  'struct ZZ' functional cast to 
struct ZZ 
 `-CXXConstructExpr 0x85c9518  'struct ZZ' 'void (uint64, const 
uint64 *)'

| -CallExpr 0x85a0a90  'uint64':'unsigned long long'   |
|  
| -ImplicitCastExpr 0x85a0a78  'uint64 (*)(uint64)' 
|
|  
| `-DeclRefExpr 0x85a09f0  'uint64 (uint64)' lvalue Function 0x85a06a0 
'Hash' 'uint64 (uint64)' |
| `-CXXDefaultArgExpr 0x85a0ac8 <> 'uint64':'unsigned long long' |

  `-CXXDefaultArgExpr 0x85c94f8 <> 'const uint64 *'

For each particular CXXDefaultArgExpr node, we need to reset
FirstSubExpr, otherwise FirstSubExpr will refer to an incorrect expr.


https://reviews.llvm.org/D30412

Files:
  clang-tidy/modernize/UseNullptrCheck.cpp
  test/clang-tidy/modernize-use-nullptr.cpp


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -228,3 +228,19 @@
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,8 +190,10 @@
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;


Index: test/clang-tidy/modernize-use-nullptr.cpp
===
--- test/clang-tidy/modernize-use-nullptr.cpp
+++ test/clang-tidy/modernize-use-nullptr.cpp
@@ -228,3 +228,19 @@
 void test_default_argument() {
   D(nullptr);
 }
+
+// Test on two neighbour CXXDefaultArgExprs nodes.
+typedef unsigned long long uint64;
+struct ZZ {
+  explicit ZZ(uint64, const uint64* = NULL) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
+// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
+  operator bool()  { return true; }
+};
+
+uint64 Hash(uint64 seed = 0) { return 0; }
+
+void f() {
+  bool a;
+  a = ZZ(Hash());
+}
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -190,8 +190,10 @@
   bool VisitStmt(Stmt *S) {
 auto *C = dyn_cast(S);
 // Catch the castExpr inside cxxDefaultArgExpr.
-if (auto *E = dyn_cast(S))
+if (auto *E = dyn_cast(S)) {
   C = dyn_cast(E->getExpr());
+  FirstSubExpr = nullptr;
+}
 if (!C) {
   FirstSubExpr = nullptr;
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27387: [libc++] Add a key function for bad_function_call

2017-02-27 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping.


https://reviews.llvm.org/D27387



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30315: [Driver] Move architecture-specific free helper functions to their own files.

2017-02-27 Thread David Blaikie via cfe-commits
On Thu, Feb 23, 2017 at 4:08 PM David L. Jones via Phabricator via
cfe-commits  wrote:

> dlj created this revision.
> Herald added subscribers: mgorny, nemanjai, jyknight, dschuff, srhines,
> danalbert, aemerson.
> Herald added a reviewer: javed.absar.
>
> This patch moves helper functions that are CPU-specific out of Driver.cpp
> and to
> separate implementation files. The new files are named for the
> architecture,
> e.g. ARMArch.cpp.
>

I'm guessing it's probably obvious - but some explanation for the
motivation for the move might be handy. (I'm guessing something like
allowing these pieces to be compiled only when the architecture support is
compiled (in the same way that LLVM targets can be opted in/out, etc)?)


>
> The next step after this will be to move OS-specific code, which I expect
> will
> include many of the tool implementations, to similarly separate files.
>
> Some CPU-specific functions are not being moved just yet. In cases where
> the
> only caller is the platform-specific tools, I plan to move them together.
> An
> example is Hexagon, where the only caller of the architecture-specific
> functions
> are the tools themselves. (I'm happy to revise this choice, it just seems
> like
> less churn to me.)
>
> This does mean that some functions which were previously static are now
> exposed
> through the library header Driver.h.
>
>
> https://reviews.llvm.org/D30315
>
> Files:
>   lib/Driver/AArch64Arch.cpp
>   lib/Driver/ARMArch.cpp
>   lib/Driver/CMakeLists.txt
>   lib/Driver/MipsArch.cpp
>   lib/Driver/PPCArch.cpp
>   lib/Driver/SparcArch.cpp
>   lib/Driver/SystemZArch.cpp
>   lib/Driver/Tools.cpp
>   lib/Driver/Tools.h
>   lib/Driver/X86Arch.cpp
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r296221 - [ODRHash] Move inherited visitor call to end of function.

2017-02-27 Thread David Blaikie via cfe-commits
An explanation as to why the code was moved (& possibly test cases, or
"NFC" in the description) would be handy here.

On Fri, Feb 24, 2017 at 5:41 PM Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Fri Feb 24 19:29:34 2017
> New Revision: 296221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=296221&view=rev
> Log:
> [ODRHash] Move inherited visitor call to end of function.
>
> Modified:
> cfe/trunk/lib/AST/ODRHash.cpp
>
> Modified: cfe/trunk/lib/AST/ODRHash.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=296221&r1=296220&r2=296221&view=diff
>
> ==
> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
> +++ cfe/trunk/lib/AST/ODRHash.cpp Fri Feb 24 19:29:34 2017
> @@ -182,8 +182,6 @@ public:
>}
>
>void VisitFieldDecl(const FieldDecl *D) {
> -Inherited::VisitFieldDecl(D);
> -
>  const bool IsBitfield = D->isBitField();
>  Hash.AddBoolean(IsBitfield);
>
> @@ -193,6 +191,8 @@ public:
>
>  Hash.AddBoolean(D->isMutable());
>  AddStmt(D->getInClassInitializer());
> +
> +Inherited::VisitFieldDecl(D);
>}
>  };
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r296351 - Fix LIBCXX_HAS_EXTERNAL_THREAD_API builds. NFC.

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 10:10:57 2017
New Revision: 296351

URL: http://llvm.org/viewvc/llvm-project?rev=296351&view=rev
Log:
Fix LIBCXX_HAS_EXTERNAL_THREAD_API builds. NFC.

Add the missing check in the __config header.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=296351&r1=296350&r2=296351&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Feb 27 10:10:57 2017
@@ -939,7 +939,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 
 // Thread API
 #if !defined(_LIBCPP_HAS_NO_THREADS) && \
-!defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
+!defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 # if defined(__FreeBSD__) || \
 defined(__Fuchsia__) || \
 defined(__NetBSD__) || \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30166: Honor __unaligned in codegen for declarations and expressions

2017-02-27 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Ping? :-)

Kind regards


https://reviews.llvm.org/D30166



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r296346 - Fix typo in error message. NFC.

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 09:49:51 2017
New Revision: 296346

URL: http://llvm.org/viewvc/llvm-project?rev=296346&view=rev
Log:
Fix typo in error message. NFC.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=296346&r1=296345&r2=296346&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Feb 27 09:49:51 2017
@@ -961,7 +961,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
-#  error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \
+#  error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \
  _LIBCPP_HAS_NO_THREADS is defined.
 #endif
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D3583: Sema: Implement DR244

2017-02-27 Thread Johnny Willemsen via Phabricator via cfe-commits
jwillemsen added a comment.

In https://reviews.llvm.org/D3583#222045, @rsmith wrote:

> This will be in 3.7.


As far as we can tell DR244 is not fixed yet in 3.9.1 so any idea why this 
review sets it to YES as implemented?


Repository:
  rL LLVM

https://reviews.llvm.org/D3583



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via cfe-commits
FILE_SHARE_DELETE is for being able to request a file to be deleted when
it's closed, which is too late, right?

I didn't write the code in Path.inc, but from what I understand you can't
generally overwrite a file that's still open on Windows, and Path.inc tries
to work around this -- but the workaround apparently causes the system to
leak temp files.

rnk will know more about this :-)

On Mon, Feb 27, 2017 at 10:10 AM, Manuel Klimek via Phabricator <
revi...@reviews.llvm.org> wrote:

> klimek added a comment.
>
> Also, do we want to not call ReplaceFile in Path.inc on Win if it
> potentially leaves temp files lying around?
> Reading the code, it looks like we currently actually believe it may fail,
> and retry with MoveFileEx afterwards...
>
>
> https://reviews.llvm.org/D30385
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxxabi] r296344 - Attempt to fix arm-native libcxxabi tests for the no-exceptions variant

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 09:31:34 2017
New Revision: 296344

URL: http://llvm.org/viewvc/llvm-project?rev=296344&view=rev
Log:
Attempt to fix arm-native libcxxabi tests for the no-exceptions variant

These tests embed calls to exceptions-related symbols from the abi library,
which are absent in the no-exceptions variant. The tests need to be marked
as unsupported for the no-exceptions configuration.

Modified:
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s

Modified: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s?rev=296344&r1=296343&r2=296344&view=diff
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s 
(original)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s Mon 
Feb 27 09:31:34 2017
@@ -1,5 +1,6 @@
 @ RUN: %cxx %flags %link_flags %s -o %t.exe
 @ RUN: %exec %t.exe
+@ UNSUPPORTED: libcxxabi-no-exceptions
 
 @ PURPOSE: Check that 0x00 is a valid value for ttype encoding.  LLVM and
 @ GCC 4.6 are generating 0x00 as ttype encoding.  libc++abi should provide

Modified: libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s?rev=296344&r1=296343&r2=296344&view=diff
==
--- libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s 
(original)
+++ libcxxabi/trunk/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s Mon 
Feb 27 09:31:34 2017
@@ -1,5 +1,6 @@
 @ RUN: %cxx %flags %link_flags %s -o %t.exe
 @ RUN: %exec %t.exe
+@ UNSUPPORTED: libcxxabi-no-exceptions
 
 @ PURPOSE: Check that 0x90 is a valid value for ttype encoding.
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30406: [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output

2017-02-27 Thread Vlad Tsyrklevich via Phabricator via cfe-commits
vlad.tsyrklevich created this revision.

While looking at checker output with https://reviews.llvm.org/D30289 applied I 
realized I was missing results. After some digging I found that it's because 
the Linux kernel makes heavy use of inlined functions included in header files, 
and the resulting diagnostic path now included cross-file diagnostics which are 
unsupported. This change adds support for cross-file diagnostic paths, 
resulting in output that looks like 
https://rawgit.com/vlad902/805a58327e12636fef119cdeb21ad639/raw/48f4183152a15e3e0f6fddfdc4edeb75c5a62295/report.html
 If the diagnostic path is not cross-file, there is no change in the output.


https://reviews.llvm.org/D30406

Files:
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  test/Analysis/diagnostics/diag-cross-file-boundaries.c
  test/Analysis/diagnostics/diag-cross-file-boundaries.h
  test/Analysis/html-diags-multifile.c
  test/Coverage/html-diagnostics.c
  test/Coverage/html-multifile-diagnostics.c
  test/Coverage/html-multifile-diagnostics.h
  www/analyzer/open_projects.html

Index: www/analyzer/open_projects.html
===
--- www/analyzer/open_projects.html
+++ www/analyzer/open_projects.html
@@ -107,13 +107,6 @@
 
   Bug Reporting 
   
-Add support for displaying cross-file diagnostic paths in HTML output
-(used by scan-build).
-Currently scan-build output does not display reports that span 
-multiple files. The main problem is that we do not have a good format to
-display such paths in HTML output. (Difficulty: Medium) 
-
-
 Refactor path diagnostic generation in http://clang.llvm.org/doxygen/BugReporter_8cpp_source.html";>BugReporter.cpp.
 It would be great to have more code reuse between "Minimal" and 
 "Extensive" PathDiagnostic generation algorithms. One idea is to create an 
Index: test/Coverage/html-multifile-diagnostics.h
===
--- /dev/null
+++ test/Coverage/html-multifile-diagnostics.h
@@ -0,0 +1,3 @@
+void f1(int *ptr) {
+  *ptr = 0;
+}
Index: test/Coverage/html-multifile-diagnostics.c
===
--- /dev/null
+++ test/Coverage/html-multifile-diagnostics.c
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t %s
+// RUN: find %t -name "*.html" -exec cat "{}" ";" | FileCheck %s
+
+// REQUIRES: staticanalyzer
+
+// CHECK: Annotated Source Code
+
+// Make sure it's generated as multi-file HTML output
+// CHECK: {{.*}}html-multifile-diagnostics.c
+// CHECK: {{.*}}html-multifile-diagnostics.h
+
+// Without tweaking expr, the expr would hit to the line below
+// emitted to the output as comment.
+// CHECK: {{[D]ereference of null pointer}}
+
+#include "html-multifile-diagnostics.h"
+
+void f0() {
+  f1((int*)0);
+}
Index: test/Coverage/html-diagnostics.c
===
--- test/Coverage/html-diagnostics.c
+++ test/Coverage/html-diagnostics.c
@@ -6,6 +6,9 @@
 
 // CHECK: Annotated Source Code
 
+// Make sure it's not generated as a multi-file HTML output
+// CHECK-NOT: {{.*}}
+
 // Without tweaking expr, the expr would hit to the line below
 // emitted to the output as comment.
 // CHECK: {{[D]ereference of null pointer}}
Index: test/Analysis/html-diags-multifile.c
===
--- test/Analysis/html-diags-multifile.c
+++ test/Analysis/html-diags-multifile.c
@@ -1,10 +1,9 @@
 // RUN: mkdir -p %t.dir
 // RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir %s
-// RUN: ls %t.dir | not grep report
+// RUN: ls %t.dir | grep report
 // RUN: rm -fR %t.dir
 
-// This tests that we do not currently emit HTML diagnostics for reports that
-// cross file boundaries.
+// This tests that we emit HTML diagnostics for reports that cross file boundaries.
 
 #include "html-diags-multifile.h"
 
Index: test/Analysis/diagnostics/diag-cross-file-boundaries.h
===
--- test/Analysis/diagnostics/diag-cross-file-boundaries.h
+++ /dev/null
@@ -1,4 +0,0 @@
-static void f() {
-  int *p = 0;
-  *p = 1;   // expected-warning{{Dereference of null pointer}}
-}
Index: test/Analysis/diagnostics/diag-cross-file-boundaries.c
===
--- test/Analysis/diagnostics/diag-cross-file-boundaries.c
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=html -o PR12421.html %s 2>&1 | FileCheck %s
-
-// Test for PR12421
-#include "diag-cross-file-boundaries.h"
-
-int main(){
-  f();
-  return 0;
-}
-
-// CHECK: warning: Path diagnostic report is not generated.
Index: lib/StaticAnalyzer/Core/HTMLDiagnostics

[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: include/clang/Rewrite/Core/Rewriter.h:188-197
+  /// prewrite(FID) is called after all changes to FID have been written to a
+  /// temporary file, but before that temporary file is moved into FID's
+  /// location.  Windows's ReplaceFileW(to, from) internally creates (another)
+  /// temporary file and swaps the data streams of that file with the one of
+  /// |to| so that it's possible to replace an opened file.  However, if |to|
+  /// _was_ opened, the temp file now has that open data stream, and
+  /// ReplaceFileW() fails to delete it, causing a tempo file leak.  To fix,

klimek wrote:
> llvm.org seems to be down, so I cannot access the original patch - but I'm 
> somewhat opposed to making this interface more complex. If we have a coupling 
> of MemoryBuffer to the Rewriter, can we make that explicit instead?
I think this generally requires per-app knowledge on when and how it's safe to 
free up memory buffers (for example, the fixit rewriter can't easily drop its 
inputs currently as far as I can tell without further refactorings). If you 
have a good suggestion, I'm all ears, but this seems like a fairly minor change 
that attempts to fix a fairly major bug. So if there's some better way of 
factoring this that I currently don't see, it's almost no work to move to that 
then.


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Also, do we want to not call ReplaceFile in Path.inc on Win if it potentially 
leaves temp files lying around?
Reading the code, it looks like we currently actually believe it may fail, and 
retry with MoveFileEx afterwards...


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Can we open the files with FILE_SHARE_DELETE instead?


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296341 - [clang-format] Add a NamespaceEndCommentsFixer

2017-02-27 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Mon Feb 27 07:28:36 2017
New Revision: 296341

URL: http://llvm.org/viewvc/llvm-project?rev=296341&view=rev
Log:
[clang-format] Add a NamespaceEndCommentsFixer

Summary:
This patch adds a NamespaceEndCommentsFixer TokenAnalyzer for clang-format,
which fixes end namespace comments.
It currently supports inserting and updating existing wrong comments.

Example source:
```
namespace A {
int i;
}

namespace B {
int j;
} // namespace A
```

after formatting:
```
namespace A {
int i;
} // namespace A

namespace B {
int j;
} // namespace B
```

Reviewers: klimek, djasper

Reviewed By: djasper

Subscribers: klimek, mgorny

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

Added:
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
cfe/trunk/lib/Format/NamespaceEndCommentsFixer.h
cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/CMakeLists.txt
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/TokenAnnotator.h
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/unittests/Format/CMakeLists.txt

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=296341&r1=296340&r2=296341&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Mon Feb 27 07:28:36 2017
@@ -829,6 +829,15 @@ tooling::Replacements cleanup(const Form
   ArrayRef Ranges,
   StringRef FileName = "");
 
+/// \brief Fix namespace end comments in the given \p Ranges in \p Code.
+///
+/// Returns the ``Replacements`` that fix the namespace comments in all
+/// \p Ranges in \p Code.
+tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style,
+  StringRef Code,
+  ArrayRef Ranges,
+  StringRef FileName = "");
+
 /// \brief Returns the ``LangOpts`` that the formatter expects you to set.
 ///
 /// \param Style determines specific settings for lexing mode.

Modified: cfe/trunk/lib/Format/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/CMakeLists.txt?rev=296341&r1=296340&r2=296341&view=diff
==
--- cfe/trunk/lib/Format/CMakeLists.txt (original)
+++ cfe/trunk/lib/Format/CMakeLists.txt Mon Feb 27 07:28:36 2017
@@ -7,6 +7,7 @@ add_clang_library(clangFormat
   Format.cpp
   FormatToken.cpp
   FormatTokenLexer.cpp
+  NamespaceEndCommentsFixer.cpp
   SortJavaScriptImports.cpp
   TokenAnalyzer.cpp
   TokenAnnotator.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=296341&r1=296340&r2=296341&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Feb 27 07:28:36 2017
@@ -17,6 +17,7 @@
 #include "AffectedRangeManager.h"
 #include "ContinuationIndenter.h"
 #include "FormatTokenLexer.h"
+#include "NamespaceEndCommentsFixer.h"
 #include "SortJavaScriptImports.h"
 #include "TokenAnalyzer.h"
 #include "TokenAnnotator.h"
@@ -1857,6 +1858,16 @@ tooling::Replacements cleanup(const Form
   return Clean.process();
 }
 
+tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style,
+  StringRef Code,
+  ArrayRef Ranges,
+  StringRef FileName) {
+  std::unique_ptr Env =
+  Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
+  NamespaceEndCommentsFixer Fix(*Env, Style);
+  return Fix.process();
+}
+
 LangOptions getFormattingLangOpts(const FormatStyle &Style) {
   LangOptions LangOpts;
   LangOpts.CPlusPlus = 1;

Added: cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp?rev=296341&view=auto
==
--- cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp (added)
+++ cfe/trunk/lib/Format/NamespaceEndCommentsFixer.cpp Mon Feb 27 07:28:36 2017
@@ -0,0 +1,165 @@
+//===--- NamespaceEndCommentsFixer.cpp --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file implements NamespaceEndCommentsFixer, a

[PATCH] D30337: [clang-move] Extend clang-move to support moving global variable.

2017-02-27 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296337: [clang-move] Extend clang-move to support moving 
global variable. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D30337?vs=89659&id=89869#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30337

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp
  clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h
  clang-tools-extra/trunk/test/clang-move/move-var.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -539,6 +539,8 @@
 "enum class E2 { Red };\n"
 "typedef int Int2;\n"
 "using Int = int;\n"
+"extern int kGlobalInt;\n"
+"extern const char* const kGlobalStr;\n"
 "} // namespace b\n"
 "} // namespace a\n";
   const char TestCode[] = "#include \"foo.h\"\n";
@@ -553,7 +555,8 @@
   {"A", "Class"}, {"B", "Class"},{"a::Move1", "Class"},
   {"a::f1", "Function"},  {"a::f2", "Function"}, {"a::b::Move1", "Class"},
   {"a::b::f", "Function"}, {"a::b::E1", "Enum"}, {"a::b::E2", "Enum"},
-  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"} };
+  {"a::b::Int2", "TypeAlias"}, {"a::b::Int", "TypeAlias"},
+  {"a::b::kGlobalInt", "Variable"}, {"a::b::kGlobalStr", "Variable"}};
   runClangMoveOnCode(Spec, TestHeader, TestCode, &Reporter);
   std::set Results;
   for (const auto& DelPair : Reporter.getDeclarationList())
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
@@ -168,6 +168,21 @@
   ClangMoveTool *MoveTool;
 };
 
+class VarDeclarationMatch : public MatchFinder::MatchCallback {
+public:
+  explicit VarDeclarationMatch(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+
+  void run(const MatchFinder::MatchResult &Result) override {
+const auto *VD = Result.Nodes.getNodeAs("var");
+assert(VD);
+MoveDeclFromOldFileToNewFile(MoveTool, VD);
+  }
+
+private:
+  ClangMoveTool *MoveTool;
+};
+
 class TypeAliasMatch : public MatchFinder::MatchCallback {
 public:
   explicit TypeAliasMatch(ClangMoveTool *MoveTool)
@@ -618,6 +633,11 @@
  .bind("function"),
  MatchCallbacks.back().get());
 
+  MatchCallbacks.push_back(llvm::make_unique(this));
+  Finder->addMatcher(
+  varDecl(InOldFiles, *HasAnySymbolNames, TopLevelDecl).bind("var"),
+  MatchCallbacks.back().get());
+
   // Match enum definition in old.h. Enum helpers (which are defined in old.cc)
   // will not be moved for now no matter whether they are used or not.
   MatchCallbacks.push_back(llvm::make_unique(this));
@@ -852,7 +872,10 @@
 for (const auto *Decl : UnremovedDeclsInOldHeader) {
   auto Kind = Decl->getKind();
   const std::string QualifiedName = Decl->getQualifiedNameAsString();
-  if (Kind == Decl::Kind::Function || Kind == Decl::Kind::FunctionTemplate)
+  if (Kind == Decl::Kind::Var)
+Reporter->reportDeclaration(QualifiedName, "Variable");
+  else if (Kind == Decl::Kind::Function ||
+   Kind == Decl::Kind::FunctionTemplate)
 Reporter->reportDeclaration(QualifiedName, "Function");
   else if (Kind == Decl::Kind::ClassTemplate ||
Kind == Decl::Kind::CXXRecord)
@@ -883,6 +906,7 @@
 case Decl::Kind::Typedef:
 case Decl::Kind::TypeAlias:
 case Decl::Kind::TypeAliasTemplate:
+case Decl::Kind::Var:
   return true;
 default:
   return false;
Index: clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h
+++ clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h
@@ -0,0 +1,11 @@
+namespace a {
+extern int kGlobalInt;
+extern const char *const kGlobalStr;
+}
+
+int kEvilInt = 2;
+
+inline void f1() {
+  int kGlobalInt = 3;
+  const char *const kGlobalStr = "Hello2";
+}
Index: clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp
===
--- clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp
+++ clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp
@@ -0,0 +1,6 @@
+#include "var_test.h"
+
+namespace a{
+int kGlobalInt = 1;
+const char *const kGlobalStr = "Hello";
+}
Index: clang-tools-

[clang-tools-extra] r296337 - [clang-move] Extend clang-move to support moving global variable.

2017-02-27 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Feb 27 07:19:13 2017
New Revision: 296337

URL: http://llvm.org/viewvc/llvm-project?rev=296337&view=rev
Log:
[clang-move] Extend clang-move to support moving global variable.

Summary: Also support dumping global variables.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp
clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h
clang-tools-extra/trunk/test/clang-move/move-var.cpp
Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.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=296337&r1=296336&r2=296337&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Mon Feb 27 07:19:13 2017
@@ -168,6 +168,21 @@ private:
   ClangMoveTool *MoveTool;
 };
 
+class VarDeclarationMatch : public MatchFinder::MatchCallback {
+public:
+  explicit VarDeclarationMatch(ClangMoveTool *MoveTool)
+  : MoveTool(MoveTool) {}
+
+  void run(const MatchFinder::MatchResult &Result) override {
+const auto *VD = Result.Nodes.getNodeAs("var");
+assert(VD);
+MoveDeclFromOldFileToNewFile(MoveTool, VD);
+  }
+
+private:
+  ClangMoveTool *MoveTool;
+};
+
 class TypeAliasMatch : public MatchFinder::MatchCallback {
 public:
   explicit TypeAliasMatch(ClangMoveTool *MoveTool)
@@ -618,6 +633,11 @@ void ClangMoveTool::registerMatchers(ast
  .bind("function"),
  MatchCallbacks.back().get());
 
+  MatchCallbacks.push_back(llvm::make_unique(this));
+  Finder->addMatcher(
+  varDecl(InOldFiles, *HasAnySymbolNames, TopLevelDecl).bind("var"),
+  MatchCallbacks.back().get());
+
   // Match enum definition in old.h. Enum helpers (which are defined in old.cc)
   // will not be moved for now no matter whether they are used or not.
   MatchCallbacks.push_back(llvm::make_unique(this));
@@ -852,7 +872,10 @@ void ClangMoveTool::onEndOfTranslationUn
 for (const auto *Decl : UnremovedDeclsInOldHeader) {
   auto Kind = Decl->getKind();
   const std::string QualifiedName = Decl->getQualifiedNameAsString();
-  if (Kind == Decl::Kind::Function || Kind == Decl::Kind::FunctionTemplate)
+  if (Kind == Decl::Kind::Var)
+Reporter->reportDeclaration(QualifiedName, "Variable");
+  else if (Kind == Decl::Kind::Function ||
+   Kind == Decl::Kind::FunctionTemplate)
 Reporter->reportDeclaration(QualifiedName, "Function");
   else if (Kind == Decl::Kind::ClassTemplate ||
Kind == Decl::Kind::CXXRecord)
@@ -883,6 +906,7 @@ void ClangMoveTool::onEndOfTranslationUn
 case Decl::Kind::Typedef:
 case Decl::Kind::TypeAlias:
 case Decl::Kind::TypeAliasTemplate:
+case Decl::Kind::Var:
   return true;
 default:
   return false;

Added: clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp?rev=296337&view=auto
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp (added)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/var_test.cpp Mon Feb 27 
07:19:13 2017
@@ -0,0 +1,6 @@
+#include "var_test.h"
+
+namespace a{
+int kGlobalInt = 1;
+const char *const kGlobalStr = "Hello";
+}

Added: clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h?rev=296337&view=auto
==
--- clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h (added)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/var_test.h Mon Feb 27 
07:19:13 2017
@@ -0,0 +1,11 @@
+namespace a {
+extern int kGlobalInt;
+extern const char *const kGlobalStr;
+}
+
+int kEvilInt = 2;
+
+inline void f1() {
+  int kGlobalInt = 3;
+  const char *const kGlobalStr = "Hello2";
+}

Added: clang-tools-extra/trunk/test/clang-move/move-var.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-var.cpp?rev=296337&view=auto
==
--- clang-tools-extra/trunk/test/clang-move/move-var.cpp (added)
+++ clang-tools-extra/trunk/test/clang-move/move-var.cpp Mon Feb 27 07:19:13 
2017
@@ -0,0 +1,46 @@
+// RUN: mkdir -p %T/move-var
+// RUN: cp %S/Inputs/var_test*  %T/move-var
+// RUN: cd %T/move-var
+// RUN: clang-move -names="a::kGlobalInt" 
-new_header=%T/move-var/new_var_test.h -old_header=../move-var/var_test.h 

[libcxx] r296338 - Fix cmake dependency for the external-thread-library variant. NFC.

2017-02-27 Thread Asiri Rathnayake via cfe-commits
Author: asiri
Date: Mon Feb 27 07:19:25 2017
New Revision: 296338

URL: http://llvm.org/viewvc/llvm-project?rev=296338&view=rev
Log:
Fix cmake dependency for the external-thread-library variant. NFC.

Modified:
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=296338&r1=296337&r2=296338&view=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Mon Feb 27 07:19:25 2017
@@ -62,7 +62,7 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
   set(LIBCXX_TEST_DEPS cxx_experimental)
 endif()
 
-if (LIBCXX_HAS_EXTERNAL_THREAD_API)
+if (LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
   list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
 endif()
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30343: [libcxxabi] Fix condition typo in rL296136

2017-02-27 Thread Ranjeet Singh via Phabricator via cfe-commits
rs added a comment.

> This works for me, but the idiomatic macro usage in libc++, and (hopefully) 
> libc++abi should always use !defined(FOO) as opposed to !FOO. I'll clean this 
> up in the next week if nobody else wants to.

I can do the clean up later this week.


Repository:
  rL LLVM

https://reviews.llvm.org/D30343



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30326: [MS-ABI] Allow #pragma section to choose for ZI data

2017-02-27 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: lib/Driver/Tools.cpp:5940
+   options::OPT_fno_always_use_bss, false))
+CmdArgs.push_back("-always-use-bss");
+

I think you mean `"-falways-use-bss"`.

Please add a test that checks that the driver is forwarding to CC1 the right 
flag. You only have a CC1 test that cannot catch this bug.



Comment at: lib/Sema/SemaDecl.cpp:10742-10743
+  Expr* InitExpr = var->getInit();
+  if (!InitExpr)
+return var->hasGlobalStorage();
+

This check wasn't in the original code. Can you explain why it is needed here?

If it is needed, maybe you want a test for this as well.



Comment at: test/CodeGenCXX/zi-sections.cpp:39
+int ArrayMinusTwo[] = {0, -2, 0};
+int ArrayUnInit;
+// CHECK-ZI-DATA: @ShortZero = global i16 0, section ".data.1", align 2

Would it make sense a test that checks array fillers?

```
int ArrayWithFiller[10] = { 0 };
int ArrayWithFillerTwo[10] = { 0, 2 };
int ArrayWithAllFiller[10] = { };
```


https://reviews.llvm.org/D30326



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296330 - clang-format: [JS] whitespace after async in arrow functions.

2017-02-27 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Feb 27 05:15:53 2017
New Revision: 296330

URL: http://llvm.org/viewvc/llvm-project?rev=296330&view=rev
Log:
clang-format: [JS] whitespace after async in arrow functions.

Summary:
Async arrow functions should be marked with a whitespace after the async 
keyword, before the parameter list:
x = async () => foo();

Before:
x = async() => foo();

This makes it easier to tell apart an async arrow function from a call to a 
function called async.

Reviewers: bkramer

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=296330&r1=296329&r2=296330&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb 27 05:15:53 2017
@@ -2220,6 +2220,14 @@ bool TokenAnnotator::spaceRequiredBefore
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen) {
+  const FormatToken *Next = Right.MatchingParen->getNextNonComment();
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  if (Next && Next->is(TT_JsFatArrow))
+return true;
+}
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=296330&r1=296329&r2=296330&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Feb 27 05:15:53 2017
@@ -463,6 +463,8 @@ TEST_F(FormatTestJS, AsyncFunctions) {
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30399: clang-format: [JS] whitespace after async in arrow functions.

2017-02-27 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296330: clang-format: [JS] whitespace after async in arrow 
functions. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D30399?vs=89859&id=89860#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30399

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2220,6 +2220,14 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen) {
+  const FormatToken *Next = Right.MatchingParen->getNextNonComment();
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  if (Next && Next->is(TT_JsFatArrow))
+return true;
+}
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -463,6 +463,8 @@
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2220,6 +2220,14 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen) {
+  const FormatToken *Next = Right.MatchingParen->getNextNonComment();
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  if (Next && Next->is(TT_JsFatArrow))
+return true;
+}
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -463,6 +463,8 @@
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30399: clang-format: [JS] whitespace after async in arrow functions.

2017-02-27 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 89859.
mprobst added a comment.

- Extract local variable for next non comment.


https://reviews.llvm.org/D30399

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -463,6 +463,8 @@
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2225,6 +2225,14 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen) {
+  const FormatToken *Next = Right.MatchingParen->getNextNonComment();
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  if (Next && Next->is(TT_JsFatArrow))
+return true;
+}
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -463,6 +463,8 @@
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2225,6 +2225,14 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen) {
+  const FormatToken *Next = Right.MatchingParen->getNextNonComment();
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  if (Next && Next->is(TT_JsFatArrow))
+return true;
+}
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30399: clang-format: [JS] whitespace after async in arrow functions.

2017-02-27 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:2229
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen && Right.MatchingParen->getNextNonComment() &&
+Right.MatchingParen->getNextNonComment()->is(TT_JsFatArrow))

As getNextNonComment() walks linearly over the tokens, I'd pull it out into a 
variable. 


https://reviews.llvm.org/D30399



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30157: [analyzer] Improve valist check

2017-02-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 89857.
xazax.hun edited the summary of this revision.
xazax.hun added a comment.

- Move the check out of alpha.


https://reviews.llvm.org/D30157

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  test/Analysis/valist-uninitialized-no-undef.c
  test/Analysis/valist-uninitialized.c
  test/Analysis/valist-unterminated.c

Index: test/Analysis/valist-unterminated.c
===
--- test/Analysis/valist-unterminated.c
+++ test/Analysis/valist-unterminated.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple hexagon-unknown-linux -analyze -analyzer-checker=core,valist.Unterminated,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,valist.Unterminated,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
 
@@ -28,9 +29,8 @@
 }
 
 void f5(va_list fst, ...) {
-  va_start(fst, fst);
-  //FIXME: this should cause a warning
-} // no-warning
+  va_start(fst, fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list}} expected-note{{Initialized va_list}}
 
 void f6(va_list *fst, ...) {
   va_start(*fst, fst); // expected-note{{Initialized va_list}}
Index: test/Analysis/valist-uninitialized.c
===
--- test/Analysis/valist-uninitialized.c
+++ test/Analysis/valist-uninitialized.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple hexagon-unknown-linux -analyze -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s
 
 #include "Inputs/system-header-simulator-for-valist.h"
 
@@ -38,13 +39,6 @@
   va_end(fst);
 } // no-warning
 
-//FIXME: this should not cause a warning
-void f6(va_list *fst, ...) {
-  va_start(*fst, fst);
-  (void)va_arg(*fst, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}}
-  va_end(*fst);
-}
-
 void f7(int *fst, ...) {
   va_list x;
   va_list *y = &x;
@@ -141,38 +135,31 @@
   (void)va_arg(arg, int);
 } //no-warning
 
-// This is the same function as the previous one, but it is called in call_uses_arg2(),
-// and the warning is generated during the analysis of call_uses_arg2().
-void inlined_uses_arg(va_list arg) {
-  (void)va_arg(arg, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}}
-}
-
-void call_inlined_uses_arg(int fst, ...) {
-  va_list va;
-  inlined_uses_arg(va); // expected-note{{Calling 'inlined_uses_arg'}}
-}
-
 void call_vprintf_ok(int isstring, ...) {
   va_list va;
   va_start(va, isstring);
   vprintf(isstring ? "%s" : "%d", va);
   va_end(va);
 } //no-warning
 
-void call_vprintf_bad(int isstring, ...) {
+void call_some_other_func(int n, ...) {
   va_list va;
-  vprintf(isstring ? "%s" : "%d", va); //expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Assuming 'isstring' is 0}} expected-note{{'?' condition is false}}
-}
+  some_library_function(n, va);
+} //no-warning
 
-void call_vsprintf_bad(char *buffer, ...) {
-  va_list va;
-  va_start(va, buffer); // expected-note{{Initialized va_list}}
-  va_end(va); // expected-note{{Ended va_list}}
-  vsprintf(buffer, "%s %d %d %lf %03d", va); //expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vsprintf' is called with an uninitialized va_list argument}}
+void inlined_uses_arg_good(va_list arg) {
+  (void)va_arg(arg, int);
 }
 
-void call_some_other_func(int n, ...) {
+void call_inlined_uses_arg_good(int fst, ...) {
   va_list va;
-  some_library_function(n, va);
-} //no-warning
+  va_start(va, fst);
+  inlined_uses_arg_good(va);
+  va_end(va);
+}
 
+void va_copy_test(va_list arg) {
+  va_list dst;
+  va_copy(dst, arg);
+  va_end(dst);
+}
Index: test/Analysis/valist-uninitialized-no-undef.c
===
--- /dev/null
+++ t

r296326 - [analyzer] clarify 'result is garbage value' when it is out of bounds

2017-02-27 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Mon Feb 27 04:44:24 2017
New Revision: 296326

URL: http://llvm.org/viewvc/llvm-project?rev=296326&view=rev
Log:
[analyzer] clarify 'result is garbage value' when it is out of bounds

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
cfe/trunk/test/Analysis/uninit-vals-ps.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp?rev=296326&r1=296325&r2=296326&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp Mon Feb 27 
04:44:24 2017
@@ -35,6 +35,30 @@ public:
 };
 } // end anonymous namespace
 
+static bool isArrayIndexOutOfBounds(CheckerContext &C, const Expr *Ex) {
+  ProgramStateRef state = C.getState();
+  const LocationContext *LCtx = C.getLocationContext();
+
+  if (!isa(Ex))
+return false;
+
+  SVal Loc = state->getSVal(Ex, LCtx);
+  if (!Loc.isValid())
+return false;
+
+  const MemRegion *MR = Loc.castAs().getRegion();
+  const ElementRegion *ER = dyn_cast(MR);
+  if (!ER)
+return false;
+
+  DefinedOrUnknownSVal Idx = ER->getIndex().castAs();
+  DefinedOrUnknownSVal NumElements = C.getStoreManager().getSizeInElements(
+  state, ER->getSuperRegion(), ER->getValueType());
+  ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
+  ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+  return StOutBound && !StInBound;
+}
+
 void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
CheckerContext &C) const {
   ProgramStateRef state = C.getState();
@@ -77,6 +101,8 @@ void UndefResultChecker::checkPostStmt(c
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
  << "' is a garbage value";
+  if (isArrayIndexOutOfBounds(C, Ex))
+OS << " due to array index out of bounds";
 }
 else {
   // Neither operand was undefined, but the result is undefined.

Modified: cfe/trunk/test/Analysis/uninit-vals-ps.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps.c?rev=296326&r1=296325&r2=296326&view=diff
==
--- cfe/trunk/test/Analysis/uninit-vals-ps.c (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c Mon Feb 27 04:44:24 2017
@@ -57,6 +57,12 @@ int f5(void) {
   return s.x; // no-warning
 }
 
+void f6(int x) {
+  int a[20];
+  if (x == 25) {}
+  if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a 
garbage value due to array index out of bounds}}
+}
+
 int ret_uninit() {
   int i;
   int *p = &i;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28278: [StaticAnalyzer] dont show wrong 'garbage value' warning when there is array index out of bounds

2017-02-27 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL296326: [analyzer] clarify 'result is garbage value' when it 
is out of bounds (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D28278?vs=89641&id=89854#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28278

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  cfe/trunk/test/Analysis/uninit-vals-ps.c


Index: cfe/trunk/test/Analysis/uninit-vals-ps.c
===
--- cfe/trunk/test/Analysis/uninit-vals-ps.c
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c
@@ -57,6 +57,12 @@
   return s.x; // no-warning
 }
 
+void f6(int x) {
+  int a[20];
+  if (x == 25) {}
+  if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a 
garbage value due to array index out of bounds}}
+}
+
 int ret_uninit() {
   int i;
   int *p = &i;
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -35,6 +35,30 @@
 };
 } // end anonymous namespace
 
+static bool isArrayIndexOutOfBounds(CheckerContext &C, const Expr *Ex) {
+  ProgramStateRef state = C.getState();
+  const LocationContext *LCtx = C.getLocationContext();
+
+  if (!isa(Ex))
+return false;
+
+  SVal Loc = state->getSVal(Ex, LCtx);
+  if (!Loc.isValid())
+return false;
+
+  const MemRegion *MR = Loc.castAs().getRegion();
+  const ElementRegion *ER = dyn_cast(MR);
+  if (!ER)
+return false;
+
+  DefinedOrUnknownSVal Idx = ER->getIndex().castAs();
+  DefinedOrUnknownSVal NumElements = C.getStoreManager().getSizeInElements(
+  state, ER->getSuperRegion(), ER->getValueType());
+  ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
+  ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+  return StOutBound && !StInBound;
+}
+
 void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
CheckerContext &C) const {
   ProgramStateRef state = C.getState();
@@ -77,6 +101,8 @@
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
  << "' is a garbage value";
+  if (isArrayIndexOutOfBounds(C, Ex))
+OS << " due to array index out of bounds";
 }
 else {
   // Neither operand was undefined, but the result is undefined.


Index: cfe/trunk/test/Analysis/uninit-vals-ps.c
===
--- cfe/trunk/test/Analysis/uninit-vals-ps.c
+++ cfe/trunk/test/Analysis/uninit-vals-ps.c
@@ -57,6 +57,12 @@
   return s.x; // no-warning
 }
 
+void f6(int x) {
+  int a[20];
+  if (x == 25) {}
+  if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a garbage value due to array index out of bounds}}
+}
+
 int ret_uninit() {
   int i;
   int *p = &i;
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -35,6 +35,30 @@
 };
 } // end anonymous namespace
 
+static bool isArrayIndexOutOfBounds(CheckerContext &C, const Expr *Ex) {
+  ProgramStateRef state = C.getState();
+  const LocationContext *LCtx = C.getLocationContext();
+
+  if (!isa(Ex))
+return false;
+
+  SVal Loc = state->getSVal(Ex, LCtx);
+  if (!Loc.isValid())
+return false;
+
+  const MemRegion *MR = Loc.castAs().getRegion();
+  const ElementRegion *ER = dyn_cast(MR);
+  if (!ER)
+return false;
+
+  DefinedOrUnknownSVal Idx = ER->getIndex().castAs();
+  DefinedOrUnknownSVal NumElements = C.getStoreManager().getSizeInElements(
+  state, ER->getSuperRegion(), ER->getValueType());
+  ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
+  ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+  return StOutBound && !StInBound;
+}
+
 void UndefResultChecker::checkPostStmt(const BinaryOperator *B,
CheckerContext &C) const {
   ProgramStateRef state = C.getState();
@@ -77,6 +101,8 @@
  << " operand of '"
  << BinaryOperator::getOpcodeStr(B->getOpcode())
  << "' is a garbage value";
+  if (isArrayIndexOutOfBounds(C, Ex))
+OS << " due to array index out of bounds";
 }
 else {
   // Neither operand was undefined, but the result is undefined.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30399: clang-format: [JS] whitespace after async in arrow functions.

2017-02-27 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg, but I don't really know JS ;)


https://reviews.llvm.org/D30399



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30399: clang-format: [JS] whitespace after async in arrow functions.

2017-02-27 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

Async arrow functions should be marked with a whitespace after the async 
keyword, before the parameter list:

  x = async () => foo();

Before:

  x = async() => foo();

This makes it easier to tell apart an async arrow function from a call to a 
function called async.


https://reviews.llvm.org/D30399

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -463,6 +463,8 @@
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2225,6 +2225,12 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen && Right.MatchingParen->getNextNonComment() &&
+Right.MatchingParen->getNextNonComment()->is(TT_JsFatArrow))
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  return true;
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -463,6 +463,8 @@
   verifyFormat("export async function f() {\n"
"  return fetch(x);\n"
"}");
+  verifyFormat("let x = async () => f();");
+  verifyFormat("let x = async();");
   verifyFormat("class X {\n"
"  async asyncMethod() {\n"
"return fetch(1);\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2225,6 +2225,12 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
+Right.MatchingParen && Right.MatchingParen->getNextNonComment() &&
+Right.MatchingParen->getNextNonComment()->is(TT_JsFatArrow))
+  // An async arrow function, for example: `x = async () => foo();`,
+  // as opposed to calling a function called async: `x = async();`
+  return true;
 if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30385: clang-format: Don't leave behind temp files in -i mode on Windows, PR26125, reloaded

2017-02-27 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: include/clang/Rewrite/Core/Rewriter.h:188-197
+  /// prewrite(FID) is called after all changes to FID have been written to a
+  /// temporary file, but before that temporary file is moved into FID's
+  /// location.  Windows's ReplaceFileW(to, from) internally creates (another)
+  /// temporary file and swaps the data streams of that file with the one of
+  /// |to| so that it's possible to replace an opened file.  However, if |to|
+  /// _was_ opened, the temp file now has that open data stream, and
+  /// ReplaceFileW() fails to delete it, causing a tempo file leak.  To fix,

llvm.org seems to be down, so I cannot access the original patch - but I'm 
somewhat opposed to making this interface more complex. If we have a coupling 
of MemoryBuffer to the Rewriter, can we make that explicit instead?


https://reviews.llvm.org/D30385



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30372: [Driver] Consolidate tools and toolchains by target platform. (NFC)

2017-02-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D30372#687054, @dlj wrote:

> In https://reviews.llvm.org/D30372#686871, @ahatanak wrote:
>
> > Have you considered using "include_directories" in CMakeLists.txt to avoid 
> > including "../Something.h"?
>
>
> I don't want to take that approach, and there's a specific reason why: my 
> concern isn't with three extra bytes, it's the fact that the headers are in 
> an unusual place. It's typical to include headers from a subdirectory, or 
> from the includes directory, but far less common to include from a parent lib 
> directory. Hiding that fact seems strictly worse to me.


OK. I was suggesting that only because LLVM already uses include_directories to 
include a header that exists in the parent directory in some cases. Apparently 
that's not what you wanted.


https://reviews.llvm.org/D30372



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >