[PATCH] D26691: [analyzer] Run clang-format and fix style

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Thank you!




Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:459
   // Notice that the lower bound is greater than the upper bound.
-  RangeSet New = GetRange(St, Sym).Intersect(getBasicVals(), F, Upper, Lower);
+  RangeSet New = getRange(St, Sym).Intersect(getBasicVals(), F, Upper, Lower);
   return New.isEmpty() ? nullptr : St->set(Sym, New);

ddcc wrote:
> zaks.anna wrote:
> > ddcc wrote:
> > > zaks.anna wrote:
> > > > We should use lower case function names.
> > > Are you saying more functions should be changed to lowercase (e.g. 
> > > intersect)? Or that `getRange` should be `getrange`?
> > Should be "camel case, and start with a lower case letter", see:
> > 
> > http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
> Right, isn't changing `GetRange` to `getRange` correct then? I'm a little 
> confused, is there something else that needs to be fixed?
Sorry, my bad. This does look good!


https://reviews.llvm.org/D26691



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


[PATCH] D27600: [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

LGTM!


https://reviews.llvm.org/D27600



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


[PATCH] D27091: Add the way to extract SVals of arguments used in a call for a given StackFrameCtx

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Update: Adding support for top frame to the CallEvent is difficult, so let's 
just use CallEvent API in the checkers for all frames but the top one and have 
custom top frame handling in the Recursion checker itself. The top frame 
handling does not need to be complete (handle all call types) since in the 
worst case we will be missing bugs (no false positives due to this).


https://reviews.llvm.org/D27091



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


[PATCH] D27202: [analyzer] Do not conjure a symbol for return value of a conservatively evaluated function

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> Could you please remove the IteratorPastEndChecker file differences from this 
> patch and make https://reviews.llvm.org/D25660 
>  dependent on this one?

Since this has not been reviewed yet while the IteratorPastEndChecker has been, 
I do not think we should block the checker on this.


https://reviews.llvm.org/D27202



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


[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:494
+def ObjCPropertyChecker : Checker<"ObjCProperty">,
+  HelpText<"Find various issues with Objective-C properties">,
+  DescFile<"ObjCPropertyChecker.cpp">;

Nit: maybe use "Check for proper uses of Objective-C properties."? "various 
issues" seems like filler words.


https://reviews.llvm.org/D27535



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


[PATCH] D25435: Add -femit-accurate-debug-info to emit more debug info for sample pgo profile collection

2016-12-09 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2743-2745
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
   !CGM.getCodeGenOpts().EmitGcovNotes &&
+  !CGM.getCodeGenOpts().ProfileDebug &&

echristo wrote:
> danielcdh wrote:
> > echristo wrote:
> > > Should we be encapsulating all of these for profile debug info? I.e. I 
> > > think coverage analysis is going to want the same things.
> > Do you mean that -fcoverage also implies -fprofile-debug?
> > 
> > I think the reason we introduce -fprofile-debug is that it has different 
> > requirments for debug info than coverage/sanitizer. E.g. we want to emit 
> > discriminator for -fprofile-debug, but not coverage/sanitizer.
> So, what are the differences here? I imagine that profile debugging will want 
> accurate source information. Perhaps we should hash this out in the thread 
> that dblaikie has started on llvm-dev.
The discussion about introducing this flag is in the thread of 
http://lists.llvm.org/pipermail/llvm-dev/2016-November/107645.html

Basically -fprofile-debug not only requires accurate source information, it 
also requires:

>> 1. emit linkage name in all subprograms
>> 2. emit discriminator with dup-factor copy-factor encoded
>> 3. use-unknown-locations=true

The above 3 items are not required by -fcoverage. That's why we introduce 
-fprofile-debug to record these extra debug info.


https://reviews.llvm.org/D25435



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


[PATCH] D25435: Add -femit-accurate-debug-info to emit more debug info for sample pgo profile collection

2016-12-09 Thread Eric Christopher via Phabricator via cfe-commits
echristo added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2743-2745
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
   !CGM.getCodeGenOpts().EmitGcovNotes &&
+  !CGM.getCodeGenOpts().ProfileDebug &&

danielcdh wrote:
> echristo wrote:
> > Should we be encapsulating all of these for profile debug info? I.e. I 
> > think coverage analysis is going to want the same things.
> Do you mean that -fcoverage also implies -fprofile-debug?
> 
> I think the reason we introduce -fprofile-debug is that it has different 
> requirments for debug info than coverage/sanitizer. E.g. we want to emit 
> discriminator for -fprofile-debug, but not coverage/sanitizer.
So, what are the differences here? I imagine that profile debugging will want 
accurate source information. Perhaps we should hash this out in the thread that 
dblaikie has started on llvm-dev.


https://reviews.llvm.org/D25435



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


[PATCH] D21453: Add support for attribute "overallocated"

2016-12-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/Decl.h:3250
+  /// This is true if this struct ends with an array marked 'flexible_array'.
+  bool HasFlexibleArrayAttr : 1;
+

ahatanak wrote:
> rsmith wrote:
> > How is this different from `HasFlexibleArrayMember`? Do we really need both?
> As I commented below, we don't need both if we are going to treat an array 
> with flexible_array attribute like other existing flexible arrays.
I forgot to mention this, but one reason I didn't treat arrays with 
flexible_array attribute as C99 flexible arrays is that there are a couple of 
places in IRGen (TargetInfo.cpp) that call hasFlexibleArrayMember() to decide 
how to pass arguments to functions. For example, when I compile the following 
code with "-arch arm64", the first function receives a pointer while the second 
one receives a value:

```
typedef struct {
  int a;
  int b[5];
} S0;

typedef struct {
  int a;
  int b[];
} S1;

S0 g0;
S1 g1;

void foo0(S0 s0) {
  g0 = s0;
}

void foo1(S1 s1) {
  g1 = s1;
}
```

I agree with you that treating flexible_arrays as C99 flexible arrays will 
probably keep the code simple and clean, but I have to see if anyone is using 
structs with flexible arrays in way that will cause ABI breakage. 


https://reviews.llvm.org/D21453



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


[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-09 Thread Howard Hinnant via Phabricator via cfe-commits
howard.hinnant added a comment.

I would like to offer two thoughts:

1. Timing with `steady_clock` is often used to time very short events.  It 
should be respected as the "high_resolution_clock".  This means that two 
consecutive calls to `steady_clock::now()` should return nanoseconds resolution 
and should not be equal unless the implementation is actually able to complete 
a call to `steady_clock::now()` in less than 1ns.

2. Here's test of thought 1:



  #include 
  #include 
  #include 
  #include 
  
  std::chrono::milliseconds
  uptime()
  {
  using namespace std::chrono;
  timeval ts;
  auto ts_len = sizeof(ts);
  int mib[2] = { CTL_KERN, KERN_BOOTTIME };
  auto constexpr mib_len = sizeof(mib)/sizeof(mib[0]);
  if (sysctl(mib, mib_len, , _len, nullptr, 0) == 0)
  {
  system_clock::time_point boot{seconds{ts.tv_sec} + 
microseconds{ts.tv_usec}};
  return duration_cast(system_clock::now() - boot);
  }
  return 0ms;
  }
  
  std::chrono::nanoseconds
  get_uptime_raw()
  {
  using namespace std::chrono;
  struct timespec tp;
  clock_gettime(CLOCK_UPTIME_RAW, );
  return seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec);
  }
  
  std::chrono::nanoseconds
  get_monotonic()
  {
  using namespace std::chrono;
  struct timespec tp;
  clock_gettime(CLOCK_MONOTONIC, );
  return seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec);
  }
  
  #include "date.h"
  #include 
  
  template 
  void
  display(Duration time)
  {
  using namespace date;
  auto d = floor(time);
  time -= d;
  std::cout << d.count() << " days " << make_time(time) << '\n';
  }
  
  int
  main()
  {
  using namespace std::chrono;
  for (int i = 0; i < 4; ++i)
  {
  std::cout << i << '\n';
  {
  auto t0 = uptime();
  auto t1 = uptime();
  std::cout << "boot time : ";  display(t0);
  std::cout << "boot time : ";  display(t1);
  std::cout << "delta boot time   : " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  {
  auto t0 = get_uptime_raw();
  auto t1 = get_uptime_raw();
  std::cout << "CLOCK_UPTIME_RAW  : "; display(t0);
  std::cout << "CLOCK_UPTIME_RAW  : "; display(t1);
  std::cout << "delta CLOCK_UPTIME_RAW time   : " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  {
  auto t0 = get_monotonic();
  auto t1 = get_monotonic();
  std::cout << "CLOCK_MONOTONIC   : "; display(t0);
  std::cout << "CLOCK_MONOTONIC   : "; display(t1);
  std::cout << "delta CLOCK_MONOTONIC time: " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  {
  auto t0 = std::chrono::steady_clock::now().time_since_epoch();
  auto t1 = std::chrono::steady_clock::now().time_since_epoch();
  std::cout << "mach_absolute_time: "; display(t0);
  std::cout << "mach_absolute_time: "; display(t1);
  std::cout << "delta mach_absolute_time time : " << nanoseconds{t1 
- t0}.count() << "ns\n";
  }
  std::cout << '\n';
  }
  }

Sorry, it requires "date.h" from https://github.com/HowardHinnant/date .  It is 
header-only and portable.  It's just used for matting purposes if it really 
stresses you out.

For me this outputs (at -O3):

  Jade:~/Development/cljunk> a.out
  0
  boot time : 11 days 22:30:42.827
  boot time : 11 days 22:30:42.827
  delta boot time   : 0ns
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960672112
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960672266
  delta CLOCK_UPTIME_RAW time   : 154ns
  CLOCK_MONOTONIC   : 11 days 22:30:42.827318000
  CLOCK_MONOTONIC   : 11 days 22:30:42.827318000
  delta CLOCK_MONOTONIC time: 0ns
  mach_absolute_time: 11 days 22:22:28.960714394
  mach_absolute_time: 11 days 22:22:28.960714504
  delta mach_absolute_time time : 110ns
  
  1
  boot time : 11 days 22:30:42.827
  boot time : 11 days 22:30:42.827
  delta boot time   : 0ns
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960761867
  CLOCK_UPTIME_RAW  : 11 days 22:22:28.960761932
  delta CLOCK_UPTIME_RAW time   : 65ns
  CLOCK_MONOTONIC   : 11 days 22:30:42.827402000
  CLOCK_MONOTONIC   : 11 days 22:30:42.827402000
  delta CLOCK_MONOTONIC time: 0ns
  mach_absolute_time: 11 days 22:22:28.960793667
  mach_absolute_time: 11 days 22:22:28.960793747
  delta mach_absolute_time time : 80ns
  
  2
  boot time : 11 days 22:30:42.827
  boot time : 11 days 22:30:42.827
  delta boot 

r289309 - [analyzer] Improve VirtualCallChecker diagnostics and move into optin package.

2016-12-09 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Fri Dec  9 19:16:09 2016
New Revision: 289309

URL: http://llvm.org/viewvc/llvm-project?rev=289309=rev
Log:
[analyzer] Improve VirtualCallChecker diagnostics and move into optin package.

The VirtualCallChecker is in alpha because its interprocedural diagnostics
represent the call path textually in the diagnostic message rather than with a
path sensitive diagnostic.

This patch turns off the AST-based interprocedural analysis in the checker so
that no call path is needed and improves with diagnostic text. With these
changes, the checker is ready to be moved into the optin package.

Ultimately the right fix is to rewrite this checker to be path sensitive -- but
there is still value in enabling the checker for intraprocedural analysis only
The interprocedural mode can be re-enabled with an -analyzer-config flag.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/test/Analysis/virtualcall.cpp
cfe/trunk/test/Analysis/virtualcall.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=289309=289308=289309=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Fri Dec  9 
19:16:09 2016
@@ -42,6 +42,7 @@ def Nullability : Package<"nullability">
 
 def Cplusplus : Package<"cplusplus">;
 def CplusplusAlpha : Package<"cplusplus">, InPackage, Hidden;
+def CplusplusOptIn : Package<"cplusplus">, InPackage;
 
 def Valist : Package<"valist">;
 def ValistAlpha : Package<"valist">, InPackage, Hidden;
@@ -262,13 +263,13 @@ def CXXSelfAssignmentChecker : Checker<"
 
 } // end: "cplusplus"
 
-let ParentPackage = CplusplusAlpha in {
+let ParentPackage = CplusplusOptIn in {
 
 def VirtualCallChecker : Checker<"VirtualCall">,
   HelpText<"Check virtual function calls during construction or destruction">,
   DescFile<"VirtualCallChecker.cpp">;
 
-} // end: "alpha.cplusplus"
+} // end: "optin.cplusplus"
 
 
 
//===--===//

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp?rev=289309=289308=289309=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp Fri Dec  9 
19:16:09 2016
@@ -32,6 +32,18 @@ class WalkAST : public StmtVisitor DFSWorkList;
 
@@ -59,9 +71,16 @@ class WalkAST : public StmtVisitor(rootMethod) ||
+   isa(rootMethod));
+  }
 
   bool hasWork() const { return !WList.empty(); }
 
@@ -132,7 +151,8 @@ void WalkAST::VisitChildren(Stmt *S) {
 
 void WalkAST::VisitCallExpr(CallExpr *CE) {
   VisitChildren(CE);
-  Enqueue(CE);
+  if (IsInterprocedural)
+Enqueue(CE);
 }
 
 void WalkAST::VisitCXXMemberCallExpr(CallExpr *CE) {
@@ -164,51 +184,64 @@ void WalkAST::VisitCXXMemberCallExpr(Cal
   !MD->getParent()->hasAttr())
 ReportVirtualCall(CE, MD->isPure());
 
-  Enqueue(CE);
+  if (IsInterprocedural)
+Enqueue(CE);
 }
 
 void WalkAST::ReportVirtualCall(const CallExpr *CE, bool isPure) {
+  if (ReportPureOnly && !isPure)
+return;
+
   SmallString<100> buf;
   llvm::raw_svector_ostream os(buf);
 
-  os << "Call Path : ";
-  // Name of current visiting CallExpr.
-  os << *CE->getDirectCallee();
-
-  // Name of the CallExpr whose body is current walking.
-  if (visitingCallExpr)
-os << " <-- " << *visitingCallExpr->getDirectCallee();
-  // Names of FunctionDecls in worklist with state PostVisited.
-  for (SmallVectorImpl::iterator I = WList.end(),
+  // FIXME: The interprocedural diagnostic experience here is not good.
+  // Ultimately this checker should be re-written to be path sensitive.
+  // For now, only diagnose intraprocedurally, by default.
+  if (IsInterprocedural) {
+os << "Call Path : ";
+// Name of current visiting CallExpr.
+os << *CE->getDirectCallee();
+
+// Name of the CallExpr whose body is current being walked.
+if (visitingCallExpr)
+  os << " <-- " << *visitingCallExpr->getDirectCallee();
+// Names of FunctionDecls in worklist with state PostVisited.
+for (SmallVectorImpl::iterator I = WList.end(),
  E = WList.begin(); I != E; --I) {
-const FunctionDecl *FD = (*(I-1))->getDirectCallee();
-assert(FD);
-if (VisitedFunctions[FD] == PostVisited)
-  os << " <-- " << *FD;
+  const FunctionDecl *FD = (*(I-1))->getDirectCallee();
+  assert(FD);
+  if (VisitedFunctions[FD] == PostVisited)
+

[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move to optin package.

2016-12-09 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289309: [analyzer] Improve VirtualCallChecker diagnostics 
and move into optin package. (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D26768?vs=80979=80984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26768

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  cfe/trunk/test/Analysis/virtualcall.cpp
  cfe/trunk/test/Analysis/virtualcall.h

Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -42,6 +42,7 @@
 
 def Cplusplus : Package<"cplusplus">;
 def CplusplusAlpha : Package<"cplusplus">, InPackage, Hidden;
+def CplusplusOptIn : Package<"cplusplus">, InPackage;
 
 def Valist : Package<"valist">;
 def ValistAlpha : Package<"valist">, InPackage, Hidden;
@@ -262,13 +263,13 @@
 
 } // end: "cplusplus"
 
-let ParentPackage = CplusplusAlpha in {
+let ParentPackage = CplusplusOptIn in {
 
 def VirtualCallChecker : Checker<"VirtualCall">,
   HelpText<"Check virtual function calls during construction or destruction">,
   DescFile<"VirtualCallChecker.cpp">;
 
-} // end: "alpha.cplusplus"
+} // end: "optin.cplusplus"
 
 
 //===--===//
Index: cfe/trunk/test/Analysis/virtualcall.cpp
===
--- cfe/trunk/test/Analysis/virtualcall.cpp
+++ cfe/trunk/test/Analysis/virtualcall.cpp
@@ -1,36 +1,79 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
+
+/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
+   from a constructor or destructor. If it is not set, we expect diagnostics
+   only in the constructor or destructor.
+
+   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
+   functions not to non-pure virtual functions.
+*/
 
 class A {
 public:
   A();
+  A(int i);
+
   ~A() {};
   
-  virtual int foo() = 0;
+  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
   virtual void bar() = 0;
   void f() {
-foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+foo();
+#if INTERPROCEDURAL
+// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
+#endif
   }
 };
 
 class B : public A {
 public:
   B() {
-foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
   }
   ~B();
   
   virtual int foo();
-  virtual void bar() { foo(); }  // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  virtual void bar() { foo(); }
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
+#endif
 };
 
 A::A() {
   f();
 }
 
+A::A(int i) {
+  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
+#else
+  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
+#endif
+}
+
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  this->foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
+#else

Re: r285301 - Attempt to make clang-format.py python 3 - compatible.

2016-12-09 Thread Vedant Kumar via cfe-commits
I confirmed that this works with :pyf and :py3f.

Committed in r289308.

thanks,
vedant

> On Dec 8, 2016, at 6:51 AM, Alexander Kornienko  wrote:
> 
> If this fixes the problem on python 3 (and it leaves the current behavior on 
> python 2), then it looks good. Can you submit it?
> 
> On Wed, Dec 7, 2016 at 6:59 AM, Vedant Kumar  wrote:
> Hi Alexander,
> 
> I think this will cause an error if used with python3 (at least, it fails on 
> my
> system). Here's the problem:
> 
>   line.decode(encoding)
> 
> When vim is compiled against python3, the type of 'line' remains 'str' -- not
> 'bytes'. There isn't a 'decode' method on strings: it only exists for bytes. I
> take this to mean that vim has done the decoding already. If not, there's a 
> bug
> in vim.
> 
> I've attached a small patch that addresses this issue. Wdyt?
> 
> 
> 
> 
> thanks,
> vedant
> 
> 
> > On Oct 27, 2016, at 8:15 AM, Alexander Kornienko via cfe-commits 
> >  wrote:
> >
> > Author: alexfh
> > Date: Thu Oct 27 10:15:23 2016
> > New Revision: 285301
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=285301=rev
> > Log:
> > Attempt to make clang-format.py python 3 - compatible.
> >
> > Modified:
> >cfe/trunk/tools/clang-format/clang-format.py
> >
> > Modified: cfe/trunk/tools/clang-format/clang-format.py
> > URL: 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=285301=285300=285301=diff
> > ==
> > --- cfe/trunk/tools/clang-format/clang-format.py (original)
> > +++ cfe/trunk/tools/clang-format/clang-format.py Thu Oct 27 10:15:23 2016
> > @@ -51,7 +51,7 @@ if vim.eval('exists("g:clang_format_fall
> > def main():
> >   # Get the current text.
> >   encoding = vim.eval("")
> > -  buf = [ unicode(line, encoding) for line in vim.current.buffer ]
> > +  buf = [ line.decode(encoding) for line in vim.current.buffer ]
> >   text = '\n'.join(buf)
> >
> >   # Determine range to format.
> >
> >
> > ___
> > 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


r289308 - [clang-format] Another attempt at python 3 compatibility

2016-12-09 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Dec  9 18:54:13 2016
New Revision: 289308

URL: http://llvm.org/viewvc/llvm-project?rev=289308=rev
Log:
[clang-format] Another attempt at python 3 compatibility

The entries in vim.current.buffer appear to be decoded strings, which
means that python3 won't allow invoking 'decode' on them. Keep the old
behavior when running under python2, but skip the error-inducing decode
step with python3..

Modified:
cfe/trunk/tools/clang-format/clang-format.py

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=289308=289307=289308=diff
==
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Fri Dec  9 18:54:13 2016
@@ -29,6 +29,7 @@ from __future__ import print_function
 
 import difflib
 import json
+import platform
 import subprocess
 import sys
 import vim
@@ -48,10 +49,15 @@ fallback_style = None
 if vim.eval('exists("g:clang_format_fallback_style")') == "1":
   fallback_style = vim.eval('g:clang_format_fallback_style')
 
+def get_buffer(encoding):
+  if platform.python_version_tuple()[0] == '3':
+return vim.current.buffer
+  return [ line.decode(encoding) for line in vim.current.buffer ]
+
 def main():
   # Get the current text.
   encoding = vim.eval("")
-  buf = [ line.decode(encoding) for line in vim.current.buffer ]
+  buf = get_buffer(encoding)
   text = '\n'.join(buf)
 
   # Determine range to format.


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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move to optin package.

2016-12-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin retitled this revision from "[analyzer] Improve VirtualCallChecker 
diagnostics" to "[analyzer] Improve VirtualCallChecker diagnostics and move to 
optin package.".
dcoughlin updated the summary for this revision.
dcoughlin updated this revision to Diff 80979.
dcoughlin added a comment.

Move the checker to the optin package. The checker will be off by default but 
supported. Projects that are interested in adopting the rule of 'no virtual 
calls in constructors/destructors' can turn this checker on explicitly.


https://reviews.llvm.org/D26768

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp
  test/Analysis/virtualcall.h

Index: test/Analysis/virtualcall.h
===
--- test/Analysis/virtualcall.h
+++ test/Analysis/virtualcall.h
@@ -18,7 +18,15 @@
   class A {
   public:
 A() {
-  foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
 }
 
 virtual int foo();
Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,36 +1,79 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
+
+/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
+   from a constructor or destructor. If it is not set, we expect diagnostics
+   only in the constructor or destructor.
+
+   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
+   functions not to non-pure virtual functions.
+*/
 
 class A {
 public:
   A();
+  A(int i);
+
   ~A() {};
   
-  virtual int foo() = 0;
+  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
   virtual void bar() = 0;
   void f() {
-foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+foo();
+#if INTERPROCEDURAL
+// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
+#endif
   }
 };
 
 class B : public A {
 public:
   B() {
-foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
   }
   ~B();
   
   virtual int foo();
-  virtual void bar() { foo(); }  // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  virtual void bar() { foo(); }
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
+#endif
 };
 
 A::A() {
   f();
 }
 
+A::A(int i) {
+  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
+#else
+  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
+#endif
+}
+
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  this->foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not 

[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2016-12-09 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 80981.
bruno added a comment.

Update after Mehdi's review!


https://reviews.llvm.org/D27604

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/crash-report-crashfile.m
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -460,8 +460,11 @@
 Res = TheDriver.ExecuteCompilation(*C, FailingCommands);
 
   // Force a crash to test the diagnostics.
-  if (::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")) {
-Diags.Report(diag::err_drv_force_crash) << "FORCE_CLANG_DIAGNOSTICS_CRASH";
+  if (TheDriver.GenReproducer) {
+Diags.Report(diag::err_drv_force_crash)
+<< (!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH")
+? "option '-gen-reproducer'"
+: "environment variable 'FORCE_CLANG_DIAGNOSTICS_CRASH'");
 
 // Pretend that every command failed.
 FailingCommands.clear();
Index: test/Driver/crash-report-crashfile.m
===
--- test/Driver/crash-report-crashfile.m
+++ test/Driver/crash-report-crashfile.m
@@ -3,15 +3,32 @@
 // RUN: mkdir -p %t/i %t/m %t
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
-// RUN: %clang -fsyntax-only %s -I %S/Inputs/module -isysroot %/t/i/\
-// RUN: -fmodules -fmodules-cache-path=%t/m/ -DFOO=BAR 2>&1 | FileCheck %s
+// RUN: %clang -fsyntax-only %s \
+// RUN:   -I %S/Inputs/module -isysroot %/t/i/ \
+// RUN:   -fmodules -fmodules-cache-path=%t/m/ -DFOO=BAR 2>&1 | \
+// RUN:   FileCheck -check-prefix=CRASH_ENV %s
+
+// RUN: not env TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: %clang -gen-reproducer -fsyntax-only %s \
+// RUN:   -I %S/Inputs/module -isysroot %/t/i/ \
+// RUN:   -fmodules -fmodules-cache-path=%t/m/ -DFOO=BAR 2>&1 | \
+// RUN:   FileCheck -check-prefix=CRASH_FLAG %s
 
 @import simple;
 const int x = MODULE_MACRO;
 
-// CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
-// CHECK-NEXT: note: diagnostic msg: {{.*}}.sh
-// CHECK-NEXT: note: diagnostic msg: Crash backtrace is located in
-// CHECK-NEXT: note: diagnostic msg: {{.*}}Library/Logs/DiagnosticReports{{.*}}
+// CRASH_ENV: failing because environment variable 'FORCE_CLANG_DIAGNOSTICS_CRASH' is set
+// CRASH_ENV: Preprocessed source(s) and associated run script(s) are located at:
+// CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.m
+// CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.cache
+// CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.sh
+// CRASH_ENV-NEXT: note: diagnostic msg: Crash backtrace is located in
+// CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}Library/Logs/DiagnosticReports{{.*}}
+
+// CRASH_FLAG: failing because option '-gen-reproducer' is set
+// CRASH_FLAG: Preprocessed source(s) and associated run script(s) are located at:
+// CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.m
+// CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.cache
+// CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.sh
+// CRASH_FLAG-NEXT: note: diagnostic msg: Crash backtrace is located in
+// CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}Library/Logs/DiagnosticReports{{.*}}
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -62,7 +62,7 @@
   CCCPrintBindings(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), DefaultTargetTriple(DefaultTargetTriple),
   CCCGenericGCCName(""), CheckInputsExist(true), CCCUsePCH(true),
-  SuppressMissingInputWarning(false) {
+  GenReproducer(false), SuppressMissingInputWarning(false) {
 
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
@@ -596,6 +596,9 @@
 CCCGenericGCCName = A->getValue();
   CCCUsePCH =
   Args.hasFlag(options::OPT_ccc_pch_is_pch, options::OPT_ccc_pch_is_pth);
+  GenReproducer = Args.hasFlag(options::OPT_gen_reproducer,
+   options::OPT_fno_crash_diagnostics,
+   !!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"));
   // FIXME: DefaultTargetTriple is used by the target-prefixed calls to as/ld
   // and getToolChain is const.
   if (IsCLMode()) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -184,6 +184,8 @@
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">,
   Flags<[CC1Option]>;
+def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
+  HelpText<"Auto-generates preprocessed source files and a 

[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2016-12-09 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> I am wondering if there is clearer name than `-gen-reproducer`.

Probably, I'm open to suggestions :-)

> IIUC, the goal is to extract all environment (system) dependent pieces, 
> copying them to a folder where the compiler can be chroot-ed (via 
> `-isysroot`).

It doesn't necessarily needs a `-isysroot` to work, only if the original 
invocation used it, then we need to use it as well to ask the VFS 
(transparently) for the right path locations.

> In some sense, what we do seems close to what `-header-include-file 
> list_of_includes.txt` does and additionally copying the contents of the 
> list_of_includes.txt (and possibly mounting a vfs overlay).

`-header-include-file` does something similar but more limited, I added some 
specific callbacks for the module collector back in the day that it might not 
collect yet though, for instance, it collects module.modulemap's and will soon 
collect header maps and some other stuff.

It also has some special handling for symlinks; it doesn't copy both files, but 
generate two yaml entries that point to the same "physical" location.


https://reviews.llvm.org/D27604



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


[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)

2016-12-09 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud created this revision.
aaboud added reviewers: rnk, probinson, rsmith.
aaboud added a subscriber: cfe-commits.

Resolve Bug 30978 .

This patch contains changes in Clang to support Checksum debug info feature.


https://reviews.llvm.org/D27641

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-atomic.c
  test/CodeGen/debug-info-file-checksum.c
  test/CodeGen/debug-info-file-checksum.c.source
  test/CodeGen/debug-prefix-map.c
  test/PCH/debug-info-pch-path.c

Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -324,15 +324,17 @@
   if (!Loc.isValid())
 // If Location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()));
+   remapDIPath(TheCU->getDirectory()),
+   TheCU->getChecksum());
 
   SourceManager  = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 
   if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
 // If the location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()));
+   remapDIPath(TheCU->getDirectory()),
+   TheCU->getChecksum());
 
   // Cache the results.
   const char *fname = PLoc.getFilename();
@@ -344,16 +346,23 @@
   return cast(V);
   }
 
+  std::string Checksum;
+  SM.getChecksumMD5(SM.getFileID(Loc), Checksum);
+
+  llvm::DIChecksum *C =
+  DBuilder.createChecksum(llvm::DIChecksum::MD5, Checksum);
+
   llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()),
-remapDIPath(getCurrentDirname()));
+remapDIPath(getCurrentDirname()), C);
 
   DIFileCache[fname].reset(F);
   return F;
 }
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
   return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
- remapDIPath(TheCU->getDirectory()));
+ remapDIPath(TheCU->getDirectory()),
+ TheCU->getChecksum());
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
@@ -396,6 +405,7 @@
 }
 
 void CGDebugInfo::CreateCompileUnit() {
+  std::string Checksum;
 
   // Should we be asking the SourceManager for the main file name, instead of
   // accepting it as an argument? This just causes the main file name to
@@ -422,6 +432,7 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+SM.getChecksumMD5(SM.getMainFileID(), Checksum);
   }
 
   llvm::dwarf::SourceLanguage LangTag;
@@ -467,7 +478,8 @@
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
   LangTag, remapDIPath(MainFileName), remapDIPath(getCurrentDirname()),
-  Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
+  llvm::DIChecksum::MD5, Checksum, Producer, LO.Optimize,
+  CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
   CGM.getCodeGenOpts().SplitDwarfFile, EmissionKind, 0 /* DWOid */,
   CGM.getCodeGenOpts().SplitDwarfInlining);
 }
@@ -1978,9 +1990,10 @@
 uint64_t Signature = Mod.getSignature() ? Mod.getSignature() : ~1ULL;
 llvm::DIBuilder DIB(CGM.getModule());
 DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
-  Mod.getPath(), TheCU->getProducer(), true,
-  StringRef(), 0, Mod.getASTFile(),
-  llvm::DICompileUnit::FullDebug, Signature);
+  Mod.getPath(), llvm::DIChecksum::None, "",
+  TheCU->getProducer(), true, StringRef(), 0,
+  Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
+  Signature);
 DIB.finalize();
   }
   llvm::DIModule *Parent =
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -20,6 +20,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/Capacity.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/MD5.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1442,6 +1444,24 @@
   return getBuffer(getFileID(Loc), Invalid)->getBufferIdentifier();
 }
 
