Re: [PATCH] D14736: [analyzer] DeadStoresChecker: Treat locals captured by reference in C++ lambdas as escaped.

2015-11-17 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

This looks good to me, I have one question inline.



Comment at: lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp:425
@@ +424,3 @@
+llvm::DenseMap CaptureFields;
+FieldDecl *ThisCaptureField;
+LambdaClass->getCaptureFields(CaptureFields, ThisCaptureField);

As far as I can see ThisCaptureField is not used. Does this solution work, when 
there is a dead store to a class member (through captured this)?


http://reviews.llvm.org/D14736



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


Re: [PATCH] D14506: Porting shouldVisitImplicitCode to DataRecursiveASTVisitor.

2015-11-17 Thread Manuel Klimek via cfe-commits
Richard, this is still optional, right? (the AST matchers need to control
visitation)

On Tue, Nov 17, 2015 at 2:26 AM Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> W00t! That’s awesome Richard!
>
> On Nov 16, 2015, at 5:10 PM, Richard Smith  wrote:
>
> Attached patch makes RAV fully data-recursive when visiting statements,
> except in cases where the derived class could tell the difference (when it
> falls back to a normal recursive walk). The queue representation is
> slightly less compact than before: instead of storing a child iterator, we
> now store a list of all children. This allows us to handle any Stmt
> subclass that we can traverse, not just those ones that finish by
> traversing all their children in the usual order.
>
> Thoughts?
>
> On Mon, Nov 16, 2015 at 2:28 PM, Craig, Ben via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> I'm fine with this approach.  How about I leave the file in place, but
>> replace the contents with a "using DataRecursiveASTVisitor =
>> RecursiveASTVisitor;" and see what breaks?  That way I won't need to go
>> through a large retrofit.
>>
>>
>> On 11/16/2015 3:28 PM, Richard Smith wrote:
>>
>> Rather than trying to maintain the horrible duplication between
>> DataRecursiveASTVisitor and RecursiveASTVisitor, can we just delete
>> DataRecursiveASTVisitor? RecursiveASTVisitor is data-recursive too these
>> days (and has a smarter implementation than DataRecursiveASTVisitor's from
>> what I can see), but doesn't yet apply data recursion in so many cases.
>>
>> On Mon, Nov 16, 2015 at 1:07 PM, Argyrios Kyrtzidis < 
>> akyr...@gmail.com> wrote:
>>
>>> LGTM.
>>>
>>> > On Nov 16, 2015, at 12:32 PM, Ben Craig < 
>>> ben.cr...@codeaurora.org> wrote:
>>> >
>>> > bcraig added a comment.
>>> >
>>> > Ping.  Note that the test is basically a copy / paste job, and the new
>>> code in DataRecursiveASTVisitor.h is a very direct translation from the
>>> 'regular' RecursiveASTVisitor.h.
>>> >
>>> >
>>> > http://reviews.llvm.org/D14506
>>> >
>>> >
>>> >
>>>
>>>
>>
>> --
>> Employee of Qualcomm Innovation Center, Inc.
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
>> Foundation Collaborative Project
>>
>>
>> ___
>> 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


Re: [PATCH] D14170: Fix false positive warning about memory leak for QApplication::postEvent

2015-11-17 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2514
@@ -2513,1 +2513,3 @@
 
+  if (FName.endswith("postEvent") &&
+  FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {

Shouldn't you use == instead of endswith here?


http://reviews.llvm.org/D14170



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


Re: [PATCH] D14506: Porting shouldVisitImplicitCode to DataRecursiveASTVisitor.

2015-11-17 Thread Richard Smith via cfe-commits
LOn Nov 17, 2015 12:49 AM, "Manuel Klimek"  wrote:
> Richard, this is still optional, right? (the AST matchers need to control
visitation)

This doesn't change RAV semantics at all (or if it does, it's a bug). If
any of the extension points are overridden in the derived class, data
recursion is automatically disabled for that case.

> On Tue, Nov 17, 2015 at 2:26 AM Argyrios Kyrtzidis via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>>
>> W00t! That’s awesome Richard!
>>
>>> On Nov 16, 2015, at 5:10 PM, Richard Smith 
wrote:
>>>
>>> Attached patch makes RAV fully data-recursive when visiting statements,
except in cases where the derived class could tell the difference (when it
falls back to a normal recursive walk). The queue representation is
slightly less compact than before: instead of storing a child iterator, we
now store a list of all children. This allows us to handle any Stmt
subclass that we can traverse, not just those ones that finish by
traversing all their children in the usual order.
>>>
>>> Thoughts?
>>>
>>> On Mon, Nov 16, 2015 at 2:28 PM, Craig, Ben via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

 I'm fine with this approach.  How about I leave the file in place, but
replace the contents with a "using DataRecursiveASTVisitor =
RecursiveASTVisitor;" and see what breaks?  That way I won't need to go
through a large retrofit.


 On 11/16/2015 3:28 PM, Richard Smith wrote:
>
> Rather than trying to maintain the horrible duplication between
DataRecursiveASTVisitor and RecursiveASTVisitor, can we just delete
DataRecursiveASTVisitor? RecursiveASTVisitor is data-recursive too these
days (and has a smarter implementation than DataRecursiveASTVisitor's from
what I can see), but doesn't yet apply data recursion in so many cases.
>
> On Mon, Nov 16, 2015 at 1:07 PM, Argyrios Kyrtzidis 
wrote:
>>
>> LGTM.
>>
>> > On Nov 16, 2015, at 12:32 PM, Ben Craig 
wrote:
>> >
>> > bcraig added a comment.
>> >
>> > Ping.  Note that the test is basically a copy / paste job, and the
new code in DataRecursiveASTVisitor.h is a very direct translation from the
'regular' RecursiveASTVisitor.h.
>> >
>> >
>> > http://reviews.llvm.org/D14506
>> >
>> >
>> >
>>
>

 --
 Employee of Qualcomm Innovation Center, Inc.
 Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project


 ___
 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


Re: [PATCH] D14506: Porting shouldVisitImplicitCode to DataRecursiveASTVisitor.

2015-11-17 Thread Manuel Klimek via cfe-commits
On Tue, Nov 17, 2015 at 10:14 AM Richard Smith 
wrote:

> LOn Nov 17, 2015 12:49 AM, "Manuel Klimek"  wrote:
> > Richard, this is still optional, right? (the AST matchers need to
> control visitation)
>
> This doesn't change RAV semantics at all (or if it does, it's a bug). If
> any of the extension points are overridden in the derived class, data
> recursion is automatically disabled for that case.
>

Ah, cool, sg.

> > On Tue, Nov 17, 2015 at 2:26 AM Argyrios Kyrtzidis via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> W00t! That’s awesome Richard!
> >>
> >>> On Nov 16, 2015, at 5:10 PM, Richard Smith 
> wrote:
> >>>
> >>> Attached patch makes RAV fully data-recursive when visiting
> statements, except in cases where the derived class could tell the
> difference (when it falls back to a normal recursive walk). The queue
> representation is slightly less compact than before: instead of storing a
> child iterator, we now store a list of all children. This allows us to
> handle any Stmt subclass that we can traverse, not just those ones that
> finish by traversing all their children in the usual order.
> >>>
> >>> Thoughts?
> >>>
> >>> On Mon, Nov 16, 2015 at 2:28 PM, Craig, Ben via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
>  I'm fine with this approach.  How about I leave the file in place,
> but replace the contents with a "using DataRecursiveASTVisitor =
> RecursiveASTVisitor;" and see what breaks?  That way I won't need to go
> through a large retrofit.
> 
> 
>  On 11/16/2015 3:28 PM, Richard Smith wrote:
> >
> > Rather than trying to maintain the horrible duplication between
> DataRecursiveASTVisitor and RecursiveASTVisitor, can we just delete
> DataRecursiveASTVisitor? RecursiveASTVisitor is data-recursive too these
> days (and has a smarter implementation than DataRecursiveASTVisitor's from
> what I can see), but doesn't yet apply data recursion in so many cases.
> >
> > On Mon, Nov 16, 2015 at 1:07 PM, Argyrios Kyrtzidis <
> akyr...@gmail.com> wrote:
> >>
> >> LGTM.
> >>
> >> > On Nov 16, 2015, at 12:32 PM, Ben Craig 
> wrote:
> >> >
> >> > bcraig added a comment.
> >> >
> >> > Ping.  Note that the test is basically a copy / paste job, and
> the new code in DataRecursiveASTVisitor.h is a very direct translation from
> the 'regular' RecursiveASTVisitor.h.
> >> >
> >> >
> >> > http://reviews.llvm.org/D14506
> >> >
> >> >
> >> >
> >>
> >
> 
>  --
>  Employee of Qualcomm Innovation Center, Inc.
>  Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
> Linux Foundation Collaborative Project
> 
> 
>  ___
>  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


Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Renato Golin via cfe-commits
On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
 wrote:
> Author: scanon
> Date: Mon Nov 16 17:09:11 2015
> New Revision: 253269
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253269&view=rev
> Log:
> Make FP_CONTRACT ON the default.
>
> Differential Revision: D14200

Hi Stephen,

It seems your commit in the blame list is the only one that affects
AArch64 directly:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388

I haven't bisected yet, but would be good if you could try those tests
locally, just to make sure it wasn't your commit, and revert if it
was, to fix offline.

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


Re: [PATCH] D14467: [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions.

2015-11-17 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla updated this revision to Diff 40380.
d.zobnin.bugzilla added a comment.

Only tests have been updated: enabled a test case for Sema, which pass with 
these changes, added corresponding test case for CodeGen.


http://reviews.llvm.org/D14467

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  test/Layout/ms-vtordisp-local.cpp
  test/SemaCXX/pragma-vtordisp.cpp

Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2854,6 +2854,11 @@
 return DeclGroupPtrTy();
   }
 
+  if (Tok.is(tok::annot_pragma_ms_vtordisp)) {
+HandlePragmaMSVtorDisp();
+return DeclGroupPtrTy();
+  }
+
   // If we see a namespace here, a close brace was missing somewhere.
   if (Tok.is(tok::kw_namespace)) {
 DiagnoseUnexpectedNamespace(cast(TagDecl));
Index: lib/Parse/ParseStmt.cpp
===
--- lib/Parse/ParseStmt.cpp
+++ lib/Parse/ParseStmt.cpp
@@ -358,6 +358,11 @@
 HandlePragmaMSPragma();
 return StmtEmpty();
 
+  case tok::annot_pragma_ms_vtordisp:
+ProhibitAttributes(Attrs);
+HandlePragmaMSVtorDisp();
+return StmtEmpty();
+
   case tok::annot_pragma_loop_hint:
 ProhibitAttributes(Attrs);
 return ParsePragmaLoopHint(Stmts, OnlyStatement, TrailingElseLoc, Attrs);
@@ -885,6 +890,9 @@
 case tok::annot_pragma_ms_pragma:
   HandlePragmaMSPragma();
   break;
+case tok::annot_pragma_ms_vtordisp:
+  HandlePragmaMSVtorDisp();
+  break;
 default:
   checkForPragmas = false;
   break;
@@ -1895,6 +1903,11 @@
   PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
   "parsing function body");
 
+  // Save and reset current vtordisp stack if we have entered a C++ method body.
+  bool IsCXXMethod =
+  getLangOpts().CPlusPlus && Decl && isa(Decl);
+  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+
   // Do not enter a scope for the brace, as the arguments are in the same scope
   // (the function body) as the body itself.  Instead, just read the statement
   // list and put it into a CompoundStmt for safe keeping.
@@ -1934,6 +1947,11 @@
 return Actions.ActOnSkippedFunctionBody(Decl);
   }
 
+  // Save and reset current vtordisp stack if we have entered a C++ method body.
+  bool IsCXXMethod =
+  getLangOpts().CPlusPlus && Decl && isa(Decl);
+  Sema::VtorDispStackRAII SavedVtorDispStack(Actions, IsCXXMethod);
+
   SourceLocation LBraceLoc = Tok.getLocation();
   StmtResult FnBody(ParseCXXTryBlockCommon(TryLoc, /*FnTry*/true));
   // If we failed to parse the try-catch, we just give the function an empty
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -1007,6 +1007,24 @@
 bool OldFPContractState : 1;
   };
 
+  /// Records and restores the vtordisp state on entry/exit of C++ method body.
+  class VtorDispStackRAII {
+  public:
+VtorDispStackRAII(Sema &S, bool ShouldSaveAndRestore)
+  : S(S), ShouldSaveAndRestore(ShouldSaveAndRestore), OldVtorDispStack() {
+  if (ShouldSaveAndRestore)
+OldVtorDispStack = S.VtorDispModeStack;
+}
+~VtorDispStackRAII() {
+  if (ShouldSaveAndRestore)
+S.VtorDispModeStack = OldVtorDispStack;
+}
+  private:
+Sema &S;
+bool ShouldSaveAndRestore;
+SmallVector OldVtorDispStack;
+  };
+
   void addImplicitTypedef(StringRef Name, QualType T);
 
 public:
Index: test/Layout/ms-vtordisp-local.cpp
===
--- test/Layout/ms-vtordisp-local.cpp
+++ test/Layout/ms-vtordisp-local.cpp
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 | FileCheck %s
+
+struct Base {
+  virtual ~Base() {}
+  virtual void BaseFunc() {}
+};
+
+#pragma vtordisp(0)
+
+struct Container {
+  static void f() try {
+#pragma vtordisp(2)
+struct HasVtorDisp : virtual Base {
+  virtual ~HasVtorDisp() {}
+  virtual void Func() {}
+};
+
+int x[sizeof(HasVtorDisp)];
+
+// HasVtorDisp: vtordisp because of pragma right before it.
+//
+// CHECK: *** Dumping AST Record Layout
+// CHECK: *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct HasVtorDisp
+// CHECK-NEXT:  0 |   (HasVtorDisp vftable pointer)
+// CHECK-NEXT:  8 |   (HasVtorDisp vbtable pointer)
+// CHECK-NEXT: 20 |   (vtordisp for vbase Base)
+// CHECK-NEXT: 24 |   struct Base (virtual base)
+// CHECK-NEXT: 24 | (Base vftable pointer)
+// CHECK-NEXT:| [sizeof=32, align=8,
+// CHECK-NEXT:|  nvsize=16, nvalign=8]
+  } catch (...) {
+  }
+};

