[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 95082.
NoQ added a comment.

Remove accidentally added braces in unrelated code.


https://reviews.llvm.org/D31982

Files:
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/Store.cpp
  test/Analysis/explain-svals.cpp
  test/Analysis/inlining/inline-defensive-checks.c
  test/Analysis/inlining/inline-defensive-checks.cpp
  test/Analysis/uninit-const.cpp

Index: test/Analysis/uninit-const.cpp
===
--- test/Analysis/uninit-const.cpp
+++ test/Analysis/uninit-const.cpp
@@ -122,7 +122,7 @@
 }
 
 void f_uninit(void) {
-  int x;
+  int x;   // expected-note {{'x' declared without an initial value}}
   doStuff_uninit(&x);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: test/Analysis/inlining/inline-defensive-checks.cpp
===
--- test/Analysis/inlining/inline-defensive-checks.cpp
+++ test/Analysis/inlining/inline-defensive-checks.cpp
@@ -70,4 +70,17 @@
 void test(int *p1, int *p2) {
   idc(p1);
 	Foo f(p1);
-}
\ No newline at end of file
+}
+
+struct Bar {
+  int x;
+};
+void idcBar(Bar *b) {
+  if (b)
+;
+}
+void testRefToField(Bar *b) {
+  idcBar(b);
+  int &x = b->x; // no-warning
+  x = 5;
+}
Index: test/Analysis/inlining/inline-defensive-checks.c
===
--- test/Analysis/inlining/inline-defensive-checks.c
+++ test/Analysis/inlining/inline-defensive-checks.c
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s
 
 // Perform inline defensive checks.
-void idc(int *p) {
+void idc(void *p) {
 	if (p)
 		;
 }
@@ -139,3 +139,42 @@
   int z = y;
   idcTriggerZeroValueThroughCall(z);
 }