+void SourceManager::getChecksumMD5(FileID FID, std::string ) const {
+  bool Invalid;
+
+  llvm::MemoryBuffer *MemBuffer = getBuffer(FID, );
+  if (Invalid) return;

[libcxx] r289298 - Creating release candidate rc3 from release_391 branch

2016-12-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Dec  9 18:34:56 2016
New Revision: 289298

URL: http://llvm.org/viewvc/llvm-project?rev=289298=rev
Log:
Creating release candidate rc3 from release_391 branch

Added:
libcxx/tags/RELEASE_391/rc3/   (props changed)
  - copied from r289297, libcxx/branches/release_39/

Propchange: libcxx/tags/RELEASE_391/rc3/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Dec  9 18:34:56 2016
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:278282,278357,278387,278904,279008


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


[libunwind] r289305 - Creating release candidate rc3 from release_391 branch

2016-12-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Dec  9 18:35:05 2016
New Revision: 289305

URL: http://llvm.org/viewvc/llvm-project?rev=289305=rev
Log:
Creating release candidate rc3 from release_391 branch

Added:
libunwind/tags/RELEASE_391/rc3/   (props changed)
  - copied from r289304, libunwind/branches/release_39/

Propchange: libunwind/tags/RELEASE_391/rc3/
--
svn:mergeinfo = /libunwind/trunk:276128,277868,278029


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


[libcxxabi] r289299 - Creating release candidate rc3 from release_391 branch

2016-12-09 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Dec  9 18:34:57 2016
New Revision: 289299

URL: http://llvm.org/viewvc/llvm-project?rev=289299=rev
Log:
Creating release candidate rc3 from release_391 branch

Added:
libcxxabi/tags/RELEASE_391/rc3/   (props changed)
  - copied from r289298, libcxxabi/branches/release_39/

Propchange: libcxxabi/tags/RELEASE_391/rc3/
--
svn:mergeinfo = /libcxxabi/trunk:278030,278579


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


Re: [PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-09 Thread Duncan P. N. Exon Smith via cfe-commits
Two points to make here:

1. CLOCK_UPTIME_RAW exactly matches the previous behaviour, so even if it's 
wrong, it's not a regression.  See the next sentence from the one Eric quoted:

 CLOCK_UPTIME_RAW   clock that increments monotonically, in the same manner 
as
CLOCK_MONOTONIC_RAW, but that does not increment while 
the
system is asleep.  The returned value is identical to 
the
result of mach_absolute_time() after the appropriate
mach_timebase conversion is applied.

The previous implementation used mach_absolute_time() with "the appropriate 
mach_timebase conversion".  Using CLOCK_UPTIME_RAW is maintaining the status 
quo.

Moreover, libc++ is currently incorrectly/accidentally/incidentally using 
CLOCK_MONOTONIC, which has frequency and time adjustments, and is definitely 
un-steady.  I think this patch should be committed promptly to maintain the 
status quo and match what's shipping (and has shipped for 5 years) on Darwin.

Then we can argue about whether to change how steady_clock works going forward 
(maybe we should).

2. I find your argument unconvincing.  Why must the clock continue to increment 
when the system is asleep?  The text only says that it advances relative to 
real time, not that it advances when the system isn't running.

> On 2016-Dec-09, at 09:15, Eric Fiselier via Phabricator 
>  wrote:
> 
> EricWF added a comment.
> 
> `CLOCK_MONOTONIC_RAW` however seems to meet the requirements..
> 
> 
> https://reviews.llvm.org/D27429
> 
> 
> 

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


r289290 - [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Dec  9 17:48:18 2016
New Revision: 289290

URL: http://llvm.org/viewvc/llvm-project?rev=289290=rev
Log:
[ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

On some Apple platforms, the ObjC BOOL type is defined as a signed char.
When performing instrumentation for -fsanitize=bool, we'd like to treat
the range of BOOL like it's always {0, 1}. While we can't change clang's
IRGen for char-backed BOOL's due to ABI compatibility concerns, we can
teach ubsan to catch potential abuses of this type.

rdar://problem/29502773

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

Added:
cfe/trunk/test/CodeGenObjC/ubsan-bool.m
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=289290=289289=289290=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Dec  9 17:48:18 2016
@@ -24,6 +24,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/NSAPI.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
@@ -1219,11 +1220,10 @@ static bool hasBooleanRepresentation(Qua
 
 static bool getRangeForType(CodeGenFunction , QualType Ty,
 llvm::APInt , llvm::APInt ,
-bool StrictEnums) {
+bool StrictEnums, bool IsBool) {
   const EnumType *ET = Ty->getAs();
   bool IsRegularCPlusPlusEnum = CGF.getLangOpts().CPlusPlus && StrictEnums &&
 ET && !ET->getDecl()->isFixed();
-  bool IsBool = hasBooleanRepresentation(Ty);
   if (!IsBool && !IsRegularCPlusPlusEnum)
 return false;
 
@@ -1253,8 +1253,8 @@ static bool getRangeForType(CodeGenFunct
 
 llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(QualType Ty) {
   llvm::APInt Min, End;
-  if (!getRangeForType(*this, Ty, Min, End,
-   CGM.getCodeGenOpts().StrictEnums))
+  if (!getRangeForType(*this, Ty, Min, End, CGM.getCodeGenOpts().StrictEnums,
+   hasBooleanRepresentation(Ty)))
 return nullptr;
 
   llvm::MDBuilder MDHelper(getLLVMContext());
@@ -1313,14 +1313,15 @@ llvm::Value *CodeGenFunction::EmitLoadOf
   false /*ConvertTypeToTag*/);
   }
 
-  bool NeedsBoolCheck =
-  SanOpts.has(SanitizerKind::Bool) && hasBooleanRepresentation(Ty);
+  bool IsBool = hasBooleanRepresentation(Ty) ||
+NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
+  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
   bool NeedsEnumCheck =
   SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
   if (NeedsBoolCheck || NeedsEnumCheck) {
 SanitizerScope SanScope(this);
 llvm::APInt Min, End;
-if (getRangeForType(*this, Ty, Min, End, true)) {
+if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool)) {
   --End;
   llvm::Value *Check;
   if (!Min)

Added: cfe/trunk/test/CodeGenObjC/ubsan-bool.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/ubsan-bool.m?rev=289290=auto
==
--- cfe/trunk/test/CodeGenObjC/ubsan-bool.m (added)
+++ cfe/trunk/test/CodeGenObjC/ubsan-bool.m Fri Dec  9 17:48:18 2016
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s 
-check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s 
-check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 
-fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C
+
+typedef signed char BOOL;
+
+// SHARED-LABEL: f1
+BOOL f1() {
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+  // C-NOT: call void @__ubsan_handle_load_invalid_value
+  BOOL a = 2;
+  return a + 1;
+}


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


[PATCH] D27607: [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289290: [ubsan] Treat ObjC's BOOL as if its range is always 
{0, 1} (authored by vedantk).

Changed prior to commit:
  https://reviews.llvm.org/D27607?vs=80960=80969#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27607

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/test/CodeGenObjC/ubsan-bool.m


Index: cfe/trunk/test/CodeGenObjC/ubsan-bool.m
===
--- cfe/trunk/test/CodeGenObjC/ubsan-bool.m
+++ cfe/trunk/test/CodeGenObjC/ubsan-bool.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s 
-check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s 
-check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 
-fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C
+
+typedef signed char BOOL;
+
+// SHARED-LABEL: f1
+BOOL f1() {
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+  // C-NOT: call void @__ubsan_handle_load_invalid_value
+  BOOL a = 2;
+  return a + 1;
+}
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/NSAPI.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
@@ -1219,11 +1220,10 @@
 
 static bool getRangeForType(CodeGenFunction , QualType Ty,
 llvm::APInt , llvm::APInt ,
-bool StrictEnums) {
+bool StrictEnums, bool IsBool) {
   const EnumType *ET = Ty->getAs();
   bool IsRegularCPlusPlusEnum = CGF.getLangOpts().CPlusPlus && StrictEnums &&
 ET && !ET->getDecl()->isFixed();
-  bool IsBool = hasBooleanRepresentation(Ty);
   if (!IsBool && !IsRegularCPlusPlusEnum)
 return false;
 
@@ -1253,8 +1253,8 @@
 
 llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(QualType Ty) {
   llvm::APInt Min, End;
-  if (!getRangeForType(*this, Ty, Min, End,
-   CGM.getCodeGenOpts().StrictEnums))
+  if (!getRangeForType(*this, Ty, Min, End, CGM.getCodeGenOpts().StrictEnums,
+   hasBooleanRepresentation(Ty)))
 return nullptr;
 
   llvm::MDBuilder MDHelper(getLLVMContext());
@@ -1313,14 +1313,15 @@
   false /*ConvertTypeToTag*/);
   }
 
-  bool NeedsBoolCheck =
-  SanOpts.has(SanitizerKind::Bool) && hasBooleanRepresentation(Ty);
+  bool IsBool = hasBooleanRepresentation(Ty) ||
+NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
+  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
   bool NeedsEnumCheck =
   SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
   if (NeedsBoolCheck || NeedsEnumCheck) {
 SanitizerScope SanScope(this);
 llvm::APInt Min, End;
-if (getRangeForType(*this, Ty, Min, End, true)) {
+if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool)) {
   --End;
   llvm::Value *Check;
   if (!Min)


Index: cfe/trunk/test/CodeGenObjC/ubsan-bool.m
===
--- cfe/trunk/test/CodeGenObjC/ubsan-bool.m
+++ cfe/trunk/test/CodeGenObjC/ubsan-bool.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C
+
+typedef signed char BOOL;
+
+// SHARED-LABEL: f1
+BOOL f1() {
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+  // C-NOT: call void @__ubsan_handle_load_invalid_value
+  BOOL a = 2;
+  return a + 1;
+}
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/NSAPI.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
@@ -1219,11 +1220,10 @@
 
 static bool getRangeForType(CodeGenFunction , QualType Ty,
 llvm::APInt , llvm::APInt ,
-bool StrictEnums) {
+bool StrictEnums, bool 

[PATCH] D27607: [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna accepted this revision.
zaks.anna added a reviewer: zaks.anna.
zaks.anna added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D27607



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


[PATCH] D27631: [CUDA,Driver] Added --no-cuda-gpu-arch= option.

2016-12-09 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289287: [CUDA,Driver] Added --no-cuda-gpu-arch= option. 
(authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D27631?vs=80950=80961#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27631

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cuda-options.cu

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -414,6 +414,9 @@
"effect on non-CUDA compilations.">;
 def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than once.">;
+def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, Flags<[DriverOption]>,
+  HelpText<"Remove GPU architecture (e.g. sm_35) from the list of GPUs to compile for. "
+   "'all' resets the list to its default value.">;
 def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">,
   HelpText<"Enable device-side debug info generation. Disables ptxas optimizations.">;
 def no_cuda_version_check : Flag<["--"], "no-cuda-version-check">,
Index: cfe/trunk/test/Driver/cuda-options.cu
===
--- cfe/trunk/test/Driver/cuda-options.cu
+++ cfe/trunk/test/Driver/cuda-options.cu
@@ -64,18 +64,18 @@
 
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE-SM35 -check-prefix HOST \
+// RUN:-check-prefix DEVICE-SM30 -check-prefix HOST \
 // RUN:-check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
 
 // Verify that there is one device-side compilation per --cuda-gpu-arch args
 // and that all results are included on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
-// RUN:-check-prefix DEVICE2-SM30 -check-prefix HOST \
+// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM30 \
+// RUN:-check-prefix DEVICE2-SM35 -check-prefix HOST \
 // RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
 // RUN:-check-prefix NOLINK %s
 
@@ -92,6 +92,65 @@
 // RUN:-check-prefix HOST -check-prefix HOST-NOSAVE \
 // RUN:-check-prefix HOST-AS -check-prefix NOLINK %s
 
+// Verify that --[no-]cuda-gpu-arch arguments are handled correctly.
+// a) --no-cuda-gpu-arch=X negates preceeding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
+
+// b) --no-cuda-gpu-arch=X negates more than one preceeding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
+
+// c) if --no-cuda-gpu-arch=X negates all preceeding --cuda-gpu-arch=X
+//we default to sm_20 -- same as if no --cuda-gpu-arch were passed.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes ARCH-SM20,NOARCH-SM30,NOARCH-SM35 %s
+
+// d) --no-cuda-gpu-arch=X is a no-op if there's no preceding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30\
+// RUN:   --no-cuda-gpu-arch=sm_50 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
+
+// e) --no-cuda-gpu-arch=X does not affect following --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
+
+// f) --no-cuda-gpu-arch=all negates all preceding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 \
+// RUN:   

r289287 - [CUDA,Driver] Added --no-cuda-gpu-arch= option.

2016-12-09 Thread Artem Belevich via cfe-commits
Author: tra
Date: Fri Dec  9 16:59:17 2016
New Revision: 289287

URL: http://llvm.org/viewvc/llvm-project?rev=289287=rev
Log:
[CUDA,Driver] Added --no-cuda-gpu-arch= option.

This allows us to negate preceding --cuda-gpu-arch=X.
This comes handy when user needs to override default
flags set for them by the build system.

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cuda-options.cu

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=289287=289286=289287=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Dec  9 16:59:17 2016
@@ -414,6 +414,9 @@ def cuda_compile_host_device : Flag<["--
"effect on non-CUDA compilations.">;
 def cuda_gpu_arch_EQ : Joined<["--"], "cuda-gpu-arch=">, Flags<[DriverOption]>,
   HelpText<"CUDA GPU architecture (e.g. sm_35).  May be specified more than 
once.">;
+def no_cuda_gpu_arch_EQ : Joined<["--"], "no-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
+  HelpText<"Remove GPU architecture (e.g. sm_35) from the list of GPUs to 
compile for. "
+   "'all' resets the list to its default value.">;
 def cuda_noopt_device_debug : Flag<["--"], "cuda-noopt-device-debug">,
   HelpText<"Enable device-side debug info generation. Disables ptxas 
optimizations.">;
 def no_cuda_version_check : Flag<["--"], "no-cuda-version-check">,

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=289287=289286=289287=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Dec  9 16:59:17 2016
@@ -1919,25 +1919,39 @@ class OffloadingActionBuilder final {
   options::OPT_cuda_device_only);
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
-  llvm::SmallSet GpuArchs;
+  std::set GpuArchs;
   bool Error = false;
   for (Arg *A : Args) {
-if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+if (!(A->getOption().matches(options::OPT_cuda_gpu_arch_EQ) ||
+  A->getOption().matches(options::OPT_no_cuda_gpu_arch_EQ)))
   continue;
 A->claim();
 
-const auto  = A->getValue();
+const StringRef ArchStr = A->getValue();
+if (A->getOption().matches(options::OPT_no_cuda_gpu_arch_EQ) &&
+ArchStr == "all") {
+  GpuArchs.clear();
+  continue;
+}
 CudaArch Arch = StringToCudaArch(ArchStr);
 if (Arch == CudaArch::UNKNOWN) {
   C.getDriver().Diag(clang::diag::err_drv_cuda_bad_gpu_arch) << 
ArchStr;
   Error = true;
-} else if (GpuArchs.insert(Arch).second)
-  GpuArchList.push_back(Arch);
+} else if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+  GpuArchs.insert(Arch);
+else if (A->getOption().matches(options::OPT_no_cuda_gpu_arch_EQ))
+  GpuArchs.erase(Arch);
+else
+  llvm_unreachable("Unexpected option.");
   }
 
-  // Default to sm_20 which is the lowest common denominator for supported
-  // GPUs.
-  // sm_20 code should work correctly, if suboptimally, on all newer GPUs.
+  // Collect list of GPUs remaining in the set.
+  for (CudaArch Arch : GpuArchs)
+GpuArchList.push_back(Arch);
+
+  // Default to sm_20 which is the lowest common denominator for
+  // supported GPUs.  sm_20 code should work correctly, if
+  // suboptimally, on all newer GPUs.
   if (GpuArchList.empty())
 GpuArchList.push_back(CudaArch::SM_20);
 

Modified: cfe/trunk/test/Driver/cuda-options.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-options.cu?rev=289287=289286=289287=diff
==
--- cfe/trunk/test/Driver/cuda-options.cu (original)
+++ cfe/trunk/test/Driver/cuda-options.cu Fri Dec  9 16:59:17 2016
@@ -64,9 +64,9 @@
 
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE-SM35 -check-prefix HOST \
+// RUN:-check-prefix DEVICE-SM30 -check-prefix HOST \
 // RUN:-check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
 
 // Verify that there is one device-side compilation per --cuda-gpu-arch args
@@ -74,8 +74,8 @@
 // RUN: %clang -### -target x86_64-linux-gnu 

r289286 - [c++17] P0490R0, NB comment FI 20: allow direct-initialization of decomposition declarations.

2016-12-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  9 16:56:20 2016
New Revision: 289286

URL: http://llvm.org/viewvc/llvm-project?rev=289286=rev
Log:
[c++17] P0490R0, NB comment FI 20: allow direct-initialization of decomposition 
declarations.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Parser/cxx1z-decomposition.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=289286=289285=289286=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec  9 16:56:20 
2016
@@ -398,8 +398,6 @@ def err_decomp_decl_not_alone : Error<
   "decomposition declaration must be the only declaration in its group">;
 def err_decomp_decl_requires_init : Error<
   "decomposition declaration %0 requires an initializer">;
-def err_decomp_decl_paren_init : Error<
-  "decomposition declaration %0 cannot have a parenthesized initializer">;
 def err_decomp_decl_wrong_number_bindings : Error<
   "type %0 decomposes into %2 elements, but %select{only |}3%1 "
   "names were provided">;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=289286=289285=289286=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec  9 16:56:20 2016
@@ -9625,6 +9625,20 @@ namespace {
   }
 } // end anonymous namespace
 
+namespace {
+  // Simple wrapper to add the name of a variable or (if no variable is
+  // available) a DeclarationName into a diagnostic.
+  struct VarDeclOrName {
+VarDecl *VDecl;
+DeclarationName Name;
+
+friend const Sema::SemaDiagnosticBuilder &
+operator<<(const Sema::SemaDiagnosticBuilder , VarDeclOrName VN) {
+  return VN.VDecl ? Diag << VN.VDecl : Diag << VN.Name;
+}
+  };
+} // end anonymous namespace
+
 QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
 DeclarationName Name, QualType 
Type,
 TypeSourceInfo *TSI,
@@ -9634,6 +9648,8 @@ QualType Sema::deduceVarTypeFromInitiali
   assert((!VDecl || !VDecl->isInitCapture()) &&
  "init captures are expected to be deduced prior to initialization");
 
+  VarDeclOrName VN{VDecl, Name};
+
   // FIXME: Deduction for a decomposition declaration does weird things if the
   // initializer is an array.
 
@@ -9652,7 +9668,7 @@ QualType Sema::deduceVarTypeFromInitiali
 Diag(Init->getLocStart(), IsInitCapture
   ? diag::err_init_capture_no_expression
   : diag::err_auto_var_init_no_expression)
-<< Name << Type << Range;
+<< VN << Type << Range;
 return QualType();
   }
 
@@ -9660,7 +9676,7 @@ QualType Sema::deduceVarTypeFromInitiali
 Diag(DeduceInits[1]->getLocStart(),
  IsInitCapture ? diag::err_init_capture_multiple_expressions
: diag::err_auto_var_init_multiple_expressions)
-<< Name << Type << Range;
+<< VN << Type << Range;
 return QualType();
   }
 
@@ -9669,7 +9685,7 @@ QualType Sema::deduceVarTypeFromInitiali
 Diag(Init->getLocStart(), IsInitCapture
   ? diag::err_init_capture_paren_braces
   : diag::err_auto_var_init_paren_braces)
-<< isa(Init) << Name << Type << Range;
+<< isa(Init) << VN << Type << Range;
 return QualType();
   }
 
@@ -9692,13 +9708,13 @@ QualType Sema::deduceVarTypeFromInitiali
 else if (isa(Init))
   Diag(Range.getBegin(),
diag::err_init_capture_deduction_failure_from_init_list)
-  << Name
+  << VN
   << (DeduceInit->getType().isNull() ? TSI->getType()
  : DeduceInit->getType())
   << DeduceInit->getSourceRange();
 else
   Diag(Range.getBegin(), diag::err_init_capture_deduction_failure)
-  << Name << TSI->getType()
+  << VN << TSI->getType()
   << (DeduceInit->getType().isNull() ? TSI->getType()
  : DeduceInit->getType())
   << DeduceInit->getSourceRange();
@@ -9712,7 +9728,7 @@ QualType Sema::deduceVarTypeFromInitiali
   if (ActiveTemplateInstantiations.empty() && !DefaultedAnyToId &&
   !IsInitCapture && !DeducedType.isNull() && DeducedType->isObjCIdType()) {
 SourceLocation Loc = TSI->getTypeLoc().getBeginLoc();
-Diag(Loc, diag::warn_auto_var_is_id) << Name << Range;
+Diag(Loc, diag::warn_auto_var_is_id) << VN << Range;
   }
 
   return DeducedType;
@@ -9746,11 +9762,6 @@ void Sema::AddInitializerToDecl(Decl *Re
 

[PATCH] D27607: [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 80960.
vsk marked 3 inline comments as done.
vsk added a comment.

- Use NSAPI's 'is-BOOL' predicate.
- Simplify test.


https://reviews.llvm.org/D27607

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenObjC/ubsan-bool.m


Index: test/CodeGenObjC/ubsan-bool.m
===
--- /dev/null
+++ test/CodeGenObjC/ubsan-bool.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s 
-check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple 
x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s 
-check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 
-fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C
+
+typedef signed char BOOL;
+
+// SHARED-LABEL: f1
+BOOL f1() {
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+  // C-NOT: call void @__ubsan_handle_load_invalid_value
+  BOOL a = 2;
+  return a + 1;
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/NSAPI.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
@@ -1219,11 +1220,10 @@
 
 static bool getRangeForType(CodeGenFunction , QualType Ty,
 llvm::APInt , llvm::APInt ,
-bool StrictEnums) {
+bool StrictEnums, bool IsBool) {
   const EnumType *ET = Ty->getAs();
   bool IsRegularCPlusPlusEnum = CGF.getLangOpts().CPlusPlus && StrictEnums &&
 ET && !ET->getDecl()->isFixed();
-  bool IsBool = hasBooleanRepresentation(Ty);
   if (!IsBool && !IsRegularCPlusPlusEnum)
 return false;
 
@@ -1253,8 +1253,8 @@
 
 llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(QualType Ty) {
   llvm::APInt Min, End;
-  if (!getRangeForType(*this, Ty, Min, End,
-   CGM.getCodeGenOpts().StrictEnums))
+  if (!getRangeForType(*this, Ty, Min, End, CGM.getCodeGenOpts().StrictEnums,
+   hasBooleanRepresentation(Ty)))
 return nullptr;
 
   llvm::MDBuilder MDHelper(getLLVMContext());
@@ -1313,14 +1313,15 @@
   false /*ConvertTypeToTag*/);
   }
 
-  bool NeedsBoolCheck =
-  SanOpts.has(SanitizerKind::Bool) && hasBooleanRepresentation(Ty);
+  bool IsBool = hasBooleanRepresentation(Ty) ||
+NSAPI(CGM.getContext()).isObjCBOOLType(Ty);
+  bool NeedsBoolCheck = SanOpts.has(SanitizerKind::Bool) && IsBool;
   bool NeedsEnumCheck =
   SanOpts.has(SanitizerKind::Enum) && Ty->getAs();
   if (NeedsBoolCheck || NeedsEnumCheck) {
 SanitizerScope SanScope(this);
 llvm::APInt Min, End;
-if (getRangeForType(*this, Ty, Min, End, true)) {
+if (getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool)) {
   --End;
   llvm::Value *Check;
   if (!Min)


Index: test/CodeGenObjC/ubsan-bool.m
===
--- /dev/null
+++ test/CodeGenObjC/ubsan-bool.m
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x objective-c++ -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,OBJC
+// RUN: %clang_cc1 -x c -emit-llvm -triple x86_64-apple-macosx10.10.0 -fsanitize=bool %s -o - | FileCheck %s -check-prefixes=SHARED,C
+
+typedef signed char BOOL;
+
+// SHARED-LABEL: f1
+BOOL f1() {
+  // OBJC: call void @__ubsan_handle_load_invalid_value
+  // C-NOT: call void @__ubsan_handle_load_invalid_value
+  BOOL a = 2;
+  return a + 1;
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/NSAPI.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
@@ -1219,11 +1220,10 @@
 
 static bool getRangeForType(CodeGenFunction , QualType Ty,
 llvm::APInt , llvm::APInt ,
-bool StrictEnums) {
+bool StrictEnums, bool IsBool) {
   const EnumType *ET = Ty->getAs();
   bool IsRegularCPlusPlusEnum = CGF.getLangOpts().CPlusPlus && StrictEnums &&
 ET && !ET->getDecl()->isFixed();
-  bool IsBool = hasBooleanRepresentation(Ty);
   if (!IsBool && !IsRegularCPlusPlusEnum)
 return false;
 
@@ 

[PATCH] D27607: [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked 3 inline comments as done.
vsk added a comment.

Thanks for your feedback. I will updated the patch shortly.




Comment at: lib/CodeGen/CGExpr.cpp:1221
+/// Check if \p Ty is defined as BOOL in a system header. In ObjC language
+/// modes, it's safe to treat such a type as 'the builtin bool'.
+static bool isObjCBool(QualType Ty, const SourceManager ,

ahatanak wrote:
> If your intention is to exclude BOOLs defined in files that aren't system 
> headers, is it possible to add a test for that?
> 
> 
> ```
> void foo() {
>   typedef long long BOOL;
>   ...
> }
> ```
Thinking about this some more, I think it's enough to check for an ObjC 
language mode, and that the system header check is unnecessary.



Comment at: lib/CodeGen/CGExpr.cpp:1222
+/// modes, it's safe to treat such a type as 'the builtin bool'.
+static bool isObjCBool(QualType Ty, const SourceManager ,
+   const LangOptions ) {

zaks.anna wrote:
> Could you use the existing method for this? From NSAPI.h:
> 
> ```
>// \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
>bool isObjCBOOLType(QualType T) const;
> 
> ```
> 
Thanks, this is a lot better than rolling my own.



Comment at: lib/CodeGen/CGExpr.cpp:1224
+   const LangOptions ) {
+  if (!LO.ObjC1 && !LO.ObjC2)
+return false;

arphaman wrote:
> LangOptions.ObjC1 should be always set if LangOptions.ObjC2 is set, so the 
> second check is redundant I think.
Using NSAPI takes care of this.


https://reviews.llvm.org/D27607



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


r289285 - Fix unused variable warnings. NFCI.

2016-12-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Dec  9 16:45:21 2016
New Revision: 289285

URL: http://llvm.org/viewvc/llvm-project?rev=289285=rev
Log:
Fix unused variable warnings. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=289285=289284=289285=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Dec  9 16:45:21 2016
@@ -1617,9 +1617,9 @@ static llvm::Constant *EmitNullConstantF
 }
 
 llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
-  if (auto PT = T->getAs())
-return 
getNullPointer(cast(getTypes().ConvertTypeForMem(T)),
-  T);
+  if (T->getAs())
+return getNullPointer(
+cast(getTypes().ConvertTypeForMem(T)), T);
 
   if (getTypes().isZeroInitializable(T))
 return llvm::Constant::getNullValue(getTypes().ConvertTypeForMem(T));

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=289285=289284=289285=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Fri Dec  9 16:45:21 2016
@@ -742,7 +742,7 @@ bool CodeGenTypes::isPointerZeroInitiali
 }
 
 bool CodeGenTypes::isZeroInitializable(QualType T) {
-  if (auto PT = T->getAs())
+  if (T->getAs())
 return Context.getTargetNullPointerValue(T) == 0;
 
   if (const auto *AT = Context.getAsArrayType(T)) {


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


[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Because, notably, if you do that, then an attempt to pass  as an int* will 
fail, which means this isn't really C++ anymore... and yet that appears to be 
exactly what you want.


https://reviews.llvm.org/D27627



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


[libcxx] r289283 - [libcxx] [test] Fix string_view tests.

2016-12-09 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Dec  9 16:35:53 2016
New Revision: 289283

URL: http://llvm.org/viewvc/llvm-project?rev=289283=rev
Log:
[libcxx] [test] Fix string_view tests.

test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
Passing -1 to size_t triggers signed/unsigned mismatch warnings because it's
a value-modifying conversion. Add static_cast to soothe the compiler.
(This file refers to size_t unqualified.)

test/std/strings/string.view/string.view.ops/substr.pass.cpp
Add  for std::min() and  for std::out_of_range.

N4618 21.4.2.4 [string.view.access]/1: "Requires: pos < size()."
/4: "[ Note: Unlike basic_string::operator[], 
basic_string_view::operator[](size())
has undefined behavior instead of returning charT(). -end note ]"

Fixes D27633.

Modified:

libcxx/trunk/test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.ops/substr.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp?rev=289283=289282=289283=diff
==
--- 
libcxx/trunk/test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
 Fri Dec  9 16:35:53 2016
@@ -376,7 +376,7 @@ int main()
 test("abcdefghijklmnopqrst", 5, 5, "", 20);
 test("abcdefghijklmnopqrst", 0, 8, "abcde", 15);
 test("abcdefghijklmnopqrst", 0, 12, "abcdefghij", 10);
-test("abcdefghijklmnopqrst", 0, -1, "abcdefghijklmnopqrst", 0);
+test("abcdefghijklmnopqrst", 0, static_cast(-1), 
"abcdefghijklmnopqrst", 0);
 }
 
 {
@@ -395,7 +395,7 @@ int main()
 test(L"abcdefghijklmnopqrst", 5, 5, L"", 20);
 test(L"abcdefghijklmnopqrst", 0, 8, L"abcde", 15);
 test(L"abcdefghijklmnopqrst", 0, 12, L"abcdefghij", 10);
-test(L"abcdefghijklmnopqrst", 0, -1, L"abcdefghijklmnopqrst", 0);
+test(L"abcdefghijklmnopqrst", 0, static_cast(-1), 
L"abcdefghijklmnopqrst", 0);
 }
 
 #if TEST_STD_VER >= 11
@@ -415,7 +415,7 @@ int main()
 test(U"abcdefghijklmnopqrst", 5, 5, U"", 20);
 test(U"abcdefghijklmnopqrst", 0, 8, U"abcde", 15);
 test(U"abcdefghijklmnopqrst", 0, 12, U"abcdefghij", 10);
-test(U"abcdefghijklmnopqrst", 0, -1, U"abcdefghijklmnopqrst", 0);
+test(U"abcdefghijklmnopqrst", 0, static_cast(-1), 
U"abcdefghijklmnopqrst", 0);
 }
 
 {
@@ -434,7 +434,7 @@ int main()
 test(u"abcdefghijklmnopqrst", 5, 5, u"", 20);
 test(u"abcdefghijklmnopqrst", 0, 8, u"abcde", 15);
 test(u"abcdefghijklmnopqrst", 0, 12, u"abcdefghij", 10);
-test(u"abcdefghijklmnopqrst", 0, -1, u"abcdefghijklmnopqrst", 0);
+test(u"abcdefghijklmnopqrst", 0, static_cast(-1), 
u"abcdefghijklmnopqrst", 0);
 }
 #endif
 

Modified: 
libcxx/trunk/test/std/strings/string.view/string.view.ops/substr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.ops/substr.pass.cpp?rev=289283=289282=289283=diff
==
--- libcxx/trunk/test/std/strings/string.view/string.view.ops/substr.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.ops/substr.pass.cpp 
Fri Dec  9 16:35:53 2016
@@ -16,6 +16,8 @@
 // Returns: basic_string_view(data()+pos, rlen).
 
 #include 
+#include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -39,7 +41,7 @@ void test1(std::basic_string_view
 #endif
 const size_t rlen = std::min(n, sv.size() - pos);
 assert (sv1.size() == rlen);
-for (size_t i = 0; i <= rlen; ++i)
+for (size_t i = 0; i < rlen; ++i)
 assert(sv[pos+i] == sv1[i]);
 }
 


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


[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I suspect that what you actually want to do in order to implement HCC is change 
SemaType so that 'int*' is implicitly interpreted as 'int __something *'.  But 
I don't know how not having explicit address spaces actually works in the HCC 
language design, given that it's based on C++.


https://reviews.llvm.org/D27627



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


Re: [PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-12-09 Thread Richard Smith via cfe-commits
On 9 December 2016 at 03:59, Richard Smith via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> rsmith added a comment.
>
> Looks like we might only be making macros visible, and failing to emit the
> annot_module_import token for Sema.


Hmm, no, we inject that token immediately afterwards. I agree that the
module's contents should already be being made visible here. Can you look
at an AST dump and make sure that the declarations are owned by the correct
module? (You might need to try to use the declaration first, since we
populate the owning module information lazily.)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27633: [libcxx] [test] Fix string_view tests.

2016-12-09 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Fix string_view tests.

test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
Passing -1 to size_t triggers signed/unsigned mismatch warnings because it's
a value-modifying conversion. Add static_cast to soothe the compiler.
(This file refers to size_t unqualified.)

test/std/strings/string.view/string.view.ops/substr.pass.cpp
Add  for std::min() and  for std::out_of_range.

N4618 21.4.2.4 [string.view.access]/1: "Requires: pos < size()."
/4: "[ Note: Unlike basic_string::operator[], 
basic_string_view::operator[](size())
has undefined behavior instead of returning charT(). -end note ]"


https://reviews.llvm.org/D27633

Files:
  test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
  test/std/strings/string.view/string.view.ops/substr.pass.cpp


Index: test/std/strings/string.view/string.view.ops/substr.pass.cpp
===
--- test/std/strings/string.view/string.view.ops/substr.pass.cpp
+++ test/std/strings/string.view/string.view.ops/substr.pass.cpp
@@ -16,6 +16,8 @@
 // Returns: basic_string_view(data()+pos, rlen).
 
 #include 
+#include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -39,7 +41,7 @@
 #endif
 const size_t rlen = std::min(n, sv.size() - pos);
 assert (sv1.size() == rlen);
-for (size_t i = 0; i <= rlen; ++i)
+for (size_t i = 0; i < rlen; ++i)
 assert(sv[pos+i] == sv1[i]);
 }
 
Index: 
test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
===
--- test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
+++ test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
@@ -376,7 +376,7 @@
 test("abcdefghijklmnopqrst", 5, 5, "", 20);
 test("abcdefghijklmnopqrst", 0, 8, "abcde", 15);
 test("abcdefghijklmnopqrst", 0, 12, "abcdefghij", 10);
-test("abcdefghijklmnopqrst", 0, -1, "abcdefghijklmnopqrst", 0);
+test("abcdefghijklmnopqrst", 0, static_cast(-1), 
"abcdefghijklmnopqrst", 0);
 }
 
 {
@@ -395,7 +395,7 @@
 test(L"abcdefghijklmnopqrst", 5, 5, L"", 20);
 test(L"abcdefghijklmnopqrst", 0, 8, L"abcde", 15);
 test(L"abcdefghijklmnopqrst", 0, 12, L"abcdefghij", 10);
-test(L"abcdefghijklmnopqrst", 0, -1, L"abcdefghijklmnopqrst", 0);
+test(L"abcdefghijklmnopqrst", 0, static_cast(-1), 
L"abcdefghijklmnopqrst", 0);
 }
 
 #if TEST_STD_VER >= 11
@@ -415,7 +415,7 @@
 test(U"abcdefghijklmnopqrst", 5, 5, U"", 20);
 test(U"abcdefghijklmnopqrst", 0, 8, U"abcde", 15);
 test(U"abcdefghijklmnopqrst", 0, 12, U"abcdefghij", 10);
-test(U"abcdefghijklmnopqrst", 0, -1, U"abcdefghijklmnopqrst", 0);
+test(U"abcdefghijklmnopqrst", 0, static_cast(-1), 
U"abcdefghijklmnopqrst", 0);
 }
 
 {
@@ -434,7 +434,7 @@
 test(u"abcdefghijklmnopqrst", 5, 5, u"", 20);
 test(u"abcdefghijklmnopqrst", 0, 8, u"abcde", 15);
 test(u"abcdefghijklmnopqrst", 0, 12, u"abcdefghij", 10);
-test(u"abcdefghijklmnopqrst", 0, -1, u"abcdefghijklmnopqrst", 0);
+test(u"abcdefghijklmnopqrst", 0, static_cast(-1), 
u"abcdefghijklmnopqrst", 0);
 }
 #endif
 


Index: test/std/strings/string.view/string.view.ops/substr.pass.cpp
===
--- test/std/strings/string.view/string.view.ops/substr.pass.cpp
+++ test/std/strings/string.view/string.view.ops/substr.pass.cpp
@@ -16,6 +16,8 @@
 // Returns: basic_string_view(data()+pos, rlen).
 
 #include 
+#include 
+#include 
 #include 
 
 #include "test_macros.h"
@@ -39,7 +41,7 @@
 #endif
 const size_t rlen = std::min(n, sv.size() - pos);
 assert (sv1.size() == rlen);
-for (size_t i = 0; i <= rlen; ++i)
+for (size_t i = 0; i < rlen; ++i)
 assert(sv[pos+i] == sv1[i]);
 }
 
Index: test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
===
--- test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
+++ test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
@@ -376,7 +376,7 @@
 test("abcdefghijklmnopqrst", 5, 5, "", 20);
 test("abcdefghijklmnopqrst", 0, 8, "abcde", 15);
 test("abcdefghijklmnopqrst", 0, 12, "abcdefghij", 10);
-test("abcdefghijklmnopqrst", 0, -1, "abcdefghijklmnopqrst", 0);
+test("abcdefghijklmnopqrst", 0, static_cast(-1), "abcdefghijklmnopqrst", 0);
 }
 
 {
@@ -395,7 +395,7 @@
 test(L"abcdefghijklmnopqrst", 5, 5, L"", 20);
 test(L"abcdefghijklmnopqrst", 0, 8, L"abcde", 15);
 test(L"abcdefghijklmnopqrst", 0, 12, L"abcdefghij", 10);
-test(L"abcdefghijklmnopqrst", 0, -1, L"abcdefghijklmnopqrst", 0);
+test(L"abcdefghijklmnopqrst", 0, static_cast(-1), L"abcdefghijklmnopqrst", 0);
 }

[PATCH] D27603: Propagate -fdiagnostics-color to LLD.

2016-12-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Driver/Tools.cpp:284
+  // propagate -fdiagnostics-color.
+  if (StringRef(TC.GetLinkerPath()).endswith("ld.lld") &&
+  D.getDiags().getShowColors())

ruiu wrote:
> rsmith wrote:
> > I don't think this will work for `-fuse-ld=$BINDIR/lld` and the like. We 
> > also have code around Tools.cpp doing things like this:
> > 
> > const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
> > if (llvm::sys::path::filename(Exec) == "lld") {
> > 
> > and
> > 
> > const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
> > if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
> > 
> > so detecting `ld.lld` here seems inconsistent. (Meanwhile, the above checks 
> > won't fire for `-fuse-ld=lld`, since that sets the linker path to 
> > .../ld.lld.)
> > 
> > I think it's time to factor out an `isLinkerLLD` function and use that to 
> > detect whether we're using lld.
> What if a linker is just `/usr/bin/ld`? I want to detect if it's LLD or not, 
> but it's not doable without running that command. (If we pass it via the 
> environment, we can always set LLD_COLOR_DIAGNOSTICS=1 though.)
Maybe the best we can do is have each target tell us what it expects 
`/usr/bin/ld` to be, and/or `readlink` it and see if it is a symlink to a 
binary named `lld`. This doesn't seem like a very satisfying answer, though :(

We already pass some flags if we think we're running `lld` (for instance, 
`-flavor gnu -target $TARGET`); passing those through the environment doesn't 
seem ideal.


https://reviews.llvm.org/D27603



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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics

2016-12-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin retitled this revision from "[analyzer] Improve VirtualCallChecker 
diagnostics and move out of alpha" to "[analyzer] Improve VirtualCallChecker 
diagnostics".
dcoughlin updated this revision to Diff 80953.
dcoughlin added a comment.

Keep the diagnostic improvements but remove the change to take the checker out 
of alpha.


https://reviews.llvm.org/D26768

Files:
  lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  test/Analysis/virtualcall.cpp
  test/Analysis/virtualcall.h

Index: test/Analysis/virtualcall.h
===
--- test/Analysis/virtualcall.h
+++ test/Analysis/virtualcall.h
@@ -18,7 +18,15 @@
   class A {
   public:
 A() {
-  foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
 }
 
 virtual int foo();
Index: test/Analysis/virtualcall.cpp
===
--- test/Analysis/virtualcall.cpp
+++ test/Analysis/virtualcall.cpp
@@ -1,36 +1,79 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -analyzer-config alpha.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region -analyzer-config alpha.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s
+
+/* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable
+   from a constructor or destructor. If it is not set, we expect diagnostics
+   only in the constructor or destructor.
+
+   When PUREONLY is set, we expect diagnostics only for calls to pure virtual
+   functions not to non-pure virtual functions.
+*/
 
 class A {
 public:
   A();
+  A(int i);
+
   ~A() {};
   
-  virtual int foo() = 0;
+  virtual int foo() = 0; // from Sema: expected-note {{'foo' declared here}}
   virtual void bar() = 0;
   void f() {
-foo(); // expected-warning{{Call pure virtual functions during construction or destruction may leads undefined behaviour}}
+foo();
+#if INTERPROCEDURAL
+// expected-warning-re@-2 ^}}Call Path : foo <-- fCall to pure virtual function during construction has undefined behavior}}
+#endif
   }
 };
 
 class B : public A {
 public:
   B() {
-foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+// expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during construction will not dispatch to derived class}}
+#else
+// expected-warning-re@-5 ^}}Call to virtual function during construction will not dispatch to derived class}}
+#endif
+#endif
+
   }
   ~B();
   
   virtual int foo();
-  virtual void bar() { foo(); }  // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  virtual void bar() { foo(); }
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : foo <-- barCall to virtual function during destruction will not dispatch to derived class}}
+#endif
 };
 
 A::A() {
   f();
 }
 
+A::A(int i) {
+  foo(); // From Sema: expected-warning {{call to pure virtual member function 'foo' has undefined behavior}}
+#if INTERPROCEDURAL
+  // expected-warning-re@-2 ^}}Call Path : fooCall to pure virtual function during construction has undefined behavior}}
+#else
+  // expected-warning-re@-4 ^}}Call to pure virtual function during construction has undefined behavior}}
+#endif
+}
+
 B::~B() {
   this->B::foo(); // no-warning
   this->B::bar();
-  this->foo(); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  this->foo();
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function during destruction will not dispatch to derived class}}
+#else
+  // expected-warning-re@-5 ^}}Call to virtual function during destruction will not dispatch to derived class}}
+#endif
+#endif
+
 }
 
 class C : public B {
@@ -43,7 +86,14 @@
 };
 
 C::C() {
-  f(foo()); // expected-warning{{Call virtual functions during construction or destruction will never go to a more derived class}}
+  f(foo());
+#if !PUREONLY
+#if INTERPROCEDURAL
+  // expected-warning-re@-3 ^}}Call Path : fooCall to virtual function 

[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Ok, I'm not understanding this, then.

I declare a local variable:

  int x;

According to you, x should be in the generic address space, i.e. the private 
address space.  And at the LLVM IR level, this will be implemented with an 
AllocaInst, which always creates memory in the private address space, i.e. LLVM 
address space 0.

But Sema believes that the l-value 'x' has type int, without an address space, 
and therefore that '' has type int*, again without an explicit address space. 
 And you want to say that that type actually points into a different address 
space, and to make sure that that pointer is in LLVM address space 4.

Something about this does not work.


https://reviews.llvm.org/D27627



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


[PATCH] Fix modernize-deprecated-headers clang-tidy warnings

2016-12-09 Thread Michael Sharpe via cfe-commits
The attached patch will replace C included headers with the respective C++
versions.

Best regards,

Michael Sharpe
diff --git lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGen/CGOpenCLRuntime.cpp
index 9062936..f4c961c 100644
--- lib/CodeGen/CGOpenCLRuntime.cpp
+++ lib/CodeGen/CGOpenCLRuntime.cpp
@@ -18,7 +18,7 @@
 #include "TargetInfo.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/GlobalValue.h"
-#include 
+#include 
 
 using namespace clang;
 using namespace CodeGen;
diff --git lib/Driver/Types.cpp lib/Driver/Types.cpp
index ab63f0e..43b5a1e 100644
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -11,7 +11,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 #include 
-#include 
+#include 
 
 using namespace clang::driver;
 using namespace clang::driver::types;
diff --git lib/Frontend/CodeGenOptions.cpp lib/Frontend/CodeGenOptions.cpp
index 50bb9f9..e5f483c 100644
--- lib/Frontend/CodeGenOptions.cpp
+++ lib/Frontend/CodeGenOptions.cpp
@@ -8,7 +8,7 @@
 //===--===//
 
 #include "clang/Frontend/CodeGenOptions.h"
-#include 
+#include 
 
 namespace clang {
 
diff --git lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInstance.cpp
index 991e9ef..139fbfb 100644
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -48,7 +48,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
-#include 
+#include 
 #include 
 
 using namespace clang;
diff --git lib/Lex/HeaderSearch.cpp lib/Lex/HeaderSearch.cpp
index 0aef7ff..cec3942 100644
--- lib/Lex/HeaderSearch.cpp
+++ lib/Lex/HeaderSearch.cpp
@@ -29,7 +29,7 @@
 #include 
 #include 
 #if defined(LLVM_ON_UNIX)
-#include 
+#include 
 #endif
 using namespace clang;
 
diff --git lib/Lex/ModuleMap.cpp lib/Lex/ModuleMap.cpp
index c1b7b33..bf2f1f5 100644
--- lib/Lex/ModuleMap.cpp
+++ lib/Lex/ModuleMap.cpp
@@ -30,9 +30,9 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
+#include 
 #if defined(LLVM_ON_UNIX)
-#include 
+#include 
 #endif
 using namespace clang;
 
diff --git lib/Sema/DelayedDiagnostic.cpp lib/Sema/DelayedDiagnostic.cpp
index 2fa5718..c047ffd 100644
--- lib/Sema/DelayedDiagnostic.cpp
+++ lib/Sema/DelayedDiagnostic.cpp
@@ -15,7 +15,7 @@
 //
 //===--===//
 #include "clang/Sema/DelayedDiagnostic.h"
-#include 
+#include 
 using namespace clang;
 using namespace sema;
 
diff --git lib/Tooling/Core/QualTypeNames.cpp lib/Tooling/Core/QualTypeNames.cpp
index 721c2c9..7bfa745 100644
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -15,7 +15,7 @@
 #include "clang/AST/GlobalDecl.h"
 #include "clang/AST/Mangle.h"
 
-#include 
+#include 
 #include 
 
 namespace clang {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27580: [modules] Add optional out-param to ASTReader::ReadAST for imported submodules.

2016-12-09 Thread Graydon Hoare via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289276: [modules] Add optional out-param to 
ASTReader::ReadAST for imported submodules. (authored by graydon).

Changed prior to commit:
  https://reviews.llvm.org/D27580?vs=80782=80952#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27580

Files:
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/lib/Serialization/ASTReader.cpp


Index: cfe/trunk/include/clang/Serialization/ASTReader.h
===
--- cfe/trunk/include/clang/Serialization/ASTReader.h
+++ cfe/trunk/include/clang/Serialization/ASTReader.h
@@ -821,14 +821,16 @@
   // \brief A list of late parsed template function data.
   SmallVector LateParsedTemplates;
 
+public:
   struct ImportedSubmodule {
 serialization::SubmoduleID ID;
 SourceLocation ImportLoc;
 
 ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
   : ID(ID), ImportLoc(ImportLoc) {}
   };
 
+private:
   /// \brief A list of modules that were imported by precompiled headers or
   /// any other non-module AST file.
   SmallVector ImportedModules;
@@ -1404,9 +1406,13 @@
   /// \param ClientLoadCapabilities The set of client load-failure
   /// capabilities, represented as a bitset of the enumerators of
   /// LoadFailureCapabilities.
+  ///
+  /// \param Imported optional out-parameter to append the list of modules
+  /// that were imported by precompiled headers or any other non-module AST 
file
   ASTReadResult ReadAST(StringRef FileName, ModuleKind Type,
 SourceLocation ImportLoc,
-unsigned ClientLoadCapabilities);
+unsigned ClientLoadCapabilities,
+SmallVectorImpl *Imported = 
nullptr);
 
   /// \brief Make the entities in the given module and any of its 
(non-explicit)
   /// submodules visible to name lookup.
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -3578,7 +3578,8 @@
 ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
 ModuleKind Type,
 SourceLocation ImportLoc,
-unsigned ClientLoadCapabilities) {
+unsigned ClientLoadCapabilities,
+SmallVectorImpl 
*Imported) {
   llvm::SaveAndRestore
 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
 
@@ -3744,6 +3745,10 @@
   }
   UnresolvedModuleRefs.clear();
 
+  if (Imported)
+Imported->append(ImportedModules.begin(),
+ ImportedModules.end());
+
   // FIXME: How do we load the 'use'd modules? They may not be submodules.
   // Might be unnecessary as use declarations are only used to build the
   // module itself.


Index: cfe/trunk/include/clang/Serialization/ASTReader.h
===
--- cfe/trunk/include/clang/Serialization/ASTReader.h
+++ cfe/trunk/include/clang/Serialization/ASTReader.h
@@ -821,14 +821,16 @@
   // \brief A list of late parsed template function data.
   SmallVector LateParsedTemplates;
 
+public:
   struct ImportedSubmodule {
 serialization::SubmoduleID ID;
 SourceLocation ImportLoc;
 
 ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
   : ID(ID), ImportLoc(ImportLoc) {}
   };
 
+private:
   /// \brief A list of modules that were imported by precompiled headers or
   /// any other non-module AST file.
   SmallVector ImportedModules;
@@ -1404,9 +1406,13 @@
   /// \param ClientLoadCapabilities The set of client load-failure
   /// capabilities, represented as a bitset of the enumerators of
   /// LoadFailureCapabilities.
+  ///
+  /// \param Imported optional out-parameter to append the list of modules
+  /// that were imported by precompiled headers or any other non-module AST file
   ASTReadResult ReadAST(StringRef FileName, ModuleKind Type,
 SourceLocation ImportLoc,
-unsigned ClientLoadCapabilities);
+unsigned ClientLoadCapabilities,
+SmallVectorImpl *Imported = nullptr);
 
   /// \brief Make the entities in the given module and any of its (non-explicit)
   /// submodules visible to name lookup.
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -3578,7 +3578,8 @@
 ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
 

[PATCH] D27631: [CUDA,Driver] Added --no-cuda-gpu-arch= option.

2016-12-09 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 80950.
tra added a comment.

Removed sorting and extraneous empty lines.


https://reviews.llvm.org/D27631

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -64,18 +64,18 @@
 
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE-SM35 -check-prefix HOST \
+// RUN:-check-prefix DEVICE-SM30 -check-prefix HOST \
 // RUN:-check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
 
 // Verify that there is one device-side compilation per --cuda-gpu-arch args
 // and that all results are included on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
-// RUN:-check-prefix DEVICE2-SM30 -check-prefix HOST \
+// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM30 \
+// RUN:-check-prefix DEVICE2-SM35 -check-prefix HOST \
 // RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
 // RUN:-check-prefix NOLINK %s
 
@@ -92,6 +92,65 @@
 // RUN:-check-prefix HOST -check-prefix HOST-NOSAVE \
 // RUN:-check-prefix HOST-AS -check-prefix NOLINK %s
 
+// Verify that --[no-]cuda-gpu-arch arguments are handled correctly.
+// a) --no-cuda-gpu-arch=X negates preceeding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
+
+// b) --no-cuda-gpu-arch=X negates more than one preceeding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
+
+// c) if --no-cuda-gpu-arch=X negates all preceeding --cuda-gpu-arch=X
+//we default to sm_20 -- same as if no --cuda-gpu-arch were passed.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes ARCH-SM20,NOARCH-SM30,NOARCH-SM35 %s
+
+// d) --no-cuda-gpu-arch=X is a no-op if there's no preceding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30\
+// RUN:   --no-cuda-gpu-arch=sm_50 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
+
+// e) --no-cuda-gpu-arch=X does not affect following --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
+
+// f) --no-cuda-gpu-arch=all negates all preceding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=all \
+// RUN:   --cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,NOARCH-SM30,ARCH-SM35 %s
+
+// g) There's no --cuda-gpu-arch=all
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=all \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCHALLERROR %s
+
+// ARCH-SM20: "-cc1"{{.*}}"-target-cpu" "sm_20"
+// NOARCH-SM20-NOT: "-cc1"{{.*}}"-target-cpu" "sm_20"
+// ARCH-SM30: "-cc1"{{.*}}"-target-cpu" "sm_30"
+// NOARCH-SM30-NOT: "-cc1"{{.*}}"-target-cpu" "sm_30"
+// ARCH-SM35: "-cc1"{{.*}}"-target-cpu" "sm_35"
+// NOARCH-SM35-NOT: "-cc1"{{.*}}"-target-cpu" "sm_35"
+// ARCHALLERROR: error: Unsupported CUDA gpu architecture: all
+
 // Match device-side preprocessor and compiler phases with -save-temps.
 // DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -107,22 +166,22 @@
 // DEVICE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // DEVICE-NOSAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
 // DEVICE-SAME: "-fcuda-is-device"
-// DEVICE-SM35-SAME: "-target-cpu" 

[PATCH] D27631: [CUDA,Driver] Added --no-cuda-gpu-arch= option.

2016-12-09 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Driver/Driver.cpp:1952
+
+
+  // Default to sm_20 which is the lowest common denominator for

Extra linebreak



Comment at: lib/Driver/Driver.cpp:1960
+// Sort GpuArchList to make compilation order deterministic.
+std::sort(GpuArchList.begin(), GpuArchList.end());
 

We're using std::set, so I don't think this is necessary?  You could have a 
comment on std::set saying that we use it to get a deterministic order, if you 
want.



Comment at: test/Driver/cuda-options.cu:154
+
+
 // Match device-side preprocessor and compiler phases with -save-temps.

Extra linebreak


https://reviews.llvm.org/D27631



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


[PATCH] D26768: [analyzer] Improve VirtualCallChecker diagnostics and move out of alpha

2016-12-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I evaluated this checker on three internal codebases that make large use of 
virtual functions.

Project 1: ~190,000 lines of C++. 16 alarms. I triaged all of them. There were 
2 definite false positives (FPs) and 14 likely FPs.
Project 2: ~320,000 lines of C++. 116 alarms. I triaged 45. All likely FPs.
Project 3: ~23,000 lines of C++. 43 alarms. I triaged 13. 3 definite FPs and 10 
likely FPs.

The definite false positives were cases where the programmer seemed aware of 
the semantics of virtual calls during construction/destruction and had each 
subclass explicitly call its own version of the virtual method in question. The 
likely false positives were cases where there was no subclass of the 
constructed class that overrode the method in question.

I think there is value in this checker: virtual calls in constructors are a 
definite code smell and are hard to get right. But I don't think we can turn it 
on by default given the sheer number of alarms. I think this needs to stay in 
alpha until we can reduce the number of false positives


https://reviews.llvm.org/D26768



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


[PATCH] D27631: [CUDA,Driver] Added --no-cuda-gpu-arch= option.

2016-12-09 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
tra added reviewers: jlebar, echristo.
tra added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.

This allows us to negate preceding --cuda-gpu-arch=X.
This comes handy when user needs to override default flags set for them by the 
build system.


https://reviews.llvm.org/D27631

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -64,18 +64,18 @@
 
 // Verify that --cuda-gpu-arch option passes the correct GPU archtecture to
 // device compilation.
-// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_35 -c %s 2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE-SM35 -check-prefix HOST \
+// RUN:-check-prefix DEVICE-SM30 -check-prefix HOST \
 // RUN:-check-prefix INCLUDES-DEVICE -check-prefix NOLINK %s
 
 // Verify that there is one device-side compilation per --cuda-gpu-arch args
 // and that all results are included on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
 // RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM35 \
-// RUN:-check-prefix DEVICE2-SM30 -check-prefix HOST \
+// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM30 \
+// RUN:-check-prefix DEVICE2-SM35 -check-prefix HOST \
 // RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
 // RUN:-check-prefix NOLINK %s
 
@@ -92,6 +92,66 @@
 // RUN:-check-prefix HOST -check-prefix HOST-NOSAVE \
 // RUN:-check-prefix HOST-AS -check-prefix NOLINK %s
 
+// Verify that --[no-]cuda-gpu-arch arguments are handled correctly.
+// a) --no-cuda-gpu-arch=X negates preceeding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
+
+// b) --no-cuda-gpu-arch=X negates more than one preceeding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,NOARCH-SM35 %s
+
+// c) if --no-cuda-gpu-arch=X negates all preceeding --cuda-gpu-arch=X
+//we default to sm_20 -- same as if no --cuda-gpu-arch were passed.
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes ARCH-SM20,NOARCH-SM30,NOARCH-SM35 %s
+
+// d) --no-cuda-gpu-arch=X is a no-op if there's no preceding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30\
+// RUN:   --no-cuda-gpu-arch=sm_50 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
+
+// e) --no-cuda-gpu-arch=X does not affect following --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --no-cuda-gpu-arch=sm_35 --no-cuda-gpu-arch=sm_30 \
+// RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,ARCH-SM30,ARCH-SM35 %s
+
+// f) --no-cuda-gpu-arch=all negates all preceding --cuda-gpu-arch=X
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 \
+// RUN:   --no-cuda-gpu-arch=all \
+// RUN:   --cuda-gpu-arch=sm_35 \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefixes NOARCH-SM20,NOARCH-SM30,ARCH-SM35 %s
+
+// g) There's no --cuda-gpu-arch=all
+// RUN: %clang -### -target x86_64-linux-gnu --cuda-device-only \
+// RUN:   --cuda-gpu-arch=all \
+// RUN:   -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix ARCHALLERROR %s
+
+// ARCH-SM20: "-cc1"{{.*}}"-target-cpu" "sm_20"
+// NOARCH-SM20-NOT: "-cc1"{{.*}}"-target-cpu" "sm_20"
+// ARCH-SM30: "-cc1"{{.*}}"-target-cpu" "sm_30"
+// NOARCH-SM30-NOT: "-cc1"{{.*}}"-target-cpu" "sm_30"
+// ARCH-SM35: "-cc1"{{.*}}"-target-cpu" "sm_35"
+// NOARCH-SM35-NOT: "-cc1"{{.*}}"-target-cpu" "sm_35"
+// ARCHALLERROR: error: Unsupported CUDA gpu architecture: all
+
+
 // Match device-side preprocessor and compiler phases with -save-temps.
 // DEVICE-SAVE: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // DEVICE-SAVE-SAME: "-aux-triple" "x86_64--linux-gnu"
@@ -107,22 +167,22 

r289273 - Remove special error recovery for ::(id)

2016-12-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Dec  9 15:10:43 2016
New Revision: 289273

URL: http://llvm.org/viewvc/llvm-project?rev=289273=rev
Log:
Remove special error recovery for ::(id)

The code pattern used to implement the token rewriting hack doesn't
interact well with token caching in the pre-processor. As a result,
clang would crash on 'int f(::(id));' while doing a tenative parse of
the contents of the outer parentheses. The original code from PR11852
still doesn't crash the compiler.

This error recovery also often does the wrong thing with member function
pointers. The test case from the original PR doesn't recover the right
way either:
  void S::(*pf)() = S::f; // should be 'void (S::*pf)()'

Instead we were recovering as 'void S::*pf()', which is still wrong.

If we still think that users mistakenly parenthesize identifiers in
nested name specifiers, we should change clang to intentionally parse
that form with an error, rather than doing a token rewrite.

Fixes PR26623, but I think there will be many more bugs like this around
token rewriting in the parser.

Reviewers: rsmith, rtrieu

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/test/Parser/colon-colon-parentheses.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=289273=289272=289273=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Dec  9 15:10:43 
2016
@@ -347,8 +347,6 @@ def ext_c11_static_assert : Extension<
 def warn_cxx98_compat_static_assert : Warning<
   "static_assert declarations are incompatible with C++98">,
   InGroup, DefaultIgnore;
-def err_paren_after_colon_colon : Error<
-  "unexpected parenthesis after '::'">;
 def err_function_definition_not_allowed : Error<
   "function definition is not allowed here">;
 def err_expected_end_of_enumerator : Error<

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=289273=289272=289273=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Fri Dec  9 15:10:43 2016
@@ -1530,8 +1530,6 @@ private:
   bool IsTypename = false,
   IdentifierInfo **LastII = nullptr);
 
-  void CheckForLParenAfterColonColon();
-
   
//======//
   // C++0x 5.1.2: Lambda expressions
 

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=289273=289272=289273=diff
==
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp Fri Dec  9 15:10:43 2016
@@ -100,48 +100,6 @@ void Parser::CheckForTemplateAndDigraph(
  /*AtDigraph*/false);
 }
 
-/// \brief Emits an error for a left parentheses after a double colon.
-///
-/// When a '(' is found after a '::', emit an error.  Attempt to fix the token
-/// stream by removing the '(', and the matching ')' if found.
-void Parser::CheckForLParenAfterColonColon() {
-  if (!Tok.is(tok::l_paren))
-return;
-
-  Token LParen = Tok;
-  Token NextTok = GetLookAheadToken(1);
-  Token StarTok = NextTok;
-  // Check for (identifier or (*identifier
-  Token IdentifierTok = StarTok.is(tok::star) ? GetLookAheadToken(2) : StarTok;
-  if (IdentifierTok.isNot(tok::identifier))
-return;
-  // Eat the '('.
-  ConsumeParen();
-  Token RParen;
-  RParen.setLocation(SourceLocation());
-  // Do we have a ')' ?
-  NextTok = StarTok.is(tok::star) ? GetLookAheadToken(2) : 
GetLookAheadToken(1);
-  if (NextTok.is(tok::r_paren)) {
-RParen = NextTok;
-// Eat the '*' if it is present.
-if (StarTok.is(tok::star))
-  ConsumeToken();
-// Eat the identifier.
-ConsumeToken();
-// Add the identifier token back.
-PP.EnterToken(IdentifierTok);
-// Add the '*' back if it was present.
-if (StarTok.is(tok::star))
-  PP.EnterToken(StarTok);
-// Eat the ')'.
-ConsumeParen();
-  }
-
-  Diag(LParen.getLocation(), diag::err_paren_after_colon_colon)
-  << FixItHint::CreateRemoval(LParen.getLocation())
-  << FixItHint::CreateRemoval(RParen.getLocation());
-}
-
 /// \brief Parse global scope or nested-name-specifier if present.
 ///
 /// Parses a C++ global scope specifier ('::') or nested-name-specifier (which
@@ -237,8 +195,6 @@ bool Parser::ParseOptionalCXXScopeSpecif
   if 

[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D27627#618597, @rjmccall wrote:

> What address space should local variables be in?


should always be 0 since that's llvm convention.


https://reviews.llvm.org/D27627



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


Re: r289259 - Improve error message when referencing a non-tag type with a tag

2016-12-09 Thread Reid Kleckner via cfe-commits
On Fri, Dec 9, 2016 at 12:01 PM, Nico Weber  wrote:

> I never heard "class specifier" outside of compilerese either…
>

Even if "specifier" is noise to the user, we mention the exact keyword they
used, i.e. class, struct, union, enum. That seems like a big improvement.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

What address space should local variables be in?


https://reviews.llvm.org/D27627



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


[PATCH] D27607: [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:1221
+/// Check if \p Ty is defined as BOOL in a system header. In ObjC language
+/// modes, it's safe to treat such a type as 'the builtin bool'.
+static bool isObjCBool(QualType Ty, const SourceManager ,

If your intention is to exclude BOOLs defined in files that aren't system 
headers, is it possible to add a test for that?


```
void foo() {
  typedef long long BOOL;
  ...
}
```


https://reviews.llvm.org/D27607



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


[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-12-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: lib/Driver/ToolChain.cpp:362
+  return UseLinker;
+  } else if (UseLinker == "ld") {
+// If we're passed the argument ld, then use whatever the default system

I'm wandering whether we shouldn't use `"platform"` instead of `"ld"` here to 
match what we do for `-rtlib=` and `-stdlib=`?


Repository:
  rL LLVM

https://reviews.llvm.org/D25263



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


[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-12-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 80934.
phosek marked 4 inline comments as done.

Repository:
  rL LLVM

https://reviews.llvm.org/D25263

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -951,6 +951,10 @@
  : RuntimeLibType::RLT_CompilerRT;
   }
 
+  const char *getDefaultLinker() const override {
+return "lld";
+  }
+
 private:
   Multilib SelectedMultilib;
   std::string LibSuffix;
@@ -1080,6 +1084,10 @@
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
+  const char *getDefaultLinker() const override {
+return "lld";
+  }
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
@@ -1279,6 +1287,10 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
 
+  const char *getDefaultLinker() const override {
+return "lld";
+  }
+
   Tool *buildLinker() const override;
 };
 
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3026,9 +3026,6 @@
   LibSuffix = tools::mips::getMipsABILibSuffix(Args, Triple);
   getFilePaths().clear();
   getFilePaths().push_back(computeSysRoot() + "/usr/lib" + LibSuffix);
-
-  // Use LLD by default.
-  DefaultLinker = "lld";
 }
 
 void MipsLLVMToolChain::AddClangSystemIncludeArgs(
@@ -4716,9 +4713,6 @@
 
   getFilePaths().push_back(D.SysRoot + "/lib");
   getFilePaths().push_back(D.ResourceDir + "/lib/fuchsia");
-
-  // Use LLD by default.
-  DefaultLinker = "lld";
 }
 
 Tool *Fuchsia::buildAssembler() const {
@@ -5140,9 +5134,6 @@
   assert(Triple.isArch32Bit() != Triple.isArch64Bit());
   getFilePaths().push_back(
   getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
-
-  // Use LLD by default.
-  DefaultLinker = "lld";
 }
 
 bool WebAssembly::IsMathErrnoDefault() const { return false; }
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -351,33 +351,31 @@
 }
 
 std::string ToolChain::GetLinkerPath() const {
-  if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
-StringRef UseLinker = A->getValue();
-
-if (llvm::sys::path::is_absolute(UseLinker)) {
-  // If we're passed -fuse-ld= with what looks like an absolute path,
-  // don't attempt to second-guess that.
-  if (llvm::sys::fs::exists(UseLinker))
-return UseLinker;
-} else {
-  // If we're passed -fuse-ld= with no argument, or with the argument ld,
-  // then use whatever the default system linker is.
-  if (UseLinker.empty() || UseLinker == "ld")
-return GetProgramPath("ld");
-
-  llvm::SmallString<8> LinkerName("ld.");
-  LinkerName.append(UseLinker);
-
-  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
-  if (llvm::sys::fs::exists(LinkerPath))
-return LinkerPath;
-}
+  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
+  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
+
+  if (llvm::sys::path::is_absolute(UseLinker)) {
+// If we're passed what looks like an absolute path, don't attempt to
+// second-guess that.
+if (llvm::sys::fs::exists(UseLinker))
+  return UseLinker;
+  } else if (UseLinker == "ld") {
+// If we're passed the argument ld, then use whatever the default system
+// linker is.
+return GetProgramPath(getDefaultLinker());
+  } else if (!UseLinker.empty()) {
+llvm::SmallString<8> LinkerName("ld.");
+LinkerName.append(UseLinker);
+
+std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+if (llvm::sys::fs::exists(LinkerPath))
+  return LinkerPath;
+  }
 
+  if (A)
 getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
-return "";
-  }
 
-  return GetProgramPath(DefaultLinker);
+  return GetProgramPath(getDefaultLinker());
 }
 
 types::ID ToolChain::LookupTypeForExtension(StringRef Ext) const {
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -105,7 +105,6 @@
 
 protected:
   MultilibSet Multilibs;
-  const char *DefaultLinker = "ld";
 
   ToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
@@ -272,6 +271,11 @@
 return 0;
   }
 
+  /// GetDefaultLinker - Get the default linker to use.
+  virtual const char *getDefaultLinker() const {
+return "ld";
+  }
+
   /// GetDefaultRuntimeLibType - Get the default runtime 

[libcxx] r289264 - [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.

2016-12-09 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Dec  9 13:53:08 2016
New Revision: 289264

URL: http://llvm.org/viewvc/llvm-project?rev=289264=rev
Log:
[libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove 
an unused variable.

test/support/test_macros.h
For convenience/greppability, add macros for libcxx-specific static_asserts 
about noexceptness.

(Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't 
technically necessary
because they're macros, but I think it's better style to define stuff before 
using it.)

test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
There was a completely unused `TrackedCallable obj;`.

apply() isn't depicted with conditional noexcept in C++17.

test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
Now that we have LIBCPP_ASSERT_NOEXCEPT, use it.

Fixes D27622.

Modified:
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
libcxx/trunk/test/support/test_macros.h

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp?rev=289264=289263=289264=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp 
Fri Dec  9 13:53:08 2016
@@ -166,7 +166,6 @@ void check_apply_quals_and_types(Tuple&&
 
 void test_call_quals_and_arg_types()
 {
-TrackedCallable obj;
 using Tup = std::tuple;
 const int x = 42;
 unsigned y = 101;
@@ -199,7 +198,7 @@ void test_noexcept()
 // test that the functions noexcept-ness is propagated
 using Tup = std::tuple;
 Tup t;
-ASSERT_NOEXCEPT(std::apply(nec, t));
+LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, t));
 ASSERT_NOT_NOEXCEPT(std::apply(tc, t));
 }
 {
@@ -207,7 +206,7 @@ void test_noexcept()
 using Tup = std::tuple;
 Tup t;
 ASSERT_NOT_NOEXCEPT(std::apply(nec, t));
-ASSERT_NOEXCEPT(std::apply(nec, std::move(t)));
+LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, std::move(t)));
 }
 }
 

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp?rev=289264=289263=289264=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
 Fri Dec  9 13:53:08 2016
@@ -175,14 +175,14 @@ void test_noexcept() {
 Tuple tup; ((void)tup);
 Tuple const& ctup = tup; ((void)ctup);
 ASSERT_NOT_NOEXCEPT(std::make_from_tuple(ctup));
-
LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup;
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup)));
 }
 {
 using Tuple = std::pair;
 Tuple tup; ((void)tup);
 Tuple const& ctup = tup; ((void)ctup);
 ASSERT_NOT_NOEXCEPT(std::make_from_tuple(ctup));
-
LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup;
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup)));
 }
 {
 using Tuple = std::tuple;
@@ -192,7 +192,7 @@ void test_noexcept() {
 {
 using Tuple = std::tuple;
 Tuple tup; ((void)tup);
-LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(tup)));
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(tup));
 }
 {
 using Tuple = std::array;
@@ -202,7 +202,7 @@ void test_noexcept() {
 {
 using Tuple = std::array;
 Tuple tup; ((void)tup);
-LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(tup)));
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(tup));
 }
 }
 

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=289264=289263=289264=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Fri Dec  9 13:53:08 2016
@@ -128,23 +128,27 @@
 #define TEST_NORETURN [[noreturn]]
 #endif
 