Re: [PATCH] D14467: [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions.

2015-11-17 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla added inline comments.


Comment at: test/SemaCXX/pragma-vtordisp.cpp:34-35
@@ -33,6 +33,4 @@
 
 struct C {
-// FIXME: Our implementation based on token insertion makes it impossible for
-// the pragma to appear everywhere we should support it.
-//#pragma vtordisp()
+#pragma vtordisp()
   struct D : virtual A {

Yes, we can. Enabled this case, it passes with these changes.


http://reviews.llvm.org/D14467



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


Re: [PATCH] D10802: [mips] Interrupt attribute support.

2015-11-17 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 40382.
sdardis marked 12 inline comments as done.
sdardis added a comment.

Updated documentation text.

Switched the various hard failures to semantic warnings/failures.

Strangely, the 'interrupt' attribute on a non-function defaults to a warning.

Thanks.


http://reviews.llvm.org/D10802

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/mips-interrupt-attr.c
  test/Sema/mips-interrupt-attr.c

Index: test/Sema/mips-interrupt-attr.c
===
--- /dev/null
+++ test/Sema/mips-interrupt-attr.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 %s -triple mips-img-elf -verify -fsyntax-only
+struct a { int b; };
+
+struct a test __attribute__((interrupt)); // expected-warning {{'interrupt' attribute only applies to functions and methods}}
+
+__attribute__((interrupt("EIC"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: 'EIC'}}
+
+__attribute__((interrupt("eic", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
+
+__attribute__((interrupt("eic"))) void foo3() {}
+__attribute__((interrupt("vector=sw0"))) void foo4() {}
+__attribute__((interrupt("vector=hw0"))) void foo5() {}
+__attribute__((interrupt("vector=hw1"))) void foo6() {}
+__attribute__((interrupt("vector=hw2"))) void foo7() {}
+__attribute__((interrupt("vector=hw3"))) void foo8() {}
+__attribute__((interrupt("vector=hw4"))) void foo9() {}
+__attribute__((interrupt("vector=hw5"))) void fooa() {}
+
+__attribute__((interrupt)) int foob() {} // expected-error {{function 'foob' does not have the 'void' return type}}
+__attribute__((interrupt())) void fooc(int a) {} // expected-error {{function 'fooc' has too many arguments}}
+__attribute__((interrupt(""))) void food() {}
+__attribute__((interrupt,mips16)) void fooe() {} // expected-error {{'interrupt' and 'mips16' attributes are not compatible}}
Index: test/CodeGen/mips-interrupt-attr.c
===
--- /dev/null
+++ test/CodeGen/mips-interrupt-attr.c
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple mipsel-unknown-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK
+
+void __attribute__ ((interrupt("vector=sw0")))
+isr_sw0 (void)
+{
+  // CHECK: define void @isr_sw0() [[SW0:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=sw1")))
+isr_sw1 (void)
+{
+  // CHECK: define void @isr_sw1() [[SW1:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw0")))
+isr_hw0 (void)
+{
+  // CHECK: define void @isr_hw0() [[HW0:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw1")))
+isr_hw1 (void)
+{
+  // CHECK: define void @isr_hw1() [[HW1:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw2")))
+isr_hw2 (void)
+{
+  // CHECK: define void @isr_hw2() [[HW2:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw3")))
+isr_hw3 (void)
+{
+  // CHECK: define void @isr_hw3() [[HW3:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw4")))
+isr_hw4 (void)
+{
+  // CHECK: define void @isr_hw4() [[HW4:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt("vector=hw5")))
+isr_hw5 (void)
+{
+  // CHECK: define void @isr_hw5() [[HW5:#[0-9]+]]
+}
+
+void __attribute__ ((interrupt))
+isr_eic (void)
+{
+  // CHECK: define void @isr_eic() [[EIC:#[0-9]+]]
+}
+// CHECK: attributes [[SW0]] = { {{.*}} "interrupt"="sw0" {{.*}} }
+// CHECK: attributes [[SW1]] = { {{.*}} "interrupt"="sw1" {{.*}} }
+// CHECK: attributes [[HW0]] = { {{.*}} "interrupt"="hw0" {{.*}} }
+// CHECK: attributes [[HW1]] = { {{.*}} "interrupt"="hw1" {{.*}} }
+// CHECK: attributes [[HW2]] = { {{.*}} "interrupt"="hw2" {{.*}} }
+// CHECK: attributes [[HW3]] = { {{.*}} "interrupt"="hw3" {{.*}} }
+// CHECK: attributes [[HW4]] = { {{.*}} "interrupt"="hw4" {{.*}} }
+// CHECK: attributes [[HW5]] = { {{.*}} "interrupt"="hw5" {{.*}} }
+// CHECK: attributes [[EIC]] = { {{.*}} "interrupt"="eic" {{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4408,10 +4408,74 @@
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
+static void handleMipsInterruptAttr(Sema &S, Decl *D,
+const AttributeList &Attr) {
+  // Only one optional argument permitted.
+  if (Attr.getNumArgs() > 1) {
+S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
+<< Attr.getName() << 1;
+return;
+  }
+
+  StringRef Str;
+  SourceLocation ArgLoc;
+
+  if (Attr.getNumArgs() == 0)
+Str = "";
+  else if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &ArgLoc))
+return;
+
+
+  // Semantic checks for a function with the 'interrupt' attribute.
+  // a) Must be a function.
+  // b) Must take no arguments.
+  // c) Must have the 'void' return type.
+  // d) C

Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Stephen Canon via cfe-commits
> On Nov 17, 2015, at 4:51 AM, Renato Golin  wrote:
> 
> On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
>  wrote:
>> Author: scanon
>> Date: Mon Nov 16 17:09:11 2015
>> New Revision: 253269
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=253269&view=rev
>> Log:
>> Make FP_CONTRACT ON the default.
>> 
>> Differential Revision: D14200
> 
> Hi Stephen,
> 
> It seems your commit in the blame list is the only one that affects
> AArch64 directly:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388
> 
> I haven't bisected yet, but would be good if you could try those tests
> locally, just to make sure it wasn't your commit, and revert if it
> was, to fix offline.

From a quick glance at the log, most of these appear to be cases where the test 
is incorrectly comparing floating-point results without any tolerance*.  That’s 
a bug in the tests, because the standard allows the expressions to be 
contracted or not by default, which will necessarily cause (usually small, but 
sometimes not) perturbations in the results.

These checks should either have a tolerance or the sources should specify 
#pragma STDC FP_CONTRACT OFF or they should be compiled with -ffp-contract=off.

If we just want things to be green, then I would recommend that these tests use 
-ffp-contract=off until someone has time and inclination to fix them.

– Steve

*linpack-pc has a tolerance, but fpcmp blindly applies it to everything in the 
output file; the error occurs in norm resid which is a normalized error term 
already scaled to the magnitude of the expected error, so the apparently large 
change from 1.6 to 2 is actually utterly inconsequential.

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


Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Renato Golin via cfe-commits" 
> To: "Stephen Canon" 
> Cc: "Clang Commits" 
> Sent: Tuesday, November 17, 2015 3:51:23 AM
> Subject: Re: r253269 - Make FP_CONTRACT ON the default.
> 
> On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
>  wrote:
> > Author: scanon
> > Date: Mon Nov 16 17:09:11 2015
> > New Revision: 253269
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=253269&view=rev
> > Log:
> > Make FP_CONTRACT ON the default.
> >
> > Differential Revision: D14200
> 
> Hi Stephen,
> 
> It seems your commit in the blame list is the only one that affects
> AArch64 directly:
> 
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388
> 
> I haven't bisected yet, but would be good if you could try those
> tests
> locally, just to make sure it wasn't your commit, and revert if it
> was, to fix offline.

The test suite already has logic to add -ffp-contract=off on PowerPC so that we 
can compare to the binary outputs. We may need to do this now for all targets, 
at least until be come up with a better solution.

 -Hal

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

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14744: PR10235: support for vector mode attributes + warning

2015-11-17 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: aaron.ballman.
DmitryPolukhin added a subscriber: cfe-commits.

Add support for vector mode attributes like "__attribute__((mode(V4SF)))". Also 
add warning about deprecated vector modes like GCC does.

http://reviews.llvm.org/D14744

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-mode-vector-types.c

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3215,38 +3215,31 @@
   return true;
 }
 
-/// handleModeAttr - This attribute modifies the width of a decl with primitive
-/// type.
-///
-/// Despite what would be logical, the mode attribute is a decl attribute, not a
-/// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be
-/// HImode, not an intermediate pointer.
-static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  // This attribute isn't documented, but glibc uses it.  It changes
-  // the width of an int or unsigned int to the specified size.
-  if (!Attr.isArgIdent(0)) {
-S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
-  << AANT_ArgumentIdentifier;
-return;
-  }
-  
-  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
-  StringRef Str = Name->getName();
-
-  normalizeName(Str);
-
-  unsigned DestWidth = 0;
-  bool IntegerMode = true;
-  bool ComplexMode = false;
+/// parseModeAttr - Parses attribute mode string and returns parsed type
+/// attribute.
+static void parseModeAttr(Sema &S, StringRef Str, unsigned &DestWidth,
+  bool &IntegerMode, bool &ComplexMode) {
   switch (Str.size()) {
   case 2:
 switch (Str[0]) {
-case 'Q': DestWidth = 8; break;
-case 'H': DestWidth = 16; break;
-case 'S': DestWidth = 32; break;
-case 'D': DestWidth = 64; break;
-case 'X': DestWidth = 96; break;
-case 'T': DestWidth = 128; break;
+case 'Q':
+  DestWidth = 8;
+  break;
+case 'H':
+  DestWidth = 16;
+  break;
+case 'S':
+  DestWidth = 32;
+  break;
+case 'D':
+  DestWidth = 64;
+  break;
+case 'X':
+  DestWidth = 96;
+  break;
+case 'T':
+  DestWidth = 128;
+  break;
 }
 if (Str[1] == 'F') {
   IntegerMode = false;
@@ -3274,6 +3267,50 @@
   DestWidth = S.Context.getTargetInfo().getUnwindWordWidth();
 break;
   }
+}
+
+/// handleModeAttr - This attribute modifies the width of a decl with primitive
+/// type.
+///
+/// Despite what would be logical, the mode attribute is a decl attribute, not a
+/// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be
+/// HImode, not an intermediate pointer.
+static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  // This attribute isn't documented, but glibc uses it.  It changes
+  // the width of an int or unsigned int to the specified size.
+  if (!Attr.isArgIdent(0)) {
+S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
+  << AANT_ArgumentIdentifier;
+return;
+  }
+
+  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
+  StringRef Str = Name->getName();
+
+  normalizeName(Str);
+
+  unsigned DestWidth = 0;
+  bool IntegerMode = true;
+  bool ComplexMode = false;
+  llvm::APInt VectorSize(64, 0);
+  if (Str.size() >= 4 && Str[0] == 'V') {
+// Minimal length of vector mode is 4: 'V' + NUMBER(>=1) + TYPE(>=2).
+int VectorStringLength = 0;
+while (isdigit(Str[VectorStringLength + 1]))
+  ++VectorStringLength;
+if (VectorStringLength &&
+!Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
+VectorSize.isPowerOf2()) {
+  parseModeAttr(S, Str.substr(VectorStringLength + 1), DestWidth,
+IntegerMode, ComplexMode);
+  S.Diag(Attr.getLoc(), diag::warn_vector_mode_deprecated);
+} else {
+  VectorSize = 0;
+}
+  }
+
+  if (!VectorSize)
+parseModeAttr(S, Str, DestWidth, IntegerMode, ComplexMode);
 
   QualType OldTy;
   if (TypedefNameDecl *TD = dyn_cast(D))
@@ -3332,7 +3369,10 @@
   }
 
   QualType NewTy = NewElemTy;
-  if (const VectorType *OldVT = OldTy->getAs()) {
+  if (VectorSize.getBoolValue()) {
+NewTy = S.Context.getVectorType(NewTy, VectorSize.getZExtValue(),
+VectorType::GenericVector);
+  } else if (const VectorType *OldVT = OldTy->getAs()) {
 // Complex machine mode does not support base vector types.
 if (ComplexMode) {
   S.Diag(Attr.getLoc(), diag::err_complex_mode_vector_type);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2761,6 +2761,10 @@
   "mode attribute only supported for integer and floating-point types">;
 def err_mode_

Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Manuel Klimek via cfe-commits
Note that due to this change we're hitting an assert at
lib/CodeGen/CGExprScalar.cpp:2570 in llvm::Value *tryEmitFMulAdd(const
(anonymous namespace)::BinOpInfo &, const clang::CodeGen::CodeGenFunction
&, clang::CodeGen::CGBuilderTy &, bool): LHSBinOp->getNumUses(
) == 0 && "Operations with multiple uses shouldn't be contracted."

Don't have a small repro yet :(

On Tue, Nov 17, 2015 at 1:39 PM Hal Finkel via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> - Original Message -
> > From: "Renato Golin via cfe-commits" 
> > To: "Stephen Canon" 
> > Cc: "Clang Commits" 
> > Sent: Tuesday, November 17, 2015 3:51:23 AM
> > Subject: Re: r253269 - Make FP_CONTRACT ON the default.
> >
> > On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
> >  wrote:
> > > Author: scanon
> > > Date: Mon Nov 16 17:09:11 2015
> > > New Revision: 253269
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=253269&view=rev
> > > Log:
> > > Make FP_CONTRACT ON the default.
> > >
> > > Differential Revision: D14200
> >
> > Hi Stephen,
> >
> > It seems your commit in the blame list is the only one that affects
> > AArch64 directly:
> >
> > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388
> >
> > I haven't bisected yet, but would be good if you could try those
> > tests
> > locally, just to make sure it wasn't your commit, and revert if it
> > was, to fix offline.
>
> The test suite already has logic to add -ffp-contract=off on PowerPC so
> that we can compare to the binary outputs. We may need to do this now for
> all targets, at least until be come up with a better solution.
>
>  -Hal
>
> >
> > cheers,
> > --renato
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14134: [OpenMP] Parsing and sema support for map clause

2015-11-17 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/AST/OpenMPClause.h:2660-2662
@@ +2659,5 @@
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  /// \param N Number of the variables in the clause.
+  ///

Not all important arguments are described


Comment at: include/clang/AST/OpenMPClause.h:2683-2686
@@ +2682,6 @@
+  ///
+  /// \param C AST context.
+  /// \brief StartLoc Starting location of the clause.
+  /// \brief EndLoc Ending location of the clause.
+  /// \param VL List of references to the variables.
+  ///

Not all important arguments are described


Comment at: lib/Basic/OpenMPKinds.cpp:199
@@ +198,3 @@
+  return "unknown";
+#define OPENMP_MAP_KIND(Name)\
+  case OMPC_MAP_##Name:  \

Extra spaces between arg and ')'


Comment at: lib/Sema/SemaOpenMP.cpp:318-342
@@ -310,1 +317,27 @@
+
+  MapInfo getMapInfoForVar(VarDecl *VD) {
+MapInfo Tmp = {0};
+for (auto Cnt = Stack.size() - 1; Cnt > 0; --Cnt) {
+  if (Stack[Cnt].MappedDecls.count(VD)) {
+Tmp = Stack[Cnt].MappedDecls[VD];
+break;
+  }
+}
+return Tmp;
+  }
+
+  void addMapInfoForVar(VarDecl *VD, MapInfo MI) {
+if (Stack.size() > 1) {
+  Stack.back().MappedDecls[VD] = MI;
+}
+  }
+
+  MapInfo IsMappedInCurrentRegion(VarDecl *VD) {
+assert(Stack.size() > 1 && "Target level is 0");
+MapInfo Tmp = {0};
+if (Stack.size() > 1 && Stack.back().MappedDecls.count(VD)) {
+  Tmp = Stack.back().MappedDecls[VD];
+}
+return Tmp;
+  }
 };

Tmp is bad name.


Comment at: test/OpenMP/target_data_ast_print.cpp:1
@@ -1,2 +1,2 @@
 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s

Also add tests for templates, serialization/deserialization


Comment at: test/OpenMP/target_map_messages.cpp:2
@@ +1,3 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+
+void foo() {

Still no tests for templates


http://reviews.llvm.org/D14134



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


Re: [PATCH] D14727: [Driver] Adapt Linux::GCCVersion::Parse to match GCC 5 installations

2015-11-17 Thread Thiago Macieira via cfe-commits
thiagomacieira added a comment.

In http://reviews.llvm.org/D14727#290661, @jroelofs wrote:

> hHave a look at the svn-blame for this file, then find other commits which 
> changed this part of the file, and see where those commits added tests.


Thanks, looks like 189212 has a way to do it.


http://reviews.llvm.org/D14727



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


Re: [PATCH] D14727: [Driver] Adapt Linux::GCCVersion::Parse to match GCC 5 installations

2015-11-17 Thread Thiago Macieira via cfe-commits
thiagomacieira updated this revision to Diff 40370.
thiagomacieira added a comment.

v3: updated to add unit testing


http://reviews.llvm.org/D14727

Files:
  lib/Driver/ToolChains.cpp
  test/Driver/Inputs/gcc_version_parsing5/bin/.keep
  
test/Driver/Inputs/gcc_version_parsing5/lib/gcc/i386-unknown-linux/4.9.2/crtbegin.o
  
test/Driver/Inputs/gcc_version_parsing5/lib/gcc/i386-unknown-linux/5/crtbegin.o
  test/Driver/linux-ld.c

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1230,14 +1230,17 @@
   GCCVersion GoodVersion = {VersionText.str(), -1, -1, -1, "", "", ""};
   if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0)
 return BadVersion;
-  GoodVersion.MajorStr = First.first.str();
+  if (First.second.empty())
+return GoodVersion;
+
   if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 
0)
 return BadVersion;
   GoodVersion.MinorStr = Second.first.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
+  //   5(handled above)
   //   4.4
   //   4.4.0
   //   4.4.x
Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -388,6 +388,15 @@
 // CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-GCC-VERSION4: 
"{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99{{/|}}crtbegin.o"
 // CHECK-GCC-VERSION4: 
"-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing5/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION5 %s
+// CHECK-GCC-VERSION5: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION5: 
"{{.*}}/Inputs/gcc_version_parsing5/bin/../lib/gcc/i386-unknown-linux/5{{/|}}crtbegin.o"
+// CHECK-GCC-VERSION5: 
"-L{{.*}}/Inputs/gcc_version_parsing5/bin/../lib/gcc/i386-unknown-linux/5"
 //
 // Test a simulated installation of libc++ on Linux, both through sysroot and
 // the installation path of Clang.


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1230,14 +1230,17 @@
   GCCVersion GoodVersion = {VersionText.str(), -1, -1, -1, "", "", ""};
   if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0)
 return BadVersion;
-  GoodVersion.MajorStr = First.first.str();
+  if (First.second.empty())
+return GoodVersion;
+
   if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
 return BadVersion;
   GoodVersion.MinorStr = Second.first.str();
 
   // First look for a number prefix and parse that if present. Otherwise just
   // stash the entire patch string in the suffix, and leave the number
   // unspecified. This covers versions strings such as:
+  //   5(handled above)
   //   4.4
   //   4.4.0
   //   4.4.x
Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -388,6 +388,15 @@
 // CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99{{/|}}crtbegin.o"
 // CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=i386-unknown-linux -m32 \
+// RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing5/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-GCC-VERSION5 %s
+// CHECK-GCC-VERSION5: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-GCC-VERSION5: "{{.*}}/Inputs/gcc_version_parsing5/bin/../lib/gcc/i386-unknown-linux/5{{/|}}crtbegin.o"
+// CHECK-GCC-VERSION5: "-L{{.*}}/Inputs/gcc_version_parsing5/bin/../lib/gcc/i386-unknown-linux/5"
 //
 // Test a simulated installation of libc++ on Linux, both through sysroot and
 // the installation path of Clang.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D10802: [mips] Interrupt attribute support.

2015-11-17 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:255
@@ -254,1 +254,3 @@
 def err_parameter_name_omitted : Error<"parameter name omitted">;
+def err_excess_arguments : Error<"function %0 has too many arguments">;
+def err_wrong_return_type : Error<"function %0 does not have the \'void\' 
return type">;

I would combine these, and name the result so that it is obvious it relates to 
the MIPS interrupt attribute. This can then become: "MIPS 'interrupt' attribute 
only applies to functions %select{with no parameters|a 'void' return type}0" 
Generally speaking, we make these warnings instead of errors (though the choice 
is obviously yours), and add them to the IgnoredAttributes group (so you warn, 
and then never attach the attribute to the declaration).


Comment at: lib/Sema/SemaDeclAttr.cpp:4441
@@ +4440,3 @@
+
+  DeclarationName Name = D->getAsFunction()->getNameInfo().getName();
+

No need for this; you can pass any NamedDecl * into Diag() and it will get 
quoted and displayed properly. Since you've already checked that it's a 
function or method, you can simply use cast(D) when needed.


Comment at: lib/Sema/SemaDeclAttr.cpp:4448
@@ +4447,3 @@
+
+  if (!(getFunctionOrMethodResultType(D)->isVoidType())) {
+S.Diag(D->getLocation(), diag::err_wrong_return_type) << Name;

No need for the extra set of parens.


Comment at: lib/Sema/SemaDeclAttr.cpp:4453
@@ +4452,3 @@
+
+  if (D->hasAttr()) {
+S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible)

Please use checkAttrMutualExclusion() instead. Also, you need to add a similar 
check to the Mips16 attribute handler to ensure the mutual exclusion is 
properly checked. Should have semantic test cases for both orderings:
```
__attribute__((mips16)) __attribute__((interrupt)) void f();
__attribute__((interrupt)) __attribute__((mips16)) void g();
```
What about the nomips16 attribute? Should this be mutually exclusive as well?


http://reviews.llvm.org/D10802



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


Re: [PATCH] D13731: [Analyzer] Supporting function attributes in .model files.

2015-11-17 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

Ping!


http://reviews.llvm.org/D13731



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


Re: [PATCH] D14506: Porting shouldVisitImplicitCode to DataRecursiveASTVisitor.

2015-11-17 Thread Craig, Ben via cfe-commits
Looks good to me.  I'm not too worried about the compactness of the 
visitor class.


On 11/16/2015 7:10 PM, Richard Smith wrote:
Attached patch makes RAV fully data-recursive when visiting 
statements, except in cases where the derived class could tell the 
difference (when it falls back to a normal recursive walk). The queue 
representation is slightly less compact than before: instead of 
storing a child iterator, we now store a list of all children. This 
allows us to handle any Stmt subclass that we can traverse, not just 
those ones that finish by traversing all their children in the usual 
order.


Thoughts?

On Mon, Nov 16, 2015 at 2:28 PM, Craig, Ben via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:


I'm fine with this approach.  How about I leave the file in place,
but replace the contents with a "using DataRecursiveASTVisitor =
RecursiveASTVisitor;" and see what breaks?  That way I won't need
to go through a large retrofit.


On 11/16/2015 3:28 PM, Richard Smith wrote:

Rather than trying to maintain the horrible duplication between
DataRecursiveASTVisitor and RecursiveASTVisitor, can we just
delete DataRecursiveASTVisitor? RecursiveASTVisitor is
data-recursive too these days (and has a smarter implementation
than DataRecursiveASTVisitor's from what I can see), but doesn't
yet apply data recursion in so many cases.

On Mon, Nov 16, 2015 at 1:07 PM, Argyrios Kyrtzidis
mailto:akyr...@gmail.com>> wrote:

LGTM.

> On Nov 16, 2015, at 12:32 PM, Ben Craig
mailto:ben.cr...@codeaurora.org>>
wrote:
>
> bcraig added a comment.
>
> Ping.  Note that the test is basically a copy / paste job,
and the new code in DataRecursiveASTVisitor.h is a very
direct translation from the 'regular' RecursiveASTVisitor.h.
>
>
> http://reviews.llvm.org/D14506
>
>
>




-- 
Employee of Qualcomm Innovation Center, Inc.

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project


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




--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


r253337 - Revert "Make FP_CONTRACT ON the default."

2015-11-17 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Nov 17 09:40:10 2015
New Revision: 253337

URL: http://llvm.org/viewvc/llvm-project?rev=253337&view=rev
Log:
Revert "Make FP_CONTRACT ON the default."

This reverts commit r253269.

This leads to assert / segfault triggering on the following reduced example:
float foo(float U, float base, float cell) { return (U = 2 * base) - cell; }

Removed:
cfe/trunk/test/CodeGen/aarch64-scalar-fma.c
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/aarch64-neon-fma.c
cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=253337&r1=253336&r2=253337&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Nov 17 09:40:10 2015
@@ -187,7 +187,7 @@ BENIGN_LANGOPT(DebuggerObjCLiteral , 1,
 BENIGN_LANGOPT(SpellChecking , 1, 1, "spell-checking")
 LANGOPT(SinglePrecisionConstants , 1, 0, "treating double-precision floating 
point constants as single precision constants")
 LANGOPT(FastRelaxedMath , 1, 0, "OpenCL fast relaxed math")
-LANGOPT(DefaultFPContract , 1, 1, "FP_CONTRACT")
+LANGOPT(DefaultFPContract , 1, 0, "FP_CONTRACT")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")
 LANGOPT(HexagonQdsp6Compat , 1, 0, "hexagon-qdsp6 backward compatibility")
 LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting")

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=253337&r1=253336&r2=253337&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Nov 17 09:40:10 2015
@@ -1336,6 +1336,7 @@ void CompilerInvocation::setLangDefaults
 Opts.ZVector = 0;
 Opts.CXXOperatorNames = 1;
 Opts.LaxVectorConversions = 0;
+Opts.DefaultFPContract = 1;
 Opts.NativeHalfType = 1;
   }
 

Modified: cfe/trunk/test/CodeGen/aarch64-neon-fma.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-fma.c?rev=253337&r1=253336&r2=253337&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-fma.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-fma.c Tue Nov 17 09:40:10 2015
@@ -1,8 +1,5 @@
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -O3 \
-// RUN:   -ffp-contract=off -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -O3 \
-// RUN:   -o - %s | FileCheck -check-prefix=CHECK-FMA %s
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon -S -O3 
-o - %s | FileCheck %s
 
 // Test new aarch64 intrinsics and types
 
@@ -13,7 +10,8 @@ float32x2_t test_vmla_n_f32(float32x2_t
   return vmla_n_f32(a, b, c);
   // CHECK: fmul {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.s[0]
   // CHECK: fadd {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.2s
-  // CHECK-FMA: fmla {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.s[0]
+  // CHECK-FMA: dup {{v[0-9]+}}.2s, {{v[0-9]+}}.s[0]
+  // CHECK-FMA: fmla {{v[0-9]+}}.2s, {{v[0-9]+}}.2s, {{v[0-9]+}}.2s
 }
 
 float32x4_t test_vmlaq_n_f32(float32x4_t a, float32x4_t b, float32_t c) {
@@ -21,7 +19,8 @@ float32x4_t test_vmlaq_n_f32(float32x4_t
   return vmlaq_n_f32(a, b, c);
   // CHECK: fmul {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.s[0]
   // CHECK: fadd {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.4s
-  // CHECK-FMA: fmla {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.s[0]
+  // CHECK-FMA: dup {{v[0-9]+}}.4s, {{v[0-9]+}}.s[0]
+  // CHECK-FMA: fmla {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.4s
 }
 
 float64x2_t test_vmlaq_n_f64(float64x2_t a, float64x2_t b, float64_t c) {
@@ -29,7 +28,8 @@ float64x2_t test_vmlaq_n_f64(float64x2_t
   return vmlaq_n_f64(a, b, c);
   // CHECK: fmul {{v[0-9]+}}.2d, {{v[0-9]+}}.2d, {{v[0-9]+}}.d[0]
   // CHECK: fadd {{v[0-9]+}}.2d, {{v[0-9]+}}.2d, {{v[0-9]+}}.2d
-  // CHECK-FMA: fmla {{v[0-9]+}}.2d, {{v[0-9]+}}.2d, {{v[0-9]+}}.d[0]
+  // CHECK-FMA: dup {{v[0-9]+}}.2d, {{v[0-9]+}}.d[0]
+  // CHECK-FMA: fmla {{v[0-9]+}}.2d, {{v[0-9]+}}.2d, {{v[0-9]+}}.2d
 }
 
 float32x4_t test_vmlsq_n_f32(float32x4_t a, float32x4_t b, float32_t c) {
@@ -37,7 +37,8 @@ float32x4_t test_vmlsq_n_f32(float32x4_t
   return vmlsq_n_f32(a, b, c);
   // CHECK: fmul {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.s[0]
   // CHECK: fsub {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.4s
-  // CHECK-FMA: fmls {{v[0-9]+}}.4s, {{v[0-9]+}}.4s, {{v[0-9]+}}.s[0]
+  // CHECK-FMA: dup {{v[0-9]+}}.4s, {{v[0

Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Manuel Klimek via cfe-commits
Repro:
float foo(float U, float base, float cell) { return (U = 2 * base) - cell; }
Preparing rollback of the CL.

On Tue, Nov 17, 2015 at 2:46 PM Manuel Klimek  wrote:

> Note that due to this change we're hitting an assert at
> lib/CodeGen/CGExprScalar.cpp:2570 in llvm::Value *tryEmitFMulAdd(const
> (anonymous namespace)::BinOpInfo &, const clang::CodeGen::CodeGenFunction
> &, clang::CodeGen::CGBuilderTy &, bool): LHSBinOp->getNumUses(
> ) == 0 && "Operations with multiple uses shouldn't be contracted."
>
> Don't have a small repro yet :(
>
> On Tue, Nov 17, 2015 at 1:39 PM Hal Finkel via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> - Original Message -
>> > From: "Renato Golin via cfe-commits" 
>> > To: "Stephen Canon" 
>> > Cc: "Clang Commits" 
>> > Sent: Tuesday, November 17, 2015 3:51:23 AM
>> > Subject: Re: r253269 - Make FP_CONTRACT ON the default.
>> >
>> > On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
>> >  wrote:
>> > > Author: scanon
>> > > Date: Mon Nov 16 17:09:11 2015
>> > > New Revision: 253269
>> > >
>> > > URL: http://llvm.org/viewvc/llvm-project?rev=253269&view=rev
>> > > Log:
>> > > Make FP_CONTRACT ON the default.
>> > >
>> > > Differential Revision: D14200
>> >
>> > Hi Stephen,
>> >
>> > It seems your commit in the blame list is the only one that affects
>> > AArch64 directly:
>> >
>> > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388
>> >
>> > I haven't bisected yet, but would be good if you could try those
>> > tests
>> > locally, just to make sure it wasn't your commit, and revert if it
>> > was, to fix offline.
>>
>> The test suite already has logic to add -ffp-contract=off on PowerPC so
>> that we can compare to the binary outputs. We may need to do this now for
>> all targets, at least until be come up with a better solution.
>>
>>  -Hal
>>
>> >
>> > cheers,
>> > --renato
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> >
>>
>> --
>> Hal Finkel
>> Assistant Computational Scientist
>> Leadership Computing Facility
>> Argonne National Laboratory
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Manuel Klimek via cfe-commits
Reverted in r253337. Failing test case in commit message.

On Tue, Nov 17, 2015 at 4:39 PM Manuel Klimek  wrote:

> Repro:
> float foo(float U, float base, float cell) { return (U = 2 * base) - cell;
> }
> Preparing rollback of the CL.
>
> On Tue, Nov 17, 2015 at 2:46 PM Manuel Klimek  wrote:
>
>> Note that due to this change we're hitting an assert at
>> lib/CodeGen/CGExprScalar.cpp:2570 in llvm::Value *tryEmitFMulAdd(const
>> (anonymous namespace)::BinOpInfo &, const clang::CodeGen::CodeGenFunction
>> &, clang::CodeGen::CGBuilderTy &, bool): LHSBinOp->getNumUses(
>> ) == 0 && "Operations with multiple uses shouldn't be contracted."
>>
>> Don't have a small repro yet :(
>>
>> On Tue, Nov 17, 2015 at 1:39 PM Hal Finkel via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> - Original Message -
>>> > From: "Renato Golin via cfe-commits" 
>>> > To: "Stephen Canon" 
>>> > Cc: "Clang Commits" 
>>> > Sent: Tuesday, November 17, 2015 3:51:23 AM
>>> > Subject: Re: r253269 - Make FP_CONTRACT ON the default.
>>> >
>>> > On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
>>> >  wrote:
>>> > > Author: scanon
>>> > > Date: Mon Nov 16 17:09:11 2015
>>> > > New Revision: 253269
>>> > >
>>> > > URL: http://llvm.org/viewvc/llvm-project?rev=253269&view=rev
>>> > > Log:
>>> > > Make FP_CONTRACT ON the default.
>>> > >
>>> > > Differential Revision: D14200
>>> >
>>> > Hi Stephen,
>>> >
>>> > It seems your commit in the blame list is the only one that affects
>>> > AArch64 directly:
>>> >
>>> >
>>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388
>>> >
>>> > I haven't bisected yet, but would be good if you could try those
>>> > tests
>>> > locally, just to make sure it wasn't your commit, and revert if it
>>> > was, to fix offline.
>>>
>>> The test suite already has logic to add -ffp-contract=off on PowerPC so
>>> that we can compare to the binary outputs. We may need to do this now for
>>> all targets, at least until be come up with a better solution.
>>>
>>>  -Hal
>>>
>>> >
>>> > cheers,
>>> > --renato
>>> > ___
>>> > cfe-commits mailing list
>>> > cfe-commits@lists.llvm.org
>>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>> >
>>>
>>> --
>>> Hal Finkel
>>> Assistant Computational Scientist
>>> Leadership Computing Facility
>>> Argonne National Laboratory
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14748: bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Hans Wennborg via cfe-commits
hans created this revision.
hans added reviewers: thakis, echristo.
hans added a subscriber: cfe-commits.

The tzcnt intrinsics are used non non-BMI targets by code (e.g. ffmpeg) that 
uses it as a potentially faster BSF.

The TZCNT instruction is special in that it's encoded in a backward-compatible 
way and behaves as BSF on non-BMI targets.

http://reviews.llvm.org/D14748

Files:
  lib/Headers/bmiintrin.h

Index: lib/Headers/bmiintrin.h
===
--- lib/Headers/bmiintrin.h
+++ lib/Headers/bmiintrin.h
@@ -39,7 +39,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("bmi")))
 
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
+/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
+   instruction behaves as BSF on non-BMI targets, there is code that expects
+   to use it as a potentially faster version of BSF. */
+#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __X ? __builtin_ctzs(__X) : 16;
@@ -83,7 +88,7 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
+static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
@@ -136,14 +141,15 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __X ? __builtin_ctzll(__X) : 64;
 }
 
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __RELAXED_FN_ATTRS
 
 #endif /* __BMIINTRIN_H */


Index: lib/Headers/bmiintrin.h
===
--- lib/Headers/bmiintrin.h
+++ lib/Headers/bmiintrin.h
@@ -39,7 +39,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
 
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
+/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
+   instruction behaves as BSF on non-BMI targets, there is code that expects
+   to use it as a potentially faster version of BSF. */
+#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __X ? __builtin_ctzs(__X) : 16;
@@ -83,7 +88,7 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
+static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
@@ -136,14 +141,15 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __X ? __builtin_ctzll(__X) : 64;
 }
 
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __RELAXED_FN_ATTRS
 
 #endif /* __BMIINTRIN_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r253350 - Add trivial utility to append -L arguments to linker step. NFC

2015-11-17 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Nov 17 11:41:23 2015
New Revision: 253350

URL: http://llvm.org/viewvc/llvm-project?rev=253350&view=rev
Log:
Add trivial utility to append -L arguments to linker step. NFC

Modified:
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=253350&r1=253349&r2=253350&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Nov 17 11:41:23 2015
@@ -377,6 +377,10 @@ public:
   virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
 
+  /// AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
+  void AddFilePathLibArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const;
+
   /// AddCCKextLibArgs - Add the system specific linker arguments to use
   /// for kernel extensions (Darwin-specific).
   virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args,

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=253350&r1=253349&r2=253350&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Nov 17 11:41:23 2015
@@ -616,6 +616,12 @@ void ToolChain::AddCXXStdlibLibArgs(cons
   }
 }
 
+void ToolChain::AddFilePathLibArgs(const ArgList &Args,
+   ArgStringList &CmdArgs) const {
+  for (const auto &LibPath : getFilePaths())
+CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+}
+
 void ToolChain::AddCCKextLibArgs(const ArgList &Args,
  ArgStringList &CmdArgs) const {
   CmdArgs.push_back("-lcc_kext");

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253350&r1=253349&r2=253350&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Nov 17 11:41:23 2015
@@ -6153,9 +6153,7 @@ constructHexagonLinkArgs(Compilation &C,
   
//
   // Library Search Paths
   
//
-  const ToolChain::path_list &LibPaths = ToolChain.getFilePaths();
-  for (const auto &LibPath : LibPaths)
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   
//
   //
@@ -6525,9 +6523,7 @@ void cloudabi::Linker::ConstructJob(Comp
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  const ToolChain::path_list &Paths = ToolChain.getFilePaths();
-  for (const auto &Path : Paths)
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs,
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
@@ -7127,9 +7123,7 @@ void solaris::Linker::ConstructJob(Compi
 Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
   }
 
-  const ToolChain::path_list &Paths = getToolChain().getFilePaths();
-  for (const auto &Path : Paths)
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));
+  getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_r});
@@ -7674,9 +7668,7 @@ void freebsd::Linker::ConstructJob(Compi
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  const ToolChain::path_list &Paths = ToolChain.getFilePaths();
-  for (const auto &Path : Paths)
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_e);
   Args.AddAllArgs(CmdArgs, options::OPT_s);
@@ -8567,10 +8559,7 @@ void gnutools::Linker::ConstructJob(Comp
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   Args.AddAllArgs(CmdArgs, options::OPT_u);
 
-  const ToolChain::path_list &Paths = ToolChain.getFilePaths();
-
-  for (const auto &Path : Paths)
-CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + Path));
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 
   if (D.isUsingLTO())
 AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin);
@@ -8771,10 

Re: [PATCH] D14744: PR10235: support for vector mode attributes + warning

2015-11-17 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I am a little bit confused -- this patch adds a deprecation warning for vector 
sizes and claims that the attribute is ignored (by placing it in the 
IgnoredAttributes group), but then provides the initial implementation for this 
functionality and makes use of the attribute. If it's deprecated, why implement 
the behavior? Better to say "we recognize this attribute and won't explode on 
it, but do not implement the functionality since it is deprecated."



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2765
@@ +2764,3 @@
+def warn_vector_mode_deprecated : Warning<
+  "specifying vector types with __attribute__ ((mode)) is deprecated, "
+  "use __attribute__ ((vector_size)) instead">,

How about:

"'mode' attribute is not supported for vector types; use the 'vector_size' 
attribute instead"


http://reviews.llvm.org/D14744



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


r253355 - ARM: fix mismatch between Clang and backend on exception type.

2015-11-17 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Nov 17 12:27:27 2015
New Revision: 253355

URL: http://llvm.org/viewvc/llvm-project?rev=253355&view=rev
Log:
ARM: fix mismatch between Clang and backend on exception type.

"-arch armv7k" is only normally used with a watchos target, but Clang doesn't
stop you from giving a "-miphoneos-version-min" option too, converting the
triple to "thumbv7k-apple-ios". In this case the backend will decide to use
SjLj exceptions, so Clang needs to agree so it can create the correct
predefines.

Fortunately, there's a handy function to make the decision for us now.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/arch-armv7k.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253355&r1=253354&r2=253355&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Nov 17 12:27:27 2015
@@ -1053,12 +1053,8 @@ bool Darwin::UseSjLjExceptions(const Arg
   getTriple().getArch() != llvm::Triple::thumb)
 return false;
 
-  // We can't check directly for watchOS here. ComputeLLVMTriple only
-  // fills in the ArchName correctly.
-  llvm::Triple Triple(ComputeLLVMTriple(Args));
-  return !(Triple.getArchName() == "armv7k" ||
-   Triple.getArchName() == "thumbv7k");
-
+  // Only watchOS uses the new DWARF/Compact unwinding method.
+  return !isTargetWatchOS();
 }
 
 bool MachO::isPICDefault() const { return true; }

Modified: cfe/trunk/test/Driver/arch-armv7k.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arch-armv7k.c?rev=253355&r1=253354&r2=253355&view=diff
==
--- cfe/trunk/test/Driver/arch-armv7k.c (original)
+++ cfe/trunk/test/Driver/arch-armv7k.c Tue Nov 17 12:27:27 2015
@@ -1,5 +1,13 @@
-// Tests that make sure armv7k is mapped to the correct CPU
+// Tests that make sure armv7k is mapped to the correct CPU and ABI choices
 
 // RUN: %clang -target x86_64-apple-macosx10.9 -arch armv7k -c %s -### 2>&1 | 
FileCheck %s
 // CHECK: "-cc1"{{.*}} "-target-cpu" "cortex-a7"
 // CHECK-NOT: "-fsjlj-exceptions"
+
+// "thumbv7k-apple-ios" is a bit of a weird triple, but since the backend is
+// going to choose to use sjlj-based exceptions for it, the front-end needs to
+// match.
+
+// RUN: %clang -target x86_64-apple-macosx10.9 -arch armv7k 
-miphoneos-version-min=9.0 -c %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SJLJ
+// CHECK-SJLJ: "-cc1"{{.*}} "-target-cpu" "cortex-a7"
+// CHECK-SJLJ: "-fsjlj-exceptions"


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


Re: [PATCH] D13263: Addition of __attribute__((pass_object_size)) to Clang

2015-11-17 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/Sema/SemaDeclAttr.cpp:829
@@ +828,3 @@
+  if (Type > 3) {
+S.Diag(E->getLocStart(), diag::err_attribute_argument_outof_range)
+  << Attr.getName() << 0 << 3 << E->getSourceRange();

>> I'm wondering why the magic value 3 at all? It seems like this (and the 
>> above code) should be replaced by a call to 
>> checkFunctionOrMethodParameterIndex().
> Marking this as done because checkFunctionOrMethodParameterIndex doesn't seem 
> to accomplish our goal.
>
>> There should be comments explaining the magic number 3.
> The docs for pass_object_size(N) state that N is passed as the second 
> parameter to __builtin_object_size, which means that N must be in the range 
> [0, 3]. I'll add a comment, but given your other comment, it looks like there 
> may have been a miscommunication about the purpose of pass_object_size's 
> argument. :)

Ah, yes, I was confused. This isn't checking that the number matches a 
parameter index. :-)


http://reviews.llvm.org/D13263



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


Re: [PATCH] D14748: bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Nico Weber via cfe-commits
thakis added a comment.

Looks good. The reasoning is that without this, projects will put in an `#if 
__clang__ no tzcnt` path (e.g. 
http://ffmpeg.org/pipermail/ffmpeg-devel/2015-November/183408.html), and with 
this patch they won't and in a few years when people use build flags that allow 
BMI instructions, we'll magically start doing the fast thing.

(This is Eric's thing, but he sounded fine with this approach on IRC yesterday.)


http://reviews.llvm.org/D14748



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


Re: [PATCH] D14748: bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Sounds good to me. Weird, but fine :)

-eric


http://reviews.llvm.org/D14748



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


r253358 - bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Nov 17 12:46:48 2015
New Revision: 253358

URL: http://llvm.org/viewvc/llvm-project?rev=253358&view=rev
Log:
bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

The tzcnt intrinsics are used non non-BMI targets by code (e.g. ffmpeg)
that uses it as a potentially faster BSF.

The TZCNT instruction is special in that it's encoded in a
backward-compatible way and behaves as BSF on non-BMI targets.

Differential Revision: http://reviews.llvm.org/D14748

Modified:
cfe/trunk/lib/Headers/bmiintrin.h

Modified: cfe/trunk/lib/Headers/bmiintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/bmiintrin.h?rev=253358&r1=253357&r2=253358&view=diff
==
--- cfe/trunk/lib/Headers/bmiintrin.h (original)
+++ cfe/trunk/lib/Headers/bmiintrin.h Tue Nov 17 12:46:48 2015
@@ -39,7 +39,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("bmi")))
 
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
+/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
+   instruction behaves as BSF on non-BMI targets, there is code that expects
+   to use it as a potentially faster version of BSF. */
+#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __X ? __builtin_ctzs(__X) : 16;
@@ -83,7 +88,7 @@ __blsr_u32(unsigned int __X)
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
+static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
@@ -136,7 +141,7 @@ __blsr_u64(unsigned long long __X)
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __X ? __builtin_ctzll(__X) : 64;
@@ -145,5 +150,6 @@ __tzcnt_u64(unsigned long long __X)
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __RELAXED_FN_ATTRS
 
 #endif /* __BMIINTRIN_H */


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


Re: [PATCH] D14748: bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Hans Wennborg via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253358: bmiintrin.h: Allow using the tzcnt intrinsics for 
non-BMI targets (authored by hans).

Changed prior to commit:
  http://reviews.llvm.org/D14748?vs=40399&id=40411#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14748

Files:
  cfe/trunk/lib/Headers/bmiintrin.h

Index: cfe/trunk/lib/Headers/bmiintrin.h
===
--- cfe/trunk/lib/Headers/bmiintrin.h
+++ cfe/trunk/lib/Headers/bmiintrin.h
@@ -39,7 +39,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("bmi")))
 
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
+/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
+   instruction behaves as BSF on non-BMI targets, there is code that expects
+   to use it as a potentially faster version of BSF. */
+#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __X ? __builtin_ctzs(__X) : 16;
@@ -83,7 +88,7 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
+static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
@@ -136,14 +141,15 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __X ? __builtin_ctzll(__X) : 64;
 }
 
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __RELAXED_FN_ATTRS
 
 #endif /* __BMIINTRIN_H */


Index: cfe/trunk/lib/Headers/bmiintrin.h
===
--- cfe/trunk/lib/Headers/bmiintrin.h
+++ cfe/trunk/lib/Headers/bmiintrin.h
@@ -39,7 +39,12 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
 
-static __inline__ unsigned short __DEFAULT_FN_ATTRS
+/* Allow using the tzcnt intrinsics even for non-BMI targets. Since the TZCNT
+   instruction behaves as BSF on non-BMI targets, there is code that expects
+   to use it as a potentially faster version of BSF. */
+#define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
+
+static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __X ? __builtin_ctzs(__X) : 16;
@@ -83,7 +88,7 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned int __DEFAULT_FN_ATTRS
+static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __X ? __builtin_ctz(__X) : 32;
@@ -136,14 +141,15 @@
   return __X & (__X - 1);
 }
 
-static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __X ? __builtin_ctzll(__X) : 64;
 }
 
 #endif /* __x86_64__ */
 
 #undef __DEFAULT_FN_ATTRS
+#undef __RELAXED_FN_ATTRS
 
 #endif /* __BMIINTRIN_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r253269 - Make FP_CONTRACT ON the default.

2015-11-17 Thread Renato Golin via cfe-commits
On 17 November 2015 at 15:47, Manuel Klimek  wrote:
> Reverted in r253337. Failing test case in commit message.

And the bot is green again! :)

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


Re: [PATCH] D14744: PR10235: support for vector mode attributes + warning

2015-11-17 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Thank you for prompt response!



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2765
@@ +2764,3 @@
+def warn_vector_mode_deprecated : Warning<
+  "specifying vector types with __attribute__ ((mode)) is deprecated, "
+  "use __attribute__ ((vector_size)) instead">,

aaron.ballman wrote:
> How about:
> 
> "'mode' attribute is not supported for vector types; use the 'vector_size' 
> attribute instead"
Both GCC and ICC support vector types in mode attribute with similar warning so 
for compatibility reasons it is better to implement it. Taking into account 
that detection of vector types is more than half of supporting them. I do agree 
that warning group is confusing. I was not able to find more suitable warning 
group so would you recommend to create new one for this warning?


http://reviews.llvm.org/D14744



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


Re: [PATCH] D14744: PR10235: support for vector mode attributes + warning

2015-11-17 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2765
@@ +2764,3 @@
+def warn_vector_mode_deprecated : Warning<
+  "specifying vector types with __attribute__ ((mode)) is deprecated, "
+  "use __attribute__ ((vector_size)) instead">,

DmitryPolukhin wrote:
> aaron.ballman wrote:
> > How about:
> > 
> > "'mode' attribute is not supported for vector types; use the 'vector_size' 
> > attribute instead"
> Both GCC and ICC support vector types in mode attribute with similar warning 
> so for compatibility reasons it is better to implement it. Taking into 
> account that detection of vector types is more than half of supporting them. 
> I do agree that warning group is confusing. I was not able to find more 
> suitable warning group so would you recommend to create new one for this 
> warning?
Are there headers from major library vendors that rely on supporting this 
feature? If not, then I would say it's probably better to simply not implement 
the diagnostic and fail to support such constructs at all. If it is used by 
major vendors and would prevent otherwise functional code from working, then 
this approach is reasonable. In that case, I would add a new diagnostic group 
(DeprecatedAttributes and add it to the Deprecated group).


http://reviews.llvm.org/D14744



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


Re: [PATCH] D14748: bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Craig Topper via cfe-commits
craig.topper added a subscriber: craig.topper.
craig.topper added a comment.

The summary of why this is ok is slightly misleading. The backend won't try to 
encode the TZCNT instruction when the BMI feature is not enabled. Notice this 
just maps the to the generic non-x86 specific __builtin_ctz. The backend will 
emit a regular BSF instruction if BMI is not supported. There will be a zero 
check around it unless the backend can prove that the input is not 0.


Repository:
  rL LLVM

http://reviews.llvm.org/D14748



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


Re: [PATCH] D14748: bmiintrin.h: Allow using the tzcnt intrinsics for non-BMI targets

2015-11-17 Thread Nico Weber via cfe-commits
On Tue, Nov 17, 2015 at 11:32 AM, Craig Topper 
wrote:

> craig.topper added a subscriber: craig.topper.
> craig.topper added a comment.
>
> The summary of why this is ok is slightly misleading.


I read this as reason why programs might try to use this, not why this
change here is correct. (This change is ok as it has an explicit 0 check as
you say, so it'll only be efficient once you target machines with BMI)


> The backend won't try to encode the TZCNT instruction when the BMI feature
> is not enabled. Notice this just maps the to the generic non-x86 specific
> __builtin_ctz. The backend will emit a regular BSF instruction if BMI is
> not supported. There will be a zero check around it unless the backend can
> prove that the input is not 0.
>
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D14748
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r253371 - [Lit Test] Updated 34 Lit tests to be C++11 compatible.

2015-11-17 Thread Charles Li via cfe-commits
Author: lcharles
Date: Tue Nov 17 14:25:05 2015
New Revision: 253371

URL: http://llvm.org/viewvc/llvm-project?rev=253371&view=rev
Log:
[Lit Test] Updated 34 Lit tests to be C++11 compatible.

Added expected diagnostics new to C++11.
Expanded RUN line to: default, C++98/03 and C++11.

Modified:
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp

cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
cfe/trunk/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
cfe/trunk/test/CXX/temp/temp.param/p3.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
cfe/trunk/test/OpenMP/for_reduction_messages.cpp
cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp
cfe/trunk/test/OpenMP/sections_reduction_messages.cpp
cfe/trunk/test/OpenMP/simd_reduction_messages.cpp
cfe/trunk/test/OpenMP/teams_reduction_messages.cpp
cfe/trunk/test/SemaCXX/constructor-initializer.cpp
cfe/trunk/test/SemaCXX/converting-constructor.cpp
cfe/trunk/test/SemaCXX/crashes.cpp
cfe/trunk/test/SemaCXX/default1.cpp
cfe/trunk/test/SemaCXX/direct-initializer.cpp
cfe/trunk/test/SemaCXX/expressions.cpp
cfe/trunk/test/SemaCXX/namespace.cpp
cfe/trunk/test/SemaCXX/overload-call-copycon.cpp
cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
cfe/trunk/test/SemaCXX/vector.cpp
cfe/trunk/test/SemaTemplate/class-template-ctor-initializer.cpp
cfe/trunk/test/SemaTemplate/constructor-template.cpp
cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
cfe/trunk/test/SemaTemplate/fun-template-def.cpp
cfe/trunk/test/SemaTemplate/qualified-names-diag.cpp

Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp?rev=253371&r1=253370&r2=253371&view=diff
==
--- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp (original)
+++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp Tue Nov 17 
14:25:05 2015
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 namespace A {
   class A {
@@ -20,6 +22,9 @@ namespace D {
 
 namespace C {
   class C {}; // expected-note {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'B::B' to 'const C::C &' for 
1st argument}}
+#if __cplusplus >= 201103L // C++11 or later
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) 
not viable: no known conversion from 'B::B' to 'C::C &&' for 1st argument}}
+#endif
   void func(C); // expected-note {{'C::func' declared here}} \
 // expected-note {{passing argument to parameter here}}
   C operator+(C,C);

Modified: 
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp?rev=253371&r1=253370&r2=253371&view=diff
==
--- 
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp 
(original)
+++ 
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp 
Tue Nov 17 14:25:05 2015
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 namespace Ints {
   int zero = 0; // expected-note {{candidate found by name lookup is 
'Ints::zero'}}
@@ -31,7 +33,11 @@ void test() {
 }
 
 namespace Numbers {
-  struct Number {  // expected-note 2 {{candidate}}
+  struct Number { // expected-note 2 {{candidate constructor (the implicit 
copy constructor) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+  // expected-note@-2 2 {{candidate constructor (the implicit move 
constructor) not viable}}
+#endif
+
 explicit Number(double d) : d(d) {}
 double d;
   };