+
+struct S {
+  int f1;
+  int f2;
+};
+
+void idcTrackZeroValueThroughUnaryPointerOperators(struct S *s) {
+  idc(s);
+  *(&(s->f1)) = 7; // no-warning
+}
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithOffset1(struct S *s) {
+  idc(s);
+  int *x = &(s->f2);
+  *x = 7; // no-warning
+}
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithOffset2(struct S *s) {
+  idc(s);
+  int *x = &(s->f2) - 1;
+  // FIXME: Should not warn.
+  *x = 7; // expected-warning{{Dereference of null pointer}}
+}
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithAssignment(struct S *s) {
+  idc(s);
+  int *x = &(s->f1);
+  *x = 7; // no-warning
+}
+
+
+struct S2 {
+  int a[1];
+};
+
+void idcTrackZeroValueThroughUnaryPointerOperatorsWithArrayField(struct S2 *s) {
+  idc(s);
+  *(&(s->a[0])) = 7; // no-warning
+}
Index: test/Analysis/explain-svals.cpp
===
--- test/Analysis/explain-svals.cpp
+++ test/Analysis/explain-svals.cpp
@@ -81,9 +81,10 @@
 
 namespace {
 class C {
+public:
   int x[10];
+  int y;
 
-public:
   void test_5(int i) {
 clang_analyzer_explain(this); // expected-warning-re^pointer to 'this' object$
 clang_analyzer_explain(&x[i]); // expected-warning-re^pointer to element of type 'int' with index 'argument 'i'' of field 'x' of 'this' object$
@@ -96,3 +97,9 @@
   clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of temporary object constructed at statement 'conjure_S\(\)'$
   clang_analyzer_explain(conjure_S().z); // expected-warning-re^value derived from \(symbol of type 'struct S' conjured at statement 'conjure_S\(\)'\) for field 'z' of temporary object constructed at statement 'conjure_S\(\)'$
 }
+
+void test_7() {
+  C *c = 0;
+  // FIXME: we need to be explaining '40' rather than '0' here; not explainer bug.
+  clang_analyzer_explain(&c->y); // expected-warning-re^concrete memory address '0'$
+}
Index: lib/StaticAnalyzer/Core/Store.cpp
===
--- lib/StaticAnalyzer/Core/Store.cpp
+++ lib/StaticAnalyzer/Core/Store.cpp
@@ -406,6 +406,10 @@
 // FIXME: What we should return is the field offset.  For example,
 //  add the field offset to the integer value.  That way funny things
 //  like this work properly:  &(((struct foo *) 0xa)->f)
+//  However, that's not easy to fix without reducing our abilities
+//  to catch null pointer dereference. Eg., ((struct foo *)0x0)->f = 7
+//  is a null dereference even though we're dereferencing offset of f
+//  rather than null.
 return Base;
 
   default:
Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -961,6 +961,28 @@
   const Expr *Inner = nullptr;
   if (co

r300178 - [analyzer] Simplify values in binary operations a bit more aggressively.

2017-04-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Apr 13 02:20:04 2017
New Revision: 300178

URL: http://llvm.org/viewvc/llvm-project?rev=300178&view=rev
Log:
[analyzer] Simplify values in binary operations a bit more aggressively.

SValBuilder tries to constant-fold symbols in the left-hand side of the symbolic
expression whenever it fails to evaluate the expression directly. However, it
only constant-folds them when they are atomic expressions, not when they are
complicated expressions themselves. This patch adds recursive constant-folding
to the left-hand side subexpression (there's a lack of symmetry because we're
trying to have symbols on the left and constants on the right). As an example,
we'd now be able to handle operations similar to "$x + 1 < $y", when $x is
constrained to a constant.

rdar://problem/31354676

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/additive-folding.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=300178&r1=300177&r2=300178&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Thu 
Apr 13 02:20:04 2017
@@ -112,6 +112,11 @@ public:
   /// Evaluates a given SVal. If the SVal has only one possible (integer) 
value,
   /// that value is returned. Otherwise, returns NULL.
   virtual const llvm::APSInt *getKnownValue(ProgramStateRef state, SVal val) = 
0;
+
+  /// Simplify symbolic expressions within a given SVal. Return an SVal
+  /// that represents the same value, but is hopefully easier to work with
+  /// than the original SVal.
+  virtual SVal simplifySVal(ProgramStateRef State, SVal Val) = 0;
   
   /// Constructs a symbolic expression for two non-location values.
   SVal makeSymExprValNN(ProgramStateRef state, BinaryOperator::Opcode op,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=300178&r1=300177&r2=300178&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Thu Apr 13 02:20:04 
2017
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 
 using namespace clang;
 using namespace ento;
@@ -44,6 +45,10 @@ public:
   ///  (integer) value, that value is returned. Otherwise, returns NULL.
   const llvm::APSInt *getKnownValue(ProgramStateRef state, SVal V) override;
 
+  /// Recursively descends into symbolic expressions and replaces symbols
+  /// with their known values (in the sense of the getKnownValue() method).
+  SVal simplifySVal(ProgramStateRef State, SVal V) override;
+
   SVal MakeSymIntVal(const SymExpr *LHS, BinaryOperator::Opcode op,
  const llvm::APSInt &RHS, QualType resultTy);
 };
@@ -537,11 +542,12 @@ SVal SimpleSValBuilder::evalBinOpNN(Prog
   // Does the symbolic expression simplify to a constant?
   // If so, "fold" the constant by setting 'lhs' to a ConcreteInt
   // and try again.
-  ConstraintManager &CMgr = state->getConstraintManager();
-  if (const llvm::APSInt *Constant = CMgr.getSymVal(state, Sym)) {
-lhs = nonloc::ConcreteInt(*Constant);
-continue;
-  }
+  SVal simplifiedLhs = simplifySVal(state, lhs);
+  if (simplifiedLhs != lhs)
+if (auto simplifiedLhsAsNonLoc = simplifiedLhs.getAs()) {
+  lhs = *simplifiedLhsAsNonLoc;
+  continue;
+}
 
   // Is the RHS a constant?
   if (const llvm::APSInt *RHSValue = getKnownValue(state, rhs))
@@ -993,3 +999,74 @@ const llvm::APSInt *SimpleSValBuilder::g
   // FIXME: Add support for SymExprs.
   return nullptr;
 }
+
+SVal SimpleSValBuilder::simplifySVal(ProgramStateRef State, SVal V) {
+  // For now, this function tries to constant-fold symbols inside a
+  // nonloc::SymbolVal, and does nothing else. More simplifications should
+  // be possible, such as constant-folding an index in an ElementRegion.
+
+  class Simplifier : public FullSValVisitor {
+ProgramStateRef State;
+SValBuilder &SVB;
+
+  public:
+Simplifier(ProgramStateRef State)
+: State(State), SVB(State->getStateManager().getSValBuilder()) {}
+
+SVal VisitSymbolData(const SymbolData *S) {
+  if (co

[PATCH] D31886: [analyzer] Simplify values in binary operations more aggressively

2017-04-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300178: [analyzer] Simplify values in binary operations a 
bit more aggressively. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D31886?vs=94955&id=95084#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31886

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/additive-folding.cpp

Index: cfe/trunk/test/Analysis/additive-folding.cpp
===
--- cfe/trunk/test/Analysis/additive-folding.cpp
+++ cfe/trunk/test/Analysis/additive-folding.cpp
@@ -205,3 +205,12 @@
 
   clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}}
 }
+
+void additiveSymSymFolding(int x, int y) {
+  // We should simplify 'x - 1' to '0' and handle the comparison,
+  // despite both sides being complicated symbols.
+  int z = x - 1;
+  if (x == 1)
+if (y >= 0)
+  clang_analyzer_eval(z <= y); // expected-warning{{TRUE}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -14,6 +14,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValVisitor.h"
 
 using namespace clang;
 using namespace ento;
@@ -44,6 +45,10 @@
   ///  (integer) value, that value is returned. Otherwise, returns NULL.
   const llvm::APSInt *getKnownValue(ProgramStateRef state, SVal V) override;
 
+  /// Recursively descends into symbolic expressions and replaces symbols
+  /// with their known values (in the sense of the getKnownValue() method).
+  SVal simplifySVal(ProgramStateRef State, SVal V) override;
+
   SVal MakeSymIntVal(const SymExpr *LHS, BinaryOperator::Opcode op,
  const llvm::APSInt &RHS, QualType resultTy);
 };
@@ -537,11 +542,12 @@
   // Does the symbolic expression simplify to a constant?
   // If so, "fold" the constant by setting 'lhs' to a ConcreteInt
   // and try again.
-  ConstraintManager &CMgr = state->getConstraintManager();
-  if (const llvm::APSInt *Constant = CMgr.getSymVal(state, Sym)) {
-lhs = nonloc::ConcreteInt(*Constant);
-continue;
-  }
+  SVal simplifiedLhs = simplifySVal(state, lhs);
+  if (simplifiedLhs != lhs)
+if (auto simplifiedLhsAsNonLoc = simplifiedLhs.getAs()) {
+  lhs = *simplifiedLhsAsNonLoc;
+  continue;
+}
 
   // Is the RHS a constant?
   if (const llvm::APSInt *RHSValue = getKnownValue(state, rhs))
@@ -993,3 +999,74 @@
   // FIXME: Add support for SymExprs.
   return nullptr;
 }
+
+SVal SimpleSValBuilder::simplifySVal(ProgramStateRef State, SVal V) {
+  // For now, this function tries to constant-fold symbols inside a
+  // nonloc::SymbolVal, and does nothing else. More simplifications should
+  // be possible, such as constant-folding an index in an ElementRegion.
+
+  class Simplifier : public FullSValVisitor {
+ProgramStateRef State;
+SValBuilder &SVB;
+
+  public:
+Simplifier(ProgramStateRef State)
+: State(State), SVB(State->getStateManager().getSValBuilder()) {}
+
+SVal VisitSymbolData(const SymbolData *S) {
+  if (const llvm::APSInt *I =
+  SVB.getKnownValue(State, nonloc::SymbolVal(S)))
+return Loc::isLocType(S->getType()) ? (SVal)SVB.makeIntLocVal(*I)
+: (SVal)SVB.makeIntVal(*I);
+  return nonloc::SymbolVal(S);
+}
+
+// TODO: Support SymbolCast. Support IntSymExpr when/if we actually
+// start producing them.
+
+SVal VisitSymIntExpr(const SymIntExpr *S) {
+  SVal LHS = Visit(S->getLHS());
+  SVal RHS;
+  // By looking at the APSInt in the right-hand side of S, we cannot
+  // figure out if it should be treated as a Loc or as a NonLoc.
+  // So make our guess by recalling that we cannot multiply pointers
+  // or compare a pointer to an integer.
+  if (Loc::isLocType(S->getLHS()->getType()) &&
+  BinaryOperator::isComparisonOp(S->getOpcode())) {
+// The usual conversion of $sym to &SymRegion{$sym}, as they have
+// the same meaning for Loc-type symbols, but the latter form
+// is preferred in SVal computations for being Loc itself.
+if (SymbolRef Sym = LHS.getAsSymbol()) {
+  assert(Loc::isLocType(Sym->getType()));
+  LHS = SVB.makeLoc(Sym);
+}
+RHS = SVB.makeIntLocVal(S->getRHS());
+  } else {
+RHS = SVB.makeIntVal(S->getRHS());
+  }
+  return SVB.evalBinOp(State, S->getOp

[PATCH] D31167: Use FPContractModeKind universally

2017-04-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

I believe considering the goal of moving to using per-instruction FMF and kills 
the global backend option, this leads to a bitcode upgrade issue: OpenCL (or 
other) bitcode that were generated bitcode don't have the right FMF and will be 
upgraded conservatively.
Performance regression when upgrading bitcode are to be expected in general, so 
it is not a bug.
To recover, an option for an OpenCL backend would be to add a pass that set the 
expected FMF everywhere after bitcode upgrade.


Repository:
  rL LLVM

https://reviews.llvm.org/D31167



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


Re: r300122 - [clang-cl] Make all sanitizer flags available in clang-cl

2017-04-13 Thread Akira Hatanaka via cfe-commits
I’m afraid I have to revert this to turn the bots green again.

> On Apr 12, 2017, at 10:41 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> I think this broke some of the bots.
> 
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/30152/ 
> 
> 
> Could you take a look?
>  
>> On Apr 12, 2017, at 3:50 PM, Reid Kleckner via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> Author: rnk
>> Date: Wed Apr 12 17:50:51 2017
>> New Revision: 300122
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=300122&view=rev 
>> 
>> Log:
>> [clang-cl] Make all sanitizer flags available in clang-cl
>> 
>> Summary:
>> Use a tablegen let {} block so that new sanitizer flags are available by
>> default in all driver modes. This should cut down on time wasted with
>> bugs like http://crbug.com/710928 .
>> 
>> Reviewers: vitalybuka, hans
>> 
>> Subscribers: kcc, llvm-commits
>> 
>> Differential Revision: https://reviews.llvm.org/D31988 
>> 
>> 
>> Modified:
>>cfe/trunk/include/clang/Driver/Options.td
>>cfe/trunk/test/Driver/fsanitize.c
>> 
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300122&r1=300121&r2=300122&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 17:50:51 2017
>> @@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fn
>> def fjump_tables : Flag<["-"], "fjump-tables">, Group;
>> def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
>> Flags<[CC1Option]>,
>>   HelpText<"Do not use jump tables for lowering switches">;
>> +
>> +// Begin sanitizer flags. These should all be core options exposed in all 
>> driver
>> +// modes.
>> +let Flags = [CC1Option, CoreOption] in {
>> +
>> def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
>> -   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
>> +   MetaVarName<"">,
>>HelpText<"Turn on runtime checks for various forms of 
>> undefined "
>> "or suspicious behavior. See user manual for 
>> available checks">;
>> def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
>> Group,
>> -  Flags<[CoreOption]>;
>> +  Flags<[CoreOption, DriverOption]>;
>> def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
>> -  Group, Flags<[CC1Option, 
>> CoreOption]>,
>> +  Group,
>>   HelpText<"Path to blacklist file for sanitizers">;
>> def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
>>  Group,
>>  HelpText<"Don't use blacklist file for 
>> sanitizers">;
>> def fsanitize_coverage
>> : CommaJoined<["-"], "fsanitize-coverage=">,
>> -  Group, Flags<[CoreOption]>,
>> +  Group,
>>   HelpText<"Specify the type of coverage instrumentation for 
>> Sanitizers">;
>> def fno_sanitize_coverage
>> : CommaJoined<["-"], "fno-sanitize-coverage=">,
>> -  Group, Flags<[CoreOption]>,
>> +  Group, Flags<[CoreOption, DriverOption]>,
>>   HelpText<"Disable specified features of coverage instrumentation for "
>>"Sanitizers">;
>> def fsanitize_memory_track_origins_EQ : Joined<["-"], 
>> "fsanitize-memory-track-origins=">,
>> -Group, 
>> Flags<[CC1Option]>,
>> +Group,
>> HelpText<"Enable origins tracking in 
>> MemorySanitizer">;
>> def fsanitize_memory_track_origins : Flag<["-"], 
>> "fsanitize-memory-track-origins">,
>> - Group, 
>> Flags<[CC1Option]>,
>> + Group,
>>  HelpText<"Enable origins tracking in 
>> MemorySanitizer">;
>> def fno_sanitize_memory_track_origins : Flag<["-"], 
>> "fno-sanitize-memory-track-origins">,
>> -Group, 
>> Flags<[CC1Option]>,
>> +Group,
>> +Flags<[CoreOption, DriverOption]>,
>> HelpText<"Disable origins tracking 
>> in MemorySanitizer">;
>> def fsanitize_memory_use_after_dtor : Flag<["-"], 
>> "fsanitize-memory-use-after-dtor">,
>> - Group, 
>> Flags<[CC1Option]>,
>> + Group,
>>

r300181 - Revert "[clang-cl] Make all sanitizer flags available in clang-cl"

2017-04-13 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Apr 13 03:02:29 2017
New Revision: 300181

URL: http://llvm.org/viewvc/llvm-project?rev=300181&view=rev
Log:
Revert "[clang-cl] Make all sanitizer flags available in clang-cl"

This reverts commit 47979b20b475664013d19382fc6875b5b9f3ed9d.

This was causing a couple of bots to fail.

http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/30152

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300181&r1=300180&r2=300181&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr 13 03:02:29 2017
@@ -778,71 +778,65 @@ def fno_signaling_math : Flag<["-"], "fn
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
-
-// Begin sanitizer flags. These should all be core options exposed in all 
driver
-// modes.
-let Flags = [CC1Option, CoreOption] in {
-
 def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
-   MetaVarName<"">,
+   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
HelpText<"Turn on runtime checks for various forms of 
undefined "
 "or suspicious behavior. See user manual for 
available checks">;
 def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
Group,
-  Flags<[CoreOption, DriverOption]>;
+  Flags<[CoreOption]>;
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
-  Group,
+  Group, Flags<[CC1Option, CoreOption]>,
   HelpText<"Path to blacklist file for sanitizers">;
 def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
  Group,
  HelpText<"Don't use blacklist file for 
sanitizers">;
 def fsanitize_coverage
 : CommaJoined<["-"], "fsanitize-coverage=">,
-  Group,
+  Group, Flags<[CoreOption]>,
   HelpText<"Specify the type of coverage instrumentation for Sanitizers">;
 def fno_sanitize_coverage
 : CommaJoined<["-"], "fno-sanitize-coverage=">,
-  Group, Flags<[CoreOption, DriverOption]>,
+  Group, Flags<[CoreOption]>,
   HelpText<"Disable specified features of coverage instrumentation for "
"Sanitizers">;
 def fsanitize_memory_track_origins_EQ : Joined<["-"], 
"fsanitize-memory-track-origins=">,
-Group,
+Group, 
Flags<[CC1Option]>,
 HelpText<"Enable origins tracking in 
MemorySanitizer">;
 def fsanitize_memory_track_origins : Flag<["-"], 
"fsanitize-memory-track-origins">,
- Group,
+ Group, Flags<[CC1Option]>,
  HelpText<"Enable origins tracking in 
MemorySanitizer">;
 def fno_sanitize_memory_track_origins : Flag<["-"], 
"fno-sanitize-memory-track-origins">,
-Group,
-Flags<[CoreOption, DriverOption]>,
+Group, 
Flags<[CC1Option]>,
 HelpText<"Disable origins tracking in 
MemorySanitizer">;
 def fsanitize_memory_use_after_dtor : Flag<["-"], 
"fsanitize-memory-use-after-dtor">,
- Group,
+ Group, Flags<[CC1Option]>,
  HelpText<"Enable use-after-destroy 
detection in MemorySanitizer">;
 def fsanitize_address_field_padding : Joined<["-"], 
"fsanitize-address-field-padding=">,
-Group,
+Group, 
Flags<[CC1Option]>,
 HelpText<"Level of field padding for 
AddressSanitizer">;
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
-Group,
+Group, 
Flags<[CC1Option]>,
 HelpText<"Enable use-after-scope 
detection in AddressSanitizer">;
 def fno_sanitize_address_use_after_scope : Flag<["-"], 
"fno-sanitize-address-use-after-scope">,
-   Group,
-   Flags<[CoreOption, DriverOption]>,
+   Group, 
Flags<[CC1Option]>,
HelpText<"Disable use-after-scope 
detection in A

r300187 - [analyzer] Add numerous assertions to SVal, SymExpr, and MemRegion classes.

2017-04-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Apr 13 04:48:05 2017
New Revision: 300187

URL: http://llvm.org/viewvc/llvm-project?rev=300187&view=rev
Log:
[analyzer] Add numerous assertions to SVal, SymExpr, and MemRegion classes.

Clean up vtable anchors (remove anchors for regions that have regular
out-of-line virtual methods, add anchors for regions that don't have those).

Fix private/public methods (all constructors should now be private for leaf
classes, protected for abstract classes).

No functional change intended, only extra sanity checks and cleanups.

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h?rev=300187&r1=300186&r2=300187&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
Thu Apr 13 04:48:05 2017
@@ -20,6 +20,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 
 namespace clang {
 namespace ento {
@@ -29,8 +30,9 @@ class CompoundValData : public llvm::Fol
   llvm::ImmutableList L;
 
 public:
-  CompoundValData(QualType t, llvm::ImmutableList l)
-: T(t), L(l) {}
+  CompoundValData(QualType t, llvm::ImmutableList l) : T(t), L(l) {
+assert(NonLoc::isCompoundType(t));
+  }
 
   typedef llvm::ImmutableList::iterator iterator;
   iterator begin() const { return L.begin(); }
@@ -47,7 +49,9 @@ class LazyCompoundValData : public llvm:
   const TypedValueRegion *region;
 public:
   LazyCompoundValData(const StoreRef &st, const TypedValueRegion *r)
-: store(st), region(r) {}
+  : store(st), region(r) {
+assert(NonLoc::isCompoundType(r->getValueType()));
+  }
 
   const void *getStore() const { return store.getStore(); }
   const TypedValueRegion *getRegion() const { return region; }

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=300187&r1=300186&r2=300187&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Thu 
Apr 13 04:48:05 2017
@@ -182,6 +182,7 @@ protected:
 
   MemSpaceRegion(MemRegionManager *mgr, Kind k) : MemRegion(k), Mgr(mgr) {
 assert(classof(this));
+assert(mgr);
   }
 
   MemRegionManager* getMemRegionManager() const override { return Mgr; }
@@ -215,9 +216,12 @@ public:
 
 class GlobalsSpaceRegion : public MemSpaceRegion {
   virtual void anchor();
+
 protected:
-  GlobalsSpaceRegion(MemRegionManager *mgr, Kind k)
-: MemSpaceRegion(mgr, k) {}
+  GlobalsSpaceRegion(MemRegionManager *mgr, Kind k) : MemSpaceRegion(mgr, k) {
+assert(classof(this));
+  }
+
 public:
   static bool classof(const MemRegion *R) {
 Kind k = R->getKind();
@@ -236,7 +240,9 @@ class StaticGlobalSpaceRegion : public G
   const CodeTextRegion *CR;
   
   StaticGlobalSpaceRegion(MemRegionManager *mgr, const CodeTextRegion *cr)
-: GlobalsSpaceRegion(mgr, StaticGlobalSpaceRegionKind), CR(cr) {}
+: GlobalsSpaceRegion(mgr, StaticGlobalSpaceRegionKind), CR(cr) {
+assert(cr);
+  }
 
 public:
   void Profile(llvm::FoldingSetNodeID &ID) const override;
@@ -257,9 +263,13 @@ public:
 /// RegionStoreManager::invalidateRegions (instead of finding all the dependent
 /// globals, we invalidate the whole parent region).
 class NonStaticGlobalSpaceRegion : public GlobalsSpaceRegion {
+  virtual void anchor() override;
+
 protected:
   NonStaticGlobalSpaceRegion(MemRegionManager *mgr, Kind k)
-: GlobalsSpaceRegion(mgr, k) {}
+  : GlobalsSpaceRegion(mgr, k) {
+assert(classof(this));
+  }
 
 public:
 
@@ -326,7 +336,6 @@ public:
 };
 
 class HeapSpaceRegion : public MemSpaceRegion {
-  virtual void anchor();
   friend class MemRegionManager;
   
   HeapSpaceRegion(MemRegionManager *mgr)
@@ -341,10 +350,10 @@ public:
 };
   
 class UnknownSpaceRegion : public MemSpaceRegion {
-  virtual void 

[PATCH] D26837: [analyzer] Litter the SVal/SymExpr/MemRegion class hierarchy with asserts.

2017-04-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300187: [analyzer] Add numerous assertions to SVal, SymExpr, 
and MemRegion classes. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D26837?vs=79538&id=95092#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26837

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -379,10 +379,8 @@
 //===--===//
 
 void GlobalsSpaceRegion::anchor() { }
-void HeapSpaceRegion::anchor() { }
-void UnknownSpaceRegion::anchor() { }
-void StackLocalsSpaceRegion::anchor() { }
-void StackArgumentsSpaceRegion::anchor() { }
+void NonStaticGlobalSpaceRegion::anchor() { }
+void StackSpaceRegion::anchor() { }
 void TypedRegion::anchor() { }
 void TypedValueRegion::anchor() { }
 void CodeTextRegion::anchor() { }
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
@@ -42,6 +42,12 @@
 protected:
   SymExpr(Kind k) : K(k) {}
 
+  static bool isValidTypeForSymbol(QualType T) {
+// FIXME: Depending on whether we choose to deprecate structural symbols,
+// this may become much stricter.
+return !T.isNull() && !T->isVoidType();
+  }
+
 public:
   virtual ~SymExpr() {}
 
@@ -103,7 +109,9 @@
   const SymbolID Sym;
 
 protected:
-  SymbolData(Kind k, SymbolID sym) : SymExpr(k), Sym(sym) {}
+  SymbolData(Kind k, SymbolID sym) : SymExpr(k), Sym(sym) {
+assert(classof(this));
+  }
 
 public:
   ~SymbolData() override {}
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -20,6 +20,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 
 namespace clang {
 namespace ento {
@@ -29,8 +30,9 @@
   llvm::ImmutableList L;
 
 public:
-  CompoundValData(QualType t, llvm::ImmutableList l)
-: T(t), L(l) {}
+  CompoundValData(QualType t, llvm::ImmutableList l) : T(t), L(l) {
+assert(NonLoc::isCompoundType(t));
+  }
 
   typedef llvm::ImmutableList::iterator iterator;
   iterator begin() const { return L.begin(); }
@@ -47,7 +49,9 @@
   const TypedValueRegion *region;
 public:
   LazyCompoundValData(const StoreRef &st, const TypedValueRegion *r)
-: store(st), region(r) {}
+  : store(st), region(r) {
+assert(NonLoc::isCompoundType(r->getValueType()));
+  }
 
   const void *getStore() const { return store.getStore(); }
   const TypedValueRegion *getRegion() const { return region; }
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -44,7 +44,10 @@
 
 public:
   SymbolRegionValue(SymbolID sym, const TypedValueRegion *r)
-: SymbolData(SymbolRegionValueKind, sym), R(r) {}
+  : SymbolData(SymbolRegionValueKind, sym), R(r) {
+assert(r);
+assert(isValidTypeForSymbol(r->getValueType()));
+  }
 
   const TypedValueRegion* getRegion() const { return R; }
 
@@ -81,7 +84,15 @@
   SymbolConjured(SymbolID sym, const Stmt *s, const LocationContext *lctx,
  QualType t, unsigned count, const void *symbolTag)
   : SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
-LCtx(lctx), SymbolTag(symbolTag) {}
+LCtx(lctx), SymbolTag(symbolTag) {
+// FIXME: 's' might be a nullptr if we're conducting invalidation
+// that was caused by a destructor call on a temporary object,
+// which has no statement associated with it.
+// Due to this, we might be creating the same invalidation symbol for
+// two different invalidation passes (for two different t

r300189 - [analyzer] Enforce super-region classes for various memory regions.

2017-04-13 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Apr 13 04:56:07 2017
New Revision: 300189

URL: http://llvm.org/viewvc/llvm-project?rev=300189&view=rev
Log:
[analyzer] Enforce super-region classes for various memory regions.

We now check the type of the super-region pointer for most SubRegion classes
in compile time; some checks are run-time though.

This is an API-breaking change (we now require explicit casts to specific region
sub-classes), but in practice very few checkers are affected.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h?rev=300189&r1=300188&r2=300189&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h Thu 
Apr 13 04:56:07 2017
@@ -458,8 +458,8 @@ class AllocaRegion : public SubRegion {
 // memory allocated by alloca at the same call site.
   const Expr *Ex;
 
-  AllocaRegion(const Expr *ex, unsigned cnt, const MemRegion *superRegion)
-: SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {
+  AllocaRegion(const Expr *ex, unsigned cnt, const MemSpaceRegion *superRegion)
+  : SubRegion(superRegion, AllocaRegionKind), Cnt(cnt), Ex(ex) {
 assert(Ex);
   }
 
@@ -546,7 +546,7 @@ class CodeTextRegion : public TypedRegio
   virtual void anchor() override;
 
 protected:
-  CodeTextRegion(const MemRegion *sreg, Kind k) : TypedRegion(sreg, k) {
+  CodeTextRegion(const MemSpaceRegion *sreg, Kind k) : TypedRegion(sreg, k) {
 assert(classof(this));
   }
 
@@ -565,7 +565,7 @@ class FunctionCodeRegion : public CodeTe
 
   const NamedDecl *FD;
 
-  FunctionCodeRegion(const NamedDecl *fd, const MemRegion* sreg)
+  FunctionCodeRegion(const NamedDecl *fd, const CodeSpaceRegion* sreg)
 : CodeTextRegion(sreg, FunctionCodeRegionKind), FD(fd) {
 assert(isa(fd) || isa(fd));
   }
@@ -616,7 +616,7 @@ class BlockCodeRegion : public CodeTextR
   CanQualType locTy;
 
   BlockCodeRegion(const BlockDecl *bd, CanQualType lTy,
-  AnalysisDeclContext *ac, const MemRegion* sreg)
+  AnalysisDeclContext *ac, const CodeSpaceRegion* sreg)
   : CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {
 assert(bd);
 assert(ac);
@@ -663,11 +663,14 @@ class BlockDataRegion : public TypedRegi
   void *OriginalVars;
 
   BlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc,
-  unsigned count, const MemRegion *sreg)
+  unsigned count, const MemSpaceRegion *sreg)
   : TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
 BlockCount(count), ReferencedVars(nullptr), OriginalVars(nullptr) {
 assert(bc);
 assert(lc);
+assert(isa(sreg) ||
+   isa(sreg) ||
+   isa(sreg));
   }
 
   static void ProfileRegion(llvm::FoldingSetNodeID&, const BlockCodeRegion *,
@@ -741,12 +744,13 @@ class SymbolicRegion : public SubRegion
 
   const SymbolRef sym;
 
-  SymbolicRegion(const SymbolRef s, const MemRegion *sreg)
+  SymbolicRegion(const SymbolRef s, const MemSpaceRegion *sreg)
   : SubRegion(sreg, SymbolicRegionKind), sym(s) {
 assert(s);
 assert(s->getType()->isAnyPointerType() ||
s->getType()->isReferenceType() ||
s->getType()->isBlockPointerType());
+assert(isa(sreg) || isa(sreg));
   }
 
 public:
@@ -777,7 +781,7 @@ class StringRegion : public TypedValueRe
 
   const StringLiteral* Str;
 
-  StringRegion(const StringLiteral *str, const MemRegion *sreg)
+  StringRegion(const StringLiteral *str, const GlobalInternalSpaceRegion *sreg)
   : TypedValueRegion(sreg, StringRegionKind), Str(str) {
 assert(str);
   }
@@ -815,7 +819,8 @@ class ObjCStringRegion : public TypedVal
 
   const ObjCStringLiteral* Str;
 
-  ObjCStringRegion(const ObjCStringLiteral *str, const MemRegion *sreg)
+  ObjCStringRegion(const ObjCStringLiteral *str,
+   const GlobalInternalSpaceRegion *sreg)
   : TypedValueRegion(sreg, ObjCStringRegionKind), Str(str) {
 assert(str);
   }
@@ -853,9 +858,12 @@ class CompoundLiteralRegion : public Typ
 
   const CompoundLiteralExpr *CL;
 
-  CompoundLiteralRegion(const CompoundLiteralExpr *cl, const MemRegion *sReg)
+  Comp

[PATCH] D26838: [analyzer] Enforce super-region classes for various memory regions through compile-time and run-time type checks.

2017-04-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300189: [analyzer] Enforce super-region classes for various 
memory regions. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D26838?vs=79537&id=95093#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26838

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/Store.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1341,7 +1341,8 @@
   if (!Array.getAs())
 return UnknownVal();
 
-  const MemRegion* R = Array.castAs().getRegion();
+  const SubRegion *R =
+  cast(Array.castAs().getRegion());
   NonLoc ZeroIdx = svalBuilder.makeZeroArrayIndex();
   return loc::MemRegionVal(MRMgr.getElementRegion(T, ZeroIdx, R, Ctx));
 }
@@ -1384,7 +1385,7 @@
 T = SR->getSymbol()->getType();
   }
 }
-MR = GetElementZeroRegion(MR, T);
+MR = GetElementZeroRegion(cast(MR), T);
   }
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -512,7 +512,8 @@
   if (CNE->isArray()) {
 // FIXME: allocating an array requires simulating the constructors.
 // For now, just return a symbolicated region.
-const MemRegion *NewReg = symVal.castAs().getRegion();
+const SubRegion *NewReg =
+symVal.castAs().getRegionAs();
 QualType ObjTy = CNE->getType()->getAs()->getPointeeType();
 const ElementRegion *EleReg =
   getStoreManager().GetElementZeroRegion(NewReg, ObjTy);
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -950,22 +950,22 @@
   if (const MemRegion *region = lhs.getAsRegion()) {
 rhs = convertToArrayIndex(rhs).castAs();
 SVal index = UnknownVal();
-const MemRegion *superR = nullptr;
+const SubRegion *superR = nullptr;
 // We need to know the type of the pointer in order to add an integer to it.
 // Depending on the type, different amount of bytes is added.
 QualType elementType;
 
 if (const ElementRegion *elemReg = dyn_cast(region)) {
   assert(op == BO_Add || op == BO_Sub);
   index = evalBinOpNN(state, op, elemReg->getIndex(), rhs,
   getArrayIndexType());
-  superR = elemReg->getSuperRegion();
+  superR = cast(elemReg->getSuperRegion());
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
   assert(op == BO_Add || op == BO_Sub);
   index = (op == BO_Add) ? rhs : evalMinus(rhs);
-  superR = region;
+  superR = cast(region);
   // TODO: Is this actually reliable? Maybe improving our MemRegion
   // hierarchy to provide typed regions for all non-void pointers would be
   // better. For instance, we cannot extend this towards LocAsInteger
Index: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -31,54 +31,56 @@
 // MemRegion Construction.
 //===--===//
 
-template 
-RegionTy* MemRegionManager::getSubRegion(const A1 a1,
- const MemRegion *superRegion) {
+template 
+RegionTy* MemRegionManager::getSubRegion(const Arg1Ty arg1,
+ const SuperTy *superRegion) {
   llvm::FoldingSetNodeID ID;
-  RegionTy::ProfileRegion(ID, a1, superRegion);
+  RegionTy::ProfileRegion(ID, arg1, superRegion);
   void *InsertPos;
   RegionTy* R = cast_or_null(Regions.FindNodeOrInsertPos(ID,
InsertPos));
 
   if (!R) {
 R = A.Allocate();
-new (R) RegionTy(a1, superRegion);
+new (R) RegionTy(arg1, superRegion);
 Regions.InsertNode(R, InsertPos);
   }
 
   return R;
 }
 
-template 
-RegionTy* MemRegionManager::getSubRegion(const A1 a1, const A2 a2,
- const 

[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:975
+  if (Op->getOpcode() == UO_AddrOf)
+if (Op->getSubExpr()->isLValue()) {
+  Ex = Op->getSubExpr()->IgnoreParenCasts();

Maybe you could move this condition one level up with &&?



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:977
+  Ex = Op->getSubExpr()->IgnoreParenCasts();
+  while (true) {
+if (const auto *ME = dyn_cast(Ex)) {

Can't you writhe this like:

```
while (const auto *ME = dyn_cast(Ex)) {
  Ex = ME->getBase()->IgnoreParenCasts();
  }
```

?




https://reviews.llvm.org/D31982



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


[libcxx] r300191 - Add TEST_NOEXCEPT_FALSE to support D31738

2017-04-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 13 05:17:23 2017
New Revision: 300191

URL: http://llvm.org/viewvc/llvm-project?rev=300191&view=rev
Log:
Add TEST_NOEXCEPT_FALSE to support D31738

Modified:
libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=300191&r1=300190&r2=300191&view=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Thu Apr 13 05:17:23 2017
@@ -106,6 +106,7 @@
 #define TEST_ALIGNAS(...) alignas(__VA_ARGS__)
 #define TEST_CONSTEXPR constexpr
 #define TEST_NOEXCEPT noexcept
+#define TEST_NOEXCEPT_FALSE noexcept(false)
 #define TEST_NOEXCEPT_COND(...) noexcept(__VA_ARGS__)
 # if TEST_STD_VER >= 14
 #   define TEST_CONSTEXPR_CXX14 constexpr
@@ -123,6 +124,7 @@
 #define TEST_CONSTEXPR
 #define TEST_CONSTEXPR_CXX14
 #define TEST_NOEXCEPT throw()
+#define TEST_NOEXCEPT_FALSE
 #define TEST_NOEXCEPT_COND(...)
 #define TEST_THROW_SPEC(...) throw(__VA_ARGS__)
 #endif


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


[PATCH] D28670: [ObjC] Disallow vector parameters and return values in Objective-C methods on older X86 targets

2017-04-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 95099.
arphaman marked an inline comment as done.
arphaman added a comment.

Add an assertion as requested by Bruno.


Repository:
  rL LLVM

https://reviews.llvm.org/D28670

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclBase.cpp
  lib/Sema/SemaDeclObjC.cpp
  test/SemaObjC/x86-method-vector-values.m

Index: test/SemaObjC/x86-method-vector-values.m
===
--- /dev/null
+++ test/SemaObjC/x86-method-vector-values.m
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-macosx10.10 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-macosx10.4 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-darwin14 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -triple=i686-apple-ios8 -Wno-objc-root-class %s
+
+// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-macosx10.11 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-darwin15 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DIOS -triple=i686-apple-ios9 -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-watchos -Wno-objc-root-class %s
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-tvos -Wno-objc-root-class %s
+
+// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=x86_64-apple-macosx10.10 -Wno-objc-root-class %s
+
+// rdar://21662309
+
+typedef __attribute__((__ext_vector_type__(3))) float float3;
+
+typedef float __m128 __attribute__((__vector_size__(16)));
+
+struct Aggregate { __m128 v; };
+struct AggregateFloat { float v; };
+
+#define AVAILABLE_MACOS_10_10 __attribute__((availability(macos, introduced = 10.10)))
+#define AVAILABLE_MACOS_10_11 __attribute__((availability(macos, introduced = 10.11)))
+
+#define AVAILABLE_IOS_8 __attribute__((availability(ios, introduced = 8.0)))
+#define AVAILABLE_IOS_9 __attribute__((availability(ios, introduced = 9.0)))
+
+@interface VectorMethods
+
+-(void)takeVector:(float3)v; // there should be no diagnostic at declaration
+-(void)takeM128:(__m128)v;
+
+@end
+
+@implementation VectorMethods
+
+#ifndef ALLOW
+
+-(void)takeVector:(float3)v {
+#ifdef MAC
+  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported; support for vector types for this target is introduced in macOS 10.11}}
+#else
+  // expected-error@-4 {{'float3' (vector of 3 'float' values) parameter type is unsupported; support for vector types for this target is introduced in iOS 9}}
+#endif
+}
+
+-(float3)retVector { // expected-error {{'float3' (vector of 3 'float' values) return type is unsupported}}
+}
+
+-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+-(void)takeVector4:(float3)v AVAILABLE_IOS_8 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+}
+
+- (__m128)retM128 { // expected-error {{'__m128' (vector of 4 'float' values) return type is unsupported}}
+}
+
+- (void)takeM128:(__m128)v { // expected-error {{'__m128' (vector of 4 'float' values) parameter type is unsupported}}
+}
+
+#else
+
+-(void)takeVector:(float3)v {
+}
+
+-(float3)retVector {
+  return 0;
+}
+
+- (__m128)retM128 {
+  __m128 value;
+  return value;
+}
+
+- (void)takeM128:(__m128)v {
+}
+
+-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 {
+#ifdef MAC
+// expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+#endif
+}
+
+- (__m128)retM128_2 AVAILABLE_MACOS_10_10 {
+#ifdef MAC
+// expected-error@-2 {{'__m128' (vector of 4 'float' values) return type is unsupported}}
+#endif
+  __m128 value;
+  return value;
+}
+
+-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // no error
+}
+
+-(void)takeVector4:(float3)v AVAILABLE_IOS_8 {
+#ifdef IOS
+  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
+#endif
+}
+
+-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // no error
+}
+
+#ifdef OTHER
+// expected-no-diagnostics
+#endif
+
+#endif
+
+-(void)doStuff:(int)m { // no error
+}
+
+-(struct Aggregate)takesAndRetVectorInAggregate:(struct Aggregate)f { // no error
+  struct Aggregate result;
+  return result;
+}
+
+-(struct AggregateFloat)takesAndRetFloatInAggregate:(struct AggregateFloat)f { // no error
+  struct AggregateFloat result;
+  return result;
+}
+
+
+@end
Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -4308,6 +43

[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-04-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This looks correct! Thanks for taking this up.

One of the possible improvements for future work here would be to actually bind 
the second argument value to the buffer instead of just invalidating it. Like, 
after `memset(buf, 0, sizeof(buf))` the analyzer should know that all values in 
the `buf` array are `0`. In the analyzer we have the notion of *default 
bindings* to handle that (see documentation in docs/analyzer/RegionStore.txt 
for more details). However, they would only work when the whole region is 
`memset`ed, not when we're wiping a smaller portion of the region. But the 
special case of `memset`ing the whole region is important enough to be worth 
handling separately anyway. In order to detect this special case, you can find 
the region's *extent* and see if it's exactly equal to the size argument 
(ideally, handle comparison with the `assume` method). This would work not only 
for arrays, but also for regions allocated via `malloc` or C++ operator `new`. 
There is an attempt to do a similar thing for `strdup` in 
https://reviews.llvm.org/D20863 (mixed with more complicated stuff).

Since we're in `CStringChecker`, we may also want to see how `memset` affects 
our model of string length. If we `memset` to zero everything from the 
beginning of the region, the length of the resulting C string is 0; if not to 
zero, then the length of the resulting C string is at least the size argument; 
if not from the beginning, then we've no idea, unless we knew the length before 
and it was less then the offset from which we started `memset`ing.




Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2025
+
+  // If the size is zero, there won't be any actual memory access, so  
 
+  // just bind the return value to the destination buffer and return.

Trailing spaces here.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2037
+
+// Ensure the memory area pointed to by s is not null. 
+// If it is NULL there will be a NULL pointer dereference.

One more trailing space.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:2051-2052
+
+// Invalidate the memory area pointed to by s (regular invalidation 
without 
+// pointer-escaping the address of the top-level region). 
+state = InvalidateBuffer(C, state, S, C.getSVal(S),

And a few more trailing spaces :) I usually catch those with a colored `git 
diff` and highlight them in my editor as well, and also have a hotkey to 
clang-format current line, which is probably the most handy.


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


[PATCH] D31868: [analyzer] Check NULL pointer dereference issue for memset function

2017-04-13 Thread Leslie Zhai via Phabricator via cfe-commits
xiangzhai added a comment.

Hi Artem,

Thanks for your review! I will update my patch tomorrow :)

Regards,
Leslie Zhai


Repository:
  rL LLVM

https://reviews.llvm.org/D31868



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


[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.

2017-04-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, i've been thinking of writing a test for this via `ExprInspection`'s 
`clang_analyzer_printState()`, however `printState()` functionality is only 
enabled in debug builds, and i'm not seeing how to enable the test only on 
debug builds (there's `REQUIRES:` but it only seems to have an asserts flag).


https://reviews.llvm.org/D31541



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


[PATCH] D31126: Do not run tests for crash recovery if libstdc++ safe mode is enabled

2017-04-13 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

The problem solved by the fix is still actual.


https://reviews.llvm.org/D31126



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2017-04-13 Thread Simon Dardis via Phabricator via cfe-commits
sdardis updated this revision to Diff 95109.
sdardis marked 2 inline comments as done.
sdardis added a comment.

Addressed review comments. I've highlighted the relevant places with FIXME:s 
where we don't support GCC vector operations.


https://reviews.llvm.org/D25866

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-gcc-compat.c
  test/Sema/vector-gcc-compat.cpp
  test/Sema/vector-ops.c
  test/Sema/zvector.c
  test/SemaCXX/vector-no-lax.cpp

Index: test/SemaCXX/vector-no-lax.cpp
===
--- test/SemaCXX/vector-no-lax.cpp
+++ test/SemaCXX/vector-no-lax.cpp
@@ -4,6 +4,6 @@
 
 vSInt32 foo (vUInt32 a) {
   vSInt32 b = { 0, 0, 0, 0 };
-  b += a; // expected-error{{cannot convert between vector values}}
+  b += a; // expected-error{{cannot convert between vector type 'vUInt32' (vector of 4 'unsigned int' values) and vector type 'vSInt32' (vector of 4 'int' values) as implicit conversion would cause truncation}}
   return b;
 }
Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{cannot convert between scalar type 'unsigned char' and vector type '__vector signed char' (vector of 16 'signed char' values) as implicit conversion would cause truncation}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-ops.c
===
--- test/Sema/vector-ops.c
+++ test/Sema/vector-ops.c
@@ -13,11 +13,11 @@
   (void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
 
   // Comparison operators
-  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values)}}
+  v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__attribute__((__vector_size__(2 * sizeof(int int' (vector of 2 'int' values}}
   v2sa = (v2ua==v2sa);
 
   // Arrays
-  int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values)}}
+  int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values}}
   int array2[17];
   // FIXME: error message below needs type!
   (void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
@@ -28,108 +28,108 @@
 }
 
 void testLogicalVecVec(v2u v2ua, v2s v2sa, v2f v2fa) {
-
   // Logical operators
-  v2ua = v2ua && v2ua; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from '__

[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Seems that we're starting to hit some YAML/JSON mismatches, or is it that your 
YAML string support is lacking?


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


Re: [PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Krasimir Georgiev via cfe-commits
sorry, is it that *our* YAML string support is lacking?

On Thu, Apr 13, 2017 at 2:38 PM, Krasimir Georgiev via Phabricator <
revi...@reviews.llvm.org> wrote:

> krasimir added a comment.
>
> Seems that we're starting to hit some YAML/JSON mismatches, or is it that
> your YAML string support is lacking?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D31992
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32010: [indexer] Record class template specializations using a new 'SpecializationOf' relationship

2017-04-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch extends the set of relationships that are recorded by the indexer by 
adding support for the 'SpecializationOf' relationship.


Repository:
  rL LLVM

https://reviews.llvm.org/D32010

Files:
  include/clang/Index/IndexSymbol.h
  lib/Index/IndexDecl.cpp
  lib/Index/IndexSymbol.cpp
  lib/Index/IndexTypeSourceInfo.cpp
  lib/Index/IndexingContext.cpp
  lib/Index/IndexingContext.h
  test/Index/Core/index-source.cpp

Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -50,6 +50,12 @@
   // CHECK-NEXT: RelChild | TemplCls | c:@ST>1#T@TemplCls
 };
 
+template<>
+class TemplCls {
+// CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | TemplCls | c:@S@TemplCls>#d |  | Def,RelSpecialization | rel: 1
+// CHECK: RelSpecialization | TemplCls | c:@ST>1#T@TemplCls
+};
+
 TemplCls gtv(0);
 // CHECK: [[@LINE-1]]:1 | class(Gen)/C++ | TemplCls | c:@ST>1#T@TemplCls |  | Ref,RelCont | rel: 1
 
@@ -91,3 +97,17 @@
 // CHECK: [[@LINE+2]]:5 | variable/C | gvf | c:@gvf | _gvf | Def | rel: 0
 // CHECK: [[@LINE+1]]:11 | variable(Gen)/C++ | tmplVar | c:index-source.cpp@VT>1#T@tmplVar | __ZL7tmplVar | Ref,Read,RelCont | rel: 1
 int gvf = tmplVar;
+
+template
+class PartialSpecilizationClass { };
+// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass |  | Def | rel: 0
+
+template
+class PartialSpecilizationClass { };
+// CHECK: [[@LINE-1]]:7 | class(Gen,TPS)/C++ | PartialSpecilizationClass | c:@SP>1#T@PartialSpecilizationClass>#I#*t0.0 |  | Def,RelSpecialization | rel: 1
+// CHECK-NEXT: RelSpecialization | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass
+
+template<>
+class PartialSpecilizationClass { };
+// CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | PartialSpecilizationClass | c:@S@PartialSpecilizationClass>#I#I |  | Def,RelSpecialization | rel: 1
+// CHECK-NEXT: RelSpecialization | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass
Index: lib/Index/IndexingContext.h
===
--- lib/Index/IndexingContext.h
+++ lib/Index/IndexingContext.h
@@ -80,7 +80,8 @@
 
   bool indexDecl(const Decl *D);
 
-  void indexTagDecl(const TagDecl *D);
+  void indexTagDecl(const TagDecl *D,
+ArrayRef Relations = None);
 
   void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
const DeclContext *DC = nullptr,
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -233,6 +233,7 @@
   case SymbolRole::RelationReceivedBy:
   case SymbolRole::RelationCalledBy:
   case SymbolRole::RelationContainedBy:
+  case SymbolRole::RelationSpecializationOf:
 return true;
   }
   llvm_unreachable("Unsupported SymbolRole value!");
Index: lib/Index/IndexTypeSourceInfo.cpp
===
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -208,11 +208,12 @@
   }
 }
 
-void IndexingContext::indexTagDecl(const TagDecl *D) {
+void IndexingContext::indexTagDecl(const TagDecl *D,
+   ArrayRef Relations) {
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return;
 
-  if (handleDecl(D)) {
+  if (handleDecl(D, /*Roles=*/SymbolRoleSet(), Relations)) {
 if (D->isThisDeclarationADefinition()) {
   indexNestedNameSpecifierLoc(D->getQualifierLoc(), D);
   if (auto CXXRD = dyn_cast(D)) {
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -346,6 +346,7 @@
   APPLY_FOR_ROLE(RelationAccessorOf);
   APPLY_FOR_ROLE(RelationContainedBy);
   APPLY_FOR_ROLE(RelationIBTypeOf);
+  APPLY_FOR_ROLE(RelationSpecializationOf);
 
 #undef APPLY_FOR_ROLE
 
@@ -386,6 +387,7 @@
 case SymbolRole::RelationAccessorOf: OS << "RelAcc"; break;
 case SymbolRole::RelationContainedBy: OS << "RelCont"; break;
 case SymbolRole::RelationIBTypeOf: OS << "RelIBType"; break;
+case SymbolRole::RelationSpecializationOf: OS << "RelSpecialization"; break;
 }
   });
 }
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -495,8 +495,18 @@
ClassTemplateSpecializationDecl *D) {
 // FIXME: Notify subsequent callbacks if info comes from implicit
 // instantiation.
-if (D->isThisDeclarationADefinition())
-  IndexCtx.indexTagDecl(D);
+if (D->isThisDeclarationADefinition()) {
+  llvm::PointerUnion
+  Template = D->getSpecializedTemplateOrPartial();
+ 

[PATCH] D31562: [coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.

2017-04-13 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added inline comments.



Comment at: lib/Sema/CoroutineBuilder.h:1
+//===- CoroutineBuilder.h - Coroutine Semantic checking -*- C++ 
-*-===//
+//

This file is called:

  CoroutineStmtBuilder.h

in trunk



Comment at: lib/Sema/CoroutineBuilder.h:14
+
+#ifndef LLVM_CLANG_LIB_SEMA_COROUTINEBUILDER_H
+#define LLVM_CLANG_LIB_SEMA_COROUTINEBUILDER_H

```
#ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
#define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
```


https://reviews.llvm.org/D31562



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


[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson added a comment.

In https://reviews.llvm.org/D31992#725866, @krasimir wrote:

> Seems that we're starting to hit some YAML/JSON mismatches, or is it that 
> your YAML string support is lacking?


I don't think so. It seems like JSON and YAML are not completely aligned on 
escaped characters. See http://yaml.org/spec/1.2/spec.html#id2776092 which 
specifies unicode 8, 16, and 32 bits are escaped with \x, \u, and \U whereas 
http://www.json.org/string.gif specifies that unicode 16 bit characters can be 
encoded with \u but \x and \U are not supported. This leads me to believe that 
a YAML parser can read JSON but a JSON parser will not necessarily be able to 
read YAML. I thought about using json cpp but that's a much bigger change


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I'm strongly against this patch. Can you give an actual test case for the 
problematic behavior?


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


[PATCH] D31976: Avoid assert when a non-static member function is qualified with __unaligned

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

This seems reasonable to me, but you should wait for confirmation before 
committing (I'm not as familiar with the mangler as others are).




Comment at: test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp:16
+void A::foo() // expected-error {{definition with same mangled name as another 
definition}}
+  // expected-note@-6 {{previous definition is here}}
+{

Might as well put this note with the declaration rather than using an offset 
for the message.


https://reviews.llvm.org/D31976



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


[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson added a comment.

In https://reviews.llvm.org/D31992#725913, @joerg wrote:

> I'm strongly against this patch. Can you give an actual test case for the 
> problematic behavior?


Sure I can add a test. If you meant more real work scenario, you can juste type 
"é" in VS Code and it will throw an exception trying to parse \x


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clangd/Protocol.cpp:26-50
+  for (llvm::StringRef::iterator i = Input.begin(), e = Input.end(); i != e; 
++i) {
+if (*i == '\\')
+  EscapedInput += "";
+else if (*i == '"')
+  EscapedInput += "\\\"";
+// bell
+else if (*i == 0x07)

For json we only need the first 2 though, right?


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:81
+  hasLoopInit(LoopVarInit),
+  hasCondition(binaryOperator(hasOperatorName("<"),
+  hasLHS(RefersToLoopVar),

Perhaps you could support other comparisons, but not attempt to generate a 
fix-it for them? It seems odd that this would trigger for `<` but not `<=`, but 
I can see why you'd not want to figure out the reserve call for `!(foo >= 10)`.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:83
+  hasLHS(RefersToLoopVar),
+  hasRHS(expr().bind(LoopEndExprName,
+  hasIncrement(unaryOperator(hasOperatorName("++"),

Thinking out loud, but, what happens if the loop end expression has some hidden 
complexity to it? e.g.,
```
for (int i = 0; i < i + 1; ++i) { // This is a "creative" loop.
  v.push_back(i);
}
```



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:84
+  hasRHS(expr().bind(LoopEndExprName,
+  hasIncrement(unaryOperator(hasOperatorName("++"),
+ hasUnaryOperand(RefersToLoopVar))),

Can you add a test case for post-increment (all of your tests use 
pre-increment)? Also, count-down loops seem reasonable to support as well, no?
```
for (int i = 10; i >= 0; --i) {
  v.push_back(i);
}
```



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:86-87
+ hasUnaryOperand(RefersToLoopVar))),
+  hasBody(anyOf(compoundStmt(statementCountIs(1), has(PushBackCall)),
+PushBackCall)),
+  hasParent(compoundStmt(has(VectorVarDefStmt)).bind(LoopParentName)))

You should update the documentation to mention that this check only worries 
about a for loop with a single statement in it. It will be surprising that this 
code does not trigger the same diagnostic:
```
for (...) {
  std::cout << i;
  v.push_back(i);
}
```



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:95-96
+const MatchFinder::MatchResult &Result) {
+  if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
+return;
+

We don't usually add this test in to our check calls; why are you adding it 
here?



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:98
+
+  const SourceManager *SM = Result.SourceManager;
+  const auto *ForLoop = Result.Nodes.getNodeAs(LoopCounterName);

Might as well make this a reference rather than a pointer (simplifies code 
elsewhere).



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:100-104
+  const auto* PushBackCall =
+  Result.Nodes.getNodeAs(PushBackCallName);
+  const auto* LoopEndExpr =
+  Result.Nodes.getNodeAs(LoopEndExprName);
+  const auto* LoopParent =

Formatting (I would recommend running clang-format over the patch).



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:109-111
+  auto AllVectorVarRefs = utils::decl_ref_expr::allDeclRefExprs(
+  *VectorVarDecl, *LoopParent, *Result.Context);
+  for (const auto *Ref : AllVectorVarRefs) {

I'm not certain what types are being used here. Can you turn `AllVectorVarRefs` 
into something with an explicit type so that I can know what `Ref`'s type is?



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:117
+//
+// FIXME: make it more intelligent to identified the pre-allocating
+// operations before the for loop.

identified -> identify



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.h:20
+/// Finds possible inefficient `std::vector` operations (e.g. `push_back`) in
+/// for-loops that may cause unnecessary memory reallocations.
+///

Drop the hyphen in for loops.



Comment at: 
docs/clang-tidy/checks/performance-inefficient-vector-operation.rst:7
+Finds possible inefficient `std::vector` operations (e.g. `push_back`) that may
+cause unnecessary memory reallocations.
+

The docs should talk more about the limitations of the check (like how many 
statements it can contain, etc).


https://reviews.llvm.org/D31757



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


[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D31992#725912, @malaperle-ericsson wrote:

> In https://reviews.llvm.org/D31992#725866, @krasimir wrote:
>
> > Seems that we're starting to hit some YAML/JSON mismatches, or is it that 
> > your YAML string support is lacking?
>
>
> I don't think so. It seems like JSON and YAML are not completely aligned on 
> escaped characters. See http://yaml.org/spec/1.2/spec.html#id2776092 which 
> specifies unicode 8, 16, and 32 bits are escaped with \x, \u, and \U whereas 
> http://www.json.org/string.gif specifies that unicode 16 bit characters can 
> be encoded with \u but \x and \U are not supported. This leads me to believe 
> that a YAML parser can read JSON but a JSON parser will not necessarily be 
> able to read YAML. I thought about using json cpp but that's a much bigger 
> change


Here we only talk about what we escape, which should be the minimum required.
If I understand correctly, that's " and \ for JSON and ", \ and all 
non-printable characters (which unfortunately requires understanding of unicode 
to solve this fully correctly) in YAML.
Am I missing something?


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


[PATCH] D32014: Remove unused varible

2017-04-13 Thread Wei-Ren Chen via Phabricator via cfe-commits
chenwj created this revision.
Herald added subscribers: rengolin, aemerson.

The Result variable is unused both in Sema::CheckARMBuiltinFunctionCall and 
Sema::CheckAArch64BuiltinFunctionCall, remove it.


https://reviews.llvm.org/D32014

Files:
  lib/Sema/SemaChecking.cpp


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1391,8 +1391,6 @@
 }
 
 bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
   BuiltinID == ARM::BI__builtin_arm_ldaex ||
   BuiltinID == ARM::BI__builtin_arm_strex ||
@@ -1439,8 +1437,6 @@
 
 bool Sema::CheckAArch64BuiltinFunctionCall(unsigned BuiltinID,
  CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
   BuiltinID == AArch64::BI__builtin_arm_ldaex ||
   BuiltinID == AArch64::BI__builtin_arm_strex ||


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1391,8 +1391,6 @@
 }
 
 bool Sema::CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == ARM::BI__builtin_arm_ldrex ||
   BuiltinID == ARM::BI__builtin_arm_ldaex ||
   BuiltinID == ARM::BI__builtin_arm_strex ||
@@ -1439,8 +1437,6 @@
 
 bool Sema::CheckAArch64BuiltinFunctionCall(unsigned BuiltinID,
  CallExpr *TheCall) {
-  llvm::APSInt Result;
-
   if (BuiltinID == AArch64::BI__builtin_arm_ldrex ||
   BuiltinID == AArch64::BI__builtin_arm_ldaex ||
   BuiltinID == AArch64::BI__builtin_arm_strex ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31167: Use FPContractModeKind universally

2017-04-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D31167#725705, @mehdi_amini wrote:

> I believe considering the goal of moving to using per-instruction FMF and 
> kills the global backend option, this leads to a bitcode upgrade issue: 
> OpenCL (or other) bitcode that were generated bitcode don't have the right 
> FMF and will be upgraded conservatively.
>  Performance regression when upgrading bitcode are to be expected in general, 
> so it is not a bug.
>  To recover, an option for an OpenCL backend would be to add a pass that set 
> the expected FMF everywhere after bitcode upgrade.


Actually we are not concerned about old bitcodes. We are doing separate 
compile/link/codegen, but the bitcode we use in codegen is fresh from the same 
revision of llvm/clang. As long as the FMF carries the correct info from Clang 
we should be OK.


Repository:
  rL LLVM

https://reviews.llvm.org/D31167



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


[libcxx] r300197 - Refactor throw_with_nested. NFC.

2017-04-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr 13 09:41:45 2017
New Revision: 300197

URL: http://llvm.org/viewvc/llvm-project?rev=300197&view=rev
Log:
Refactor throw_with_nested. NFC.

Modified:
libcxx/trunk/include/exception

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=300197&r1=300196&r2=300197&view=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Thu Apr 13 09:41:45 2017
@@ -202,46 +202,54 @@ struct __nested
 _LIBCPP_INLINE_VISIBILITY explicit __nested(const _Tp& __t) : _Tp(__t) {}
 };
 
-template 
-_LIBCPP_NORETURN
-void
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-throw_with_nested(_Tp&& __t, typename enable_if<
-  is_class::type>::value &&
-  !is_base_of::type>::value
-  && !__libcpp_is_final::type>::value
->::type* = 0)
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-throw_with_nested (_Tp& __t, typename enable_if<
-  is_class<_Tp>::value && !is_base_of::value
->::type* = 0)
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-{
 #ifndef _LIBCPP_NO_EXCEPTIONS
-throw __nested::type>(_VSTD::forward<_Tp>(__t));
-#else
-((void)__t);
-// FIXME: Make this abort.
+template 
+struct __throw_with_nested;
+
+template 
+struct __throw_with_nested<_Tp, _Up, true> {
+_LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__do_throw(_Tp&& __t)
+#else
+__do_throw (_Tp& __t)
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+{
+throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
+}
+};
+
+template 
+struct __throw_with_nested<_Tp, _Up, false> {
+_LIBCPP_NORETURN static inline _LIBCPP_ALWAYS_INLINE void
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+__do_throw(_Tp&& __t)
+#else
+__do_throw (_Tp& __t)
+#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+{
+throw _VSTD::forward<_Tp>(__t);
+}
+};
 #endif
-}
 
 template 
 _LIBCPP_NORETURN
 void
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-throw_with_nested(_Tp&& __t, typename enable_if<
-  !is_class::type>::value ||
-  is_base_of::type>::value
-  || __libcpp_is_final::type>::value
->::type* = 0)
-#else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-throw_with_nested (_Tp& __t, typename enable_if<
-  !is_class<_Tp>::value || is_base_of::value
->::type* = 0)
-#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+throw_with_nested(_Tp&& __t)
+#else
+throw_with_nested (_Tp& __t)
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
-throw _VSTD::forward<_Tp>(__t);
+typedef typename remove_reference<_Tp>::type _Up;
+//static_assert( is_copy_constructible<_Up>::value, "");
+__throw_with_nested<_Tp, _Up,
+is_class<_Up>::value &&
+!is_base_of::value &&
+!__libcpp_is_final<_Up>::value>::
+__do_throw(_VSTD::forward<_Tp>(__t));
 #else
 ((void)__t);
 // FIXME: Make this abort


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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-04-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 95126.
gtbercea added a comment.

Fix.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -500,7 +500,12 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP)
+CC1Args.push_back(
+DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ, 
"+ptx42").data());
+  else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -500,7 +500,12 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP)
+CC1Args.push_back(
+DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ, "+ptx42").data());
+  else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-a

[PATCH] D29658: [OpenMP] Customize CUDA-based tool chain selection

2017-04-13 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Is there a way to actually test the changed code? The current test changes seem 
unrelated...




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:165-166
   "The target '%0' is not a supported OpenMP host target.">;
+def err_drv_omp_device_target_not_supported : Error<
+  "The target '%0' is not a supported OpenMP device target.">;
 def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<

This diagnostic seems unrelated to the code.



Comment at: test/OpenMP/target_messages.cpp:7-8
 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target 
'{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host 
target.
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu 
-o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s
+// CHECK-UNSUPPORTED-DEVICE-TARGET: The target 'hexagon-linux-gnu' is not a 
supported OpenMP device target.
 

This test seems unrelated to the changes to the code.


Repository:
  rL LLVM

https://reviews.llvm.org/D29658



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


[PATCH] D32020: [indexer] The relationship between the declarations in template specializations that 'override' declarations in the base template should be recorded

2017-04-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This is useful for "go to definition" feature for an IDE like Xcode. Consider 
the following example:

  template
  struct Traits { 
using EncodedAs = void; // 1
  }; 
  
  template<>
  struct Traits {
using EncodedAs = int; // 2
  };

This change will allow the IDE to take the user to `EncodedAs` at `1` if the 
user wishes to perform "go to definition" on `EncodedAs` at `2`.


Repository:
  rL LLVM

https://reviews.llvm.org/D32020

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/IndexingContext.cpp
  lib/Index/IndexingContext.h
  test/Index/Core/index-source.cpp

Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -111,3 +111,97 @@
 class PartialSpecilizationClass { };
 // CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | PartialSpecilizationClass | c:@S@PartialSpecilizationClass>#I#I |  | Def,RelSpecialization | rel: 1
 // CHECK-NEXT: RelSpecialization | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass
+
+template
+class PseudoOverridesInSpecializations {
+  void function() { }
+  void function(int) { }
+
+  static void staticFunction() { }
+
+  int field;
+  static int variable;
+
+  typedef T TypeDef;
+  using TypeAlias = T;
+
+  enum anEnum { };
+
+  struct Struct { };
+  union Union { };
+
+  using TypealiasOrRecord = void;
+
+  template struct InnerTemplate { };
+  template struct InnerTemplate  { };
+};
+
+template<>
+class PseudoOverridesInSpecializations {
+  void function() { }
+// CHECK: [[@LINE-1]]:8 | instance-method/C++ | function | c:@S@PseudoOverridesInSpecializations>#d#I@F@function# | __ZN32PseudoOverridesInSpecializationsIdiE8functionEv | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | function | c:@ST>2#T#T@PseudoOverridesInSpecializations@F@function#
+
+  void staticFunction() { }
+// CHECK: [[@LINE-1]]:8 | instance-method/C++ | staticFunction | c:@S@PseudoOverridesInSpecializations>#d#I@F@staticFunction# | __ZN32PseudoOverridesInSpecializationsIdiE14staticFunctionEv | Def,RelChild | rel: 1
+// CHECK-NOT: RelOver
+
+  int notOverridingField = 0;
+
+// CHECK-LABEL: checLabelBreak
+  int checLabelBreak = 0;
+
+  int field = 0;
+// CHECK: [[@LINE-1]]:7 | field/C++ | field | c:@S@PseudoOverridesInSpecializations>#d#I@FI@field |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | field | c:@ST>2#T#T@PseudoOverridesInSpecializations@FI@field
+
+  static double variable;
+// CHECK: [[@LINE-1]]:17 | static-property/C++ | variable | c:@S@PseudoOverridesInSpecializations>#d#I@variable | __ZN32PseudoOverridesInSpecializationsIdiE8variableE | Decl,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | variable | c:@ST>2#T#T@PseudoOverridesInSpecializations@variable
+
+  typedef double TypeDef;
+// CHECK: [[@LINE-1]]:18 | type-alias/C | TypeDef | c:index-source.cpp@S@PseudoOverridesInSpecializations>#d#I@T@TypeDef |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | TypeDef | c:index-source.cpp@ST>2#T#T@PseudoOverridesInSpecializations@T@TypeDef
+
+  using TypeAlias = int;
+// CHECK: [[@LINE-1]]:9 | type-alias/C++ | TypeAlias | c:@S@PseudoOverridesInSpecializations>#d#I@TypeAlias |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | TypeAlias | c:@ST>2#T#T@PseudoOverridesInSpecializations@TypeAlias
+
+  enum anEnum { };
+// CHECK: [[@LINE-1]]:8 | enum/C | anEnum | c:@S@PseudoOverridesInSpecializations>#d#I@E@anEnum |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | anEnum | c:@ST>2#T#T@PseudoOverridesInSpecializations@E@anEnum
+  class Struct { };
+// CHECK: [[@LINE-1]]:9 | class/C++ | Struct | c:@S@PseudoOverridesInSpecializations>#d#I@S@Struct |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | Struct | c:@ST>2#T#T@PseudoOverridesInSpecializations@S@Struct
+  union Union { };
+// CHECK: [[@LINE-1]]:9 | union/C | Union | c:@S@PseudoOverridesInSpecializations>#d#I@U@Union |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | Union | c:@ST>2#T#T@PseudoOverridesInSpecializations@U@Union
+
+  struct TypealiasOrRecord { };
+// CHECK: [[@LINE-1]]:10 | struct/C | TypealiasOrRecord | c:@S@PseudoOverridesInSpecializations>#d#I@S@TypealiasOrRecord |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | TypealiasOrRecord | c:@ST>2#T#T@PseudoOverridesInSpecializations@TypealiasOrRecord
+
+  template struct InnerTemplate { };
+// CHECK: [[@LINE-1]]:31 | struct(Gen)/C++ | InnerTemplate | c:@S@PseudoOverridesInSpecializations>#d#I@ST>1#T@InnerTemplate |  | Def,RelChild,RelOver | rel: 2
+// CHECK-NEXT: RelChild
+// CHECK-NEXT: RelOver | InnerTemplate | c:@ST>2#T#T@PseudoOverridesInSpecializations@ST>1#T@InnerTemplate
+  template struct InnerTemplate  { };
+

[PATCH] D32014: Remove unused varible

2017-04-13 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.

Looks good


https://reviews.llvm.org/D32014



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


[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-13 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Yay! This is going to fix some really confusing false positives.LGTM with 
Gabor's comments addressed.

One note. I am not a big fan of using clang_analyzer_explain() in tests for 
functionality. It is great for debugging, but for testing it exposes too much 
of the implementation details of the region hierarchy and store. Exposing this 
kind of state is fine in tests specific to the store/region store, but in my 
opinion it should be another clang_analyzer_ entry point and should be limited 
to regions.

Similarly we should have a clang_analyzer_ entry point for testing symbols but 
that doesn't expose the guts of MemRegions. And (maybe?) another one for 
SymExprs.




Comment at: test/Analysis/explain-svals.cpp:103
+  C *c = 0;
+  // FIXME: we need to be explaining '40' rather than '0' here; not explainer 
bug.
+  clang_analyzer_explain(&c->y); // expected-warning-re^concrete memory 
address '0'$

It would be good to mention that this is a modeling bug and point to where it 
could be fixed. Otherwise the FIXME is not super helpful to future maintainers.




https://reviews.llvm.org/D31982



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


[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: docs/clang-tidy/checks/misc-unused-parameters.rst:15
+
+  void a(int  /*i*/) {}
+

sylvestre.ledru wrote:
> alexfh wrote:
> > nit: two spaces before the comment.
> I believe it is the case ? 
> I stole this from the unit test //test/clang-tidy/misc-unused-parameters.c//
Indeed. But now we have `-format-style=` option to fix formatting after 
applying fixes ;). Since it's not on by default, it's fair to leave the example 
as is.


https://reviews.llvm.org/D31860



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


[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2017-04-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

https://reviews.llvm.org/D31864 covered all that was needed for Gentoo, and I 
lack the knowledge to push the full split properly forward.


https://reviews.llvm.org/D25157



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


[libcxx] r300206 - [libc++] Explicitly set output directory for DLL

2017-04-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Apr 13 11:27:38 2017
New Revision: 300206

URL: http://llvm.org/viewvc/llvm-project?rev=300206&view=rev
Log:
[libc++] Explicitly set output directory for DLL

DLLs on Windows are treated as runtime targets. Explicitly set the
output directory for them, to be consistent with other platforms.

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=300206&r1=300205&r2=300206&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Thu Apr 13 11:27:38 2017
@@ -347,6 +347,7 @@ file(MAKE_DIRECTORY "${LIBCXX_BINARY_INC
 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR})
 
 # Declare libc++ configuration variables.
 # They are intended for use as follows:


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


r300209 - Re-land "[clang-cl] Make all sanitizer flags available in clang-cl"

2017-04-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 13 11:32:26 2017
New Revision: 300209

URL: http://llvm.org/viewvc/llvm-project?rev=300209&view=rev
Log:
Re-land "[clang-cl] Make all sanitizer flags available in clang-cl"

Adding RUN lines with %clang_cl was causing these tests to fail on Mac
because absolute paths there tend to start with "/User/", which is
recognized as the "/U" flag.

Re-lands r300122

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300209&r1=300208&r2=300209&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Apr 13 11:32:26 2017
@@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fn
 def fjump_tables : Flag<["-"], "fjump-tables">, Group;
 def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not use jump tables for lowering switches">;
+
+// Begin sanitizer flags. These should all be core options exposed in all 
driver
+// modes.
+let Flags = [CC1Option, CoreOption] in {
+
 def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
-   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
+   MetaVarName<"">,
HelpText<"Turn on runtime checks for various forms of 
undefined "
 "or suspicious behavior. See user manual for 
available checks">;
 def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
Group,
-  Flags<[CoreOption]>;
+  Flags<[CoreOption, DriverOption]>;
 def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
-  Group, Flags<[CC1Option, CoreOption]>,
+  Group,
   HelpText<"Path to blacklist file for sanitizers">;
 def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
  Group,
  HelpText<"Don't use blacklist file for 
sanitizers">;
 def fsanitize_coverage
 : CommaJoined<["-"], "fsanitize-coverage=">,
-  Group, Flags<[CoreOption]>,
+  Group,
   HelpText<"Specify the type of coverage instrumentation for Sanitizers">;
 def fno_sanitize_coverage
 : CommaJoined<["-"], "fno-sanitize-coverage=">,
-  Group, Flags<[CoreOption]>,
+  Group, Flags<[CoreOption, DriverOption]>,
   HelpText<"Disable specified features of coverage instrumentation for "
"Sanitizers">;
 def fsanitize_memory_track_origins_EQ : Joined<["-"], 
"fsanitize-memory-track-origins=">,
-Group, 
Flags<[CC1Option]>,
+Group,
 HelpText<"Enable origins tracking in 
MemorySanitizer">;
 def fsanitize_memory_track_origins : Flag<["-"], 
"fsanitize-memory-track-origins">,
- Group, Flags<[CC1Option]>,
+ Group,
  HelpText<"Enable origins tracking in 
MemorySanitizer">;
 def fno_sanitize_memory_track_origins : Flag<["-"], 
"fno-sanitize-memory-track-origins">,
-Group, 
Flags<[CC1Option]>,
+Group,
+Flags<[CoreOption, DriverOption]>,
 HelpText<"Disable origins tracking in 
MemorySanitizer">;
 def fsanitize_memory_use_after_dtor : Flag<["-"], 
"fsanitize-memory-use-after-dtor">,
- Group, Flags<[CC1Option]>,
+ Group,
  HelpText<"Enable use-after-destroy 
detection in MemorySanitizer">;
 def fsanitize_address_field_padding : Joined<["-"], 
"fsanitize-address-field-padding=">,
-Group, 
Flags<[CC1Option]>,
+Group,
 HelpText<"Level of field padding for 
AddressSanitizer">;
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
-Group, 
Flags<[CC1Option]>,
+Group,
 HelpText<"Enable use-after-scope 
detection in AddressSanitizer">;
 def fno_sanitize_address_use_after_scope : Flag<["-"], 
"fno-sanitize-address-use-after-scope">,
-   Group, 
Flags<[CC1Option]>,
+   Group,
+   Flags<[CoreOption, DriverOption]>,
HelpText<"Disable use-after-scope 
detection in 

r300214 - Use the clang-cl recognized spelling of --target=

2017-04-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 13 11:36:28 2017
New Revision: 300214

URL: http://llvm.org/viewvc/llvm-project?rev=300214&view=rev
Log:
Use the clang-cl recognized spelling of --target=

This fixes a warning. The test was passing without this change.

Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=300214&r1=300213&r2=300214&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Thu Apr 13 11:36:28 2017
@@ -109,15 +109,15 @@
 // CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with 
'-fsanitize=kernel-address'
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
-// RUN: %clang_cl -target x86_64-windows -fsanitize=address 
-fsanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fsanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE-OFF
-// RUN: %clang_cl -target x86_64-windows -fsanitize=address 
-fno-sanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE-OFF
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fno-sanitize-address-use-after-scope -### -- %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE-OFF
 // CHECK-USE-AFTER-SCOPE-OFF-NOT: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
-// RUN: %clang_cl -target x86_64-windows -fsanitize=address 
-fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope -### 
-- %s 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
+// RUN: %clang_cl --target=x86_64-windows -fsanitize=address 
-fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope -### 
-- %s 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
 // CHECK-USE-AFTER-SCOPE-BOTH: -cc1{{.*}}-fsanitize-address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope -fno-sanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH-OFF


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


Re: r300122 - [clang-cl] Make all sanitizer flags available in clang-cl

2017-04-13 Thread Reid Kleckner via cfe-commits
Fixed in r300209. Was the -Wslash-u-filename warning not explanatory enough
to suggest the solution? Maybe we could add a note like "escape source
paths starting with /U by passing them at the end of the command line after
--".

/Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/fsanitize.c:113:27:
error: expected string not found in input
// CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
  ^
:1:1: note: scanning from here
clang-5.0: warning: unknown argument ignored in clang-cl: '-target'
[-Wunknown-argument]
^
:7:89: note: possible intended match here
clang-5.0: warning:
'/Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/fsanitize.c'
treated as the '/U' option [-Wslash-u-filename]

On Thu, Apr 13, 2017 at 1:12 AM, Akira Hatanaka  wrote:

> I’m afraid I have to revert this to turn the bots green again.
>
> On Apr 12, 2017, at 10:41 PM, Akira Hatanaka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> I think this broke some of the bots.
>
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/30152/
>
> Could you take a look?
>
>
> On Apr 12, 2017, at 3:50 PM, Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: rnk
> Date: Wed Apr 12 17:50:51 2017
> New Revision: 300122
>
> URL: http://llvm.org/viewvc/llvm-project?rev=300122&view=rev
> Log:
> [clang-cl] Make all sanitizer flags available in clang-cl
>
> Summary:
> Use a tablegen let {} block so that new sanitizer flags are available by
> default in all driver modes. This should cut down on time wasted with
> bugs like http://crbug.com/710928.
>
> Reviewers: vitalybuka, hans
>
> Subscribers: kcc, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D31988
>
> Modified:
>cfe/trunk/include/clang/Driver/Options.td
>cfe/trunk/test/Driver/fsanitize.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=300122&r1=300121&r2=300122&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 17:50:51 2017
> @@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fn
> def fjump_tables : Flag<["-"], "fjump-tables">, Group;
> def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group,
> Flags<[CC1Option]>,
>   HelpText<"Do not use jump tables for lowering switches">;
> +
> +// Begin sanitizer flags. These should all be core options exposed in all
> driver
> +// modes.
> +let Flags = [CC1Option, CoreOption] in {
> +
> def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
> -   Flags<[CC1Option, CoreOption]>,
> MetaVarName<"">,
> +   MetaVarName<"">,
>HelpText<"Turn on runtime checks for various forms of
> undefined "
> "or suspicious behavior. See user manual for
> available checks">;
> def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">,
> Group,
> -  Flags<[CoreOption]>;
> +  Flags<[CoreOption, DriverOption]>;
> def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
> -  Group, Flags<[CC1Option,
> CoreOption]>,
> +  Group,
>   HelpText<"Path to blacklist file for
> sanitizers">;
> def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
>  Group,
>  HelpText<"Don't use blacklist file for
> sanitizers">;
> def fsanitize_coverage
> : CommaJoined<["-"], "fsanitize-coverage=">,
> -  Group, Flags<[CoreOption]>,
> +  Group,
>   HelpText<"Specify the type of coverage instrumentation for
> Sanitizers">;
> def fno_sanitize_coverage
> : CommaJoined<["-"], "fno-sanitize-coverage=">,
> -  Group, Flags<[CoreOption]>,
> +  Group, Flags<[CoreOption, DriverOption]>,
>   HelpText<"Disable specified features of coverage instrumentation for
> "
>"Sanitizers">;
> def fsanitize_memory_track_origins_EQ : Joined<["-"],
> "fsanitize-memory-track-origins=">,
> -Group,
> Flags<[CC1Option]>,
> +Group,
> HelpText<"Enable origins tracking
> in MemorySanitizer">;
> def fsanitize_memory_track_origins : Flag<["-"], "fsanitize-memory-track-
> origins">,
> - Group,
> Flags<[CC1Option]>,
> + Group,
>  HelpText<"Enable origins tracking in
> MemorySanitizer">;
> def fno_sanitize_memory_track_origins : Flag<["-"],
> "fno-sanitize-memory-track-origins">,
> -Group,
> Flags<[CC1Option]>,
> +

[PATCH] D31982: [analyzer] Improve suppression for inlined defensive checks when operator& is involved.

2017-04-13 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

Thanks!!!




Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:965
+
+// Performing operator `&' on an lvalue expression is essentially a no-op.
+// Then, if we are taking addresses of fields or elements, these are also

NoQ wrote:
> alexshap wrote:
> > "Address-of" operator can be overloaded, 
> > just wondering - doest this code work correctly in that case ?
> In this case we'd see a `CXXOperatorCallExpr` instead of `UnaryOperator` (all 
> hail clang AST!).
Adding a test case for that would be good.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:968
+// unlikely to matter.
+// FIXME: Currently offsets of fields are computed incorrectly,
+// being always equal to 0. See the FIXME in StoreManager's

Incorrect implies that there is a better "correct" model and invites a fix. Do 
we know what better model would be? If so, we could add that to the comment. If 
not, I'd prefer explaining why it works this way (similarly to how you did in 
the comment below). Maybe adding an example of what does not work. And you 
could add a FIXME to say that it's worth investigating if there is a better way 
of handling it. (The majority of this info should probably go to Store.cpp)

Also, maybe it's just the choice of words here. "Incorrect" sounds like 
something that needs to be corrected. Whereas you could use something like "is 
modeled imprecisely with respect to what happens at execution time", which 
could still mean that this is how we do want to model it going forward.

It seems that the problem with modeling this way is demonstrated with a test 
case in explain-svals.cpp. So the benefits of the current modeling seem to be 
worth it.

Can we add a note along the path saying that "p" in "p->f" is null? This would 
address the user confusion with imprecise modeling.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:977
+  Ex = Op->getSubExpr()->IgnoreParenCasts();
+  while (true) {
+if (const auto *ME = dyn_cast(Ex)) {

Why do we need the "while (true)"? Can we just use "dyn_cast(Ex)" 
as the loop condition?

Take a look at the getDerefExpr(const Stmt *S) and see if that would be a 
better place to add this code. Maybe not..




Comment at: lib/StaticAnalyzer/Core/Store.cpp:405
   case loc::ConcreteIntKind:
 // While these seem funny, this can happen through casts.
 // FIXME: What we should return is the field offset.  For example,

Could you rephrase this existing comment while you are here? Using word "funny" 
seems content-free and a bit strange. 





Comment at: lib/StaticAnalyzer/Core/Store.cpp:409
 //  like this work properly:  &(((struct foo *) 0xa)->f)
+//  However, that's not easy to fix without reducing our abilities
+//  to catch null pointer dereference. Eg., ((struct foo *)0x0)->f = 7

Thanks for adding the explanation!

Can you think of other cases where the same would apply? (Ex: array index)


https://reviews.llvm.org/D31982



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


[libcxx] r300218 - Implement LWG#2855 - made easy by previous refactoring

2017-04-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr 13 11:57:42 2017
New Revision: 300218

URL: http://llvm.org/viewvc/llvm-project?rev=300218&view=rev
Log:
Implement LWG#2855 - made easy by previous refactoring

Modified:
libcxx/trunk/include/exception

libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=300218&r1=300217&r2=300218&view=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Thu Apr 13 11:57:42 2017
@@ -243,8 +243,8 @@ throw_with_nested (_Tp& __t)
 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
-typedef typename remove_reference<_Tp>::type _Up;
-//static_assert( is_copy_constructible<_Up>::value, "");
+typedef typename decay<_Tp>::type _Up;
+static_assert( is_copy_constructible<_Up>::value, "type thrown must be 
CopyConstructible");
 __throw_with_nested<_Tp, _Up,
 is_class<_Up>::value &&
 !is_base_of::value &&

Modified: 
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp?rev=300218&r1=300217&r2=300218&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
 Thu Apr 13 11:57:42 2017
@@ -107,6 +107,16 @@ int main()
 assert(i == 7);
 }
 }
+{
+try
+{
+std::throw_with_nested("String literal");
+assert(false);
+}
+catch (const char * s)
+{
+}
+}
 #if TEST_STD_VER > 11
 {
 try

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=300218&r1=300217&r2=300218&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Apr 13 11:57:42 2017
@@ -463,7 +463,7 @@
http://wg21.link/LWG2842";>2842in_place_t 
check for optional::optional(U&&) should decay 
UKonaComplete
http://wg21.link/LWG2850";>2850std::function move constructor 
does unnecessary workKona
http://wg21.link/LWG2853";>2853Possible 
inconsistency in specification of erase in 
[vector.modifiers]Kona
-   http://wg21.link/LWG2855";>2855std::throw_with_nested("string_literal")Kona
+   http://wg21.link/LWG2855";>2855std::throw_with_nested("string_literal")KonaComplete
http://wg21.link/LWG2857";>2857{variant,optional,any}::emplace
 should return the constructed valueKona
http://wg21.link/LWG2861";>2861basic_string should require 
that charT match traits::char_typeKonaComplete
http://wg21.link/LWG2866";>2866Incorrect 
derived classes constraintsKona
@@ -489,7 +489,7 @@
 
   
 
-  Last Updated: 11-Apr-2017
+  Last Updated: 13-Apr-2017
 
 
 


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


[PATCH] D32029: [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt

2017-04-13 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek created this revision.
kubamracek added a project: Sanitizers.

CodeGenFunction::EmitObjCForCollectionStmt currently emits lifetime markers for 
the loop variable in an inconsistent way:  `lifetime.start` is emitted before 
the loop is entered, but `lifetime.end` is emitted inside the loop:

  ; entry block
%u = alloca %1*, align 8
%1 = bitcast %1** %u to i8*
call void @llvm.lifetime.start(i64 8, i8* %1) #5
...
  
  ; loop body
...
%14 = bitcast %1** %u to i8*
call void @llvm.lifetime.end(i64 8, i8* %14) #5
...
br i1 %21, ... ; loop
  
  ; loop ended
ret void

AddressSanitizer uses these markers to track out-of-scope accesses to local 
variables, and we get false positives in Obj-C foreach loops (in the 2nd 
iteration of the loop).  The markers of the loop variable need to be either 
both inside the loop (so that we poison and unpoison the variable in each 
iteration), or both outside.  This patch implements the "both inside" approach 
and makes EmitObjCForCollectionStmt emit:

  ; entry block
%u = alloca %1*, align 8
...
  
  ; loop body
%12 = bitcast %1** %u to i8*
call void @llvm.lifetime.start(i64 8, i8* %12) #5
...
%14 = bitcast %1** %u to i8*
call void @llvm.lifetime.end(i64 8, i8* %14) #5
br label %15
  
  ; loop ended
ret void

The test fixups are only changing the order of allocas.   There's some related 
discussion at https://reviews.llvm.org/D18618.


Repository:
  rL LLVM

https://reviews.llvm.org/D32029

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/arc-foreach.m
  test/CodeGenObjC/arc-ternary-op.m


Index: test/CodeGenObjC/arc-ternary-op.m
===
--- test/CodeGenObjC/arc-ternary-op.m
+++ test/CodeGenObjC/arc-ternary-op.m
@@ -120,9 +120,9 @@
 
   // CHECK-LABEL:define void @test2(
   // CHECK:  [[COND:%.*]] = alloca i32,
-  // CHECK:  alloca i8*
   // CHECK:  [[CLEANUP_SAVE:%.*]] = alloca i8*
   // CHECK:  [[RUN_CLEANUP:%.*]] = alloca i1
+  // CHECK:  alloca i8*
   //   Evaluate condition; cleanup disabled by default.
   // CHECK:  [[T0:%.*]] = load i32, i32* [[COND]],
   // CHECK-NEXT: icmp ne i32 [[T0]], 0
Index: test/CodeGenObjC/arc-foreach.m
===
--- test/CodeGenObjC/arc-foreach.m
+++ test/CodeGenObjC/arc-foreach.m
@@ -24,9 +24,9 @@
 
 // CHECK-LP64-LABEL:define void @test0(
 // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T:%.*]]*,
-// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
 // CHECK-LP64-NEXT: [[BUFFER:%.*]] = alloca [16 x i8*], align 8
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
 // Initialize 'array'.
@@ -97,9 +97,9 @@
 
 // CHECK-LP64-LABEL:define void @test1(
 // CHECK-LP64:  alloca [[ARRAY_T:%.*]]*,
-// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[STATE:%.*]] = alloca [[STATE_T:%.*]],
 // CHECK-LP64-NEXT: alloca [16 x i8*], align 8
+// CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*,
 // CHECK-LP64-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]],
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], 
[[STATE_T]]* [[STATE]], i32 0, i32 1
@@ -160,7 +160,7 @@
 
   // CHECK-LP64-LABEL:define void @test3(
   // CHECK-LP64:  [[ARRAY:%.*]] = alloca [[ARRAY_T]]*, align 8
-  // CHECK-LP64-NEXT: [[X:%.*]] = alloca i8*, align 8
+  // CHECK-LP64:  [[X:%.*]] = alloca i8*, align 8
   // CHECK-LP64:  [[T0:%.*]] = load i8*, i8** [[X]], align 8
   // CHECK-LP64-NEXT: [[T1:%.*]] = icmp ne i8* [[T0]], null
   // CHECK-LP64-NEXT: br i1 [[T1]],
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -1469,11 +1469,6 @@
   if (DI)
 DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin());
 
-  // The local variable comes into scope immediately.
-  AutoVarEmission variable = AutoVarEmission::invalid();
-  if (const DeclStmt *SD = dyn_cast(S.getElement()))
-variable = EmitAutoVarAlloca(*cast(SD->getSingleDecl()));
-
   JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end");
 
   // Fast enumeration state.
@@ -1625,8 +1620,10 @@
   bool elementIsVariable;
   LValue elementLValue;
   QualType elementType;
+  AutoVarEmission variable = AutoVarEmission::invalid();
   if (const DeclStmt *SD = dyn_cast(S.getElement())) {
 // Initialize the variable, in case it's a __block variable or something.
+variable = EmitAutoVarAlloca(*cast(SD->getSingleDecl()));
 EmitAutoVarInit(variable);
 
 const VarDecl* D = cast(SD->getSingleDecl());


Index: test/CodeGenObjC/arc-ternary-op.m
===
--- test/CodeGenObjC/arc-ternary-op.m
+++ test/CodeGenObjC/arc-ternary-op.m
@@ -120,9 +120,9 @@
 
   // CHECK-LABEL: 

[PATCH] D27263: Address of bitfield in anonymous struct doesn't error.

2017-04-13 Thread Jacob Young via Phabricator via cfe-commits
jacobly added a comment.

Ping.


https://reviews.llvm.org/D27263



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


r300223 - clang-format-vs: Use a separate license.txt copy

2017-04-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Apr 13 12:37:17 2017
New Revision: 300223

URL: http://llvm.org/viewvc/llvm-project?rev=300223&view=rev
Log:
clang-format-vs: Use a separate license.txt copy

The regular file used to display very poorly in the VSIX installer due
to long lines, wrapping etc.

Added:
cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt   (with props)
Modified:
cfe/trunk/tools/clang-format-vs/.gitignore
cfe/trunk/tools/clang-format-vs/CMakeLists.txt

Modified: cfe/trunk/tools/clang-format-vs/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/.gitignore?rev=300223&r1=300222&r2=300223&view=diff
==
--- cfe/trunk/tools/clang-format-vs/.gitignore (original)
+++ cfe/trunk/tools/clang-format-vs/.gitignore Thu Apr 13 12:37:17 2017
@@ -7,6 +7,5 @@
 
 # Generated and copied files
 /ClangFormat/Key.snk
-/ClangFormat/license.txt
 /ClangFormat/clang-format.exe
 /ClangFormat/source.extension.vsixmanifest

Modified: cfe/trunk/tools/clang-format-vs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/CMakeLists.txt?rev=300223&r1=300222&r2=300223&view=diff
==
--- cfe/trunk/tools/clang-format-vs/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-format-vs/CMakeLists.txt Thu Apr 13 12:37:17 2017
@@ -6,11 +6,6 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
   DEPENDS clang-format)
 
-  add_custom_target(clang_format_license
-  ${CMAKE_COMMAND} -E copy_if_different
-  "${CLANG_SOURCE_DIR}/LICENSE.TXT"
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
-
   # Build number added to Clang version to ensure that new VSIX can be upgraded
   string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
 
@@ -34,5 +29,5 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
   COMMAND ${CMAKE_COMMAND} -E copy_if_different
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
   "${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
-  DEPENDS clang_format_exe_for_vsix clang_format_license)
+  DEPENDS clang_format_exe_for_vsix)
 endif()

Added: cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt?rev=300223&view=auto
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt (added)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt Thu Apr 13 12:37:17 
2017
@@ -0,0 +1,39 @@
+
+LLVM Release License
+
+University of Illinois/NCSA
+Open Source License
+
+Copyright (c) 2007-2017 University of Illinois at Urbana-Champaign.
+All rights reserved.
+
+Developed by:
+
+LLVM Team
+
+University of Illinois at Urbana-Champaign
+
+http://llvm.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy 
of this software and associated documentation files (the "Software"), to deal 
with the Software without restriction, including without limitation the rights 
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
copies of the Software, and to permit persons to whom the Software is furnished 
to do so, subject to the following conditions:
+
+* Redistributions of source code must retain the above copyright notice, 
this list of conditions and the following disclaimers.
+
+* Redistributions in binary form must reproduce the above copyright 
notice, this list of conditions and the following disclaimers in the 
documentation and/or other materials provided with the distribution.
+
+* Neither the names of the LLVM Team, University of Illinois at 
Urbana-Champaign, nor the names of its contributors may be used to endorse or 
promote products derived from this Software without specific prior written 
permission.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE 
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE 
SOFTWARE.
+
+
+The LLVM software contains code written by third parties.  Such software will 
have its own individual LICENSE.TXT file in the directory in which it appears.  
This file will describe the copyrights, license, and restrictions which apply
+to that code.
+
+The disclaimer of warranty in the University of Illinois Open Source License 
applies to all code in the LLVM Distribution, and nothing in any of the other 
licenses gives permission to use

r300225 - Warning-free clang-format plugin install for VS 15.0

2017-04-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Apr 13 12:42:45 2017
New Revision: 300225

URL: http://llvm.org/viewvc/llvm-project?rev=300225&view=rev
Log:
Warning-free clang-format plugin install for VS 15.0

With the new release of VS, it's required that all plugins migrate to
the new VSIX manifest format. The new format is backwards compatible
with all versions newer that Visual Studio 2012, so this migration
effectively drops support for older versions of the IDE.

It's also required that these new extensions are built with Visual
Studio 2017, so unfortunately it was necessary to migrate the project
and solution. Also removed COM references to EnvDTE and
Microsoft.VisualStudio.TextManager.Interop from the csproj, as they seem
to both be unnecessary and would trigger build warnings because of
changes to GAC.

Patch by Hugo Puhlmann!

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

Modified:
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config
cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj?rev=300225&r1=300224&r2=300225&view=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj Thu Apr 13 
12:42:45 2017
@@ -59,8 +59,10 @@
   
   
 
-  ..\packages\VSSDK.DTE.7.0.3\lib\net20\envdte.dll
-  False
+  True
+
+
+  True
 
 
 
@@ -116,10 +118,6 @@
   
..\packages\VSSDK.Text.10.0.4\lib\net40\Microsoft.VisualStudio.Text.UI.Wpf.dll
   False
 
-
-  
..\packages\VSSDK.TextManager.Interop.7.0.4\lib\net20\Microsoft.VisualStudio.TextManager.Interop.dll
-  True
-
 
   False
 
@@ -146,42 +144,6 @@
 
   
   
-
-  {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}
-  8
-  0
-  0
-  primary
-  False
-  False
-
-
-  {26AD1324-4B7C-44BC-84F8-B86AED45729F}
-  10
-  0
-  0
-  primary
-  False
-  False
-
-
-  {1A31287A-4D7D-413E-8E32-3B374931BD89}
-  8
-  0
-  0
-  primary
-  False
-  False
-
-
-  {2CE2370E-D744-4936-A090-3FFFE667B0E1}
-  9
-  0
-  0
-  primary
-  False
-  False
-
 
   {1CBA492E-7263-47BB-87FE-639000619B15}
   8
@@ -230,7 +192,9 @@
   
   
 
-
+
+  Designer
+
 
   Designer
 
@@ -294,4 +258,4 @@
   
   
   -->
-
\ No newline at end of file
+

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config?rev=300225&r1=300224&r2=300225&view=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/packages.config Thu Apr 13 
12:42:45 2017
@@ -2,7 +2,6 @@
 
   
   
-  
   
   
   

Modified: cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in?rev=300225&r1=300224&r2=300225&view=diff
==
--- cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in (original)
+++ cfe/trunk/tools/clang-format-vs/source.extension.vsixmanifest.in Thu Apr 13 
12:42:45 2017
@@ -1,39 +1,19 @@
 
-http://schemas.microsoft.com/developer/vsx-schema/2010";>
-  
-ClangFormat
-LLVM
-@CLANG_FORMAT_VS_VERSION@
+http://schemas.microsoft.com/developer/vsx-schema/2011"; 
xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011";>
+  
+
+ClangFormat
 A tool to format C/C++/Obj-C 
code.
-1033
-http://clang.llvm.org/docs/ClangFormat.html
+http://clang.llvm.org/docs/ClangFormat.html
 license.txt
-false
-
-  
-Pro
-  
-  
-Pro
-  
-  
-Pro
-  
-  
-Pro
-  
-  
-Pro
-  
-
-
-  
-  
-
-Visual Studio MPF
-
-  
-  
-|%CurrentProject%;PkgdefProjectOutputGroup|
-  
-
+  
+  
+
+  
+  
+
+  
+  
+
+  
+


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


r300226 - Follow-up to r300225: update ClangFormat.sln to VS2017

2017-04-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Apr 13 12:47:47 2017
New Revision: 300226

URL: http://llvm.org/viewvc/llvm-project?rev=300226&view=rev
Log:
Follow-up to r300225: update ClangFormat.sln to VS2017

This got lost in the previous patch somehow.

Modified:
cfe/trunk/tools/clang-format-vs/ClangFormat.sln

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat.sln
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat.sln?rev=300226&r1=300225&r2=300226&view=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat.sln (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat.sln Thu Apr 13 12:47:47 2017
@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio 15
+VisualStudioVersion = 15.0.26228.12
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClangFormat", 
"ClangFormat\ClangFormat.csproj", "{7FD1783E-2D31-4D05-BF23-6EBE1B42B608}"
 EndProject


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


[PATCH] D29658: [OpenMP] Customize CUDA-based tool chain selection

2017-04-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 95171.
gtbercea added a comment.

Remove tests which belong into a different patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D29658

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -553,8 +553,22 @@
   if (TT.getArch() == llvm::Triple::UnknownArch)
 Diag(clang::diag::err_drv_invalid_omp_target) << Val;
   else {
-const ToolChain &TC = getToolChain(C.getInputArgs(), TT);
-C.addOffloadDeviceToolChain(&TC, Action::OFK_OpenMP);
+const ToolChain *TC = nullptr;
+// CUDA toolchains have to be selected differently. They pair host
+// and device in their implementation.
+if (TT.isNVPTX()) {
+  const ToolChain *HostTC =
+  C.getSingleOffloadToolChain();
+  assert(HostTC && "Host toolchain should be always defined.");
+  auto &CudaTC =
+  ToolChains[TT.str() + "/" + HostTC->getTriple().normalize()];
+  if (!CudaTC)
+CudaTC = llvm::make_unique(
+*this, TT, *HostTC, C.getInputArgs());
+  TC = CudaTC.get();
+} else
+  TC = &getToolChain(C.getInputArgs(), TT);
+C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);
   }
 }
   } else


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -553,8 +553,22 @@
   if (TT.getArch() == llvm::Triple::UnknownArch)
 Diag(clang::diag::err_drv_invalid_omp_target) << Val;
   else {
-const ToolChain &TC = getToolChain(C.getInputArgs(), TT);
-C.addOffloadDeviceToolChain(&TC, Action::OFK_OpenMP);
+const ToolChain *TC = nullptr;
+// CUDA toolchains have to be selected differently. They pair host
+// and device in their implementation.
+if (TT.isNVPTX()) {
+  const ToolChain *HostTC =
+  C.getSingleOffloadToolChain();
+  assert(HostTC && "Host toolchain should be always defined.");
+  auto &CudaTC =
+  ToolChains[TT.str() + "/" + HostTC->getTriple().normalize()];
+  if (!CudaTC)
+CudaTC = llvm::make_unique(
+*this, TT, *HostTC, C.getInputArgs());
+  TC = CudaTC.get();
+} else
+  TC = &getToolChain(C.getInputArgs(), TT);
+C.addOffloadDeviceToolChain(TC, Action::OFK_OpenMP);
   }
 }
   } else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32035: [OpenMP] Error when trying to offload to an unsupported architecture

2017-04-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
Herald added a subscriber: rengolin.

Throw an error when offloading is unsupported for a particular target 
architecture.


Repository:
  rL LLVM

https://reviews.llvm.org/D32035

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/target_messages.cpp


Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -4,6 +4,8 @@
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx64-nvidia-cuda -o - %s 
2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 
2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target 
'{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host 
target.
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu 
-o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s
+// CHECK-UNSUPPORTED-DEVICE-TARGET: The target 'hexagon-linux-gnu' is not a 
supported OpenMP device target.
 
 void foo() {
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2239,6 +2239,16 @@
 for (unsigned i = 0; i < A->getNumValues(); ++i) {
   llvm::Triple TT(A->getValue(i));
 
+  if (!(TT.getArch() == llvm::Triple::ppc ||
+TT.getArch() == llvm::Triple::ppc64 ||
+TT.getArch() == llvm::Triple::ppc64le ||
+TT.getArch() == llvm::Triple::nvptx ||
+TT.getArch() == llvm::Triple::nvptx64 ||
+TT.getArch() == llvm::Triple::x86 ||
+TT.getArch() == llvm::Triple::x86_64))
+Diags.Report(clang::diag::err_drv_omp_device_target_not_supported)
+<< A->getValue(i);
+
   if (TT.getArch() == llvm::Triple::UnknownArch)
 Diags.Report(clang::diag::err_drv_invalid_omp_target) << 
A->getValue(i);
   else
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -162,6 +162,8 @@
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<
   "The target '%0' is not a supported OpenMP host target.">;
+def err_drv_omp_device_target_not_supported : Error<
+  "The target '%0' is not a supported OpenMP device target.">;
 def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
   "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading, please use -fopenmp=libomp or 
-fopenmp=libiomp5.">;
 def warn_drv_omp_offload_target_duplicate : Warning<


Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -4,6 +4,8 @@
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx64-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target '{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host target.
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s
+// CHECK-UNSUPPORTED-DEVICE-TARGET: The target 'hexagon-linux-gnu' is not a supported OpenMP device target.
 
 void foo() {
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2239,6 +2239,16 @@
 for (unsigned i = 0; i < A->getNumValues(); ++i) {
   llvm::Triple TT(A->getValue(i));
 
+  if (!(TT.getArch() == llvm::Triple::ppc ||
+TT.getArch() == llvm::Triple::ppc64 ||
+TT.getArch() == llvm::Triple::ppc64le ||
+TT.getArch() == llvm::Triple::nvptx ||
+TT.getArch() == llvm::Triple::nvptx64 ||
+TT.getArch() == llvm::Triple::x86 ||
+TT.getArch() == llvm::Triple::x86_64))
+Diags.Report(clang::diag::err_drv_omp_device_target_not_supported)
+<< A->getValue(i);
+
   if (TT.getArch() == llvm::Triple::UnknownArch)
 Diags.Report(clang::diag::err_drv_invalid_omp_target) << A->getValue(i);
   else
Index: include/clang/Basic/DiagnosticDriverKinds.td
=

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 95174.
hokein marked 11 inline comments as done.
hokein added a comment.

Address review comments.


https://reviews.llvm.org/D31757

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientVectorOperationCheck.cpp
  clang-tidy/performance/InefficientVectorOperationCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-vector-operation.rst
  test/clang-tidy/performance-inefficient-vector-operation.cpp

Index: test/clang-tidy/performance-inefficient-vector-operation.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-vector-operation.cpp
@@ -0,0 +1,183 @@
+// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- -format-style=llvm --
+
+typedef int size_t;
+
+namespace std {
+template 
+class vector {
+ public:
+  typedef T* iterator;
+  typedef const T* const_iterator;
+  typedef T& reference;
+  typedef const T& const_reference;
+  typedef size_t size_type;
+
+  explicit vector();
+  explicit vector(size_type n);
+
+  void push_back(const T& val);
+  void reserve(size_t n);
+  void resize(size_t n);
+
+  size_t size();
+  const_reference operator[] (size_type) const;
+  reference operator[] (size_type);
+};
+} // namespace std
+
+void f(std::vector& t) {
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called inside a loop; consider pre-allocating the vector capacity before the loop
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; i++)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(5);
+for (int i = 0; i < 5; ++i) {
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+// CHECK-FIXES-NOT: v.reserve(10);
+for (int i = 0; i < 10; ++i) {
+  // No fix for this loop as we encounter the prior loops.
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+std::vector v2;
+v2.reserve(3);
+// CHECK-FIXES: v.reserve(10);
+for (int i = 0; i < 10; ++i)
+  v.push_back(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size());
+for (size_t i = 0; i < t.size(); ++i) {
+  v.push_back(t[i]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES: v.reserve(t.size() - 1);
+for (size_t i = 0; i < t.size() - 1; ++i) {
+  v.push_back(t[i]);
+} // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
+  }
+
+  //  Non-fixed Cases 
+  {
+std::vector v;
+v.reserve(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a "reserve" call already.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+v.reserve(5);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a "reserve" call already.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+v.resize(5);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a ref usage of v before the loop.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+v.push_back(0);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a ref usage of v before the loop.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+f(v);
+// CHECK-FIXES-NOT: v.reserve(10);
+// There is a ref usage of v before the loop.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v(20);
+// CHECK-FIXES-NOT: v.reserve(10);
+// v is not constructed with default constructor.
+for (int i = 0; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop is not started with 0.
+for (int i = 1; i < 10; ++i) {
+  v.push_back(i);
+}
+  }
+  {
+std::vector v;
+// CHECK-FIXES-NOT: v.reserve(t.size());
+// v isn't referenced in for-loop body.
+for (size_t i = 0; i < t.size(); ++i) {
+  t.push_back(i);
+}
+  }
+  {
+std::vector v;
+int k;
+// CHECK-FIXES-NOT: v.reserve(10);
+// For-loop isn't a fixable loop.
+for (size_t i = 0; k < 10; ++i) {
+  v.push_back(t[i]);
+}
+  }
+  {
+std::vector v;
+/

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the comments.




Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:81
+  hasLoopInit(LoopVarInit),
+  hasCondition(binaryOperator(hasOperatorName("<"),
+  hasLHS(RefersToLoopVar),

aaron.ballman wrote:
> Perhaps you could support other comparisons, but not attempt to generate a 
> fix-it for them? It seems odd that this would trigger for `<` but not `<=`, 
> but I can see why you'd not want to figure out the reserve call for `!(foo >= 
> 10)`.
We could support other comparisons in the future. I think it is a good start to 
just support `<` in the first version as `<` usage happens more frequently than 
other comparisons.

Added a fixme.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:83
+  hasLHS(RefersToLoopVar),
+  hasRHS(expr().bind(LoopEndExprName,
+  hasIncrement(unaryOperator(hasOperatorName("++"),

aaron.ballman wrote:
> Thinking out loud, but, what happens if the loop end expression has some 
> hidden complexity to it? e.g.,
> ```
> for (int i = 0; i < i + 1; ++i) { // This is a "creative" loop.
>   v.push_back(i);
> }
> ```
Good point. It will copy the expr "i+1" to "reserve" parameter. This kind of 
case should not be existed, but it is safer to filter out this case.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:95-96
+const MatchFinder::MatchResult &Result) {
+  if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
+return;
+

aaron.ballman wrote:
> We don't usually add this test in to our check calls; why are you adding it 
> here?
It will prevent some unexpected things happened when the translation unit fails 
to compile.

We had a few experiences before. We encountered some misbehavior of some checks 
(e.g. https://reviews.llvm.org/rL294578) with a non-compilable TU, and then we 
added this statement to avoid the misbehavior.



https://reviews.llvm.org/D31757



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-04-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 95175.
gtbercea added a comment.

Use the rename() utility function of LLVM for renaming the PTXAS output before 
invoking NVLINK.


Repository:
  rL LLVM

https://reviews.llvm.org/D29654

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -590,6 +590,16 @@
 
 /// ###
 
+/// Check cubin file generation and usage by nvlink
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
+
+// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" "{{.*}}-openmp-nvptx64-nvidia-cuda.o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} "openmp-offload-openmp-nvptx64-nvidia-cuda.cubin"
+
+/// ###
+
 /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -203,131 +203,6 @@
   // The types are (hopefully) good enough.
 }
 
-/// Add OpenMP linker script arguments at the end of the argument list so that
-/// the fat binary is built by embedding each of the device images into the
-/// host. The linker script also defines a few symbols required by the code
-/// generation so that the images can be easily retrieved at runtime by the
-/// offloading library. This should be used only in tool chains that support
-/// linker scripts.
-static void AddOpenMPLinkerScript(const ToolChain &TC, Compilation &C,
-  const InputInfo &Output,
-  const InputInfoList &Inputs,
-  const ArgList &Args, ArgStringList &CmdArgs,
-  const JobAction &JA) {
-
-  // If this is not an OpenMP host toolchain, we don't need to do anything.
-  if (!JA.isHostOffloading(Action::OFK_OpenMP))
-return;
-
-  // Create temporary linker script. Keep it if save-temps is enabled.
-  const char *LKS;
-  SmallString<256> Name = llvm::sys::path::filename(Output.getFilename());
-  if (C.getDriver().isSaveTempsEnabled()) {
-llvm::sys::path::replace_extension(Name, "lk");
-LKS = C.getArgs().MakeArgString(Name.c_str());
-  } else {
-llvm::sys::path::replace_extension(Name, "");
-Name = C.getDriver().GetTemporaryPath(Name, "lk");
-LKS = C.addTempFile(C.getArgs().MakeArgString(Name.c_str()));
-  }
-
-  // Add linker script option to the command.
-  CmdArgs.push_back("-T");
-  CmdArgs.push_back(LKS);
-
-  // Create a buffer to write the contents of the linker script.
-  std::string LksBuffer;
-  llvm::raw_string_ostream LksStream(LksBuffer);
-
-  // Get the OpenMP offload tool chains so that we can extract the triple
-  // associated with each device input.
-  auto OpenMPToolChains = C.getOffloadToolChains();
-  assert(OpenMPToolChains.first != OpenMPToolChains.second &&
- "No OpenMP toolchains??");
-
-  // Track the input file name and device triple in order to build the script,
-  // inserting binaries in the designated sections.
-  SmallVector, 8> InputBinaryInfo;
-
-  // Add commands to embed target binaries. We ensure that each section and
-  // image is 16-byte aligned. This is not mandatory, but increases the
-  // likelihood of data to be aligned with a cache block in several main host
-  // machines.
-  LksStream << "/*\n";
-  LksStream << "   OpenMP Offload Linker Script\n";
-  LksStream << " *** Automatically generated by Clang ***\n";
-  LksStream << "*/\n";
-  LksStream << "TARGET(binary)\n";
-  auto DTC = OpenMPToolChains.first;
-  for (auto &II : Inputs) {
-const Action *A = II.getAction();
-// Is this a device linking action?
-if (A && isa(A) &&
-A->isDeviceOffloading(Action::OFK_OpenMP)) {
-  assert(DTC != OpenMPToolChains.second &&
- "More device inputs than device toolchains??");
-  InputBinaryInfo.push_back(std::make_pair(
-  DTC->second->getTriple().normalize(), II.getFilename()));
-  ++DTC;
-  LksStream << "INPUT(" << II.getFilename() << ")\n";
-}
-  }
-
-  assert(DTC == OpenMPToolChains.second 

[PATCH] D25383: [libcxx][modules] Add a submodule for math.h

2017-04-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno abandoned this revision.
bruno added a comment.

This isn't needed anymore.


https://reviews.llvm.org/D25383



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


[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-04-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 4 inline comments as done.
gtbercea added inline comments.



Comment at: test/Driver/openmp-offload.c:594
+/// Check cubin file generation and usage by nvlink
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s

rnk wrote:
> In this case, it would be nicer if you arranged for ptxas to output to a 
> .cubin file.
@rnk I'm not sure what you mean by this comment, can you please clarify?


Repository:
  rL LLVM

https://reviews.llvm.org/D29654



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


r300231 - Follow-up to r300225: update ClangFormat.csproj too

2017-04-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Apr 13 13:15:00 2017
New Revision: 300231

URL: http://llvm.org/viewvc/llvm-project?rev=300231&view=rev
Log:
Follow-up to r300225: update ClangFormat.csproj too

Modified:
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj?rev=300231&r1=300230&r2=300231&view=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.csproj Thu Apr 13 
13:15:00 2017
@@ -14,7 +14,7 @@
 true
 Key.snk
 v4.0
-14.0
+15.0
 
 
 


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


[PATCH] D31717: CodeGen: Let lifetime intrinsic use alloca address space

2017-04-13 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: test/CodeGenOpenCL/lifetime.cl:14
+// AMDGIZ: @llvm.lifetime.start.p5i
+  helper_no_markers();
+}

Check line for the end as well?


https://reviews.llvm.org/D31717



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


[libcxx] r300232 - Remove the binders from C++17. Reviewed as https://reviews.llvm.org/D31769

2017-04-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr 13 13:25:32 2017
New Revision: 300232

URL: http://llvm.org/viewvc/llvm-project?rev=300232&view=rev
Log:
Remove the binders from C++17. Reviewed as https://reviews.llvm.org/D31769

Added:
libcxx/trunk/test/libcxx/depr/depr.function.objects/
libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors/

libcxx/trunk/test/libcxx/depr/depr.function.objects/depr.adaptors.cxx1z.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref1.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_ref_t.cxx1z.fail.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun_t.cxx1z.fail.cpp
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/functional

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_binary_function.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/pointer_to_unary_function.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun1.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.function.pointer.adaptors/ptr_fun2.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_ref_t.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun1_t.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref1.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_ref_t.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/const_mem_fun_t.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adaptors/mem_fun1_ref_t.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.adaptors/depr.member.pointer.adapto

[PATCH] D31769: Remove the binders `bind1st`, `bind2nd`, `men_fun`, etc from C++17

2017-04-13 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

committed as revision 300232


https://reviews.llvm.org/D31769



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


[PATCH] D29001: [Modules] Fallback to building the module if a timeout occurs

2017-04-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno closed this revision.
bruno added a comment.

Updating: already done in r298175


https://reviews.llvm.org/D29001



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


[PATCH] D31992: [clangd] Escape only necessary characters in JSON output

2017-04-13 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

In https://reviews.llvm.org/D31992#725963, @klimek wrote:

> If I understand correctly, that's " and \ for JSON and ", \ and all 
> non-printable characters (which unfortunately requires understanding of 
> unicode to solve this fully correctly) in YAML.


I'd modify that slightly: let's escape those two and all the known ASCII 
control characters, but just pass the rest through. I.e. reduce the current \x 
etc handling to known problematic input and not second guess the rest.


Repository:
  rL LLVM

https://reviews.llvm.org/D31992



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


Re: r300122 - [clang-cl] Make all sanitizer flags available in clang-cl

2017-04-13 Thread Akira Hatanaka via cfe-commits

> On Apr 13, 2017, at 9:50 AM, Reid Kleckner  wrote:
> 
> Fixed in r300209. Was the -Wslash-u-filename warning not explanatory enough 
> to suggest the solution? Maybe we could add a note like "escape source paths 
> starting with /U by passing them at the end of the command line after —".

Ah, I see, I didn’t think it was correlated. I could have figured it out if I 
had read the warnings more carefully, but I think a note like the one you 
suggested would have been clearer.

> /Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/fsanitize.c:113:27:
>  error: expected string not found in input
> // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
>   ^
> :1:1: note: scanning from here
> clang-5.0: warning: unknown argument ignored in clang-cl: '-target' 
> [-Wunknown-argument]
> ^
> :7:89: note: possible intended match here
> clang-5.0: warning: 
> '/Users/buildslave/jenkins/sharedspace/phase1@2/llvm/tools/clang/test/Driver/fsanitize.c'
>  treated as the '/U' option [-Wslash-u-filename]
> 
> On Thu, Apr 13, 2017 at 1:12 AM, Akira Hatanaka  > wrote:
> I’m afraid I have to revert this to turn the bots green again.
> 
>> On Apr 12, 2017, at 10:41 PM, Akira Hatanaka via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> I think this broke some of the bots.
>> 
>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/30152/ 
>> 
>> 
>> Could you take a look?
>>  
>>> On Apr 12, 2017, at 3:50 PM, Reid Kleckner via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>> Author: rnk
>>> Date: Wed Apr 12 17:50:51 2017
>>> New Revision: 300122
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=300122&view=rev 
>>> 
>>> Log:
>>> [clang-cl] Make all sanitizer flags available in clang-cl
>>> 
>>> Summary:
>>> Use a tablegen let {} block so that new sanitizer flags are available by
>>> default in all driver modes. This should cut down on time wasted with
>>> bugs like http://crbug.com/710928 .
>>> 
>>> Reviewers: vitalybuka, hans
>>> 
>>> Subscribers: kcc, llvm-commits
>>> 
>>> Differential Revision: https://reviews.llvm.org/D31988 
>>> 
>>> 
>>> Modified:
>>>cfe/trunk/include/clang/Driver/Options.td
>>>cfe/trunk/test/Driver/fsanitize.c
>>> 
>>> Modified: cfe/trunk/include/clang/Driver/Options.td
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300122&r1=300121&r2=300122&view=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>>> +++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 17:50:51 2017
>>> @@ -778,65 +778,71 @@ def fno_signaling_math : Flag<["-"], "fn
>>> def fjump_tables : Flag<["-"], "fjump-tables">, Group;
>>> def fno_jump_tables : Flag<["-"], "fno-jump-tables">, Group, 
>>> Flags<[CC1Option]>,
>>>   HelpText<"Do not use jump tables for lowering switches">;
>>> +
>>> +// Begin sanitizer flags. These should all be core options exposed in all 
>>> driver
>>> +// modes.
>>> +let Flags = [CC1Option, CoreOption] in {
>>> +
>>> def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group,
>>> -   Flags<[CC1Option, CoreOption]>, MetaVarName<"">,
>>> +   MetaVarName<"">,
>>>HelpText<"Turn on runtime checks for various forms of 
>>> undefined "
>>> "or suspicious behavior. See user manual for 
>>> available checks">;
>>> def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, 
>>> Group,
>>> -  Flags<[CoreOption]>;
>>> +  Flags<[CoreOption, DriverOption]>;
>>> def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
>>> -  Group, Flags<[CC1Option, 
>>> CoreOption]>,
>>> +  Group,
>>>   HelpText<"Path to blacklist file for sanitizers">;
>>> def fno_sanitize_blacklist : Flag<["-"], "fno-sanitize-blacklist">,
>>>  Group,
>>>  HelpText<"Don't use blacklist file for 
>>> sanitizers">;
>>> def fsanitize_coverage
>>> : CommaJoined<["-"], "fsanitize-coverage=">,
>>> -  Group, Flags<[CoreOption]>,
>>> +  Group,
>>>   HelpText<"Specify the type of coverage instrumentation for 
>>> Sanitizers">;
>>> def fno_sanitize_coverage
>>> : CommaJoined<["-"], "fno-sanitize-coverage=">,
>>> -  Group, Flags<[CoreOption]>,
>>> +  Group, Flags<[CoreOption, DriverOption]>,
>>>   HelpText<"Disable specified features of coverage instrumentation for "
>>>

[PATCH] D13117: [DarwinDriver] Use -lto_library to specify the path for libLTO.dylib

2017-04-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno closed this revision.
bruno added a comment.

Done way back in r248932


Repository:
  rL LLVM

https://reviews.llvm.org/D13117



___
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

2017-04-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno closed this revision.
bruno added a comment.

r291466 & r291517


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] D27546: [ASTReader] Sort RawComments before merging

2017-04-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno closed this revision.
bruno added a comment.

Done in r290134


https://reviews.llvm.org/D27546



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


[PATCH] D31778: [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-04-13 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

@rsmith ping!


https://reviews.llvm.org/D31778



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


[PATCH] D27546: [ASTReader] Sort RawComments before merging

2017-04-13 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Serialization/ASTReader.cpp:8487
+std::sort(Comments.begin(), Comments.end(),
+  BeforeThanCompare(SourceMgr));
 Context.Comments.addDeserializedComments(Comments);

Does this cause us to deserialize the SLocEntry for every FileID referenced by 
a RawComment? That would seem pretty bad.


https://reviews.llvm.org/D27546



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


r300245 - clang-format-vs licence.txt: drop svn:executable

2017-04-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Apr 13 15:09:18 2017
New Revision: 300245

URL: http://llvm.org/viewvc/llvm-project?rev=300245&view=rev
Log:
clang-format-vs licence.txt: drop svn:executable

Not sure how it ended up with that property in the first place.

Modified:
cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt   (props changed)

Propchange: cfe/trunk/tools/clang-format-vs/ClangFormat/license.txt
--
--- svn:executable (original)
+++ svn:executable (removed)
@@ -1 +0,0 @@
-*


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


[PATCH] D31725: [libc++] Add _LIBCPP_DISABLE_EXTERN_TEMPLATE config option

2017-04-13 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 95189.
smeenai added a comment.

Add documentation


https://reviews.llvm.org/D31725

Files:
  docs/UsingLibcxx.rst
  include/__config


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -856,6 +856,11 @@
 # endif
 #endif
 
+#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#define _LIBCPP_EXTERN_TEMPLATE2(...)
+#endif
+
 #ifndef _LIBCPP_EXTERN_TEMPLATE
 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 #endif
Index: docs/UsingLibcxx.rst
===
--- docs/UsingLibcxx.rst
+++ docs/UsingLibcxx.rst
@@ -146,6 +146,11 @@
   build of libc++ which does not export any symbols, which can be useful when
   building statically for inclusion into another library.
 
+**_LIBCPP_DISABLE_EXTERN_TEMPLATE**:
+  This macro is used to disable extern template declarations in the libc++
+  headers. The intended use case is for clients who wish to use the libc++
+  headers without taking a dependency on the libc++ library itself.
+
 **_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
   This macro is used to re-enable an extension in `std::tuple` which allowed
   it to be implicitly constructed from fewer initializers than contained


Index: include/__config
===
--- include/__config
+++ include/__config
@@ -856,6 +856,11 @@
 # endif
 #endif
 
+#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#define _LIBCPP_EXTERN_TEMPLATE2(...)
+#endif
+
 #ifndef _LIBCPP_EXTERN_TEMPLATE
 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 #endif
Index: docs/UsingLibcxx.rst
===
--- docs/UsingLibcxx.rst
+++ docs/UsingLibcxx.rst
@@ -146,6 +146,11 @@
   build of libc++ which does not export any symbols, which can be useful when
   building statically for inclusion into another library.
 
+**_LIBCPP_DISABLE_EXTERN_TEMPLATE**:
+  This macro is used to disable extern template declarations in the libc++
+  headers. The intended use case is for clients who wish to use the libc++
+  headers without taking a dependency on the libc++ library itself.
+
 **_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
   This macro is used to re-enable an extension in `std::tuple` which allowed
   it to be implicitly constructed from fewer initializers than contained
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r300246 - [libc++] Add _LIBCPP_DISABLE_EXTERN_TEMPLATE config option

2017-04-13 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Apr 13 15:13:32 2017
New Revision: 300246

URL: http://llvm.org/viewvc/llvm-project?rev=300246&view=rev
Log:
[libc++] Add _LIBCPP_DISABLE_EXTERN_TEMPLATE config option

When the libc++ extern template macros were added, the intent was for it
to be possible for consumers of the headers to disable extern templates
(via `-D_LIBCPP_EXTERN_TEMPLATE(...)=`). Unfortunately, support for
specifying function-like macros varies on the command line varies across
compilers (e.g. MSVC doesn't support it at all), and cmake doesn't allow
it for the same reason. Add a non-function macro for this purpose.

The intended use is for libraries which want to use the libc++ headers
without taking a dependency on the libc++ library itself. I can name the
macro something which reflects its intent rather than its behavior (e.g.
`_LIBCPP_HEADER_ONLY`) if desired.

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

Modified:
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/__config

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=300246&r1=300245&r2=300246&view=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Thu Apr 13 15:13:32 2017
@@ -146,6 +146,11 @@ thread safety annotations.
   build of libc++ which does not export any symbols, which can be useful when
   building statically for inclusion into another library.
 
+**_LIBCPP_DISABLE_EXTERN_TEMPLATE**:
+  This macro is used to disable extern template declarations in the libc++
+  headers. The intended use case is for clients who wish to use the libc++
+  headers without taking a dependency on the libc++ library itself.
+
 **_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
   This macro is used to re-enable an extension in `std::tuple` which allowed
   it to be implicitly constructed from fewer initializers than contained

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=300246&r1=300245&r2=300246&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Apr 13 15:13:32 2017
@@ -856,6 +856,11 @@ template  struct __static_asse
 # endif
 #endif
 
+#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#define _LIBCPP_EXTERN_TEMPLATE2(...)
+#endif
+
 #ifndef _LIBCPP_EXTERN_TEMPLATE
 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 #endif


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


[PATCH] D31725: [libc++] Add _LIBCPP_DISABLE_EXTERN_TEMPLATE config option

2017-04-13 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300246: [libc++] Add _LIBCPP_DISABLE_EXTERN_TEMPLATE config 
option (authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D31725?vs=95189&id=95190#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31725

Files:
  libcxx/trunk/docs/UsingLibcxx.rst
  libcxx/trunk/include/__config


Index: libcxx/trunk/docs/UsingLibcxx.rst
===
--- libcxx/trunk/docs/UsingLibcxx.rst
+++ libcxx/trunk/docs/UsingLibcxx.rst
@@ -146,6 +146,11 @@
   build of libc++ which does not export any symbols, which can be useful when
   building statically for inclusion into another library.
 
+**_LIBCPP_DISABLE_EXTERN_TEMPLATE**:
+  This macro is used to disable extern template declarations in the libc++
+  headers. The intended use case is for clients who wish to use the libc++
+  headers without taking a dependency on the libc++ library itself.
+
 **_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
   This macro is used to re-enable an extension in `std::tuple` which allowed
   it to be implicitly constructed from fewer initializers than contained
Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -856,6 +856,11 @@
 # endif
 #endif
 
+#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#define _LIBCPP_EXTERN_TEMPLATE2(...)
+#endif
+
 #ifndef _LIBCPP_EXTERN_TEMPLATE
 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 #endif


Index: libcxx/trunk/docs/UsingLibcxx.rst
===
--- libcxx/trunk/docs/UsingLibcxx.rst
+++ libcxx/trunk/docs/UsingLibcxx.rst
@@ -146,6 +146,11 @@
   build of libc++ which does not export any symbols, which can be useful when
   building statically for inclusion into another library.
 
+**_LIBCPP_DISABLE_EXTERN_TEMPLATE**:
+  This macro is used to disable extern template declarations in the libc++
+  headers. The intended use case is for clients who wish to use the libc++
+  headers without taking a dependency on the libc++ library itself.
+
 **_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
   This macro is used to re-enable an extension in `std::tuple` which allowed
   it to be implicitly constructed from fewer initializers than contained
Index: libcxx/trunk/include/__config
===
--- libcxx/trunk/include/__config
+++ libcxx/trunk/include/__config
@@ -856,6 +856,11 @@
 # endif
 #endif
 
+#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE
+#define _LIBCPP_EXTERN_TEMPLATE(...)
+#define _LIBCPP_EXTERN_TEMPLATE2(...)
+#endif
+
 #ifndef _LIBCPP_EXTERN_TEMPLATE
 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29401: Fix MSVC Compatibility around dependent type with missing 'typename'

2017-04-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane abandoned this revision.
erichkeane added a comment.

I don't really see a good solution for this, and haven't tried in a while, so 
I'll see if I can prep another version of this in the future.


https://reviews.llvm.org/D29401



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


[PATCH] D32035: [OpenMP] Error when trying to offload to an unsupported architecture

2017-04-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 95198.
gtbercea added a comment.

Re-use an already existing flag rather than creating a new one.


Repository:
  rL LLVM

https://reviews.llvm.org/D32035

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/target_messages.cpp


Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -4,6 +4,8 @@
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx64-nvidia-cuda -o - %s 
2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 
2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target 
'{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host 
target.
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu 
-o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s
+// CHECK-UNSUPPORTED-DEVICE-TARGET: OpenMP target is invalid: 
'hexagon-linux-gnu'
 
 void foo() {
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2239,6 +2239,16 @@
 for (unsigned i = 0; i < A->getNumValues(); ++i) {
   llvm::Triple TT(A->getValue(i));
 
+  if (!(TT.getArch() == llvm::Triple::ppc ||
+TT.getArch() == llvm::Triple::ppc64 ||
+TT.getArch() == llvm::Triple::ppc64le ||
+TT.getArch() == llvm::Triple::nvptx ||
+TT.getArch() == llvm::Triple::nvptx64 ||
+TT.getArch() == llvm::Triple::x86 ||
+TT.getArch() == llvm::Triple::x86_64))
+Diags.Report(clang::diag::err_drv_invalid_omp_target)
+<< A->getValue(i);
+
   if (TT.getArch() == llvm::Triple::UnknownArch)
 Diags.Report(clang::diag::err_drv_invalid_omp_target) << 
A->getValue(i);
   else


Index: test/OpenMP/target_messages.cpp
===
--- test/OpenMP/target_messages.cpp
+++ test/OpenMP/target_messages.cpp
@@ -4,6 +4,8 @@
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx64-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s
 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target '{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host target.
+// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s
+// CHECK-UNSUPPORTED-DEVICE-TARGET: OpenMP target is invalid: 'hexagon-linux-gnu'
 
 void foo() {
 }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2239,6 +2239,16 @@
 for (unsigned i = 0; i < A->getNumValues(); ++i) {
   llvm::Triple TT(A->getValue(i));
 
+  if (!(TT.getArch() == llvm::Triple::ppc ||
+TT.getArch() == llvm::Triple::ppc64 ||
+TT.getArch() == llvm::Triple::ppc64le ||
+TT.getArch() == llvm::Triple::nvptx ||
+TT.getArch() == llvm::Triple::nvptx64 ||
+TT.getArch() == llvm::Triple::x86 ||
+TT.getArch() == llvm::Triple::x86_64))
+Diags.Report(clang::diag::err_drv_invalid_omp_target)
+<< A->getValue(i);
+
   if (TT.getArch() == llvm::Triple::UnknownArch)
 Diags.Report(clang::diag::err_drv_invalid_omp_target) << A->getValue(i);
   else
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32043: [Driver] Load all necessary default sanitizer blacklists

2017-04-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

This patch removes a limitation which causes us to load at most one
default sanitizer blacklist when multiple sanitizers are enabled. E.g if
asan + cfi are enabled, and default blacklists for both sanitizers are
present, we would only load one of the blacklists.

The new behavior would be to load all available default blacklists for
enabled sanitizers.


https://reviews.llvm.org/D32043

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir/cfi_blacklist.txt
  test/Driver/fsanitize-blacklist.c


Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -20,9 +20,20 @@
 // CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" 
"-fdepfile-entry={{.*}}.second
 
 // Check that the default blacklist is not added as an extra dependency.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-DEFAULT-BLACKLIST --implicit-check-not=fdepfile-entry
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-resource-dir=%S/Inputs/resource_dir %s -### &> %t.cc1_asan
+// RUN: FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST 
--implicit-check-not=fdepfile-entry -input-file %t.cc1_asan
 // CHECK-DEFAULT-BLACKLIST: -fsanitize-blacklist={{.*}}asan_blacklist.txt
 
+// Check that default blacklists are not added unless the matching sanitizer is
+// enabled, even if the blacklist exists.
+// RUN: FileCheck %s --implicit-check-not=cfi_blacklist.txt -input-file 
%t.cc1_asan
+
+// Check that we can add multiple default blacklists if the matching sanitizers
+// are enabled.
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,cfi -flto 
-fvisibility=hidden -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | 
FileCheck %s --check-prefix=MULTIPLE-DEFAULT-BLACKLISTS
+// MULTIPLE-DEFAULT-BLACKLISTS-DAG: 
-fsanitize-blacklist={{.*}}asan_blacklist.txt
+// MULTIPLE-DEFAULT-BLACKLISTS-DAG: 
-fsanitize-blacklist={{.*}}cfi_blacklist.txt
+
 // Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-blacklist=%t.good %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE --check-prefix=DELIMITERS
 // CHECK-NO-SANITIZE-NOT: -fsanitize-blacklist
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -85,27 +85,24 @@
 /// Sanitizers set.
 static std::string toString(const clang::SanitizerSet &Sanitizers);
 
-static bool getDefaultBlacklist(const Driver &D, SanitizerMask Kinds,
-std::string &BLPath) {
-  const char *BlacklistFile = nullptr;
-  if (Kinds & Address)
-BlacklistFile = "asan_blacklist.txt";
-  else if (Kinds & Memory)
-BlacklistFile = "msan_blacklist.txt";
-  else if (Kinds & Thread)
-BlacklistFile = "tsan_blacklist.txt";
-  else if (Kinds & DataFlow)
-BlacklistFile = "dfsan_abilist.txt";
-  else if (Kinds & CFI)
-BlacklistFile = "cfi_blacklist.txt";
-
-  if (BlacklistFile) {
+/// Add default blacklists from the resource directory.
+static void findDefaultBlacklists(const Driver &D, SanitizerMask Kinds,
+  std::vector &BlacklistFiles) {
+  const std::pair DefaultBlacklists[] = {
+  {Address, "asan_blacklist.txt"},
+  {Memory, "msan_blacklist.txt"},
+  {Thread, "tsan_blacklist.txt"},
+  {DataFlow, "dfsan_abilist.txt"},
+  {CFI, "cfi_blacklist.txt"}};
+  for (const auto &BL : DefaultBlacklists) {
+if (!(Kinds & BL.first))
+  continue;
+
 clang::SmallString<64> Path(D.ResourceDir);
-llvm::sys::path::append(Path, BlacklistFile);
-BLPath = Path.str();
-return true;
+llvm::sys::path::append(Path, BL.second);
+if (llvm::sys::fs::exists(Path))
+  BlacklistFiles.push_back(Path.str());
   }
-  return false;
 }
 
 /// Sets group bits for every group that has at least one representative 
already
@@ -382,12 +379,8 @@
   TrappingKinds &= Kinds;
 
   // Setup blacklist files.
-  // Add default blacklist from resource directory.
-  {
-std::string BLPath;
-if (getDefaultBlacklist(D, Kinds, BLPath) && llvm::sys::fs::exists(BLPath))
-  BlacklistFiles.push_back(BLPath);
-  }
+  findDefaultBlacklists(D, Kinds, BlacklistFiles);
+
   // Parse -f(no-)sanitize-blacklist options.
   for (const auto *Arg : Args) {
 if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {


Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -20,9 +20,20 @@
 // CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" "-fdepfile-entry={{.*}}.second
 
 // Check that the default blacklist is not added as an extra dependency.
-// RUN: %clang -tar

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

2017-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:95-96
+const MatchFinder::MatchResult &Result) {
+  if (Result.Context->getDiagnostics().hasUncompilableErrorOccurred())
+return;
+

hokein wrote:
> aaron.ballman wrote:
> > We don't usually add this test in to our check calls; why are you adding it 
> > here?
> It will prevent some unexpected things happened when the translation unit 
> fails to compile.
> 
> We had a few experiences before. We encountered some misbehavior of some 
> checks (e.g. https://reviews.llvm.org/rL294578) with a non-compilable TU, and 
> then we added this statement to avoid the misbehavior.
> 
I think that this should be moved up into whatever layer calls check(), because 
it does not seem like the checks are actually valid if the TU has had a fatal 
error. However, that doesn't have to be part of this patch.



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:109-111
+  auto AllVectorVarRefs = utils::decl_ref_expr::allDeclRefExprs(
+  *VectorVarDecl, *LoopParent, *Result.Context);
+  for (const auto *Ref : AllVectorVarRefs) {

aaron.ballman wrote:
> I'm not certain what types are being used here. Can you turn 
> `AllVectorVarRefs` into something with an explicit type so that I can know 
> what `Ref`'s type is?
I may not have been clear -- I don't mean that the variable name should contain 
type information, I mean that the type should not be automatically deduced. We 
only use `auto` when the type is spelled explicitly in the initialization or is 
otherwise obvious from context (like range-based for loops).


https://reviews.llvm.org/D31757



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


[PATCH] D32047: [Driver] Add support for default UBSan blacklists

2017-04-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

Clang should look for a default UBSan blacklist in its resource dir.

Depends on https://reviews.llvm.org/D32043.


https://reviews.llvm.org/D32047

Files:
  lib/Driver/SanitizerArgs.cpp
  test/Driver/Inputs/resource_dir/ubsan_blacklist.txt
  test/Driver/fsanitize-blacklist.c


Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -30,9 +30,10 @@
 
 // Check that we can add multiple default blacklists if the matching sanitizers
 // are enabled.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,cfi -flto 
-fvisibility=hidden -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | 
FileCheck %s --check-prefix=MULTIPLE-DEFAULT-BLACKLISTS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,cfi,undefined -flto 
-fvisibility=hidden -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | 
FileCheck %s --check-prefix=MULTIPLE-DEFAULT-BLACKLISTS
 // MULTIPLE-DEFAULT-BLACKLISTS-DAG: 
-fsanitize-blacklist={{.*}}asan_blacklist.txt
 // MULTIPLE-DEFAULT-BLACKLISTS-DAG: 
-fsanitize-blacklist={{.*}}cfi_blacklist.txt
+// MULTIPLE-DEFAULT-BLACKLISTS-DAG: 
-fsanitize-blacklist={{.*}}ubsan_blacklist.txt
 
 // Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-blacklist=%t.good %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE --check-prefix=DELIMITERS
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -93,7 +93,8 @@
   {Memory, "msan_blacklist.txt"},
   {Thread, "tsan_blacklist.txt"},
   {DataFlow, "dfsan_abilist.txt"},
-  {CFI, "cfi_blacklist.txt"}};
+  {CFI, "cfi_blacklist.txt"},
+  {Undefined | Integer | Nullability, "ubsan_blacklist.txt"}};
   for (const auto &BL : DefaultBlacklists) {
 if (!(Kinds & BL.first))
   continue;


Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -30,9 +30,10 @@
 
 // Check that we can add multiple default blacklists if the matching sanitizers
 // are enabled.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,cfi -flto -fvisibility=hidden -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=MULTIPLE-DEFAULT-BLACKLISTS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address,cfi,undefined -flto -fvisibility=hidden -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=MULTIPLE-DEFAULT-BLACKLISTS
 // MULTIPLE-DEFAULT-BLACKLISTS-DAG: -fsanitize-blacklist={{.*}}asan_blacklist.txt
 // MULTIPLE-DEFAULT-BLACKLISTS-DAG: -fsanitize-blacklist={{.*}}cfi_blacklist.txt
+// MULTIPLE-DEFAULT-BLACKLISTS-DAG: -fsanitize-blacklist={{.*}}ubsan_blacklist.txt
 
 // Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-blacklist=%t.good %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE --check-prefix=DELIMITERS
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -93,7 +93,8 @@
   {Memory, "msan_blacklist.txt"},
   {Thread, "tsan_blacklist.txt"},
   {DataFlow, "dfsan_abilist.txt"},
-  {CFI, "cfi_blacklist.txt"}};
+  {CFI, "cfi_blacklist.txt"},
+  {Undefined | Integer | Nullability, "ubsan_blacklist.txt"}};
   for (const auto &BL : DefaultBlacklists) {
 if (!(Kinds & BL.first))
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30837: [libcxx] Support for shared_ptr

2017-04-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 95210.
erik.pilkington added a comment.

This new patch includes @EricWF's static_assert & test.
Thanks,
Erik


https://reviews.llvm.org/D30837

Files:
  include/memory
  
test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp

Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -45,6 +45,13 @@
 virtual ~Foo() = default;
 };
 
+struct Result {};
+static Result theFunction() { return Result(); }
+static int resultDeletorCount;
+static void resultDeletor(Result (*pf)()) {
+  assert(pf == theFunction);
+  ++resultDeletorCount;
+}
 
 int main()
 {
@@ -65,7 +72,11 @@
 std::shared_ptr p2 = std::make_shared();
 assert(p2.get());
 }
-
+{ // https://bugs.llvm.org/show_bug.cgi?id=27566
+  std::shared_ptr x(&theFunction, &resultDeletor);
+  std::shared_ptr y(theFunction, resultDeletor);
+}
+assert(resultDeletorCount == 2);
 #if TEST_STD_VER >= 11
 nc = globalMemCounter.outstanding_new;
 {
Index: test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
===
--- test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
+++ test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
@@ -0,0 +1,40 @@
+#include 
+
+template  struct Tag {};
+
+template 
+using SPtr = std::shared_ptr)>;
+
+template 
+using FnType = void(Tag);
+
+template 
+void TestFn(Tag) {}
+
+template 
+FnType* getFn() {
+  return &TestFn;
+}
+
+struct Deleter {
+  template 
+  void operator()(Tp) const {
+using RawT = typename std::remove_pointer::type;
+static_assert(std::is_function::value ||
+  std::is_null_pointer::value, "");
+  }
+};
+
+int main() {
+  {
+SPtr<0> s; // OK
+SPtr<1> s1(nullptr); // OK
+SPtr<2> s2(getFn<2>(), Deleter{}); // OK
+SPtr<3> s3(nullptr, Deleter{}); // OK
+  }
+  // expected-error@memory:* 2 {{static_assert failed "default_delete cannot be instantiated for function types"}}
+  {
+SPtr<4> s4(getFn<4>()); // expected-note {{requested here}}
+SPtr<5> s5(getFn<5>(), std::default_delete>{}); // expected-note {{requested here}}
+  }
+}
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -2274,6 +2274,8 @@
 template 
 struct _LIBCPP_TEMPLATE_VIS default_delete
 {
+static_assert(!is_function<_Tp>::value,
+  "default_delete cannot be instantiated for function types");
 #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
 #else
@@ -3493,6 +3495,17 @@
 __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
+struct __shared_ptr_dummy_rebind_allocator_type;
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{
+template 
+struct rebind
+{
+typedef allocator<_Other> other;
+};
+};
+
 template class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
 
 template
@@ -3761,6 +3774,17 @@
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 private:
+template ::value>
+struct __shared_ptr_default_allocator
+{
+typedef allocator<_Yp> type;
+};
+
+template 
+struct __shared_ptr_default_allocator<_Yp, true>
+{
+typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type;
+};
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3776,8 +3800,7 @@
 }
 }
 
-_LIBCPP_INLINE_VISIBILITY
-void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {}
+_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}
 
 template  friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
 template  friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
@@ -3808,8 +3831,9 @@
 : __ptr_(__p)
 {
 unique_ptr<_Yp> __hold(__p);
-typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT());
 __hold.release();
 __enable_weak_this(__p, __p);

[PATCH] D30837: [libcxx] Support for shared_ptr

2017-04-13 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: include/memory:3606
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{

EricWF wrote:
> I would prefer using an entirely different allocator type, not a 
> specialization of `std::allocator`. 
> 
> Re-naming this class to `__shared_ptr_dummy_rebind_allocator` and moving it 
> closer to `__shared_ptr_default_allocator` would be  good.
Unfortunately, for this approach to work we have to specialize `std::allocator` 
because we use the `template  allocator(const allocator<_Up> &)` 
constructor at `__shared_ptr_pointer::__on_zero_shared_weak`. 

If specializing `std::allocator` is a problem, I suppose we could pass in a 
special entirely empty struct as an "allocator" to `__shared_ptr_pointer` when 
necessary, then metaprogram our way out of using the converting constructor at 
`__shared_ptr_ptr::__on_zero_shared_weak`. I think the current approach is 
simpler though.


https://reviews.llvm.org/D30837



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


[PATCH] D31591: Fix a bug which access nullptr and cause segmentation fault

2017-04-13 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.

LGTM.


https://reviews.llvm.org/D31591



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


r300257 - [CMake] Support building Fuchsia toolchain on Darwin

2017-04-13 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Apr 13 16:09:42 2017
New Revision: 300257

URL: http://llvm.org/viewvc/llvm-project?rev=300257&view=rev
Log:
[CMake] Support building Fuchsia toolchain on Darwin

This is already supported on Linux but on Darwin it requires some
extra flags.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=300257&r1=300256&r2=300257&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Thu Apr 13 16:09:42 2017
@@ -19,6 +19,10 @@ if(NOT APPLE)
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 endif()
 
+if(APPLE)
+  set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
+endif()
+
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")

Modified: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=300257&r1=300256&r2=300257&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Thu Apr 13 16:09:42 2017
@@ -19,6 +19,12 @@ if(NOT APPLE)
   set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
 endif()
 
+if(APPLE)
+  set(COMPILER_RT_ENABLE_IOS OFF CACHE BOOL "")
+  set(COMPILER_RT_ENABLE_TVOS OFF CACHE BOOL "")
+  set(COMPILER_RT_ENABLE_WATCHOS OFF CACHE BOOL "")
+endif()
+
 set(CLANG_BOOTSTRAP_TARGETS
   check-all
   check-llvm


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


[libcxx] r300261 - [libcxx] Direct support for Fuchsia

2017-04-13 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Apr 13 16:29:21 2017
New Revision: 300261

URL: http://llvm.org/viewvc/llvm-project?rev=300261&view=rev
Log:
[libcxx] Direct support for Fuchsia

Fuchsia's libc was forked from musl, but has evolved sufficiently
since then so it no longer makes sense to pretend it's musl. This
change implements direct support for Fuchsia rather than
piggybacking on musl support.

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

Added:
libcxx/trunk/include/support/fuchsia/
libcxx/trunk/include/support/fuchsia/xlocale.h
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__locale

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=300261&r1=300260&r2=300261&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Apr 13 16:29:21 2017
@@ -1027,7 +1027,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #endif
 
 #if defined(__BIONIC__) || defined(__CloudABI__) ||
\
-defined(_LIBCPP_HAS_MUSL_LIBC)
+defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC)
 #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
 #endif
 

Modified: libcxx/trunk/include/__locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=300261&r1=300260&r2=300261&view=diff
==
--- libcxx/trunk/include/__locale (original)
+++ libcxx/trunk/include/__locale Thu Apr 13 16:29:21 2017
@@ -37,9 +37,11 @@
 #elif (defined(__GLIBC__) || defined(__APPLE__)  || defined(__FreeBSD__) \
 || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include 
+#elif defined(__Fuchsia__)
+# include 
 #elif defined(_LIBCPP_HAS_MUSL_LIBC)
 # include 
-#endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ 
|| __IBMCPP__
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Added: libcxx/trunk/include/support/fuchsia/xlocale.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/fuchsia/xlocale.h?rev=300261&view=auto
==
--- libcxx/trunk/include/support/fuchsia/xlocale.h (added)
+++ libcxx/trunk/include/support/fuchsia/xlocale.h Thu Apr 13 16:29:21 2017
@@ -0,0 +1,23 @@
+// -*- C++ -*-
+//===--- support/fuchsia/xlocale.h 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
+#define _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H
+
+#if defined(__Fuchsia__)
+
+#include 
+#include 
+#include 
+#include 
+
+#endif // defined(__Fuchsia__)
+
+#endif // _LIBCPP_SUPPORT_FUCHSIA_XLOCALE_H


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


[PATCH] D31885: Remove TBAA information from LValues representing union members

2017-04-13 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz updated this revision to Diff 95217.
kparzysz edited the summary of this revision.
kparzysz added a reviewer: hfinkel.
kparzysz added a comment.

Fixed the testcases (forgot to use FileCheck).


Repository:
  rL LLVM

https://reviews.llvm.org/D31885

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/union-tbaa1.c
  test/CodeGenCXX/union-tbaa2.cpp

Index: test/CodeGenCXX/union-tbaa2.cpp
===
--- /dev/null
+++ test/CodeGenCXX/union-tbaa2.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -target-cpu x86-64 -target-feature +sse4.2 -target-feature +avx -emit-llvm -o - | FileCheck %s
+
+// Testcase from llvm.org/PR32056
+
+extern "C" int printf (const char *__restrict __format, ...);
+
+typedef double __m256d __attribute__((__vector_size__(32)));
+
+static __inline __m256d __attribute__((__always_inline__, __nodebug__,
+   __target__("avx")))
+_mm256_setr_pd(double __a, double __b, double __c, double __d) {
+  return (__m256d){ __a, __b, __c, __d };
+}
+
+struct A {
+  A () {
+// Check that there is no TBAA information generated for the stores to the
+// union members:
+// CHECK: store <4 x double>
+// CHECK-NOT: tbaa
+// CHECK: store <4 x double>
+// CHECK-NOT: tbaa
+a = _mm256_setr_pd(0.0, 1.0, 2.0, 3.0);
+b = _mm256_setr_pd(4.0, 5.0, 6.0, 7.0);
+  }
+
+  const double *begin() { return c; }
+  const double *end() { return c+8; }
+
+  union {
+struct { __m256d a, b; };
+double c[8];
+  };
+};
+
+int main(int argc, char *argv[]) {
+  A a;
+  for (double value : a)
+printf("%f ", value);
+  return 0;
+}
Index: test/CodeGen/union-tbaa1.c
===
--- /dev/null
+++ test/CodeGen/union-tbaa1.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -triple hexagon-unknown-elf -O2 -emit-llvm -o - | FileCheck %s
+
+typedef union __attribute__((aligned(4))) {
+  unsigned short uh[2];
+  unsigned uw;
+} vect32;
+
+void bar(vect32 p[][2]);
+
+// CHECK-LABEL: define void @fred
+void fred(unsigned Num, int Vec[2], int *Index, int Arr[4][2]) {
+  vect32 Tmp[4][2];
+// Generate tbaa for the load of Index:
+// CHECK: load i32, i32* %Index{{.*}}tbaa
+// But no tbaa for the two stores:
+// CHECK: %uw[[UW1:[0-9]*]] = getelementptr
+// CHECK: store{{.*}}%uw[[UW1]]
+// CHECK-NOT: tbaa
+// There will be a load after the store, and it will use tbaa. Make sure
+// the check-not above doesn't find it:
+// CHECK: load
+  Tmp[*Index][0].uw = Arr[*Index][0] * Num;
+// CHECK: %uw[[UW2:[0-9]*]] = getelementptr
+// CHECK: store{{.*}}%uw[[UW2]]
+// CHECK-NOT: tbaa
+  Tmp[*Index][1].uw = Arr[*Index][1] * Num;
+// Same here, don't generate tbaa for the loads:
+// CHECK: %uh[[UH1:[0-9]*]] = bitcast %union.vect32
+// CHECK: %arrayidx[[AX1:[0-9]*]] = getelementptr{{.*}}%uh[[UH1]]
+// CHECK: load i16, i16* %arrayidx[[AX1]]
+// CHECK-NOT: tbaa
+// CHECK: store
+  Vec[0] = Tmp[*Index][0].uh[1];
+// CHECK: %uh[[UH2:[0-9]*]] = bitcast %union.vect32
+// CHECK: %arrayidx[[AX2:[0-9]*]] = getelementptr{{.*}}%uh[[UH2]]
+// CHECK: load i16, i16* %arrayidx[[AX2]]
+// CHECK-NOT: tbaa
+// CHECK: store
+  Vec[1] = Tmp[*Index][1].uh[1];
+  bar(Tmp);
+}
+
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2886,6 +2886,17 @@
   /// that the address will be used to access the object.
   LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK);
 
+private:
+  /// The actual implementations of LValue emission. As a workaround for
+  /// a problem in representing union member accesses in TBAA, the public
+  /// functions will remove the TBAA information from any LValue generated
+  /// for such an access.
+  /// When the TBAA issue is fixed, the public wrappers (declared above)
+  /// should be replaced with these functions.
+  LValue EmitLValueImpl(const Expr *E);
+  LValue EmitCheckedLValueImpl(const Expr *E, TypeCheckKind TCK);
+
+public:
   RValue convertTempToRValue(Address addr, QualType type,
  SourceLocation Loc);
 
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -980,7 +980,37 @@
   return true;
 }
 
+/// Hacks to remove TBAA information from LValues that represent union members.
+/// The TBAA in the current form does not work for union members: the aliasing
+/// information emitted in such cases may be incorrect (leading to incorrect
+/// optimizations).
+static bool isUnionAccess(const Expr *E) {
+  switch (E->getStmtClass()) {
+case Stmt::MemberExprClass: {
+  const Expr *BE = cast(E)->getBase();
+  if (BE->getType()->isUnionType())
+return true;
+  return isUnionAccess(BE);
+}
+case Stmt::ImplicitCastExprClass:
+  return isUnionAccess(cast(

r300262 - PR32185: Revert r291512 and add a testcase for PR32185.

2017-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 13 16:37:24 2017
New Revision: 300262

URL: http://llvm.org/viewvc/llvm-project?rev=300262&view=rev
Log:
PR32185: Revert r291512 and add a testcase for PR32185.

This reverts an attempt to check that types match when matching a
dependently-typed non-type template parameter. (This comes up when matching the
parameters of a template template parameter against the parameters of a
template template argument.)

The matching rules here are murky at best. Our behavior after this revert is
definitely wrong for certain C++17 features (for 'auto' template parameter
types within the parameter list of a template template argument in particular),
but our behavior before this revert is wrong for some pre-existing testcases,
so reverting to our prior behavior seems like our best option.

Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/Modules/cxx-templates.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
cfe/trunk/test/SemaTemplate/deduction.cpp
cfe/trunk/test/SemaTemplate/temp_arg_template.cpp
cfe/trunk/test/SemaTemplate/temp_arg_template_cxx1z.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=300262&r1=300261&r2=300262&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Apr 13 16:37:24 2017
@@ -2109,7 +2109,6 @@ struct DependencyChecker : RecursiveASTV
   typedef RecursiveASTVisitor super;
 
   unsigned Depth;
-  bool FindLessThanDepth;
 
   // Whether we're looking for a use of a template parameter that makes the
   // overall construct type-dependent / a dependent type. This is strictly
@@ -2120,16 +2119,25 @@ struct DependencyChecker : RecursiveASTV
   bool Match;
   SourceLocation MatchLoc;
 
-  DependencyChecker(unsigned Depth, bool IgnoreNonTypeDependent,
-bool FindLessThanDepth = false)
-  : Depth(Depth), FindLessThanDepth(FindLessThanDepth),
-IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(false) {}
+  DependencyChecker(unsigned Depth, bool IgnoreNonTypeDependent)
+  : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
+Match(false) {}
 
   DependencyChecker(TemplateParameterList *Params, bool IgnoreNonTypeDependent)
-  : DependencyChecker(Params->getDepth(), IgnoreNonTypeDependent) {}
+  : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(false) {
+NamedDecl *ND = Params->getParam(0);
+if (TemplateTypeParmDecl *PD = dyn_cast(ND)) {
+  Depth = PD->getDepth();
+} else if (NonTypeTemplateParmDecl *PD =
+ dyn_cast(ND)) {
+  Depth = PD->getDepth();
+} else {
+  Depth = cast(ND)->getDepth();
+}
+  }
 
   bool Matches(unsigned ParmDepth, SourceLocation Loc = SourceLocation()) {
-if (FindLessThanDepth ^ (ParmDepth >= Depth)) {
+if (ParmDepth >= Depth) {
   Match = true;
   MatchLoc = Loc;
   return true;
@@ -6432,15 +6440,6 @@ Sema::BuildExpressionFromIntegralTemplat
   return E;
 }
 
-static bool isDependentOnOuter(NonTypeTemplateParmDecl *NTTP) {
-  if (NTTP->getDepth() == 0 || !NTTP->getType()->isDependentType())
-return false;
-  DependencyChecker Checker(NTTP->getDepth(), /*IgnoreNonTypeDependent*/ false,
-/*FindLessThanDepth*/ true);
-  Checker.TraverseType(NTTP->getType());
-  return Checker.Match;
-}
-
 /// \brief Match two template parameters within template parameter lists.
 static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old,
bool Complain,
@@ -6497,10 +6496,11 @@ static bool MatchTemplateParameterKind(S
 
 // If we are matching a template template argument to a template
 // template parameter and one of the non-type template parameter types
-// is dependent on an outer template's parameter, then we must wait until
-// template instantiation time to actually compare the arguments.
+// is dependent, then we must wait until template instantiation time
+// to actually compare the arguments.
 if (Kind == Sema::TPL_TemplateTemplateArgumentMatch &&
-(isDependentOnOuter(OldNTTP) || isDependentOnOuter(NewNTTP)))
+(OldNTTP->getType()->isDependentType() ||
+ NewNTTP->getType()->isDependentType()))
   return true;
 
 if (!S.Context.hasSameType(OldNTTP->getType(), NewNTTP->getType())) {

Modified: cfe/trunk/test/Modules/cxx-templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-templates.cpp?rev=300262&r1=300261&r2=300262&view=diff
==
--- cfe/trunk/test/Modules/cxx-templates.cpp (original)
+++ cfe/trunk/test/Modules/cxx-templates.cpp Thu Apr 13 16:37:24 2017
@@ -49,8 +49,14 @@ void g() {
   // expected-note@Inputs/cxx-templat

[PATCH] D32014: Remove unused varible

2017-04-13 Thread Wei-Ren Chen via Phabricator via cfe-commits
chenwj added a comment.

I don't have commit access, need someone's help.  :-)


https://reviews.llvm.org/D32014



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


r300264 - Diagnose attempt to take address of bitfield members in anonymous structs.

2017-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 13 16:49:46 2017
New Revision: 300264

URL: http://llvm.org/viewvc/llvm-project?rev=300264&view=rev
Log:
Diagnose attempt to take address of bitfield members in anonymous structs.

Patch by Jacob Young!

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

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/expr-address-of.c
cfe/trunk/test/SemaCXX/ptrtomember.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=300264&r1=300263&r2=300264&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr 13 16:49:46 2017
@@ -1772,7 +1772,10 @@ Sema::BuildDeclRefExpr(ValueDecl *D, Qua
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  if (FieldDecl *FD = dyn_cast(D)) {
+  FieldDecl *FD = dyn_cast(D);
+  if (IndirectFieldDecl *IFD = dyn_cast(D))
+FD = IFD->getAnonField();
+  if (FD) {
 UnusedPrivateFields.remove(FD);
 // Just in case we're building an illegal pointer-to-member.
 if (FD->isBitField())

Modified: cfe/trunk/test/Sema/expr-address-of.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/expr-address-of.c?rev=300264&r1=300263&r2=300264&view=diff
==
--- cfe/trunk/test/Sema/expr-address-of.c (original)
+++ cfe/trunk/test/Sema/expr-address-of.c Thu Apr 13 16:49:46 2017
@@ -102,8 +102,9 @@ char* f7() {
   register struct {char* x;} t1 = {"Hello"};
   char* dummy1 = &(t1.x[0]);
 
-  struct {int a : 10;} t2;
+  struct {int a : 10; struct{int b : 10;};} t2;
   int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}}
+  int* dummy3 = &(t2.b); // expected-error {{address of bit-field requested}}
 
   void* t3 = &(*(void*)0);
 }

Modified: cfe/trunk/test/SemaCXX/ptrtomember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ptrtomember.cpp?rev=300264&r1=300263&r2=300264&view=diff
==
--- cfe/trunk/test/SemaCXX/ptrtomember.cpp (original)
+++ cfe/trunk/test/SemaCXX/ptrtomember.cpp Thu Apr 13 16:49:46 2017
@@ -13,9 +13,13 @@ int foo(int S::* ps, S *s)
 
 struct S2 {
   int bitfield : 1;
+  struct {
+int anon_bitfield : 1;
+  };
 };
 
 int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field 
requested}}
+int S2::*anon_pf = &S2::anon_bitfield; // expected-error {{address of 
bit-field requested}}
 
 struct S3 {
   void m();


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


[PATCH] D27263: Address of bitfield in anonymous struct doesn't error.

2017-04-13 Thread Richard Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300264: Diagnose attempt to take address of bitfield members 
in anonymous structs. (authored by rsmith).

Changed prior to commit:
  https://reviews.llvm.org/D27263?vs=79759&id=95222#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27263

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Sema/expr-address-of.c
  cfe/trunk/test/SemaCXX/ptrtomember.cpp


Index: cfe/trunk/test/SemaCXX/ptrtomember.cpp
===
--- cfe/trunk/test/SemaCXX/ptrtomember.cpp
+++ cfe/trunk/test/SemaCXX/ptrtomember.cpp
@@ -13,9 +13,13 @@
 
 struct S2 {
   int bitfield : 1;
+  struct {
+int anon_bitfield : 1;
+  };
 };
 
 int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field 
requested}}
+int S2::*anon_pf = &S2::anon_bitfield; // expected-error {{address of 
bit-field requested}}
 
 struct S3 {
   void m();
Index: cfe/trunk/test/Sema/expr-address-of.c
===
--- cfe/trunk/test/Sema/expr-address-of.c
+++ cfe/trunk/test/Sema/expr-address-of.c
@@ -102,8 +102,9 @@
   register struct {char* x;} t1 = {"Hello"};
   char* dummy1 = &(t1.x[0]);
 
-  struct {int a : 10;} t2;
+  struct {int a : 10; struct{int b : 10;};} t2;
   int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}}
+  int* dummy3 = &(t2.b); // expected-error {{address of bit-field requested}}
 
   void* t3 = &(*(void*)0);
 }
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -1772,7 +1772,10 @@
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  if (FieldDecl *FD = dyn_cast(D)) {
+  FieldDecl *FD = dyn_cast(D);
+  if (IndirectFieldDecl *IFD = dyn_cast(D))
+FD = IFD->getAnonField();
+  if (FD) {
 UnusedPrivateFields.remove(FD);
 // Just in case we're building an illegal pointer-to-member.
 if (FD->isBitField())


Index: cfe/trunk/test/SemaCXX/ptrtomember.cpp
===
--- cfe/trunk/test/SemaCXX/ptrtomember.cpp
+++ cfe/trunk/test/SemaCXX/ptrtomember.cpp
@@ -13,9 +13,13 @@
 
 struct S2 {
   int bitfield : 1;
+  struct {
+int anon_bitfield : 1;
+  };
 };
 
 int S2::*pf = &S2::bitfield; // expected-error {{address of bit-field requested}}
+int S2::*anon_pf = &S2::anon_bitfield; // expected-error {{address of bit-field requested}}
 
 struct S3 {
   void m();
Index: cfe/trunk/test/Sema/expr-address-of.c
===
--- cfe/trunk/test/Sema/expr-address-of.c
+++ cfe/trunk/test/Sema/expr-address-of.c
@@ -102,8 +102,9 @@
   register struct {char* x;} t1 = {"Hello"};
   char* dummy1 = &(t1.x[0]);
 
-  struct {int a : 10;} t2;
+  struct {int a : 10; struct{int b : 10;};} t2;
   int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}}
+  int* dummy3 = &(t2.b); // expected-error {{address of bit-field requested}}
 
   void* t3 = &(*(void*)0);
 }
Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -1772,7 +1772,10 @@
   !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
   recordUseOfEvaluatedWeak(E);
 
-  if (FieldDecl *FD = dyn_cast(D)) {
+  FieldDecl *FD = dyn_cast(D);
+  if (IndirectFieldDecl *IFD = dyn_cast(D))
+FD = IFD->getAnonField();
+  if (FD) {
 UnusedPrivateFields.remove(FD);
 // Just in case we're building an illegal pointer-to-member.
 if (FD->isBitField())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300266 - Add test for anonymous struct containing an implicitly private data member.

2017-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 13 16:51:04 2017
New Revision: 300266

URL: http://llvm.org/viewvc/llvm-project?rev=300266&view=rev
Log:
Add test for anonymous struct containing an implicitly private data member.

Patch by Jacob Young!

Modified:
cfe/trunk/test/SemaCXX/anonymous-struct.cpp

Modified: cfe/trunk/test/SemaCXX/anonymous-struct.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/anonymous-struct.cpp?rev=300266&r1=300265&r2=300266&view=diff
==
--- cfe/trunk/test/SemaCXX/anonymous-struct.cpp (original)
+++ cfe/trunk/test/SemaCXX/anonymous-struct.cpp Thu Apr 13 16:51:04 2017
@@ -21,6 +21,9 @@ struct E {
   };
   static struct {
   };
+  class {
+int anon_priv_field; // expected-error {{anonymous struct cannot contain a 
private data member}}
+  };
 };
 
 template  void foo(T);


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


[PATCH] D27263: Address of bitfield in anonymous struct doesn't error.

2017-04-13 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

The change to test/SemaCXX/anonymous-struct.cpp appeared to be unrelated to the 
rest of the patch, so I committed it separately as r300266.

Thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D27263



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


r300270 - [docs] Fix a couple of typos in command line flag help text and regenerate documentation.

2017-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 13 17:39:49 2017
New Revision: 300270

URL: http://llvm.org/viewvc/llvm-project?rev=300270&view=rev
Log:
[docs] Fix a couple of typos in command line flag help text and regenerate 
documentation.

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=300270&r1=300269&r2=300270&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Apr 13 17:39:49 2017
@@ -198,6 +198,10 @@ Specify comma-separated list of triples
 
 .. option:: -framework 
 
+.. option:: -frtlib-add-rpath, -fno-rtlib-add-rpath
+
+Add -rpath with architecture-specific resource directory to the linker flags
+
 .. option:: --gcc-toolchain=, -gcc-toolchain 
 
 Use the gcc toolchain at the given directory
@@ -238,6 +242,8 @@ Make the next included directory (-I or
 
 Run the migrator
 
+.. option:: -mios-simulator-version-min=, 
-miphonesimulator-version-min=
+
 .. option:: -mlinker-version=
 
 .. option:: -mlittle-endian, -EL
@@ -250,6 +256,8 @@ Additional arguments to forward to LLVM'
 
 Directory to dump module dependencies to
 
+.. option:: -mtvos-simulator-version-min=, 
-mappletvsimulator-version-min=
+
 .. option:: -multi\_module
 
 .. option:: -multiply\_defined 
@@ -258,6 +266,8 @@ Directory to dump module dependencies to
 .. option:: -multiply\_defined\_unused 
 .. program:: clang
 
+.. option:: -mwatchos-simulator-version-min=, 
-mwatchsimulator-version-min=
+
 .. option:: --no-cuda-version-check
 
 Don't error out if the detected version of the CUDA install is too low for the 
requested CUDA gpu architecture.
@@ -416,6 +426,10 @@ Print the library path for the currently
 
 Print the full program path of 
 
+.. option:: -print-resource-dir, --print-resource-dir
+
+Print the resource directory pathname
+
 .. option:: -print-search-dirs, --print-search-dirs
 
 Print the paths used for finding libraries and programs
@@ -678,6 +692,8 @@ Inline functions which are (explicitly o
 
 .. option:: -fno-crash-diagnostics
 
+Disable auto-generation of preprocessed source files and a script for 
reproduction during a clang crash
+
 .. option:: -fno-sanitize-blacklist
 
 Don't use blacklist file for sanitizers
@@ -872,6 +888,10 @@ Add directory to AFTER include search pa
 
 Add directory to SYSTEM framework search path
 
+.. option:: -iframeworkwithsysroot
+
+Add directory to SYSTEM framework search path, absolute paths are relative to 
-isysroot
+
 .. option:: -imacros, --imacros, --imacros=
 
 Include macros from file before parsing
@@ -1053,9 +1073,7 @@ Enable C++17 aligned allocation function
 
 .. option:: -fallow-unsupported
 
-.. option:: -maltivec, -mno-altivec
-
-Enable AltiVec vector initializer syntax
+.. option:: -faltivec, -fno-altivec
 
 .. option:: -fansi-escape-codes
 
@@ -1155,6 +1173,10 @@ Place each data in its own section (ELF
 
 Emit extra debug info to make sample profile more accurate.
 
+.. option:: -fdebug-macro, -fno-debug-macro
+
+Emit macro debug information
+
 .. option:: -fdebug-pass-arguments
 
 .. option:: -fdebug-pass-structure
@@ -1531,7 +1553,11 @@ Generate instrumented code to collect ex
 
 Use instrumentation data for profile-guided optimization
 
+.. option:: -fprofile-sample-use, -fauto-profile, -fno-profile-sample-use
+
+.. program:: clang1
 .. option:: -fprofile-sample-use=, -fauto-profile=
+.. program:: clang
 
 Enable sample-based profile guided optimizations
 
@@ -1653,7 +1679,7 @@ Enable optimizations based on the strict
 
 .. option:: -fstrict-return, -fno-strict-return
 
-Always treat control flow paths that fall off the end of a non-voidfunction as 
unreachable
+Always treat control flow paths that fall off the end of a non-void function 
as unreachable
 
 .. option:: -fstrict-vtable-pointers, -fno-strict-vtable-pointers
 
@@ -1765,6 +1791,10 @@ Treat signed integer overflow as two's c
 
 Store string literals as writable data
 
+.. option:: -fxray-always-instrument=
+
+Filename defining the whitelist for imbuing the 'always instrument' XRay 
attribute.
+
 .. option:: -fxray-instruction-threshold
 
 .. program:: clang1
@@ -1777,6 +1807,10 @@ Sets the minimum function size to instru
 
 Generate XRay instrumentation sleds on function entry and exit
 
+.. option:: -fxray-never-instrument=
+
+Filename defining the whitelist for imbuing the 'never instrument' XRay 
attribute.
+
 .. option:: -fzero-initialized-in-bss, -fno-zero-initialized-in-bss
 
 .. option:: -fzvector, -fno-zvector, -mzvector
@@ -1875,7 +1909,7 @@ Link stack frames through backchain on S
 
 .. option:: -mconsole
 
-.. option:: -mcpu=, -mv4 (equivalent to -mcpu=hexagonv4), -mv5 
(equivalent to -mcpu=hexagonv5), -mv55 (equivalent to -mcpu=hexagonv55), -mv60 
(equivalent to 

r300271 - [docs] Regenerate diagnostics reference.

2017-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 13 17:44:22 2017
New Revision: 300271

URL: http://llvm.org/viewvc/llvm-project?rev=300271&view=rev
Log:
[docs] Regenerate diagnostics reference.

Modified:
cfe/trunk/docs/DiagnosticsReference.rst

Modified: cfe/trunk/docs/DiagnosticsReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/DiagnosticsReference.rst?rev=300271&r1=300270&r2=300271&view=diff
==
--- cfe/trunk/docs/DiagnosticsReference.rst (original)
+++ cfe/trunk/docs/DiagnosticsReference.rst Thu Apr 13 17:44:22 2017
@@ -797,6 +797,23 @@ This diagnostic is enabled by default.
 
++
 
 
+-Wbitfield-enum-conversion
+--
+**Diagnostic text:**
+
++--+
+|:warning:`warning:` |nbsp| :diagtext:`bit-field` |nbsp| :placeholder:`A` 
|nbsp| :diagtext:`is not wide enough to store all enumerators of` |nbsp| 
:placeholder:`B`|
++--+
+
++--+
+|:warning:`warning:` |nbsp| :diagtext:`signed bit-field` |nbsp| 
:placeholder:`A` |nbsp| :diagtext:`needs an extra bit to represent the largest 
positive enumerators of` |nbsp| :placeholder:`B`|
++--+
+
++-+
+|:warning:`warning:` |nbsp| :diagtext:`assigning value of signed enum type` 
|nbsp| :placeholder:`B` |nbsp| :diagtext:`to unsigned bit-field` |nbsp| 
:placeholder:`A`:diagtext:`; negative enumerators of enum` |nbsp| 
:placeholder:`B` |nbsp| :diagtext:`will be converted to positive values`|
++-+
+
+
 -Wbitfield-width
 
 This diagnostic is enabled by default.
@@ -833,6 +850,8 @@ This diagnostic is enabled by default.
 
 -Wblock-capture-autoreleasing
 -
+This diagnostic is enabled by default.
+
 **Diagnostic text:**
 
 
+-+
@@ -2380,7 +2399,7 @@ This diagnostic is enabled by default.
 
 Some of the diagnostics controlled by this flag are enabled by default.
 
-Also controls `-Wbool-conversion`_, `-Wconstant-conversion`_, 
`-Wenum-conversion`_, `-Wfloat-conversion`_, `-Wint-conversion`_, 
`-Wliteral-conversion`_, `-Wnon-literal-null-conversion`_, 
`-Wnull-conversion`_, `-Wobjc-literal-conversion`_, `-Wshorten-64-to-32`_, 
`-Wsign-conversion`_, `-Wstring-conversion`_.
+Also controls `-Wbitfield-enum-conversion`_, `-Wbool-conversion`_, 
`-Wconstant-conversion`_, `-Wenum-conversion`_, `-Wfloat-conversion`_, 
`-Wint-conversion`_, `-Wliteral-conversion`_, `-Wnon-literal-null-conversion`_, 
`-Wnull-conversion`_, `-Wobjc-literal-conversion`_, `-Wshorten-64-to-32`_, 
`-Wsign-conversion`_, `-Wstring-conversion`_.
 
 **Diagnostic text:**
 
@@ -2414,6 +2433,17 @@ Also controls `-Wbool-conversion`_, `-Wc
 Synonym for `-Wnull-conversion`_.
 
 
+-Wcoroutine
+---
+This diagnostic is enabled by default.
+
+**Diagnostic text:**
+
++-+
+|:warning:`warning:` |nbsp| :placeholder:`A` |nbsp| :diagtext:`is required to 
declare the member 'unhandled\_exception()' when exceptions are enabled`|
++-+
+
+
 -Wcovered-switch-default
 
 **Diagnostic text:**
@@ -4463,6 +4493,8 @@ This diagnostic is enabled by default.
 | 

r300272 - [IR] Make getParamAttributes take argument numbers, not ArgNo+1

2017-04-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 13 18:12:13 2017
New Revision: 300272

URL: http://llvm.org/viewvc/llvm-project?rev=300272&view=rev
Log:
[IR] Make getParamAttributes take argument numbers, not ArgNo+1

Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1,
Kind) everywhere.

The fact that the AttributeList index for an argument is ArgNo+1 should
be a hidden implementation detail.

NFC

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=300272&r1=300271&r2=300272&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 13 18:12:13 2017
@@ -2953,7 +2953,7 @@ static void replaceUsesOfNonProtoConstan
   }
 
   // Add any parameter attributes.
-  newArgAttrs.push_back(oldAttrs.getParamAttributes(argNo + 1));
+  newArgAttrs.push_back(oldAttrs.getParamAttributes(argNo));
   argNo++;
 }
 if (dontTransform)


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


[PATCH] D32063: [clang-move] cleanup: create ClangMoveActionFactory on the stack

2017-04-13 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
alexshap created this object with visibility "All Users".

This diff removes unnecessary using of unique_ptr with ClangMoveActionFactory 
(pico cleanup).
NFC


Repository:
  rL LLVM

https://reviews.llvm.org/D32063

Files:
  tool/ClangMoveMain.cpp


Index: tool/ClangMoveMain.cpp
===
--- tool/ClangMoveMain.cpp
+++ tool/ClangMoveMain.cpp
@@ -127,10 +127,9 @@
   move::ClangMoveContext Context{Spec, Tool.getReplacements(),
  InitialDirectory.str(), Style, DumpDecls};
   move::DeclarationReporter Reporter;
-  auto Factory = llvm::make_unique(
-  &Context, &Reporter);
-
-  int CodeStatus = Tool.run(Factory.get());
+  move::ClangMoveActionFactory Factory(&Context, &Reporter);
+  
+  int CodeStatus = Tool.run(&Factory);
   if (CodeStatus)
 return CodeStatus;
 


Index: tool/ClangMoveMain.cpp
===
--- tool/ClangMoveMain.cpp
+++ tool/ClangMoveMain.cpp
@@ -127,10 +127,9 @@
   move::ClangMoveContext Context{Spec, Tool.getReplacements(),
  InitialDirectory.str(), Style, DumpDecls};
   move::DeclarationReporter Reporter;
-  auto Factory = llvm::make_unique(
-  &Context, &Reporter);
-
-  int CodeStatus = Tool.run(Factory.get());
+  move::ClangMoveActionFactory Factory(&Context, &Reporter);
+  
+  int CodeStatus = Tool.run(&Factory);
   if (CodeStatus)
 return CodeStatus;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32029: [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt

2017-04-13 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

Note that C++ foreach loops also generate lifetime.start and lifetime.end 
inside of the loop body.


Repository:
  rL LLVM

https://reviews.llvm.org/D32029



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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and CGOpts

2017-04-13 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis created this revision.

The linux part is a bit ahead of time - the instrumentation code where this 
matters have not landed yet. But when it does, this would be the right 
condition, and for now ELF instrumentation simply ignores this setting.


Repository:
  rL LLVM

https://reviews.llvm.org/D32064

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -132,16 +132,20 @@
 // that we add to the PassManagerBuilder.
 class PassManagerBuilderWrapper : public PassManagerBuilder {
 public:
-  PassManagerBuilderWrapper(const CodeGenOptions &CGOpts,
+  PassManagerBuilderWrapper(const Triple &TargetTriple,
+const CodeGenOptions &CGOpts,
 const LangOptions &LangOpts)
-  : PassManagerBuilder(), CGOpts(CGOpts), LangOpts(LangOpts) {}
+  : PassManagerBuilder(), TargetTriple(TargetTriple), CGOpts(CGOpts),
+LangOpts(LangOpts) {}
+  const Triple &getTargetTriple() const { return TargetTriple; }
   const CodeGenOptions &getCGOpts() const { return CGOpts; }
   const LangOptions &getLangOpts() const { return LangOpts; }
+
 private:
+  const Triple &TargetTriple;
   const CodeGenOptions &CGOpts;
   const LangOptions &LangOpts;
 };
-
 }
 
 static void addObjCARCAPElimPass(const PassManagerBuilder &Builder, 
PassManagerBase &PM) {
@@ -188,16 +192,36 @@
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 
+// Check if ASan should use GC-friendly instrumentation for globals.
+// First of all, there is no point if -fdata-sections is off (expect for MachO,
+// where this is not a factor). Also, on ELF this feature requires an assembler
+// extension that only works with -integrated-as at the moment.
+static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
+  switch (T.getObjectFormat()) {
+  case Triple::MachO:
+return true;
+  case Triple::COFF:
+return CGOpts.DataSections;
+  case Triple::ELF:
+return CGOpts.DataSections && !CGOpts.DisableIntegratedAS;
+  default:
+return false;
+  }
+}
+
 static void addAddressSanitizerPasses(const PassManagerBuilder &Builder,
   legacy::PassManagerBase &PM) {
   const PassManagerBuilderWrapper &BuilderWrapper =
   static_cast(Builder);
+  const Triple &T = BuilderWrapper.getTargetTriple();
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
   bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Address);
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
+  bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
-  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/false, Recover));
+  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/ false, Recover,
+  UseGlobalsGC));
 }
 
 static void addKernelAddressSanitizerPasses(const PassManagerBuilder &Builder,
@@ -435,16 +459,16 @@
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
-  PassManagerBuilderWrapper PMBuilder(CodeGenOpts, LangOpts);
-
   // Figure out TargetLibraryInfo.  This needs to be added to MPM and FPM
   // manually (and not via PMBuilder), since some passes (eg. InstrProfiling)
   // are inserted before PMBuilder ones - they'd get the default-constructed
   // TLI with an unknown target otherwise.
   Triple TargetTriple(TheModule->getTargetTriple());
   std::unique_ptr TLII(
   createTLII(TargetTriple, CodeGenOpts));
 
+  PassManagerBuilderWrapper PMBuilder(TargetTriple, CodeGenOpts, LangOpts);
+
   // At O0 and O1 we only run the always inliner which is more efficient. At
   // higher optimization levels we run the normal inliner.
   if (CodeGenOpts.OptimizationLevel <= 1) {


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -132,16 +132,20 @@
 // that we add to the PassManagerBuilder.
 class PassManagerBuilderWrapper : public PassManagerBuilder {
 public:
-  PassManagerBuilderWrapper(const CodeGenOptions &CGOpts,
+  PassManagerBuilderWrapper(const Triple &TargetTriple,
+const CodeGenOptions &CGOpts,
 const LangOptions &LangOpts)
-  : PassManagerBuilder(), CGOpts(CGOpts), LangOpts(LangOpts) {}
+  : PassManagerBuilder(), TargetTriple(TargetTriple), CGOpts(CGOpts),
+LangOpts(LangOpts) {}
+  const Triple &getTargetTriple() const { return TargetTriple; }
   const CodeGenOptions &getCGOpts() const { return CGOpts; }
   const LangOptions &getLangOpts() const { return LangOpts; }
+
 private:
+  const Triple &TargetTriple;
   const CodeGenOptions &CGOpts;
   const LangOptions &LangOpts;
 };
-
 }
 
 static void addObjCARCAPEl

r300279 - [Profile] PE binary coverage bug fix

2017-04-13 Thread Xinliang David Li via cfe-commits
Author: davidxl
Date: Thu Apr 13 18:37:21 2017
New Revision: 300279

URL: http://llvm.org/viewvc/llvm-project?rev=300279&view=rev
Log:
[Profile] PE binary coverage bug fix

PR/32584

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

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=300279&r1=300278&r2=300279&view=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Thu Apr 13 18:37:21 2017
@@ -966,7 +966,7 @@ bool isMachO(const CodeGenModule &CGM) {
 }
 
 StringRef getCoverageSection(const CodeGenModule &CGM) {
-  return llvm::getInstrProfCoverageSectionName(isMachO(CGM));
+  return llvm::getInstrProfCoverageSectionName(&CGM.getModule());
 }
 
 std::string normalizeFilename(StringRef Filename) {


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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and CGOpts

2017-04-13 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis added a comment.

From a quick look at the code, it seems like -fno-data-sections on COFF would 
suppress GC of globals the same as on ELF. Is that true?


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


[PATCH] D32029: [ObjC] Fix lifetime markers of loop variable in EmitObjCForCollectionStmt

2017-04-13 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.

Yes, looks good to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D32029



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


r300283 - Fix PR31934: forming refs to functions with enable_if attrs.

2017-04-13 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Thu Apr 13 18:47:08 2017
New Revision: 300283

URL: http://llvm.org/viewvc/llvm-project?rev=300283&view=rev
Log:
Fix PR31934: forming refs to functions with enable_if attrs.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/enable_if.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=300283&r1=300282&r2=300283&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Apr 13 18:47:08 2017
@@ -6684,6 +6684,19 @@ InitializationSequence::Perform(Sema &S,
   if (S.CheckExceptionSpecCompatibility(CurInit.get(), DestType))
 return ExprError();
 
+  // We don't check for e.g. function pointers here, since address
+  // availability checks should only occur when the function first decays
+  // into a pointer or reference.
+  if (CurInit.get()->getType()->isFunctionProtoType()) {
+if (auto *DRE = dyn_cast(CurInit.get()->IgnoreParens())) {
+  if (auto *FD = dyn_cast(DRE->getDecl())) {
+if (!S.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true,
+ DRE->getLocStart()))
+  return ExprError();
+  }
+}
+  }
+
   // Even though we didn't materialize a temporary, the binding may still
   // extend the lifetime of a temporary. This happens if we bind a 
reference
   // to the result of a cast to reference type.

Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=300283&r1=300282&r2=300283&view=diff
==
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Thu Apr 13 18:47:08 2017
@@ -472,3 +472,30 @@ namespace instantiate_constexpr_in_enabl
   };
   void g() { X().f(); }
 }
+
+namespace PR31934 {
+int foo(int a) __attribute__((enable_if(a, "")));
+int runFn(int (&)(int));
+
+void run() {
+  {
+int (&bar)(int) = foo; // expected-error{{cannot take address of function 
'foo'}}
+int baz = runFn(foo); // expected-error{{cannot take address of function 
'foo'}}
+  }
+
+  {
+int (&bar)(int) = (foo); // expected-error{{cannot take address of 
function 'foo'}}
+int baz = runFn((foo)); // expected-error{{cannot take address of function 
'foo'}}
+  }
+
+  {
+int (&bar)(int) = static_cast(foo); // 
expected-error{{cannot take address of function 'foo'}}
+int baz = runFn(static_cast(foo)); // expected-error{{cannot 
take address of function 'foo'}}
+  }
+
+  {
+int (&bar)(int) = static_cast((foo)); // 
expected-error{{cannot take address of function 'foo'}}
+int baz = runFn(static_cast((foo))); // 
expected-error{{cannot take address of function 'foo'}}
+  }
+}
+}


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


  1   2   >