+#define ASSERT_NOEXCEPT(...) \
+static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept")
+
+#define ASSERT_NOT_NOEXCEPT(...) \
+static_assert(!noexcept(__VA_ARGS__), "Operation 

Re: r289259 - Improve error message when referencing a non-tag type with a tag

2016-12-09 Thread Nico Weber via cfe-commits
I never heard "class specifier" outside of compilerese either…

On Fri, Dec 9, 2016 at 2:47 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Fri Dec  9 13:47:58 2016
> New Revision: 289259
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289259=rev
> Log:
> Improve error message when referencing a non-tag type with a tag
>
> Other compilers accept invalid code here that we reject, and we need a
> better error message to try to convince users that the code is really
> incorrect. Consider:
>   class Foo {
> typedef MyIterHelper iterator;
> friend class iterator;
>   };
>
> Previously our wording was "elaborated type refers to a typedef".
> "elaborated type" isn't widely known terminology, so the new diagnostic
> says "typedef 'iterator' cannot be referenced with class specifier".
>
> Reviewers: rsmith
>
> Differential Revision: https://reviews.llvm.org/D25216
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
> cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
> cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
> cfe/trunk/test/CXX/drs/dr2xx.cpp
> cfe/trunk/test/CXX/drs/dr4xx.cpp
> cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
> cfe/trunk/test/CXX/temp/temp.spec/no-body.cpp
> cfe/trunk/test/SemaCXX/PR8755.cpp
> cfe/trunk/test/SemaCXX/using-decl-templates.cpp
> cfe/trunk/test/SemaTemplate/template-id-expr.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=289259=289258=289259=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec  9
> 13:47:58 2016
> @@ -4564,10 +4564,15 @@ def err_redefinition_different_typedef :
>"%select{typedef|type alias|type alias template}0 "
>"redefinition with different types%diff{ ($ vs $)|}1,2">;
>  def err_tag_reference_non_tag : Error<
> -  "elaborated type refers to %select{a non-tag type|a typedef|a type
> alias|a template|a type alias template|a template template argument}0">;
> +  "%select{non-struct type|non-class type|non-union type|non-enum "
> +  "type|typedef|type alias|template|type alias template|template "
> +  "template argument}1 %0 cannot be referenced with a "
> +  "%select{struct|interface|union|class|enum}2 specifier">;
>  def err_tag_reference_conflict : Error<
> -  "implicit declaration introduced by elaborated type conflicts with "
> -  "%select{a declaration|a typedef|a type alias|a template}0 of the same
> name">;
> +  "implicit declaration introduced by elaborated type conflicts with a "
> +  "%select{non-struct type|non-class type|non-union type|non-enum "
> +  "type|typedef|type alias|template|type alias template|template "
> +  "template argument}0 of the same name">;
>  def err_dependent_tag_decl : Error<
>"%select{declaration|definition}0 of "
>"%select{struct|interface|union|class|enum}1 in a dependent scope">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=289259=289258=289259=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Dec  9 13:47:58 2016
> @@ -1976,7 +1976,10 @@ public:
>/// Common ways to introduce type names without a tag for use in
> diagnostics.
>/// Keep in sync with err_tag_reference_non_tag.
>enum NonTagKind {
> -NTK_Unknown,
> +NTK_NonStruct,
> +NTK_NonClass,
> +NTK_NonUnion,
> +NTK_NonEnum,
>  NTK_Typedef,
>  NTK_TypeAlias,
>  NTK_Template,
> @@ -1986,7 +1989,7 @@ public:
>
>/// Given a non-tag type declaration, returns an enum useful for
> indicating
>/// what kind of non-tag type this is.
> -  NonTagKind getNonTagTypeDeclKind(const Decl *D);
> +  NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
>
>bool isAcceptableTagRedeclaration(const TagDecl *Previous,
>  TagTypeKind NewTag, bool isDefinition,
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=289259=289258=289259=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec  9 13:47:58 2016
> @@ -12430,7 +12430,8 @@ static bool isClassCompatTagKind(TagType
>return Tag == TTK_Struct || Tag == TTK_Class || Tag == TTK_Interface;
>  }
>
> 

r289259 - Improve error message when referencing a non-tag type with a tag

2016-12-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Dec  9 13:47:58 2016
New Revision: 289259

URL: http://llvm.org/viewvc/llvm-project?rev=289259=rev
Log:
Improve error message when referencing a non-tag type with a tag

Other compilers accept invalid code here that we reject, and we need a
better error message to try to convince users that the code is really
incorrect. Consider:
  class Foo {
typedef MyIterHelper iterator;
friend class iterator;
  };

Previously our wording was "elaborated type refers to a typedef".
"elaborated type" isn't widely known terminology, so the new diagnostic
says "typedef 'iterator' cannot be referenced with class specifier".

Reviewers: rsmith

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
cfe/trunk/test/CXX/drs/dr2xx.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
cfe/trunk/test/CXX/temp/temp.spec/no-body.cpp
cfe/trunk/test/SemaCXX/PR8755.cpp
cfe/trunk/test/SemaCXX/using-decl-templates.cpp
cfe/trunk/test/SemaTemplate/template-id-expr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=289259=289258=289259=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec  9 13:47:58 
2016
@@ -4564,10 +4564,15 @@ def err_redefinition_different_typedef :
   "%select{typedef|type alias|type alias template}0 "
   "redefinition with different types%diff{ ($ vs $)|}1,2">;
 def err_tag_reference_non_tag : Error<
-  "elaborated type refers to %select{a non-tag type|a typedef|a type alias|a 
template|a type alias template|a template template argument}0">;
+  "%select{non-struct type|non-class type|non-union type|non-enum "
+  "type|typedef|type alias|template|type alias template|template "
+  "template argument}1 %0 cannot be referenced with a "
+  "%select{struct|interface|union|class|enum}2 specifier">;
 def err_tag_reference_conflict : Error<
-  "implicit declaration introduced by elaborated type conflicts with "
-  "%select{a declaration|a typedef|a type alias|a template}0 of the same 
name">;
+  "implicit declaration introduced by elaborated type conflicts with a "
+  "%select{non-struct type|non-class type|non-union type|non-enum "
+  "type|typedef|type alias|template|type alias template|template "
+  "template argument}0 of the same name">;
 def err_dependent_tag_decl : Error<
   "%select{declaration|definition}0 of "
   "%select{struct|interface|union|class|enum}1 in a dependent scope">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=289259=289258=289259=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Dec  9 13:47:58 2016
@@ -1976,7 +1976,10 @@ public:
   /// Common ways to introduce type names without a tag for use in diagnostics.
   /// Keep in sync with err_tag_reference_non_tag.
   enum NonTagKind {
-NTK_Unknown,
+NTK_NonStruct,
+NTK_NonClass,
+NTK_NonUnion,
+NTK_NonEnum,
 NTK_Typedef,
 NTK_TypeAlias,
 NTK_Template,
@@ -1986,7 +1989,7 @@ public:
 
   /// Given a non-tag type declaration, returns an enum useful for indicating
   /// what kind of non-tag type this is.
-  NonTagKind getNonTagTypeDeclKind(const Decl *D);
+  NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
 
   bool isAcceptableTagRedeclaration(const TagDecl *Previous,
 TagTypeKind NewTag, bool isDefinition,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=289259=289258=289259=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Dec  9 13:47:58 2016
@@ -12430,7 +12430,8 @@ static bool isClassCompatTagKind(TagType
   return Tag == TTK_Struct || Tag == TTK_Class || Tag == TTK_Interface;
 }
 
-Sema::NonTagKind Sema::getNonTagTypeDeclKind(const Decl *PrevDecl) {
+Sema::NonTagKind Sema::getNonTagTypeDeclKind(const Decl *PrevDecl,
+ TagTypeKind TTK) {
   if (isa(PrevDecl))
 return NTK_Typedef;
   else if (isa(PrevDecl))
@@ -12441,7 +12442,17 @@ Sema::NonTagKind Sema::getNonTagTypeDecl
 return 

[PATCH] D25216: Improve error message when referencing a non-tag type with a tag

2016-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289259: Improve error message when referencing a non-tag 
type with a tag (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D25216?vs=80903=80927#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25216

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp
  cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp
  cfe/trunk/test/CXX/drs/dr2xx.cpp
  cfe/trunk/test/CXX/drs/dr4xx.cpp
  cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
  cfe/trunk/test/CXX/temp/temp.spec/no-body.cpp
  cfe/trunk/test/SemaCXX/PR8755.cpp
  cfe/trunk/test/SemaCXX/using-decl-templates.cpp
  cfe/trunk/test/SemaTemplate/template-id-expr.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1976,7 +1976,10 @@
   /// Common ways to introduce type names without a tag for use in diagnostics.
   /// Keep in sync with err_tag_reference_non_tag.
   enum NonTagKind {
-NTK_Unknown,
+NTK_NonStruct,
+NTK_NonClass,
+NTK_NonUnion,
+NTK_NonEnum,
 NTK_Typedef,
 NTK_TypeAlias,
 NTK_Template,
@@ -1986,7 +1989,7 @@
 
   /// Given a non-tag type declaration, returns an enum useful for indicating
   /// what kind of non-tag type this is.
-  NonTagKind getNonTagTypeDeclKind(const Decl *D);
+  NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK);
 
   bool isAcceptableTagRedeclaration(const TagDecl *Previous,
 TagTypeKind NewTag, bool isDefinition,
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4564,10 +4564,15 @@
   "%select{typedef|type alias|type alias template}0 "
   "redefinition with different types%diff{ ($ vs $)|}1,2">;
 def err_tag_reference_non_tag : Error<
-  "elaborated type refers to %select{a non-tag type|a typedef|a type alias|a template|a type alias template|a template template argument}0">;
+  "%select{non-struct type|non-class type|non-union type|non-enum "
+  "type|typedef|type alias|template|type alias template|template "
+  "template argument}1 %0 cannot be referenced with a "
+  "%select{struct|interface|union|class|enum}2 specifier">;
 def err_tag_reference_conflict : Error<
-  "implicit declaration introduced by elaborated type conflicts with "
-  "%select{a declaration|a typedef|a type alias|a template}0 of the same name">;
+  "implicit declaration introduced by elaborated type conflicts with a "
+  "%select{non-struct type|non-class type|non-union type|non-enum "
+  "type|typedef|type alias|template|type alias template|template "
+  "template argument}0 of the same name">;
 def err_dependent_tag_decl : Error<
   "%select{declaration|definition}0 of "
   "%select{struct|interface|union|class|enum}1 in a dependent scope">;
Index: cfe/trunk/test/SemaTemplate/template-id-expr.cpp
===
--- cfe/trunk/test/SemaTemplate/template-id-expr.cpp
+++ cfe/trunk/test/SemaTemplate/template-id-expr.cpp
@@ -100,5 +100,5 @@
 class C {};
 template  class D>  // expected-note{{previous use is here}}
 class E {
-  template class D;  // expected-error {{elaborated type refers to a template template argument}}
+  template class D;  // expected-error {{template template argument 'D' cannot be referenced with a class specifier}}
 };
Index: cfe/trunk/test/SemaCXX/PR8755.cpp
===
--- cfe/trunk/test/SemaCXX/PR8755.cpp
+++ cfe/trunk/test/SemaCXX/PR8755.cpp
@@ -7,7 +7,7 @@
 
 template 
 void f() {
-  class A  ::iterator foo;  // expected-error{{elaborated type refers to a typedef}}
+  class A  ::iterator foo;  // expected-error{{typedef 'iterator' cannot be referenced with a class specifier}}
 }
 
 void g() {
Index: cfe/trunk/test/SemaCXX/using-decl-templates.cpp
===
--- cfe/trunk/test/SemaCXX/using-decl-templates.cpp
+++ cfe/trunk/test/SemaCXX/using-decl-templates.cpp
@@ -90,7 +90,7 @@
   template struct A { };
   template using APtr = A; // expected-note{{previous use is here}}
 
-  template struct APtr; // expected-error{{elaborated type refers to a type alias template}}
+  template struct APtr; // expected-error{{type alias template 'APtr' cannot be referenced with a struct specifier}}
 }
 
 namespace DontDiagnoseInvalidTest {
Index: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp

[PATCH] D27627: Allow target to specify default address space for codegen

2016-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, tstellarAMD, arsenm.
yaxunl added a subscriber: cfe-commits.
Herald added a subscriber: wdng.

By default, if a variable is declared without address space qualifier, clang 
will assume address space 0 in codegen. This is OK for most targets.

However since AMDGPU target has separate address spaces for different memory 
regions, and address space 0 is used for private memory regions. It is desired 
to use address space 4 (so called generic address space) as the default address 
space. This is especially important for supporting address-space-agnostic 
languages e.g. HCC (a variant of C++ which does not have explicit address space 
https://github.com/RadeonOpenCompute/hcc).

This patch introduce a virtual function 
TargetInfo::getDefaultTargetAddressSpace which allows each target to specify 
the default target address space based on language options.


https://reviews.llvm.org/D27627

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets.cpp
  test/CodeGen/default-addr-space.cpp

Index: test/CodeGen/default-addr-space.cpp
===
--- /dev/null
+++ test/CodeGen/default-addr-space.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -O0 -std=c++11 -emit-llvm -o - -triple amdgcn-- %s | FileCheck %s
+
+// CHECK-LABEL: @_Z1fPi(i32 addrspace(4)* %a)
+// CHECK:  %[[a_addr:.*]] = alloca i32 addrspace(4)*
+// CHECK:  %b = alloca i32
+// CHECK:  store i32 addrspace(4)* %a, i32 addrspace(4)** %[[a_addr]]
+// CHECK:  store i32 1, i32* %b
+// CHECK:  %[[r0:.*]] = load i32, i32* %b
+// CHECK:  %[[r1:.*]] = load i32 addrspace(4)*, i32 addrspace(4)** %[[a_addr]]
+// CHECK:  store i32 %[[r0]], i32 addrspace(4)* %[[r1]]
+void f(int* a) {
+  int b = 1;
+  *a = b;
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1978,16 +1978,6 @@
   }
 };
 
-static const unsigned AMDGPUAddrSpaceMap[] = {
-  1,// opencl_global
-  3,// opencl_local
-  2,// opencl_constant
-  4,// opencl_generic
-  1,// cuda_device
-  2,// cuda_constant
-  3 // cuda_shared
-};
-
 // If you edit the description strings, make sure you update
 // getPointerWidthV().
 
@@ -2001,9 +1991,18 @@
   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
 
 class AMDGPUTargetInfo final : public TargetInfo {
+  static const unsigned AddrSpaceMap_[7];
   static const Builtin::Info BuiltinInfo[];
   static const char * const GCCRegNames[];
 
+  enum AddrSpaceKind {
+AS_Private = 0,
+AS_Global = 1,
+AS_Constant = 2,
+AS_Local = 3,
+AS_Generic = 4
+  };
+
   /// \brief The GPU profiles supported by the AMDGPU target.
   enum GPUKind {
 GK_NONE,
@@ -2046,7 +2045,7 @@
 resetDataLayout(getTriple().getArch() == llvm::Triple::amdgcn ?
 DataLayoutStringSI : DataLayoutStringR600);
 
-AddrSpaceMap = 
+AddrSpaceMap = _;
 UseAddrSpaceMapMangling = true;
   }
 
@@ -2232,6 +2231,14 @@
 }
   }
 
+  unsigned getDefaultTargetAddressSpace(LangOptions ) const override {
+// OpenCL sets address space explicitly in AST. The default case (type
+// qualifier containing no address space) represents private address space.
+if (Opts.OpenCL)
+  return AS_Private;
+return AS_Generic;
+  }
+
   LangAS::ID getOpenCLImageAddrSpace() const override {
 return LangAS::opencl_constant;
   }
@@ -2254,6 +2261,16 @@
   }
 };
 
+const unsigned AMDGPUTargetInfo::AddrSpaceMap_[] = {
+AS_Global,   // opencl_global
+AS_Local,// opencl_local
+AS_Constant, // opencl_constant
+AS_Generic,  // opencl_generic
+AS_Global,   // cuda_device
+AS_Constant, // cuda_constant
+AS_Local // cuda_shared
+};
+
 const Builtin::Info AMDGPUTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)\
   { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -9436,6 +9436,12 @@
   return getTargetInfo().getNullPointerValue(AS);
 }
 
+unsigned ASTContext::getTargetAddressSpace(Qualifiers Q) const {
+  return Q.hasAddressSpace()
+ ? getTargetAddressSpace(Q.getAddressSpace())
+ : getTargetInfo().getDefaultTargetAddressSpace(LangOpts);
+}
+
 // Explicitly instantiate this in case a Redeclarable is used from a TU that
 // doesn't include ASTContext.h
 template
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -945,6 +945,10 @@
 return *AddrSpaceMap;
   }
 
+  virtual unsigned getDefaultTargetAddressSpace(LangOptions ) const {
+return 0;
+  }
+
   /// \brief Retrieve the name 

r289258 - Add tests for a couple more DRs.

2016-12-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  9 13:35:45 2016
New Revision: 289258

URL: http://llvm.org/viewvc/llvm-project?rev=289258=rev
Log:
Add tests for a couple more DRs.

Added:
cfe/trunk/test/CXX/drs/dr118.cpp
cfe/trunk/test/CXX/drs/dr158.cpp
Modified:
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/test/CXX/drs/dr0xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr0xx.cpp?rev=289258=289257=289258=diff
==
--- cfe/trunk/test/CXX/drs/dr0xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr0xx.cpp Fri Dec  9 13:35:45 2016
@@ -333,7 +333,7 @@ namespace dr27 { // dr27: yes
   E  = true ? n : n;
 }
 
-// dr28: na
+// dr28: na lib
 
 namespace dr29 { // dr29: 3.4
   void dr29_f0(); // expected-note {{here}}

Added: cfe/trunk/test/CXX/drs/dr118.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr118.cpp?rev=289258=auto
==
--- cfe/trunk/test/CXX/drs/dr118.cpp (added)
+++ cfe/trunk/test/CXX/drs/dr118.cpp Fri Dec  9 13:35:45 2016
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -pedantic-errors 
-emit-llvm -o - | FileCheck %s --implicit-check-not " call "
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -pedantic-errors 
-emit-llvm -o - | FileCheck %s --implicit-check-not " call "
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -pedantic-errors 
-emit-llvm -o - | FileCheck %s --implicit-check-not " call "
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -pedantic-errors 
-emit-llvm -o - | FileCheck %s --implicit-check-not " call "
+
+// dr118: yes
+
+struct S {
+  virtual void f();
+};
+void (S::*pmf)();
+
+// CHECK-LABEL: define {{.*}} @_Z1g
+void g(S *sp) {
+  // CHECK: call void %
+  sp->f();// 1: polymorphic
+  // CHECK: call void @
+  sp->S::f(); // 2: non-polymorphic
+  // CHECK: call void @
+  (sp->S::f)();   // 3: non-polymorphic
+  // CHECK: call void %
+  (sp->*pmf)();   // 4: polymorphic
+  // CHECK: call void %
+  (sp->*::f)(); // 5: polymorphic
+}
+

Added: cfe/trunk/test/CXX/drs/dr158.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr158.cpp?rev=289258=auto
==
--- cfe/trunk/test/CXX/drs/dr158.cpp (added)
+++ cfe/trunk/test/CXX/drs/dr158.cpp Fri Dec  9 13:35:45 2016
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -O3 -disable-llvm-optzns 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -O3 -disable-llvm-optzns 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -O3 -disable-llvm-optzns 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -O3 -disable-llvm-optzns 
-pedantic-errors -emit-llvm -o - | FileCheck %s
+
+// dr158: yes
+
+// CHECK-LABEL: define {{.*}} @_Z1f
+const int *f(const int * const *p, int **q) {
+  // CHECK: load i32**, {{.*}}, !tbaa ![[INTPTR_TBAA:[^,]*]]
+  const int *x = *p;
+  // CHECK: store i32* null, {{.*}}, !tbaa ![[INTPTR_TBAA]]
+  *q = 0;
+  return x;
+}
+
+struct A {};
+
+// CHECK-LABEL: define {{.*}} @_Z1g
+const int *(A::*const *g(const int *(A::* const **p)[3], int 
*(A::***q)[3]))[3] {
+  // CHECK: load i64**, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]]
+  const int *(A::*const *x)[3] = *p;
+  // CHECK: store i64* null, {{.*}}, !tbaa ![[MEMPTR_TBAA]]
+  *q = 0;
+  return x;
+}
+

Modified: cfe/trunk/test/CXX/drs/dr1xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr1xx.cpp?rev=289258=289257=289258=diff
==
--- cfe/trunk/test/CXX/drs/dr1xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr1xx.cpp Fri Dec  9 13:35:45 2016
@@ -35,7 +35,7 @@ namespace dr102 { // dr102: yes
 }
 
 // dr103: na
-// dr104 FIXME: add codegen test
+// dr104: na lib
 // dr105: na
 
 namespace dr106 { // dr106: sup 540
@@ -202,7 +202,7 @@ namespace dr116 { // dr116: yes
 }
 
 // dr117: na
-// dr118 FIXME: add codegen test
+// dr118 is in its own file.
 // dr119: na
 // dr120: na
 
@@ -608,7 +608,7 @@ namespace dr155 { // dr155: dup 632
   struct S { int n; } s = { { 1 } }; // expected-warning {{braces around 
scalar initializer}}
 }
 
-// dr158 FIXME write codegen test
+// dr158 is in its own file.
 
 namespace dr159 { // dr159: 3.5
   namespace X { void f(); }

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=289258=289257=289258=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Fri Dec  9 13:35:45 

[PATCH] D27600: [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna updated this revision to Diff 80925.
zaks.anna added a comment.

Updated "null"-> "Null" as per Devin's suggestion.


https://reviews.llvm.org/D27600

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability-no-arc.mm
  test/Analysis/nullability.mm
  test/Analysis/nullability_nullonly.mm

Index: test/Analysis/nullability_nullonly.mm
===
--- test/Analysis/nullability_nullonly.mm
+++ test/Analysis/nullability_nullonly.mm
@@ -24,7 +24,7 @@
 
 Dummy *_Nonnull testNullReturn() {
   Dummy *p = 0;
-  return p; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return p; // expected-warning {{Null returned from a function that is expected to return a non-null value}}
 }
 
 void onlyReportFirstPreconditionViolationOnPath() {
@@ -100,24 +100,24 @@
 }
 
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{Null is assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}
 }
 
 // Under ARC, returned expressions of ObjC objects types are are implicitly
 // cast to _Nonnull when the functions return type is _Nonnull, so make
 // sure this doesn't implicit cast doesn't suppress a legitimate warning.
 TestObject * _Nonnull returnsNilObjCInstanceIndirectly() {
-  TestObject *local = 0;
-  return local; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  TestObject *local = nil;
+  return local; // expected-warning {{nil returned from a function that is expected to return a non-null value}}
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceIndirectlyWithSupressingCast() {
-  TestObject *local = 0;
+  TestObject *local = nil;
   return (TestObject * _Nonnull)local; // no-warning
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceDirectly() {
-  return nil; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return nil; // expected-warning {{nil returned from a function that is expected to return a non-null value}}
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceDirectlyWithSuppressingCast() {
@@ -130,7 +130,7 @@
 @implementation SomeClass (MethodReturn)
 - (SomeClass * _Nonnull)testReturnsNilInNonnull {
   SomeClass *local = nil;
-  return local; // expected-warning {{Null is returned from a method that is expected to return a non-null value}}
+  return local; // expected-warning {{nil returned from a method that is expected to return a non-null value}}
 }
 
 - (SomeClass * _Nonnull)testReturnsCastSuppressedNilInNonnull {
@@ -154,7 +154,7 @@
 
   NSSystemFunctionTakingNonnull(s);
   #if !NOSYSTEMHEADERS
-  // expected-warning@-2{{Null passed to a callee that requires a non-null 1st parameter}}
+  // expected-warning@-2{{nil passed to a callee that requires a non-null 1st parameter}}
   #endif
 }
 
@@ -165,6 +165,6 @@
   NSSystemClass *sc = [[NSSystemClass alloc] init];
   [sc takesNonnull:s];
   #if !NOSYSTEMHEADERS
-  // expected-warning@-2{{Null passed to a callee that requires a non-null 1st parameter}}
+  // expected-warning@-2{{nil passed to a callee that requires a non-null 1st parameter}}
   #endif
 }
Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -75,7 +75,7 @@
   }
   Dummy a;
   Dummy *_Nonnull nonnull = 
-  nonnull = q; // expected-warning {{Null is assigned to a pointer which is expected to have non-null value}}
+  nonnull = q; // expected-warning {{Null assigned to a pointer which is expected to have non-null value}}
   q = 
   takesNullable(q);
   takesNonnull(q);
@@ -107,7 +107,7 @@
 
 Dummy *_Nonnull testNullReturn() {
   Dummy *p = 0;
-  return p; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return p; // expected-warning {{Null returned from a function that is expected to return a non-null value}}
 }
 
 void testObjCMessageResultNullability() {
@@ -229,7 +229,7 @@
 Dummy * _Nonnull testIndirectCastNilToNonnullAndReturn() {
   Dummy *p = (Dummy * _Nonnull)0;
   // FIXME: Ideally the cast above would suppress this warning.
-  return p; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return p; // expected-warning {{Null returned from a function that is expected to return a non-null value}}
 }
 
 void testInvalidPropagation() {
Index: test/Analysis/nullability-no-arc.mm
===
--- test/Analysis/nullability-no-arc.mm
+++ test/Analysis/nullability-no-arc.mm
@@ -17,20 +17,20 @@
 @interface TestObject : NSObject
 @end
 
-TestObject * 

[PATCH] D27377: clang-format: Support the Java 8 'default' method modifier

2016-12-09 Thread Luis Héctor Chávez via Phabricator via cfe-commits
lhchavez added a comment.

Gentle ping?


https://reviews.llvm.org/D27377



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


[PATCH] D27607: [ubsan] Treat ObjC's BOOL as if its range is always {0, 1}

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:1222
+/// modes, it's safe to treat such a type as 'the builtin bool'.
+static bool isObjCBool(QualType Ty, const SourceManager ,
+   const LangOptions ) {

Could you use the existing method for this? From NSAPI.h:

```
   // \brief Returns true if \param T is a typedef of "BOOL" in objective-c.
   bool isObjCBOOLType(QualType T) const;

```



https://reviews.llvm.org/D27607



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


r289255 - cxx_dr_status: update to latest issue list and add a couple more tests.

2016-12-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  9 13:11:50 2016
New Revision: 289255

URL: http://llvm.org/viewvc/llvm-project?rev=289255=rev
Log:
cxx_dr_status: update to latest issue list and add a couple more tests.

Modified:
cfe/trunk/test/CXX/drs/dr15xx.cpp
cfe/trunk/test/CXX/drs/dr16xx.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/test/CXX/drs/dr15xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr15xx.cpp?rev=289255=289254=289255=diff
==
--- cfe/trunk/test/CXX/drs/dr15xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr15xx.cpp Fri Dec  9 13:11:50 2016
@@ -179,6 +179,45 @@ struct InheritsCtor : BaseCtor { // expe
 };
 InheritsCtor II = {{}, 42}; // expected-error {{no matching constructor}}
 
+namespace std_example {
+  struct A {
+explicit A() = default; // expected-note 2{{declared here}}
+  };
+
+  struct B : A {
+explicit B() = default; // expected-note 2{{declared here}}
+  };
+
+  struct C {
+explicit C(); // expected-note 2{{declared here}}
+  };
+
+  struct D : A {
+C c;
+explicit D() = default; // expected-note 2{{declared here}}
+  };
+
+  template  void f() {
+T t; // ok
+T u{}; // ok
+T v = {}; // expected-error 4{{explicit}}
+  }
+  template  void g() {
+void x(T t); // expected-note 4{{parameter}}
+x({}); // expected-error 4{{explicit}}
+  }
+
+  void test() {
+f(); // expected-note {{instantiation of}}
+f(); // expected-note {{instantiation of}}
+f(); // expected-note {{instantiation of}}
+f(); // expected-note {{instantiation of}}
+g(); // expected-note {{instantiation of}}
+g(); // expected-note {{instantiation of}}
+g(); // expected-note {{instantiation of}}
+g(); // expected-note {{instantiation of}}
+  }
+}
 #endif  // __cplusplus >= 201103L
 }
 

Modified: cfe/trunk/test/CXX/drs/dr16xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr16xx.cpp?rev=289255=289254=289255=diff
==
--- cfe/trunk/test/CXX/drs/dr16xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr16xx.cpp Fri Dec  9 13:11:50 2016
@@ -3,10 +3,6 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
-#if __cplusplus < 201103L
-// expected-no-diagnostics
-#endif
-
 namespace dr1684 { // dr1684: 3.6
 #if __cplusplus >= 201103L
   struct NonLiteral { // expected-note {{because}}
@@ -44,6 +40,35 @@ namespace dr1631 {  // dr1631: 3.7
 #endif
 }
 
+namespace dr1638 { // dr1638: yes
+#if __cplusplus >= 201103L
+  template struct A {
+enum class E; // expected-note {{previous}}
+enum class F : T; // expected-note 2{{previous}}
+  };
+
+  template<> enum class A::E;
+  template<> enum class A::E {};
+  template<> enum class A::F : int;
+  template<> enum class A::F : int {};
+
+  template<> enum class A::E : int;
+  template<> enum class A::E : int {};
+
+  template<> enum class A::F; // expected-error {{different underlying 
type}}
+  template<> enum class A::E : char; // expected-error {{different 
underlying type}}
+  template<> enum class A::F : int; // expected-error {{different 
underlying type}}
+
+  enum class A::E; // expected-error {{template specialization 
requires 'template<>'}} expected-error {{nested name specifier}}
+  template enum class A::E; // expected-error {{enumerations cannot 
be explicitly instantiated}}
+  enum class A::E *e; // expected-error {{must use 'enum' not 'enum 
class'}}
+
+  struct B {
+friend enum class A::E; // expected-error {{must use 'enum' not 
'enum class'}}
+  };
+#endif
+}
+
 namespace dr1645 { // dr1645: 3.9
 #if __cplusplus >= 201103L
   struct A { // expected-note 2{{candidate}}
@@ -60,3 +85,19 @@ namespace dr1645 { // dr1645: 3.9
   constexpr B b(0, 0); // expected-error {{ambiguous}}
 #endif
 }
+
+namespace dr1653 { // dr1653: 4.0 c++17
+  void f(bool b) {
+++b;
+b++;
+#if __cplusplus <= 201402L
+// expected-warning@-3 {{deprecated}} expected-warning@-2 {{deprecated}}
+#else
+// expected-error@-5 {{incrementing expression of type bool}} 
expected-error@-4 {{incrementing expression of type bool}}
+#endif
+--b; // expected-error {{cannot decrement expression of type bool}}
+b--; // expected-error {{cannot decrement expression of type bool}}
+b += 1; // ok
+b -= 1; // ok
+  }
+}

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=289255=289254=289255=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Fri Dec  9 13:11:50 2016
@@ -589,7 +589,7 @@
   
   
 

r289252 - Add support for non-zero null pointer for C and OpenCL

2016-12-09 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Fri Dec  9 13:01:11 2016
New Revision: 289252

URL: http://llvm.org/viewvc/llvm-project?rev=289252=rev
Log:
Add support for non-zero null pointer for C and OpenCL

In amdgcn target, null pointers in global, constant, and generic address space 
take value 0 but null pointers in private and local address space take value 
-1. Currently LLVM assumes all null pointers take value 0, which results in 
incorrectly translated IR. To workaround this issue, instead of emit null 
pointers in local and private address space, a null pointer in generic address 
space is emitted and casted to local and private address space.

Tentative definition of global variables with non-zero initializer will have 
weak linkage instead of common linkage since common linkage requires zero 
initializer and does not have explicit section to hold the non-zero value.

Virtual member functions getNullPointer and performAddrSpaceCast are added to 
TargetCodeGenInfo which by default returns ConstantPointerNull and emitting 
addrspacecast instruction. A virtual member function getNullPointerValue is 
added to TargetInfo which by default returns 0. Each target can override these 
virtual functions to get target specific null pointer and the null pointer 
value for specific address space, and perform specific translations for 
addrspacecast.

Wrapper functions getNullPointer is added to CodegenModule and 
getTargetNullPointerValue is added to ASTContext to facilitate getting the 
target specific null pointers and their values.

This change has no effect on other targets except amdgcn target. Other targets 
can provide support of non-zero null pointer in a similar way.

This change only provides support for non-zero null pointer for C and OpenCL. 
Supporting for other languages will be added later incrementally.

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

Added:
cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/CodeGen/TargetInfo.h

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=289252=289251=289252=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Fri Dec  9 13:01:11 2016
@@ -135,14 +135,15 @@ public:
   }
   APValue(const APValue );
   APValue(APValue &) : Kind(Uninitialized) { swap(RHS); }
-  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned CallIndex)
+  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned CallIndex,
+  bool IsNullPtr = false)
   : Kind(Uninitialized) {
-MakeLValue(); setLValue(B, O, N, CallIndex);
+MakeLValue(); setLValue(B, O, N, CallIndex, IsNullPtr);
   }
   APValue(LValueBase B, const CharUnits , ArrayRef Path,
-  bool OnePastTheEnd, unsigned CallIndex)
+  bool OnePastTheEnd, unsigned CallIndex, bool IsNullPtr = false)
   : Kind(Uninitialized) {
-MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex);
+MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex, IsNullPtr);
   }
   APValue(UninitArray, unsigned InitElts, unsigned Size) : Kind(Uninitialized) 
{
 MakeArray(InitElts, Size);
@@ -254,6 +255,7 @@ public:
   bool hasLValuePath() const;
   ArrayRef getLValuePath() const;
   unsigned getLValueCallIndex() const;
+  bool isNullPointer() const;
 
   APValue (unsigned I) {
 assert(isVector() && "Invalid accessor");
@@ -374,10 +376,10 @@ public:
 ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I);
   }
   void setLValue(LValueBase B, const CharUnits , NoLValuePath,
- unsigned CallIndex);
+ unsigned CallIndex, bool IsNullPtr);
   void setLValue(LValueBase B, const CharUnits ,
  ArrayRef Path, bool OnePastTheEnd,
- unsigned CallIndex);
+ unsigned CallIndex, bool IsNullPtr);
   void setUnion(const FieldDecl *Field, const APValue ) {
 assert(isUnion() && "Invalid accessor");
 ((UnionData*)(char*)Data.buffer)->Field = Field;

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=289252=289251=289252=diff

[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-09 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289252: Add support for non-zero null pointer for C and 
OpenCL (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D26196?vs=80902=80919#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26196

Files:
  cfe/trunk/include/clang/AST/APValue.h
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/APValue.cpp
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
  cfe/trunk/lib/CodeGen/CodeGenTypes.h
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/lib/CodeGen/TargetInfo.h
  cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,534 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
+
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test constant folding of null pointer.
+// A null pointer should be folded to a null pointer in the target address space.
+
+// CHECK: @fold_generic = local_unnamed_addr addrspace(1) global i32 addrspace(4)* null, align 4
+generic int *fold_generic = (global int*)(generic float*)(private char*)0;
+
+// CHECK: @fold_priv = local_unnamed_addr addrspace(1) global i16* addrspacecast (i16 addrspace(4)* null to i16*), align 4
+private short *fold_priv = (private short*)(generic int*)(global void*)0;
+
+// CHECK: @fold_priv_arith = local_unnamed_addr addrspace(1) global i8* inttoptr (i32 9 to i8*), align 4
+private char *fold_priv_arith = (private char*)0 + 10;
+
+// CHECK: @fold_int = local_unnamed_addr addrspace(1) global i32 13, align 4
+int fold_int = (int)(private void*)(generic char*)(global int*)0 + 14;
+
+// CHECK: @fold_int2 = local_unnamed_addr addrspace(1) global i32 12, align 4
+int fold_int2 = (int) ((private void*)0 + 13);
+
+// CHECK: @fold_int3 = local_unnamed_addr addrspace(1) global i32 -1, align 4
+int fold_int3 = (int) ((private int*)0);
+
+// CHECK: @fold_int4 = local_unnamed_addr addrspace(1) global i32 7, align 4
+int fold_int4 = (int) &((private int*)0)[2];
+
+// CHECK: @fold_int5 = local_unnamed_addr addrspace(1) global i32 3, align 4
+int fold_int5 = (int) &((private StructTy1*)0)->p2;
+
+// Test static variable initialization.
+
+// NOOPT: @test_static_var.sp1 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp2 = internal 

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Thanks Artem!

Just to be clear, I think this patch should be committed once 
"inTopLevelNamespace" issue is addressed. That is the only issue pending as far 
as I can see.

The visitor should be a separate patch.


https://reviews.llvm.org/D25660



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


[PATCH] D27603: Propagate -fdiagnostics-color to LLD.

2016-12-09 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: lib/Driver/Tools.cpp:284
+  // propagate -fdiagnostics-color.
+  if (StringRef(TC.GetLinkerPath()).endswith("ld.lld") &&
+  D.getDiags().getShowColors())

rsmith wrote:
> I don't think this will work for `-fuse-ld=$BINDIR/lld` and the like. We also 
> have code around Tools.cpp doing things like this:
> 
> const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
> if (llvm::sys::path::filename(Exec) == "lld") {
> 
> and
> 
> const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
> if (llvm::sys::path::stem(Exec).equals_lower("lld")) {
> 
> so detecting `ld.lld` here seems inconsistent. (Meanwhile, the above checks 
> won't fire for `-fuse-ld=lld`, since that sets the linker path to .../ld.lld.)
> 
> I think it's time to factor out an `isLinkerLLD` function and use that to 
> detect whether we're using lld.
What if a linker is just `/usr/bin/ld`? I want to detect if it's LLD or not, 
but it's not doable without running that command. (If we pass it via the 
environment, we can always set LLD_COLOR_DIAGNOSTICS=1 though.)


https://reviews.llvm.org/D27603



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


r289250 - DR1295 and cleanup for P0135R1: Make our initialization code more directly

2016-12-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Dec  9 12:49:13 2016
New Revision: 289250

URL: http://llvm.org/viewvc/llvm-project?rev=289250=rev
Log:
DR1295 and cleanup for P0135R1: Make our initialization code more directly
mirror the description in the standard. Per DR1295, this means that binding a
const / rvalue reference to a bit-field no longer "binds directly", and per
P0135R1, this means that we materialize a temporary in reference binding
after adjusting cv-qualifiers and before performing a derived-to-base cast.

In C++11 onwards, this should have fixed the last case where we would
materialize a temporary of the wrong type (with a subobject adjustment inside
the MaterializeTemporaryExpr instead of outside), but we still have to deal
with that possibility in C++98, unless we want to start using xvalues to
represent materialized temporaries there too.

Modified:
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp
cfe/trunk/test/CXX/drs/dr12xx.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1z.cpp
cfe/trunk/test/SemaCXX/member-init.cpp
cfe/trunk/test/SemaCXX/microsoft-new-delete.cpp
cfe/trunk/test/SemaCXX/reinterpret-cast.cpp

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=289250=289249=289250=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Fri Dec  9 12:49:13 2016
@@ -668,6 +668,9 @@ public:
 /// temporary object, which is permitted (but not required) by
 /// C++98/03 but not C++0x.
 SK_ExtraneousCopyToTemporary,
+/// \brief Direct-initialization from a reference-related object in the
+/// final stage of class copy-initialization.
+SK_FinalCopy,
 /// \brief Perform a user-defined conversion, either via a conversion
 /// function or via a constructor.
 SK_UserConversion,
@@ -805,6 +808,10 @@ public:
 FK_ReferenceInitOverloadFailed,
 /// \brief Non-const lvalue reference binding to a temporary.
 FK_NonConstLValueReferenceBindingToTemporary,
+/// \brief Non-const lvalue reference binding to a bit-field.
+FK_NonConstLValueReferenceBindingToBitfield,
+/// \brief Non-const lvalue reference binding to a vector element.
+FK_NonConstLValueReferenceBindingToVectorElement,
 /// \brief Non-const lvalue reference binding to an lvalue of unrelated
 /// type.
 FK_NonConstLValueReferenceBindingToUnrelated,
@@ -1028,6 +1035,10 @@ public:
   /// \param T The type of the temporary being created.
   void AddExtraneousCopyToTemporary(QualType T);
 
+  /// \brief Add a new step that makes a copy of the input to an object of
+  /// the given type, as the final step in class copy-initialization.
+  void AddFinalCopy(QualType T);
+
   /// \brief Add a new step invoking a conversion function, which is either
   /// a constructor or a conversion function.
   void AddUserConversionStep(FunctionDecl *Function,

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=289250=289249=289250=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Dec  9 12:49:13 2016
@@ -76,8 +76,8 @@ namespace {
   const Expr *Inner = Temp->skipRValueSubobjectAdjustments(CommaLHSs,
Adjustments);
   // Keep any cv-qualifiers from the reference if we generated a temporary
-  // for it.
-  if (Inner != Temp)
+  // for it directly. Otherwise use the type after adjustment.
+  if (!Adjustments.empty())
 return Inner->getType();
 }
 

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=289250=289249=289250=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Dec  9 12:49:13 2016
@@ -1164,7 +1164,8 @@ CFGBlock *CFGBuilder::addInitializer(CXX
 /// \brief Retrieve the type of the temporary object whose lifetime was 
 /// extended by a local reference with the given initializer.
 static QualType getReferenceInitTemporaryType(ASTContext ,
-  const Expr *Init) {
+  const Expr *Init,
+

[PATCH] D27603: Propagate -fdiagnostics-color to LLD.

2016-12-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Driver/Tools.cpp:284
+  // propagate -fdiagnostics-color.
+  if (StringRef(TC.GetLinkerPath()).endswith("ld.lld") &&
+  D.getDiags().getShowColors())

I don't think this will work for `-fuse-ld=$BINDIR/lld` and the like. We also 
have code around Tools.cpp doing things like this:

const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
if (llvm::sys::path::filename(Exec) == "lld") {

and

const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
if (llvm::sys::path::stem(Exec).equals_lower("lld")) {

so detecting `ld.lld` here seems inconsistent. (Meanwhile, the above checks 
won't fire for `-fuse-ld=lld`, since that sets the linker path to .../ld.lld.)

I think it's time to factor out an `isLinkerLLD` function and use that to 
detect whether we're using lld.


https://reviews.llvm.org/D27603



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


[PATCH] D27603: Propagate -fdiagnostics-color to LLD.

2016-12-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: lib/Driver/Tools.cpp:234
 const ArgList , ArgStringList ,
 const JobAction ) {
   const Driver  = TC.getDriver();

ruiu wrote:
> hans wrote:
> > Yes, this doesn't seem like exactly the right place, but maybe there is no 
> > better one. Perhaps we could add an "addCommonLinkerFlags" function?
> The other way of propagating this is to use an environment variable. Because 
> we have control of both the compiler and the linker, we can make a change to 
> LLD to interpret something like LLD_COLOR_DIAGNOSTICS=1 and set it in Clang.
> 
> The point is that in that way we can still have the exact same command line 
> for bfd/gold/lld. What do you think?
I don't think Clang passes things via the environment to any other tool. I 
think passing a flag is better.


https://reviews.llvm.org/D27603



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added a comment.

In https://reviews.llvm.org/D27621#618379, @JDevlieghere wrote:

> Some small stuff I noticed while reading through the code, I didn't check it 
> in much detail though.


Thanks, fixed it.


https://reviews.llvm.org/D27621



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Firat Kasmis via Phabricator via cfe-commits
firolino updated this revision to Diff 80916.
firolino added a comment.

Addressed comment from JDevlieghere


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = , * long3 = 
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = 
+// CHECK-FIXES: {{^}}long * long3 = 
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+unsigned int uint1 = 0, uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+double darray1[] = {}, darray2[] = {1,	2}, dv1 = 3, dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^}}double dv1 = 3;
+// CHECK-FIXES: {{^}}double dv2;
+
+int notransform[] =   {
+  1,
+  2
+  };
+
+const int cx = 1, cy = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int cx = 1;
+// CHECK-FIXES: {{^}}const int cy = 2;
+
+volatile int vx, vy;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}volatile int vx;
+// CHECK-FIXES: {{^}}volatile int vy;
+
+signed char sc1 = 'h', sc2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}signed char sc1 = 'h';
+// CHECK-FIXES: {{^}}signed char sc2;
+
+long long ll1, ll2, ***ft;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long ll1;
+// CHECK-FIXES: {{^}}long long ll2;
+// CHECK-FIXES: {{^}}long long ***ft;
+
+const char *cstr1 = "str1", *cstr2="str2";
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const char *cstr1 = "str1";
+// CHECK-FIXES: {{^}}const char *cstr2="str2";
+
+const char *literal1 = "clang"		"test" \
+   "one",
+   *literal2 = "empty", literal3[] = "three";
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: declaration statement can be split up into single line declarations 

[PATCH] D27603: Propagate -fdiagnostics-color to LLD.

2016-12-09 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added inline comments.



Comment at: lib/Driver/Tools.cpp:234
 const ArgList , ArgStringList ,
 const JobAction ) {
   const Driver  = TC.getDriver();

hans wrote:
> Yes, this doesn't seem like exactly the right place, but maybe there is no 
> better one. Perhaps we could add an "addCommonLinkerFlags" function?
The other way of propagating this is to use an environment variable. Because we 
have control of both the compiler and the linker, we can make a change to LLD 
to interpret something like LLD_COLOR_DIAGNOSTICS=1 and set it in Clang.

The point is that in that way we can still have the exact same command line for 
bfd/gold/lld. What do you think?


https://reviews.llvm.org/D27603



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


[PATCH] D27612: [libcxx] Fix PR24075, PR23841 - Add scoped_allocator_adaptor::construct(pair<T, U>*, ...) overloads.

2016-12-09 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a reviewer: AlisdairM.
EricWF added a subscriber: AlisdairM.
EricWF added a comment.

Adding @AlisdairM as a reviewer, because nobody knows more about allocators 
than Alisdair.


https://reviews.llvm.org/D27612



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


[PATCH] D27600: [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-09 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Looks like Sema uses "null" not only when referring to literals (see below). 
Also, if we were referring to literals, we would use single quotes, no?

I suggest keeping as is for consistency with the wording that uses nil. I do 
not see much difference between the two cases..

  TestObject * _Nonnull returnsNilObjCInstanceDirectly() {
 // The first warning is from Sema. The second is from the static analyzer.
 return nil; // expected-warning {{null returned from function that 
requires a non-null return value}}
 // expected-warning@-1 {{nil returned from a function that is 
expected to return a non-null value}}
  }




https://reviews.llvm.org/D27600



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

A quick example of how a bug reporter visitor for this checker may look like - 
it needs to be expanded significantly but here's a start.

F2675703: report-11.html  <== example of 
how it looks.

See, for example, `MallocChecker` to understand the rest of the bureaucracy 
around bug reporter visitors.

  PathDiagnosticPiece *IteratorPastEndChecker::IteratorVisitor::VisitNode(
  const ExplodedNode *N, const ExplodedNode *PrevN,
  BugReporterContext , BugReport ) {
if (!TrackedRegion)
  return nullptr;
  
const Stmt *S = PathDiagnosticLocation::getStmt(N);
if (!S)
  return nullptr;
  
const LocationContext *LC = N->getLocationContext();
  
PathDiagnosticLocation L = PathDiagnosticLocation::createBegin(
S, BRC.getSourceManager(), N->getLocationContext());
  
ProgramStateRef State = N->getState(),
PrevState = PrevN->getState();
  
const IteratorPosition *Pos =
   getIteratorPosition(State, TrackedRegion),
   *PrevPos =
   getIteratorPosition(PrevState, TrackedRegion);
  
// Because we're tracking this region, it must be an interesting region.
assert(Pos);
  
if (Pos && !PrevPos) {
  // We didn't know the state of this iterator before, why do we know it 
now?
  // Maybe it was constructed from another iterator (state of which we 
knew).
  // FIXME: Handle more carryover cases.
  if (const auto *CE = dyn_cast(S)) {
if (CE->getConstructor()->isCopyOrMoveConstructor()) {
  if (State->getSVal(CE, LC).getAsRegion() == TrackedRegion) {
if (const MemRegion *FromRegion =
State->getSVal(CE->getArg(0), LC).getAsRegion()) {
  assert(getIteratorPosition(State, FromRegion));
  // Because we traverse the ExplodedGraph from bottom to top,
  // this affects how we handle the events before copying.
  TrackedRegion = FromRegion;
  // FIXME: More sensible text.
  return new PathDiagnosticEventPiece(L, "Iterator state copied");
}
  }
}
  }
  
  // Or maybe it's a brand-new iterator.
  TrackedRegion = nullptr;
  // FIXME: More sensible text.
  return new PathDiagnosticEventPiece(L, "Begin tracking the iterator");
}
return nullptr;
  }


https://reviews.llvm.org/D25660



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:47
+// Single declarations and macros will be ignored
+if (DeclStmt->isSingleDecl() == false &&
+DeclStmt->getLocStart().isMacroID() == false) {

Please run Clang-tidy readability-simplify-boolean-expr. Will be good idea to 
run other readability and modernize checks too.


https://reviews.llvm.org/D27621



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Firat Kasmis via Phabricator via cfe-commits
firolino removed rL LLVM as the repository for this revision.
firolino updated this revision to Diff 80915.
firolino added a comment.

Updated docs/ReleaseNotes.txt


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = , * long3 = 
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = 
+// CHECK-FIXES: {{^}}long * long3 = 
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+unsigned int uint1 = 0, uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+double darray1[] = {}, darray2[] = {1,	2}, dv1 = 3, dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^}}double dv1 = 3;
+// CHECK-FIXES: {{^}}double dv2;
+
+int notransform[] =   {
+  1,
+  2
+  };
+
+const int cx = 1, cy = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int cx = 1;
+// CHECK-FIXES: {{^}}const int cy = 2;
+
+volatile int vx, vy;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}volatile int vx;
+// CHECK-FIXES: {{^}}volatile int vy;
+
+signed char sc1 = 'h', sc2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}signed char sc1 = 'h';
+// CHECK-FIXES: {{^}}signed char sc2;
+
+long long ll1, ll2, ***ft;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long ll1;
+// CHECK-FIXES: {{^}}long long ll2;
+// CHECK-FIXES: {{^}}long long ***ft;
+
+const char *cstr1 = "str1", *cstr2="str2";
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const char *cstr1 = "str1";
+// CHECK-FIXES: {{^}}const char *cstr2="str2";
+
+const char *literal1 = "clang"		"test" \
+   "one",
+   *literal2 = "empty", literal3[] = "three";
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: declaration 