@@ -66,7 +72,11 @@ void test3() {
 
 namespace inline_ns {
   int x; // expected-note 2{{found}}
-  inline namespace A { // expected-warning {{C++11}}
+  inline namespace A {
+#if __cplusplus <= 199711L // C++03 or earlier
+  //

r253372 - Use !hasArg with two options instead of !hasArg && !hasArg.

2015-11-17 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Nov 17 14:28:07 2015
New Revision: 253372

URL: http://llvm.org/viewvc/llvm-project?rev=253372&view=rev
Log:
Use !hasArg with two options instead of !hasArg && !hasArg.

Thereby fixing a warning about failure to claim all args.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/nostdlib.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253372&r1=253371&r2=253372&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Nov 17 14:28:07 2015
@@ -6516,8 +6516,7 @@ void cloudabi::Linker::ConstructJob(Comp
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
   }
@@ -6533,16 +6532,14 @@ void cloudabi::Linker::ConstructJob(Comp
 
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (D.CCCIsCXX())
   ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
 CmdArgs.push_back("-lc");
 CmdArgs.push_back("-lcompiler_rt");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nostartfiles))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
@@ -6889,8 +6886,7 @@ void darwin::Linker::ConstructJob(Compil
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nostartfiles))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
 getMachOToolChain().addStartObjectFileArgs(Args, CmdArgs);
 
   // SafeStack requires its own runtime libraries
@@ -6922,12 +6918,11 @@ void darwin::Linker::ConstructJob(Compil
 InputFileList.push_back(II.getFilename());
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 addOpenMPRuntime(CmdArgs, getToolChain(), Args);
 
-  if (isObjCRuntimeLinked(Args) && !Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
+  if (isObjCRuntimeLinked(Args) &&
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 // We use arclite library for both ARC and subscripting support.
 getMachOToolChain().AddLinkARCArgs(Args, CmdArgs);
 
@@ -6948,8 +6943,7 @@ void darwin::Linker::ConstructJob(Compil
 
   getMachOToolChain().addProfileRTLibs(Args, CmdArgs);
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (getToolChain().getDriver().CCCIsCXX())
   getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
 
@@ -6959,8 +6953,7 @@ void darwin::Linker::ConstructJob(Compil
 getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
 // endfile_spec is empty.
   }
 
@@ -6971,8 +6964,7 @@ void darwin::Linker::ConstructJob(Compil
   for (const Arg *A : Args.filtered(options::OPT_iframework))
 CmdArgs.push_back(Args.MakeArgString(std::string("-F") + A->getValue()));
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
 if (Arg *A = Args.getLastArg(options::OPT_fveclib)) {
   if (A->getValue() == StringRef("Accelerate")) {
 CmdArgs.push_back("-framework");
@@ -7083,8 +7075,7 @@ void solaris::Linker::ConstructJob(Compi
   // Demangle C++ names in errors
   CmdArgs.push_back("-C");
 
-  if ((!Args.hasArg(options::OPT_nostdlib)) &&
-  (!Args.hasArg(options::OPT_shared))) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_shared)) {
 CmdArgs.push_back("-e");
 CmdArgs.push_back("_start");
   }
@@ -7110,8 +7101,7 @@ void solaris::Linker::ConstructJob(Compi
 assert(Output.isNothing() && "Invalid output.");
   }
 
-  if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
 if (!Args.hasArg(options::OPT_shared))
  

Re: [PATCH] D9600: Add scan-build python implementation

2015-11-17 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist added a comment.

In http://reviews.llvm.org/D9600#290031, @jroelofs wrote:

> Thanks for re-uploading!


thanks for your comments! :)

most of your comments are about to embed it more into the clang build, test 
infrastructure. i think these are valid points!

i would like to have these code in the repository first and to do -the work 
you've proposed- afterwards. i might need help for some of those too. (like 
using lint to run python unit tests.)


http://reviews.llvm.org/D9600



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


[libcxx] r253376 - Add tests for the extended integer types - as required by LWG#2119

2015-11-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Nov 17 15:04:24 2015
New Revision: 253376

URL: http://llvm.org/viewvc/llvm-project?rev=253376&view=rev
Log:
Add tests for the extended integer types - as required by LWG#2119

Modified:

libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp?rev=253376&r1=253375&r2=253376&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/unord.hash/integral.pass.cpp 
Tue Nov 17 15:04:24 2015
@@ -57,4 +57,44 @@ int main()
 test();
 test();
 test();
+
+// LWG #2119
+test();
+test();
+
+   test();
+   test();
+   test();
+   test();
+   
+   test();
+   test();
+   test();
+   test();
+
+   test();
+   test();
+   test();
+   test();
+
+test();
+test();
+   
+   test();
+   test();
+   test();
+   test();
+   
+   test();
+   test();
+   test();
+   test();
+
+   test();
+   test();
+   test();
+   test();
+
+test();
+test();
 }


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


[PATCH] D14754: [Myriad]: insert -L paths into linker cmd only when they exist.

2015-11-17 Thread Douglas Katzman via cfe-commits
dougk created this revision.
dougk added a reviewer: jyknight.
dougk added a subscriber: cfe-commits.
Herald added a subscriber: jyknight.

http://reviews.llvm.org/D14754

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtend.o
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crti.o
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtn.o
  test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o

Index: test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o
===
--- /dev/null
+++ test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o
@@ -0,0 +1 @@
+ 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9910,10 +9910,6 @@
   bool UseDefaultLibs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
 
-  std::string StartFilesDir, BuiltinLibDir;
-  TC.getCompilerSupportDir(StartFilesDir);
-  TC.getBuiltinLibDir(BuiltinLibDir);
-
   if (T.getArch() == llvm::Triple::sparc)
 CmdArgs.push_back("-EB");
   else // SHAVE assumes little-endian, and sparcel is expressly so.
@@ -9937,19 +9933,15 @@
   if (UseStartfiles) {
 // If you want startfiles, it means you want the builtin crti and crtbegin,
 // but not crt0. Myriad link commands provide their own crt0.o as needed.
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crti.o"));
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtbegin.o"));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crti.o")));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtbegin.o")));
   }
 
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
-  // The linker doesn't use these builtin paths unless directed to,
-  // because it was not compiled for support with sysroots, nor does
-  // it have a default of little-endian with FPU.
-  CmdArgs.push_back(Args.MakeArgString("-L" + BuiltinLibDir));
-  CmdArgs.push_back(Args.MakeArgString("-L" + StartFilesDir));
+  TC.AddFilePathLibArgs(Args, CmdArgs);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
 
@@ -9969,8 +9961,8 @@
 CmdArgs.push_back("-lgcc");
   }
   if (UseStartfiles) {
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtend.o"));
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtn.o"));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtn.o")));
   }
 
   std::string Exec =
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1062,8 +1062,6 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
   Tool *SelectTool(const JobAction &JA) const override;
