[clang-tools-extra] r295544 - [clang-tidy] google-readability-casting: Handle user-defined conversions

2017-02-18 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Sat Feb 18 03:45:00 2017
New Revision: 295544

URL: http://llvm.org/viewvc/llvm-project?rev=295544&view=rev
Log:
[clang-tidy] google-readability-casting: Handle user-defined conversions

Modified:
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=295544&r1=295543&r2=295544&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Sat Feb 
18 03:45:00 2017
@@ -35,25 +35,28 @@ void AvoidCStyleCastsCheck::registerMatc
 }
 
 static bool needsConstCast(QualType SourceType, QualType DestType) {
-  SourceType = SourceType.getNonReferenceType();
-  DestType = DestType.getNonReferenceType();
-  while (SourceType->isPointerType() && DestType->isPointerType()) {
-SourceType = SourceType->getPointeeType();
-DestType = DestType->getPointeeType();
-if (SourceType.isConstQualified() && !DestType.isConstQualified())
-  return true;
+  for (;;) {
+if (SourceType.isConstQualified() && !DestType.isConstQualified()) {
+  return (SourceType->isPointerType() == DestType->isPointerType()) &&
+ (SourceType->isReferenceType() == DestType->isReferenceType());
+}
+if ((SourceType->isPointerType() && DestType->isPointerType()) ||
+(SourceType->isReferenceType() && DestType->isReferenceType())) {
+  SourceType = SourceType->getPointeeType();
+  DestType = DestType->getPointeeType();
+   } else {
+ return false;
+   }
   }
-  return false;
 }
 
-static bool pointedTypesAreEqual(QualType SourceType, QualType DestType) {
-  SourceType = SourceType.getNonReferenceType();
-  DestType = DestType.getNonReferenceType();
-  while (SourceType->isPointerType() && DestType->isPointerType()) {
-SourceType = SourceType->getPointeeType();
-DestType = DestType->getPointeeType();
+static bool pointedUnqualifiedTypesAreEqual(QualType T1, QualType T2) {
+  while ((T1->isPointerType() && T2->isPointerType()) ||
+ (T1->isReferenceType() && T2->isReferenceType())) {
+T1 = T1->getPointeeType();
+T2 = T2->getPointeeType();
   }
-  return SourceType.getUnqualifiedType() == DestType.getUnqualifiedType();
+  return T1.getUnqualifiedType() == T2.getUnqualifiedType();
 }
 
 void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) {
@@ -67,35 +70,38 @@ void AvoidCStyleCastsCheck::check(const
 
   // Casting to void is an idiomatic way to mute "unused variable" and similar
   // warnings.
-  if (CastExpr->getTypeAsWritten()->isVoidType())
+  if (CastExpr->getCastKind() == CK_ToVoid)
 return;
 
-  QualType SourceType = CastExpr->getSubExprAsWritten()->getType();
-  QualType DestType = CastExpr->getTypeAsWritten();
-
   auto isFunction = [](QualType T) {
 T = T.getCanonicalType().getNonReferenceType();
 return T->isFunctionType() || T->isFunctionPointerType() ||
T->isMemberFunctionPointerType();
   };
 
-  bool FnToFnCast = isFunction(SourceType) && isFunction(DestType);
-
-  // Function pointer/reference casts may be needed to resolve ambiguities in
-  // case of overloaded functions, so detection of redundant casts is trickier
-  // in this case. Don't emit "redundant cast" warnings for function
-  // pointer/reference types.
-  if (SourceType == DestType && !FnToFnCast) {
-diag(CastExpr->getLocStart(), "redundant cast to the same type")
-<< FixItHint::CreateRemoval(ParenRange);
-return;
-  }
-  SourceType = SourceType.getCanonicalType();
-  DestType = DestType.getCanonicalType();
-  if (SourceType == DestType && !FnToFnCast) {
-diag(CastExpr->getLocStart(),
- "possibly redundant cast between typedefs of the same type");
-return;
+  const QualType DestTypeAsWritten = CastExpr->getTypeAsWritten();
+  const QualType SourceTypeAsWritten = 
CastExpr->getSubExprAsWritten()->getType();
+  const QualType SourceType = SourceTypeAsWritten.getCanonicalType();
+  const QualType DestType = DestTypeAsWritten.getCanonicalType();
+
+  bool FnToFnCast =
+  isFunction(SourceTypeAsWritten) && isFunction(DestTypeAsWritten);
+
+  if (CastExpr->getCastKind() == CK_NoOp && !FnToFnCast) {
+// Function pointer/reference casts may be needed to resolve ambiguities in
+// case of overloaded functions, so detection of redundant casts is 
trickier
+// in this case. Don't emit "redundant cast" warnings for function
+// pointer/reference types.
+if (SourceTypeAsWritten == DestTypeAsWritten) {
+  diag(CastExpr->getLocStart(), "redundant cast to the same type")
+  << FixItHint::CreateRemoval(ParenRange);
+  retu

r295545 - [analyzer] Fix crash in CastToStruct when there is no record definition

2017-02-18 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Sat Feb 18 05:18:57 2017
New Revision: 295545

URL: http://llvm.org/viewvc/llvm-project?rev=295545&view=rev
Log:
[analyzer] Fix crash in CastToStruct when there is no record definition

This crash was reported in https://bugs.llvm.org//show_bug.cgi?id=31173

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
cfe/trunk/test/Analysis/cast-to-struct.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp?rev=295545&r1=295544&r2=295545&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp Sat Feb 18 
05:18:57 2017
@@ -84,6 +84,13 @@ bool CastToStructVisitor::VisitCastExpr(
 if (!VD || VD->getType()->isReferenceType())
   return true;
 
+// Don't warn when target type has no definition.
+if (const RecordType *RD = dyn_cast(ToPointeeTy.getTypePtr())) 
{
+  if (!RD->getDecl()->getDefinition()) {
+return true;
+  }
+}
+
 // Warn when there is widening cast.
 unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width;
 unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width;

Modified: cfe/trunk/test/Analysis/cast-to-struct.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-to-struct.cpp?rev=295545&r1=295544&r2=295545&view=diff
==
--- cfe/trunk/test/Analysis/cast-to-struct.cpp (original)
+++ cfe/trunk/test/Analysis/cast-to-struct.cpp Sat Feb 18 05:18:57 2017
@@ -65,3 +65,8 @@ void intToStruct(int *P) {
   void *VP = P;
   Abc = (struct ABC *)VP;
 }
+
+// https://llvm.org/bugs/show_bug.cgi?id=31173
+void dontCrash(struct AB X) {
+  struct UndefS *S = (struct UndefS *)&X;
+}


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


[PATCH] D28297: [StaticAnalyzer] Fix crash in CastToStructChecker

2017-02-18 Thread Daniel Marjamäki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295545: [analyzer] Fix crash in CastToStruct when there is 
no record definition (authored by danielmarjamaki).

Changed prior to commit:
  https://reviews.llvm.org/D28297?vs=83062&id=89019#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28297

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
  cfe/trunk/test/Analysis/cast-to-struct.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
@@ -84,6 +84,13 @@
 if (!VD || VD->getType()->isReferenceType())
   return true;
 
+// Don't warn when target type has no definition.
+if (const RecordType *RD = dyn_cast(ToPointeeTy.getTypePtr())) 
{
+  if (!RD->getDecl()->getDefinition()) {
+return true;
+  }
+}
+
 // Warn when there is widening cast.
 unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width;
 unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width;
Index: cfe/trunk/test/Analysis/cast-to-struct.cpp
===
--- cfe/trunk/test/Analysis/cast-to-struct.cpp
+++ cfe/trunk/test/Analysis/cast-to-struct.cpp
@@ -65,3 +65,8 @@
   void *VP = P;
   Abc = (struct ABC *)VP;
 }
+
+// https://llvm.org/bugs/show_bug.cgi?id=31173
+void dontCrash(struct AB X) {
+  struct UndefS *S = (struct UndefS *)&X;
+}


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
@@ -84,6 +84,13 @@
 if (!VD || VD->getType()->isReferenceType())
   return true;
 
+// Don't warn when target type has no definition.
+if (const RecordType *RD = dyn_cast(ToPointeeTy.getTypePtr())) {
+  if (!RD->getDecl()->getDefinition()) {
+return true;
+  }
+}
+
 // Warn when there is widening cast.
 unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width;
 unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width;
Index: cfe/trunk/test/Analysis/cast-to-struct.cpp
===
--- cfe/trunk/test/Analysis/cast-to-struct.cpp
+++ cfe/trunk/test/Analysis/cast-to-struct.cpp
@@ -65,3 +65,8 @@
   void *VP = P;
   Abc = (struct ABC *)VP;
 }
+
+// https://llvm.org/bugs/show_bug.cgi?id=31173
+void dontCrash(struct AB X) {
+  struct UndefS *S = (struct UndefS *)&X;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30135: [OpenMP] Generate better diagnostics for cancel and cancellation point

2017-02-18 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.

Handle errors related to a specific directive before checking the nesting:
The specific checks may validate required arguments and give more helpful
messages, especially when the nesting depends on those arguments.

This change requires some minor adaptions to the tests to maintain the
expected diagnostics.


https://reviews.llvm.org/D30135

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/cancel_messages.cpp
  test/OpenMP/cancellation_point_messages.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/task_messages.cpp

Index: test/OpenMP/task_messages.cpp
===
--- test/OpenMP/task_messages.cpp
+++ test/OpenMP/task_messages.cpp
@@ -101,7 +101,8 @@
 // expected-error@+2 {{reduction variable must be shared}}
 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
 #pragma omp for reduction(+ : r)
-  ++r;
+  for (int i = 0; i < 10; ++i)
+++r;
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
 #pragma omp task untied untied
   ++r;
@@ -257,7 +258,8 @@
 // expected-error@+2 {{reduction variable must be shared}}
 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
 #pragma omp for reduction(+ : r)
-  ++r;
+  for (int i = 0; i < 10; ++i)
+++r;
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
 #pragma omp task untied untied
   ++r;
Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -12467,7 +12467,7 @@
   // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
   // expected-note@+1 {{expected an expression statement}}
   {
-#pragma omp target update // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
+#pragma omp target update to(a) // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   }
 #pragma omp atomic
   // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
Index: test/OpenMP/cancellation_point_messages.cpp
===
--- test/OpenMP/cancellation_point_messages.cpp
+++ test/OpenMP/cancellation_point_messages.cpp
@@ -4,8 +4,16 @@
 #pragma omp cancellation   // expected-error {{expected an OpenMP directive}}
 #pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
   ;
+#pragma omp parallel
+  {
+#pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancellation point parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancellation point'}}
 #pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+#pragma omp parallel
+  {
+#pragma omp cancellation point unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancellation point sections(   // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}}
 #pragma omp cancellation point for, )  // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}}
 #pragma omp cancellation point taskgroup() // expected-warning {{extra tokens at the end of '#pragma omp cancellation point' are ignored}}
Index: test/OpenMP/cancel_messages.cpp
===
--- test/OpenMP/cancel_messages.cpp
+++ test/OpenMP/cancel_messages.cpp
@@ -4,8 +4,16 @@
 #pragma omp cancellation   // expected-error {{expected an OpenMP directive}}
 #pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
   ;
+#pragma omp parallel
+  {
+#pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+  }
 #pragma omp cancel parallel untied // expected-error {{unexpected OpenMP clause 'untied' in directive '#pragma omp cancel'}}
 #pragma omp cancel unknown // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+#pragma omp parallel
+  {
+#pragma omp cancel unknown // expected-error {{one of 'for', 'parall

[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-18 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 89022.

https://reviews.llvm.org/D30111

Files:
  test/Format/check-coding-style-mozilla.cpp

Index: test/Format/check-coding-style-mozilla.cpp
===
--- test/Format/check-coding-style-mozilla.cpp
+++ test/Format/check-coding-style-mozilla.cpp
@@ -0,0 +1,130 @@
+// RUN: clang-format -style=Mozilla %s > %T/foo.cpp 2>&1
+// RUN: diff -u %s %T/foo.cpp
+// RUN: rm -rf %T/foo.cpp
+
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+if (true) {
+} else if (false) {
+} else {
+}
+
+while (true) {
+}
+
+do {
+} while (true);
+
+for (auto bar::in) {
+}
+
+switch (var) {
+  case 1: {
+// When you need to declare a variable in a switch, put the block in braces
+int var;
+break;
+  }
+  case 2:
+foo();
+break;
+  default:
+break;
+}
+
+namespace mozilla {
+
+class MyClass : public A
+{
+  void Myclass();
+};
+
+class MyClass : public X // When deriving from more than one class, put each on
+ // its own line.
+,
+public Y
+{
+public:
+  MyClass(int aVar, int aVar2)
+: mVar(aVar)
+, mVar2(aVar2)
+  {
+foo();
+  }
+
+  // Tiny constructors and destructors can be written on a single line.
+  MyClass() {}
+
+  // Unless it's a copy or move constructor or you have a specific reason to
+  // allow implicit conversions, mark all single-argument constructors explicit.
+  explicit MyClass(OtherClass aArg) { bar(); }
+
+  // This constructor can also take a single argument, so it also needs to be
+  // marked explicit.
+  explicit MyClass(OtherClass aArg, AnotherClass aArg2 = AnotherClass())
+  {
+foo();
+  }
+
+  int TinyFunction()
+  {
+return mVar;
+  } // Tiny functions can be written in a single line.
+
+  int LargerFunction()
+  {
+bar();
+foo();
+  }
+
+private:
+  int mVar;
+};
+
+} // namespace mozilla
+
+template // Templates on own line.
+static int
+MyFunction(int a) // Return type on own line for top-level functions.
+{
+  foo();
+}
+
+int
+MyClass::Method(long b)
+{
+  bar();
+}
+
+T* p; // Correct declaration style
+
+// Test the && and || with parentheses
+return (nextKeyframe < aTimeThreshold ||
+(mVideo.mTimeThreshold &&
+ mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold)) &&
+   nextKeyframe.ToMicroseconds() >= 0 && !nextKeyframe.IsInfinite();
+
+// The ? should be placed 2 spaces after the previous declaration
+LOGV("%d audio samples demuxed (sid:%d)",
+ aSamples->mSamples.Length(),
+ aSamples->mSamples[0]->mTrackInfo
+   ? aSamples->mSamples[0]->mTrackInfo->GetID()
+   : 0);
+
+// Test with the 80 chars limit
+return (aDecoder.HasPromise() || aDecoder.mTimeThreshold.isSome()) &&
+   !aDecoder.HasPendingDrain() && !aDecoder.HasFatalError() &&
+   !aDecoder.mDemuxRequest.Exists() && !aDecoder.mOutput.Length() &&
+   !aDecoder.HasInternalSeekPending() && !aDecoder.mDecodeRequest.Exists();
+
+template
+void
+foo();
+
+#define MACRO(V)   \
+  V(Rt2) /* one more char */   \
+  V(Rs)  /* than here  */  \
+/* comment 3 */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30111: [clang-format] Add a test to check at once all the Mozilla coding style

2017-02-18 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru marked 3 inline comments as done.
sylvestre.ledru added inline comments.



Comment at: test/Format/check-coding-style-mozilla.cpp:10
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+if (true) {

krasimir wrote:
> What is tested here? Brace styles?
Yes, do you want me to add a comment to explicit that?



Comment at: test/Format/check-coding-style-mozilla.cpp:48
+,
+public Y
+{

krasimir wrote:
> This does not check precisely what the comment says, because the comment 
> affects the indentation decisions. Better put the comment before the class 
> declaration.
I know, this is one of the thing I would like to see fixed in clang format or 
us. 
I am adding it in the test suite to make sure that we address it



Comment at: test/Format/check-coding-style-mozilla.cpp:75
+return mVar;
+  } // Tiny functions can be written in a single line.
+

krasimir wrote:
> I don't get it - shouldn't then TinyFunction be on a single line? Also the 
> long trailing comment might affect formatting, so I suggest putting it before 
> the function definition.
Same as above



Comment at: test/Format/check-coding-style-mozilla.cpp:90
+template // Templates on own line.
+static int   // Return type on own line for top-level functions.
+  MyFunction(int a)

krasimir wrote:
> Trailing comments affect line breaking, so this is not really testing what 
> the comments say. Suggest to put them on a line before the template.
Yeah, we are trying to fix this issue.
but you are correct, I will move it



Comment at: test/Format/check-coding-style-mozilla.cpp:106
+ !GetCachedStyleData(aSID),
+   "bar");
+

krasimir wrote:
> What does this fragment and the following ones test?
Testing some issues which were reported. I added comments and removed some


https://reviews.llvm.org/D30111



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


r295548 - [analyzer] Revert 295545. There are buildbot failures.

2017-02-18 Thread Daniel Marjamaki via cfe-commits
Author: danielmarjamaki
Date: Sat Feb 18 10:31:35 2017
New Revision: 295548

URL: http://llvm.org/viewvc/llvm-project?rev=295548&view=rev
Log:
[analyzer] Revert 295545. There are buildbot failures.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
cfe/trunk/test/Analysis/cast-to-struct.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp?rev=295548&r1=295547&r2=295548&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp Sat Feb 18 
10:31:35 2017
@@ -84,13 +84,6 @@ bool CastToStructVisitor::VisitCastExpr(
 if (!VD || VD->getType()->isReferenceType())
   return true;
 
-// Don't warn when target type has no definition.
-if (const RecordType *RD = dyn_cast(ToPointeeTy.getTypePtr())) 
{
-  if (!RD->getDecl()->getDefinition()) {
-return true;
-  }
-}
-
 // Warn when there is widening cast.
 unsigned ToWidth = Ctx.getTypeInfo(ToPointeeTy).Width;
 unsigned OrigWidth = Ctx.getTypeInfo(OrigPointeeTy).Width;

Modified: cfe/trunk/test/Analysis/cast-to-struct.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-to-struct.cpp?rev=295548&r1=295547&r2=295548&view=diff
==
--- cfe/trunk/test/Analysis/cast-to-struct.cpp (original)
+++ cfe/trunk/test/Analysis/cast-to-struct.cpp Sat Feb 18 10:31:35 2017
@@ -65,8 +65,3 @@ void intToStruct(int *P) {
   void *VP = P;
   Abc = (struct ABC *)VP;
 }
-
-// https://llvm.org/bugs/show_bug.cgi?id=31173
-void dontCrash(struct AB X) {
-  struct UndefS *S = (struct UndefS *)&X;
-}


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


r295556 - AMDGPU: Add gfx900 and gfx901 processors

2017-02-18 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Sat Feb 18 13:02:41 2017
New Revision: 295556

URL: http://llvm.org/viewvc/llvm-project?rev=295556&view=rev
Log:
AMDGPU: Add gfx900 and gfx901 processors

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Driver/r600-mcpu.cl

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=295556&r1=29&r2=295556&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sat Feb 18 13:02:41 2017
@@ -2034,7 +2034,8 @@ class AMDGPUTargetInfo final : public Ta
 GK_CAYMAN,
 GK_GFX6,
 GK_GFX7,
-GK_GFX8
+GK_GFX8,
+GK_GFX9
   } GPU;
 
   bool hasFP64:1;
@@ -2211,6 +2212,8 @@ public:
   .Case("gfx803",GK_GFX8)
   .Case("gfx804",GK_GFX8)
   .Case("gfx810",GK_GFX8)
+  .Case("gfx900",GK_GFX9)
+  .Case("gfx901",GK_GFX9)
   .Default(GK_NONE);
   }
 

Modified: cfe/trunk/test/Driver/r600-mcpu.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/r600-mcpu.cl?rev=295556&r1=29&r2=295556&view=diff
==
--- cfe/trunk/test/Driver/r600-mcpu.cl (original)
+++ cfe/trunk/test/Driver/r600-mcpu.cl Sat Feb 18 13:02:41 2017
@@ -40,6 +40,8 @@ t// Check that -mcpu works for all suppo
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=carrizo %s -o - 
2>&1 | FileCheck --check-prefix=CARRIZO-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=fiji %s -o - 2>&1 
| FileCheck --check-prefix=FIJI-CHECK %s
 // RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=stoney %s -o - 
2>&1 | FileCheck --check-prefix=STONEY-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx900 %s -o - 
2>&1 | FileCheck --check-prefix=GFX900-CHECK %s
+// RUN: %clang -### -target amdgcn -x cl -S -emit-llvm -mcpu=gfx901 %s -o - 
2>&1 | FileCheck --check-prefix=GFX901-CHECK %s
 
 // R600-CHECK:  "-target-cpu" "r600"
 // RS880-CHECK: "-target-cpu" "rs880"
@@ -70,3 +72,5 @@ t// Check that -mcpu works for all suppo
 // CARRIZO-CHECK: "-target-cpu" "carrizo"
 // FIJI-CHECK: "-target-cpu" "fiji"
 // STONEY-CHECK: "-target-cpu" "stoney"
+// GFX900-CHECK: "-target-cpu" "gfx900"
+// GFX901-CHECK: "-target-cpu" "gfx901"


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


[libcxx] r295561 - Revert "threading_support: make __thread_sleep_for be alertable"

2017-02-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Feb 18 13:28:43 2017
New Revision: 295561

URL: http://llvm.org/viewvc/llvm-project?rev=295561&view=rev
Log:
Revert "threading_support: make __thread_sleep_for be alertable"

This reverts SVN r295329.  Although `__libcpp_thread_sleep_for` should
be alertable, the implementation causes a large regression in the test
suite.  Add a FIXME item there for now to get the test suite in a better
state before attempting to fix that behaviour.

Modified:
libcxx/trunk/include/__threading_support

Modified: libcxx/trunk/include/__threading_support
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=295561&r1=295560&r2=295561&view=diff
==
--- libcxx/trunk/include/__threading_support (original)
+++ libcxx/trunk/include/__threading_support Sat Feb 18 13:28:43 2017
@@ -589,14 +589,12 @@ void __libcpp_thread_yield()
 
 void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
 {
-  using namespace _VSTD::chrono;
-
+  using namespace chrono;
   // round-up to the nearest milisecond
   milliseconds __ms =
   duration_cast(__ns + chrono::nanoseconds(99));
-  auto start = system_clock::now();
-  while (::SleepEx((__ms - (system_clock::now() - start)).count(),
-   TRUE) == WAIT_IO_COMPLETION);
+  // FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)
+  Sleep(__ms.count());
 }
 
 // Thread Local Storage


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


[libcxx] r295559 - math: add type promoting template definition on MSVCRT

2017-02-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Feb 18 13:28:38 2017
New Revision: 295559

URL: http://llvm.org/viewvc/llvm-project?rev=295559&view=rev
Log:
math: add type promoting template definition on MSVCRT

When building with MSVCRT, we need to manually provide the type
promoting overloads to allow the correct type deduced invocation for
signbit(Int) and fpclassify(int).

Modified:
libcxx/trunk/include/math.h

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=295559&r1=295558&r2=295559&view=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Sat Feb 18 13:28:38 2017
@@ -333,6 +333,16 @@ signbit(_A1 __lcpp_x) _NOEXCEPT
 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
+#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{
+  return ::signbit(static_cast::type>(__lcpp_x));
+}
+
 #endif  // signbit
 
 // fpclassify
@@ -357,6 +367,16 @@ fpclassify(_A1 __lcpp_x) _NOEXCEPT
 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
+#elif defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) >= 14)
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{
+  return ::fpclassify(static_cast::type>(__lcpp_x));
+}
+
 #endif  // fpclassify
 
 // isfinite


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


[libcxx] r295558 - test: explicitly size enumeration

2017-02-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Feb 18 13:28:36 2017
New Revision: 295558

URL: http://llvm.org/viewvc/llvm-project?rev=295558&view=rev
Log:
test: explicitly size enumeration

On certain targets, enumerations may be smaller than an `unsigned long`.
Use an explicitly sized enumeration.

Modified:
libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp

Modified: libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp?rev=295558&r1=295557&r2=295558&view=diff
==
--- libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/type_traits/convert_to_integral.pass.cpp Sat Feb 
18 13:28:36 2017
@@ -76,7 +76,7 @@ void check_enum_types()
 
 
 enum enum1 { zero = 0, one = 1 };
-enum enum2 {
+enum enum2 : unsigned long {
   value = std::numeric_limits::max()
 };
 


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


[libcxx] r295560 - test: silence warnings on clang under clang-cl

2017-02-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Sat Feb 18 13:28:41 2017
New Revision: 295560

URL: http://llvm.org/viewvc/llvm-project?rev=295560&view=rev
Log:
test: silence warnings on clang under clang-cl

When running under clang-cl mode, we do not define `__GNUC__`, resulting
in the test failing.

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp?rev=295560&r1=295559&r2=295560&view=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdio_h.pass.cpp Sat Feb 18 
13:28:41 2017
@@ -99,7 +99,7 @@
 
 #include 
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) || defined(__clang__)
 #pragma GCC diagnostic ignored "-Wformat-zero-length"
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam
 #endif


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


r295570 - [X86] Replace XOP vpcmov builtins with native vector logical operations.

2017-02-18 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Feb 18 15:15:30 2017
New Revision: 295570

URL: http://llvm.org/viewvc/llvm-project?rev=295570&view=rev
Log:
[X86] Replace XOP vpcmov builtins with native vector logical operations.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/xopintrin.h
cfe/trunk/test/CodeGen/xop-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=295570&r1=295569&r2=295570&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sat Feb 18 15:15:30 2017
@@ -832,8 +832,6 @@ TARGET_BUILTIN(__builtin_ia32_vphaddudq,
 TARGET_BUILTIN(__builtin_ia32_vphsubbw, "V8sV16c", "", "xop")
 TARGET_BUILTIN(__builtin_ia32_vphsubwd, "V4iV8s", "", "xop")
 TARGET_BUILTIN(__builtin_ia32_vphsubdq, "V2LLiV4i", "", "xop")
-TARGET_BUILTIN(__builtin_ia32_vpcmov, "V2LLiV2LLiV2LLiV2LLi", "", "xop")
-TARGET_BUILTIN(__builtin_ia32_vpcmov_256, "V4LLiV4LLiV4LLiV4LLi", "", "xop")
 TARGET_BUILTIN(__builtin_ia32_vpperm, "V16cV16cV16cV16c", "", "xop")
 TARGET_BUILTIN(__builtin_ia32_vprotb, "V16cV16cV16c", "", "xop")
 TARGET_BUILTIN(__builtin_ia32_vprotw, "V8sV8sV8s", "", "xop")

Modified: cfe/trunk/lib/Headers/xopintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xopintrin.h?rev=295570&r1=295569&r2=295570&view=diff
==
--- cfe/trunk/lib/Headers/xopintrin.h (original)
+++ cfe/trunk/lib/Headers/xopintrin.h Sat Feb 18 15:15:30 2017
@@ -198,13 +198,13 @@ _mm_hsubq_epi32(__m128i __A)
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cmov_si128(__m128i __A, __m128i __B, __m128i __C)
 {
-  return (__m128i)__builtin_ia32_vpcmov((__v2di)__A, (__v2di)__B, (__v2di)__C);
+  return (__m128i)((__v2du)__A & (__v2du)__C) | ((__v2du)__B & ~(__v2du)__C);
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_cmov_si256(__m256i __A, __m256i __B, __m256i __C)
 {
-  return (__m256i)__builtin_ia32_vpcmov_256((__v4di)__A, (__v4di)__B, 
(__v4di)__C);
+  return (__m256i)((__v4du)__A & (__v4du)__C) | ((__v4du)__B & ~(__v4du)__C);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS

Modified: cfe/trunk/test/CodeGen/xop-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xop-builtins.c?rev=295570&r1=295569&r2=295570&view=diff
==
--- cfe/trunk/test/CodeGen/xop-builtins.c (original)
+++ cfe/trunk/test/CodeGen/xop-builtins.c Sat Feb 18 15:15:30 2017
@@ -170,13 +170,19 @@ __m128i test_mm_hsubq_epi32(__m128i a) {
 
 __m128i test_mm_cmov_si128(__m128i a, __m128i b, __m128i c) {
   // CHECK-LABEL: test_mm_cmov_si128
-  // CHECK: call <2 x i64> @llvm.x86.xop.vpcmov(<2 x i64> %{{.*}}, <2 x i64> 
%{{.*}}, <2 x i64> %{{.*}})
+  // CHECK: [[AND:%.*]] = and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: [[NEG:%.*]] = xor <2 x i64> %{{.*}}, 
+  // CHECK-NEXT: [[ANDN:%.*]] = and <2 x i64> %{{.*}}, [[NEG]]
+  // CHECK-NEXT: %{{.*}} = or <2 x i64> [[AND]], [[ANDN]]
   return _mm_cmov_si128(a, b, c);
 }
 
 __m256i test_mm256_cmov_si256(__m256i a, __m256i b, __m256i c) {
   // CHECK-LABEL: test_mm256_cmov_si256
-  // CHECK: call <4 x i64> @llvm.x86.xop.vpcmov.256(<4 x i64> %{{.*}}, <4 x 
i64> %{{.*}}, <4 x i64> %{{.*}})
+  // CHECK: [[AND:%.*]] = and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: [[NEG:%.*]] = xor <4 x i64> %{{.*}}, 
+  // CHECK-NEXT: [[ANDN:%.*]] = and <4 x i64> %{{.*}}, [[NEG]]
+  // CHECK-NEXT: %{{.*}} = or <4 x i64> [[AND]], [[ANDN]]
   return _mm256_cmov_si256(a, b, c);
 }
 


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


r295584 - [X86][XOP] Fix type conversion warning in vpcmov generic implementations.

2017-02-18 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sat Feb 18 17:47:34 2017
New Revision: 295584

URL: http://llvm.org/viewvc/llvm-project?rev=295584&view=rev
Log:
[X86][XOP] Fix type conversion warning in vpcmov generic implementations.

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

Modified: cfe/trunk/lib/Headers/xopintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xopintrin.h?rev=295584&r1=295583&r2=295584&view=diff
==
--- cfe/trunk/lib/Headers/xopintrin.h (original)
+++ cfe/trunk/lib/Headers/xopintrin.h Sat Feb 18 17:47:34 2017
@@ -198,13 +198,13 @@ _mm_hsubq_epi32(__m128i __A)
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cmov_si128(__m128i __A, __m128i __B, __m128i __C)
 {
-  return (__m128i)((__v2du)__A & (__v2du)__C) | ((__v2du)__B & ~(__v2du)__C);
+  return (__m128i)(((__v2du)__A & (__v2du)__C) | ((__v2du)__B & ~(__v2du)__C));
 }
 
 static __inline__ __m256i __DEFAULT_FN_ATTRS
 _mm256_cmov_si256(__m256i __A, __m256i __B, __m256i __C)
 {
-  return (__m256i)((__v4du)__A & (__v4du)__C) | ((__v4du)__B & ~(__v4du)__C);
+  return (__m256i)(((__v4du)__A & (__v4du)__C) | ((__v4du)__B & ~(__v4du)__C));
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS


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


r295592 - clang/CMakeLists.txt: Rework r294954 -- use file(TO_CMAKE_PATH).

2017-02-18 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Feb 18 21:17:31 2017
New Revision: 295592

URL: http://llvm.org/viewvc/llvm-project?rev=295592&view=rev
Log:
clang/CMakeLists.txt: Rework r294954 -- use file(TO_CMAKE_PATH).

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=295592&r1=295591&r2=295592&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Sat Feb 18 21:17:31 2017
@@ -59,7 +59,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 
   # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
   # CMake assumes slashes as PATH.
-  get_filename_component(LLVM_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} ABSOLUTE)
+  file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)


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


[PATCH] D26061: [analyzer] Refactor and simplify SimpleConstraintManager

2017-02-18 Thread Dominic Chen via Phabricator via cfe-commits
ddcc updated this revision to Diff 89054.
ddcc added a comment.

Rebase, incorporate https://reviews.llvm.org/D22862


https://reviews.llvm.org/D26061

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/ConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.h
  lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  lib/StaticAnalyzer/Core/SimpleConstraintManager.h

Index: lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -7,12 +7,12 @@
 //
 //===--===//
 //
-//  This file defines SimpleConstraintManager, a class that holds code shared
-//  between BasicConstraintManager and RangeConstraintManager.
+//  This file defines SimpleConstraintManager, a class that provides a
+//  simplified constraint manager interface, compared to ConstraintManager.
 //
 //===--===//
 
-#include "SimpleConstraintManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SimpleConstraintManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -23,48 +23,6 @@
 
 SimpleConstraintManager::~SimpleConstraintManager() {}
 
-bool SimpleConstraintManager::canReasonAbout(SVal X) const {
-  Optional SymVal = X.getAs();
-  if (SymVal && SymVal->isExpression()) {
-const SymExpr *SE = SymVal->getSymbol();
-
-if (const SymIntExpr *SIE = dyn_cast(SE)) {
-  switch (SIE->getOpcode()) {
-  // We don't reason yet about bitwise-constraints on symbolic values.
-  case BO_And:
-  case BO_Or:
-  case BO_Xor:
-return false;
-  // We don't reason yet about these arithmetic constraints on
-  // symbolic values.
-  case BO_Mul:
-  case BO_Div:
-  case BO_Rem:
-  case BO_Shl:
-  case BO_Shr:
-return false;
-  // All other cases.
-  default:
-return true;
-  }
-}
-
-if (const SymSymExpr *SSE = dyn_cast(SE)) {
-  if (BinaryOperator::isComparisonOp(SSE->getOpcode())) {
-// We handle Loc <> Loc comparisons, but not (yet) NonLoc <> NonLoc.
-if (Loc::isLocType(SSE->getLHS()->getType())) {
-  assert(Loc::isLocType(SSE->getRHS()->getType()));
-  return true;
-}
-  }
-}
-
-return false;
-  }
-
-  return true;
-}
-
 ProgramStateRef SimpleConstraintManager::assume(ProgramStateRef State,
 DefinedSVal Cond,
 bool Assumption) {
@@ -92,23 +50,6 @@
   return State;
 }
 
-ProgramStateRef
-SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State,
-SymbolRef Sym, bool Assumption) {
-  BasicValueFactory &BVF = getBasicVals();
-  QualType T = Sym->getType();
-
-  // None of the constraint solvers currently support non-integer types.
-  if (!T->isIntegralOrEnumerationType())
-return State;
-
-  const llvm::APSInt &zero = BVF.getValue(0, T);
-  if (Assumption)
-return assumeSymNE(State, Sym, zero, zero);
-  else
-return assumeSymEQ(State, Sym, zero, zero);
-}
-
 ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef State,
NonLoc Cond,
bool Assumption) {
@@ -118,7 +59,8 @@
   if (!canReasonAbout(Cond)) {
 // Just add the constraint to the expression without trying to simplify.
 SymbolRef Sym = Cond.getAsSymExpr();
-return assumeAuxForSymbol(State, Sym, Assumption);
+assert(Sym);
+return assumeSymUnsupported(State, Sym, Assumption);
   }
 
   switch (Cond.getSubKind()) {
@@ -129,51 +71,7 @@
 nonloc::SymbolVal SV = Cond.castAs();
 SymbolRef Sym = SV.getSymbol();
 assert(Sym);
-
-// Handle SymbolData.
-if (!SV.isExpression()) {
-  return assumeAuxForSymbol(State, Sym, Assumption);
-
-  // Handle symbolic expression.
-} else if (const SymIntExpr *SE = dyn_cast(Sym)) {
-  // We can only simplify expressions whose RHS is an integer.
-
-  BinaryOperator::Opcode Op = SE->getOpcode();
-  if (BinaryOperator::isComparisonOp(Op)) {
-if (!Assumption)
-  Op = BinaryOperator::negateComparisonOp(Op);
-
-return assumeSymRel(State, SE->getLHS(), Op, SE->getRHS());
-  }
-
-} else if (const SymSymExpr *SSE = dyn_cast(Sym)) {

[PATCH] D15227: [analyzer] Valist checkers.

2017-02-18 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

>   But as far as I remember, this produced false negatives in the tests not 
> false positives.

Could you double check that? Maybe you still have some notes in your mail box 
or just by looking at the code.

Did none of the checks work or just some of them?

Also, which platforms did this not work on?

It would be great to move all of the useful checks out of alpha since alpha 
essentially means "unsupported" and we do not recommend turning those checkers 
on.

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D15227



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


[clang-tools-extra] r295600 - clangd/ASTManager.cpp: Appease msc19 Debug build -- Don't deref std::vector::end().

2017-02-18 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sun Feb 19 01:18:16 2017
New Revision: 295600

URL: http://llvm.org/viewvc/llvm-project?rev=295600&view=rev
Log:
clangd/ASTManager.cpp: Appease msc19 Debug build -- Don't deref 
std::vector::end().

Modified:
clang-tools-extra/trunk/clangd/ASTManager.cpp

Modified: clang-tools-extra/trunk/clangd/ASTManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ASTManager.cpp?rev=295600&r1=295599&r2=295600&view=diff
==
--- clang-tools-extra/trunk/clangd/ASTManager.cpp (original)
+++ clang-tools-extra/trunk/clangd/ASTManager.cpp Sun Feb 19 01:18:16 2017
@@ -190,8 +190,9 @@ ASTManager::createASTUnitForFile(StringR
   for (const auto &S : Commands.front().CommandLine)
 ArgStrs.push_back(S.c_str());
 
+  auto ArgP = &*ArgStrs.begin();
   return std::unique_ptr(ASTUnit::LoadFromCommandLine(
-  &*ArgStrs.begin(), &*ArgStrs.end(), PCHs, Diags, ResourceDir,
+  ArgP, ArgP + ArgStrs.size(), PCHs, Diags, ResourceDir,
   /*OnlyLocalDecls=*/false, /*CaptureDiagnostics=*/true,
   getRemappedFiles(Docs),
   /*RemappedFilesKeepOriginalName=*/true,


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