[PATCH] D22296: CodeGen: New vtable group representation: struct of vtable arrays.

2016-12-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

A couple minor suggestions, then LGTM.




Comment at: clang/include/clang/AST/VTableBuilder.h:255
+operator ArrayRef() const { return {data(), size()}; };
+  };
+

Maybe this ought to be in LLVM as OwnedArrayRef?  And the more minimal 
implementation approach would be to inherit from MutableArrayRef and just 
add a destructor and a move constructor.

The implicit conversion to ArrayRef is dangerous, but only in ways that 
ArrayRef is already dangerous.



Comment at: clang/include/clang/AST/VTableBuilder.h:260
+  // the vtable group contains a single vtable, an empty vector here represents
+  // the vector {0}.
+  FixedSizeVector VTableIndices;

Ah.  Yes, that's a reasonable solution.



Comment at: clang/lib/AST/VTableBuilder.cpp:986
+  /// vtable group.
+  SmallVector VTableIndices;
+

Same comment here.  Might as well give this enough capacity for any reasonably 
foreseeable case.



Comment at: clang/lib/CodeGen/CGVTables.cpp:641
+llvm::Type *CodeGenVTables::getVTableType(const VTableLayout ) {
+  SmallVector tys;
+  for (unsigned i = 0, e = layout.getNumVTables(); i != e; ++i) {

While 1 is definitely the most likely size, adding small amounts of extra 
inline capacity to a temporary SmallVector has basically zero cost, and of 
course those cases do happen.  4 sounds reasonable.


https://reviews.llvm.org/D22296



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

Some small stuff I noticed while reading through the code, I didn't check it in 
much detail though.




Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:43
+void OneNamePerDeclarationCheck::check(const MatchFinder::MatchResult ) 
{
+  if (const auto *DeclStmt =
+  Result.Nodes.getNodeAs("declstmt")) {

Early exit would reduce the level of indentation of the whole function. 



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:47
+// Single declarations and macros will be ignored
+if (DeclStmt->isSingleDecl() == false &&
+DeclStmt->getLocStart().isMacroID() == false) {

Same as previous comment. 



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:55
+  getCurrentLineIndent(DeclStmt->getLocStart(), SM);
+  std::string UserWrittenType = getUserWrittenType(DeclStmt, SM);
+

I think this can be const as well.



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:116
+
+std::string Appendee = Lexer::getSourceText(
+CharSourceRange::getTokenRange(

const



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:159
+
+  if (auto FirstVar =
+  llvm::dyn_cast(*FirstVarIt)) {

const auto



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:164
+Type = FirstVar->getType();
+  } else if (auto FirstVar =
+ llvm::dyn_cast(*FirstVarIt)) {

const auto



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:245
+  FileID FID = V.first;
+  unsigned StartOffs = V.second;
+

const



Comment at: clang-tidy/readability/OneNamePerDeclarationCheck.cpp:249
+
+  unsigned LineNo = SM.getLineNumber(FID, StartOffs) - 1;
+  const SrcMgr::ContentCache *Content =

const


Repository:
  rL LLVM

https://reviews.llvm.org/D27621



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


[PATCH] D27622: [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.

2016-12-09 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

[libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove 
an unused variable.

test/support/test_macros.h
For convenience/greppability, add macros for libcxx-specific static_asserts 
about noexceptness.

(Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't 
technically necessary
because they're macros, but I think it's better style to define stuff before 
using it.)

test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
There was a completely unused `TrackedCallable obj;`.

apply() isn't depicted with conditional noexcept in C++17.

test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
Now that we have LIBCPP_ASSERT_NOEXCEPT, use it.


https://reviews.llvm.org/D27622

Files:
  test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
  test/support/test_macros.h

Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -128,23 +128,27 @@
 #define TEST_NORETURN [[noreturn]]
 #endif
 
+#define ASSERT_NOEXCEPT(...) \
+static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept")
+
+#define ASSERT_NOT_NOEXCEPT(...) \
+static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept")
+
 /* Macros for testing libc++ specific behavior and extensions */
 #if defined(_LIBCPP_VERSION)
 #define LIBCPP_ASSERT(...) assert(__VA_ARGS__)
 #define LIBCPP_STATIC_ASSERT(...) static_assert(__VA_ARGS__)
+#define LIBCPP_ASSERT_NOEXCEPT(...) ASSERT_NOEXCEPT(__VA_ARGS__)
+#define LIBCPP_ASSERT_NOT_NOEXCEPT(...) ASSERT_NOT_NOEXCEPT(__VA_ARGS__)
 #define LIBCPP_ONLY(...) __VA_ARGS__
 #else
 #define LIBCPP_ASSERT(...) ((void)0)
 #define LIBCPP_STATIC_ASSERT(...) ((void)0)
+#define LIBCPP_ASSERT_NOEXCEPT(...) ((void)0)
+#define LIBCPP_ASSERT_NOT_NOEXCEPT(...) ((void)0)
 #define LIBCPP_ONLY(...) ((void)0)
 #endif
 
-#define ASSERT_NOEXCEPT(...) \
-static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept")
-
-#define ASSERT_NOT_NOEXCEPT(...) \
-static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept")
-
 namespace test_macros_detail {
 template 
 struct is_same { enum { value = 0};} ;
Index: test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
@@ -175,14 +175,14 @@
 Tuple tup; ((void)tup);
 Tuple const& ctup = tup; ((void)ctup);
 ASSERT_NOT_NOEXCEPT(std::make_from_tuple(ctup));
-LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup;
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup)));
 }
 {
 using Tuple = std::pair;
 Tuple tup; ((void)tup);
 Tuple const& ctup = tup; ((void)ctup);
 ASSERT_NOT_NOEXCEPT(std::make_from_tuple(ctup));
-LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup;
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(std::move(tup)));
 }
 {
 using Tuple = std::tuple;
@@ -192,7 +192,7 @@
 {
 using Tuple = std::tuple;
 Tuple tup; ((void)tup);
-LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(tup)));
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(tup));
 }
 {
 using Tuple = std::array;
@@ -202,7 +202,7 @@
 {
 using Tuple = std::array;
 Tuple tup; ((void)tup);
-LIBCPP_ONLY(ASSERT_NOEXCEPT(std::make_from_tuple(tup)));
+LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple(tup));
 }
 }
 
Index: test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
@@ -166,7 +166,6 @@
 
 void test_call_quals_and_arg_types()
 {
-TrackedCallable obj;
 using Tup = std::tuple;
 const int x = 42;
 unsigned y = 101;
@@ -199,15 +198,15 @@
 // test that the functions noexcept-ness is propagated
 using Tup = std::tuple;
 Tup t;
-ASSERT_NOEXCEPT(std::apply(nec, t));
+LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, t));
 ASSERT_NOT_NOEXCEPT(std::apply(tc, t));
 }
 {
 // test that the noexcept-ness of the argument conversions is checked.
 using Tup = std::tuple;
 Tup t;
 ASSERT_NOT_NOEXCEPT(std::apply(nec, t));
-

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added a comment.

I have agreed with Kirill to continue this. See 
http://lists.llvm.org/pipermail/cfe-dev/2016-October/051270.html
I would suggest to close https://reviews.llvm.org/D25024.


Repository:
  rL LLVM

https://reviews.llvm.org/D27621



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).

This is duplicate of  https://reviews.llvm.org/D25024. Will be goo idea to 
combine code in one. Please note that there are multiple coding guidelines 
which suggest this style.


https://reviews.llvm.org/D27621



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


[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-09 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay.  With that resolved, this LGTM.


https://reviews.llvm.org/D26196



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


r289234 - Relax IRgen check in decl-in-prototype.c to match signext on PPC64

2016-12-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Dec  9 11:56:04 2016
New Revision: 289234

URL: http://llvm.org/viewvc/llvm-project?rev=289234=rev
Log:
Relax IRgen check in decl-in-prototype.c to match signext on PPC64

Modified:
cfe/trunk/test/PCH/decl-in-prototype.c

Modified: cfe/trunk/test/PCH/decl-in-prototype.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/decl-in-prototype.c?rev=289234=289233=289234=diff
==
--- cfe/trunk/test/PCH/decl-in-prototype.c (original)
+++ cfe/trunk/test/PCH/decl-in-prototype.c Fri Dec  9 11:56:04 2016
@@ -8,7 +8,7 @@
 // RUN: %clang_cc1 -emit-pch -o %t %s
 // RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck %s
 
-// CHECK-LABEL: define i32 @main()
+// CHECK-LABEL: define {{.*}}i32 @main()
 // CHECK:   ret i32 1
 
 #ifndef HEADER


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


[PATCH] D27529: Correct Vectorcall Register passing and HVA Behavior

2016-12-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 80913.
erichkeane marked an inline comment as done.
erichkeane added a comment.

Based on the tests, I was able to track down the 2 locations that stopped 
working.  I've updated them appropriately.

It seems though that this Template Decl Instantiation is the ONLY time that the 
attributes aren't just initialized immediately.  This gets me wondering if I 
should just create a pair of functions for it specifically?  It would likely be 
a little bit of re-work on InstatiateAttrs (perhaps separate the implementation 
to take the instantiateTemplateAttrribute 'function' as a parameter), but would 
that be preferential?


https://reviews.llvm.org/D27529

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1858,6 +1858,8 @@
   namespace sema {
 Attr *instantiateTemplateAttribute(const Attr *At, ASTContext , Sema ,
 const MultiLevelTemplateArgumentList );
+Attr *instantiateTemplateAttributeForDecl(const Attr *At, ASTContext , Sema ,
+const MultiLevelTemplateArgumentList );
   }
 }
 
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2352,6 +2352,10 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  MultiLevelTemplateArgumentList TemplateArgLists;
+  TemplateArgLists.addOuterTemplateArguments(Converted);
+  InstantiateAttrsForDecl(TemplateArgLists,
+  ClassTemplate->getTemplatedDecl(), Decl);
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -308,6 +308,26 @@
   Attr.getRange());
 }
 