-  void getCompilerSupportDir(std::string &Dir) const;
-  void getBuiltinLibDir(std::string &Dir) const;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
 protected:
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4313,7 +4313,27 @@
   case llvm::Triple::shave:
 GCCInstallation.init(Triple, Args, {"sparc-myriad-elf"});
   }
-}
+
+  // The contents of LibDir are independent of the version of gcc.
+  // This contains libc, libg (a superset of libc), libm, libstdc++, libssp.
+  SmallString<128> LibDir(GCCInstallation.getParentLibPath());
+  if (Triple.getArch() == llvm::Triple::sparcel)
+llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib/le");
+  else
+llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib");
+  if (getVFS().exists(LibDir))
+getFilePaths().push_back(LibDir.str());
+
+  // This directory contains crt{i,n,begin,end}.o as well as libgcc.
+  // These files are tied to a particular version of gcc.
+  SmallString<128> CompilerSupportDir(GCCInstallation.getInstallPath());
+  // There are actually 4 choices: {le,be} x {fpu,nofpu}
+  // but as this toolchain is for LEON sparc, it can assume FPU.
+  if (Triple.getArch() == llvm::Triple::sparcel)
+llvm::sys::path::append(CompilerSupportDir, "le");
+  if (getVFS().exists(CompilerSupportDir))
+getFilePaths().push_back(CompilerSupportDir.str());
+ }
 
 MyriadToolChain::~MyriadToolChain() {}
 
@@ -4359,27 +4379,6 @@
   }
 }
 
-void MyriadToolChain::getCompilerSupportDir(std::string &Dir) const {
-  // This directory contains crt{i,n,begin,end}.o as well as libgcc.
-  // These files are tied to a particular version of gcc.
-  SmallString<128

Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-17 Thread Pete Cooper via cfe-commits
pete updated this revision to Diff 40426.
pete added a comment.

Updated the driver test to ensure that the option is set for tvOS and watchOS.


http://reviews.llvm.org/D14737

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Basic/ObjCRuntime.h
  include/clang/Driver/Options.td
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/Driver/objc-convert-messages-to-runtime-calls.m

Index: test/Driver/objc-convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/Driver/objc-convert-messages-to-runtime-calls.m
@@ -0,0 +1,21 @@
+// RUN: %clang %s -### -o %t.o 2>&1 -fobjc-convert-messages-to-runtime-calls -fsyntax-only -fno-objc-convert-messages-to-runtime-calls -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=DISABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fobjc-convert-messages-to-runtime-calls -fsyntax-only -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=ENABLE
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target x86_64-apple-macosx10.10.0 | FileCheck  %s --check-prefix=SUPPORTED_MACOS
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target x86_64-apple-macosx10.9.0 | FileCheck  %s --check-prefix=UNSUPPORTED_MACOS
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target armv7-apple-ios8.0 | FileCheck  %s --check-prefix=SUPPORTED_IOS
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target armv7-apple-ios7.0 | FileCheck  %s --check-prefix=UNSUPPORTED_IOS
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target arm64-apple-tvos9.0 | FileCheck  %s --check-prefix=SUPPORTED_TVOS
+// RUN: %clang %s -### -o %t.o 2>&1 -fsyntax-only -target armv7k-apple-watchos2.0 | FileCheck  %s --check-prefix=SUPPORTED_WATCHOS
+
+// Check that we pass fobjc-convert-messages-to-runtime-calls only when supported, and not explicitly disabled.
+
+// DISABLE-NOT: "-fobjc-convert-messages-to-runtime-calls"
+// ENABLE: "-fobjc-convert-messages-to-runtime-calls"
+// SUPPORTED_MACOS: "-fobjc-convert-messages-to-runtime-calls"
+// UNSUPPORTED_MACOS-NOT: "-fobjc-convert-messages-to-runtime-calls"
+// SUPPORTED_IOS: "-fobjc-convert-messages-to-runtime-calls"
+// UNSUPPORTED_IOS-NOT: "-fobjc-convert-messages-to-runtime-calls"
+// SUPPORTED_TVOS: "-fobjc-convert-messages-to-runtime-calls"
+// SUPPORTED_WATCHOS: "-fobjc-convert-messages-to-runtime-calls"
+
+
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- /dev/null
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=MSGS
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -emit-llvm -o - %s -fobjc-convert-messages-to-runtime-calls | FileCheck %s --check-prefix=CALLS
+
+@interface NSObject
++ (id)alloc;
++ (id)alloc2;
+- (id)init;
+- (id)retain;
+- (void)release;
+- (id)autorelease;
+@end
+
+@interface NSString : NSObject
+@end
+
+// CHECK-LABEL: define {{.*}}void @test1
+void test1(id x) {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_alloc}}
+  // CALLS: {{call.*@objc_retain}}
+  // CALLS: {{call.*@objc_release}}
+  // CALLS: {{call.*@objc_autorelease}}
+  [NSObject alloc];
+  [x retain];
+  [x release];
+  [x autorelease];
+}
+
+// CHECK-LABEL: define {{.*}}void @test2
+void test2() {
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // Make sure alloc has the correct name and number of types.
+  [NSObject alloc2];
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1519,6 +1519,9 @@
 if (Args.hasArg(OPT_fobjc_subscripting_legacy_runtime))
   Opts.ObjCSubscriptingLegacyRuntime =
 (Opts.ObjCRuntime.getKind() == ObjCRuntime::FragileMacOSX);
+
+if (Args.hasArg(OPT_fobjc_convert_messages_to_runtime_calls))
+  Opts.ObjCConvertMessagesToRuntimeCalls = 1;
   }
 
   if (Args.hasArg(OPT_fgnu89_inline)) {
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4842,6 +4842,15 @@
 
   }
 
+  // Allow the user to control whether messages can be converted to runtime
+  // functions.
+  if (types::isObjC(InputType) &&
+  Args.hasFlag(options::OPT_fobjc_convert_messages_to_runtime_calls,
+   options::OPT_fno_objc_convert_messages_to_runtime_calls,
+   true) &&
+  objcRuntime.shouldUseARCFunctionsForRetainRelease())
+CmdArgs.push_back("-fobjc-

Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-17 Thread John McCall via cfe-commits
rjmccall added inline comments.


Comment at: include/clang/Basic/LangOptions.def:194
@@ -193,2 +193,3 @@
 LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated reference counting")
+LANGOPT(ObjCConvertMessagesToRuntimeCalls , 1, 0, "objc_* support for 
retain/release in the runtime")
 LANGOPT(ObjCWeakRuntime , 1, 0, "__weak support in the ARC runtime")

I think this can just be a code-gen option.

Also, please use the description "Replace certain message sends with calls to 
ObjC runtime entrypoints".


Comment at: include/clang/Basic/ObjCRuntime.h:179
@@ +178,3 @@
+  /// the runtime are aware of custom retain/release methods and so can send
+  /// the message if required, but otherwise are able to take a fast-path.
+  bool shouldUseARCFunctionsForRetainRelease() const {

This isn't really an appropriate comment.  Please use:

  Does this runtime provide ARC entrypoints that are likely to be faster than
  an ordinary message send of the appropriate selector?

  The ARC entrypoints are guaranteed to be equivalent to just sending the
  corresponding message.  If the entrypoint is implemented naively as just a
  message send, using it is a trade-off: it sacrifices a few cycles of overhead
  to save a small amount of code.  However, it's possible for runtimes to detect
  and special-case classes that use "standard" retain/release behavior; if 
that's
  dynamically a large proportion of all retained objects, using the entrypoint 
will
  also be faster than using a message send.

  When this method returns true, Clang will turn non-super message sends of
  certain selectors into calls to the correspond entrypoint:
retain => objc_retain
release => objc_release


Comment at: include/clang/Basic/ObjCRuntime.h:182
@@ +181,3 @@
+switch (getKind()) {
+case FragileMacOSX: return false;
+case MacOSX: return getVersion() >= VersionTuple(10, 10);

Would you mind asking our runtime folks about the fragile runtime?  We do 
provide these entrypoints there.


Comment at: lib/CodeGen/CGObjCMac.cpp:1871
@@ +1870,3 @@
+  // Call runtime methods directly if we can.
+  if (Method && CGM.getLangOpts().ObjCConvertMessagesToRuntimeCalls) {
+switch (Method->getMethodFamily()) {

Hmm.  It would be better if you could implement this in CGObjC instead of 
CGObjCMac so that it automatically works on all runtimes.

Also, you need to gate this on !IsSuper.  Please add a test for that case.


Comment at: lib/CodeGen/CGObjCMac.cpp:1876
@@ +1875,3 @@
+// are identified as OMF_alloc but we only want to call the runtime for
+// this version.
+Selector S = Method->getSelector();

You really ought to have a separate query on the runtime for whether this is 
okay, since objc_alloc isn't one of the standard ARC entrypoints.

I'm not sure what that ends up meaning for the code-gen option.  It makes sense 
to just have one command-line option: we should have the target's default rules 
for rewriting message sends, there should be a runtime option to suppress it 
for people who need to (e.g. because they're writing a runtime), end of story.  
Maybe what you should do is have the driver pass down the suppression option, 
if indeed it was provided last, and then have the frontend enable stuff based 
on the target runtime if the suppression option wasn't given; that is, 
-fno-objc-X would be the -cc1 flag, not -fobjc-X.


Comment at: test/CodeGenObjC/convert-messages-to-runtime-calls.m:38
@@ +37,2 @@
+  [NSObject alloc2];
+}

You should also test that sending "alloc" with a dynamic receiver work.  This 
includes something like [self alloc] in a class method. 


http://reviews.llvm.org/D14737



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


Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-17 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

@rengolin: Gentle ping.

Cheers,

- Asiri


http://reviews.llvm.org/D14293



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


[libcxx] r253382 - Fix bad variable name. project_root -> project_obj_root

2015-11-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Nov 17 15:48:29 2015
New Revision: 253382

URL: http://llvm.org/viewvc/llvm-project?rev=253382&view=rev
Log:
Fix bad variable name. project_root -> project_obj_root

Modified:
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=253382&r1=253381&r2=253382&view=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Tue Nov 17 15:48:29 2015
@@ -202,7 +202,7 @@ class Configuration(object):
 if os.path.isdir(possible_root):
 self.libcxx_obj_root = possible_root
 else:
-self.libcxx_obj_root = self.project_root
+self.libcxx_obj_root = self.project_obj_root
 
 def configure_cxx_library_root(self):
 self.cxx_library_root = self.get_lit_conf('cxx_library_root',


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


[PATCH] D14756: Handle ARMv6-J as an alias, instead of fake architecture

2015-11-17 Thread A. Skrobov via cfe-commits
tyomitch created this revision.
tyomitch added reviewers: rengolin, bogden, compnerd.
tyomitch added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Clang-side update, corresponding to D14755

http://reviews.llvm.org/D14756

Files:
  test/Driver/arm-cortex-cpus.c

Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -57,11 +57,11 @@
 
 // FIXME %clang -target armv6j -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J %s
 // RUN: %clang -target arm -march=armv6j -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J %s
-// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6j -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J-THUMB %s
 // RUN: %clang -target arm -march=armv6j -mthumb -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6J-THUMB %s
-// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" 
"arm1136j-s"
+// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" 
"arm1136jf-s"
 
 // FIXME %clang -target armv6z -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6Z %s
 // FIXME %clang -target arm -march=armv6z -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-V6Z %s


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -57,11 +57,11 @@
 
 // FIXME %clang -target armv6j -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J %s
 // RUN: %clang -target arm -march=armv6j -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J %s
-// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J: "-cc1"{{.*}} "-triple" "armv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6j -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J-THUMB %s
 // RUN: %clang -target arm -march=armv6j -mthumb -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6J-THUMB %s
-// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" "arm1136j-s"
+// CHECK-V6J-THUMB: "-cc1"{{.*}} "-triple" "thumbv6-{{.*}} "-target-cpu" "arm1136jf-s"
 
 // FIXME %clang -target armv6z -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6Z %s
 // FIXME %clang -target arm -march=armv6z -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V6Z %s
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r253386 - [CUDA] added include paths for both sides of CUDA compilation.

2015-11-17 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Nov 17 16:28:46 2015
New Revision: 253386

URL: http://llvm.org/viewvc/llvm-project?rev=253386&view=rev
Log:
[CUDA] added include paths for both sides of CUDA compilation.

In order to compile a CUDA file clang must be able to find
include files for both both host and device.

This patch passes AuxToolchain to AddPreprocessingOptions and
uses it to add include paths for the opposite side of compilation.

We also must be able to find CUDA include files. If the driver
found CUDA installation, it adds appropriate include path
to CUDA headers. This can be disabled with '-nocudainc'.

- Added include paths for the opposite side of compilation.
- Added include paths to detected CUDA installation.
- Added -nocudainc to prevent adding CUDA include path.
- Added test cases to verify new functionality.

Differential Revision: http://reviews.llvm.org/D13170

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=253386&r1=253385&r2=253386&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Nov 17 16:28:46 2015
@@ -1596,6 +1596,7 @@ def no_pedantic : Flag<["-", "--"], "no-
 def no__dead__strip__inits__and__terms : Flag<["-"], 
"no_dead_strip_inits_and_terms">;
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>,
   HelpText<"Disable builtin #include directories">;
+def nocudainc : Flag<["-"], "nocudainc">;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=253386&r1=253385&r2=253386&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Nov 17 16:28:46 2015
@@ -397,6 +397,10 @@ public:
   virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const;
 
+  /// \brief Add arguments to use system-specific CUDA includes.
+  virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const;
+
   /// \brief Return sanitizers which are available in this toolchain.
   virtual SanitizerMask getSupportedSanitizers() const;
 };

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=253386&r1=253385&r2=253386&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Nov 17 16:28:46 2015
@@ -662,3 +662,6 @@ SanitizerMask ToolChain::getSupportedSan
 Res |= CFIICall;
   return Res;
 }
+
+void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {}

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253386&r1=253385&r2=253386&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Nov 17 16:28:46 2015
@@ -4104,6 +4104,15 @@ void Linux::AddClangCXXStdlibIncludeArgs
   }
 }
 
+void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {
+  if (DriverArgs.hasArg(options::OPT_nocudainc))
+return;
+
+  if (CudaInstallation.isValid())
+addSystemInclude(DriverArgs, CC1Args, CudaInstallation.getIncludePath());
+}
+
 bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask Linux::getSupportedSanitizers() const {

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253386&r1=253385&r2=253386&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov 17 16:28:46 2015
@@ -784,6 +784,8 @@ public:
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCudaIncludeArgs(const llvm::op

r253387 - [CUDA] Detect and link with CUDA's libdevice bitcode library.

2015-11-17 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Nov 17 16:28:50 2015
New Revision: 253387

URL: http://llvm.org/viewvc/llvm-project?rev=253387&view=rev
Log:
[CUDA] Detect and link with CUDA's libdevice bitcode library.

- added detection of libdevice bitcode file and API to find one appropriate for 
the GPU we're compiling for.
- pass additional cc1 options for linking with detected libdevice bitcode
- added -nocudalib to prevent automatic linking with libdevice
- added test cases to verify new functionality

Differential Revision: http://reviews.llvm.org/D14556

Added:

cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
  - copied, changed from r253386, 
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/.keep

cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_35.10.bc
  - copied, changed from r253386, 
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/.keep
Removed:
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/.keep
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=253387&r1=253386&r2=253387&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Nov 17 16:28:50 2015
@@ -1597,6 +1597,7 @@ def no__dead__strip__inits__and__terms :
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
+def nocudalib : Flag<["-"], "nocudalib">;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253387&r1=253386&r2=253387&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Nov 17 16:28:50 2015
@@ -1647,6 +1647,31 @@ void Generic_GCC::CudaInstallationDetect
   D.getVFS().exists(CudaLibDevicePath)))
   continue;
 
+std::error_code EC;
+for (llvm::sys::fs::directory_iterator LI(CudaLibDevicePath, EC), LE;
+ !EC && LI != LE; LI = LI.increment(EC)) {
+  StringRef FilePath = LI->path();
+  StringRef FileName = llvm::sys::path::filename(FilePath);
+  // Process all bitcode filenames that look like 
libdevice.compute_XX.YY.bc
+  const StringRef LibDeviceName = "libdevice.";
+  if (!(FileName.startswith(LibDeviceName) && FileName.endswith(".bc")))
+continue;
+  StringRef GpuArch = FileName.slice(
+  LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
+  CudaLibDeviceMap[GpuArch] = FilePath.str();
+  // Insert map entries for specifc devices with this compute capability.
+  if (GpuArch == "compute_20") {
+CudaLibDeviceMap["sm_20"] = FilePath;
+CudaLibDeviceMap["sm_21"] = FilePath;
+  } else if (GpuArch == "compute_30") {
+CudaLibDeviceMap["sm_30"] = FilePath;
+CudaLibDeviceMap["sm_32"] = FilePath;
+  } else if (GpuArch == "compute_35") {
+CudaLibDeviceMap["sm_35"] = FilePath;
+CudaLibDeviceMap["sm_37"] = FilePath;
+  }
+}
+
 IsValid = true;
 break;
   }
@@ -4195,6 +4220,22 @@ CudaToolChain::addClangTargetOptions(con
  llvm::opt::ArgStringList &CC1Args) const {
   Linux::addClangTargetOptions(DriverArgs, CC1Args);
   CC1Args.push_back("-fcuda-is-device");
+
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
+  std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(
+  DriverArgs.getLastArgValue(options::OPT_march_EQ));
+  if (!LibDeviceFile.empty()) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
+
+// Libdevice in CUDA-7.0 requires PTX version that's more recent
+// than LLVM defaults to. Use PTX4.2 which is the PTX version that
+// came with CUDA-7.0.
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+ptx42");
+  }
 }
 
 llvm::opt::DerivedArgList *

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253387&r1=253386&r2=253387&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov 17 16:28:50 2015
@@ -166,6 +166,7 @@ protected:
 std::string CudaLibPath;
  

r253385 - [CUDA] use -aux-triple to pass target triple of opposite side of compilation

2015-11-17 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Nov 17 16:28:40 2015
New Revision: 253385

URL: http://llvm.org/viewvc/llvm-project?rev=253385&view=rev
Log:
[CUDA] use -aux-triple to pass target triple of opposite side of compilation

Clang needs to know target triple for both sides of compilation so that
preprocessor macros and target builtins from both sides are available.

This change augments Compilation class to carry information about
toolchains used during different CUDA compilation passes and refactors
BuildActions to use it when it constructs CUDA jobs.

Removed DeviceTriple from CudaHostAction/CudaDeviceAction as it's no
longer needed.

Differential Revision: http://reviews.llvm.org/D13144

Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/include/clang/Driver/Compilation.h
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cuda-options.cu
cfe/trunk/test/SemaCUDA/function-target-hd.cu

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=253385&r1=253384&r2=253385&view=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Tue Nov 17 16:28:40 2015
@@ -139,17 +139,15 @@ class CudaDeviceAction : public Action {
   virtual void anchor();
   /// GPU architecture to bind -- e.g 'sm_35'.
   const char *GpuArchName;
-  const char *DeviceTriple;
   /// True when action results are not consumed by the host action (e.g when
   /// -fsyntax-only or --cuda-device-only options are used).
   bool AtTopLevel;
 
 public:
   CudaDeviceAction(std::unique_ptr Input, const char *ArchName,
-   const char *DeviceTriple, bool AtTopLevel);
+   bool AtTopLevel);
 
   const char *getGpuArchName() const { return GpuArchName; }
-  const char *getDeviceTriple() const { return DeviceTriple; }
   bool isAtTopLevel() const { return AtTopLevel; }
 
   static bool classof(const Action *A) {
@@ -160,16 +158,13 @@ public:
 class CudaHostAction : public Action {
   virtual void anchor();
   ActionList DeviceActions;
-  const char *DeviceTriple;
 
 public:
-  CudaHostAction(std::unique_ptr Input, const ActionList 
&DeviceActions,
- const char *DeviceTriple);
+  CudaHostAction(std::unique_ptr Input,
+ const ActionList &DeviceActions);
   ~CudaHostAction() override;
 
-  ActionList &getDeviceActions() { return DeviceActions; }
   const ActionList &getDeviceActions() const { return DeviceActions; }
-  const char *getDeviceTriple() const { return DeviceTriple; }
 
   static bool classof(const Action *A) { return A->getKind() == CudaHostClass; 
}
 };

Modified: cfe/trunk/include/clang/Driver/Compilation.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=253385&r1=253384&r2=253385&view=diff
==
--- cfe/trunk/include/clang/Driver/Compilation.h (original)
+++ cfe/trunk/include/clang/Driver/Compilation.h Tue Nov 17 16:28:40 2015
@@ -38,6 +38,9 @@ class Compilation {
   /// The default tool chain.
   const ToolChain &DefaultToolChain;
 
+  const ToolChain *CudaHostToolChain;
+  const ToolChain *CudaDeviceToolChain;
+
   /// The original (untranslated) input argument list.
   llvm::opt::InputArgList *Args;
 
@@ -81,6 +84,17 @@ public:
   const Driver &getDriver() const { return TheDriver; }
 
   const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
+  const ToolChain *getCudaHostToolChain() const { return CudaHostToolChain; }
+  const ToolChain *getCudaDeviceToolChain() const {
+return CudaDeviceToolChain;
+  }
+
+  void setCudaHostToolChain(const ToolChain *HostToolChain) {
+CudaHostToolChain = HostToolChain;
+  }
+  void setCudaDeviceToolChain(const ToolChain *DeviceToolChain) {
+CudaDeviceToolChain = DeviceToolChain;
+  }
 
   const llvm::opt::InputArgList &getInputArgs() const { return *Args; }
 

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=253385&r1=253384&r2=253385&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Nov 17 16:28:40 2015
@@ -297,22 +297,23 @@ public:
   /// BuildActions - Construct the list of actions to perform for the
   /// given arguments, which are only done for a single architecture.
   ///
+  /// \param C - The compilation that is being built.
   /// \param TC - The default host tool chain.
   /// \param Args - The input arguments.
   /// \param Actions - The list to store the resulting actions onto.
-  void Buil

Re: [PATCH] D13144: [CUDA] propagate to CUDA sub-compilations target triple of opposite side.

2015-11-17 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253385: [CUDA] use -aux-triple to pass target triple of 
opposite side of compilation (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D13144?vs=40163&id=40432#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13144

Files:
  cfe/trunk/include/clang/Driver/Action.h
  cfe/trunk/include/clang/Driver/Compilation.h
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Action.cpp
  cfe/trunk/lib/Driver/Compilation.cpp
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cuda-options.cu
  cfe/trunk/test/SemaCUDA/function-target-hd.cu

Index: cfe/trunk/test/SemaCUDA/function-target-hd.cu
===
--- cfe/trunk/test/SemaCUDA/function-target-hd.cu
+++ cfe/trunk/test/SemaCUDA/function-target-hd.cu
@@ -8,9 +8,9 @@
 // host device functions are not allowed to call device functions.
 
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -triple nvptx-unknown-cuda -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fcuda-allow-host-calls-from-host-device -verify %s -DTEST_WARN_HD
-// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -fcuda-allow-host-calls-from-host-device -verify %s -DTEST_WARN_HD
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -triple nvptx-unknown-cuda -fcuda-allow-host-calls-from-host-device -verify %s -DTEST_WARN_HD
 
 #include "Inputs/cuda.h"
 
Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -111,14 +111,6 @@
 // Make sure we don't link anything.
 // RUN:   -check-prefix CUDA-NL %s
 
-// Match device-side preprocessor, and compiler phases with -save-temps
-// CUDA-D1S: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
-// CUDA-D1S-SAME: "-fcuda-is-device"
-// CUDA-D1S-SAME: "-x" "cuda"
-// CUDA-D1S: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
-// CUDA-D1S-SAME: "-fcuda-is-device"
-// CUDA-D1S-SAME: "-x" "cuda-cpp-output"
-
 // --cuda-host-only should never trigger unused arg warning.
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-host-only -c %s 2>&1 | \
 // RUN:FileCheck -check-prefix CUDA-NO-UNUSED-CHO %s
@@ -133,34 +125,47 @@
 // RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only -x c -c %s 2>&1 | \
 // RUN:FileCheck -check-prefix CUDA-UNUSED-CDO %s
 
+// Match device-side preprocessor, and compiler phases with -save-temps
+// CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
+// CUDA-D1S-SAME: "-fcuda-is-device"
+// CUDA-D1S-SAME: "-x" "cuda"
+
+// CUDA-D1S: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// CUDA-D1S-SAME: "-aux-triple" "x86_64--linux-gnu"
+// CUDA-D1S-SAME: "-fcuda-is-device"
+// CUDA-D1S-SAME: "-x" "cuda-cpp-output"
+
 // Match the job that produces PTX assembly
-// CUDA-D1: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
+// CUDA-D1: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// CUDA-D1NS-SAME: "-aux-triple" "x86_64--linux-gnu"
 // CUDA-D1-SAME: "-fcuda-is-device"
 // CUDA-D1-SM35-SAME: "-target-cpu" "sm_35"
 // CUDA-D1-SAME: "-o" "[[GPUBINARY1:[^"]*]]"
 // CUDA-D1NS-SAME: "-x" "cuda"
 // CUDA-D1S-SAME: "-x" "ir"
 
-// Match anothe device-side compilation
-// CUDA-D2: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
+// Match another device-side compilation
+// CUDA-D2: "-cc1" "-triple" "nvptx64-nvidia-cuda"
+// CUDA-D2-SAME: "-aux-triple" "x86_64--linux-gnu"
 // CUDA-D2-SAME: "-fcuda-is-device"
 // CUDA-D2-SM30-SAME: "-target-cpu" "sm_30"
 // CUDA-D2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
 // CUDA-D2-SAME: "-x" "cuda"
 
 // Match no device-side compilation
-// CUDA-ND-NOT: "-cc1" "-triple" "nvptx{{(64)?}}-nvidia-cuda"
+// CUDA-ND-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // CUDA-ND-SAME-NOT: "-fcuda-is-device"
 
 // Match host-side preprocessor job with -save-temps
-// CUDA-HS: "-cc1" "-triple"
-// CUDA-HS-SAME-NOT: "nvptx{{(64)?}}-nvidia-cuda"
+// CUDA-HS: "-cc1" "-triple" "x86_64--linux-gnu"
+// CUDA-HS-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
 // CUDA-HS-SAME-NOT: "-fcuda-is-device"
 // CUDA-HS-SAME: "-x" "cuda"
 
 // Match host-side compilation
-// CUDA-H: "-cc1" "-triple"
-// CUDA-H-SAME-NOT: "nvptx{{(64)?}}-nvidia-cuda"
+// CUDA-H: "-cc1" "-triple" "x86_64--linux-gnu"
+// CUDA-H-SAME: "-aux-triple" "nvptx64-nvidia-cuda"
 // CUDA-H-SAME-NOT: "-fcuda-is-device"
 // CUDA-H-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
 // CUDA-HNS-SAME: "-x" "cuda"
Index: cfe/trunk/lib/Driver/Compilation.cpp
===
--- cfe/trunk/lib/Driver/Compilation.cpp
+++ cfe/trunk/lib/Driver/Compilation.cpp
@@ -24,8 +24,9 @@
 
 Compilation::Compilation(const Driver &D, const ToolChain &_DefaultToolChain,
  

Re: [PATCH] D13170: [CUDA] Driver changes to pass flags needed to use detected CUDA installation.

2015-11-17 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253386: [CUDA] added include paths for both sides of CUDA 
compilation. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D13170?vs=39860&id=40433#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13170

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Driver/ToolChain.h
  cfe/trunk/lib/Driver/ToolChain.cpp
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/lib/Driver/ToolChain.cpp
===
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -662,3 +662,6 @@
 Res |= CFIICall;
   return Res;
 }
+
+void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {}
Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -784,6 +784,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -57,7 +57,8 @@
const Driver &D, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const InputInfo &Output,
-   const InputInfoList &Inputs) const;
+   const InputInfoList &Inputs,
+   const ToolChain *AuxToolChain) const;
 
   void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -4104,6 +4104,15 @@
   }
 }
 
+void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
+   ArgStringList &CC1Args) const {
+  if (DriverArgs.hasArg(options::OPT_nocudainc))
+return;
+
+  if (CudaInstallation.isValid())
+addSystemInclude(DriverArgs, CC1Args, CudaInstallation.getIncludePath());
+}
+
 bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
 
 SanitizerMask Linux::getSupportedSanitizers() const {
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -278,7 +278,8 @@
 const Driver &D, const ArgList &Args,
 ArgStringList &CmdArgs,
 const InputInfo &Output,
-const InputInfoList &Inputs) const {
+const InputInfoList &Inputs,
+const ToolChain *AuxToolChain) const {
   Arg *A;
 
   CheckPreprocessingOptions(D, Args);
@@ -470,12 +471,26 @@
   // OBJCPLUS_INCLUDE_PATH - system includes enabled when compiling ObjC++.
   addDirectoryList(Args, CmdArgs, "-objcxx-isystem", "OBJCPLUS_INCLUDE_PATH");
 
+  // Optional AuxToolChain indicates that we need to include headers
+  // for more than one target. If that's the case, add include paths
+  // from AuxToolChain right after include paths of the same kind for
+  // the current target.
+
   // Add C++ include arguments, if needed.
-  if (types::isCXX(Inputs[0].getType()))
+  if (types::isCXX(Inputs[0].getType())) {
 getToolChain().AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+if (AuxToolChain)
+  AuxToolChain->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+  }
 
   // Add system include arguments.
   getToolChain().AddClangSystemIncludeArgs(Args, CmdArgs);
+  if (AuxToolChain)
+  AuxToolChain->AddClangCXXStdlibIncludeArgs(Args, CmdArgs);
+
+  // Add CUDA include arguments, if needed.
+  if (types::isCuda(Inputs[0].getType()))
+getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 }
 
 // FIXME: Move to target hook.