+void Sema::InstantiateAttrsForDecl(
+const MultiLevelTemplateArgumentList , const Decl *Tmpl,
+Decl *New, LateInstantiatedAttrVec *LateAttrs,
+LocalInstantiationScope *OuterMostScope) {
+  for (const auto *TmplAttr : Tmpl->attrs()) {
+// FIXME: If any of the special case versions from InstantiateAttrs become
+// applicable to template declaration, we'll need to add them here.
+NamedDecl *ND = dyn_cast(New);
+CXXRecordDecl *ThisContext =
+dyn_cast_or_null(ND->getDeclContext());
+CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/ 0,
+   ND && ND->isCXXInstanceMember());
+
+Attr *NewAttr = sema::instantiateTemplateAttributeForDecl(TmplAttr, Context, *this,
+   TemplateArgs);
+if (NewAttr)
+  New->addAttr(NewAttr);
+  }
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList ,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
@@ -945,6 +965,7 @@
 }
   }
 
+  SemaRef.InstantiateAttrsForDecl(TemplateArgs, D, Enum);
   SemaRef.InstantiateAttrs(TemplateArgs, D, Enum);
 
   Enum->setInstantiationOfMemberEnum(D, TSK_ImplicitInstantiation);
@@ -1033,6 +1054,7 @@
 }
 
 if (EnumConst) {
+  SemaRef.InstantiateAttrsForDecl(TemplateArgs, EC, EnumConst);
   SemaRef.InstantiateAttrs(TemplateArgs, EC, EnumConst);
 
   EnumConst->setAccess(Enum->getAccess());
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2452,26 +2452,20 @@
   OS << "#endif  // ATTR_VISITOR_DECLS_ONLY\n";
 }
 
-// Emits code to instantiate dependent attributes on templates.
-void EmitClangAttrTemplateInstantiate(RecordKeeper , raw_ostream ) {
-  emitSourceFileHeader("Template instantiation code for attributes", OS);
-
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-
-  OS << "namespace clang {\n"
- << "namespace sema {\n\n"
- << "Attr *instantiateTemplateAttribute(const Attr *At, ASTContext , "
- << "Sema ,\n"
- << "const MultiLevelTemplateArgumentList ) {\n"
- << "  switch (At->getKind()) {\n";
+void EmitClangAttrTemplateInstantiateHelper(const std::vector ,
+  

[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Firat Kasmis via Phabricator via cfe-commits
firolino added a comment.

I have tested it on the whole llvm/clang/extra source code without any problems.


https://reviews.llvm.org/D27621



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


[PATCH] D25216: Improve error message when referencing a non-tag type with a tag

2016-12-09 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!


https://reviews.llvm.org/D25216



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-09 Thread Firat Kasmis via Phabricator via cfe-commits
firolino created this revision.
firolino added reviewers: alexfh, aaron.ballman, klimek, malcolm.parsons.
firolino added a subscriber: cfe-commits.
Herald added subscribers: JDevlieghere, mgorny.

This check can be used to find declarations, which declare more than one name. 
It helps improving readability and prevents potential bugs caused by inattention
and C/C++ syntax specifics.

In addition, appropriate fix-it hints are provided and all user-intended 
indentation will be preserved. For example:

  {
long ** lint1, lint2 = 0, * lint3, **linn;
  
const int cx = 1, cy = 2;
  
int const CS :: * pp = ::a, CS::* const qq = ::a;
  
decltype(int()) declint1 = 5, declint2 = 3;

typedef int ta, tb;
  }

will be transformed to:

  {
long ** lint1;
long lint2 = 0;
long * lint3;
long **linn;

const int cx = 1;
const int cy = 2;

int const CS :: * pp = ::a;
int const CS::* const qq = ::a;

decltype(int()) declint1 = 5;
decltype(int()) declint2 = 3;

typdef int ta;
typdef int tb;
  }

Only declarations within a compound statement are matched. Meaning, global 
declarations
and function parameters are not matched. Moreover, it does not match on the 
following:

  {
class A { } Object1, Object2;

for(int i = 0, j = 0;;);
  }

This check will be used for:

- CppCoreGuideline ES.10 

- DCL04 


in the future and provide appropriate options for it.


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,132 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = , * long3 = 
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = 
+// CHECK-FIXES: {{^}}long * long3 = 
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+unsigned int uint1 = 0, uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+double darray1[] = {}, darray2[] = {1,	2}, dv1 = 3, dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^}}double dv1 = 3;
+// CHECK-FIXES: {{^}}double dv2;
+
+int notransform[] =   {
+  1,
+  2
+  };
+
+const int cx = 1, cy = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^

[PATCH] D27545: Don't assert when redefining a built-in macro in a PCH, PR29119

2016-12-09 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r289228, thanks!


https://reviews.llvm.org/D27545



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


r289228 - Don't assert when redefining a built-in macro in a PCH, PR29119

2016-12-09 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Dec  9 11:32:52 2016
New Revision: 289228

URL: http://llvm.org/viewvc/llvm-project?rev=289228=rev
Log:
Don't assert when redefining a built-in macro in a PCH, PR29119

PCH files store the macro history for a given macro, and the whole history list
for one identifier is given to the Preprocessor at once via
Preprocessor::setLoadedMacroDirective(). This contained an assert that no macro
history exists yet for that identifier. That's usually true, but it's not true
for builtin macros, which are created in Preprocessor() before flags and pchs
are processed. Luckily, ASTWriter stops writing macro history lists at builtins
(see shouldIgnoreMacro() in ASTWriter.cpp), so the head of the history list was
missing for builtin macros. So make the assert weaker, and splice the history
list to the existing single define for builtins.

https://reviews.llvm.org/D27545

Added:
cfe/trunk/test/PCH/builtin-macro.c
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=289228=289227=289228=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Fri Dec  9 11:32:52 2016
@@ -887,7 +887,8 @@ public:
 return appendDefMacroDirective(II, MI, MI->getDefinitionLoc());
   }
   /// \brief Set a MacroDirective that was loaded from a PCH file.