@@ -3262,12 +3277,12 @@
   CmdArgs.push_back("-triple");
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
 
+  const ToolChain *AuxToolChain = nullptr;
   if (IsCuda) {
 // FIXME: We need a (better) way 

Re: [PATCH] D14754: [Myriad]: insert -L paths into linker cmd only when they exist.

2015-11-17 Thread James Y Knight via cfe-commits
jyknight added inline comments.


Comment at: lib/Driver/ToolChains.cpp:4319
@@ +4318,3 @@
+  // This contains libc, libg (a superset of libc), libm, libstdc++, libssp.
+  SmallString<128> LibDir(GCCInstallation.getParentLibPath());
+  if (Triple.getArch() == llvm::Triple::sparcel)

Should check GCCInstallation.isValid() before doing any of this.


Comment at: lib/Driver/ToolChains.cpp:4324
@@ +4323,3 @@
+llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib");
+  if (getVFS().exists(LibDir))
+getFilePaths().push_back(LibDir.str());

addPathIfExists instead of if/push_back.


http://reviews.llvm.org/D14754



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


r253388 - [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-11-17 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Nov 17 16:28:52 2015
New Revision: 253388

URL: http://llvm.org/viewvc/llvm-project?rev=253388&view=rev
Log:
[CUDA] Added a wrapper header for inclusion of stock CUDA headers.

Header files that come with CUDA are assuming split host/device
compilation and are not usable by clang out of the box.
With a bit of preprocessor magic it's possible to twist them
into something clang can use.

This wrapper always includes CUDA headers exactly the same way during
host and device compilation passes and produces identical preprocessed
content during host and device side compilation for sm_35 GPUs. Device
compilation passes for older GPUs will see a smaller subset of device
functions supported by particular GPU.

The wrapper assumes specific contents of CUDA header files and works
only with CUDA 7.0 and 7.5.

Differential Revision: http://reviews.llvm.org/D13171

Added:
cfe/trunk/lib/Headers/cuda_runtime.h
Modified:
cfe/trunk/lib/Headers/CMakeLists.txt

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=253388&r1=253387&r2=253388&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue Nov 17 16:28:52 2015
@@ -17,6 +17,7 @@ set(files
   bmiintrin.h
   cpuid.h
   cuda_builtin_vars.h
+  cuda_runtime.h
   emmintrin.h
   f16cintrin.h
   float.h

Added: cfe/trunk/lib/Headers/cuda_runtime.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/cuda_runtime.h?rev=253388&view=auto
==
--- cfe/trunk/lib/Headers/cuda_runtime.h (added)
+++ cfe/trunk/lib/Headers/cuda_runtime.h Tue Nov 17 16:28:52 2015
@@ -0,0 +1,179 @@
+/*=== cuda_runtime.h - CUDA runtime support ===
+ *
+ * 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.
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_CUDA_RUNTIME_H__
+#define __CLANG_CUDA_RUNTIME_H__
+
+#if defined(__CUDA__) && defined(__clang__)
+
+// Include some standard headers to avoid CUDA headers including them
+// while some required macros (like __THROW) are in a weird state.
+#include 
+
+// Preserve common macros that will be changed below by us or by CUDA
+// headers.
+#pragma push_macro("__THROW")
+#pragma push_macro("__CUDA_ARCH__")
+
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.x headers and are expected to break with
+// any other version of CUDA headers.
+#include "cuda.h"
+#if !defined(CUDA_VERSION)
+#error "cuda.h did not define CUDA_VERSION"
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 7050
+#error "Unsupported CUDA version!"
+#endif
+
+// Make largest subset of device functions available during host
+// compilation -- SM_35 for the time being.
+#ifndef __CUDA_ARCH__
+#define __CUDA_ARCH__ 350
+#endif
+
+#include "cuda_builtin_vars.h"
+
+// No need for device_launch_parameters.h as cuda_builtin_vars.h above
+// has taken care of builtin variables declared in the file.
+#define __DEVICE_LAUNCH_PARAMETERS_H__
+
+// {math,device}_functions.h only have declarations of the
+// functions. We don't need them as we're going to pull in their
+// definitions from .hpp files.
+#define __DEVICE_FUNCTIONS_H__
+#define __MATH_FUNCTIONS_H__
+
+#undef __CUDACC__
+#define __CUDABE__
+// Disables definitions of device-side runtime support stubs in
+// cuda_device_runtime_api.h
+#define __CUDADEVRT_INTERNAL__
+#include "host_config.h"
+#include "host_defines.h"
+#include "driver_types.h"
+#include "common_functions.h"
+#undef __CUDADEVRT_INTERNAL__
+
+#undef __CUDABE__
+#define __CUDACC__
+#include_next "cuda_runtime.h"
+
+#undef __CUDACC__
+#define __CUDABE__
+
+// CUDA headers use __nvvm_memcpy and __nvvm_memset which clang does
+// no

Re: [PATCH] D14556: [CUDA] Detect and link with CUDA's libdevice bitcode library.

2015-11-17 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253387: [CUDA] Detect and link with CUDA's libdevice bitcode 
library. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D14556?vs=39863&id=40434#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14556

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains.cpp
  cfe/trunk/lib/Driver/ToolChains.h
  cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/.keep
  
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_20.10.bc
  
cfe/trunk/test/Driver/Inputs/CUDA/usr/local/cuda/nvvm/libdevice/libdevice.compute_35.10.bc
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/lib/Driver/ToolChains.h
===
--- cfe/trunk/lib/Driver/ToolChains.h
+++ cfe/trunk/lib/Driver/ToolChains.h
@@ -166,6 +166,7 @@
 std::string CudaLibPath;
 std::string CudaLibDevicePath;
 std::string CudaIncludePath;
+llvm::StringMap CudaLibDeviceMap;
 
   public:
 CudaInstallationDetector(const Driver &D) : IsValid(false), D(D) {}
@@ -185,6 +186,9 @@
 /// \brief Get the detected Cuda device library path.
 StringRef getLibDevicePath() const { return CudaLibDevicePath; }
 /// \brief Get libdevice file for given architecture
+StringRef getLibDeviceFile(StringRef Gpu) const {
+  return CudaLibDeviceMap.lookup(Gpu);
+}
   };
 
   CudaInstallationDetector CudaInstallation;
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1647,6 +1647,31 @@
   D.getVFS().exists(CudaLibDevicePath)))
   continue;
 
+std::error_code EC;
+for (llvm::sys::fs::directory_iterator LI(CudaLibDevicePath, EC), LE;
+ !EC && LI != LE; LI = LI.increment(EC)) {
+  StringRef FilePath = LI->path();
+  StringRef FileName = llvm::sys::path::filename(FilePath);
+  // Process all bitcode filenames that look like libdevice.compute_XX.YY.bc
+  const StringRef LibDeviceName = "libdevice.";
+  if (!(FileName.startswith(LibDeviceName) && FileName.endswith(".bc")))
+continue;
+  StringRef GpuArch = FileName.slice(
+  LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
+  CudaLibDeviceMap[GpuArch] = FilePath.str();
+  // Insert map entries for specifc devices with this compute capability.
+  if (GpuArch == "compute_20") {
+CudaLibDeviceMap["sm_20"] = FilePath;
+CudaLibDeviceMap["sm_21"] = FilePath;
+  } else if (GpuArch == "compute_30") {
+CudaLibDeviceMap["sm_30"] = FilePath;
+CudaLibDeviceMap["sm_32"] = FilePath;
+  } else if (GpuArch == "compute_35") {
+CudaLibDeviceMap["sm_35"] = FilePath;
+CudaLibDeviceMap["sm_37"] = FilePath;
+  }
+}
+
 IsValid = true;
 break;
   }
@@ -4195,6 +4220,22 @@
  llvm::opt::ArgStringList &CC1Args) const {
   Linux::addClangTargetOptions(DriverArgs, CC1Args);
   CC1Args.push_back("-fcuda-is-device");
+
+  if (DriverArgs.hasArg(options::OPT_nocudalib))
+return;
+
+  std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(
+  DriverArgs.getLastArgValue(options::OPT_march_EQ));
+  if (!LibDeviceFile.empty()) {
+CC1Args.push_back("-mlink-cuda-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
+
+// Libdevice in CUDA-7.0 requires PTX version that's more recent
+// than LLVM defaults to. Use PTX4.2 which is the PTX version that
+// came with CUDA-7.0.
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+ptx42");
+  }
 }
 
 llvm::opt::DerivedArgList *
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1597,6 +1597,7 @@
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
+def nocudalib : Flag<["-"], "nocudalib">;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
Index: cfe/trunk/test/Driver/cuda-detect.cu
===
--- cfe/trunk/test/Driver/cuda-detect.cu
+++ cfe/trunk/test/Driver/cuda-detect.cu
@@ -8,26 +8,51 @@
 // RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
 // RUN: %clang -v --target=i386-unknown-linux \
+// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
+// RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
 
-// Verify that C

r253389 - [CUDA] Make CUDA compilation usable by default.

2015-11-17 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Nov 17 16:28:55 2015
New Revision: 253389

URL: http://llvm.org/viewvc/llvm-project?rev=253389&view=rev
Log:
[CUDA] Make CUDA compilation usable by default.

Currently clang requires several additional command
line options in order to enable new features needed
during CUDA compilation. This patch makes these
options default.

* Automatically include cuda_runtime.h if we've found
  a valid CUDA installation.
* Disable automatic CUDA header inclusion during unit tests.
* Added test case for command line construction.
* Enabled target overloads and relaxed call checks that are
  needed in order to include CUDA headers.
* Added CUDA-7.5 installation path to the CUDA installation search list.
* Define __CUDA__ macro to indicate CUDA compilation.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/cuda-detect.cu
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=253389&r1=253388&r2=253389&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Nov 17 16:28:55 2015
@@ -1629,6 +1629,7 @@ void Generic_GCC::CudaInstallationDetect
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
 
@@ -4134,8 +4135,11 @@ void Linux::AddCudaIncludeArgs(const Arg
   if (DriverArgs.hasArg(options::OPT_nocudainc))
 return;
 
-  if (CudaInstallation.isValid())
+  if (CudaInstallation.isValid()) {
 addSystemInclude(DriverArgs, CC1Args, CudaInstallation.getIncludePath());
+CC1Args.push_back("-include");
+CC1Args.push_back("cuda_runtime.h");
+  }
 }
 
 bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253389&r1=253388&r2=253389&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Nov 17 16:28:55 2015
@@ -3292,6 +3292,8 @@ void Clang::ConstructJob(Compilation &C,
 assert(AuxToolChain != nullptr && "No aux toolchain.");
 CmdArgs.push_back("-aux-triple");
 CmdArgs.push_back(Args.MakeArgString(AuxToolChain->getTriple().str()));
+CmdArgs.push_back("-fcuda-target-overloads");
+CmdArgs.push_back("-fcuda-disable-target-call-checks");
   }
 
   if (Triple.isOSWindows() && (Triple.getArch() == llvm::Triple::arm ||

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=253389&r1=253388&r2=253389&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Nov 17 16:28:55 2015
@@ -411,6 +411,8 @@ static void InitializeStandardPredefined
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");
+  if (LangOpts.CUDA)
+Builder.defineMacro("__CUDA__");
 }
 
 /// Initialize the predefined C++ language feature test macros defined in

Modified: cfe/trunk/test/Driver/cuda-detect.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=253389&r1=253388&r2=253389&view=diff
==
--- cfe/trunk/test/Driver/cuda-detect.cu (original)
+++ cfe/trunk/test/Driver/cuda-detect.cu Tue Nov 17 16:28:55 2015
@@ -8,8 +8,6 @@
 // RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
 // RUN: %clang -v --target=i386-unknown-linux \
-// RUN:   --sysroot=%S/Inputs/CUDA 2>&1 | FileCheck %s
-// RUN: %clang -v --target=i386-unknown-linux \
 // RUN:   --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s
 
 // Make sure we map libdevice bitcode files to proper GPUs.
@@ -40,6 +38,12 @@
 // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
 // RUN:   -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE
+// Verify that we don't add include paths, link with libdevice or
+// -include cuda_runtime without valid CUDA installation.
+// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \
+// RUN:   --cuda-path=%S/no-cuda-there %s 2>&1 \
+// RUN:   | FileCheck %s -check-prefix COMMON \
+// RUN:

Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-11-17 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253388: [CUDA] Added a wrapper header for inclusion of stock 
CUDA headers. (authored by tra).

Changed prior to commit:
  http://reviews.llvm.org/D13171?vs=38574&id=40435#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13171

Files:
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/cuda_runtime.h

Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -17,6 +17,7 @@
   bmiintrin.h
   cpuid.h
   cuda_builtin_vars.h
+  cuda_runtime.h
   emmintrin.h
   f16cintrin.h
   float.h
Index: cfe/trunk/lib/Headers/cuda_runtime.h
===
--- cfe/trunk/lib/Headers/cuda_runtime.h
+++ cfe/trunk/lib/Headers/cuda_runtime.h
@@ -0,0 +1,179 @@
+/*=== cuda_runtime.h - CUDA runtime support ===
+ *
+ * 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.
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_CUDA_RUNTIME_H__
+#define __CLANG_CUDA_RUNTIME_H__
+
+#if defined(__CUDA__) && defined(__clang__)
+
+// Include some standard headers to avoid CUDA headers including them
+// while some required macros (like __THROW) are in a weird state.
+#include 
+
+// Preserve common macros that will be changed below by us or by CUDA
+// headers.
+#pragma push_macro("__THROW")
+#pragma push_macro("__CUDA_ARCH__")
+
+// WARNING: Preprocessor hacks below are based on specific of
+// implementation of CUDA-7.x headers and are expected to break with
+// any other version of CUDA headers.
+#include "cuda.h"
+#if !defined(CUDA_VERSION)
+#error "cuda.h did not define CUDA_VERSION"
+#elif CUDA_VERSION < 7000 || CUDA_VERSION > 7050
+#error "Unsupported CUDA version!"
+#endif
+
+// Make largest subset of device functions available during host
+// compilation -- SM_35 for the time being.
+#ifndef __CUDA_ARCH__
+#define __CUDA_ARCH__ 350
+#endif
+
+#include "cuda_builtin_vars.h"
+
+// No need for device_launch_parameters.h as cuda_builtin_vars.h above
+// has taken care of builtin variables declared in the file.
+#define __DEVICE_LAUNCH_PARAMETERS_H__
+
+// {math,device}_functions.h only have declarations of the
+// functions. We don't need them as we're going to pull in their
+// definitions from .hpp files.
+#define __DEVICE_FUNCTIONS_H__
+#define __MATH_FUNCTIONS_H__
+
+#undef __CUDACC__
+#define __CUDABE__
+// Disables definitions of device-side runtime support stubs in
+// cuda_device_runtime_api.h
+#define __CUDADEVRT_INTERNAL__
+#include "host_config.h"
+#include "host_defines.h"
+#include "driver_types.h"
+#include "common_functions.h"
+#undef __CUDADEVRT_INTERNAL__
+
+#undef __CUDABE__
+#define __CUDACC__
+#include_next "cuda_runtime.h"
+
+#undef __CUDACC__
+#define __CUDABE__
+
+// CUDA headers use __nvvm_memcpy and __nvvm_memset which clang does
+// not have at the moment. Emulate them with a builtin memcpy/memset.
+#define __nvvm_memcpy(s,d,n,a) __builtin_memcpy(s,d,n)
+#define __nvvm_memset(d,c,n,a) __builtin_memset(d,c,n)
+
+#include "crt/host_runtime.h"
+#include "crt/device_runtime.h"
+// device_runtime.h defines __cxa_* macros that will conflict with
+// cxxabi.h.
+// FIXME: redefine these as __device__ functions.
+#undef __cxa_vec_ctor
+#undef __cxa_vec_cctor
+#undef __cxa_vec_dtor
+#undef __cxa_vec_new2
+#undef __cxa_vec_new3
+#undef __cxa_vec_delete2
+#undef __cxa_vec_delete
+#undef __cxa_vec_delete3
+#undef __cxa_pure_virtual
+
+// We need decls for functions in CUDA's libdevice woth __device__
+// attribute only. Alas they come either as __host__ __device__ or
+// with no attributes at all. To work around that, define __CUDA_RTC__
+// which produces HD variant and undef __host__ which gives us desided
+// decls with __device_

[PATCH] D14758: Handle ARMv7K as an alias, instead of fake architecture (NFC)

2015-11-17 Thread A. Skrobov via cfe-commits
tyomitch created this revision.
tyomitch added reviewers: t.p.northover, rengolin.
tyomitch added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Clang-side update, corresponding to D14757

http://reviews.llvm.org/D14758

Files:
  lib/Driver/Tools.cpp

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6295,19 +6295,17 @@
 StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
const llvm::Triple &Triple) {
   unsigned ArchKind;
+  if (Arch == "armv7k" || Arch == "thumbv7k")
+return "v7k"; // In other cases, Cortex-A7 should resolve to ARMv7-A
   if (CPU == "generic") {
 std::string ARMArch = tools::arm::getARMArch(Arch, Triple);
 ArchKind = llvm::ARM::parseArch(ARMArch);
 if (ArchKind == llvm::ARM::AK_INVALID)
   // In case of generic Arch, i.e. "arm",
   // extract arch from default cpu of the Triple
   ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(ARMArch));
   } else {
-// FIXME: horrible hack to get around the fact that Cortex-A7 is only an
-// armv7k triple if it's actually been specified via "-arch armv7k".
-ArchKind = (Arch == "armv7k" || Arch == "thumbv7k")
-  ? (unsigned)llvm::ARM::AK_ARMV7K
-  : llvm::ARM::parseCPUArch(CPU);
+  ArchKind = llvm::ARM::parseCPUArch(CPU);
   }
   if (ArchKind == llvm::ARM::AK_INVALID)
 return "";


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -6295,19 +6295,17 @@
 StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch,
const llvm::Triple &Triple) {
   unsigned ArchKind;
+  if (Arch == "armv7k" || Arch == "thumbv7k")
+return "v7k"; // In other cases, Cortex-A7 should resolve to ARMv7-A
   if (CPU == "generic") {
 std::string ARMArch = tools::arm::getARMArch(Arch, Triple);
 ArchKind = llvm::ARM::parseArch(ARMArch);
 if (ArchKind == llvm::ARM::AK_INVALID)
   // In case of generic Arch, i.e. "arm",
   // extract arch from default cpu of the Triple
   ArchKind = llvm::ARM::parseCPUArch(Triple.getARMCPUForArch(ARMArch));
   } else {
-// FIXME: horrible hack to get around the fact that Cortex-A7 is only an
-// armv7k triple if it's actually been specified via "-arch armv7k".
-ArchKind = (Arch == "armv7k" || Arch == "thumbv7k")
-  ? (unsigned)llvm::ARM::AK_ARMV7K
-  : llvm::ARM::parseCPUArch(CPU);
+  ArchKind = llvm::ARM::parseCPUArch(CPU);
   }
   if (ArchKind == llvm::ARM::AK_INVALID)
 return "";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r253390 - [Myriad]: -nostdlib implies -nostartfiles

2015-11-17 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Nov 17 16:33:34 2015
New Revision: 253390

URL: http://llvm.org/viewvc/llvm-project?rev=253390&view=rev
Log:
[Myriad]: -nostdlib implies -nostartfiles

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=253390&r1=253389&r2=253390&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Nov 17 16:33:34 2015
@@ -9941,7 +9941,7 @@ void tools::Myriad::Linker::ConstructJob
   static_cast(getToolChain());
   const llvm::Triple &T = TC.getTriple();
   ArgStringList CmdArgs;
-  bool UseStartfiles = !Args.hasArg(options::OPT_nostartfiles);
+  bool UseStartfiles = !Args.hasArg(options::OPT_nostdlib, 
options::OPT_nostartfiles);
   bool UseDefaultLibs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
 

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=253390&r1=253389&r2=253390&view=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Tue Nov 17 16:33:34 2015
@@ -68,6 +68,7 @@
 // STDLIBCXX: "-lstdc++" "-lc" "-lgcc"
 
 // RUN: %clang -target sparc-myriad -### -nostdlib %s 2>&1 | FileCheck %s 
--check-prefix=NOSTDLIB
+// NOSTDLIB-NOT: crtbegin.o
 // NOSTDLIB-NOT: "-lc"
 
 // RUN: %clang -### -c -g %s -target sparc-myriad 2>&1 | FileCheck 
-check-prefix=G_SPARC %s


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


Re: [PATCH] D14754: [Myriad]: insert -L paths into linker cmd only when they exist.

2015-11-17 Thread Douglas Katzman via cfe-commits
dougk updated this revision to Diff 40442.
dougk marked 2 inline comments as done.
dougk added a comment.

changes per jyknight


http://reviews.llvm.org/D14754

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtend.o
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crti.o
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtn.o
  test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o

Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9945,10 +9945,6 @@
   bool UseDefaultLibs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
 
-  std::string StartFilesDir, BuiltinLibDir;
-  TC.getCompilerSupportDir(StartFilesDir);
-  TC.getBuiltinLibDir(BuiltinLibDir);
-
   if (T.getArch() == llvm::Triple::sparc)
 CmdArgs.push_back("-EB");
   else // SHAVE assumes little-endian, and sparcel is expressly so.
@@ -9972,19 +9968,15 @@
   if (UseStartfiles) {
 // If you want startfiles, it means you want the builtin crti and crtbegin,
 // but not crt0. Myriad link commands provide their own crt0.o as needed.
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crti.o"));
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtbegin.o"));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crti.o")));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtbegin.o")));
   }
 
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
-  // The linker doesn't use these builtin paths unless directed to,
-  // because it was not compiled for support with sysroots, nor does
-  // it have a default of little-endian with FPU.
-  CmdArgs.push_back(Args.MakeArgString("-L" + BuiltinLibDir));
-  CmdArgs.push_back(Args.MakeArgString("-L" + StartFilesDir));
+  TC.AddFilePathLibArgs(Args, CmdArgs);
 
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
 
@@ -10004,8 +9996,8 @@
 CmdArgs.push_back("-lgcc");
   }
   if (UseStartfiles) {
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtend.o"));
-CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtn.o"));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
+CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtn.o")));
   }
 
   std::string Exec =
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -1068,8 +1068,6 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
   Tool *SelectTool(const JobAction &JA) const override;
-  void getCompilerSupportDir(std::string &Dir) const;
-  void getBuiltinLibDir(std::string &Dir) const;
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
 protected:
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4367,6 +4367,26 @@
   case llvm::Triple::shave:
 GCCInstallation.init(Triple, Args, {"sparc-myriad-elf"});
   }
+
+  if (GCCInstallation.isValid()) {
+// The contents of LibDir are independent of the version of gcc.
+// This contains libc, libg (a superset of libc), libm, libstdc++, libssp.
+SmallString<128> LibDir(GCCInstallation.getParentLibPath());
+if (Triple.getArch() == llvm::Triple::sparcel)
+  llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib/le");
+else
+  llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib");
+addPathIfExists(D, LibDir, getFilePaths());
+
+// This directory contains crt{i,n,begin,end}.o as well as libgcc.
+// These files are tied to a particular version of gcc.
+SmallString<128> CompilerSupportDir(GCCInstallation.getInstallPath());
+// There are actually 4 choices: {le,be} x {fpu,nofpu}
+// but as this toolchain is for LEON sparc, it can assume FPU.
+if (Triple.getArch() == llvm::Triple::sparcel)
+  llvm::sys::path::append(CompilerSupportDir, "le");
+addPathIfExists(D, CompilerSupportDir, getFilePaths());
+  }
 }
 
 MyriadToolChain::~MyriadToolChain() {}
@@ -4413,27 +4433,6 @@
   }
 }
 
-void MyriadToolChain::getCompilerSupportDir(std::string &Dir) const {
-  // This directory contains crt{i,n,begin,end}.o as well as libgcc.
-  // These files are tied to a particular version of gcc.
-  SmallString<128> Result(GCCInstallation.getInstallPath());
-  // There are actually 4 choices: {le,be} x {fpu,nofpu}
-  // but as this toolchain is for LEON sparc, it can assume FPU.
-  if (this->getTriple().getArch() == llvm::Triple::sparcel)
-llvm::sys::path::app

r253398 - [modules] When a #include is mapped to a module import and appears somewhere

2015-11-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Nov 17 17:32:01 2015
New Revision: 253398

URL: http://llvm.org/viewvc/llvm-project?rev=253398&view=rev
Log:
[modules] When a #include is mapped to a module import and appears somewhere
other than the top level, we issue an error. This breaks a fair amount of C++
code wrapping C libraries, where the C library is #included within a namespace
/ extern "C" combination, because the C library (probably) includes C++
standard library headers which may be within modules.

Without modules, this setup is harmless if (and *only* if) the corresponding
standard library module was already included outside the namespace, so
downgrade the error to a default-error extension in that case, so that it can
be selectively disabled for such misbehaving libraries.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/auto-module-import.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253398&r1=253397&r2=253398&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 17 17:32:01 
2015
@@ -7930,6 +7930,9 @@ def note_module_import_in_extern_c : Not
   "extern \"C\" language linkage specification begins here">;
 def err_module_import_not_at_top_level_fatal : Error<
   "import of module '%0' appears within %1">, DefaultFatal;
+def ext_module_import_not_at_top_level_noop : ExtWarn<
+  "redundant #include of module '%0' appears within %1">, DefaultError,
+  InGroup>;
 def note_module_import_not_at_top_level : Note<"%0 begins here">;
 def err_module_self_import : Error<
   "import of module '%0' appears within same top-level module '%1'">;

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=253398&r1=253397&r2=253398&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Nov 17 17:32:01 2015
@@ -3589,8 +3589,8 @@ void Parser::ParseStructUnionBody(Source
   SmallVector FieldDecls;
 
   // While we still have something to read, read the declarations in the 
struct.
-  while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
- !tryParseMisplacedModuleImport()) {
+  while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
+ Tok.isNot(tok::eof)) {
 // Each iteration of this loop reads one struct-declaration.
 
 // Check for extraneous top-level semicolon.

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=253398&r1=253397&r2=253398&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Nov 17 17:32:01 2015
@@ -210,8 +210,8 @@ void Parser::ParseInnerNamespace(std::ve
  ParsedAttributes &attrs,
  BalancedDelimiterTracker &Tracker) {
   if (index == Ident.size()) {
-while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
-   !tryParseMisplacedModuleImport()) {
+while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
+   Tok.isNot(tok::eof)) {
   ParsedAttributesWithRange attrs(AttrFactory);
   MaybeParseCXX11Attributes(attrs);
   MaybeParseMicrosoftAttributes(attrs);
@@ -3064,8 +3064,8 @@ void Parser::ParseCXXMemberSpecification
 
   if (TagDecl) {
 // While we still have something to read, read the member-declarations.
-while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
-   !tryParseMisplacedModuleImport()) {
+while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
+   Tok.isNot(tok::eof)) {
   // Each iteration of this loop reads one member-declaration.
   ParseCXXClassMemberDeclarationWithPragmas(
   CurAS, AccessAttrs, static_cast(TagType), TagDecl);

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=253398&r1=253397&r2=253398&view=diff
==
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Tue Nov 17 17:32:01 2015
@@ -948,8 +948,8 @@ StmtResult Parser::ParseCompoundStatemen
   Stmts.push_back(R.get());
   }
 
-  while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
- !tryParseMisplacedModuleImport()) {
+  while (!tryParseMisplacedModuleImpo

[clang-tools-extra] r253399 - Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not consider const"

2015-11-17 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Tue Nov 17 17:35:39 2015
New Revision: 253399

URL: http://llvm.org/viewvc/llvm-project?rev=253399&view=rev
Log:
Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not 
consider const"

Summary:
The current matcher is
  implicitCastExpr(unless(hasParent(explicitCastExpr(
but the AST in the bug is
  `-CXXStaticCastExpr 0x2bb64f8  'void *const *'
static_cast 
`-ImplicitCastExpr 0x2bb64e0  'void *const *' 
  `-ImplicitCastExpr 0x2bb64c8  'void **'

`-DeclRefExpr 0x2bb6458  'void *[2]' lvalue Var
0x2bb59d0 'addrlist' 'void *[2]'
i.e. an ImplicitCastExpr (const cast) between decay and explicit cast.

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D14517

Modified:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp?rev=253399&r1=253398&r2=253399&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
 Tue Nov 17 17:35:39 2015
@@ -28,6 +28,22 @@ AST_MATCHER(Stmt, isInsideOfRangeBeginEn
   .matches(Node, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, hasParentIgnoringImpCasts,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const Expr *E = &Node;
+  do {
+ASTContext::DynTypedNodeList Parents =
+Finder->getASTContext().getParents(*E);
+if (Parents.size() != 1)
+  return false;
+E = Parents[0].get();
+if (!E)
+  return false;
+  } while (isa(E));
+
+  return InnerMatcher.matches(*E, Finder, Builder);
+}
+
 void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -38,7 +54,7 @@ void ProBoundsArrayToPointerDecayCheck::
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
   implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
-   unless(hasParent(explicitCastExpr())),
+   unless(hasParentIgnoringImpCasts(explicitCastExpr())),
unless(isInsideOfRangeBeginEndStmt()),
unless(hasSourceExpression(stringLiteral(
   .bind("cast"),

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h?rev=253399&r1=253398&r2=253399&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
 Tue Nov 17 17:35:39 2015
@@ -31,4 +31,3 @@ public:
 } // namespace clang
 
 #endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
-

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp?rev=253399&r1=253398&r2=253399&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
 Tue Nov 17 17:35:39 2015
@@ -39,3 +39,9 @@ void f() {
 const char *g() {
   return "clang"; // OK, decay string literal to pointer
 }
+
+void f2(void *const *);
+void bug25362() {
+  void *a[2];
+  f2(static_cast(a)); // OK, explicit cast
+}


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


Re: [PATCH] D14517: Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not consider const"

2015-11-17 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253399: Fix bug 25362 
"cppcoreguidelines-pro-bounds-array-to-pointer-decay does not… (authored by 
mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D14517?vs=39948&id=40446#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14517

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp

Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -39,3 +39,9 @@
 const char *g() {
   return "clang"; // OK, decay string literal to pointer
 }
+
+void f2(void *const *);
+void bug25362() {
+  void *a[2];
+  f2(static_cast(a)); // OK, explicit cast
+}
Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
@@ -31,4 +31,3 @@
 } // namespace clang
 
 #endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
-
Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -28,6 +28,22 @@
   .matches(Node, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, hasParentIgnoringImpCasts,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const Expr *E = &Node;
+  do {
+ASTContext::DynTypedNodeList Parents =
+Finder->getASTContext().getParents(*E);
+if (Parents.size() != 1)
+  return false;
+E = Parents[0].get();
+if (!E)
+  return false;
+  } while (isa(E));
+
+  return InnerMatcher.matches(*E, Finder, Builder);
+}
+
 void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
@@ -38,7 +54,7 @@
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
   implicitCastExpr(unless(hasParent(arraySubscriptExpr())),
-   unless(hasParent(explicitCastExpr())),
+   unless(hasParentIgnoringImpCasts(explicitCastExpr())),
unless(isInsideOfRangeBeginEndStmt()),
unless(hasSourceExpression(stringLiteral(
   .bind("cast"),


Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -39,3 +39,9 @@
 const char *g() {
   return "clang"; // OK, decay string literal to pointer
 }
+
+void f2(void *const *);
+void bug25362() {
+  void *a[2];
+  f2(static_cast(a)); // OK, explicit cast
+}
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h
@@ -31,4 +31,3 @@
 } // namespace clang
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_ARRAY_TO_POINTER_DECAY_H
-
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -28,6 +28,22 @@
   .matches(Node, Finder, Builder);
 }
 
+AST_MATCHER_P(Expr, hasParentIgnoringImpCasts,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  const Expr *E = &Node;
+  do {
+ASTContext::DynTypedNodeList Parents =
+Finder->getASTContext().getParents(*E);
+if (Parents.size() != 1)
+  return false;
+E = Parents[0].get();
+if (!E)
+  return false;
+  }

Re: r253398 - [modules] When a #include is mapped to a module import and appears somewhere

2015-11-17 Thread David Blaikie via cfe-commits
On Tue, Nov 17, 2015 at 3:32 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Nov 17 17:32:01 2015
> New Revision: 253398
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253398&view=rev
> Log:
> [modules] When a #include is mapped to a module import and appears
> somewhere
> other than the top level, we issue an error. This breaks a fair amount of
> C++
> code wrapping C libraries, where the C library is #included within a
> namespace
> / extern "C" combination, because the C library (probably) includes C++
> standard library headers which may be within modules.
>
> Without modules, this setup is harmless if (and *only* if) the
> corresponding
> standard library module was already included outside the namespace,


^ if that's the only place it's valid, is it that much more work to just
remove all such inclusions as pointless? If they ever trigger they'll do
bad things, yes?

(but I guess on a large enough codebase this fight is not worth fighting in
the effort to transition to modules? even if it's just deletions (code
review turnaround, etc))


> so
> downgrade the error to a default-error extension in that case, so that it
> can
> be selectively disabled for such misbehaving libraries.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Parse/ParseDecl.cpp
> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Modules/auto-module-import.m
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253398&r1=253397&r2=253398&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 17
> 17:32:01 2015
> @@ -7930,6 +7930,9 @@ def note_module_import_in_extern_c : Not
>"extern \"C\" language linkage specification begins here">;
>  def err_module_import_not_at_top_level_fatal : Error<
>"import of module '%0' appears within %1">, DefaultFatal;
> +def ext_module_import_not_at_top_level_noop : ExtWarn<
> +  "redundant #include of module '%0' appears within %1">, DefaultError,
> +  InGroup>;
>  def note_module_import_not_at_top_level : Note<"%0 begins here">;
>  def err_module_self_import : Error<
>"import of module '%0' appears within same top-level module '%1'">;
>
> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=253398&r1=253397&r2=253398&view=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Nov 17 17:32:01 2015
> @@ -3589,8 +3589,8 @@ void Parser::ParseStructUnionBody(Source
>SmallVector FieldDecls;
>
>// While we still have something to read, read the declarations in the
> struct.
> -  while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
> - !tryParseMisplacedModuleImport()) {
> +  while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
> + Tok.isNot(tok::eof)) {
>  // Each iteration of this loop reads one struct-declaration.
>
>  // Check for extraneous top-level semicolon.
>
> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=253398&r1=253397&r2=253398&view=diff
>
> ==
> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Nov 17 17:32:01 2015
> @@ -210,8 +210,8 @@ void Parser::ParseInnerNamespace(std::ve
>   ParsedAttributes &attrs,
>   BalancedDelimiterTracker &Tracker) {
>if (index == Ident.size()) {
> -while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
> -   !tryParseMisplacedModuleImport()) {
> +while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
> +   Tok.isNot(tok::eof)) {
>ParsedAttributesWithRange attrs(AttrFactory);
>MaybeParseCXX11Attributes(attrs);
>MaybeParseMicrosoftAttributes(attrs);
> @@ -3064,8 +3064,8 @@ void Parser::ParseCXXMemberSpecification
>
>if (TagDecl) {
>  // While we still have something to read, read the
> member-declarations.
> -while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
> -   !tryParseMisplacedModuleImport()) {
> +while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
> +   Tok.isNot(tok::eof)) {
>// Each iteration of this loop reads one member-declaration.
>ParseCXXClassMemberDeclarationWithPragmas(
>CurAS, AccessAttrs, static

Re: [PATCH] D14582: [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore generated pointer arithmetic

2015-11-17 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 40448.
mgehre added a comment.

Simplified with Alex suggestion. Thanks!


http://reviews.llvm.org/D14582

Files:
  clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
  test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
@@ -84,4 +84,6 @@
   i = j - 1;
 
   auto diff = p - q; // OK, result is arithmetic
+
+  for(int ii : a) ; // OK, pointer arithmetic generated by compiler
 }
Index: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
@@ -24,7 +24,8 @@
   Finder->addMatcher(
   binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-"),
hasOperatorName("+="), hasOperatorName("-=")),
- hasType(pointerType()))
+ hasType(pointerType()),
+ 
unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))
   .bind("expr"),
   this);
 


Index: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
@@ -84,4 +84,6 @@
   i = j - 1;
 
   auto diff = p - q; // OK, result is arithmetic
+
+  for(int ii : a) ; // OK, pointer arithmetic generated by compiler
 }
Index: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
@@ -24,7 +24,8 @@
   Finder->addMatcher(
   binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-"),
hasOperatorName("+="), hasOperatorName("-=")),
- hasType(pointerType()))
+ hasType(pointerType()),
+ unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))
   .bind("expr"),
   this);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r253401 - [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-11-17 Thread Matthias Gehre via cfe-commits
Author: mgehre
Date: Tue Nov 17 17:43:20 2015
New Revision: 253401

URL: http://llvm.org/viewvc/llvm-project?rev=253401&view=rev
Log:
[clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

Summary:
This check flags all array subscriptions on static arrays and
std::arrays that either have a non-compile-time-constant index or are
out of bounds.

Dynamic accesses into arrays are difficult for both tools and humans to
validate as safe. array_view is a bounds-checked, safe type for
accessing arrays of data. at() is another alternative that ensures
single accesses are bounds-checked. If iterators are needed to access an
array, use the iterators from an array_view constructed over the array.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds2-only-index-into-arrays-using-constant-expressions

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13746

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=253401&r1=253400&r2=253401&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Tue Nov 
17 17:43:20 2015
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
+  ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeCstyleCastCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=253401&r1=253400&r2=253401&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Tue Nov 17 17:43:20 2015
@@ -12,6 +12,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/AssignOperatorSignatureCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
+#include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeCstyleCastCheck.h"
@@ -30,6 +31,8 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
+CheckFactories.registerCheck(
+"cppcoreguidelines-pro-bounds-constant-array-index");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=253401&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 Tue Nov 17 17:43:20 2015
@@ -0,0 +1,131 @@
+//===--- ProBoundsConstantArrayIndexCheck.cpp - 
clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProBoundsConstantArrayIndexCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;

Re: [PATCH] D13746: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-11-17 Thread Matthias Gehre via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253401: [clang-tidy] add check 
cppcoreguidelines-pro-bounds-constant-array-index (authored by mgehre).

Changed prior to commit:
  http://reviews.llvm.org/D13746?vs=39953&id=40449#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13746

Files:
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp

Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
@@ -0,0 +1,40 @@
+//===--- ProBoundsConstantArrayIndexCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
+
+#include "../ClangTidy.h"
+#include "../utils/IncludeInserter.h"
+
+namespace clang {
+namespace tidy {
+
+/// This checks that all array subscriptions on static arrays and std::arrays
+/// have a constant index and are within bounds
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.html
+class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck {
+  std::string GslHeader;
+  const IncludeSorter::IncludeStyle IncludeStyle;
+  std::unique_ptr Inserter;
+
+public:
+  ProBoundsConstantArrayIndexCheck(StringRef Name, ClangTidyContext *Context);
+  void registerPPCallbacks(CompilerInstance &Compiler) override;
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_BOUNDS_CONSTANT_ARRAY_INDEX_H
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -0,0 +1,131 @@
+//===--- ProBoundsConstantArrayIndexCheck.cpp - clang-tidy-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ProBoundsConstantArrayIndexCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Preprocessor.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")),
+  IncludeStyle(IncludeSorter::parseIncludeStyle(
+  Options.get("IncludeStyle", "llvm"))) {}
+
+void ProBoundsConstantArrayIndexCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "GslHeader", GslHeader);
+}
+
+void ProBoundsConstantArrayIndexCheck::registerPPCallbacks(
+CompilerInstance &Compiler) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Inserter.reset(new IncludeInserter(Compiler.getSourceManager(),
+ Compiler.getLangOpts(), IncludeStyle));
+  Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
+}
+
+void ProBoundsConstantArrayIndexCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(arraySubscriptExpr(hasBase(ignoringImpCasts(hasType(
+ 

Re: [PATCH] D13834: Produce a better diagnostic for global register variables

2015-11-17 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Thanks, I'll commit this patch shortly.

If it makes the code cleaner, I can define enums in TargetInfo and change 
validateGlobalRegisterVariable to return one of them in a follow-up patch.


http://reviews.llvm.org/D13834



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


Re: r253398 - [modules] When a #include is mapped to a module import and appears somewhere

2015-11-17 Thread Richard Smith via cfe-commits
On Tue, Nov 17, 2015 at 3:40 PM, David Blaikie  wrote:

> On Tue, Nov 17, 2015 at 3:32 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue Nov 17 17:32:01 2015
>> New Revision: 253398
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253398&view=rev
>> Log:
>> [modules] When a #include is mapped to a module import and appears
>> somewhere
>> other than the top level, we issue an error. This breaks a fair amount of
>> C++
>> code wrapping C libraries, where the C library is #included within a
>> namespace
>> / extern "C" combination, because the C library (probably) includes C++
>> standard library headers which may be within modules.
>>
>> Without modules, this setup is harmless if (and *only* if) the
>> corresponding
>> standard library module was already included outside the namespace,
>
>
> ^ if that's the only place it's valid, is it that much more work to just
> remove all such inclusions as pointless?
>

Yes, and that would break the build of the third-party library in a lot of
cases. The pattern looks like this:

c_header.h:
#include 
my decls(); // use stuff from stdio.h here

cxx_header.h:
#include  // important, do not remove
namespace WrappedCLibrary {
extern "C" {
#include "c_header.h"
}
}

Note that removing the include from c_header.h will potentially break all
the other (C) users of that header.


> If they ever trigger they'll do bad things, yes?
>
> (but I guess on a large enough codebase this fight is not worth fighting
> in the effort to transition to modules? even if it's just deletions (code
> review turnaround, etc))
>
>
>> so
>> downgrade the error to a default-error extension in that case, so that it
>> can
>> be selectively disabled for such misbehaving libraries.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Parse/ParseDecl.cpp
>> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>> cfe/trunk/lib/Parse/ParseStmt.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/test/Modules/auto-module-import.m
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253398&r1=253397&r2=253398&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 17
>> 17:32:01 2015
>> @@ -7930,6 +7930,9 @@ def note_module_import_in_extern_c : Not
>>"extern \"C\" language linkage specification begins here">;
>>  def err_module_import_not_at_top_level_fatal : Error<
>>"import of module '%0' appears within %1">, DefaultFatal;
>> +def ext_module_import_not_at_top_level_noop : ExtWarn<
>> +  "redundant #include of module '%0' appears within %1">, DefaultError,
>> +  InGroup>;
>>  def note_module_import_not_at_top_level : Note<"%0 begins here">;
>>  def err_module_self_import : Error<
>>"import of module '%0' appears within same top-level module '%1'">;
>>
>> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=253398&r1=253397&r2=253398&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Nov 17 17:32:01 2015
>> @@ -3589,8 +3589,8 @@ void Parser::ParseStructUnionBody(Source
>>SmallVector FieldDecls;
>>
>>// While we still have something to read, read the declarations in the
>> struct.
>> -  while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
>> - !tryParseMisplacedModuleImport()) {
>> +  while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
>> + Tok.isNot(tok::eof)) {
>>  // Each iteration of this loop reads one struct-declaration.
>>
>>  // Check for extraneous top-level semicolon.
>>
>> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=253398&r1=253397&r2=253398&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Nov 17 17:32:01 2015
>> @@ -210,8 +210,8 @@ void Parser::ParseInnerNamespace(std::ve
>>   ParsedAttributes &attrs,
>>   BalancedDelimiterTracker &Tracker) {
>>if (index == Ident.size()) {
>> -while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
>> -   !tryParseMisplacedModuleImport()) {
>> +while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
>> +   Tok.isNot(tok::eof)) {
>>ParsedAttributesWithRange attrs(AttrFactory);
>>MaybeParseCXX11Attributes(attrs);
>>MaybeParseMicros

r253404 - [PGO] Removed unused code. [NFC]

2015-11-17 Thread Betul Buyukkurt via cfe-commits
Author: betulb
Date: Tue Nov 17 18:14:08 2015
New Revision: 253404

URL: http://llvm.org/viewvc/llvm-project?rev=253404&view=rev
Log:
[PGO] Removed unused code. [NFC]


Modified:
cfe/trunk/lib/CodeGen/CodeGenPGO.h

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=253404&r1=253403&r2=253404&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.h Tue Nov 17 18:14:08 2015
@@ -92,7 +92,6 @@ public:
 private:
   void setFuncName(llvm::Function *Fn);
   void setFuncName(StringRef Name, llvm::GlobalValue::LinkageTypes Linkage);
-  void createFuncNameVar(llvm::GlobalValue::LinkageTypes Linkage);
   void mapRegionCounters(const Decl *D);
   void computeRegionCounts(const Decl *D);
   void applyFunctionAttributes(llvm::IndexedInstrProfReader *PGOReader,


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


Re: r253398 - [modules] When a #include is mapped to a module import and appears somewhere

2015-11-17 Thread David Blaikie via cfe-commits
On Tue, Nov 17, 2015 at 4:15 PM, Richard Smith 
wrote:

> On Tue, Nov 17, 2015 at 3:40 PM, David Blaikie  wrote:
>
>> On Tue, Nov 17, 2015 at 3:32 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Tue Nov 17 17:32:01 2015
>>> New Revision: 253398
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=253398&view=rev
>>> Log:
>>> [modules] When a #include is mapped to a module import and appears
>>> somewhere
>>> other than the top level, we issue an error. This breaks a fair amount
>>> of C++
>>> code wrapping C libraries, where the C library is #included within a
>>> namespace
>>> / extern "C" combination, because the C library (probably) includes C++
>>> standard library headers which may be within modules.
>>>
>>> Without modules, this setup is harmless if (and *only* if) the
>>> corresponding
>>> standard library module was already included outside the namespace,
>>
>>
>> ^ if that's the only place it's valid, is it that much more work to just
>> remove all such inclusions as pointless?
>>
>
> Yes, and that would break the build of the third-party library in a lot of
> cases. The pattern looks like this:
>
> c_header.h:
> #include 
> my decls(); // use stuff from stdio.h here
>
> cxx_header.h:
> #include  // important, do not remove
> namespace WrappedCLibrary {
> extern "C" {
> #include "c_header.h"
> }
> }
>
> Note that removing the include from c_header.h will potentially break all
> the other (C) users of that header.
>

Ah, I understand now - sorry for the confusion.

'spose at best we could 'ifdef CXX' the inclusions out, but that's more
invasive, etc... :/


>
>
>> If they ever trigger they'll do bad things, yes?
>>
>> (but I guess on a large enough codebase this fight is not worth fighting
>> in the effort to transition to modules? even if it's just deletions (code
>> review turnaround, etc))
>>
>>
>>> so
>>> downgrade the error to a default-error extension in that case, so that
>>> it can
>>> be selectively disabled for such misbehaving libraries.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/lib/Parse/ParseDecl.cpp
>>> cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>>> cfe/trunk/lib/Parse/ParseStmt.cpp
>>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>> cfe/trunk/test/Modules/auto-module-import.m
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253398&r1=253397&r2=253398&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 17
>>> 17:32:01 2015
>>> @@ -7930,6 +7930,9 @@ def note_module_import_in_extern_c : Not
>>>"extern \"C\" language linkage specification begins here">;
>>>  def err_module_import_not_at_top_level_fatal : Error<
>>>"import of module '%0' appears within %1">, DefaultFatal;
>>> +def ext_module_import_not_at_top_level_noop : ExtWarn<
>>> +  "redundant #include of module '%0' appears within %1">, DefaultError,
>>> +  InGroup>;
>>>  def note_module_import_not_at_top_level : Note<"%0 begins here">;
>>>  def err_module_self_import : Error<
>>>"import of module '%0' appears within same top-level module '%1'">;
>>>
>>> Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=253398&r1=253397&r2=253398&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Nov 17 17:32:01 2015
>>> @@ -3589,8 +3589,8 @@ void Parser::ParseStructUnionBody(Source
>>>SmallVector FieldDecls;
>>>
>>>// While we still have something to read, read the declarations in
>>> the struct.
>>> -  while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof) &&
>>> - !tryParseMisplacedModuleImport()) {
>>> +  while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
>>> + Tok.isNot(tok::eof)) {
>>>  // Each iteration of this loop reads one struct-declaration.
>>>
>>>  // Check for extraneous top-level semicolon.
>>>
>>> Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=253398&r1=253397&r2=253398&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Nov 17 17:32:01 2015
>>> @@ -210,8 +210,8 @@ void Parser::ParseInnerNamespace(std::ve
>>>   ParsedAttributes &attrs,
>>>   BalancedDelimiterTracker &Tracker) {
>>>if (index == Ident.size()) {
>>> -while (Tok.isN

Re: [PATCH] D13834: Produce a better diagnostic for global register variables

2015-11-17 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL253405: Produce a better diagnostic for global register 
variables. (authored by ahatanak).

Changed prior to commit:
  http://reviews.llvm.org/D13834?vs=39774&id=40451#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13834

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGen/named_reg_global.c
  cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
  cfe/trunk/test/OpenMP/atomic_read_codegen.c
  cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
  cfe/trunk/test/OpenMP/atomic_write_codegen.c
  cfe/trunk/test/OpenMP/for_loop_messages.cpp
  cfe/trunk/test/OpenMP/threadprivate_messages.cpp
  cfe/trunk/test/Sema/asm.c
  cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6543,6 +6543,10 @@
 "asm constraint has an unexpected number of alternatives: %0 vs %1">;
   def err_asm_incomplete_type : Error<"asm operand has incomplete type %0">;
   def err_asm_unknown_register_name : Error<"unknown register name '%0' in asm">;
+  def err_asm_invalid_global_var_reg : Error<"register '%0' unsuitable for "
+"global register variables on this target">;
+  def err_asm_register_size_mismatch : Error<"size of register '%0' does not "
+"match variable size">;
   def err_asm_bad_register_type : Error<"bad type for named register variable">;
   def err_asm_invalid_input_size : Error<
 "invalid input size for constraint '%0'">;
Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -644,6 +644,19 @@
 }
   };
 
+  /// \brief Validate register name used for global register variables.
+  ///
+  /// This function returns true if the register passed in RegName can be used
+  /// for global register variables on this target. In addition, it returns
+  /// true in HasSizeMismatch if the size of the register doesn't match the
+  /// variable size passed in RegSize.
+  virtual bool validateGlobalRegisterVariable(StringRef RegName,
+  unsigned RegSize,
+  bool &HasSizeMismatch) const {
+HasSizeMismatch = false;
+return true;
+  }
+
   // validateOutputConstraint, validateInputConstraint - Checks that
   // a constraint is valid and provides information about it.
   // FIXME: These should return a real error instead of just true/false.
Index: cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
===
--- cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
+++ cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu
@@ -5,22 +5,22 @@
 
 __attribute__((device)) register long global_dev_reg asm("r0");
 __attribute__((device)) register long
-global_dev_hreg asm("rax"); // device-side error
+global_dev_hreg asm("rsp"); // device-side error
 
-register long global_host_reg asm("rax");
+register long global_host_reg asm("rsp");
 register long global_host_dreg asm("r0"); // host-side error
 
 __attribute__((device)) void df() {
   register long local_dev_reg asm("r0");
-  register long local_host_reg asm("rax"); // device-side error
+  register long local_host_reg asm("rsp"); // device-side error
   short h;
   // asm with PTX constraints. Some of them are PTX-specific.
   __asm__("dont care" : "=h"(h) : "f"(0.0), "d"(0.0), "h"(0), "r"(0), "l"(0));
 }
 
 void hf() {
   register long local_dev_reg asm("r0"); // host-side error
-  register long local_host_reg asm("rax");
+  register long local_host_reg asm("rsp");
   int a;
   // Asm with x86 constraints and registers that are not supported by PTX.
   __asm__("dont care" : "=a"(a) : "a"(0), "b"(0), "c"(0) : "flags");
@@ -30,8 +30,8 @@
 // We should only see errors relevant to current compilation mode.
 #if defined(__CUDA_ARCH__)
 // Device-side compilation:
-// expected-error@8 {{unknown register name 'rax' in asm}}
-// expected-error@15 {{unknown register name 'rax' in asm}}
+// expected-error@8 {{unknown register name 'rsp' in asm}}
+// expected-error@15 {{unknown register name 'rsp' in asm}}
 #else
 // Host-side compilation:
 // expected-error@11 {{unknown register name 'r0' in asm}}
Index: cfe/trunk/test/CodeGen/named_reg_global.c
===
--- cfe/trunk/test/CodeGen/named_reg_global.c
+++ cfe/trunk/test/CodeGen/named_reg_global.c
@@ -1,16 +1,26 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
-// RUN: %clan

r253405 - Produce a better diagnostic for global register variables.

2015-11-17 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue Nov 17 18:15:28 2015
New Revision: 253405

URL: http://llvm.org/viewvc/llvm-project?rev=253405&view=rev
Log:
Produce a better diagnostic for global register variables.

Currently, when there is a global register variable in a program that
is bound to an invalid register, clang/llvm prints an error message that
is not very user-friendly.

This commit improves the diagnostic and moves the check that used to be
in the backend to Sema. In addition, it makes changes to error out if
the size of the register doesn't match the declared variable size.

e.g., volatile register int B asm ("rbp");

rdar://problem/23084219

Differential Revision: http://reviews.llvm.org/D13834

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/named_reg_global.c
cfe/trunk/test/OpenMP/atomic_capture_codegen.cpp
cfe/trunk/test/OpenMP/atomic_read_codegen.c
cfe/trunk/test/OpenMP/atomic_update_codegen.cpp
cfe/trunk/test/OpenMP/atomic_write_codegen.c
cfe/trunk/test/OpenMP/for_loop_messages.cpp
cfe/trunk/test/OpenMP/threadprivate_messages.cpp
cfe/trunk/test/Sema/asm.c
cfe/trunk/test/SemaCUDA/asm-constraints-mixed.cu

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253405&r1=253404&r2=253405&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 17 18:15:28 
2015
@@ -6543,6 +6543,10 @@ let CategoryName = "Inline Assembly Issu
 "asm constraint has an unexpected number of alternatives: %0 vs %1">;
   def err_asm_incomplete_type : Error<"asm operand has incomplete type %0">;
   def err_asm_unknown_register_name : Error<"unknown register name '%0' in 
asm">;
+  def err_asm_invalid_global_var_reg : Error<"register '%0' unsuitable for "
+"global register variables on this target">;
+  def err_asm_register_size_mismatch : Error<"size of register '%0' does not "
+"match variable size">;
   def err_asm_bad_register_type : Error<"bad type for named register 
variable">;
   def err_asm_invalid_input_size : Error<
 "invalid input size for constraint '%0'">;

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=253405&r1=253404&r2=253405&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Nov 17 18:15:28 2015
@@ -644,6 +644,19 @@ public:
 }
   };
 
+  /// \brief Validate register name used for global register variables.
+  ///
+  /// This function returns true if the register passed in RegName can be used
+  /// for global register variables on this target. In addition, it returns
+  /// true in HasSizeMismatch if the size of the register doesn't match the
+  /// variable size passed in RegSize.
+  virtual bool validateGlobalRegisterVariable(StringRef RegName,
+  unsigned RegSize,
+  bool &HasSizeMismatch) const {
+HasSizeMismatch = false;
+return true;
+  }
+
   // validateOutputConstraint, validateInputConstraint - Checks that
   // a constraint is valid and provides information about it.
   // FIXME: These should return a real error instead of just true/false.

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=253405&r1=253404&r2=253405&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov 17 18:15:28 2015
@@ -2358,6 +2358,20 @@ public:
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &info) const override;
 
+  bool validateGlobalRegisterVariable(StringRef RegName,
+  unsigned RegSize,
+  bool &HasSizeMismatch) const override {
+// esp and ebp are the only 32-bit registers the x86 backend can currently
+// handle.
+if (RegName.equals("esp") || RegName.equals("ebp")) {
+  // Check that the register size is 32-bit.
+  HasSizeMismatch = RegSize != 32;
+  return true;
+}
+
+return false;
+  }
+
   bool validateOutputSize(StringRef Constraint, unsigned Size) const override;
 
   bool validateInputSize(StringRef Constraint, unsigned Size) const override;
@@ -3974,6 +3988,22 @@ public:
 
   // for x32 we need it here explicitly
   bool hasInt128Type() const override { ret

r253410 - Fix for use-after-free which caused test failure in cuda-detect.cu.

2015-11-17 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Nov 17 18:37:41 2015
New Revision: 253410

URL: http://llvm.org/viewvc/llvm-project?rev=253410&view=rev
Log:
Fix for use-after-free which caused test failure in cuda-detect.cu.

Return std::string itself instead StringRef to a temporary std::string.

Modified:
cfe/trunk/lib/Driver/ToolChains.h

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253410&r1=253409&r2=253410&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov 17 18:37:41 2015
@@ -186,7 +186,7 @@ protected:
 /// \brief Get the detected Cuda device library path.
 StringRef getLibDevicePath() const { return CudaLibDevicePath; }
 /// \brief Get libdevice file for given architecture
-StringRef getLibDeviceFile(StringRef Gpu) const {
+std::string getLibDeviceFile(StringRef Gpu) const {
   return CudaLibDeviceMap.lookup(Gpu);
 }
   };


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


Re: [clang-tools-extra] r253401 - [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-11-17 Thread Bruno Cardoso Lopes via cfe-commits
Hi Matthias,

This is failing on the green dragon bot:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/13184/
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/13184/consoleFull#54616856949ba4694-19c4-4d7e-bec5-911270d8a58c

Thanks,

On Tue, Nov 17, 2015 at 3:43 PM, Matthias Gehre via cfe-commits
 wrote:
> Author: mgehre
> Date: Tue Nov 17 17:43:20 2015
> New Revision: 253401
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253401&view=rev
> Log:
> [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index
>
> Summary:
> This check flags all array subscriptions on static arrays and
> std::arrays that either have a non-compile-time-constant index or are
> out of bounds.
>
> Dynamic accesses into arrays are difficult for both tools and humans to
> validate as safe. array_view is a bounds-checked, safe type for
> accessing arrays of data. at() is another alternative that ensures
> single accesses are bounds-checked. If iterators are needed to access an
> array, use the iterators from an array_view constructed over the array.
>
> This rule is part of the "Bounds safety" profile of the C++ Core
> Guidelines, see
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds2-only-index-into-arrays-using-constant-expressions
>
> Reviewers: alexfh, sbenza, bkramer, aaron.ballman
>
> Subscribers: cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D13746
>
> Added:
> 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
> 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h
> 
> clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
> 
> clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
> 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=253401&r1=253400&r2=253401&view=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Tue 
> Nov 17 17:43:20 2015
> @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
>  add_clang_library(clangTidyCppCoreGuidelinesModule
>CppCoreGuidelinesTidyModule.cpp
>ProBoundsArrayToPointerDecayCheck.cpp
> +  ProBoundsConstantArrayIndexCheck.cpp
>ProBoundsPointerArithmeticCheck.cpp
>ProTypeConstCastCheck.cpp
>ProTypeCstyleCastCheck.cpp
>
> Modified: 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=253401&r1=253400&r2=253401&view=diff
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
>  Tue Nov 17 17:43:20 2015
> @@ -12,6 +12,7 @@
>  #include "../ClangTidyModuleRegistry.h"
>  #include "../misc/AssignOperatorSignatureCheck.h"
>  #include "ProBoundsArrayToPointerDecayCheck.h"
> +#include "ProBoundsConstantArrayIndexCheck.h"
>  #include "ProBoundsPointerArithmeticCheck.h"
>  #include "ProTypeConstCastCheck.h"
>  #include "ProTypeCstyleCastCheck.h"
> @@ -30,6 +31,8 @@ public:
>void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
>  CheckFactories.registerCheck(
>  "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
> +CheckFactories.registerCheck(
> +"cppcoreguidelines-pro-bounds-constant-array-index");
>  CheckFactories.registerCheck(
>  "cppcoreguidelines-pro-bounds-pointer-arithmetic");
>  CheckFactories.registerCheck(
>
> Added: 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=253401&view=auto
> ==
> --- 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
>  (added)
> +++ 
> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
>  Tue Nov 17 17:43:20 2015
> @@ -0,0 +1,131 @@
> +//===--- ProBoundsConstantArrayIndexCheck.cpp - 
> clang-tidy

Re: [PATCH] D13488: [analyzer] Assume escape is possible through system functions taking void*

2015-11-17 Thread Anna Zaks via cfe-commits
zaks.anna closed this revision.
zaks.anna added a comment.

Committed in r251449.


http://reviews.llvm.org/D13488



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


Re: r252853 - libclang: add clang_Cursor_getCXXManglings

2015-11-17 Thread Reid Kleckner via cfe-commits
This introduced a memory leak, which I'm testing a patch for.

Aside from that, did you get Doug to review this? We probably want to be
really careful about changing libclang's C API, so you should be more
cautious here than you would be normally.

On Wed, Nov 11, 2015 at 7:57 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: compnerd
> Date: Wed Nov 11 21:57:22 2015
> New Revision: 252853
>
> URL: http://llvm.org/viewvc/llvm-project?rev=252853&view=rev
> Log:
> libclang: add clang_Cursor_getCXXManglings
>
> This function permits the mangling of a C++ 'structor.  Depending on the
> ABI and
> the declaration, the declaration may contain more than one associated
> symbol for
> a given declaration.  This allows the consumer to retrieve all of the
> associated
> symbols for the declaration the cursor points to.
>
> Added:
> cfe/trunk/test/Index/print-cxx-manglings.cpp
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/libclang.exports
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=252853&r1=252852&r2=252853&view=diff
>
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Wed Nov 11 21:57:22 2015
> @@ -3863,6 +3863,12 @@ CINDEX_LINKAGE CXString clang_Cursor_get
>  CINDEX_LINKAGE CXString clang_Cursor_getMangling(CXCursor);
>
>  /**
> + * \brief Retrieve the CXStrings representing the mangled symbols of the
> C++
> + * constructor or destructor at the cursor.
> + */
> +CINDEX_LINKAGE CXStringSet *clang_Cursor_getCXXManglings(CXCursor);
> +
> +/**
>   * @}
>   */
>
>
> Added: cfe/trunk/test/Index/print-cxx-manglings.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-cxx-manglings.cpp?rev=252853&view=auto
>
> ==
> --- cfe/trunk/test/Index/print-cxx-manglings.cpp (added)
> +++ cfe/trunk/test/Index/print-cxx-manglings.cpp Wed Nov 11 21:57:22 2015
> @@ -0,0 +1,66 @@
> +// REQUIRES: x86-registered-target
> +
> +// RUN: c-index-test -write-pch %t.itanium.ast -target i686-pc-linux-gnu
> -fdeclspec %s
> +// RUN: c-index-test -test-print-manglings %t.itanium.ast | FileCheck
> --check-prefix=ITANIUM %s
> +
> +// RUN: c-index-test -write-pch %t.macho.ast -target i686-apple-darwin
> -fdeclspec %s
> +// RUN: c-index-test -test-print-manglings %t.macho.ast | FileCheck
> --check-prefix=MACHO %s
> +
> +// RUN: c-index-test -write-pch %t.msvc.ast -target i686-pc-windows %s
> +// RUN: c-index-test -test-print-manglings %t.msvc.ast | FileCheck
> --check-prefix=MSVC %s
> +
> +struct s {
> +  s(int);
> +  ~s();
> +  int m(int);
> +};
> +
> +// ITANIUM: CXXConstructor=s{{.*}}[mangled=_ZN1sC2Ei] [mangled=_ZN1sC1Ei]
> +// ITANIUM: CXXDestructor=~s{{.*}}[mangled=_ZN1sD2Ev] [mangled=_ZN1sD1Ev]
> [mangled=_ZN1sD0Ev]
> +
> +// MACHO: CXXConstructor=s{{.*}}[mangled=__ZN1sC2Ei] [mangled=__ZN1sC1Ei]
> +// MACHO: CXXDestructor=~s{{.*}}[mangled=__ZN1sD2Ev] [mangled=__ZN1sD1Ev]
> [mangled=__ZN1sD0Ev]
> +
> +// MSVC: CXXConstructor=s{{.*}}[mangled=??0s@@QAE@H@Z]
> +// MSVC: CXXDestructor=~s{{.*}}[mangled=??1s@@QAE@XZ]
> +
> +struct t {
> +  t(int);
> +  virtual ~t();
> +  int m(int);
> +};
> +
> +// ITANIUM: CXXConstructor=t{{.*}}[mangled=_ZN1tC2Ei] [mangled=_ZN1tC1Ei]
> +// ITANIUM: CXXDestructor=~t{{.*}}[mangled=_ZN1tD2Ev] [mangled=_ZN1tD1Ev]
> +
> +// MACHO: CXXConstructor=t{{.*}}[mangled=__ZN1tC2Ei] [mangled=__ZN1tC1Ei]
> +// MACHO: CXXDestructor=~t{{.*}}[mangled=__ZN1tD2Ev] [mangled=__ZN1tD1Ev]
> +
> +// MSVC: CXXConstructor=t{{.*}}[mangled=??0t@@QAE@H@Z]
> +// MSVC: CXXDestructor=~t{{.*}}[mangled=??1t@@UAE@XZ]
> +
> +struct u {
> +  u();
> +  virtual ~u();
> +  virtual int m(int) = 0;
> +};
> +
> +// ITANIUM: CXXConstructor=u{{.*}}[mangled=_ZN1uC2Ev]
> +// ITANIUM: CXXDestructor=~u{{.*}}[mangled=_ZN1uD2Ev] [mangled=_ZN1uD1Ev]
> +
> +// MACHO: CXXConstructor=u{{.*}}[mangled=__ZN1uC2Ev]
> +// MACHO: CXXDestructor=~u{{.*}}[mangled=__ZN1uD2Ev] [mangled=__ZN1uD1Ev]
> +
> +// MSVC: CXXConstructor=u{{.*}}[mangled=??0u@@QAE@XZ]
> +// MSVC: CXXDestructor=~u{{.*}}[mangled=??1u@@UAE@XZ]
> +
> +struct v {
> +  __declspec(dllexport) v(int = 0);
> +};
> +
> +// ITANIUM: CXXConstructor=v{{.*}}[mangled=_ZN1vC2Ei] [mangled=_ZN1vC1Ei]
> +
> +// MACHO: CXXConstructor=v{{.*}}[mangled=__ZN1vC2Ei] [mangled=__ZN1vC1Ei]
> +
> +// MSVC: CXXConstructor=v{{.*}}[mangled=??0v@@QAE@H@Z] [mangled=??_Fv@
> @QAEXXZ]
> +
>
> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=252853&r1=252852&r2=252853&view=diff
>
> ==
> --- cfe/trunk/tools/c-inde

r253418 - Try to fix leak in CXStringSet from r252853

2015-11-17 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Nov 17 19:06:39 2015
New Revision: 253418

URL: http://llvm.org/viewvc/llvm-project?rev=253418&view=rev
Log:
Try to fix leak in CXStringSet from r252853

Modified:
cfe/trunk/tools/libclang/CXString.cpp

Modified: cfe/trunk/tools/libclang/CXString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXString.cpp?rev=253418&r1=253417&r2=253418&view=diff
==
--- cfe/trunk/tools/libclang/CXString.cpp (original)
+++ cfe/trunk/tools/libclang/CXString.cpp Tue Nov 17 19:06:39 2015
@@ -186,6 +186,8 @@ void clang_disposeString(CXString string
 }
 
 void clang_disposeStringSet(CXStringSet *set) {
+  for (unsigned SI = 0, SE = set->Count; SI < SE; ++SI)
+clang_disposeString(set->Strings[SI]);
   delete[] set->Strings;
   delete set;
 }


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


Re: r253410 - Fix for use-after-free which caused test failure in cuda-detect.cu.

2015-11-17 Thread David Blaikie via cfe-commits
On Tue, Nov 17, 2015 at 4:37 PM, Artem Belevich via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: tra
> Date: Tue Nov 17 18:37:41 2015
> New Revision: 253410
>
> URL: http://llvm.org/viewvc/llvm-project?rev=253410&view=rev
> Log:
> Fix for use-after-free which caused test failure in cuda-detect.cu.
>
> Return std::string itself instead StringRef to a temporary std::string.
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains.h
>
> Modified: cfe/trunk/lib/Driver/ToolChains.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253410&r1=253409&r2=253410&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov 17 18:37:41 2015
> @@ -186,7 +186,7 @@ protected:
>  /// \brief Get the detected Cuda device library path.
>  StringRef getLibDevicePath() const { return CudaLibDevicePath; }
>  /// \brief Get libdevice file for given architecture
> -StringRef getLibDeviceFile(StringRef Gpu) const {
> +std::string getLibDeviceFile(StringRef Gpu) const {
>return CudaLibDeviceMap.lookup(Gpu);
>

You could implement this as:

auto I = CudaLibDeviceMap.find(Gpu);
return I != CudaLibDeviceMap.end() ? I->second : "";

returning StringRef

Or, if you know the element will always be in the collection, you could
just assert that and "return CudaLibDeviceMap[Gpu]; - and you could return
const std::string& there, or StringRef, whichever.

(both/any of these options would avoid needing to allocate a new string to
every caller)


>  }
>};
>
>
> ___
> 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: [PATCH] D14652: [analyzer] Improve modeling of static initializers.

2015-11-17 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: test/Analysis/inline.cpp:308
@@ +307,3 @@
+clang_analyzer_eval(0 != void_string); // expected-warning{{TRUE}}
+clang_analyzer_eval(0 != ((char *)void_string)[1]); // 
expected-warning{{TRUE}}
+  }

Why are we checking that the first element is not '0'?


http://reviews.llvm.org/D14652



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


r253420 - Don't expose iterators into the list of types on the ASTContext; these are

2015-11-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Nov 17 19:19:02 2015
New Revision: 253420

URL: http://llvm.org/viewvc/llvm-project?rev=253420&view=rev
Log:
Don't expose iterators into the list of types on the ASTContext; these are
unsafe, since many operations on the types can trigger lazy deserialization of
more types and invalidate the iterators. This fixes a crasher, but I've not
been able to reduce it to a reasonable testcase yet.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=253420&r1=253419&r2=253420&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Nov 17 19:19:02 2015
@@ -2274,16 +2274,6 @@ public:
   QualType getCorrespondingUnsignedType(QualType T) const;
 
   
//======//
-  //Type Iterators.
-  
//======//
-  typedef llvm::iterator_range::const_iterator>
-type_const_range;
-
-  type_const_range types() const {
-return type_const_range(Types.begin(), Types.end());
-  }
-
-  
//======//
   //Integer Values
   
//======//
 

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=253420&r1=253419&r2=253420&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Tue Nov 17 19:19:02 2015
@@ -3873,7 +3873,12 @@ void TypoCorrectionConsumer::addNamespac
 if (const Type *T = NNS->getAsType())
   SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization;
   }