-  void setLoadedMacroDirective(IdentifierInfo *II, MacroDirective *MD);
+  void setLoadedMacroDirective(IdentifierInfo *II, MacroDirective *ED,
+   MacroDirective *MD);
 
   /// \brief Register an exported macro for a module and identifier.
   ModuleMacro *addModuleMacro(Module *Mod, IdentifierInfo *II, MacroInfo 
*Macro,

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=289228=289227=289228=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Dec  9 11:32:52 2016
@@ -92,12 +92,35 @@ void Preprocessor::appendMacroDirective(
 }
 
 void Preprocessor::setLoadedMacroDirective(IdentifierInfo *II,
+   MacroDirective *ED,
MacroDirective *MD) {
+  // Normally, when a macro is defined, it goes through appendMacroDirective()
+  // above, which chains a macro to previous defines, undefs, etc.
+  // However, in a pch, the whole macro history up to the end of the pch is
+  // stored, so ASTReader goes through this function instead.
+  // However, built-in macros are already registered in the Preprocessor
+  // ctor, and ASTWriter stops writing the macro chain at built-in macros,
+  // so in that case the chain from the pch needs to be spliced to the existing
+  // built-in.
+
   assert(II && MD);
   MacroState  = CurSubmoduleState->Macros[II];
-  assert(!StoredMD.getLatest() &&
- "the macro history was modified before initializing it from a pch");
-  StoredMD = MD;
+
+  if (auto *OldMD = StoredMD.getLatest()) {
+// shouldIgnoreMacro() in ASTWriter also stops at macros from the
+// predefines buffer in module builds. However, in module builds, modules
+// are loaded completely before predefines are processed, so StoredMD
+// will be nullptr for them when they're loaded. StoredMD should only be
+// non-nullptr for builtins read from a pch file.
+assert(OldMD->getMacroInfo()->isBuiltinMacro() &&
+   "only built-ins should have an entry here");
+assert(!OldMD->getPrevious() && "builtin should only have a single entry");
+ED->setPrevious(OldMD);
+StoredMD.setLatest(MD);
+  } else {
+StoredMD = MD;
+  }
+
   // Setup the identifier as having associated macro history.
   II->setHasMacroDefinition(true);
   if (!MD->isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=289228=289227=289228=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Dec  9 11:32:52 2016
@@ -1953,7 +1953,7 @@ void ASTReader::resolvePendingMacro(Iden
   }
 
   if (Latest)
-PP.setLoadedMacroDirective(II, Latest);
+PP.setLoadedMacroDirective(II, Earliest, Latest);
 }
 
 ASTReader::InputFileInfo

Added: cfe/trunk/test/PCH/builtin-macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/builtin-macro.c?rev=289228=auto

[PATCH] D25882: Remove special error recovery for ::(id)

2016-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think the last time we discussed this, we decided that to truly fix this we 
need to audit all calls to PP.EnterToken(Stream) from the parser. They are 
probably broken in token caching mode. I haven't been able to find the time to 
do that. Should we commit this in the meantime, since we think this error 
recovery is questionable and adds unnecessary complexity?


https://reviews.llvm.org/D25882



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


[PATCH] D27501: clang-format-vsix: add command to format document

2016-12-09 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

(NOTE, I forgot to click Submit on the reply to @klimek a couple days ago!)




Comment at: tools/clang-format-vs/ClangFormat/ClangFormat.vsct:76
+
+  Clang Format Document
+

klimek wrote:
> hans wrote:
> > amaiorano wrote:
> > > hans wrote:
> > > > I think File would be better than Document when referring to source 
> > > > code.
> > > > 
> > > > But it seems a little annoying to need two menu alternatives. Could we 
> > > > make the regular "Clang Format" option just format the whole file if 
> > > > there is currently no selection, or would that be confusing?
> > > The reason I chose "Document" is that it mimics the existing 
> > > functionality in Visual Studio:
> > > {F2661117}
> > > 
> > > As you can see, "Ctrl+K, Ctrl+F" is bound to format selection by default; 
> > > which I assumed is the reason "Ctrl+R, Ctrl+F" was used for Clang Format 
> > > (Selection). So along the same lines, I bound "Ctrl + R, Ctrl + D" to 
> > > Clang Format Document.
> > > 
> > > I don't really have a problem with having multiple menu options, although 
> > > we could have both of them underneath a "Clang Format" top menu, with 
> > > "Format Selection" and "Format Document" as sub menu items.
> > > 
> > > As for annoyance in menus, I think most developers would reach for 
> > > keyboard shortcuts in this case anyway. Furthermore, the next feature I 
> > > want to add, building on top of this one, is allowing the user to enable 
> > > "Format on Save", which would make this even easier to use.
> > I see, I didn't realize they call it documents. And if they also have 
> > separate commands for formating selection and formating the whole file, 
> > maybe that makes sense for us too.
> > 
> > Right, I also imagine folks would use this from the keyboard, but there too 
> > it's annoying to have two shortcuts for the same thing. But again, if 
> > that's how it's generally done in VS...
> > 
> > I'd like to hear from Manuel on this patch too, though.
> Clang-format currently formats the current line / statement if there is no 
> selection, and that's how most people I know use it.
> Formatting the whole file by default is not what clang-format is optimized 
> for, and highly disruptive (eclipse does that, and it's annoying).
> I'm more wondering why we need a setting for this at all - isn't 
> ctrl-a,ctrl-k,ctrl-f equivalent to formatting the whole file?
@klimek My own experience, which also seems to match those of others online, is 
that clang-format is a fantastic tool for making sure your code-base follows a 
strict formatting standard. What many people do is install Git pre-stage hooks, 
for instance, to run clang-format across entire source files, to ensure they're 
formatted properly. So even if it's not optimized for that, it works very well 
:)

Using clang-format to format only the current line doesn't guarantee that 
everything will be formatted accordingly. My own experience is that it 
sometimes formats the line differently than if you format the entire document. 
Or perhaps you end up writing a few lines of code, and formatting current line 
doesn't pick up all the lines you've modified. As for ctrl-a,ctrl-r-ctrl-f, the 
problem with it is that you lose your cursor position, as ctrl-a will place it 
at the end of the file.

You also mention that formatting the entire file is "highly disruptive" like in 
eclipse. I'm not sure how eclipse handles that, but so far VS seems to do a 
pretty good job. It manages to maintain breakpoint positions quite well, it 
manages to keep the cursor in the same place, and it manages to keep the 
relative location of the code where the cursor is at visible on screen. I 
suspect part of the reason it works well in VS is because Microsoft made sure 
it worked for their own format document feature (ctrl-k,ctrl-d).

As I mentioned earlier, this is a stepping stone towards adding a feature to 
"format on save", for which I'd like to offer the ability to choose "current 
line/selection" and "document". [[ 
https://github.com/Elders/VSE-FormatDocumentOnSave | Here's an example ]] of an 
extension that offers this feature, but for VS's built-in formatting.


https://reviews.llvm.org/D27501



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


[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2016-12-09 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:95
 def err_drv_force_crash : Error<
-  "failing because environment variable '%0' is set">;
+  "failing because %select{environment variable|option}0 '%1' is set">;
 def err_drv_invalid_mfloat_abi : Error<

Is it worth it? What about `"failing because %1 is set">;`

And then later:

```
Diags.Report(diag::err_drv_force_crash) << "option '-gen-reproducer'";
```


https://reviews.llvm.org/D27604



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


[PATCH] D27545: Don't assert when redefining a built-in macro in a PCH, PR29119

2016-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D27545



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


[PATCH] D27279: Store decls in prototypes on the declarator instead of in the AST

2016-12-09 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289225: Store decls in prototypes on the declarator instead 
of in the AST (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D27279?vs=80827=80910#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27279

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/Misc/ast-dump-decl.c
  cfe/trunk/test/PCH/decl-in-prototype.c
  cfe/trunk/test/Sema/decl-in-prototype.c
  cfe/trunk/test/SemaCXX/type-definition-in-specifier.cpp

Index: cfe/trunk/include/clang/Sema/DeclSpec.h
===
--- cfe/trunk/include/clang/Sema/DeclSpec.h
+++ cfe/trunk/include/clang/Sema/DeclSpec.h
@@ -1248,9 +1248,10 @@
 /// declarator.
 unsigned NumParams;
 
-/// NumExceptions - This is the number of types in the dynamic-exception-
-/// decl, if the function has one.
-unsigned NumExceptions;
+/// NumExceptionsOrDecls - This is the number of types in the
+/// dynamic-exception-decl, if the function has one. In C, this is the
+/// number of declarations in the function prototype.
+unsigned NumExceptionsOrDecls;
 
 /// \brief The location of the ref-qualifier, if any.
 ///
@@ -1300,6 +1301,11 @@
   /// \brief Pointer to the cached tokens for an exception-specification
   /// that has not yet been parsed.
   CachedTokens *ExceptionSpecTokens;
+
+  /// Pointer to a new[]'d array of declarations that need to be available
+  /// for lookup inside the function body, if one exists. Does not exist in
+  /// C++.
+  NamedDecl **DeclsInPrototype;
 };
 
 /// \brief If HasTrailingReturnType is true, this is the trailing return
@@ -1322,10 +1328,20 @@
 void destroy() {
   if (DeleteParams)
 delete[] Params;
-  if (getExceptionSpecType() == EST_Dynamic)
+  switch (getExceptionSpecType()) {
+  default:
+break;
+  case EST_Dynamic:
 delete[] Exceptions;
-  else if (getExceptionSpecType() == EST_Unparsed)
+break;
+  case EST_Unparsed:
 delete ExceptionSpecTokens;
+break;
+  case EST_None:
+if (NumExceptionsOrDecls != 0)
+  delete[] DeclsInPrototype;
+break;
+  }
 }
 
 /// isKNRPrototype - Return true if this is a K style identifier list,
@@ -1395,6 +1411,19 @@
   return static_cast(ExceptionSpecType);
 }
 
+/// \brief Get the number of dynamic exception specifications.
+unsigned getNumExceptions() const {
+  assert(ExceptionSpecType != EST_None);
+  return NumExceptionsOrDecls;
+}
+
+/// \brief Get the non-parameter decls defined within this function
+/// prototype. Typically these are tag declarations.
+ArrayRef getDeclsInPrototype() const {
+  assert(ExceptionSpecType == EST_None);
+  return llvm::makeArrayRef(DeclsInPrototype, NumExceptionsOrDecls);
+}
+
 /// \brief Determine whether this function declarator had a
 /// trailing-return-type.
 bool hasTrailingReturnType() const { return HasTrailingReturnType; }
@@ -1540,6 +1569,7 @@
  unsigned NumExceptions,
  Expr *NoexceptExpr,
  CachedTokens *ExceptionSpecTokens,
+ ArrayRef DeclsInPrototype,
  SourceLocation LocalRangeBegin,
  SourceLocation LocalRangeEnd,
  Declarator ,
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1527,12 +1527,6 @@
 NamedDecl *Previous;
   };
 
-  /// List of decls defined in a function prototype. This contains EnumConstants
-  /// that incorrectly end up in translation unit scope because there is no
-  /// function to pin them on. ActOnFunctionDeclarator reads this list and patches
-  /// them into the FunctionDecl.
-  std::vector DeclsInPrototypeScope;
-
   DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr);
 
   void DiagnoseUseOfUnimplementedSelectors();
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -1601,11 +1601,6 @@
   /// no formals.
   ParmVarDecl **ParamInfo;
 
-  /// 

r289225 - Store decls in prototypes on the declarator instead of in the AST

2016-12-09 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Dec  9 11:14:05 2016
New Revision: 289225

URL: http://llvm.org/viewvc/llvm-project?rev=289225=rev
Log:
Store decls in prototypes on the declarator instead of in the AST

This saves two pointers from FunctionDecl that were being used for some
rare and questionable C-only functionality.  The DeclsInPrototypeScope
ArrayRef was added in r151712 in order to parse this kind of C code:

enum e {x, y};
int f(enum {y, x} n) {
 return x; // should return 1, not 0
}

The challenge is that we parse 'int f(enum {y, x} n)' it its own
function prototype scope that gets popped before we build the
FunctionDecl for 'f'. The original change was doing two questionable
things:

1. Saving all tag decls introduced in prototype scope on a TU-global
Sema variable. This is problematic when you have cases like this, where
'x' and 'y' shouldn't be visible in 'f':
void f(void (*fp)(enum { x, y } e)) { /* no x */ }
This patch fixes that, so now 'f' can't see 'x', which is consistent
with GCC.

2. Storing the decls in FunctionDecl in ActOnFunctionDeclarator so that
they could be used in ActOnStartOfFunctionDef. This is just an
inefficient way to move information around. The AST lives forever, but
the list of non-parameter decls in prototype scope is short lived.

Moving these things to the Declarator solves both of these issues.

Reviewers: rsmith

Subscribers: jmolloy, cfe-commits

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

Added:
cfe/trunk/test/PCH/decl-in-prototype.c
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Misc/ast-dump-decl.c
cfe/trunk/test/Sema/decl-in-prototype.c
cfe/trunk/test/SemaCXX/type-definition-in-specifier.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=289225=289224=289225=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Dec  9 11:14:05 2016
@@ -1601,11 +1601,6 @@ private:
   /// no formals.
   ParmVarDecl **ParamInfo;
 
-  /// DeclsInPrototypeScope - Array of pointers to NamedDecls for
-  /// decls defined in the function prototype that are not parameters. E.g.
-  /// 'enum Y' in 'void f(enum Y {AA} x) {}'.
-  ArrayRef DeclsInPrototypeScope;
-
   LazyDeclStmtPtr Body;
 
   // FIXME: This can be packed into the bitfields in DeclContext.
@@ -2050,11 +2045,6 @@ public:
 setParams(getASTContext(), NewParamInfo);
   }
 
-  ArrayRef getDeclsInPrototypeScope() const {
-return DeclsInPrototypeScope;
-  }
-  void setDeclsInPrototypeScope(ArrayRef NewDecls);
-
   /// getMinRequiredArguments - Returns the minimum number of arguments
   /// needed to call this function. This may be fewer than the number of
   /// function parameters, if some of the parameters have default

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=289225=289224=289225=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Fri Dec  9 11:14:05 2016
@@ -1248,9 +1248,10 @@ struct DeclaratorChunk {
 /// declarator.
 unsigned NumParams;
 
-/// NumExceptions - This is the number of types in the dynamic-exception-
-/// decl, if the function has one.
-unsigned NumExceptions;
+/// NumExceptionsOrDecls - This is the number of types in the
+/// dynamic-exception-decl, if the function has one. In C, this is the
+/// number of declarations in the function prototype.
+unsigned NumExceptionsOrDecls;
 
 /// \brief The location of the ref-qualifier, if any.
 ///
@@ -1300,6 +1301,11 @@ struct DeclaratorChunk {
   /// \brief Pointer to the cached tokens for an exception-specification
   /// that has not yet been parsed.
   CachedTokens *ExceptionSpecTokens;
+
+  /// Pointer to a new[]'d array of declarations that need to be available
+  /// for lookup inside the function body, if one exists. Does not exist in
+  /// C++.
+  NamedDecl **DeclsInPrototype;
 };
 
 /// \brief If HasTrailingReturnType is true, this is the trailing return
@@ -1322,10 +1328,20 @@ struct DeclaratorChunk {
 void destroy() {
   if (DeleteParams)
 delete[] Params;
-  if (getExceptionSpecType() == EST_Dynamic)
+  switch (getExceptionSpecType()) {
+  default:
+   

[PATCH] D27486: Correct class-template deprecation behavior

2016-12-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 80907.
erichkeane added a comment.

I've been trying to do what @rsmith suggested, so this is a WIP checkpoint, I 
was hoping you could take a look and tell me if I'm on the right track.  I 
beleive I'm very nearly done, and all but 1 of the tests pass, which if you 
have spare cycles and could suggest something, I would much appreciate it.  
Currently:

template struct C { 
enum [[deprecated]] Enum {c0;}};

void foo() {
CEnum x; // Used to warn, no longer does
x = C::c0; // Used to warn, no longer does
}


https://reviews.llvm.org/D27486

Files:
  include/clang/Basic/Attr.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1858,6 +1858,8 @@
   namespace sema {
 Attr *instantiateTemplateAttribute(const Attr *At, ASTContext , Sema ,
 const MultiLevelTemplateArgumentList );
+Attr *instantiateTemplateAttributeForDecl(const Attr *At, ASTContext , Sema ,
+const MultiLevelTemplateArgumentList );
   }
 }
 
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -2352,6 +2352,10 @@
 ClassTemplate->getLocation(),
  ClassTemplate,
  Converted, nullptr);
+  MultiLevelTemplateArgumentList TemplateArgLists;
+  TemplateArgLists.addOuterTemplateArguments(Converted);
+  InstantiateAttrsForDecl(TemplateArgLists,
+  ClassTemplate->getTemplatedDecl(), Decl);
   ClassTemplate->AddSpecialization(Decl, InsertPos);
   if (ClassTemplate->isOutOfLine())
 Decl->setLexicalDeclContext(ClassTemplate->getLexicalDeclContext());
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -308,6 +308,26 @@
   Attr.getRange());
 }
 
+void Sema::InstantiateAttrsForDecl(
+const MultiLevelTemplateArgumentList , const Decl *Tmpl,
+Decl *New, LateInstantiatedAttrVec *LateAttrs,
+LocalInstantiationScope *OuterMostScope) {
+  for (const auto *TmplAttr : Tmpl->attrs()) {
+// FIXME: If any of the special case versions from InstantiateAttrs become
+// applicable to template declaration, we'll need to add them here.
+NamedDecl *ND = dyn_cast(New);
+CXXRecordDecl *ThisContext =
+dyn_cast_or_null(ND->getDeclContext());
+CXXThisScopeRAII ThisScope(*this, ThisContext, /*TypeQuals*/ 0,
+   ND && ND->isCXXInstanceMember());
+
+Attr *NewAttr = sema::instantiateTemplateAttributeForDecl(TmplAttr, Context, *this,
+   TemplateArgs);
+if (NewAttr)
+  New->addAttr(NewAttr);
+  }
+}
+
 void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList ,
 const Decl *Tmpl, Decl *New,
 LateInstantiatedAttrVec *LateAttrs,
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -2452,26 +2452,20 @@
   OS << "#endif  // ATTR_VISITOR_DECLS_ONLY\n";
 }
 
-// Emits code to instantiate dependent attributes on templates.
-void EmitClangAttrTemplateInstantiate(RecordKeeper , raw_ostream ) {
-  emitSourceFileHeader("Template instantiation code for attributes", OS);
-
-  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
-
-  OS << "namespace clang {\n"
- << "namespace sema {\n\n"
- << "Attr *instantiateTemplateAttribute(const Attr *At, ASTContext , "
- << "Sema ,\n"
- << "const MultiLevelTemplateArgumentList ) {\n"
- << "  switch (At->getKind()) {\n";
+void EmitClangAttrTemplateInstantiateHelper(const std::vector ,
+raw_ostream , bool DeclTime) {
+ OS << "  switch (At->getKind()) {\n";
 
   for (const auto *Attr : Attrs) {
 const Record  = *Attr;
 if (!R.getValueAsBit("ASTNode"))
   continue;
 
 OS << "case attr::" << R.getName() << ": {\n";
-bool ShouldClone = R.getValueAsBit("Clone");
+
+bool ShouldClone =
+R.getValueAsBit("Clone") &&
+R.getValueAsBit("AppliesToTemplateDeclaration") == DeclTime;
 
 if (!ShouldClone) {
   OS << "  return nullptr;\n";
@@ -2508,8 +2502,27 

[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-09 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

`CLOCK_MONOTONIC_RAW` however seems to meet the requirements..


https://reviews.llvm.org/D27429



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


[PATCH] D27429: [Chrono][Darwin] On Darwin use CLOCK_UPTIME_RAW instead of CLOCK_MONOTONIC

2016-12-09 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I agree with @EricWF .   If `CLOCK_UPTIME_RAW` doesn't meet the requirements of 
`steady_clock`  (i.e, monotonically increasing, and advances in real time), 
then we can't use it.


https://reviews.llvm.org/D27429



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


[PATCH] D27600: [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I think in the 'null' case it might be better to keep it as "Null passed" or 
even "Null value passed". This is different than the 'nil' case because the 
diagnostic is not referring to a literal.


https://reviews.llvm.org/D27600



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


[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp:44
+   BugReporter ) const {
+  if (D->isReadOnly() || D->getSetterKind() != ObjCPropertyDecl::Copy)
+return;

It is probably worth adding a test that the checker still issues a diagnostic 
when a readonly property in the primary interface is 'shadowed' by a readwrite 
property in a class extension. This is a very common idiom which lets the 
programmer expose the property as readonly in public but readwrite in private.


https://reviews.llvm.org/D27535



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


  1   2   >