-  for (const auto *TI : SemaRef.getASTContext().types()) {
+  // Do not transform this into an iterator-based loop. The loop body can
+  // trigger the creation of further types (through lazy deserialization) and
+  // invalide iterators into this list.
+  auto &Types = SemaRef.getASTContext().getTypes();
+  for (unsigned I = 0; I != Types.size(); ++I) {
+const auto *TI = Types[I];
 if (!TI->isClassType() && isa(TI))
   continue;
 if (CXXRecordDecl *CD = TI->getAsCXXRecordDecl()) {


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


Re: r253410 - Fix for use-after-free which caused test failure in cuda-detect.cu.

2015-11-17 Thread Artem Belevich via cfe-commits
getLibDeviceFile only used once per device-side compilation in driver, so
returning the string should be OK here.

BTW, would copy elision kick in when I use std::string Path =
getLibDeviceFile("foo"); ?

--Artem

On Tue, Nov 17, 2015 at 5:12 PM, David Blaikie  wrote:

>
>
> On Tue, Nov 17, 2015 at 4:37 PM, Artem Belevich via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: tra
>> Date: Tue Nov 17 18:37:41 2015
>> New Revision: 253410
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253410&view=rev
>> Log:
>> Fix for use-after-free which caused test failure in cuda-detect.cu.
>>
>> Return std::string itself instead StringRef to a temporary std::string.
>>
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains.h
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253410&r1=253409&r2=253410&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov 17 18:37:41 2015
>> @@ -186,7 +186,7 @@ protected:
>>  /// \brief Get the detected Cuda device library path.
>>  StringRef getLibDevicePath() const { return CudaLibDevicePath; }
>>  /// \brief Get libdevice file for given architecture
>> -StringRef getLibDeviceFile(StringRef Gpu) const {
>> +std::string getLibDeviceFile(StringRef Gpu) const {
>>return CudaLibDeviceMap.lookup(Gpu);
>>
>
> You could implement this as:
>
> auto I = CudaLibDeviceMap.find(Gpu);
> return I != CudaLibDeviceMap.end() ? I->second : "";
>
> returning StringRef
>
> Or, if you know the element will always be in the collection, you could
> just assert that and "return CudaLibDeviceMap[Gpu]; - and you could return
> const std::string& there, or StringRef, whichever.
>
> (both/any of these options would avoid needing to allocate a new string to
> every caller)
>
>
>>  }
>>};
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>


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


Re: r253410 - Fix for use-after-free which caused test failure in cuda-detect.cu.

2015-11-17 Thread David Blaikie via cfe-commits
On Tue, Nov 17, 2015 at 5:35 PM, Artem Belevich  wrote:

> getLibDeviceFile only used once per device-side compilation in driver, so
> returning the string should be OK here.
>
> BTW, would copy elision kick in when I use std::string Path =
> getLibDeviceFile("foo"); ?
>

Yeah - if the caller needs a copy anyway (if they're going to build a new
string from it - appending things, etc) then, yeah, the API choice won't
impact performance much/at all.

- Dave


>
> --Artem
>
> On Tue, Nov 17, 2015 at 5:12 PM, David Blaikie  wrote:
>
>>
>>
>> On Tue, Nov 17, 2015 at 4:37 PM, Artem Belevich via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: tra
>>> Date: Tue Nov 17 18:37:41 2015
>>> New Revision: 253410
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=253410&view=rev
>>> Log:
>>> Fix for use-after-free which caused test failure in cuda-detect.cu.
>>>
>>> Return std::string itself instead StringRef to a temporary std::string.
>>>
>>> Modified:
>>> cfe/trunk/lib/Driver/ToolChains.h
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=253410&r1=253409&r2=253410&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/Driver/ToolChains.h (original)
>>> +++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov 17 18:37:41 2015
>>> @@ -186,7 +186,7 @@ protected:
>>>  /// \brief Get the detected Cuda device library path.
>>>  StringRef getLibDevicePath() const { return CudaLibDevicePath; }
>>>  /// \brief Get libdevice file for given architecture
>>> -StringRef getLibDeviceFile(StringRef Gpu) const {
>>> +std::string getLibDeviceFile(StringRef Gpu) const {
>>>return CudaLibDeviceMap.lookup(Gpu);
>>>
>>
>> You could implement this as:
>>
>> auto I = CudaLibDeviceMap.find(Gpu);
>> return I != CudaLibDeviceMap.end() ? I->second : "";
>>
>> returning StringRef
>>
>> Or, if you know the element will always be in the collection, you could
>> just assert that and "return CudaLibDeviceMap[Gpu]; - and you could return
>> const std::string& there, or StringRef, whichever.
>>
>> (both/any of these options would avoid needing to allocate a new string
>> to every caller)
>>
>>
>>>  }
>>>};
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
>
> --
> --Artem Belevich
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r253428 - Revert r253401, "[clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index"

2015-11-17 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Nov 17 20:14:35 2015
New Revision: 253428

URL: http://llvm.org/viewvc/llvm-project?rev=253428&view=rev
Log:
Revert r253401, "[clang-tidy] add check 
cppcoreguidelines-pro-bounds-constant-array-index"

cppcoreguidelines-pro-bounds-constant-array-index.cpp is failing in several 
hosts.

Removed:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=253428&r1=253427&r2=253428&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Tue Nov 
17 20:14:35 2015
@@ -3,7 +3,6 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyCppCoreGuidelinesModule
   CppCoreGuidelinesTidyModule.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
-  ProBoundsConstantArrayIndexCheck.cpp
   ProBoundsPointerArithmeticCheck.cpp
   ProTypeConstCastCheck.cpp
   ProTypeCstyleCastCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=253428&r1=253427&r2=253428&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Tue Nov 17 20:14:35 2015
@@ -12,7 +12,6 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/AssignOperatorSignatureCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
-#include "ProBoundsConstantArrayIndexCheck.h"
 #include "ProBoundsPointerArithmeticCheck.h"
 #include "ProTypeConstCastCheck.h"
 #include "ProTypeCstyleCastCheck.h"
@@ -31,8 +30,6 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
-CheckFactories.registerCheck(
-"cppcoreguidelines-pro-bounds-constant-array-index");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
 CheckFactories.registerCheck(

Removed: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp?rev=253427&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 (removed)
@@ -1,131 +0,0 @@
-//===--- ProBoundsConstantArrayIndexCheck.cpp - 
clang-tidy-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "ProBoundsConstantArrayIndexCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Lex/Preprocessor.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-
-ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck(
-StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), GslHeader(Options.get("GslHeader", "")),
-  IncludeStyle(IncludeSorter::parseIncludeStyle(
-  Options.get("IncludeStyle", "llvm"))) {}
-
-void ProBoundsConstantArrayIndexCheck::storeOptions(
-ClangTidyOptions::OptionMap &Opts) {
-  Options.store(Opts, "GslHeader", GslHeader);
-}
-
-void ProBoundsConstantArrayIndexCheck::registerPPCallbacks(
-CompilerInstance &Compiler) {
-  if (!getLangOpts().CPlusPlus)
-return;
-
-  Inserter.reset(new IncludeInserter(Compiler.getSourceManager(),
- Compiler.getLan

Re: [PATCH] D13746: [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-index

2015-11-17 Thread NAKAMURA Takumi via cfe-commits
chapuni added a subscriber: chapuni.
chapuni added a comment.

I have reverted in r253428, since I can reproduce failure locally. I'll 
investigate later, too.



Comment at: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-bounds-constant-array-index.cpp:2
@@ +1,3 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-bounds-constant-array-index 
%t -- -config='{CheckOptions: [{key: 
cppcoreguidelines-pro-bounds-constant-array-index.GslHeader, value: 
"dir1/gslheader.h"}]}' -- -std=c++11
+#include 
+// CHECK-FIXES: #include "dir1/gslheader.h"

Standard headers might be unavailable depending on a target, like host=linux 
target=msvc.
Could you improve it?


  # Avoid 
  # Introduce a new feature like "native"




Repository:
  rL LLVM

http://reviews.llvm.org/D13746



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-17 Thread Stephane Moore via cfe-commits
stephanemoore added a subscriber: stephanemoore.
stephanemoore added a comment.

I hope that it's not presumptuous of me to inquire but I was wondering if the 
intent of this patch is to optimize calls to RR methods (and alloc) in non-ARC 
code? Would I be correct in assuming that clang will already emit direct calls 
to relevant RR runtime functions when ARC is enabled?


http://reviews.llvm.org/D14737



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


Re: [PATCH] D14737: Convert some ObjC msgSends to runtime calls

2015-11-17 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D14737#291481, @stephanemoore wrote:

> I hope that it's not presumptuous of me to inquire but I was wondering if the 
> intent of this patch is to optimize calls to RR methods (and alloc) in 
> non-ARC code? Would I be correct in assuming that clang will already emit 
> direct calls to relevant RR runtime functions when ARC is enabled?


Correct.  The patch turns ObjC message sends of -retain, -release, and +alloc 
into calls to the runtime functions we already use in ARC.

This is largely irrelevant in ARC because it's illegal to write an ObjC message 
send of -retain or -release.  The change to +alloc would still apply, however.


http://reviews.llvm.org/D14737



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


r253431 - [NFC] Change the evaluation context of a non-type default template argument from Unevaluated to ConstantEvaluated.

2015-11-17 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Tue Nov 17 22:29:22 2015
New Revision: 253431

URL: http://llvm.org/viewvc/llvm-project?rev=253431&view=rev
Log:
[NFC] Change the evaluation context of a non-type default template argument 
from Unevaluated to ConstantEvaluated.  

This patch emits a more appropriate (but still noisy) diagnostic stream when a 
lambda-expression is encountered within a non-type default argument. 

For e.g. template int f();

As opposed to complaining that a lambda expression is not allowed in an 
unevaluated operand, the patch complains about the lambda being forbidden in a 
constant expression context (which will be allowed in C++17 now that they have 
been accepted by EWG, unless of course CWG or national bodies (that have so far 
shown no signs of concern) rise in protest) 

As I start submitting patches for constexpr lambdas (http://wg21.link/P0170R0) 
under C++1z (OK'd by Richard Smith at Kona), this will be one less change to 
make.

Thanks!

Modified:
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=253431&r1=253430&r2=253431&view=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Tue Nov 17 22:29:22 2015
@@ -695,7 +695,8 @@ Parser::ParseNonTypeTemplateParameter(un
 //   end of the template-parameter-list rather than a greater-than
 //   operator.
 GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
-EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
+EnterExpressionEvaluationContext Unevaluated(Actions,
+ Sema::ConstantEvaluated);
 
 DefaultArg = 
Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
 if (DefaultArg.isInvalid())

Modified: cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp?rev=253431&r1=253430&r2=253431&view=diff
==
--- cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp Tue Nov 17 
22:29:22 2015
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -triple=x86_64-linux-gnu 
%s -DCPP11ONLY
 
 // C++11 [temp.arg.nontype]p1:
 //
@@ -6,6 +7,8 @@
 //   be one of:
 //   -- an integral constant expression; or
 //   -- the name of a non-type template-parameter ; or
+#ifndef CPP11ONLY 
+
 namespace non_type_tmpl_param {
   template  struct X0 { X0(); };
   template  X0::X0() { }
@@ -95,3 +98,14 @@ namespace bad_args {
   int* iptr = &i;
   X0 x0b; // expected-error{{non-type template argument for template 
parameter of pointer type 'int *' must have its address taken}}
 }
+#endif // CPP11ONLY
+
+namespace default_args {
+#ifdef CPP11ONLY
+namespace lambdas {
+template //expected-error 2{{constant 
expression}} expected-note{{constant expression}}
+int f();
+}
+#endif // CPP11ONLY
+
+}
\ No newline at end of file


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


Re: [PATCH] D14652: [analyzer] Improve modeling of static initializers.

2015-11-17 Thread Yury Gribov via cfe-commits
ygribov added inline comments.


Comment at: test/Analysis/inline.cpp:308
@@ +307,3 @@
+clang_analyzer_eval(0 != void_string); // expected-warning{{TRUE}}
+clang_analyzer_eval(0 != ((char *)void_string)[1]); // 
expected-warning{{TRUE}}
+  }

zaks.anna wrote:
> Why are we checking that the first element is not '0'?
We could check s[0] as well, there is no difference actually.


http://reviews.llvm.org/D14652



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


r253434 - BuildUniversalActions(): Prune obsolete \param(s). [-Wdocumentation]

2015-11-17 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Nov 17 23:15:21 2015
New Revision: 253434

URL: http://llvm.org/viewvc/llvm-project?rev=253434&view=rev
Log:
BuildUniversalActions(): Prune obsolete \param(s). [-Wdocumentation]

FIXME: Describe BAInputs.

Modified:
cfe/trunk/include/clang/Driver/Driver.h

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=253434&r1=253433&r2=253434&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Nov 17 23:15:21 2015
@@ -310,8 +310,6 @@ public:
   ///
   /// \param C - The compilation that is being built.
   /// \param TC - The default host tool chain.
-  /// \param Args - The input arguments.
-  /// \param Actions - The list to store the resulting actions onto.
   void BuildUniversalActions(Compilation &C, const ToolChain &TC,
  const InputList &BAInputs) const;
 


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


[libcxxabi] r253435 - c++abi: use __builtin_offsetof instead of offsetof

2015-11-17 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Nov 17 23:33:38 2015
New Revision: 253435

URL: http://llvm.org/viewvc/llvm-project?rev=253435&view=rev
Log:
c++abi: use __builtin_offsetof instead of offsetof

Use `__builtin_offsetof` in place of `offsetof`.  Certain environments provide a
macro definition of `offsetof` which may end up causing issues.  This was
observed on Windows.  Use `__builtin_offsetof` to ensure correct evaluation
everywhere.  NFC.

Modified:
libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=253435&r1=253434&r2=253435&view=diff
==
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Tue Nov 17 23:33:38 2015
@@ -448,14 +448,15 @@ void __cxa_end_catch()
   static_assert(sizeof(__cxa_exception) == sizeof(__cxa_dependent_exception),
 "sizeof(__cxa_exception) must be equal to "
 "sizeof(__cxa_dependent_exception)");
-static_assert(offsetof(__cxa_exception, referenceCount) ==
-  offsetof(__cxa_dependent_exception, primaryException),
-  "the layout of __cxa_exception must match the layout of "
-  "__cxa_dependent_exception");
-static_assert(offsetof(__cxa_exception, handlerCount) ==
-  offsetof(__cxa_dependent_exception, handlerCount),
-  "the layout of __cxa_exception must match the layout of "
-  "__cxa_dependent_exception");
+  static_assert(__builtin_offsetof(__cxa_exception, referenceCount) ==
+__builtin_offsetof(__cxa_dependent_exception,
+   primaryException),
+"the layout of __cxa_exception must match the layout of "
+"__cxa_dependent_exception");
+  static_assert(__builtin_offsetof(__cxa_exception, handlerCount) ==
+__builtin_offsetof(__cxa_dependent_exception, 
handlerCount),
+"the layout of __cxa_exception must match the layout of "
+"__cxa_dependent_exception");
 __cxa_eh_globals* globals = __cxa_get_globals_fast(); // __cxa_get_globals 
called in __cxa_begin_catch
 __cxa_exception* exception_header = globals->caughtExceptions;
 // If we've rethrown a foreign exception, then globals->caughtExceptions


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


r253440 - Update for llvm change.

2015-11-17 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Wed Nov 18 00:54:13 2015
New Revision: 253440

URL: http://llvm.org/viewvc/llvm-project?rev=253440&view=rev
Log:
Update for llvm change.

Modified:
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=253440&r1=253439&r2=253440&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Wed Nov 18 00:54:13 2015
@@ -141,7 +141,7 @@ public:
 
   /// \brief The set of macro names that should be ignored for the purposes
   /// of computing the module hash.
-  llvm::SetVector ModulesIgnoreMacros;
+  llvm::SmallSetVector ModulesIgnoreMacros;
 
   /// \brief The set of user-provided virtual filesystem overlay files.
   std::vector VFSOverlayFiles;

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=253440&r1=253439&r2=253440&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Nov 18 00:54:13 2015
@@ -833,7 +833,7 @@ protected:
   llvm::DenseMap MethodVarNames;
 
   /// DefinedCategoryNames - list of category names in form Class_Category.
-  llvm::SetVector DefinedCategoryNames;
+  llvm::SmallSetVector DefinedCategoryNames;
 
   /// MethodVarTypes - uniqued method type signatures. We have to use
   /// a StringMap here because have no other unique reference.


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


[clang-tools-extra] r253442 - Replace a dyn_cast with isa where the result was only being used as a boolean. NFC.

2015-11-17 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Nov 18 01:08:11 2015
New Revision: 253442

URL: http://llvm.org/viewvc/llvm-project?rev=253442&view=rev
Log:
Replace a dyn_cast with isa where the result was only being used as a boolean. 
NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp?rev=253442&r1=253441&r2=253442&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp Wed Nov 18 
01:08:11 2015
@@ -302,7 +302,7 @@ void UseDefaultCheck::check(const MatchF
   if (!StartLoc.isValid())
 return;
 }
-  } else if (dyn_cast(SpecialFunctionDecl)) {
+  } else if (isa(SpecialFunctionDecl)) {
 SpecialFunctionName = "destructor";
   } else {
 if (!isCopyAssignmentAndCanBeDefaulted(Result.Context, 
SpecialFunctionDecl))


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