[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56554/new/

https://reviews.llvm.org/D56554



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


[PATCH] D57435: [clang-tidy] created wrap-unique check

2019-01-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

`.DS_Store` files clearly should not be there.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57435/new/

https://reviews.llvm.org/D57435



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


r352605 - [ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC)

2019-01-29 Thread Jonas Devlieghere via cfe-commits
Author: jdevlieghere
Date: Tue Jan 29 22:26:26 2019
New Revision: 352605

URL: http://llvm.org/viewvc/llvm-project?rev=352605&view=rev
Log:
[ModuleDependencyCollector] Use llvm::sys::fs::real_path (NFC)

Use the real_path implementation from llvm::sys::fs::real_path instead
of having a custom implementation in the ModuleDependencyCollector.

Differential revision: https://reviews.llvm.org/D57411

Modified:
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=352605&r1=352604&r2=352605&view=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Tue Jan 29 22:26:26 
2019
@@ -98,24 +98,6 @@ struct ModuleDependencyMMCallbacks : pub
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -130,7 +112,7 @@ void ModuleDependencyCollector::attachTo
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -140,7 +122,7 @@ static bool isCaseSensitivePath(StringRe
   // already expects when sensitivity isn't setup.
   for (auto &C : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -186,7 +168,7 @@ bool ModuleDependencyCollector::getRealP
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {


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


[PATCH] D57411: [ModuleDependencyCollector] Use llvm::sys::fs::real_path

2019-01-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352605: [ModuleDependencyCollector] Use 
llvm::sys::fs::real_path (NFC) (authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57411?vs=184155&id=184250#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57411/new/

https://reviews.llvm.org/D57411

Files:
  lib/Frontend/ModuleDependencyCollector.cpp


Index: lib/Frontend/ModuleDependencyCollector.cpp
===
--- lib/Frontend/ModuleDependencyCollector.cpp
+++ lib/Frontend/ModuleDependencyCollector.cpp
@@ -98,24 +98,6 @@
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -130,7 +112,7 @@
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -140,7 +122,7 @@
   // already expects when sensitivity isn't setup.
   for (auto &C : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -186,7 +168,7 @@
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {


Index: lib/Frontend/ModuleDependencyCollector.cpp
===
--- lib/Frontend/ModuleDependencyCollector.cpp
+++ lib/Frontend/ModuleDependencyCollector.cpp
@@ -98,24 +98,6 @@
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -130,7 +112,7 @@
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -140,7 +122,7 @@
   // already expects when sensitivity isn't setup.
   for (auto &C : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -186,7 +168,7 @@
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57427: [CodeGen][ObjC] Fix assert on calling `__builtin_constant_p` with ObjC objects.

2019-01-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

LGTM with one minor nit.




Comment at: clang/test/CodeGenObjC/builtin-constant-p.m:1
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -O3 -o - %s | 
FileCheck %s
+

Since this is just testing front-end's IRGen, can you pass 
`-disable-llvm-passes` ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57427/new/

https://reviews.llvm.org/D57427



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


[PATCH] D57438: [Sema][ObjC] Allow declaring ObjC pointer members in C++ unions under ARC

2019-01-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added inline comments.



Comment at: test/SemaObjCXX/arc-0x.mm:164
+union {
+  union { // expected-note 2 {{'S1' is implicitly deleted because variant 
field '' has a non-trivial}} expected-note 4 {{'S1' is implicitly deleted 
because field '' has a deleted}}
+id f0; // expected-note 2 {{'' is implicitly deleted because variant 
field 'f0' is an ObjC pointer}}

The diagnostic message here should say the special function is deleted because 
the anonymous union's corresponding special function is deleted, but when 
diagnosing a deleted copy assignment operator, it says the anonymous union's 
special function is non-trivial. I'm not sure this is a bug, but I see the same 
diagnostic message when I compile the following non-ObjC code:

```
struct S0 {
  S0(const S0 &);
  S0 &operator=(const S0 &);
  int *p;
};

struct S1 {
  union {
union { // copy assignment operator of 'S1' is implicitly deleted because 
variant field '' has a non-trivial copy assignment operator
  S0 s10;
  int b;
};
int c;
  };
  ~S1();
};

S1 *x0;

void testC1(S1 *a0) {
  *a0 = *x0; // error: object of type 'S1' cannot be assigned because its copy 
assignment operator is implicitly deleted
  *a0 = static_cast(*x0); // error: object of type 'S1' cannot be 
assigned because its copy assignment operator is implicitly deleted
}
```

It seems that this happens because the following code in 
`Sema::ShouldDeleteSpecialMember` is preventing the method declaration from 
being marked as deleted:

```
  // For an anonymous struct or union, the copy and assignment special members
  // will never be used, so skip the check. For an anonymous union declared at
  // namespace scope, the constructor and destructor are used.
  if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
  RD->isAnonymousStructOrUnion())
return false;
```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57438/new/

https://reviews.llvm.org/D57438



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


[PATCH] D57438: [Sema][ObjC] Allow declaring ObjC pointer members in C++ unions under ARC

2019-01-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, rjmccall, doug.gregor.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

ObjC pointer members are currently not allowed in unions in either C or C++ 
mode. This patch lifts the restriction in C++ mode.

This patch essentially treats ObjC pointer members the same way a non-static 
data member of a class type that has non-trivial special functions is treated. 
The ObjC pointer member causes all of the defaulted special functions of the 
union that directly contains the member to be defined as deleted, except when 
the member has an in-class initializer, the default constructor isn't defined 
as deleted.

rdar://problem/34213306


Repository:
  rC Clang

https://reviews.llvm.org/D57438

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaObjCXX/arc-0x.mm
  test/SemaObjCXX/objc-weak.mm

Index: test/SemaObjCXX/objc-weak.mm
===
--- test/SemaObjCXX/objc-weak.mm
+++ test/SemaObjCXX/objc-weak.mm
@@ -13,7 +13,7 @@
 };
 
 union U {
-  __weak id a; // expected-error {{ARC forbids Objective-C objects in union}}
+  __weak id a;
   S b; // expected-error {{union member 'b' has a non-trivial copy constructor}}
 };
 
Index: test/SemaObjCXX/arc-0x.mm
===
--- test/SemaObjCXX/arc-0x.mm
+++ test/SemaObjCXX/arc-0x.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -verify -fblocks -fobjc-exceptions %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -fobjc-weak -verify -fblocks -fobjc-exceptions %s
 
 // "Move" semantics, trivial version.
 void move_it(__strong id &&from) {
@@ -111,3 +111,141 @@
 func(^(A *a[]){}); // expected-error{{must explicitly describe intended ownership of an object array parameter}}
   }
 }
+
+namespace test_union {
+  // Implicitly-declared special functions of a union are deleted by default if
+  // ARC is enabled and the union has an ObjC pointer field.
+  union U0 {
+id f0; // expected-note 6 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  };
+
+  union U1 {
+__weak id f0; // expected-note 12 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+U1() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
+~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
+U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
+U1(U1 &&) = default; // expected-warning {{explicitly defaulted move constructor is implicitly deleted}}
+U1 & operator=(const U1 &) = default; // expected-warning {{explicitly defaulted copy assignment operator is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
+U1 & operator=(U1 &&) = default; // expected-warning {{explicitly defaulted move assignment operator is implicitly deleted}}
+  };
+
+  id getStrong();
+
+  // If the ObjC pointer field of a union has a default member initializer, the
+  // implicitly-declared default constructor of the union is not deleted by
+  // default.
+  union U2 {
+id f0 = getStrong(); // expected-note 4 {{'U2' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+~U2();
+  };
+
+  // It's fine if the user has explicitly defined the special functions.
+  union U3 {
+id f0;
+U3();
+~U3();
+U3(const U3 &);
+U3(U3 &&);
+U3 & operator=(const U3 &);
+U3 & operator=(U3 &&);
+  };
+
+  // ObjC pointer fields in anonymous union fields delete the defaulted special
+  // functions of the containing class.
+  struct S0 {
+union {
+  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  char f1;
+};
+  };
+
+  struct S1 {
+union {
+  union { // expected-note 2 {{'S1' is implicitly deleted because variant field '' has a non-trivial}} expected-note 4 {{'S1' is implicitly deleted because field '' has a deleted}}
+id f0; // expected-note 2 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+char f1;
+  };
+  int f2;
+};
+  };
+
+  U0 *x0;
+  U1 *x1;
+  U2 *x2;
+  U3 *x3;
+  S0 *x4;
+  S1 *x5;
+
+  static union { // expected-error {{call to implicitly-deleted default constructor of}}
+id g0; // expected-note {{default constructor of '' is implicitly deleted because variant field 'g0' is an ObjC pointer}}
+  };
+
+  static unio

[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-29 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.

Thanks, LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56318/new/

https://reviews.llvm.org/D56318



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 184245.
yaxunl added a comment.

Use const argument.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56318/new/

https://reviews.llvm.org/D56318

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/Frontend/CompilerInstance.cpp
  test/SemaCUDA/amdgpu-size_t.cu

Index: test/SemaCUDA/amdgpu-size_t.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-size_t.cu
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef unsigned __int64 size_t;
+typedef __int64 intptr_t;
+typedef unsigned __int64 uintptr_t;
+
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -928,6 +928,9 @@
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
 
+  if (auto *Aux = getAuxTarget())
+getTarget().setAuxTarget(Aux);
+
   // rewriter project will change target built-in bool type from its default.
   if (getFrontendOpts().ProgramAction == frontend::RewriteObjC)
 getTarget().noSignedCharForObjCBool();
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -351,6 +351,8 @@
   uint64_t getNullPointerValue(LangAS AS) const override {
 return AS == LangAS::opencl_local ? ~0 : 0;
   }
+
+  void setAuxTarget(const TargetInfo *Aux) override;
 };
 
 } // namespace targets
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -305,3 +305,7 @@
   if (hasFastFMA())
 Builder.defineMacro("FP_FAST_FMA");
 }
+
+void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
+  copyAuxTarget(Aux);
+}
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -796,3 +796,9 @@
   assert(getAccumIBits() >= getUnsignedAccumIBits());
   assert(getLongAccumIBits() >= getUnsignedLongAccumIBits());
 }
+
+void TargetInfo::copyAuxTarget(const TargetInfo *Aux) {
+  auto *Target = static_cast(this);
+  auto *Src = static_cast(Aux);
+  *Target = *Src;
+}
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -48,22 +48,10 @@
 
 namespace Builtin { struct Info; }
 
-/// Exposes information about the current target.
-///
-class TargetInfo : public RefCountedBase {
-  std::shared_ptr TargetOpts;
-  llvm::Triple Triple;
-protected:
-  // Target values set by the ctor of the actual target implementation.  Default
-  // values are specified by the TargetInfo constructor.
-  bool BigEndian;
-  bool TLSSupported;
-  bool VLASupported;
-  bool NoAsmVariants;  // True if {|} are normal characters.
-  bool HasLegalHalfType; // True if the backend supports operations on the half
- // LLVM IR type.
-  bool HasFloat128;
-  bool HasFloat16;
+/// Fields controlling how types are laid out in memory; these may need to
+/// be copied for targets like AMDGPU that base their ABIs on an auxiliary
+/// CPU target.
+struct TransferrableTargetInfo {
   unsigned char PointerWidth, PointerAlign;
   unsigned char BoolWidth, BoolAlign;
   unsigned char IntWidth, IntAlign;
@@ -104,15 +92,92 @@
   unsigned char SuitableAlign;
   unsigned char DefaultAlignForAttributeAligned;
   unsigned char MinGlobalAlign;
-  unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
+
+  unsigned short NewAlign;
   unsigned short MaxVectorAlign;
   unsigned short MaxTLSAlign;
+
+  const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
+*LongDoubleFormat, *Float128Format;
+
+  ///=== Target Data Type Query Methods ---===//
+  enum IntType {
+NoInt = 0,
+SignedChar,
+UnsignedChar,
+SignedShort,
+UnsignedShort,
+SignedInt,
+UnsignedInt,
+SignedLong,
+UnsignedLong,
+SignedLongLong,
+UnsignedLongLong
+  };
+
+  enum RealType {
+NoFloat = 255,
+Float = 0,
+Double,
+LongDouble,
+Float128
+  };
+protected:
+  IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType,
+  WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
+  ProcessIDType;
+
+  /// Whether Objective-C's built-in boolean type should be signed char.
+  ///
+  /// Otherwise, when this flag is not set, the normal built-in boolean type is
+  /// used.
+  unsigned UseSignedCharForObjCBool : 1;
+
+  /// C

[PATCH] D57411: [ModuleDependencyCollector] Use llvm::sys::fs::real_path

2019-01-29 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

Thanks for working on this! LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57411/new/

https://reviews.llvm.org/D57411



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


[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

One minor change and then LGTM.




Comment at: include/clang/Basic/TargetInfo.h:1352
+  /// Copy type and layout related info.
+  void copyAuxTarget(TargetInfo *Aux);
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {

This can take a `const TargetInfo *`, which also very clearly documents 
expectations.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56318/new/

https://reviews.llvm.org/D56318



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


[PATCH] D57435: [clang-tidy] created wrap-unique check

2019-01-29 Thread Ryan Piantedosi via Phabricator via cfe-commits
Dosi-Dough created this revision.
Dosi-Dough added reviewers: EricWF, JonasToth.
Dosi-Dough added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, mgorny.

based on abseil tip of the week 126 https://abseil.io/tips/126

Created a check which looks for instances of a factory function that uses a 
non-public constructor and return a std::unique_ptr.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57435

Files:
  clang-tidy/.DS_Store
  clang-tidy/abseil/.DS_Store
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/WrapUniqueCheck.cpp
  clang-tidy/abseil/WrapUniqueCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-wrap-unique.rst
  docs/clang-tidy/checks/list.rst
  test/.DS_Store
  test/clang-tidy/.DS_Store
  test/clang-tidy/abseil-wrap-unique.cpp

Index: test/clang-tidy/abseil-wrap-unique.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-wrap-unique.cpp
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy %s abseil-wrap-unique %t
+
+
+namespace std {
+
+template 
+class default_delete {};
+
+template >
+class unique_ptr {
+public:
+  unique_ptr() {}
+  unique_ptr(type *ptr) {}
+  unique_ptr(const unique_ptr &t) = delete;
+  unique_ptr(unique_ptr &&t) {}
+  ~unique_ptr() {}
+  type &operator*() { return *ptr; }
+  type *operator->() { return ptr; }
+  type *release() { return ptr; }
+  void reset() {}
+  void reset(type *pt) {}
+  void reset(type pt) {}
+  unique_ptr &operator=(unique_ptr &&) { return *this; }
+  template 
+  unique_ptr &operator=(unique_ptr &&) { return *this; }
+
+private:
+  type *ptr;
+};
+}  // namespace std
+
+
+class A {
+ public:
+  static A* NewA() {
+return new A();
+  }
+
+ private:
+  A() {}
+};
+
+class B {
+ public:
+  static B* NewB(int bIn) {
+return new B();
+  }
+
+ private:
+  B() {}
+};
+
+struct C {
+  int x;
+  int y;
+};
+/*
+std::unique_ptr returnPointer() {
+  return std::unique_ptr(A::NewA());
+}
+*/
+void positives() {
+  std::unique_ptr a;
+  a.reset(A::NewA());
+  //CHECK-MESSAGE: :[[@LINE-1]]:3: warning: prefer absl::WrapUnique for resetting unique_ptr [abseil-wrap-unique]
+  //CHECK-FIXES: a = absl::WrapUnique(A::NewA())
+  
+  std::unique_ptr b(A::NewA());
+  //CHECK-MESSAGE: :[[@LINE-1]]:3: warning: Perfer absl::WrapUnique to constructing unique_ptr [abseil-wrap-unique]
+  //CHECK-FIXES: auto b = absl::WrapUnique(A::NewA())
+
+  int cIn;
+  std::unique_ptr c(B::NewB(cIn));
+  //CHECK-MESSAGE: :[[@LINE-1]]:3: warning: Perfer absl::WrapUnique to constructing unique_ptr [abseil-wrap-unique]
+  //CHECK-FIXES: auto c = absl::WrapUnique(B::NewB(cIn))
+
+  int dIn;
+  std::unique_ptr d;
+  d.reset(B::NewB(dIn));
+  //CHECK-MESSAGE: :[[@LINE-1]]:3: warning: prefer absl::WrapUnique for resetting unique_ptr [abseil-wrap-unique]
+  //CHECK-FIXES: d = absl::WrapUnique(B::NewB(dIn))
+  
+  auto e = std::unique_ptr(A::NewA());
+  //CHECK-MESSAGE: :[[@LINE-1]]:3: warning: prefer absl::WrapUnique for resetting unique_ptr [abseil-wrap-unique]
+  //CHECK-FIXES: e = absl::WrapUnique(A::NewA())
+
+  //std::unique_ptr e(new int[2] {1,2});
+  
+}
+
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -17,6 +17,7 @@
abseil-str-cat-append
abseil-string-find-startswith
abseil-upgrade-duration-conversions
+   abseil-wrap-unique
android-cloexec-accept
android-cloexec-accept4
android-cloexec-creat
Index: docs/clang-tidy/checks/abseil-wrap-unique.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/abseil-wrap-unique.rst
@@ -0,0 +1,34 @@
+.. title:: clang-tidy - abseil-wrap-unique
+
+abseil-wrap-unique
+==
+
+Checks for instances of static function within a class being called and
+returning a std:unique_ptr type. Also checks for instances where reset
+is called on a static function which returns std::unique_ptr.
+
+.. code-block:: c++
+
+  class A {
+public:
+  static A* NewA() {
+return new A();
+  }
+
+private:
+  A() {}
+  };
+ 
+  std::unique_ptr a;
+ 
+  //Original - reset called with a static function returning a std::unqiue_ptr
+  a.reset(A::NewA());
+
+  //Suggested - reset ptr with absl::WrapUnique
+  a = absl::WrapUnique(A::NewA());
+
+  //Original - std::unique_ptr initialized with static function
+  std::unique_ptr b(A::NewA());
+
+  //Suggested - initialize with absl::WrapUnique instead
+  auto b = absl::WrapUnique(A::NewA())
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -67,6 +67,13 @@
 Improvements to clang-tidy
 --
 
+- New :doc:`abseil-wrap-unique
+  ` check.
+
+  Looks for instances of factory functions which uses a non-public constructor

[PATCH] D56318: [HIP] Fix size_t for MSVC environment

2019-01-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 184238.
yaxunl added a comment.

Revised by John's comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56318/new/

https://reviews.llvm.org/D56318

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/Frontend/CompilerInstance.cpp
  test/SemaCUDA/amdgpu-size_t.cu

Index: test/SemaCUDA/amdgpu-size_t.cu
===
--- /dev/null
+++ test/SemaCUDA/amdgpu-size_t.cu
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -aux-triple x86_64-pc-windows-msvc -fms-compatibility -fcuda-is-device -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+typedef unsigned __int64 size_t;
+typedef __int64 intptr_t;
+typedef unsigned __int64 uintptr_t;
+
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -928,6 +928,9 @@
   // Adjust target options based on codegen options.
   getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
 
+  if (auto *Aux = getAuxTarget())
+getTarget().setAuxTarget(Aux);
+
   // rewriter project will change target built-in bool type from its default.
   if (getFrontendOpts().ProgramAction == frontend::RewriteObjC)
 getTarget().noSignedCharForObjCBool();
Index: lib/Basic/Targets/AMDGPU.h
===
--- lib/Basic/Targets/AMDGPU.h
+++ lib/Basic/Targets/AMDGPU.h
@@ -351,6 +351,8 @@
   uint64_t getNullPointerValue(LangAS AS) const override {
 return AS == LangAS::opencl_local ? ~0 : 0;
   }
+
+  void setAuxTarget(TargetInfo *Aux) override;
 };
 
 } // namespace targets
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -305,3 +305,5 @@
   if (hasFastFMA())
 Builder.defineMacro("FP_FAST_FMA");
 }
+
+void AMDGPUTargetInfo::setAuxTarget(TargetInfo *Aux) { copyAuxTarget(Aux); }
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -796,3 +796,9 @@
   assert(getAccumIBits() >= getUnsignedAccumIBits());
   assert(getLongAccumIBits() >= getUnsignedLongAccumIBits());
 }
+
+void TargetInfo::copyAuxTarget(TargetInfo *Aux) {
+  auto *Target = static_cast(this);
+  auto *Src = static_cast(Aux);
+  *Target = *Src;
+}
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -48,22 +48,10 @@
 
 namespace Builtin { struct Info; }
 
-/// Exposes information about the current target.
-///
-class TargetInfo : public RefCountedBase {
-  std::shared_ptr TargetOpts;
-  llvm::Triple Triple;
-protected:
-  // Target values set by the ctor of the actual target implementation.  Default
-  // values are specified by the TargetInfo constructor.
-  bool BigEndian;
-  bool TLSSupported;
-  bool VLASupported;
-  bool NoAsmVariants;  // True if {|} are normal characters.
-  bool HasLegalHalfType; // True if the backend supports operations on the half
- // LLVM IR type.
-  bool HasFloat128;
-  bool HasFloat16;
+/// Fields controlling how types are laid out in memory; these may need to
+/// be copied for targets like AMDGPU that base their ABIs on an auxiliary
+/// CPU target.
+struct TransferrableTargetInfo {
   unsigned char PointerWidth, PointerAlign;
   unsigned char BoolWidth, BoolAlign;
   unsigned char IntWidth, IntAlign;
@@ -104,15 +92,92 @@
   unsigned char SuitableAlign;
   unsigned char DefaultAlignForAttributeAligned;
   unsigned char MinGlobalAlign;
-  unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
+
+  unsigned short NewAlign;
   unsigned short MaxVectorAlign;
   unsigned short MaxTLSAlign;
+
+  const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
+*LongDoubleFormat, *Float128Format;
+
+  ///=== Target Data Type Query Methods ---===//
+  enum IntType {
+NoInt = 0,
+SignedChar,
+UnsignedChar,
+SignedShort,
+UnsignedShort,
+SignedInt,
+UnsignedInt,
+SignedLong,
+UnsignedLong,
+SignedLongLong,
+UnsignedLongLong
+  };
+
+  enum RealType {
+NoFloat = 255,
+Float = 0,
+Double,
+LongDouble,
+Float128
+  };
+protected:
+  IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType,
+  WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
+  ProcessIDType;
+
+  /// Whether Objective-C's built-in boolean type should be signed char.
+  ///
+  /// Otherwise, when this flag is not set, the normal built-in boolean type is
+  /// used.
+  unsigned UseSignedCharForObjCBool : 1;
+
+  /// Control whether

r352595 - Cleanup: replace uses of CallSite with CallBase.

2019-01-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Jan 29 18:54:28 2019
New Revision: 352595

URL: http://llvm.org/viewvc/llvm-project?rev=352595&view=rev
Log:
Cleanup: replace uses of CallSite with CallBase.

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=352595&r1=352594&r2=352595&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Jan 29 18:54:28 2019
@@ -22,7 +22,6 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/CodeGen/ConstantInitBuilder.h"
 #include "llvm/ADT/SmallSet.h"
-#include "llvm/IR/CallSite.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/ScopedPrinter.h"

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=352595&r1=352594&r2=352595&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jan 29 18:54:28 2019
@@ -26,7 +26,6 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringExtras.h"
-#include "llvm/IR/CallSite.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
@@ -799,9 +798,9 @@ static RValue EmitMSVCRTSetJmp(CodeGenFu
   llvm::Value *Buf = CGF.Builder.CreateBitOrPointerCast(
   CGF.EmitScalarExpr(E->getArg(0)), CGF.Int8PtrTy);
   llvm::Value *Args[] = {Buf, Arg1};
-  llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(SetJmpFn, Args);
-  CS.setAttributes(ReturnsTwiceAttr);
-  return RValue::get(CS.getInstruction());
+  llvm::CallBase *CB = CGF.EmitRuntimeCallOrInvoke(SetJmpFn, Args);
+  CB->setAttributes(ReturnsTwiceAttr);
+  return RValue::get(CB);
 }
 
 // Many of MSVC builtins are on x64, ARM and AArch64; to avoid repeating code,
@@ -1002,9 +1001,9 @@ Value *CodeGenFunction::EmitMSVCBuiltinE
 llvm::AttributeList NoReturnAttr = llvm::AttributeList::get(
 getLLVMContext(), llvm::AttributeList::FunctionIndex,
 llvm::Attribute::NoReturn);
-CallSite CS = Builder.CreateCall(IA, EmitScalarExpr(E->getArg(0)));
-CS.setAttributes(NoReturnAttr);
-return CS.getInstruction();
+llvm::CallInst *CI = Builder.CreateCall(IA, EmitScalarExpr(E->getArg(0)));
+CI->setAttributes(NoReturnAttr);
+return CI;
   }
   }
   llvm_unreachable("Incorrect MSVC intrinsic!");
@@ -11851,9 +11850,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 llvm::AttributeList NoReturnAttr = llvm::AttributeList::get(
 getLLVMContext(), llvm::AttributeList::FunctionIndex,
 llvm::Attribute::NoReturn);
-CallSite CS = Builder.CreateCall(IA);
-CS.setAttributes(NoReturnAttr);
-return CS.getInstruction();
+llvm::CallInst *CI = Builder.CreateCall(IA);
+CI->setAttributes(NoReturnAttr);
+return CI;
   }
   case X86::BI__readfsbyte:
   case X86::BI__readfsword:

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=352595&r1=352594&r2=352595&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Tue Jan 29 18:54:28 2019
@@ -17,7 +17,6 @@
 #include "clang/AST/Decl.h"
 #include "clang/CodeGen/ConstantInitBuilder.h"
 #include "llvm/IR/BasicBlock.h"
-#include "llvm/IR/CallSite.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/Support/Format.h"
@@ -208,11 +207,11 @@ void CGNVCUDARuntime::emitDeviceStubBody
 llvm::ConstantInt::get(SizeTy, TyWidth.getQuantity()),
 llvm::ConstantInt::get(SizeTy, Offset.getQuantity()),
 };
-llvm::CallSite CS = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
+llvm::CallBase *CB = CGF.EmitRuntimeCallOrInvoke(cudaSetupArgFn, Args);
 llvm::Constant *Zero = llvm::ConstantInt::get(IntTy, 0);
-llvm::Value *CSZero = CGF.

r352593 - Simplify and modernize this code a little.

2019-01-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jan 29 18:23:34 2019
New Revision: 352593

URL: http://llvm.org/viewvc/llvm-project?rev=352593&view=rev
Log:
Simplify and modernize this code a little.

No functionality change intended.

Modified:
cfe/trunk/lib/Basic/FileManager.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=352593&r1=352592&r2=352593&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Jan 29 18:23:34 2019
@@ -35,14 +35,6 @@
 
 using namespace clang;
 
-/// NON_EXISTENT_DIR - A special value distinct from null that is used to
-/// represent a dir name that doesn't exist on the disk.
-#define NON_EXISTENT_DIR reinterpret_cast((intptr_t)-1)
-
-/// NON_EXISTENT_FILE - A special value distinct from null that is used to
-/// represent a filename that doesn't exist on the disk.
-#define NON_EXISTENT_FILE reinterpret_cast((intptr_t)-1)
-
 
//===--===//
 // Common logic.
 
//===--===//
@@ -95,14 +87,13 @@ void FileManager::addAncestorsAsVirtualD
   if (DirName.empty())
 DirName = ".";
 
-  auto &NamedDirEnt =
-  *SeenDirEntries.insert(std::make_pair(DirName, nullptr)).first;
+  auto &NamedDirEnt = *SeenDirEntries.insert({DirName, nullptr}).first;
 
   // When caching a virtual directory, we always cache its ancestors
   // at the same time.  Therefore, if DirName is already in the cache,
   // we don't need to recurse as its ancestors must also already be in
-  // the cache.
-  if (NamedDirEnt.second && NamedDirEnt.second != NON_EXISTENT_DIR)
+  // the cache (or it's a known non-virtual directory).
+  if (NamedDirEnt.second)
 return;
 
   // Add the virtual directory to the cache.
@@ -136,19 +127,17 @@ const DirectoryEntry *FileManager::getDi
 #endif
 
   ++NumDirLookups;
-  auto &NamedDirEnt =
-  *SeenDirEntries.insert(std::make_pair(DirName, nullptr)).first;
 
   // See if there was already an entry in the map.  Note that the map
   // contains both virtual and real directories.
-  if (NamedDirEnt.second)
-return NamedDirEnt.second == NON_EXISTENT_DIR ? nullptr
-  : NamedDirEnt.second;
+  auto SeenDirInsertResult = SeenDirEntries.insert({DirName, nullptr});
+  if (!SeenDirInsertResult.second)
+return SeenDirInsertResult.first->second;
 
+  // We've not seen this before. Fill it in.
   ++NumDirCacheMisses;
-
-  // By default, initialize it to invalid.
-  NamedDirEnt.second = NON_EXISTENT_DIR;
+  auto &NamedDirEnt = *SeenDirInsertResult.first;
+  assert(!NamedDirEnt.second && "should be newly-created");
 
   // Get the null-terminated directory name as stored as the key of the
   // SeenDirEntries map.
@@ -184,18 +173,14 @@ const FileEntry *FileManager::getFile(St
   ++NumFileLookups;
 
   // See if there is already an entry in the map.
-  auto &NamedFileEnt =
-  *SeenFileEntries.insert(std::make_pair(Filename, nullptr)).first;
-
-  // See if there is already an entry in the map.
-  if (NamedFileEnt.second)
-return NamedFileEnt.second == NON_EXISTENT_FILE ? nullptr
-: NamedFileEnt.second;
+  auto SeenFileInsertResult = SeenFileEntries.insert({Filename, nullptr});
+  if (!SeenFileInsertResult.second)
+return SeenFileInsertResult.first->second;
 
+  // We've not seen this before. Fill it in.
   ++NumFileCacheMisses;
-
-  // By default, initialize it to invalid.
-  NamedFileEnt.second = NON_EXISTENT_FILE;
+  auto &NamedFileEnt = *SeenFileInsertResult.first;
+  assert(!NamedFileEnt.second && "should be newly-created");
 
   // Get the null-terminated file name as stored as the key of the
   // SeenFileEntries map.
@@ -218,7 +203,7 @@ const FileEntry *FileManager::getFile(St
   // FIXME: Use the directory info to prune this, before doing the stat 
syscall.
   // FIXME: This will reduce the # syscalls.
 
-  // Nope, there isn't.  Check to see if the file exists.
+  // Check to see if the file exists.
   std::unique_ptr F;
   FileData Data;
   if (getStatValue(InterndFileName, Data, true, openFile ? &F : nullptr)) {
@@ -240,13 +225,9 @@ const FileEntry *FileManager::getFile(St
   // If the name returned by getStatValue is different than Filename, re-intern
   // the name.
   if (Data.Name != Filename) {
-auto &NamedFileEnt =
-*SeenFileEntries.insert(std::make_pair(Data.Name, nullptr)).first;
-if (!NamedFileEnt.second)
-  NamedFileEnt.second = &UFE;
-else
-  assert(NamedFileEnt.second == &UFE &&
- "filename from getStatValue() refers to wrong file");
+auto &NamedFileEnt = *SeenFileEntries.insert({Data.Name, &UFE}).first;
+assert(NamedFileEnt.second == &UFE &&
+   "filename from getStatValue

[PATCH] D57433: [analyzer] [RetainCountChecker] Bugfix for tracking top-level parameters of Objective-C methods

2019-01-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352588: [analyzer] [RetainCountChecker] Bugfix for tracking 
top-level parameters of… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57433?vs=184221&id=184225#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57433/new/

https://reviews.llvm.org/D57433

Files:
  include/clang/Analysis/RetainSummaryManager.h
  lib/Analysis/RetainSummaryManager.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  test/Analysis/retain-release.m



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


[PATCH] D57432: [CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia standard

2019-01-29 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352586: [CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia 
standard (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57432?vs=184218&id=184222#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57432/new/

https://reviews.llvm.org/D57432

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -35,7 +35,6 @@
   list(APPEND BUILTIN_TARGETS "default")
   list(APPEND RUNTIME_TARGETS "default")
 
-  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()


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -35,7 +35,6 @@
   list(APPEND BUILTIN_TARGETS "default")
   list(APPEND RUNTIME_TARGETS "default")
 
-  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()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352586 - [CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia standard

2019-01-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jan 29 18:06:06 2019
New Revision: 352586

URL: http://llvm.org/viewvc/llvm-project?rev=352586&view=rev
Log:
[CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia standard

Turned out this is used by Flutter which uses Fuchsia Clang toolchain.

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

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

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=352586&r1=352585&r2=352586&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Tue Jan 29 18:06:06 2019
@@ -35,7 +35,6 @@ if(APPLE)
   list(APPEND BUILTIN_TARGETS "default")
   list(APPEND RUNTIME_TARGETS "default")
 
-  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()


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


[PATCH] D57431: [CMake][Fuchsia] Enable hermetic static libunwind for Fuchsia

2019-01-29 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352584: [CMake][Fuchsia] Enable hermetic static libunwind 
for Fuchsia (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57431?vs=184216&id=184220#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57431/new/

https://reviews.llvm.org/D57431

Files:
  cmake/caches/Fuchsia-stage2.cmake


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -114,6 +114,7 @@
 set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
 set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL 
"")


Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -114,6 +114,7 @@
 set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
 set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352584 - [CMake][Fuchsia] Enable hermetic static libunwind for Fuchsia

2019-01-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jan 29 18:02:25 2019
New Revision: 352584

URL: http://llvm.org/viewvc/llvm-project?rev=352584&view=rev
Log:
[CMake][Fuchsia] Enable hermetic static libunwind for Fuchsia

In addition to libc++abi and libc++, we also want to use hermetic
static libunwind on Fuchsia.

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

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

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=352584&r1=352583&r2=352584&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Tue Jan 29 18:02:25 2019
@@ -114,6 +114,7 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
 set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL 
"")


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


[PATCH] D57432: [CMake][Fuchsia] Re-enable iOS runtimes for Fuchsia standard

2019-01-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: jakehehrlich.
Herald added subscribers: cfe-commits, mgorny.

Turned out this is used by Flutter which uses Fuchsia Clang toolchain.


Repository:
  rC Clang

https://reviews.llvm.org/D57432

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -35,7 +35,6 @@
   list(APPEND BUILTIN_TARGETS "default")
   list(APPEND RUNTIME_TARGETS "default")
 
-  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()


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -35,7 +35,6 @@
   list(APPEND BUILTIN_TARGETS "default")
   list(APPEND RUNTIME_TARGETS "default")
 
-  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()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57431: [CMake][Fuchsia] Enable hermetic static libunwind for Fuchsia

2019-01-29 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: jakehehrlich.
Herald added subscribers: cfe-commits, mgorny.
jakehehrlich accepted this revision.
This revision is now accepted and ready to land.

In addition to libc++abi and libc++, we also want to use hermetic
static libunwind on Fuchsia.


Repository:
  rC Clang

https://reviews.llvm.org/D57431

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -114,6 +114,7 @@
 set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} 
CACHE PATH "")
 set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY ON CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE 
BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL 
"")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -114,6 +114,7 @@
 set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
 set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia_LIBUNWIND_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57427: [CodeGen][ObjC] Fix assert on calling `__builtin_constant_p` with ObjC objects.

2019-01-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D57427#1376493 , @void wrote:

> LGTM, but may want to wait for other reviewers.


Thanks for the prompt review, Bill. I'll wait for other reviewers to confirm 
the change makes sense for Objective-C.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57427/new/

https://reviews.llvm.org/D57427



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


[PATCH] D57427: [CodeGen][ObjC] Fix assert on calling `__builtin_constant_p` with ObjC objects.

2019-01-29 Thread Bill Wendling via Phabricator via cfe-commits
void accepted this revision.
void added a comment.
This revision is now accepted and ready to land.

LGTM, but may want to wait for other reviewers.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57427/new/

https://reviews.llvm.org/D57427



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


[PATCH] D57427: [CodeGen][ObjC] Fix assert on calling `__builtin_constant_p` with ObjC objects.

2019-01-29 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rjmccall, ahatanak, void.
Herald added subscribers: dexonsmith, jkorous.

When we are calling `__builtin_constant_p` with ObjC objects of
different classes, we hit the assertion

> Assertion failed: (isa(Val) && "cast() argument of incompatible 
> type!"), function cast, file include/llvm/Support/Casting.h, line 254.

It happens because LLVM types for `ObjCInterfaceType` are opaque and
have no name (see `CodeGenTypes::ConvertType`). As the result, for
different ObjC classes we have different `is_constant` intrinsics with
the same name `llvm.is.constant.p0s_s`. When we try to reuse an
intrinsic with the same name, we fail because of type mismatch.

Fix by bitcasting `ObjCObjectPointerType` to `id` prior to passing as an
argument to `__builtin_constant_p`. This results in using intrinsic
`llvm.is.constant.p0i8` and correct types.

rdar://problem/47499250


https://reviews.llvm.org/D57427

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenObjC/builtin-constant-p.m


Index: clang/test/CodeGenObjC/builtin-constant-p.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/builtin-constant-p.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -O3 -o - %s | 
FileCheck %s
+
+// Test that can call `__builtin_constant_p` with instances of different
+// Objective-C classes.
+// rdar://problem/47499250
+@class Foo;
+@class Bar;
+
+extern void callee(void);
+
+// CHECK-LABEL: define void @test(%0* %foo, %1* %bar)
+void test(Foo *foo, Bar *bar) {
+  // CHECK: [[ADDR_FOO:%.*]] = bitcast %0* %foo to i8*
+  // CHECK-NEXT: call i1 @llvm.is.constant.p0i8(i8* [[ADDR_FOO]])
+  // CHECK: [[ADDR_BAR:%.*]] = bitcast %1* %bar to i8*
+  // CHECK-NEXT: call i1 @llvm.is.constant.p0i8(i8* [[ADDR_BAR]])
+  if (__builtin_constant_p(foo) && __builtin_constant_p(bar))
+callee();
+}
+
+// Test other Objective-C types.
+// CHECK-LABEL: define void @test_more(i8* %object, i8* %klass)
+void test_more(id object, Class klass) {
+  // CHECK: call i1 @llvm.is.constant.p0i8(i8* %object)
+  // CHECK: call i1 @llvm.is.constant.p0i8(i8* %klass)
+  if (__builtin_constant_p(object) && __builtin_constant_p(klass))
+callee();
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1972,6 +1972,12 @@
   return RValue::get(ConstantInt::get(ResultType, 0));
 
 Value *ArgValue = EmitScalarExpr(Arg);
+if (ArgType->isObjCObjectPointerType()) {
+  // Convert Objective-C objects to id because we cannot distinguish 
between
+  // LLVM types for Obj-C classes as they are opaque.
+  ArgType = CGM.getContext().getObjCIdType();
+  ArgValue = Builder.CreateBitCast(ArgValue, ConvertType(ArgType));
+}
 Value *F = CGM.getIntrinsic(Intrinsic::is_constant, ConvertType(ArgType));
 Value *Result = Builder.CreateCall(F, ArgValue);
 if (Result->getType() != ResultType)


Index: clang/test/CodeGenObjC/builtin-constant-p.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/builtin-constant-p.m
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -O3 -o - %s | FileCheck %s
+
+// Test that can call `__builtin_constant_p` with instances of different
+// Objective-C classes.
+// rdar://problem/47499250
+@class Foo;
+@class Bar;
+
+extern void callee(void);
+
+// CHECK-LABEL: define void @test(%0* %foo, %1* %bar)
+void test(Foo *foo, Bar *bar) {
+  // CHECK: [[ADDR_FOO:%.*]] = bitcast %0* %foo to i8*
+  // CHECK-NEXT: call i1 @llvm.is.constant.p0i8(i8* [[ADDR_FOO]])
+  // CHECK: [[ADDR_BAR:%.*]] = bitcast %1* %bar to i8*
+  // CHECK-NEXT: call i1 @llvm.is.constant.p0i8(i8* [[ADDR_BAR]])
+  if (__builtin_constant_p(foo) && __builtin_constant_p(bar))
+callee();
+}
+
+// Test other Objective-C types.
+// CHECK-LABEL: define void @test_more(i8* %object, i8* %klass)
+void test_more(id object, Class klass) {
+  // CHECK: call i1 @llvm.is.constant.p0i8(i8* %object)
+  // CHECK: call i1 @llvm.is.constant.p0i8(i8* %klass)
+  if (__builtin_constant_p(object) && __builtin_constant_p(klass))
+callee();
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1972,6 +1972,12 @@
   return RValue::get(ConstantInt::get(ResultType, 0));
 
 Value *ArgValue = EmitScalarExpr(Arg);
+if (ArgType->isObjCObjectPointerType()) {
+  // Convert Objective-C objects to id because we cannot distinguish between
+  // LLVM types for Obj-C classes as they are opaque.
+  ArgType = CGM.getContext().getObjCIdType();
+  ArgValue = Builder.CreateBitCast(ArgValue, ConvertType(ArgType));
+}
 Value *F = CGM.getIntrinsic(Intrinsic::is_constant, Conve

[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

arphaman: ping?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57345/new/

https://reviews.llvm.org/D57345



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


r352574 - Fix thread safety tests after r352549

2019-01-29 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Tue Jan 29 16:18:24 2019
New Revision: 352574

URL: http://llvm.org/viewvc/llvm-project?rev=352574&view=rev
Log:
Fix thread safety tests after r352549

Modified:
cfe/trunk/test/PCH/thread-safety-attrs.cpp
cfe/trunk/test/Sema/warn-thread-safety-analysis.c

Modified: cfe/trunk/test/PCH/thread-safety-attrs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/thread-safety-attrs.cpp?rev=352574&r1=352573&r2=352574&view=diff
==
--- cfe/trunk/test/PCH/thread-safety-attrs.cpp (original)
+++ cfe/trunk/test/PCH/thread-safety-attrs.cpp Tue Jan 29 16:18:24 2019
@@ -213,7 +213,7 @@ void sls_fun_bad_1() {
 }
 
 void sls_fun_bad_2() {
-  sls_mu.Lock();
+  sls_mu.Lock(); // expected-note{{mutex acquired here}}
   sls_mu.Lock(); // \
 // expected-warning{{acquiring mutex 'sls_mu' that is already held}}
   sls_mu.Unlock();

Modified: cfe/trunk/test/Sema/warn-thread-safety-analysis.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-thread-safety-analysis.c?rev=352574&r1=352573&r2=352574&view=diff
==
--- cfe/trunk/test/Sema/warn-thread-safety-analysis.c (original)
+++ cfe/trunk/test/Sema/warn-thread-safety-analysis.c Tue Jan 29 16:18:24 2019
@@ -77,7 +77,7 @@ int main() {
   Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires 
holding mutex 'mu2'}} \
   expected-warning{{calling function 'Foo_fun1' requires 
holding mutex 'mu1' exclusively}}
 
-  mutex_exclusive_lock(&mu1);
+  mutex_exclusive_lock(&mu1); // expected-note{{mutex acquired here}}
   mutex_shared_lock(&mu2);
   Foo_fun1(1);
 


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


[PATCH] D55734: [analyzer] Revise GenericTaintChecker's internal representation

2019-01-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352572: [analyzer] NFC: GenericTaintChecker: Revise rule 
specification mechanisms. (authored by dergachev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55734?vs=179436&id=184201#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734

Files:
  lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Index: lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -22,6 +22,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include 
+#include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -45,7 +47,7 @@
   static const unsigned ReturnValueIndex = UINT_MAX - 1;
 
   mutable std::unique_ptr BT;
-  inline void initBugType() const {
+  void initBugType() const {
 if (!BT)
   BT.reset(new BugType(this, "Use of Untrusted Data", "Untrusted Data"));
   }
@@ -71,7 +73,7 @@
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Functions defining the attack surface.
-  typedef ProgramStateRef (GenericTaintChecker::*FnCheck)(
+  using FnCheck = ProgramStateRef (GenericTaintChecker::*)(
   const CallExpr *, CheckerContext &C) const;
   ProgramStateRef postScanf(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postSocket(const CallExpr *CE, CheckerContext &C) const;
@@ -102,7 +104,7 @@
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  typedef SmallVector ArgVector;
+  using ArgVector = SmallVector;
 
   /// A struct used to specify taint propagation rules for a function.
   ///
@@ -114,48 +116,47 @@
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
+enum class VariadicType { None, Src, Dst };
+
 /// List of arguments which can be taint sources and should be checked.
 ArgVector SrcArgs;
 /// List of arguments which should be tainted on function return.
 ArgVector DstArgs;
-// TODO: Check if using other data structures would be more optimal.
-
-TaintPropagationRule() {}
-
-TaintPropagationRule(unsigned SArg, unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
-
-TaintPropagationRule(unsigned SArg1, unsigned SArg2, unsigned DArg,
- bool TaintRet = false) {
-  SrcArgs.push_back(SArg1);
-  SrcArgs.push_back(SArg2);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
+/// Index for the first variadic parameter if exist.
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it marks all
+/// of them as source or destination.
+VariadicType VarType;
+
+TaintPropagationRule()
+: VariadicIndex(InvalidArgIndex), VarType(VariadicType::None) {}
+
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
 getTaintPropagationRule(const FunctionDecl *FDecl, StringRef Name,
 CheckerContext &C);
 
-inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A) { DstArgs.push_back(A); }
+void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
+void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}
 
-inline bool isDestinationArgument(unsigned ArgNum) const {
-  return (std::find(DstArgs.begin(), DstArgs.end(), ArgNum) !=
-  DstArgs.end());
+bool isDestinationArgument(unsigned ArgNum) const {
+  return (llvm::find(DstArgs, ArgNum) != DstArgs.end());
 }
 
-static inline bool isTaintedOrPointsToTainted(const Expr *E,
-  ProgramStateRef State,
-  CheckerContext &C) {
+static bool isTaintedOrPointsToTainted(const Expr *E, ProgramStateRef State,
+   Checke

[PATCH] D55734: [analyzer] Revise GenericTaintChecker's internal representation

2019-01-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, the diff is a mixture of D54918  and this 
patch. I'll apply it by reverting D54918  
locally and then applying this diff, but please let us know if you accidentally 
uploaded a wrong diff!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55734/new/

https://reviews.llvm.org/D55734



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


r352572 - [analyzer] NFC: GenericTaintChecker: Revise rule specification mechanisms.

2019-01-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jan 29 16:06:43 2019
New Revision: 352572

URL: http://llvm.org/viewvc/llvm-project?rev=352572&view=rev
Log:
[analyzer] NFC: GenericTaintChecker: Revise rule specification mechanisms.

Provide a more powerful and at the same time more readable way of specifying
taint propagation rules for known functions within the checker.

Now it should be possible to specify an unlimited amount of source and
destination parameters for taint propagation.

No functional change intended just yet.

Patch by Gábor Borsik!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp?rev=352572&r1=352571&r2=352572&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Tue Jan 29 
16:06:43 2019
@@ -22,6 +22,8 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include 
+#include 
+#include 
 
 using namespace clang;
 using namespace ento;
@@ -45,7 +47,7 @@ private:
   static const unsigned ReturnValueIndex = UINT_MAX - 1;
 
   mutable std::unique_ptr BT;
-  inline void initBugType() const {
+  void initBugType() const {
 if (!BT)
   BT.reset(new BugType(this, "Use of Untrusted Data", "Untrusted Data"));
   }
@@ -71,7 +73,7 @@ private:
   static Optional getPointedToSVal(CheckerContext &C, const Expr *Arg);
 
   /// Functions defining the attack surface.
-  typedef ProgramStateRef (GenericTaintChecker::*FnCheck)(
+  using FnCheck = ProgramStateRef (GenericTaintChecker::*)(
   const CallExpr *, CheckerContext &C) const;
   ProgramStateRef postScanf(const CallExpr *CE, CheckerContext &C) const;
   ProgramStateRef postSocket(const CallExpr *CE, CheckerContext &C) const;
@@ -102,7 +104,7 @@ private:
   bool generateReportIfTainted(const Expr *E, const char Msg[],
CheckerContext &C) const;
 
-  typedef SmallVector ArgVector;
+  using ArgVector = SmallVector;
 
   /// A struct used to specify taint propagation rules for a function.
   ///
@@ -114,48 +116,47 @@ private:
   /// ReturnValueIndex is added to the dst list, the return value will be
   /// tainted.
   struct TaintPropagationRule {
+enum class VariadicType { None, Src, Dst };
+
 /// List of arguments which can be taint sources and should be checked.
 ArgVector SrcArgs;
 /// List of arguments which should be tainted on function return.
 ArgVector DstArgs;
-// TODO: Check if using other data structures would be more optimal.
-
-TaintPropagationRule() {}
-
-TaintPropagationRule(unsigned SArg, unsigned DArg, bool TaintRet = false) {
-  SrcArgs.push_back(SArg);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
-
-TaintPropagationRule(unsigned SArg1, unsigned SArg2, unsigned DArg,
- bool TaintRet = false) {
-  SrcArgs.push_back(SArg1);
-  SrcArgs.push_back(SArg2);
-  DstArgs.push_back(DArg);
-  if (TaintRet)
-DstArgs.push_back(ReturnValueIndex);
-}
+/// Index for the first variadic parameter if exist.
+unsigned VariadicIndex;
+/// Show when a function has variadic parameters. If it has, it marks all
+/// of them as source or destination.
+VariadicType VarType;
+
+TaintPropagationRule()
+: VariadicIndex(InvalidArgIndex), VarType(VariadicType::None) {}
+
+TaintPropagationRule(std::initializer_list &&Src,
+ std::initializer_list &&Dst,
+ VariadicType Var = VariadicType::None,
+ unsigned VarIndex = InvalidArgIndex)
+: SrcArgs(std::move(Src)), DstArgs(std::move(Dst)),
+  VariadicIndex(VarIndex), VarType(Var) {}
 
 /// Get the propagation rule for a given function.
 static TaintPropagationRule
 getTaintPropagationRule(const FunctionDecl *FDecl, StringRef Name,
 CheckerContext &C);
 
-inline void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
-inline void addDstArg(unsigned A) { DstArgs.push_back(A); }
+void addSrcArg(unsigned A) { SrcArgs.push_back(A); }
+void addDstArg(unsigned A) { DstArgs.push_back(A); }
 
-inline bool isNull() const { return SrcArgs.empty(); }
+bool isNull() const {
+  return SrcArgs.empty() && DstArgs.empty() &&
+ VariadicType::None == VarType;
+}
 
-inline bool isDestinationArgument(unsigned ArgNum) const {
-  return (std::find(DstArgs.begin(), DstArgs.end(), ArgNum) !=
-  DstArgs.end());
+bool isDestinationArg

[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-29 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

LGTM assuming the plan is to add !nosanitize where !noreturn has been, at the 
original call site, in the follow-up change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57278/new/

https://reviews.llvm.org/D57278



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


[PATCH] D56959: [AST] NFC: Introduce new class GenericSelectionExpr::Association

2019-01-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire abandoned this revision.
steveire added a comment.

An alternative was written and committed.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56959/new/

https://reviews.llvm.org/D56959



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


[PATCH] D57419: [ASTDump] Move Decl node dumping to TextNodeDumper

2019-01-29 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, jfb.

Repository:
  rC Clang

https://reviews.llvm.org/D57419

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -266,6 +266,8 @@
   }
 }
   }
+
+  ConstDeclVisitor::Visit(D);
 }
 
 void TextNodeDumper::Visit(const CXXCtorInitializer *Init) {
@@ -1196,3 +1198,700 @@
   if (auto N = T->getNumExpansions())
 OS << " expansions " << *N;
 }
+
+void TextNodeDumper::VisitLabelDecl(const LabelDecl *D) { dumpName(D); }
+
+void TextNodeDumper::VisitTypedefDecl(const TypedefDecl *D) {
+  dumpName(D);
+  dumpType(D->getUnderlyingType());
+  if (D->isModulePrivate())
+OS << " __module_private__";
+}
+
+void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
+  if (D->isScoped()) {
+if (D->isScopedUsingClassTag())
+  OS << " class";
+else
+  OS << " struct";
+  }
+  dumpName(D);
+  if (D->isModulePrivate())
+OS << " __module_private__";
+  if (D->isFixed())
+dumpType(D->getIntegerType());
+}
+
+void TextNodeDumper::VisitRecordDecl(const RecordDecl *D) {
+  OS << ' ' << D->getKindName();
+  dumpName(D);
+  if (D->isModulePrivate())
+OS << " __module_private__";
+  if (D->isCompleteDefinition())
+OS << " definition";
+}
+
+void TextNodeDumper::VisitEnumConstantDecl(const EnumConstantDecl *D) {
+  dumpName(D);
+  dumpType(D->getType());
+}
+
+void TextNodeDumper::VisitIndirectFieldDecl(const IndirectFieldDecl *D) {
+  dumpName(D);
+  dumpType(D->getType());
+
+  for (const auto *Child : D->chain())
+dumpDeclRef(Child);
+}
+
+void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
+  dumpName(D);
+  dumpType(D->getType());
+
+  StorageClass SC = D->getStorageClass();
+  if (SC != SC_None)
+OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
+  if (D->isInlineSpecified())
+OS << " inline";
+  if (D->isVirtualAsWritten())
+OS << " virtual";
+  if (D->isModulePrivate())
+OS << " __module_private__";
+
+  if (D->isPure())
+OS << " pure";
+  if (D->isDefaulted()) {
+OS << " default";
+if (D->isDeleted())
+  OS << "_delete";
+  }
+  if (D->isDeletedAsWritten())
+OS << " delete";
+  if (D->isTrivial())
+OS << " trivial";
+
+  if (const auto *FPT = D->getType()->getAs()) {
+FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
+switch (EPI.ExceptionSpec.Type) {
+default:
+  break;
+case EST_Unevaluated:
+  OS << " noexcept-unevaluated " << EPI.ExceptionSpec.SourceDecl;
+  break;
+case EST_Uninstantiated:
+  OS << " noexcept-uninstantiated " << EPI.ExceptionSpec.SourceTemplate;
+  break;
+}
+  }
+
+  if (const auto *MD = dyn_cast(D)) {
+if (MD->size_overridden_methods() != 0) {
+  auto dumpOverride = [=](const CXXMethodDecl *D) {
+SplitQualType T_split = D->getType().split();
+OS << D << " " << D->getParent()->getName()
+   << "::" << D->getNameAsString() << " '"
+   << QualType::getAsString(T_split, PrintPolicy) << "'";
+  };
+
+  AddChild([=] {
+auto Overrides = MD->overridden_methods();
+OS << "Overrides: [ ";
+dumpOverride(*Overrides.begin());
+for (const auto *Override :
+ llvm::make_range(Overrides.begin() + 1, Overrides.end())) {
+  OS << ", ";
+  dumpOverride(Override);
+}
+OS << " ]";
+  });
+}
+  }
+
+  // Since NumParams comes from the FunctionProtoType of the FunctionDecl and
+  // the Params are set later, it is possible for a dump during debugging to
+  // encounter a FunctionDecl that has been created but hasn't been assigned
+  // ParmVarDecls yet.
+  if (!D->param_empty() && !D->param_begin())
+OS << " <>>";
+}
+
+void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
+  dumpName(D);
+  dumpType(D->getType());
+  if (D->isMutable())
+OS << " mutable";
+  if (D->isModulePrivate())
+OS << " __module_private__";
+}
+
+void TextNodeDumper::VisitVarDecl(const VarDecl *D) {
+  dumpName(D);
+  dumpType(D->getType());
+  StorageClass SC = D->getStorageClass();
+  if (SC != SC_None)
+OS << ' ' << VarDecl::getStorageClassSpecifierString(SC);
+  switch (D->getTLSKind()) {
+  case VarDecl::TLS_None:
+break;
+  case VarDecl::TLS_Static:
+OS << " tls";
+break;
+  case VarDecl::TLS_Dynamic:
+OS << " tls_dynamic";
+break;
+  }
+  if (D->isModulePrivate())
+OS << " __module_private__";
+  if (D->isNRVOVariable())
+OS << " nrvo";
+  if (D->isInline())
+OS << " inline";
+  if (D->isConstexpr())
+OS << " constexpr";
+  if (D->hasInit()) {
+switch (D->getInitStyle()) {
+case VarDecl::CInit:
+  OS << " cinit";
+  break;
+case VarDecl::Ca

[PATCH] D56961: NFC: Move GenericSelectionExpr dump to NodeDumper

2019-01-29 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352558: NFC: Move GenericSelectionExpr dump to NodeDumper 
(authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56961?vs=182674&id=184187#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56961/new/

https://reviews.llvm.org/D56961

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -776,6 +776,11 @@
   }
 }
 
+void TextNodeDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
+  if (E->isResultDependent())
+OS << " result_dependent";
+}
+
 void TextNodeDumper::VisitUnaryOperator(const UnaryOperator *Node) {
   OS << " " << (Node->isPostfix() ? "postfix" : "prefix") << " '"
  << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -1467,8 +1467,6 @@
 }
 
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
-  if (E->isResultDependent())
-OS << " result_dependent";
   dumpStmt(E->getControllingExpr());
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -237,6 +237,7 @@
   void VisitFloatingLiteral(const FloatingLiteral *Node);
   void VisitStringLiteral(const StringLiteral *Str);
   void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
   void VisitUnaryOperator(const UnaryOperator *Node);
   void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
   void VisitMemberExpr(const MemberExpr *Node);


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -776,6 +776,11 @@
   }
 }
 
+void TextNodeDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
+  if (E->isResultDependent())
+OS << " result_dependent";
+}
+
 void TextNodeDumper::VisitUnaryOperator(const UnaryOperator *Node) {
   OS << " " << (Node->isPostfix() ? "postfix" : "prefix") << " '"
  << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -1467,8 +1467,6 @@
 }
 
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
-  if (E->isResultDependent())
-OS << " result_dependent";
   dumpStmt(E->getControllingExpr());
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -237,6 +237,7 @@
   void VisitFloatingLiteral(const FloatingLiteral *Node);
   void VisitStringLiteral(const StringLiteral *Str);
   void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
   void VisitUnaryOperator(const UnaryOperator *Node);
   void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
   void VisitMemberExpr(const MemberExpr *Node);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] r352559 - [libunwind] Support building hermetic static library

2019-01-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jan 29 15:01:08 2019
New Revision: 352559

URL: http://llvm.org/viewvc/llvm-project?rev=352559&view=rev
Log:
[libunwind] Support building hermetic static library

This is useful when the static libunwind library is being linked into
shared libraries that may be used in with other shared libraries that
use different unwinder. We want to avoid avoid exporting libunwind
symbols in those cases. This achieved by a new CMake option which can be
enabled by libunwind vendors as needed.

The same CMake option has already been added to libc++ and libc++abi in
D55404 and D56026.

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=352559&r1=352558&r2=352559&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Jan 29 15:01:08 2019
@@ -168,6 +168,9 @@ elseif(LIBUNWIND_BUILD_32_BITS)
   message(FATAL_ERROR "LIBUNWIND_BUILD_32_BITS=ON is not supported on this 
platform.")
 endif()
 
+option(LIBUNWIND_HERMETIC_STATIC_LIBRARY
+  "Do not export any symbols from the static library." OFF)
+
 
#===
 # Configure System
 
#===

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=352559&r1=352558&r2=352559&view=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Tue Jan 29 15:01:08 2019
@@ -105,17 +105,44 @@ set_property(SOURCE ${LIBUNWIND_CXX_SOUR
 set_property(SOURCE ${LIBUNWIND_C_SOURCES}
  APPEND_STRING PROPERTY COMPILE_FLAGS " ${LIBUNWIND_C_FLAGS}")
 
+macro(unwind_object_library name)
+  cmake_parse_arguments(ARGS "" "" "DEFINES;FLAGS" ${ARGN})
+
 # Add a object library that contains the compiled source files.
-add_library(unwind_objects OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
+  add_library(${name} OBJECT ${LIBUNWIND_SOURCES} ${LIBUNWIND_HEADERS})
+
+  if(ARGS_DEFINES)
+target_compile_definitions(${name} PRIVATE ${ARGS_DEFINES})
+  endif()
+
+  set_target_properties(${name}
+PROPERTIES
+  COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
+  POSITION_INDEPENDENT_CODE ON)
+
+  if(ARGS_FLAGS)
+target_compile_options(${name} PRIVATE ${ARGS_FLAGS})
+  endif()
+endmacro()
 
-set_target_properties(unwind_objects
-  PROPERTIES
-COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}"
-POSITION_INDEPENDENT_CODE ON)
+if(LIBUNWIND_HERMETIC_STATIC_LIBRARY)
+  append_flags_if_supported(UNWIND_STATIC_OBJECTS_FLAGS -fvisibility=hidden)
+  append_flags_if_supported(UNWIND_STATIC_OBJECTS_FLAGS 
-fvisibility-global-new-delete-hidden)
+  unwind_object_library(unwind_static_objects
+DEFINES _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS
+FLAGS ${UNWIND_STATIC_OBJECTS_FLAGS})
+  unwind_object_library(unwind_shared_objects)
+  set(unwind_static_sources $)
+  set(unwind_shared_sources $)
+else()
+  unwind_object_library(unwind_objects)
+  set(unwind_static_sources $)
+  set(unwind_shared_sources $)
+endif()
 
 # Build the shared library.
 if (LIBUNWIND_ENABLE_SHARED)
-  add_library(unwind_shared SHARED $)
+  add_library(unwind_shared SHARED ${unwind_shared_sources})
   if(COMMAND llvm_setup_rpath)
 llvm_setup_rpath(unwind_shared)
   endif()
@@ -134,7 +161,7 @@ endif()
 
 # Build the static library.
 if (LIBUNWIND_ENABLE_STATIC)
-  add_library(unwind_static STATIC $)
+  add_library(unwind_static STATIC ${unwind_static_sources})
   target_link_libraries(unwind_static ${libraries})
   set_target_properties(unwind_static
 PROPERTIES


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


r352558 - NFC: Move GenericSelectionExpr dump to NodeDumper

2019-01-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 29 14:58:28 2019
New Revision: 352558

URL: http://llvm.org/viewvc/llvm-project?rev=352558&view=rev
Log:
NFC: Move GenericSelectionExpr dump to NodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=352558&r1=352557&r2=352558&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 29 14:58:28 2019
@@ -237,6 +237,7 @@ public:
   void VisitFloatingLiteral(const FloatingLiteral *Node);
   void VisitStringLiteral(const StringLiteral *Str);
   void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
   void VisitUnaryOperator(const UnaryOperator *Node);
   void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
   void VisitMemberExpr(const MemberExpr *Node);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352558&r1=352557&r2=352558&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 29 14:58:28 2019
@@ -1467,8 +1467,6 @@ void ASTDumper::Visit(const GenericSelec
 }
 
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
-  if (E->isResultDependent())
-OS << " result_dependent";
   dumpStmt(E->getControllingExpr());
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=352558&r1=352557&r2=352558&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 29 14:58:28 2019
@@ -776,6 +776,11 @@ void TextNodeDumper::VisitInitListExpr(c
   }
 }
 
+void TextNodeDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
+  if (E->isResultDependent())
+OS << " result_dependent";
+}
+
 void TextNodeDumper::VisitUnaryOperator(const UnaryOperator *Node) {
   OS << " " << (Node->isPostfix() ? "postfix" : "prefix") << " '"
  << UnaryOperator::getOpcodeStr(Node->getOpcode()) << "'";


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


[libunwind] r352553 - Drop the dependency on , add placement new inline

2019-01-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jan 29 14:26:18 2019
New Revision: 352553

URL: http://llvm.org/viewvc/llvm-project?rev=352553&view=rev
Log:
Drop the dependency on , add placement new inline

We haven't eliminated C++ library dependency altogether in D57251,
UnwindCursor.hpp had an unused dependency on  which was
pulling in other C++ headers. Removing that dependency also revealed
(correctly) that we need our own global placement new declaration. Now
libunwind should be independent of the C++ library.

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/Unwind-EHABI.cpp
libunwind/trunk/src/Unwind-seh.cpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=352553&r1=352552&r2=352553&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Jan 29 14:26:18 2019
@@ -287,6 +287,9 @@ unwind_append_if(LIBUNWIND_CXX_FLAGS LIB
 
 unwind_append_if(LIBUNWIND_C_FLAGS LIBUNWIND_HAS_FUNWIND_TABLES 
-funwind-tables)
 
+# Ensure that we don't depend on C++ standard library.
+unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NOSTDINCXX_FLAG -nostdinc++)
+
 # Assert
 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
 if (LIBUNWIND_ENABLE_ASSERTIONS)
@@ -341,28 +344,6 @@ endif()
 
 include_directories(include)
 
-find_path(
-  LIBUNWIND_LIBCXX_INCLUDES_INTERNAL
-  __libcpp_version
-  PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
-${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
-${LLVM_MAIN_SRC_DIR}/../libcxx/include
-  NO_DEFAULT_PATH
-  NO_CMAKE_FIND_ROOT_PATH
-  )
-if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
-IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
-  set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
-endif()
-
-set(LIBUNWIND_CXX_INCLUDE_PATHS "${LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT}" CACHE 
PATH
-"Paths to C++ header directories separated by ';'.")
-
-if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STREQUAL "")
-  list(APPEND LIBUNWIND_CXX_FLAGS -nostdinc++)
-  include_directories("${LIBUNWIND_CXX_INCLUDE_PATHS}")
-endif()
-
 add_subdirectory(src)
 
 if (LIBUNWIND_INCLUDE_DOCS)

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=352553&r1=352552&r2=352553&view=diff
==
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Tue Jan 29 14:26:18 2019
@@ -20,8 +20,6 @@
 #include 
 #include 
 
-#include 
-
 #include "config.h"
 #include "libunwind.h"
 #include "libunwind_ext.h"

Modified: libunwind/trunk/src/Unwind-seh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-seh.cpp?rev=352553&r1=352552&r2=352553&view=diff
==
--- libunwind/trunk/src/Unwind-seh.cpp (original)
+++ libunwind/trunk/src/Unwind-seh.cpp Tue Jan 29 14:26:18 2019
@@ -49,6 +49,10 @@ using namespace libunwind;
 /// Class of foreign exceptions based on unrecognized SEH exceptions.
 static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0
 
+// libunwind does not and should not depend on C++ library which means that we
+// need our own declaration of global placement new.
+void *operator new(size_t, void*);
+
 /// Exception cleanup routine used by \c _GCC_specific_handler to
 /// free foreign exceptions.
 static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=352553&r1=352552&r2=352553&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Tue Jan 29 14:26:18 2019
@@ -11,7 +11,6 @@
 #ifndef __UNWINDCURSOR_HPP__
 #define __UNWINDCURSOR_HPP__
 
-#include 
 #include 
 #include 
 #include 
@@ -105,7 +104,6 @@ private:
   static void dyldUnloadHook(const struct mach_header *mh, intptr_t slide);
   static bool _registeredForDyldUnloads;
 #endif
-  // Can't use std::vector<> here because this code is below libc++.
   static entry *_buffer;
   static entry *_bufferUsed;
   static entry *_bufferEnd;
@@ -1225,7 +1223,6 @@ template
 struct EHABISectionIterator {
   typedef EHABISectionIterator _Self;
 
-  typedef std::random_access_iterator_tag iterator_category;
   typedef typename A::pint_t value_type;
   typedef typename A::pint_t* pointer;
   typedef typename A::pint_t& reference;
@@ -1279,6 +1276,29 @@ struct EHABISectionIterator {
   const UnwindInfoSections* _sects;
 };
 
+n

[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-29 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

@eugenis @delcypher
Looks good to you?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57278/new/

https://reviews.llvm.org/D57278



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


[PATCH] D56960: NFC: Implement GenericSelectionExpr::Association dump with Visitor

2019-01-29 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352552: NFC: Implement GenericSelectionExpr::Association 
dump with Visitor (authored by steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56960?vs=182673&id=184178#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56960/new/

https://reviews.llvm.org/D56960

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -297,6 +297,7 @@
 void VisitInitListExpr(const InitListExpr *ILE);
 void VisitBlockExpr(const BlockExpr *Node);
 void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
+void Visit(const GenericSelectionExpr::ConstAssociation &A);
 void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
 // C++
@@ -1456,6 +1457,15 @@
 dumpStmt(Source);
 }
 
+void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  dumpChild([=] {
+NodeDumper.Visit(A);
+if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
+  dumpTypeAsChild(TSI->getType());
+dumpStmt(A.getAssociationExpr());
+  });
+}
+
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
   if (E->isResultDependent())
 OS << " result_dependent";
@@ -1463,21 +1473,7 @@
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
   for (const auto &Assoc : E->associations()) {
-dumpChild([=] {
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo()) {
-OS << "case ";
-NodeDumper.dumpType(TSI->getType());
-  } else {
-OS << "default";
-  }
-
-  if (Assoc.isSelected())
-OS << " selected";
-
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
-dumpTypeAsChild(TSI->getType());
-  dumpStmt(Assoc.getAssociationExpr());
-});
+Visit(Assoc);
   }
 }
 
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -312,6 +312,19 @@
 OS << " ";
 }
 
+void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+  if (TSI) {
+OS << "case ";
+dumpType(TSI->getType());
+  } else {
+OS << "default";
+  }
+
+  if (A.isSelected())
+OS << " selected";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -172,6 +172,8 @@
 
   void Visit(const BlockDecl::Capture &C);
 
+  void Visit(const GenericSelectionExpr::ConstAssociation &A);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);


Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -297,6 +297,7 @@
 void VisitInitListExpr(const InitListExpr *ILE);
 void VisitBlockExpr(const BlockExpr *Node);
 void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
+void Visit(const GenericSelectionExpr::ConstAssociation &A);
 void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
 // C++
@@ -1456,6 +1457,15 @@
 dumpStmt(Source);
 }
 
+void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  dumpChild([=] {
+NodeDumper.Visit(A);
+if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
+  dumpTypeAsChild(TSI->getType());
+dumpStmt(A.getAssociationExpr());
+  });
+}
+
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
   if (E->isResultDependent())
 OS << " result_dependent";
@@ -1463,21 +1473,7 @@
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
   for (const auto &Assoc : E->associations()) {
-dumpChild([=] {
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo()) {
-OS << "case ";
-NodeDumper.dumpType(TSI->getType());
-  } else {
-OS << "default";
-  }
-
-  if (Assoc.isSelected())
-OS << " selected";
-
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
-dumpTypeAsChild(TSI->getType());
-  dumpStmt(Assoc.getAssociationExpr());
-});
+Visit(Assoc);
   }
 }
 
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -312,6 +312,19 @@
 OS << " ";
 }
 
+void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  const TypeSourceInfo *TSI 

r352552 - NFC: Implement GenericSelectionExpr::Association dump with Visitor

2019-01-29 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Jan 29 14:22:55 2019
New Revision: 352552

URL: http://llvm.org/viewvc/llvm-project?rev=352552&view=rev
Log:
NFC: Implement GenericSelectionExpr::Association dump with Visitor

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=352552&r1=352551&r2=352552&view=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Tue Jan 29 14:22:55 2019
@@ -172,6 +172,8 @@ public:
 
   void Visit(const BlockDecl::Capture &C);
 
+  void Visit(const GenericSelectionExpr::ConstAssociation &A);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=352552&r1=352551&r2=352552&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Jan 29 14:22:55 2019
@@ -297,6 +297,7 @@ namespace  {
 void VisitInitListExpr(const InitListExpr *ILE);
 void VisitBlockExpr(const BlockExpr *Node);
 void VisitOpaqueValueExpr(const OpaqueValueExpr *Node);
+void Visit(const GenericSelectionExpr::ConstAssociation &A);
 void VisitGenericSelectionExpr(const GenericSelectionExpr *E);
 
 // C++
@@ -1456,6 +1457,15 @@ void ASTDumper::VisitOpaqueValueExpr(con
 dumpStmt(Source);
 }
 
+void ASTDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  dumpChild([=] {
+NodeDumper.Visit(A);
+if (const TypeSourceInfo *TSI = A.getTypeSourceInfo())
+  dumpTypeAsChild(TSI->getType());
+dumpStmt(A.getAssociationExpr());
+  });
+}
+
 void ASTDumper::VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
   if (E->isResultDependent())
 OS << " result_dependent";
@@ -1463,21 +1473,7 @@ void ASTDumper::VisitGenericSelectionExp
   dumpTypeAsChild(E->getControllingExpr()->getType()); // FIXME: remove
 
   for (const auto &Assoc : E->associations()) {
-dumpChild([=] {
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo()) {
-OS << "case ";
-NodeDumper.dumpType(TSI->getType());
-  } else {
-OS << "default";
-  }
-
-  if (Assoc.isSelected())
-OS << " selected";
-
-  if (const TypeSourceInfo *TSI = Assoc.getTypeSourceInfo())
-dumpTypeAsChild(TSI->getType());
-  dumpStmt(Assoc.getAssociationExpr());
-});
+Visit(Assoc);
   }
 }
 

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=352552&r1=352551&r2=352552&view=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Tue Jan 29 14:22:55 2019
@@ -312,6 +312,19 @@ void TextNodeDumper::Visit(const OMPClau
 OS << " ";
 }
 
+void TextNodeDumper::Visit(const GenericSelectionExpr::ConstAssociation &A) {
+  const TypeSourceInfo *TSI = A.getTypeSourceInfo();
+  if (TSI) {
+OS << "case ";
+dumpType(TSI->getType());
+  } else {
+OS << "default";
+  }
+
+  if (A.isSelected())
+OS << " selected";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;


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


[PATCH] D57330: Adjust documentation for git migration.

2019-01-29 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D57330#1376069 , @mehdi_amini wrote:

> > You can avoid the git status pollution by adding the build directory to 
> > .git/info/exclude.
>
> Good to know! Should we include this in the doc?


I can put that change up fore review. It probably makes most sense to add it to 
www/get_started.html? There's lots of different places which document building, 
but that seems like the canonical one.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57330/new/

https://reviews.llvm.org/D57330



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


r352549 - Thread safety analysis: Improve diagnostics for double locking

2019-01-29 Thread Aaron Puchert via cfe-commits
Author: aaronpuchert
Date: Tue Jan 29 14:11:42 2019
New Revision: 352549

URL: http://llvm.org/viewvc/llvm-project?rev=352549&view=rev
Log:
Thread safety analysis: Improve diagnostics for double locking

Summary:
We use the existing diag::note_locked_here to tell the user where we saw
the first locking.

Reviewers: aaron.ballman, delesley

Reviewed By: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h?rev=352549&r1=352548&r2=352549&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h Tue Jan 29 
14:11:42 2019
@@ -128,9 +128,10 @@ public:
   /// \param Kind -- the capability's name parameter (role, mutex, etc).
   /// \param LockName -- A StringRef name for the lock expression, to be 
printed
   /// in the error message.
+  /// \param LocLocked -- The location of the first lock expression.
   /// \param Loc -- The location of the second lock expression.
   virtual void handleDoubleLock(StringRef Kind, Name LockName,
-SourceLocation Loc) {}
+SourceLocation LocLocked, SourceLocation Loc) 
{}
 
   /// Warn about situations where a mutex is sometimes held and sometimes not.
   /// The three situations are:

Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=352549&r1=352548&r2=352549&view=diff
==
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Tue Jan 29 14:11:42 2019
@@ -873,7 +873,7 @@ public:
   void handleLock(FactSet &FSet, FactManager &FactMan, const FactEntry &entry,
   ThreadSafetyHandler &Handler,
   StringRef DiagKind) const override {
-Handler.handleDoubleLock(DiagKind, entry.toString(), entry.loc());
+Handler.handleDoubleLock(DiagKind, entry.toString(), loc(), entry.loc());
   }
 
   void handleUnlock(FactSet &FSet, FactManager &FactMan,
@@ -981,12 +981,13 @@ private:
   void lock(FactSet &FSet, FactManager &FactMan, const CapabilityExpr &Cp,
 LockKind kind, SourceLocation loc, ThreadSafetyHandler *Handler,
 StringRef DiagKind) const {
-if (!FSet.findLock(FactMan, Cp)) {
+if (const FactEntry *Fact = FSet.findLock(FactMan, Cp)) {
+  if (Handler)
+Handler->handleDoubleLock(DiagKind, Cp.toString(), Fact->loc(), loc);
+} else {
   FSet.removeLock(FactMan, !Cp);
   FSet.addLock(FactMan,
llvm::make_unique(Cp, kind, loc));
-} else if (Handler) {
-  Handler->handleDoubleLock(DiagKind, Cp.toString(), loc);
 }
   }
 

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=352549&r1=352548&r2=352549&view=diff
==
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Tue Jan 29 14:11:42 2019
@@ -1638,17 +1638,6 @@ class ThreadSafetyReporter : public clan
 return ONS;
   }
 
-  // Helper functions
-  void warnLockMismatch(unsigned DiagID, StringRef Kind, Name LockName,
-SourceLocation Loc) {
-// Gracefully handle rare cases when the analysis can't get a more
-// precise source location.
-if (!Loc.isValid())
-  Loc = FunLocation;
-PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID) << Kind << LockName);
-Warnings.emplace_back(std::move(Warning), getNotes());
-  }
-
  public:
   ThreadSafetyReporter(Sema &S, SourceLocation FL, SourceLocation FEL)
 : S(S), FunLocation(FL), FunEndLocation(FEL),
@@ -1677,7 +1666,11 @@ class ThreadSafetyReporter : public clan
 
   void handleUnmatchedUnlock(StringRef Kind, Name LockName,
  SourceLocation Loc) override {
-warnLockMismatch(diag::warn_unlock_but_no_lock, Kind, LockName, Loc);
+if (Loc.isInvalid())
+  Loc = FunLocation;
+PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_unlock_but_no_lock)
+ << Kind << LockName);
+Warnings.emplace_back(std::move(Warning), getNotes());
   }
 
   void handleIncorrectUnlockKind(StringRef Kind, Name LockName,
@@ -1691,8 +1684,18 @@ class ThreadSafetyReporter : public clan
 Warnings.emplace_b

[PATCH] D56967: Thread safety analysis: Improve diagnostics for double locking

2019-01-29 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352549: Thread safety analysis: Improve diagnostics for 
double locking (authored by aaronpuchert, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56967?vs=182687&id=184170#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56967/new/

https://reviews.llvm.org/D56967

Files:
  cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h
  cfe/trunk/lib/Analysis/ThreadSafety.cpp
  cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
  cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Index: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
===
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1638,17 +1638,6 @@
 return ONS;
   }
 
-  // Helper functions
-  void warnLockMismatch(unsigned DiagID, StringRef Kind, Name LockName,
-SourceLocation Loc) {
-// Gracefully handle rare cases when the analysis can't get a more
-// precise source location.
-if (!Loc.isValid())
-  Loc = FunLocation;
-PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID) << Kind << LockName);
-Warnings.emplace_back(std::move(Warning), getNotes());
-  }
-
  public:
   ThreadSafetyReporter(Sema &S, SourceLocation FL, SourceLocation FEL)
 : S(S), FunLocation(FL), FunEndLocation(FEL),
@@ -1677,7 +1666,11 @@
 
   void handleUnmatchedUnlock(StringRef Kind, Name LockName,
  SourceLocation Loc) override {
-warnLockMismatch(diag::warn_unlock_but_no_lock, Kind, LockName, Loc);
+if (Loc.isInvalid())
+  Loc = FunLocation;
+PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_unlock_but_no_lock)
+ << Kind << LockName);
+Warnings.emplace_back(std::move(Warning), getNotes());
   }
 
   void handleIncorrectUnlockKind(StringRef Kind, Name LockName,
@@ -1691,8 +1684,18 @@
 Warnings.emplace_back(std::move(Warning), getNotes());
   }
 
-  void handleDoubleLock(StringRef Kind, Name LockName, SourceLocation Loc) override {
-warnLockMismatch(diag::warn_double_lock, Kind, LockName, Loc);
+  void handleDoubleLock(StringRef Kind, Name LockName, SourceLocation LocLocked,
+SourceLocation Loc) override {
+if (Loc.isInvalid())
+  Loc = FunLocation;
+PartialDiagnosticAt Warning(Loc, S.PDiag(diag::warn_double_lock)
+ << Kind << LockName);
+OptionalNotes Notes =
+LocLocked.isValid()
+? getNotes(PartialDiagnosticAt(
+  LocLocked, S.PDiag(diag::note_locked_here) << Kind))
+: getNotes();
+Warnings.emplace_back(std::move(Warning), std::move(Notes));
   }
 
   void handleMutexHeldEndOfScope(StringRef Kind, Name LockName,
Index: cfe/trunk/lib/Analysis/ThreadSafety.cpp
===
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp
@@ -873,7 +873,7 @@
   void handleLock(FactSet &FSet, FactManager &FactMan, const FactEntry &entry,
   ThreadSafetyHandler &Handler,
   StringRef DiagKind) const override {
-Handler.handleDoubleLock(DiagKind, entry.toString(), entry.loc());
+Handler.handleDoubleLock(DiagKind, entry.toString(), loc(), entry.loc());
   }
 
   void handleUnlock(FactSet &FSet, FactManager &FactMan,
@@ -981,12 +981,13 @@
   void lock(FactSet &FSet, FactManager &FactMan, const CapabilityExpr &Cp,
 LockKind kind, SourceLocation loc, ThreadSafetyHandler *Handler,
 StringRef DiagKind) const {
-if (!FSet.findLock(FactMan, Cp)) {
+if (const FactEntry *Fact = FSet.findLock(FactMan, Cp)) {
+  if (Handler)
+Handler->handleDoubleLock(DiagKind, Cp.toString(), Fact->loc(), loc);
+} else {
   FSet.removeLock(FactMan, !Cp);
   FSet.addLock(FactMan,
llvm::make_unique(Cp, kind, loc));
-} else if (Handler) {
-  Handler->handleDoubleLock(DiagKind, Cp.toString(), loc);
 }
   }
 
Index: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h
===
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafety.h
@@ -128,9 +128,10 @@
   /// \param Kind -- the capability's name parameter (role, mutex, etc).
   /// \param LockName -- A StringRef name for the lock expression, to be printed
   /// in the error message.
+  /// \param LocLocked -- The location of the first lock expression.
   /// \param Loc -- The location of the second lock expression.
   virtual void handleDoubleLock(StringRef Kind, Name LockName,
-SourceLocation Loc) {}
+Sour

[PATCH] D56760: Add a new builtin: __builtin_dynamic_object_size

2019-01-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

In D56760#1368279 , @erik.pilkington 
wrote:

> FWIW I'd prefer the __builtin_object_size spelling too, but it doesn't seem 
> like the GCC folks are super crazy about it to me. So it seems likely to me 
> that if we implement it it will just be a clang extension for at least the 
> medium term (if not permanently). I guess that's fine, so long as the GCC 
> people are aware that it would be bad to extend their builtin to use `type&4`.


In the absence of a commitment from the GCC folks, I think we should use the 
`__builtin_dynamic_object_size` approach for now. If they later change their 
mind we can deprecate that spelling in favor of a flag bit.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56760/new/

https://reviews.llvm.org/D56760



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


[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-29 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.

LGTM, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57278/new/

https://reviews.llvm.org/D57278



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


[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-29 Thread Julian Lettner via Phabricator via cfe-commits
yln updated this revision to Diff 184168.
yln added a comment.

Directly insert calls to `__asan_handle_no_return`

Clang-CodeGen now directly insert calls to `__asan_handle_no_return`
when a call to a noreturn function is encountered and both UBsan
unreachable and ASan are enabled. This allows UBSan to continue
removing the noreturn attribute from functions without any changes to
the ASan pass.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57278/new/

https://reviews.llvm.org/D57278

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/ubsan-asan-noreturn.c
  clang/test/CodeGenCXX/ubsan-unreachable.cpp

Index: clang/test/CodeGenCXX/ubsan-unreachable.cpp
===
--- clang/test/CodeGenCXX/ubsan-unreachable.cpp
+++ clang/test/CodeGenCXX/ubsan-unreachable.cpp
@@ -1,39 +1,37 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=unreachable | FileCheck %s
 
-extern void __attribute__((noreturn)) abort();
+void abort() __attribute__((noreturn));
 
-// CHECK-LABEL: define void @_Z14calls_noreturnv
+// CHECK-LABEL: define void @_Z14calls_noreturnv()
 void calls_noreturn() {
+  // Check absence ([^#]*) of call site attributes (including noreturn)
+  // CHECK: call void @_Z5abortv(){{[^#]*}}
   abort();
 
-  // Check that there are no attributes on the call site.
-  // CHECK-NOT: call void @_Z5abortv{{.*}}#
-
   // CHECK: __ubsan_handle_builtin_unreachable
   // CHECK: unreachable
 }
 
 struct A {
-  // CHECK: declare void @_Z5abortv{{.*}} [[ABORT_ATTR:#[0-9]+]]
+  // CHECK: declare void @_Z5abortv() [[EXTERN_FN_ATTR:#[0-9]+]]
 
   // CHECK-LABEL: define linkonce_odr void @_ZN1A5call1Ev
   void call1() {
-// CHECK-NOT: call void @_ZN1A16does_not_return2Ev{{.*}}#
+// CHECK: call void @_ZN1A16does_not_return2Ev({{.*}}){{[^#]*}}
 does_not_return2();
 
 // CHECK: __ubsan_handle_builtin_unreachable
 // CHECK: unreachable
   }
 
-  // Test static members.
-  static void __attribute__((noreturn)) does_not_return1() {
-// CHECK-NOT: call void @_Z5abortv{{.*}}#
+  // Test static members. Checks are below after `struct A` scope ends.
+  static void does_not_return1() __attribute__((noreturn)) {
 abort();
   }
 
   // CHECK-LABEL: define linkonce_odr void @_ZN1A5call2Ev
   void call2() {
-// CHECK-NOT: call void @_ZN1A16does_not_return1Ev{{.*}}#
+// CHECK: call void @_ZN1A16does_not_return1Ev(){{[^#]*}}
 does_not_return1();
 
 // CHECK: __ubsan_handle_builtin_unreachable
@@ -41,23 +39,23 @@
   }
 
   // Test calls through pointers to non-static member functions.
-  typedef void __attribute__((noreturn)) (A::*MemFn)();
+  typedef void (A::*MemFn)() __attribute__((noreturn));
 
   // CHECK-LABEL: define linkonce_odr void @_ZN1A5call3Ev
   void call3() {
 MemFn MF = &A::does_not_return2;
+// CHECK: call void %{{[0-9]+\(.*}}){{[^#]*}}
 (this->*MF)();
 
-// CHECK-NOT: call void %{{.*}}#
 // CHECK: __ubsan_handle_builtin_unreachable
 // CHECK: unreachable
   }
 
   // Test regular members.
   // CHECK-LABEL: define linkonce_odr void @_ZN1A16does_not_return2Ev({{.*}})
-  // CHECK-SAME: [[DOES_NOT_RETURN_ATTR:#[0-9]+]]
-  void __attribute__((noreturn)) does_not_return2() {
-// CHECK-NOT: call void @_Z5abortv(){{.*}}#
+  // CHECK-SAME: [[USER_FN_ATTR:#[0-9]+]]
+  void does_not_return2() __attribute__((noreturn)) {
+// CHECK: call void @_Z5abortv(){{[^#]*}}
 abort();
 
 // CHECK: call void @__ubsan_handle_builtin_unreachable
@@ -68,7 +66,9 @@
   }
 };
 
-// CHECK: define linkonce_odr void @_ZN1A16does_not_return1Ev() [[DOES_NOT_RETURN_ATTR]]
+// CHECK-LABEL: define linkonce_odr void @_ZN1A16does_not_return1Ev()
+// CHECK-SAME: [[USER_FN_ATTR]]
+// CHECK: call void @_Z5abortv(){{[^#]*}}
 
 void force_irgen() {
   A a;
@@ -77,5 +77,7 @@
   a.call3();
 }
 
-// CHECK-NOT: [[ABORT_ATTR]] = {{[^}]+}}noreturn
-// CHECK-NOT: [[DOES_NOT_RETURN_ATTR]] = {{[^}]+}}noreturn
+// `noreturn` should be removed from functions and call sites
+// CHECK-LABEL: attributes
+// CHECK-NOT: [[USER_FN_ATTR]] = { {{.*noreturn.*}} }
+// CHECK-NOT: [[EXTERN_FN_ATTR]] = { {{.*noreturn.*}} }
Index: clang/test/CodeGen/ubsan-asan-noreturn.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-asan-noreturn.c
@@ -0,0 +1,21 @@
+// Ensure compatiblity of UBSan unreachable with ASan in the presence of
+// noreturn functions.
+// RUN: %clang_cc1 -fsanitize=unreachable,address -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s
+
+void my_longjmp(void) __attribute__((noreturn));
+
+// CHECK-LABEL: define void @calls_noreturn()
+void calls_noreturn() {
+  my_longjmp();
+  // CHECK:  @__asan_handle_no_return{{.*}} !nosanitize
+  // CHECK-NEXT: @my_longjmp(){{[^#]*}}
+  // CHECK:  @__asan_handle_no_return()
+  // CHECK-NEXT: @__ubsan_handle_builtin_unreachable{{.*}} !nosanitize
+  // CHEC

Re: r352539 - Revert "OpenCL: Extend argument promotion rules to vector types"

2019-01-29 Thread Hans Wennborg via cfe-commits
Merged to 8.0 in r352547.

On Tue, Jan 29, 2019 at 3:49 PM Matt Arsenault via cfe-commits
 wrote:
>
> Author: arsenm
> Date: Tue Jan 29 12:49:47 2019
> New Revision: 352539
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352539&view=rev
> Log:
> Revert "OpenCL: Extend argument promotion rules to vector types"
>
> This reverts r348083. This was based on a misreading of the spec
> for printf specifiers.
>
> Also revert r343653, as without a subsequent patch, a correctly
> specified format for a vector will incorrectly warn.
>
> Fixes bug 40491.
>
> Modified:
> cfe/trunk/lib/Headers/opencl-c.h
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/test/CodeGenOpenCL/printf.cl
> cfe/trunk/test/SemaOpenCL/printf-format-string-warnings.cl
> cfe/trunk/test/SemaOpenCL/printf-format-strings.cl
>
> Modified: cfe/trunk/lib/Headers/opencl-c.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=352539&r1=352538&r2=352539&view=diff
> ==
> --- cfe/trunk/lib/Headers/opencl-c.h (original)
> +++ cfe/trunk/lib/Headers/opencl-c.h Tue Jan 29 12:49:47 2019
> @@ -14469,7 +14469,7 @@ half16 __ovld __cnfn shuffle2(half16 x,
>  #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
>  // OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
>
> -int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 
> 2)));
> +int printf(__constant const char* st, ...);
>  #endif
>
>  // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write 
> Functions
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=352539&r1=352538&r2=352539&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 29 12:49:47 2019
> @@ -737,33 +737,20 @@ ExprResult Sema::DefaultArgumentPromotio
>  return ExprError();
>E = Res.get();
>
> -  QualType ScalarTy = Ty;
> -  unsigned NumElts = 0;
> -  if (const ExtVectorType *VecTy = Ty->getAs()) {
> -NumElts = VecTy->getNumElements();
> -ScalarTy = VecTy->getElementType();
> -  }
> -
>// If this is a 'float'  or '__fp16' (CVR qualified or typedef)
>// promote to double.
>// Note that default argument promotion applies only to float (and
>// half/fp16); it does not apply to _Float16.
> -  const BuiltinType *BTy = ScalarTy->getAs();
> +  const BuiltinType *BTy = Ty->getAs();
>if (BTy && (BTy->getKind() == BuiltinType::Half ||
>BTy->getKind() == BuiltinType::Float)) {
>  if (getLangOpts().OpenCL &&
>  !getOpenCLOptions().isEnabled("cl_khr_fp64")) {
> -  if (BTy->getKind() == BuiltinType::Half) {
> -QualType Ty = Context.FloatTy;
> -if (NumElts != 0)
> -  Ty = Context.getExtVectorType(Ty, NumElts);
> -E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
> -  }
> +if (BTy->getKind() == BuiltinType::Half) {
> +E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
> +}
>  } else {
> -  QualType Ty = Context.DoubleTy;
> -  if (NumElts != 0)
> -Ty = Context.getExtVectorType(Ty, NumElts);
> -  E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
> +  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
>  }
>}
>
>
> Modified: cfe/trunk/test/CodeGenOpenCL/printf.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/printf.cl?rev=352539&r1=352538&r2=352539&view=diff
> ==
> --- cfe/trunk/test/CodeGenOpenCL/printf.cl (original)
> +++ cfe/trunk/test/CodeGenOpenCL/printf.cl Tue Jan 29 12:49:47 2019
> @@ -12,28 +12,26 @@ int printf(__constant const char* st, ..
>
>
>  // ALL-LABEL: @test_printf_float2(
> -// FP64: %conv = fpext <2 x float> %0 to <2 x double>
> -// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
> addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, 
> i32 0, i32 0), <2 x double> %conv)
> +// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
> addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, 
> i32 0, i32 0), <2 x float> %0)
>
> -// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
> addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, 
> i32 0, i32 0), <2 x float> %0)
> +
> +// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
> addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, 
> i32 0, i32 0), <2 x float> %0)
>  kernel void test_printf_float2(float2 arg) {
> -  printf("%v2f", arg);
> +  printf("%v2hlf", arg);
>  }
>
>  // ALL-LABEL: @test_printf_half2(
> -// FP64: %conv = fpext <2 x half> %0 to <2 x double>
> -// FP64:  %call = call

[PATCH] D57330: Adjust documentation for git migration.

2019-01-29 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

> You can avoid the git status pollution by adding the build directory to 
> .git/info/exclude.

Good to know! Should we include this in the doc?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57330/new/

https://reviews.llvm.org/D57330



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


r352544 - OpenCL: Try to fix bot test failure

2019-01-29 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Jan 29 13:14:56 2019
New Revision: 352544

URL: http://llvm.org/viewvc/llvm-project?rev=352544&view=rev
Log:
OpenCL: Try to fix bot test failure

Modified:
cfe/trunk/test/SemaOpenCL/format-strings-fixit.cl

Modified: cfe/trunk/test/SemaOpenCL/format-strings-fixit.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/format-strings-fixit.cl?rev=352544&r1=352543&r2=352544&view=diff
==
--- cfe/trunk/test/SemaOpenCL/format-strings-fixit.cl (original)
+++ cfe/trunk/test/SemaOpenCL/format-strings-fixit.cl Tue Jan 29 13:14:56 2019
@@ -3,6 +3,8 @@
 // RUN: %clang_cc1 -cl-std=CL1.2 -fsyntax-only -pedantic -Wall -Werror %t
 // RUN: %clang_cc1 -cl-std=CL1.2 -E -o - %t | FileCheck %s
 
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
 typedef __attribute__((ext_vector_type(4))) char char4;
 typedef __attribute__((ext_vector_type(4))) short short4;
 typedef __attribute__((ext_vector_type(4))) int int4;


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


r352543 - [OPENMP]Fix PR40513: lastprivate taskloop counter.

2019-01-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 29 13:12:28 2019
New Revision: 352543

URL: http://llvm.org/viewvc/llvm-project?rev=352543&view=rev
Log:
[OPENMP]Fix PR40513: lastprivate taskloop counter.

We don't need to use the predetermined data-sharing attributes for the
loop counters if the user explicitly specified correct data-sharing
attributes for such variables.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=352543&r1=352542&r2=352543&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 29 13:12:28 2019
@@ -4866,10 +4866,7 @@ static bool checkOpenMPIterationSpace(
   // lastprivate (for simd directives with several collapsed or ordered
   // loops).
   if (DVar.CKind == OMPC_unknown)
-DVar = DSA.hasDSA(LCDecl, isOpenMPPrivate,
-  [](OpenMPDirectiveKind) -> bool { return true; },
-  /*FromParent=*/false);
-  DSA.addDSA(LCDecl, LoopDeclRefExpr, PredeterminedCKind);
+DSA.addDSA(LCDecl, LoopDeclRefExpr, PredeterminedCKind);
 }
 
 assert(isOpenMPLoopDirective(DKind) && "DSA for non-loop vars");

Modified: cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp?rev=352543&r1=352542&r2=352543&view=diff
==
--- cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/taskloop_lastprivate_codegen.cpp Tue Jan 29 13:12:28 
2019
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DARRAY -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=ARRAY %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLOOP -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LOOP %s
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
@@ -11,11 +12,12 @@
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLAMBDA -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -fblocks -DBLOCKS -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DARRAY -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 
%s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLOOP -triple 
x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 // It doesn't pass on win32.
 // REQUIRES: shell
-#ifndef ARRAY
+#if !defined(ARRAY) && !defined(LOOP)
 #ifndef HEADER
 #define HEADER
 
@@ -501,7 +503,7 @@ int main() {
 // CHECK: ret i32
 
 #endif
-#else
+#elif defined(ARRAY)
 // ARRAY-LABEL: array_func
 struct St {
   int a, b;
@@ -522,5 +524,16 @@ void array_func(int n, float a[n], St s[
   for (int i = 0; i < 10; ++i)
 ;
 }
+#else
+
+// LOOP-LABEL: loop
+void loop() {
+// LOOP: call i8* @__kmpc_omp_task_alloc(
+// LOOP: call void @__kmpc_taskloop(
+  int i;
+#pragma omp taskloop lastprivate(i)
+  for (i = 0; i < 10; ++i)
+;
+}
 #endif
 


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


r352542 - [cc1as] Test that -g of empty .s file does something sensible.

2019-01-29 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Tue Jan 29 12:57:50 2019
New Revision: 352542

URL: http://llvm.org/viewvc/llvm-project?rev=352542&view=rev
Log:
[cc1as] Test that -g of empty .s file does something sensible.

Depends on LLVM r352541.

Added:
cfe/trunk/test/Misc/cc1as-asm-debug.s

Added: cfe/trunk/test/Misc/cc1as-asm-debug.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-asm-debug.s?rev=352542&view=auto
==
--- cfe/trunk/test/Misc/cc1as-asm-debug.s (added)
+++ cfe/trunk/test/Misc/cc1as-asm-debug.s Tue Jan 29 12:57:50 2019
@@ -0,0 +1,11 @@
+// Run cc1as with debug on empty file. Needs a known name so we can check it.
+// REQUIRES: x86-registered-target
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: cp %s %t/comment.s
+// RUN: %clang -cc1as -triple x86_64-linux-gnu -filetype asm 
-debug-info-kind=limited -dwarf-version=4 %t/comment.s | FileCheck %s
+// RUN: %clang -cc1as -triple x86_64-linux-gnu -filetype asm 
-debug-info-kind=limited -dwarf-version=5 %t/comment.s | FileCheck %s
+// Asm output actually emits the .section directives twice.
+// CHECK: {{\.}}section .debug_info
+// CHECK: {{\.}}section .debug_info
+// CHECK-NOT: {{\.}}section
+// CHECK: .ascii "comment.s"


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


[PATCH] D57390: OpenCL: Use length modifier for warning on vector printf arguments

2019-01-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r352540


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57390/new/

https://reviews.llvm.org/D57390



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


[PATCH] D57405: Revert "OpenCL: Extend argument promotion rules to vector types"

2019-01-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r352539


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57405/new/

https://reviews.llvm.org/D57405



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


r352540 - OpenCL: Use length modifier for warning on vector printf arguments

2019-01-29 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Jan 29 12:49:54 2019
New Revision: 352540

URL: http://llvm.org/viewvc/llvm-project?rev=352540&view=rev
Log:
OpenCL: Use length modifier for warning on vector printf arguments

Re-enable format string warnings on printf.

The warnings are still incomplete. Apparently it is undefined to use a
vector specifier without a length modifier, which is not currently
warned on. Additionally, type warnings appear to not be working with
the hh modifier, and aren't warning on all of the special restrictions
from c99 printf.

Modified:
cfe/trunk/include/clang/AST/FormatString.h
cfe/trunk/lib/AST/FormatString.cpp
cfe/trunk/lib/AST/PrintfFormatString.cpp
cfe/trunk/lib/AST/ScanfFormatString.cpp
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/format-strings.c
cfe/trunk/test/SemaOpenCL/format-strings-fixit.cl
cfe/trunk/test/SemaOpenCL/printf-format-string-warnings.cl
cfe/trunk/test/SemaOpenCL/printf-format-strings.cl

Modified: cfe/trunk/include/clang/AST/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/FormatString.h?rev=352540&r1=352539&r2=352540&view=diff
==
--- cfe/trunk/include/clang/AST/FormatString.h (original)
+++ cfe/trunk/include/clang/AST/FormatString.h Tue Jan 29 12:49:54 2019
@@ -67,6 +67,7 @@ public:
 None,
 AsChar,   // 'hh'
 AsShort,  // 'h'
+AsShortLong,  // 'hl' (OpenCL float/int vector element)
 AsLong,   // 'l'
 AsLongLong,   // 'll'
 AsQuad,   // 'q' (BSD, deprecated, for 64-bit integer types)
@@ -436,7 +437,8 @@ public:
 
   bool usesPositionalArg() const { return UsesPositionalArg; }
 
-  bool hasValidLengthModifier(const TargetInfo &Target) const;
+  bool hasValidLengthModifier(const TargetInfo &Target,
+  const LangOptions &LO) const;
 
   bool hasStandardLengthModifier() const;
 

Modified: cfe/trunk/lib/AST/FormatString.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/FormatString.cpp?rev=352540&r1=352539&r2=352540&view=diff
==
--- cfe/trunk/lib/AST/FormatString.cpp (original)
+++ cfe/trunk/lib/AST/FormatString.cpp Tue Jan 29 12:49:54 2019
@@ -223,6 +223,9 @@ clang::analyze_format_string::ParseLengt
   if (I != E && *I == 'h') {
 ++I;
 lmKind = LengthModifier::AsChar;
+  } else if (I != E && *I == 'l' && LO.OpenCL) {
+++I;
+lmKind = LengthModifier::AsShortLong;
   } else {
 lmKind = LengthModifier::AsShort;
   }
@@ -487,7 +490,8 @@ ArgType::matchesType(ASTContext &C, Qual
 }
 
 ArgType ArgType::makeVectorType(ASTContext &C, unsigned NumElts) const {
-  if (K != SpecificTy) // Won't be a valid vector element type.
+  // Check for valid vector element types.
+  if (T.isNull())
 return ArgType::Invalid();
 
   QualType Vec = C.getExtVectorType(T, NumElts);
@@ -572,6 +576,8 @@ analyze_format_string::LengthModifier::t
 return "hh";
   case AsShort:
 return "h";
+  case AsShortLong:
+return "hl";
   case AsLong: // or AsWideChar
 return "l";
   case AsLongLong:
@@ -707,13 +713,18 @@ void OptionalAmount::toString(raw_ostrea
   }
 }
 
-bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target) const {
+bool FormatSpecifier::hasValidLengthModifier(const TargetInfo &Target,
+ const LangOptions &LO) const {
   switch (LM.getKind()) {
 case LengthModifier::None:
   return true;
 
 // Handle most integer flags
 case LengthModifier::AsShort:
+  // Length modifier only applies to FP vectors.
+  if (LO.OpenCL && CS.isDoubleArg())
+return !VectorNumElts.isInvalid();
+
   if (Target.getTriple().isOSMSVCRT()) {
 switch (CS.getKind()) {
   case ConversionSpecifier::cArg:
@@ -752,8 +763,18 @@ bool FormatSpecifier::hasValidLengthModi
   return false;
   }
 
+case LengthModifier::AsShortLong:
+  return LO.OpenCL && !VectorNumElts.isInvalid();
+
 // Handle 'l' flag
 case LengthModifier::AsLong: // or AsWideChar
+  if (CS.isDoubleArg()) {
+// Invalid for OpenCL FP scalars.
+if (LO.OpenCL && VectorNumElts.isInvalid())
+  return false;
+return true;
+  }
+
   switch (CS.getKind()) {
 case ConversionSpecifier::dArg:
 case ConversionSpecifier::DArg:
@@ -764,14 +785,6 @@ bool FormatSpecifier::hasValidLengthModi
 case ConversionSpecifier::UArg:
 case ConversionSpecifier::xArg:
 case ConversionSpecifier::XArg:
-case ConversionSpecifier::aArg:
-case ConversionSpecifier::AArg:
-case ConversionSpecifier::fArg:
-case ConversionSpecifier::FArg:
-case ConversionSpecifier::eArg:
-case ConversionSpecifier::EArg:
-case 

r352539 - Revert "OpenCL: Extend argument promotion rules to vector types"

2019-01-29 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Jan 29 12:49:47 2019
New Revision: 352539

URL: http://llvm.org/viewvc/llvm-project?rev=352539&view=rev
Log:
Revert "OpenCL: Extend argument promotion rules to vector types"

This reverts r348083. This was based on a misreading of the spec
for printf specifiers.

Also revert r343653, as without a subsequent patch, a correctly
specified format for a vector will incorrectly warn.

Fixes bug 40491.

Modified:
cfe/trunk/lib/Headers/opencl-c.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenOpenCL/printf.cl
cfe/trunk/test/SemaOpenCL/printf-format-string-warnings.cl
cfe/trunk/test/SemaOpenCL/printf-format-strings.cl

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=352539&r1=352538&r2=352539&view=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Tue Jan 29 12:49:47 2019
@@ -14469,7 +14469,7 @@ half16 __ovld __cnfn shuffle2(half16 x,
 #if __OPENCL_C_VERSION__ >= CL_VERSION_1_2
 // OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
 
-int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 
2)));
+int printf(__constant const char* st, ...);
 #endif
 
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write 
Functions

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=352539&r1=352538&r2=352539&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 29 12:49:47 2019
@@ -737,33 +737,20 @@ ExprResult Sema::DefaultArgumentPromotio
 return ExprError();
   E = Res.get();
 
-  QualType ScalarTy = Ty;
-  unsigned NumElts = 0;
-  if (const ExtVectorType *VecTy = Ty->getAs()) {
-NumElts = VecTy->getNumElements();
-ScalarTy = VecTy->getElementType();
-  }
-
   // If this is a 'float'  or '__fp16' (CVR qualified or typedef)
   // promote to double.
   // Note that default argument promotion applies only to float (and
   // half/fp16); it does not apply to _Float16.
-  const BuiltinType *BTy = ScalarTy->getAs();
+  const BuiltinType *BTy = Ty->getAs();
   if (BTy && (BTy->getKind() == BuiltinType::Half ||
   BTy->getKind() == BuiltinType::Float)) {
 if (getLangOpts().OpenCL &&
 !getOpenCLOptions().isEnabled("cl_khr_fp64")) {
-  if (BTy->getKind() == BuiltinType::Half) {
-QualType Ty = Context.FloatTy;
-if (NumElts != 0)
-  Ty = Context.getExtVectorType(Ty, NumElts);
-E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
-  }
+if (BTy->getKind() == BuiltinType::Half) {
+E = ImpCastExprToType(E, Context.FloatTy, CK_FloatingCast).get();
+}
 } else {
-  QualType Ty = Context.DoubleTy;
-  if (NumElts != 0)
-Ty = Context.getExtVectorType(Ty, NumElts);
-  E = ImpCastExprToType(E, Ty, CK_FloatingCast).get();
+  E = ImpCastExprToType(E, Context.DoubleTy, CK_FloatingCast).get();
 }
   }
 

Modified: cfe/trunk/test/CodeGenOpenCL/printf.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/printf.cl?rev=352539&r1=352538&r2=352539&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/printf.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/printf.cl Tue Jan 29 12:49:47 2019
@@ -12,28 +12,26 @@ int printf(__constant const char* st, ..
 
 
 // ALL-LABEL: @test_printf_float2(
-// FP64: %conv = fpext <2 x float> %0 to <2 x double>
-// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, 
i32 0, i32 0), <2 x double> %conv)
+// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, 
i32 0, i32 0), <2 x float> %0)
 
-// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, 
i32 0, i32 0), <2 x float> %0)
+
+// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, 
i32 0, i32 0), <2 x float> %0)
 kernel void test_printf_float2(float2 arg) {
-  printf("%v2f", arg);
+  printf("%v2hlf", arg);
 }
 
 // ALL-LABEL: @test_printf_half2(
-// FP64: %conv = fpext <2 x half> %0 to <2 x double>
-// FP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, 
i32 0, i32 0), <2 x double> %conv) #2
+// FP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 
addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.s

[PATCH] D57404: build: remove use of llvm-config

2019-01-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I don't think that's going to work on top of unconfigured sources.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57404/new/

https://reviews.llvm.org/D57404



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


[PATCH] D44823: [libcxx] Improving std::vector and std::deque perfomance

2019-01-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D44823#1375654 , @mclow.lists wrote:

> In D44823#1375590 , @mclow.lists 
> wrote:
>
> > I just tried this (on Compiler Explorer) using LLVM 7, and the code for my 
> > original test in https://bugs.llvm.org/show_bug.cgi?id=35637 is now optimal.
>
>
> Pilot error - it's still the same.


Not too surprising, i don't recall any of the `memset` llvm differentials 
progressing.
Though i think there was a consensus in some one of them that the transform 
itself is valid.
Not sure which patch was the closest one to completion, or what it would take 
though.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D44823/new/

https://reviews.llvm.org/D44823



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: docs/clang-tidy/checks/abseil-duration-double-conversion.rst:20
+
+
+  // Original - Conversion to integer and back again

hwright wrote:
> Eugene.Zelenko wrote:
> > Unnecessary empty line.
> This is consistent with other documentation in this directory, such as 
> `abseil-faster-strsplit-delimiter.rst`.
In your example `abseil-faster-strsplit-delimiter.rst` , The double blank line 
in the html doesn't give much delineation between the before and after code and 
the next example.

{F7867869}

There probably isn't a convention per say (which is a shame), across the docs 
we do a mixture of different styles 

https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
https://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
https://clang.llvm.org/extra/clang-tidy/checks/google-objc-function-naming.html

But there is a desire by some of the regular clang-tidy reviewers to make the 
documentation consistent

It may not be ideal but the "Before/After" style, that is used in 
`modernize-use-emplace`, 
`modernize-use-using`,`readability-braces-around-statements`,`readability-identifier-naming`
 and `readability-redundant-function-ptr-dereference` does help a little.

I'm not saying looks better, but I've added a couple of examples of formatting 
the strsplit example for comparison, feel free to ignore.

{F7867960}

{F7868028}




CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57353/new/

https://reviews.llvm.org/D57353



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


[PATCH] D57404: build: remove use of llvm-config

2019-01-29 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@mgorny, no, you should specify `-DLLVM_DIR=/path/to/where/the/config/lives` 
instead.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57404/new/

https://reviews.llvm.org/D57404



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


[PATCH] D57411: [ModuleDependencyCollector] Use llvm::sys::fs::real_path

2019-01-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: bruno.

Use the real_path from llvm::sys::fs::real_path instead of having a custom 
implementation.


Repository:
  rC Clang

https://reviews.llvm.org/D57411

Files:
  clang/lib/Frontend/ModuleDependencyCollector.cpp


Index: clang/lib/Frontend/ModuleDependencyCollector.cpp
===
--- clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -98,24 +98,6 @@
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -130,7 +112,7 @@
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -140,7 +122,7 @@
   // already expects when sensitivity isn't setup.
   for (auto &C : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -186,7 +168,7 @@
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {


Index: clang/lib/Frontend/ModuleDependencyCollector.cpp
===
--- clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -98,24 +98,6 @@
 
 }
 
-// TODO: move this to Support/Path.h and check for HAVE_REALPATH?
-static bool real_path(StringRef SrcPath, SmallVectorImpl &RealPath) {
-#ifdef LLVM_ON_UNIX
-  char CanonicalPath[PATH_MAX];
-
-  // TODO: emit a warning in case this fails...?
-  if (!realpath(SrcPath.str().c_str(), CanonicalPath))
-return false;
-
-  SmallString<256> RPath(CanonicalPath);
-  RealPath.swap(RPath);
-  return true;
-#else
-  // FIXME: Add support for systems without realpath.
-  return false;
-#endif
-}
-
 void ModuleDependencyCollector::attachToASTReader(ASTReader &R) {
   R.addListener(llvm::make_unique(*this));
 }
@@ -130,7 +112,7 @@
 static bool isCaseSensitivePath(StringRef Path) {
   SmallString<256> TmpDest = Path, UpperDest, RealDest;
   // Remove component traversals, links, etc.
-  if (!real_path(Path, TmpDest))
+  if (llvm::sys::fs::real_path(Path, TmpDest))
 return true; // Current default value in vfs.yaml
   Path = TmpDest;
 
@@ -140,7 +122,7 @@
   // already expects when sensitivity isn't setup.
   for (auto &C : Path)
 UpperDest.push_back(toUppercase(C));
-  if (real_path(UpperDest, RealDest) && Path.equals(RealDest))
+  if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
 return false;
   return true;
 }
@@ -186,7 +168,7 @@
   // Computing the real path is expensive, cache the search through the
   // parent path directory.
   if (DirWithSymLink == SymLinkMap.end()) {
-if (!real_path(Dir, RealPath))
+if (llvm::sys::fs::real_path(Dir, RealPath))
   return false;
 SymLinkMap[Dir] = RealPath.str();
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57405: Revert "OpenCL: Extend argument promotion rules to vector types"

2019-01-29 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.

Thanks, LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57405/new/

https://reviews.llvm.org/D57405



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


[PATCH] D57390: OpenCL: Use length modifier for warning on vector printf arguments

2019-01-29 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.

LGTM, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57390/new/

https://reviews.llvm.org/D57390



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


Re: r350970 - [Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO

2019-01-29 Thread Steven Wu via cfe-commits
r352537 should fix it.

Steven

> On Jan 29, 2019, at 11:36 AM, Matt Arsenault  wrote:
> 
> 
> 
>> On Jan 11, 2019, at 4:16 PM, Steven Wu via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> Author: steven_wu
>> Date: Fri Jan 11 13:16:04 2019
>> New Revision: 350970
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=350970&view=rev 
>> 
>> Log:
>> [Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO
>> 
>> Summary:
>> After r327851, Driver::GetTemporaryPath will create the file rather than
>> just create a potientially unqine filename. If clang driver pass the
>> file as parameter as -object_path_lto, ld64 will pass it back to libLTO
>> as GeneratedObjectsDirectory, which is going to cause a LLVM ERROR if it
>> is not a directory.
>> Now during thinLTO, pass a temp directory path to linker instread.
>> 
>> rdar://problem/47194182 
>> 
>> Reviewers: arphaman, dexonsmith
>> 
>> Reviewed By: arphaman
>> 
>> Subscribers: mehdi_amini, inglorion, jkorous, cfe-commits
>> 
>> Differential Revision: https://reviews.llvm.org/D56608
>> 
>> Modified:
>>cfe/trunk/include/clang/Driver/Driver.h
>>cfe/trunk/lib/Driver/Driver.cpp
>>cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>>cfe/trunk/test/Driver/darwin-ld-lto.c
>> 
>> Modified: cfe/trunk/include/clang/Driver/Driver.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=350970&r1=350969&r2=350970&view=diff
>> ==
>> --- cfe/trunk/include/clang/Driver/Driver.h (original)
>> +++ cfe/trunk/include/clang/Driver/Driver.h Fri Jan 11 13:16:04 2019
>> @@ -505,6 +505,10 @@ public:
>>   /// GCC goes to extra lengths here to be a bit more robust.
>>   std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const;
>> 
>> +  /// GetTemporaryDirectory - Return the pathname of a temporary directory 
>> to
>> +  /// use as part of compilation; the directory will have the given prefix.
>> +  std::string GetTemporaryDirectory(StringRef Prefix) const;
>> +
>>   /// Return the pathname of the pch file in clang-cl mode.
>>   std::string GetClPchPath(Compilation &C, StringRef BaseName) const;
>> 
>> 
>> Modified: cfe/trunk/lib/Driver/Driver.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=350970&r1=350969&r2=350970&view=diff
>> ==
>> --- cfe/trunk/lib/Driver/Driver.cpp (original)
>> +++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 11 13:16:04 2019
>> @@ -4478,6 +4478,17 @@ std::string Driver::GetTemporaryPath(Str
>>   return Path.str();
>> }
>> 
>> +std::string Driver::GetTemporaryDirectory(StringRef Prefix) const {
>> +  SmallString<128> Path;
>> +  std::error_code EC = llvm::sys::fs::createUniqueDirectory(Prefix, Path);
>> +  if (EC) {
>> +Diag(clang::diag::err_unable_to_make_temp) << EC.message();
>> +return "";
>> +  }
>> +
>> +  return Path.str();
>> +}
>> +
>> std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const {
>>   SmallString<128> Output;
>>   if (Arg *FpArg = C.getArgs().getLastArg(options::OPT__SLASH_Fp)) {
>> 
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=350970&r1=350969&r2=350970&view=diff
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Jan 11 13:16:04 2019
>> @@ -224,13 +224,20 @@ void darwin::Linker::AddLinkArgs(Compila
>>options::OPT_fno_application_extension, false))
>> CmdArgs.push_back("-application_extension");
>> 
>> -  if (D.isUsingLTO()) {
>> -// If we are using LTO, then automatically create a temporary file path 
>> for
>> -// the linker to use, so that it's lifetime will extend past a possible
>> -// dsymutil step.
>> -if (Version[0] >= 116 && NeedsTempPath(Inputs)) {
>> -  const char *TmpPath = C.getArgs().MakeArgString(
>> -  D.GetTemporaryPath("cc", 
>> types::getTypeTempSuffix(types::TY_Object)));
>> +  if (D.isUsingLTO() && Version[0] >= 116 && NeedsTempPath(Inputs)) {
>> +std::string TmpPathName;
>> +if (D.getLTOMode() == LTOK_Full) {
>> +  // If we are using full LTO, then automatically create a temporary 
>> file
>> +  // path for the linker to use, so that it's lifetime will extend past 
>> a
>> +  // possible dsymutil step.
>> +  TmpPathName =
>> +  D.GetTemporaryPath("cc", 
>> types::getTypeTempSuffix(types::TY_Object));
>> +} else if (D.getLTOMode() == LTOK_Thin)
>> +  // If we are using thin LTO, then create a directory instead.
>> +  TmpPathName = D.GetTemporaryDirectory("thinlto");
>> +
>> +if (!TmpPathName.empty()) {
>> +  auto *TmpPat

r352537 - Fix the tests from r350970

2019-01-29 Thread Steven Wu via cfe-commits
Author: steven_wu
Date: Tue Jan 29 12:13:02 2019
New Revision: 352537

URL: http://llvm.org/viewvc/llvm-project?rev=352537&view=rev
Log:
Fix the tests from r350970

Relax the tests from r350970 to allow non-standard path for ld.

Modified:
cfe/trunk/test/Driver/darwin-ld-lto.c

Modified: cfe/trunk/test/Driver/darwin-ld-lto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld-lto.c?rev=352537&r1=352536&r2=352537&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld-lto.c (original)
+++ cfe/trunk/test/Driver/darwin-ld-lto.c Tue Jan 29 12:13:02 2019
@@ -22,9 +22,9 @@
 // Check that -object_lto_path is passed correctly to ld64
 // RUN: %clang -target x86_64-apple-darwin10 %s -flto=full -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=FULL_LTO_OBJECT_PATH %s
-// FULL_LTO_OBJECT_PATH: /usr/bin/ld
+// FULL_LTO_OBJECT_PATH: {{ld(.exe)?"}}
 // FULL_LTO_OBJECT_PATH-SAME: "-object_path_lto" 
"{{[a-zA-Z0-9_\/]+\/cc\-[a-zA-Z0-9_]+.o}}"
 // RUN: %clang -target x86_64-apple-darwin10 %s -flto=thin -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=THIN_LTO_OBJECT_PATH %s
-// THIN_LTO_OBJECT_PATH: /usr/bin/ld
+// THIN_LTO_OBJECT_PATH: {{ld(.exe)?"}}
 // THIN_LTO_OBJECT_PATH-SAME: "-object_path_lto" 
"{{[a-zA-Z0-9_\/]+\/thinlto\-[a-zA-Z0-9_]+}}"


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


[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-29 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Sounds good.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57278/new/

https://reviews.llvm.org/D57278



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


[PATCH] D57380: [clang-tools-extra] add missing .clang-format and .clang-tidy for use with git monorepo

2019-01-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay abandoned this revision.
MyDeveloperDay added a comment.

Abandoning as its been superseded by...

https://github.com/llvm/llvm-project/commit/149be18dbc4d54328fe33b5ac21dcbbca2b07aa6

Which puts these files at the base of llvm-project


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57380/new/

https://reviews.llvm.org/D57380



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


[PATCH] D57390: OpenCL: Use length modifier for warning on vector printf arguments

2019-01-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 184147.
arsenm marked 2 inline comments as done.
arsenm retitled this revision from "OpenCL: Don't promote vector args to 
printf" to "OpenCL: Use length modifier for warning on vector printf arguments".
arsenm edited the summary of this revision.
arsenm added a comment.

Split revert into separate patch


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57390/new/

https://reviews.llvm.org/D57390

Files:
  include/clang/AST/FormatString.h
  lib/AST/FormatString.cpp
  lib/AST/PrintfFormatString.cpp
  lib/AST/ScanfFormatString.cpp
  lib/Headers/opencl-c.h
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings.c
  test/SemaOpenCL/format-strings-fixit.cl
  test/SemaOpenCL/printf-format-string-warnings.cl
  test/SemaOpenCL/printf-format-strings.cl

Index: test/SemaOpenCL/printf-format-strings.cl
===
--- test/SemaOpenCL/printf-format-strings.cl
+++ test/SemaOpenCL/printf-format-strings.cl
@@ -1,22 +1,90 @@
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=+cl_khr_fp64 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -fsyntax-only -verify %s
 
+typedef __attribute__((ext_vector_type(4))) half half4;
+
 typedef __attribute__((ext_vector_type(2))) float float2;
 typedef __attribute__((ext_vector_type(4))) float float4;
 
+#ifdef cl_khr_fp64
+typedef __attribute__((ext_vector_type(4))) double double4;
+#endif
+
+typedef __attribute__((ext_vector_type(4))) char char4;
+typedef __attribute__((ext_vector_type(4))) unsigned char uchar4;
+
+typedef __attribute__((ext_vector_type(4))) short short4;
+typedef __attribute__((ext_vector_type(4))) unsigned short ushort4;
+
 typedef __attribute__((ext_vector_type(2))) int int2;
 typedef __attribute__((ext_vector_type(4))) int int4;
 typedef __attribute__((ext_vector_type(16))) int int16;
 
+typedef __attribute__((ext_vector_type(4))) long long4;
+typedef __attribute__((ext_vector_type(4))) unsigned int uint4;
+typedef __attribute__((ext_vector_type(4))) unsigned long ulong4;
+
 int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
 
+
+#ifdef cl_khr_fp64
+kernel void format_v4f64(half4 arg_h, float4 arg_f, double4 arg_d)
+{
+  printf("%v4lf", arg_d);
+  printf("%v4lf", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4lf", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4lF", arg_d);
+  printf("%v4lF", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4lF", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4le", arg_d);
+  printf("%v4le", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4le", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4lE", arg_d);
+  printf("%v4lE", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4lE", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4lg", arg_d);
+  printf("%v4lg", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4lg", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4lG", arg_d);
+  printf("%v4lG", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4lG", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4la", arg_d);
+  printf("%v4la", arg_f); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
+  printf("%v4la", arg_h); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'half4' (vector of 4 'half' values)}}
+
+  printf("%v4lA", arg_d);
+ 

[PATCH] D57330: Adjust documentation for git migration.

2019-01-29 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D57330#1375913 , @mehdi_amini wrote:

> In D57330#1375096 , @labath wrote:
>
> > This is not an full out-of-source build, since the build folder is still a 
> > subfolder of the repo root
>
>
> My definition of what qualify an "out-of-source" build is that the build 
> process won't touch anything outside of the build directory: i.e. the build 
> directory itself is hermetic, self-contained, and can be destroyed without 
> impacting anything else.
>  (I agree with you that polluting `git status` is annoying, and personally I 
> usually have my build directories in parallel with the repo).


You can avoid the `git status` pollution by adding the build directory to 
`.git/info/exclude`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57330/new/

https://reviews.llvm.org/D57330



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-29 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: docs/clang-tidy/checks/abseil-duration-double-conversion.rst:28
+
+Note: Converting to an integer and back to an `absl::Duration` might be a
+truncating operation if the value is not aligned to the scale of conversion.

Eugene.Zelenko wrote:
> Please use `` for language constructs. Same below.
Thanks; I thought I'd caught them all.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57353/new/

https://reviews.llvm.org/D57353



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-29 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 184146.
hwright marked 2 inline comments as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57353/new/

https://reviews.llvm.org/D57353

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationDoubleConversionCheck.cpp
  clang-tidy/abseil/DurationDoubleConversionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-double-conversion.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-duration-double-conversion.cpp

Index: test/clang-tidy/abseil-duration-double-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-double-conversion.cpp
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s abseil-duration-double-conversion %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1, d2;
+
+  // Floating point
+  d2 = absl::Hours(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Minutes(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Seconds(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Microseconds(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+
+  // Integer point
+  d2 = absl::Hours(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Minutes(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Seconds(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Milliseconds(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Microseconds(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Nanoseconds(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+
+  // As macro argument
+#define PLUS_FIVE_S(x) x + absl::Seconds(5)
+  d2 = PLUS_FIVE_S(absl::Seconds(absl::ToInt64Seconds(d1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: PLUS_FIVE_S(d1)
+#undef PLUS_FIVE_S
+
+  // Split by macro: should not change
+#define TOSECONDS(x) absl::Seconds(x)
+  d2 = TOSECONDS(absl::ToInt64Seconds(d1));
+#undef TOSECONDS
+
+  // Don't change something inside a macro definition
+#define VALUE(x) absl::Hours(absl::ToInt64Hours(x));
+  d2 = VALUE(d1);
+#undef VALUE
+
+  // These should not match
+  d2 = absl::Seconds(absl::ToDoubleMilliseconds(d1));
+  d2 = absl::Seconds(4);
+  int i = absl::ToInt64Milliseconds(d1);
+}
Index: test/clang-tidy/Inputs/absl/time/time.h
===
--- test/clang-tidy/Inputs/absl/time/time.h
+++ test/clang-tidy/Inputs/absl/time/time.h
@@ -14,6 +14,8 @@
   Duration &operator/=(float r);
   Duration &operator/=(double r);
   template  Duration &operator/=(T r);
+
+  Duration &operator+(Duration d);
 };
 
 template  Duration operator*(Duration lhs, T rhs);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -8,6 +8,7 @@
abseil-duration-comparison
abseil-duration-conversion-cast
abseil-duration-division
+   abseil-duration-double-conversion
abseil-duration-factory-float
abseil-duration-factory-s

[PATCH] D57330: Adjust documentation for git migration.

2019-01-29 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D57330#1375096 , @labath wrote:

> This is not an full out-of-source build, since the build folder is still a 
> subfolder of the repo root


My definition of what qualify an "out-of-source" build is that the build 
process won't touch anything outside of the build directory: i.e. the build 
directory itself is hermetic, self-contained, and can be destroyed without 
impacting anything else.
(I agree with you that polluting `git status` is annoying, and personally I 
usually have my build directories in parallel with the repo).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57330/new/

https://reviews.llvm.org/D57330



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


[PATCH] D57322: [ASTImporter] Refactor unittests to be able to parameterize them in a more flexible way

2019-01-29 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: unittests/AST/ASTImporterTest.cpp:468
 
+  template  DeclT *Import(DeclT *From, Language Lang) {
+return cast_or_null(Import(cast(From), Lang));

Is this being used in this PR?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57322/new/

https://reviews.llvm.org/D57322



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


[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-29 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

In D57278#1374852 , @vsk wrote:

> Is it necessary to remove visitation of 'noreturn' call sites from ASan? I'd 
> expect that to break non-C frontends which emit noreturn calls (rust/swift?).


Good point! I didn't think about other frontends.

Currently we insert all `noreturn` handler calls in the frontend. Since the 
ASan pass still needs to insert handler calls to support other frontends, I 
would like to change it so that clang only inserts calls when it is necessary 
to prevent UBSan incompatibilities. This means that the ASan pass can remain 
completely unchanged.
(Orthogonal issue exposed by the above: In a follow-up I will change the ASan 
pass to not intrument `!nosanitize` calls to get rid of superfluous handler 
calls.)

@eugenis
We were hoping to only insert `noreturn` handler calls in one place, but I am 
not sure this is feasible when we consider alternative frontends. Are you still 
fine with this?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57278/new/

https://reviews.llvm.org/D57278



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-29 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/clang-tidy/checks/abseil-duration-double-conversion.rst:28
+
+Note: Converting to an integer and back to an `absl::Duration` might be a
+truncating operation if the value is not aligned to the scale of conversion.

Please use `` for language constructs. Same below.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57353/new/

https://reviews.llvm.org/D57353



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-29 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: docs/clang-tidy/checks/abseil-duration-double-conversion.rst:20
+
+
+  // Original - Conversion to integer and back again

Eugene.Zelenko wrote:
> Unnecessary empty line.
This is consistent with other documentation in this directory, such as 
`abseil-faster-strsplit-delimiter.rst`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57353/new/

https://reviews.llvm.org/D57353



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-29 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 184143.
hwright marked 5 inline comments as done.
hwright added a comment.

Address reviewer comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57353/new/

https://reviews.llvm.org/D57353

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationDoubleConversionCheck.cpp
  clang-tidy/abseil/DurationDoubleConversionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-double-conversion.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-duration-double-conversion.cpp

Index: test/clang-tidy/abseil-duration-double-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-double-conversion.cpp
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s abseil-duration-double-conversion %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1, d2;
+
+  // Floating point
+  d2 = absl::Hours(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Minutes(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Seconds(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Microseconds(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+
+  // Integer point
+  d2 = absl::Hours(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Minutes(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Seconds(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Milliseconds(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Microseconds(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Nanoseconds(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+
+  // As macro argument
+#define PLUS_FIVE_S(x) x + absl::Seconds(5)
+  d2 = PLUS_FIVE_S(absl::Seconds(absl::ToInt64Seconds(d1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: PLUS_FIVE_S(d1)
+#undef PLUS_FIVE_S
+
+  // Split by macro: should not change
+#define TOSECONDS(x) absl::Seconds(x)
+  d2 = TOSECONDS(absl::ToInt64Seconds(d1));
+#undef TOSECONDS
+
+  // Don't change something inside a macro definition
+#define VALUE(x) absl::Hours(absl::ToInt64Hours(x));
+  d2 = VALUE(d1);
+#undef VALUE
+
+  // These should not match
+  d2 = absl::Seconds(absl::ToDoubleMilliseconds(d1));
+  d2 = absl::Seconds(4);
+  int i = absl::ToInt64Milliseconds(d1);
+}
Index: test/clang-tidy/Inputs/absl/time/time.h
===
--- test/clang-tidy/Inputs/absl/time/time.h
+++ test/clang-tidy/Inputs/absl/time/time.h
@@ -14,6 +14,8 @@
   Duration &operator/=(float r);
   Duration &operator/=(double r);
   template  Duration &operator/=(T r);
+
+  Duration &operator+(Duration d);
 };
 
 template  Duration operator*(Duration lhs, T rhs);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -8,6 +8,7 @@
abseil-duration-comparison
abseil-duration-conversion-cast
abseil-duration-division
+   abseil-duration-double-conversion
absei

Re: r350970 - [Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO

2019-01-29 Thread Matt Arsenault via cfe-commits


> On Jan 11, 2019, at 4:16 PM, Steven Wu via cfe-commits 
>  wrote:
> 
> Author: steven_wu
> Date: Fri Jan 11 13:16:04 2019
> New Revision: 350970
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=350970&view=rev
> Log:
> [Darwin][Driver] Don't pass a file as object_path_lto during ThinLTO
> 
> Summary:
> After r327851, Driver::GetTemporaryPath will create the file rather than
> just create a potientially unqine filename. If clang driver pass the
> file as parameter as -object_path_lto, ld64 will pass it back to libLTO
> as GeneratedObjectsDirectory, which is going to cause a LLVM ERROR if it
> is not a directory.
> Now during thinLTO, pass a temp directory path to linker instread.
> 
> rdar://problem/47194182
> 
> Reviewers: arphaman, dexonsmith
> 
> Reviewed By: arphaman
> 
> Subscribers: mehdi_amini, inglorion, jkorous, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D56608
> 
> Modified:
>cfe/trunk/include/clang/Driver/Driver.h
>cfe/trunk/lib/Driver/Driver.cpp
>cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>cfe/trunk/test/Driver/darwin-ld-lto.c
> 
> Modified: cfe/trunk/include/clang/Driver/Driver.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=350970&r1=350969&r2=350970&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Driver.h (original)
> +++ cfe/trunk/include/clang/Driver/Driver.h Fri Jan 11 13:16:04 2019
> @@ -505,6 +505,10 @@ public:
>   /// GCC goes to extra lengths here to be a bit more robust.
>   std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix) const;
> 
> +  /// GetTemporaryDirectory - Return the pathname of a temporary directory to
> +  /// use as part of compilation; the directory will have the given prefix.
> +  std::string GetTemporaryDirectory(StringRef Prefix) const;
> +
>   /// Return the pathname of the pch file in clang-cl mode.
>   std::string GetClPchPath(Compilation &C, StringRef BaseName) const;
> 
> 
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=350970&r1=350969&r2=350970&view=diff
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan 11 13:16:04 2019
> @@ -4478,6 +4478,17 @@ std::string Driver::GetTemporaryPath(Str
>   return Path.str();
> }
> 
> +std::string Driver::GetTemporaryDirectory(StringRef Prefix) const {
> +  SmallString<128> Path;
> +  std::error_code EC = llvm::sys::fs::createUniqueDirectory(Prefix, Path);
> +  if (EC) {
> +Diag(clang::diag::err_unable_to_make_temp) << EC.message();
> +return "";
> +  }
> +
> +  return Path.str();
> +}
> +
> std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const {
>   SmallString<128> Output;
>   if (Arg *FpArg = C.getArgs().getLastArg(options::OPT__SLASH_Fp)) {
> 
> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=350970&r1=350969&r2=350970&view=diff
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Jan 11 13:16:04 2019
> @@ -224,13 +224,20 @@ void darwin::Linker::AddLinkArgs(Compila
>options::OPT_fno_application_extension, false))
> CmdArgs.push_back("-application_extension");
> 
> -  if (D.isUsingLTO()) {
> -// If we are using LTO, then automatically create a temporary file path 
> for
> -// the linker to use, so that it's lifetime will extend past a possible
> -// dsymutil step.
> -if (Version[0] >= 116 && NeedsTempPath(Inputs)) {
> -  const char *TmpPath = C.getArgs().MakeArgString(
> -  D.GetTemporaryPath("cc", 
> types::getTypeTempSuffix(types::TY_Object)));
> +  if (D.isUsingLTO() && Version[0] >= 116 && NeedsTempPath(Inputs)) {
> +std::string TmpPathName;
> +if (D.getLTOMode() == LTOK_Full) {
> +  // If we are using full LTO, then automatically create a temporary file
> +  // path for the linker to use, so that it's lifetime will extend past a
> +  // possible dsymutil step.
> +  TmpPathName =
> +  D.GetTemporaryPath("cc", 
> types::getTypeTempSuffix(types::TY_Object));
> +} else if (D.getLTOMode() == LTOK_Thin)
> +  // If we are using thin LTO, then create a directory instead.
> +  TmpPathName = D.GetTemporaryDirectory("thinlto");
> +
> +if (!TmpPathName.empty()) {
> +  auto *TmpPath = C.getArgs().MakeArgString(TmpPathName);
>   C.addTempFile(TmpPath);
>   CmdArgs.push_back("-object_path_lto");
>   CmdArgs.push_back(TmpPath);
> 
> Modified: cfe/trunk/test/Driver/darwin-ld-lto.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld-lto.c?rev=350970&r1=350969

[PATCH] D53199: Fix the behavior of clang's -w flag.

2019-01-29 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352535: Fix the behavior of clang's -w flag. (authored 
by jyknight, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53199?vs=183966&id=184142#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53199/new/

https://reviews.llvm.org/D53199

Files:
  cfe/trunk/lib/Basic/DiagnosticIDs.cpp
  cfe/trunk/test/Frontend/optimization-remark.c
  cfe/trunk/test/Frontend/warning-mapping-2.c
  cfe/trunk/test/Frontend/warning-mapping-4.c
  cfe/trunk/test/Frontend/warning-mapping-5.c
  cfe/trunk/test/Frontend/warning-mapping-6.c
  cfe/trunk/test/Modules/implementation-of-module.m

Index: cfe/trunk/test/Frontend/optimization-remark.c
===
--- cfe/trunk/test/Frontend/optimization-remark.c
+++ cfe/trunk/test/Frontend/optimization-remark.c
@@ -13,6 +13,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-NO-REMARKS
 // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
 //
+// Check that -w doesn't disable remarks.
+// RUN: %clang_cc1 %s -Rpass=inline -w -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
+//
 // FIXME: -Reverything should imply -Rpass=.*.
 // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s --check-prefix=CHECK-NO-REMARKS
 //
Index: cfe/trunk/test/Frontend/warning-mapping-5.c
===
--- cfe/trunk/test/Frontend/warning-mapping-5.c
+++ cfe/trunk/test/Frontend/warning-mapping-5.c
@@ -1,6 +1,5 @@
-// Check that #pragma diagnostic warning overrides -Werror. This matches GCC's
-// original documentation, but not its earlier implementations.
-// 
+// Check that #pragma diagnostic warning overrides -Werror.
+//
 // RUN: %clang_cc1 -verify -Werror %s
 
 #pragma clang diagnostic warning "-Wsign-compare"
Index: cfe/trunk/test/Frontend/warning-mapping-6.c
===
--- cfe/trunk/test/Frontend/warning-mapping-6.c
+++ cfe/trunk/test/Frontend/warning-mapping-6.c
@@ -0,0 +1,9 @@
+// Check that "#pragma diagnostic error" is suppressed by -w.
+//
+// RUN: %clang_cc1 -verify -Werror -w %s
+
+// expected-no-diagnostics
+#pragma gcc diagnostic error "-Wsign-compare"
+int f0(int x, unsigned y) {
+  return x < y;
+}
Index: cfe/trunk/test/Frontend/warning-mapping-4.c
===
--- cfe/trunk/test/Frontend/warning-mapping-4.c
+++ cfe/trunk/test/Frontend/warning-mapping-4.c
@@ -1,5 +1,9 @@
+// Verify that various combinations of flags properly keep the sign-compare
+// warning disabled.
+
 // RUN: %clang_cc1 -verify -Wno-error=sign-compare %s
 // RUN: %clang_cc1 -verify -Wsign-compare -w -Wno-error=sign-compare %s
+// RUN: %clang_cc1 -verify -w -Werror=sign-compare %s
 // expected-no-diagnostics
 
 int f0(int x, unsigned y) {
Index: cfe/trunk/test/Frontend/warning-mapping-2.c
===
--- cfe/trunk/test/Frontend/warning-mapping-2.c
+++ cfe/trunk/test/Frontend/warning-mapping-2.c
@@ -1,5 +1,7 @@
-// Check that -w has lower priority than -pedantic-errors.
+// Check that -w takes precedence over -pedantic-errors.
 // RUN: %clang_cc1 -verify -pedantic-errors -w %s
 
-void f0() { f1(); } // expected-error {{implicit declaration of function}}
+// Expect *not* to see a diagnostic for "implicit declaration of function"
+// expected-no-diagnostics
 
+void f0() { f1(); }
Index: cfe/trunk/test/Modules/implementation-of-module.m
===
--- cfe/trunk/test/Modules/implementation-of-module.m
+++ cfe/trunk/test/Modules/implementation-of-module.m
@@ -1,17 +1,17 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \
 // RUN: -fmodule-implementation-of category_right -fsyntax-only
 
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \
 // RUN: -fmodule-implementation-of category_right -dM -E -o - 2>&1 | FileCheck %s
 // CHECK-NOT: __building_module
 
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \
 // RUN: -fmodule-implementation-of category_left -verify
 
-// RUN: %clang_cc1 -x

r352535 - Fix the behavior of clang's -w flag.

2019-01-29 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Jan 29 11:33:48 2019
New Revision: 352535

URL: http://llvm.org/viewvc/llvm-project?rev=352535&view=rev
Log:
Fix the behavior of clang's -w flag.

It is intended to disable _all_ warnings, even those upgraded to
errors via `-Werror=warningname` or `#pragma clang diagnostic error'

Fixes: https://llvm.org/PR38231
Differential Revision: https://reviews.llvm.org/D53199

Added:
cfe/trunk/test/Frontend/warning-mapping-6.c
Modified:
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/test/Frontend/optimization-remark.c
cfe/trunk/test/Frontend/warning-mapping-2.c
cfe/trunk/test/Frontend/warning-mapping-4.c
cfe/trunk/test/Frontend/warning-mapping-5.c
cfe/trunk/test/Modules/implementation-of-module.m

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=352535&r1=352534&r2=352535&view=diff
==
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Tue Jan 29 11:33:48 2019
@@ -456,12 +456,17 @@ DiagnosticIDs::getDiagnosticSeverity(uns
   if (Result == diag::Severity::Ignored)
 return Result;
 
-  // Honor -w, which is lower in priority than pedantic-errors, but higher than
-  // -Werror.
-  // FIXME: Under GCC, this also suppresses warnings that have been mapped to
-  // errors by -W flags and #pragma diagnostic.
-  if (Result == diag::Severity::Warning && State->IgnoreAllWarnings)
-return diag::Severity::Ignored;
+  // Honor -w: this disables all messages which which are not Error/Fatal by
+  // default (disregarding attempts to upgrade severity from Warning to Error),
+  // as well as disabling all messages which are currently mapped to Warning
+  // (whether by default or downgraded from Error via e.g. -Wno-error or 
#pragma
+  // diagnostic.)
+  if (State->IgnoreAllWarnings) {
+if (Result == diag::Severity::Warning ||
+(Result >= diag::Severity::Error &&
+ !isDefaultMappingAsError((diag::kind)DiagID)))
+  return diag::Severity::Ignored;
+  }
 
   // If -Werror is enabled, map warnings to errors unless explicitly disabled.
   if (Result == diag::Severity::Warning) {

Modified: cfe/trunk/test/Frontend/optimization-remark.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark.c?rev=352535&r1=352534&r2=352535&view=diff
==
--- cfe/trunk/test/Frontend/optimization-remark.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark.c Tue Jan 29 11:33:48 2019
@@ -13,6 +13,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -emit-llvm -o - 2>&1 | 
FileCheck %s --check-prefix=CHECK-NO-REMARKS
 // RUN: %clang_cc1 %s -Rpass=inline -Rno-everything -Reverything -emit-llvm -o 
- 2>&1 | FileCheck %s --check-prefix=CHECK-REMARKS
 //
+// Check that -w doesn't disable remarks.
+// RUN: %clang_cc1 %s -Rpass=inline -w -emit-llvm -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-REMARKS
+//
 // FIXME: -Reverything should imply -Rpass=.*.
 // RUN: %clang_cc1 %s -Reverything -emit-llvm -o - 2>/dev/null | FileCheck %s 
--check-prefix=CHECK-NO-REMARKS
 //

Modified: cfe/trunk/test/Frontend/warning-mapping-2.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-mapping-2.c?rev=352535&r1=352534&r2=352535&view=diff
==
--- cfe/trunk/test/Frontend/warning-mapping-2.c (original)
+++ cfe/trunk/test/Frontend/warning-mapping-2.c Tue Jan 29 11:33:48 2019
@@ -1,5 +1,7 @@
-// Check that -w has lower priority than -pedantic-errors.
+// Check that -w takes precedence over -pedantic-errors.
 // RUN: %clang_cc1 -verify -pedantic-errors -w %s
 
-void f0() { f1(); } // expected-error {{implicit declaration of function}}
+// Expect *not* to see a diagnostic for "implicit declaration of function"
+// expected-no-diagnostics
 
+void f0() { f1(); }

Modified: cfe/trunk/test/Frontend/warning-mapping-4.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-mapping-4.c?rev=352535&r1=352534&r2=352535&view=diff
==
--- cfe/trunk/test/Frontend/warning-mapping-4.c (original)
+++ cfe/trunk/test/Frontend/warning-mapping-4.c Tue Jan 29 11:33:48 2019
@@ -1,5 +1,9 @@
+// Verify that various combinations of flags properly keep the sign-compare
+// warning disabled.
+
 // RUN: %clang_cc1 -verify -Wno-error=sign-compare %s
 // RUN: %clang_cc1 -verify -Wsign-compare -w -Wno-error=sign-compare %s
+// RUN: %clang_cc1 -verify -w -Werror=sign-compare %s
 // expected-no-diagnostics
 
 int f0(int x, unsigned y) {

Modified: cfe/trunk/test/Frontend/warning-mapping-5.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/warning-mapping-5.c?rev=352535&r1=352534&r2=352535&view=diff
=

r352533 - [analyzer] [RetainSummaryManager] [NFC] Split one function into two, as it's really doing two things

2019-01-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jan 29 11:29:45 2019
New Revision: 352533

URL: http://llvm.org/viewvc/llvm-project?rev=352533&view=rev
Log:
[analyzer] [RetainSummaryManager] [NFC] Split one function into two, as it's 
really doing two things

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

Modified:
cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
cfe/trunk/lib/Analysis/RetainSummaryManager.cpp

Modified: cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/RetainSummaryManager.h?rev=352533&r1=352532&r2=352533&view=diff
==
--- cfe/trunk/include/clang/Analysis/RetainSummaryManager.h (original)
+++ cfe/trunk/include/clang/Analysis/RetainSummaryManager.h Tue Jan 29 11:29:45 
2019
@@ -693,10 +693,22 @@ private:
   void updateSummaryFromAnnotations(const RetainSummary *&Summ,
 const FunctionDecl *FD);
 
-  void updateSummaryForCall(const RetainSummary *&Summ,
-AnyCall C,
-bool HasNonZeroCallbackArg,
-bool IsReceiverUnconsumedSelf);
+  const RetainSummary *updateSummaryForNonZeroCallbackArg(const RetainSummary 
*S,
+  AnyCall &C);
+
+  /// Special case '[super init];' and '[self init];'
+  ///
+  /// Even though calling '[super init]' without assigning the result to self
+  /// and checking if the parent returns 'nil' is a bad pattern, it is common.
+  /// Additionally, our Self Init checker already warns about it. To avoid
+  /// overwhelming the user with messages from both checkers, we model the case
+  /// of '[super init]' in cases when it is not consumed by another expression
+  /// as if the call preserves the value of 'self'; essentially, assuming it 
can
+  /// never fail and return 'nil'.
+  /// Note, we don't want to just stop tracking the value since we want the
+  /// RetainCount checker to report leaks and use-after-free if SelfInit 
checker
+  /// is turned off.
+  void updateSummaryForReceiverUnconsumedSelf(const RetainSummary *&S);
 
   /// Determine whether a declaration {@code D} of correspondent type (return
   /// type for functions/methods) {@code QT} has any of the given attributes,

Modified: cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RetainSummaryManager.cpp?rev=352533&r1=352532&r2=352533&view=diff
==
--- cfe/trunk/lib/Analysis/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/Analysis/RetainSummaryManager.cpp Tue Jan 29 11:29:45 2019
@@ -557,64 +557,47 @@ static ArgEffect getStopTrackingHardEqui
   llvm_unreachable("Unknown ArgEffect kind");
 }
 
-void RetainSummaryManager::updateSummaryForCall(const RetainSummary *&S,
-AnyCall C,
-bool HasNonZeroCallbackArg,
-bool IsReceiverUnconsumedSelf) 
{
-
-  if (HasNonZeroCallbackArg) {
-ArgEffect RecEffect =
-  getStopTrackingHardEquivalent(S->getReceiverEffect());
-ArgEffect DefEffect =
-  getStopTrackingHardEquivalent(S->getDefaultArgEffect());
-
-ArgEffects ScratchArgs(AF.getEmptyMap());
-ArgEffects CustomArgEffects = S->getArgEffects();
-for (ArgEffects::iterator I = CustomArgEffects.begin(),
-  E = CustomArgEffects.end();
- I != E; ++I) {
-  ArgEffect Translated = getStopTrackingHardEquivalent(I->second);
-  if (Translated.getKind() != DefEffect.getKind())
-ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
-}
-
-RetEffect RE = RetEffect::MakeNoRetHard();
+const RetainSummary *
+RetainSummaryManager::updateSummaryForNonZeroCallbackArg(const RetainSummary 
*S,
+ AnyCall &C) {
+  ArgEffect RecEffect = getStopTrackingHardEquivalent(S->getReceiverEffect());
+  ArgEffect DefEffect = 
getStopTrackingHardEquivalent(S->getDefaultArgEffect());
+
+  ArgEffects ScratchArgs(AF.getEmptyMap());
+  ArgEffects CustomArgEffects = S->getArgEffects();
+  for (ArgEffects::iterator I = CustomArgEffects.begin(),
+E = CustomArgEffects.end();
+   I != E; ++I) {
+ArgEffect Translated = getStopTrackingHardEquivalent(I->second);
+if (Translated.getKind() != DefEffect.getKind())
+  ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
+  }
 
-// Special cases where the callback argument CANNOT free the return value.
-// This can generally only happen if we know that the callback will only be
-// called when the return value is already being deallocated.
-if (C.getKind() == AnyCall::Function) {
-  if (const Identifier

[PATCH] D57201: [analyzer] [RetainSummaryManager] [NFC] Split one function into two, as it's really doing two things

2019-01-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352533: [analyzer] [RetainSummaryManager] [NFC] Split one 
function into two, as it's… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57201?vs=183426&id=184140#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57201/new/

https://reviews.llvm.org/D57201

Files:
  include/clang/Analysis/RetainSummaryManager.h
  lib/Analysis/RetainSummaryManager.cpp

Index: lib/Analysis/RetainSummaryManager.cpp
===
--- lib/Analysis/RetainSummaryManager.cpp
+++ lib/Analysis/RetainSummaryManager.cpp
@@ -557,64 +557,47 @@
   llvm_unreachable("Unknown ArgEffect kind");
 }
 
-void RetainSummaryManager::updateSummaryForCall(const RetainSummary *&S,
-AnyCall C,
-bool HasNonZeroCallbackArg,
-bool IsReceiverUnconsumedSelf) {
-
-  if (HasNonZeroCallbackArg) {
-ArgEffect RecEffect =
-  getStopTrackingHardEquivalent(S->getReceiverEffect());
-ArgEffect DefEffect =
-  getStopTrackingHardEquivalent(S->getDefaultArgEffect());
-
-ArgEffects ScratchArgs(AF.getEmptyMap());
-ArgEffects CustomArgEffects = S->getArgEffects();
-for (ArgEffects::iterator I = CustomArgEffects.begin(),
-  E = CustomArgEffects.end();
- I != E; ++I) {
-  ArgEffect Translated = getStopTrackingHardEquivalent(I->second);
-  if (Translated.getKind() != DefEffect.getKind())
-ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
-}
+const RetainSummary *
+RetainSummaryManager::updateSummaryForNonZeroCallbackArg(const RetainSummary *S,
+ AnyCall &C) {
+  ArgEffect RecEffect = getStopTrackingHardEquivalent(S->getReceiverEffect());
+  ArgEffect DefEffect = getStopTrackingHardEquivalent(S->getDefaultArgEffect());
 
-RetEffect RE = RetEffect::MakeNoRetHard();
+  ArgEffects ScratchArgs(AF.getEmptyMap());
+  ArgEffects CustomArgEffects = S->getArgEffects();
+  for (ArgEffects::iterator I = CustomArgEffects.begin(),
+E = CustomArgEffects.end();
+   I != E; ++I) {
+ArgEffect Translated = getStopTrackingHardEquivalent(I->second);
+if (Translated.getKind() != DefEffect.getKind())
+  ScratchArgs = AF.add(ScratchArgs, I->first, Translated);
+  }
 
-// Special cases where the callback argument CANNOT free the return value.
-// This can generally only happen if we know that the callback will only be
-// called when the return value is already being deallocated.
-if (C.getKind() == AnyCall::Function) {
-  if (const IdentifierInfo *Name = C.getIdentifier()) {
-// When the CGBitmapContext is deallocated, the callback here will free
-// the associated data buffer.
-// The callback in dispatch_data_create frees the buffer, but not
-// the data object.
-if (Name->isStr("CGBitmapContextCreateWithData") ||
-Name->isStr("dispatch_data_create"))
-  RE = S->getRetEffect();
-  }
-}
+  RetEffect RE = RetEffect::MakeNoRetHard();
 
-S = getPersistentSummary(RE, ScratchArgs, RecEffect, DefEffect);
+  // Special cases where the callback argument CANNOT free the return value.
+  // This can generally only happen if we know that the callback will only be
+  // called when the return value is already being deallocated.
+  if (const IdentifierInfo *Name = C.getIdentifier()) {
+// When the CGBitmapContext is deallocated, the callback here will free
+// the associated data buffer.
+// The callback in dispatch_data_create frees the buffer, but not
+// the data object.
+if (Name->isStr("CGBitmapContextCreateWithData") ||
+Name->isStr("dispatch_data_create"))
+  RE = S->getRetEffect();
   }
 
-  // Special case '[super init];' and '[self init];'
-  //
-  // Even though calling '[super init]' without assigning the result to self
-  // and checking if the parent returns 'nil' is a bad pattern, it is common.
-  // Additionally, our Self Init checker already warns about it. To avoid
-  // overwhelming the user with messages from both checkers, we model the case
-  // of '[super init]' in cases when it is not consumed by another expression
-  // as if the call preserves the value of 'self'; essentially, assuming it can
-  // never fail and return 'nil'.
-  // Note, we don't want to just stop tracking the value since we want the
-  // RetainCount checker to report leaks and use-after-free if SelfInit checker
-  // is turned off.
-  if (IsReceiverUnconsumedSelf) {
-RetainSummaryTemplate ModifiableSummaryTemplate(S, *this);
-ModifiableSummaryTemplate->setReceiverEffect(ArgEffect(DoNothi

[PATCH] D57344: Extend AnyCall to handle callable declarations without the call expressions

2019-01-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352531: Extend AnyCall to handle callable declarations 
without the call expressions (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57344?vs=183975&id=184138#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57344/new/

https://reviews.llvm.org/D57344

Files:
  include/clang/Analysis/AnyCall.h
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -347,7 +347,7 @@
   const Expr *CE = Call.getOriginExpr();
   AnyCall C =
   CE ? *AnyCall::forExpr(CE)
- : AnyCall::forDestructorCall(cast(Call.getDecl()));
+ : AnyCall(cast(Call.getDecl()));
   return Summaries.getSummary(C, Call.hasNonZeroCallbackArg(),
   isReceiverUnconsumedSelf(Call), ReceiverType);
 }
Index: include/clang/Analysis/AnyCall.h
===
--- include/clang/Analysis/AnyCall.h
+++ include/clang/Analysis/AnyCall.h
@@ -19,7 +19,9 @@
 
 namespace clang {
 
-/// An instance of this class corresponds to a 'callable' call.
+/// An instance of this class corresponds to a call.
+/// It might be a syntactically-concrete call, done as a part of evaluating an
+/// expression, or it may be an abstract callee with no associated expression.
 class AnyCall {
 public:
   enum Kind {
@@ -48,7 +50,11 @@
   };
 
 private:
-  /// Call expression, remains null iff the call is an implicit destructor call.
+  /// Either expression or declaration (but not both at the same time)
+  /// can be null.
+
+  /// Call expression, is null when is not known (then declaration is non-null),
+  /// or for implicit destructor calls (when no expression exists.)
   const Expr *E = nullptr;
 
   /// Corresponds to a statically known declaration of the called function,
@@ -56,8 +62,6 @@
   const Decl *D = nullptr;
   Kind K;
 
-  AnyCall(const Expr *E, const Decl *D, Kind K) : E(E), D(D), K(K) {}
-
 public:
   AnyCall(const CallExpr *CE) : E(CE) {
 D = CE->getCalleeDecl();
@@ -80,6 +84,23 @@
   AnyCall(const CXXConstructExpr *NE)
   : E(NE), D(NE->getConstructor()), K(Constructor) {}
 
+  AnyCall(const CXXDestructorDecl *D) : E(nullptr), D(D), K(Destructor) {}
+
+  AnyCall(const CXXConstructorDecl *D) : E(nullptr), D(D), K(Constructor) {}
+
+  AnyCall(const ObjCMethodDecl *D) : E(nullptr), D(D), K(ObjCMethod) {}
+
+  AnyCall(const FunctionDecl *D) : E(nullptr), D(D) {
+if (isa(D)) {
+  K = Constructor;
+} else if (isa (D)) {
+  K = Destructor;
+} else {
+  K = Function;
+}
+
+  }
+
   /// If {@code E} is a generic call (to ObjC method /function/block/etc),
   /// return a constructed {@code AnyCall} object. Return None otherwise.
   static Optional forExpr(const Expr *E) {
@@ -98,8 +119,16 @@
 }
   }
 
-  static AnyCall forDestructorCall(const CXXDestructorDecl *D) {
-return AnyCall(/*E=*/nullptr, D, Destructor);
+  /// If {@code D} is a callable (Objective-C method or a function), return
+  /// a constructed {@code AnyCall} object. Return None otherwise.
+  // FIXME: block support.
+  static Optional forDecl(const Decl *D) {
+if (const auto *FD = dyn_cast(D)) {
+  return AnyCall(FD);
+} else if (const auto *MD = dyn_cast(D)) {
+  return AnyCall(MD);
+}
+return None;
   }
 
   /// \returns formal parameters for direct calls (including virtual calls)
@@ -111,8 +140,6 @@
   return FD->parameters();
 } else if (const auto *MD = dyn_cast(D)) {
   return MD->parameters();
-} else if (const auto *CD = dyn_cast(D)) {
-  return CD->parameters();
 } else if (const auto *BD = dyn_cast(D)) {
   return BD->parameters();
 } else {
@@ -129,10 +156,17 @@
   QualType getReturnType(ASTContext &Ctx) const {
 switch (K) {
 case Function:
+  if (E)
+return cast(E)->getCallReturnType(Ctx);
+  return cast(D)->getReturnType();
+case ObjCMethod:
+  if (E)
+return cast(E)->getCallReturnType(Ctx);
+  return cast(D)->getReturnType();
 case Block:
+  // FIXME: BlockDecl does not know its return type,
+  // hence the asymmetry with the function and method cases above.
   return cast(E)->getCallReturnType(Ctx);
-case ObjCMethod:
-  return cast(E)->getCallReturnType(Ctx);
 case Destructor:
 case Constructor:
 case Allocator:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57346: [analyzer] [ARCMT] [NFC] Unify entry point into RetainSummaryManager

2019-01-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352532: [analyzer] [ARCMT] [NFC] Unify entry point into 
RetainSummaryManager (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57346?vs=183916&id=184139#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57346/new/

https://reviews.llvm.org/D57346

Files:
  include/clang/Analysis/RetainSummaryManager.h
  lib/ARCMigrate/ObjCMT.cpp
  lib/Analysis/RetainSummaryManager.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

Index: lib/Analysis/RetainSummaryManager.cpp
===
--- lib/Analysis/RetainSummaryManager.cpp
+++ lib/Analysis/RetainSummaryManager.cpp
@@ -635,11 +635,14 @@
 // FIXME: These calls are currently unsupported.
 return getPersistentStopSummary();
   case AnyCall::ObjCMethod: {
-const auto *ME = cast(C.getExpr());
-if (ME->isInstanceMessage())
+const auto *ME = cast_or_null(C.getExpr());
+if (!ME) {
+  return getMethodSummary(cast(C.getDecl()));
+} else if (ME->isInstanceMessage()) {
   Summ = getInstanceMethodSummary(ME, ReceiverType);
-else
+} else {
   Summ = getClassMethodSummary(ME);
+}
 break;
   }
   }
@@ -1238,31 +1241,3 @@
 
   return getMethodSummary(S, ID, MD, ResultTy, *CachedSummaries);
 }
-
-CallEffects CallEffects::getEffect(const ObjCMethodDecl *MD) {
-  ASTContext &Ctx = MD->getASTContext();
-  RetainSummaryManager M(Ctx,
- /*TrackNSAndCFObjects=*/true,
- /*TrackOSObjects=*/false);
-  const RetainSummary *S = M.getMethodSummary(MD);
-  CallEffects CE(S->getRetEffect(), S->getReceiverEffect());
-  unsigned N = MD->param_size();
-  for (unsigned i = 0; i < N; ++i) {
-CE.Args.push_back(S->getArg(i));
-  }
-  return CE;
-}
-
-CallEffects CallEffects::getEffect(const FunctionDecl *FD) {
-  ASTContext &Ctx = FD->getASTContext();
-  RetainSummaryManager M(Ctx,
- /*TrackNSAndCFObjects=*/true,
- /*TrackOSObjects=*/false);
-  const RetainSummary *S = M.getFunctionSummary(FD);
-  CallEffects CE(S->getRetEffect());
-  unsigned N = FD->param_size();
-  for (unsigned i = 0; i < N; ++i) {
-CE.Args.push_back(S->getArg(i));
-  }
-  return CE;
-}
Index: lib/ARCMigrate/ObjCMT.cpp
===
--- lib/ARCMigrate/ObjCMT.cpp
+++ lib/ARCMigrate/ObjCMT.cpp
@@ -64,9 +64,11 @@
 ObjCInstanceTypeFamily OIT_Family = OIT_None);
 
   void migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl);
-  void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE,
+  void AddCFAnnotations(ASTContext &Ctx,
+const RetainSummary *RS,
 const FunctionDecl *FuncDecl, bool ResultAnnotated);
-  void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE,
+  void AddCFAnnotations(ASTContext &Ctx,
+const RetainSummary *RS,
 const ObjCMethodDecl *MethodDecl, bool ResultAnnotated);
 
   void AnnotateImplicitBridging(ASTContext &Ctx);
@@ -84,6 +86,8 @@
 
   bool InsertFoundation(ASTContext &Ctx, SourceLocation Loc);
 
+  std::unique_ptr Summaries;
+
 public:
   std::string MigrateDir;
   unsigned ASTMigrateActions;
@@ -102,6 +106,14 @@
   llvm::SmallVector CFFunctionIBCandidates;
   llvm::StringSet<> WhiteListFilenames;
 
+  RetainSummaryManager &getSummaryManager(ASTContext &Ctx) {
+if (!Summaries)
+  Summaries.reset(new RetainSummaryManager(Ctx,
+   /*TrackNSCFObjects=*/true,
+   /*TrackOSObjects=*/false));
+return *Summaries;
+  }
+
   ObjCMigrateASTConsumer(StringRef migrateDir,
  unsigned astMigrateActions,
  FileRemapper &remapper,
@@ -1452,12 +1464,12 @@
 }
 
 void ObjCMigrateASTConsumer::AddCFAnnotations(ASTContext &Ctx,
-  const CallEffects &CE,
+  const RetainSummary *RS,
   const FunctionDecl *FuncDecl,
   bool ResultAnnotated) {
   // Annotate function.
   if (!ResultAnnotated) {
-RetEffect Ret = CE.getReturnValue();
+RetEffect Ret = RS->getRetEffect();
 const char *AnnotationString = nullptr;
 if (Ret.getObjKind() == ObjKind::CF) {
   if (Ret.isOwned() && NSAPIObj->isMacroDefined("CF_RETURNS_RETAINED"))
@@ -1477,12 +1489,11 @@
   Editor->commit(commit);
 }
   }
-  ArrayRef AEArgs = CE.getArgs();
   unsigned i = 0;
   for (FunctionDecl::param_const_iterator pi = FuncDecl->param_begin(),
pe = FuncDecl->param_end(); pi != pe; ++pi, ++i) {

r352532 - [analyzer] [ARCMT] [NFC] Unify entry point into RetainSummaryManager

2019-01-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jan 29 11:29:33 2019
New Revision: 352532

URL: http://llvm.org/viewvc/llvm-project?rev=352532&view=rev
Log:
[analyzer] [ARCMT] [NFC] Unify entry point into RetainSummaryManager

Just use one single entry point, since we have AnyCall utility now.

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

Modified:
cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/lib/Analysis/RetainSummaryManager.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

Modified: cfe/trunk/include/clang/Analysis/RetainSummaryManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/RetainSummaryManager.h?rev=352532&r1=352531&r2=352532&view=diff
==
--- cfe/trunk/include/clang/Analysis/RetainSummaryManager.h (original)
+++ cfe/trunk/include/clang/Analysis/RetainSummaryManager.h Tue Jan 29 11:29:33 
2019
@@ -203,40 +203,6 @@ public:
   }
 };
 
-/// Encapsulates the retain count semantics on the arguments, return value,
-/// and receiver (if any) of a function/method call.
-///
-/// Note that construction of these objects is not highly efficient.  That
-/// is okay for clients where creating these objects isn't really a bottleneck.
-/// The purpose of the API is to provide something simple.  The actual
-/// static analyzer checker that implements retain/release typestate
-/// tracking uses something more efficient.
-class CallEffects {
-  llvm::SmallVector Args;
-  RetEffect Ret;
-  ArgEffect Receiver;
-
-  CallEffects(const RetEffect &R,
-  ArgEffect Receiver = ArgEffect(DoNothing, ObjKind::AnyObj))
-  : Ret(R), Receiver(Receiver) {}
-
-public:
-  /// Returns the argument effects for a call.
-  ArrayRef getArgs() const { return Args; }
-
-  /// Returns the effects on the receiver.
-  ArgEffect getReceiver() const { return Receiver; }
-
-  /// Returns the effect on the return value.
-  RetEffect getReturnValue() const { return Ret; }
-
-  /// Return the CallEfect for a given Objective-C method.
-  static CallEffects getEffect(const ObjCMethodDecl *MD);
-
-  /// Return the CallEfect for a given C/C++ function.
-  static CallEffects getEffect(const FunctionDecl *FD);
-};
-
 /// A key identifying a summary.
 class ObjCSummaryKey {
   IdentifierInfo* II;
@@ -690,9 +656,13 @@ public:
   bool isTrustedReferenceCountImplementation(const FunctionDecl *FD);
 
   const RetainSummary *getSummary(AnyCall C,
-  bool HasNonZeroCallbackArg,
-  bool IsReceiverUnconsumedSelf,
-  QualType ReceiverType=QualType());
+  bool HasNonZeroCallbackArg=false,
+  bool IsReceiverUnconsumedSelf=false,
+  QualType ReceiverType={});
+
+  RetEffect getObjAllocRetEffect() const { return ObjCAllocRetE; }
+
+private:
 
   /// getMethodSummary - This version of getMethodSummary is used to query
   ///  the summary for the current method being analyzed.
@@ -700,9 +670,6 @@ public:
 
   const RetainSummary *getFunctionSummary(const FunctionDecl *FD);
 
-  RetEffect getObjAllocRetEffect() const { return ObjCAllocRetE; }
-
-private:
   const RetainSummary *getMethodSummary(Selector S, const ObjCInterfaceDecl 
*ID,
 const ObjCMethodDecl *MD,
 QualType RetTy,

Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=352532&r1=352531&r2=352532&view=diff
==
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Tue Jan 29 11:29:33 2019
@@ -64,9 +64,11 @@ class ObjCMigrateASTConsumer : public AS
 ObjCInstanceTypeFamily OIT_Family = OIT_None);
 
   void migrateCFAnnotation(ASTContext &Ctx, const Decl *Decl);
-  void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE,
+  void AddCFAnnotations(ASTContext &Ctx,
+const RetainSummary *RS,
 const FunctionDecl *FuncDecl, bool ResultAnnotated);
-  void AddCFAnnotations(ASTContext &Ctx, const CallEffects &CE,
+  void AddCFAnnotations(ASTContext &Ctx,
+const RetainSummary *RS,
 const ObjCMethodDecl *MethodDecl, bool 
ResultAnnotated);
 
   void AnnotateImplicitBridging(ASTContext &Ctx);
@@ -84,6 +86,8 @@ class ObjCMigrateASTConsumer : public AS
 
   bool InsertFoundation(ASTContext &Ctx, SourceLocation Loc);
 
+  std::unique_ptr Summaries;
+
 public:
   std::string MigrateDir;
   unsigned ASTMigrateActions;
@@ -102,6 +106,14 @@ public:
   llvm::SmallVector CFFunctionIBCandidates;
   llvm::StringSet<> WhiteListFilenam

r352531 - Extend AnyCall to handle callable declarations without the call expressions

2019-01-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jan 29 11:29:19 2019
New Revision: 352531

URL: http://llvm.org/viewvc/llvm-project?rev=352531&view=rev
Log:
Extend AnyCall to handle callable declarations without the call expressions

That weakens inner invariants, but allows the class to be more generic,
allowing usage in situations where the call expression is not known (or
should not matter).

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

Modified:
cfe/trunk/include/clang/Analysis/AnyCall.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

Modified: cfe/trunk/include/clang/Analysis/AnyCall.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnyCall.h?rev=352531&r1=352530&r2=352531&view=diff
==
--- cfe/trunk/include/clang/Analysis/AnyCall.h (original)
+++ cfe/trunk/include/clang/Analysis/AnyCall.h Tue Jan 29 11:29:19 2019
@@ -19,7 +19,9 @@
 
 namespace clang {
 
-/// An instance of this class corresponds to a 'callable' call.
+/// An instance of this class corresponds to a call.
+/// It might be a syntactically-concrete call, done as a part of evaluating an
+/// expression, or it may be an abstract callee with no associated expression.
 class AnyCall {
 public:
   enum Kind {
@@ -48,7 +50,11 @@ public:
   };
 
 private:
-  /// Call expression, remains null iff the call is an implicit destructor 
call.
+  /// Either expression or declaration (but not both at the same time)
+  /// can be null.
+
+  /// Call expression, is null when is not known (then declaration is 
non-null),
+  /// or for implicit destructor calls (when no expression exists.)
   const Expr *E = nullptr;
 
   /// Corresponds to a statically known declaration of the called function,
@@ -56,8 +62,6 @@ private:
   const Decl *D = nullptr;
   Kind K;
 
-  AnyCall(const Expr *E, const Decl *D, Kind K) : E(E), D(D), K(K) {}
-
 public:
   AnyCall(const CallExpr *CE) : E(CE) {
 D = CE->getCalleeDecl();
@@ -80,6 +84,23 @@ public:
   AnyCall(const CXXConstructExpr *NE)
   : E(NE), D(NE->getConstructor()), K(Constructor) {}
 
+  AnyCall(const CXXDestructorDecl *D) : E(nullptr), D(D), K(Destructor) {}
+
+  AnyCall(const CXXConstructorDecl *D) : E(nullptr), D(D), K(Constructor) {}
+
+  AnyCall(const ObjCMethodDecl *D) : E(nullptr), D(D), K(ObjCMethod) {}
+
+  AnyCall(const FunctionDecl *D) : E(nullptr), D(D) {
+if (isa(D)) {
+  K = Constructor;
+} else if (isa (D)) {
+  K = Destructor;
+} else {
+  K = Function;
+}
+
+  }
+
   /// If {@code E} is a generic call (to ObjC method /function/block/etc),
   /// return a constructed {@code AnyCall} object. Return None otherwise.
   static Optional forExpr(const Expr *E) {
@@ -98,8 +119,16 @@ public:
 }
   }
 
-  static AnyCall forDestructorCall(const CXXDestructorDecl *D) {
-return AnyCall(/*E=*/nullptr, D, Destructor);
+  /// If {@code D} is a callable (Objective-C method or a function), return
+  /// a constructed {@code AnyCall} object. Return None otherwise.
+  // FIXME: block support.
+  static Optional forDecl(const Decl *D) {
+if (const auto *FD = dyn_cast(D)) {
+  return AnyCall(FD);
+} else if (const auto *MD = dyn_cast(D)) {
+  return AnyCall(MD);
+}
+return None;
   }
 
   /// \returns formal parameters for direct calls (including virtual calls)
@@ -111,8 +140,6 @@ public:
   return FD->parameters();
 } else if (const auto *MD = dyn_cast(D)) {
   return MD->parameters();
-} else if (const auto *CD = dyn_cast(D)) {
-  return CD->parameters();
 } else if (const auto *BD = dyn_cast(D)) {
   return BD->parameters();
 } else {
@@ -129,10 +156,17 @@ public:
   QualType getReturnType(ASTContext &Ctx) const {
 switch (K) {
 case Function:
+  if (E)
+return cast(E)->getCallReturnType(Ctx);
+  return cast(D)->getReturnType();
+case ObjCMethod:
+  if (E)
+return cast(E)->getCallReturnType(Ctx);
+  return cast(D)->getReturnType();
 case Block:
+  // FIXME: BlockDecl does not know its return type,
+  // hence the asymmetry with the function and method cases above.
   return cast(E)->getCallReturnType(Ctx);
-case ObjCMethod:
-  return cast(E)->getCallReturnType(Ctx);
 case Destructor:
 case Constructor:
 case Allocator:

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=352531&r1=352530&r2=352531&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Tue Jan 29 11:29:19 2019
@@ -347,7 +347,7 @@ const static RetainSummary *g

[PATCH] D57211: [analyzer] [RetainCountChecker] Support 'taggedRetain' and 'taggedRelease'

2019-01-29 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352530: [analyzer] [RetainCountChecker] Support 
'taggedRetain' and 'taggedRelease' (authored by 
george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57211?vs=183449&id=184137#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57211/new/

https://reviews.llvm.org/D57211

Files:
  lib/Analysis/RetainSummaryManager.cpp
  test/Analysis/os_object_base.h
  test/Analysis/os_smart_ptr.h
  test/Analysis/osobject-retain-release.cpp

Index: test/Analysis/os_smart_ptr.h
===
--- test/Analysis/os_smart_ptr.h
+++ test/Analysis/os_smart_ptr.h
@@ -51,7 +51,6 @@
   }
 
   T * operator->() const {
-OSPTR_LOG("Dereference smart_ptr with %p\n", pointer);
 return pointer;
   }
 
@@ -84,6 +83,6 @@
 
   T *pointer;
 };
-}
+} // namespace os
 
 #endif /* _OS_SMART_POINTER_H */
Index: test/Analysis/osobject-retain-release.cpp
===
--- test/Analysis/osobject-retain-release.cpp
+++ test/Analysis/osobject-retain-release.cpp
@@ -593,12 +593,12 @@
// expected-note@-1{{Returning from constructor for 'smart_ptr'}}
 // expected-note@os_smart_ptr.h:13{{Taking true branch}}
 // expected-note@os_smart_ptr.h:14{{Calling 'smart_ptr::_retain'}}
-// expected-note@os_smart_ptr.h:72{{Reference count incremented. The object now has a +2 retain count}}
+// expected-note@os_smart_ptr.h:71{{Reference count incremented. The object now has a +2 retain count}}
 // expected-note@os_smart_ptr.h:14{{Returning from 'smart_ptr::_retain'}}
   } // expected-note{{Calling '~smart_ptr'}}
   // expected-note@os_smart_ptr.h:35{{Taking true branch}}
   // expected-note@os_smart_ptr.h:36{{Calling 'smart_ptr::_release'}}
-  // expected-note@os_smart_ptr.h:77{{Reference count decremented. The object now has a +1 retain count}}
+  // expected-note@os_smart_ptr.h:76{{Reference count decremented. The object now has a +1 retain count}}
   // expected-note@os_smart_ptr.h:36{{Returning from 'smart_ptr::_release'}}
  // expected-note@-5{{Returning from '~smart_ptr'}}
   obj->release(); // expected-note{{Object released}}
@@ -613,12 +613,12 @@
// expected-note@-1{{Returning from constructor for 'smart_ptr'}}
 // expected-note@os_smart_ptr.h:13{{Taking true branch}}
 // expected-note@os_smart_ptr.h:14{{Calling 'smart_ptr::_retain'}}
-// expected-note@os_smart_ptr.h:72{{Reference count incremented. The object now has a +2 retain count}}
+// expected-note@os_smart_ptr.h:71{{Reference count incremented. The object now has a +2 retain count}}
 // expected-note@os_smart_ptr.h:14{{Returning from 'smart_ptr::_retain'}}
   } // expected-note{{Calling '~smart_ptr'}}
   // expected-note@os_smart_ptr.h:35{{Taking true branch}}
   // expected-note@os_smart_ptr.h:36{{Calling 'smart_ptr::_release'}}
-  // expected-note@os_smart_ptr.h:77{{Reference count decremented. The object now has a +1 retain count}}
+  // expected-note@os_smart_ptr.h:76{{Reference count decremented. The object now has a +1 retain count}}
   // expected-note@os_smart_ptr.h:36{{Returning from 'smart_ptr::_release'}}
  // expected-note@-5{{Returning from '~smart_ptr'}}
 } // expected-warning{{Potential leak of an object stored into 'obj'}}
@@ -648,3 +648,15 @@
   // expected-warning@-1{{'free' called on an object that may be referenced elsewhere}}
 }
 
+void test_tagged_retain_no_leak() {
+  OSObject *obj = new OSObject;
+  obj->taggedRelease();
+}
+
+void test_tagged_retain_no_uaf() {
+  OSObject *obj = new OSObject;
+  obj->taggedRetain();
+  obj->release();
+  obj->release();
+}
+
Index: test/Analysis/os_object_base.h
===
--- test/Analysis/os_object_base.h
+++ test/Analysis/os_object_base.h
@@ -27,6 +27,10 @@
 
   virtual void retain() const;
   virtual void release() const;
+
+  virtual void taggedRetain(const void * tag = nullptr) const;
+  virtual void taggedRelease(const void * tag = nullptr) const;
+
   virtual void free();
   virtual ~OSMetaClassBase(){};
 };
Index: lib/Analysis/RetainSummaryManager.cpp
===
--- lib/Analysis/RetainSummaryManager.cpp
+++ lib/Analysis/RetainSummaryManager.cpp
@@ -242,10 +242,10 @@
   if (const auto *MD = dyn_cast(FD)) {
 const CXXRecordDecl *Parent = MD->getParent();
 if (TrackOSObjects && Parent && isOSObjectSubclass(Parent)) {
-  if (FName == "release")
+  if (FName == "release" || FName == "taggedRelease")
 return getOSSummaryReleaseRule(FD);
 
-  if (FName == "retain")
+  if (FName == "retain" || FName == "taggedRetain")
 return getOSSummaryRetainRule(FD);
 
   if (FName == "free")
___
cfe-c

r352530 - [analyzer] [RetainCountChecker] Support 'taggedRetain' and 'taggedRelease'

2019-01-29 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Jan 29 11:29:07 2019
New Revision: 352530

URL: http://llvm.org/viewvc/llvm-project?rev=352530&view=rev
Log:
[analyzer] [RetainCountChecker] Support 'taggedRetain' and 'taggedRelease'

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

Modified:
cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/os_object_base.h
cfe/trunk/test/Analysis/os_smart_ptr.h
cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: cfe/trunk/lib/Analysis/RetainSummaryManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RetainSummaryManager.cpp?rev=352530&r1=352529&r2=352530&view=diff
==
--- cfe/trunk/lib/Analysis/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/Analysis/RetainSummaryManager.cpp Tue Jan 29 11:29:07 2019
@@ -242,10 +242,10 @@ RetainSummaryManager::getSummaryForOSObj
   if (const auto *MD = dyn_cast(FD)) {
 const CXXRecordDecl *Parent = MD->getParent();
 if (TrackOSObjects && Parent && isOSObjectSubclass(Parent)) {
-  if (FName == "release")
+  if (FName == "release" || FName == "taggedRelease")
 return getOSSummaryReleaseRule(FD);
 
-  if (FName == "retain")
+  if (FName == "retain" || FName == "taggedRetain")
 return getOSSummaryRetainRule(FD);
 
   if (FName == "free")

Modified: cfe/trunk/test/Analysis/os_object_base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/os_object_base.h?rev=352530&r1=352529&r2=352530&view=diff
==
--- cfe/trunk/test/Analysis/os_object_base.h (original)
+++ cfe/trunk/test/Analysis/os_object_base.h Tue Jan 29 11:29:07 2019
@@ -27,6 +27,10 @@ struct OSMetaClassBase {
 
   virtual void retain() const;
   virtual void release() const;
+
+  virtual void taggedRetain(const void * tag = nullptr) const;
+  virtual void taggedRelease(const void * tag = nullptr) const;
+
   virtual void free();
   virtual ~OSMetaClassBase(){};
 };

Modified: cfe/trunk/test/Analysis/os_smart_ptr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/os_smart_ptr.h?rev=352530&r1=352529&r2=352530&view=diff
==
--- cfe/trunk/test/Analysis/os_smart_ptr.h (original)
+++ cfe/trunk/test/Analysis/os_smart_ptr.h Tue Jan 29 11:29:07 2019
@@ -51,7 +51,6 @@ struct smart_ptr {
   }
 
   T * operator->() const {
-OSPTR_LOG("Dereference smart_ptr with %p\n", pointer);
 return pointer;
   }
 
@@ -84,6 +83,6 @@ struct smart_ptr {
 
   T *pointer;
 };
-}
+} // namespace os
 
 #endif /* _OS_SMART_POINTER_H */

Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=352530&r1=352529&r2=352530&view=diff
==
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Tue Jan 29 11:29:07 2019
@@ -593,12 +593,12 @@ void test_smart_ptr_uaf() {
// expected-note@-1{{Returning from constructor for 'smart_ptr'}}
 // expected-note@os_smart_ptr.h:13{{Taking true branch}}
 // expected-note@os_smart_ptr.h:14{{Calling 'smart_ptr::_retain'}}
-// expected-note@os_smart_ptr.h:72{{Reference count incremented. The 
object now has a +2 retain count}}
+// expected-note@os_smart_ptr.h:71{{Reference count incremented. The 
object now has a +2 retain count}}
 // expected-note@os_smart_ptr.h:14{{Returning from 'smart_ptr::_retain'}}
   } // expected-note{{Calling '~smart_ptr'}}
   // expected-note@os_smart_ptr.h:35{{Taking true branch}}
   // expected-note@os_smart_ptr.h:36{{Calling 'smart_ptr::_release'}}
-  // expected-note@os_smart_ptr.h:77{{Reference count decremented. The object 
now has a +1 retain count}}
+  // expected-note@os_smart_ptr.h:76{{Reference count decremented. The object 
now has a +1 retain count}}
   // expected-note@os_smart_ptr.h:36{{Returning from 'smart_ptr::_release'}}
  // expected-note@-5{{Returning from '~smart_ptr'}}
   obj->release(); // expected-note{{Object released}}
@@ -613,12 +613,12 @@ void test_smart_ptr_leak() {
// expected-note@-1{{Returning from constructor for 'smart_ptr'}}
 // expected-note@os_smart_ptr.h:13{{Taking true branch}}
 // expected-note@os_smart_ptr.h:14{{Calling 'smart_ptr::_retain'}}
-// expected-note@os_smart_ptr.h:72{{Reference count incremented. The 
object now has a +2 retain count}}
+// expected-note@os_smart_ptr.h:71{{Reference count incremented. The 
object now has a +2 retain count}}
 // expected-note@os_smart_ptr.h:14{{Returning from 'smart_ptr::_retain'}}
   } // expected-note{{Calling '~smart_ptr'}}
   // expected-note@os_smart_ptr.h:35{{Taking true branch}}
   // expected-note@os_smart_ptr.h:3

[PATCH] D57405: Revert "OpenCL: Extend argument promotion rules to vector types"

2019-01-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: rjmccall, Anastasia.
Herald added subscribers: yaxunl, wdng.

This reverts r348083. This was based on a misreading of the spec
for printf specifiers.

  

Also revert r343653, as without a subsequent patch, a correctly
specified format for a vector will incorrectly warn.

  

Fixes bug 40491.


https://reviews.llvm.org/D57405

Files:
  lib/Headers/opencl-c.h
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/printf.cl
  test/SemaOpenCL/printf-format-string-warnings.cl
  test/SemaOpenCL/printf-format-strings.cl

Index: test/SemaOpenCL/printf-format-strings.cl
===
--- test/SemaOpenCL/printf-format-strings.cl
+++ test/SemaOpenCL/printf-format-strings.cl
@@ -13,10 +13,10 @@
 kernel void format_v4f32(float4 arg)
 {
 #ifdef cl_khr_fp64
-printf("%v4f\n", arg);
+printf("%v4f\n", arg); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
 
 // Precision modifier
-printf("%.2v4f\n", arg);
+printf("%.2v4f\n", arg); // expected-warning{{format specifies type 'double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
 #else
 // FIXME: These should not warn, and the type should be expected to be float.
 printf("%v4f\n", arg);  // expected-warning {{double __attribute__((ext_vector_type(4)))' but the argument has type 'float4' (vector of 4 'float' values)}}
Index: test/SemaOpenCL/printf-format-string-warnings.cl
===
--- test/SemaOpenCL/printf-format-string-warnings.cl
+++ test/SemaOpenCL/printf-format-string-warnings.cl
@@ -1,13 +1,14 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 -finclude-default-header
 
-// Make sure warnings are produced based on printf format strings.
+// FIXME: Make sure warnings are produced based on printf format strings.
 
+// expected-no-diagnostics
 
 kernel void format_string_warnings(__constant char* arg) {
 
-  printf("%d", arg); // expected-warning {{format specifies type 'int' but the argument has type '__constant char *'}}
+  printf("%d", arg);
 
-  printf("not enough arguments %d %d", 4); // expected-warning {{more '%' conversions than data arguments}}
+  printf("not enough arguments %d %d", 4);
 
-  printf("too many arguments", 4); // expected-warning {{data argument not used by format string}}
+  printf("too many arguments", 4);
 }
Index: test/CodeGenOpenCL/printf.cl
===
--- test/CodeGenOpenCL/printf.cl
+++ test/CodeGenOpenCL/printf.cl
@@ -12,28 +12,26 @@
 
 
 // ALL-LABEL: @test_printf_float2(
-// FP64: %conv = fpext <2 x float> %0 to <2 x double>
-// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %conv)
+// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
 
-// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
+
+// NOFP64:  call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
 kernel void test_printf_float2(float2 arg) {
-  printf("%v2f", arg);
+  printf("%v2hlf", arg);
 }
 
 // ALL-LABEL: @test_printf_half2(
-// FP64: %conv = fpext <2 x half> %0 to <2 x double>
-// FP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %conv) #2
+// FP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.1, i32 0, i32 0), <2 x half> %0)
 
-// NOFP64: %conv = fpext <2 x half> %0 to <2 x float>
-// NOFP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %conv) #2
+// NOFP64:  %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.1, i32 0, i32 0), <2 x half> %0)
 kernel void test_printf_half2(half2 arg) {
-  printf("%v2f", arg);
+  printf("%v2hf", arg);
 }
 
 #ifdef cl_khr_fp64
 // FP64-LABEL: @test_printf_double2(
-// FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x double> %0) #2
+// FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* gete

[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2019-01-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

After this landed, options for RetainCountChecker stopped working - e.g. I 
can't use `osx.cocoa.RetainCount:blah=X`.
Do you know why is this the case / how to fix it?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54438/new/

https://reviews.llvm.org/D54438



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


[PATCH] D57404: build: remove use of llvm-config

2019-01-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Will overriding `LLVM_BUILD_MAIN_SRC_DIR` work? Gentoo relies on being able to 
provide sources in another directory since all builds are done in isolated 
temporary directories.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57404/new/

https://reviews.llvm.org/D57404



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


Re: r352524 - Rollback unwindlib patch.

2019-01-29 Thread Richard Smith via cfe-commits
Hi Sterling,

For a rollback, it's useful to list in the commit message why the change is
being rolled back. Thanks!

On Tue, 29 Jan 2019, 10:27 Sterling Augustine via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> Author: saugustine
> Date: Tue Jan 29 10:27:51 2019
> New Revision: 352524
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352524&view=rev
> Log:
> Rollback unwindlib patch.
>
> Removed:
> cfe/trunk/test/Driver/compiler-rt-unwind.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/include/clang/Driver/ToolChain.h
> cfe/trunk/lib/Driver/ToolChain.cpp
> cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=352524&r1=352523&r2=352524&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jan 29
> 10:27:51 2019
> @@ -51,10 +51,6 @@ def err_drv_invalid_rtlib_name : Error<
>"invalid runtime library name in argument '%0'">;
>  def err_drv_unsupported_rtlib_for_platform : Error<
>"unsupported runtime library '%0' for platform '%1'">;
> -def err_drv_invalid_unwindlib_name : Error<
> -  "invalid unwind library name in argument '%0'">;
> -def err_drv_incompatible_unwindlib : Error<
> -  "--rtlib=libgcc requires --unwindlib=libgcc">;
>  def err_drv_invalid_stdlib_name : Error<
>"invalid library name in argument '%0'">;
>  def err_drv_invalid_output_with_multiple_archs : Error<
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352524&r1=352523&r2=352524&view=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Tue Jan 29 10:27:51 2019
> @@ -2568,8 +2568,6 @@ def std_EQ : Joined<["-", "--"], "std=">
>}]>;
>  def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
>HelpText<"C++ standard library to use">,
> Values<"libc++,libstdc++,platform">;
> -def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
> -  HelpText<"Unwind library to use">,
> Values<"libgcc,compiler-rt,platform">;
>  def sub__library : JoinedOrSeparate<["-"], "sub_library">;
>  def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
>  def system_header_prefix : Joined<["--"], "system-header-prefix=">,
>
> Modified: cfe/trunk/include/clang/Driver/ToolChain.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=352524&r1=352523&r2=352524&view=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
> +++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Jan 29 10:27:51 2019
> @@ -367,10 +367,6 @@ public:
>  return ToolChain::CST_Libstdcxx;
>}
>
> -  virtual RuntimeLibType GetDefaultUnwindLibType() const {
> -return ToolChain::RLT_Libgcc;
> -  }
> -
>virtual std::string getCompilerRTPath() const;
>
>virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
> @@ -515,10 +511,6 @@ public:
>// given compilation arguments.
>virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args)
> const;
>
> -  // GetUnwindLibType - Determine the unwind library type to use with the
> -  // given compilation arguments.
> -  virtual RuntimeLibType GetUnwindLibType(const llvm::opt::ArgList &Args)
> const;
> -
>/// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments
> to set
>/// the include paths to use for the given C++ standard library type.
>virtual void
>
> Modified: cfe/trunk/lib/Driver/ToolChain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=352524&r1=352523&r2=352524&view=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Jan 29 10:27:51 2019
> @@ -679,33 +679,6 @@ ToolChain::RuntimeLibType ToolChain::Get
>return GetDefaultRuntimeLibType();
>  }
>
> -ToolChain::RuntimeLibType ToolChain
> -::GetUnwindLibType(
> -const ArgList &Args) const {
> -  const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
> -  // If nothing has been specified, follow the runtime lib type.
> -  if (!A)
> -return GetRuntimeLibType(Args);
> -
> -  StringRef LibName = A->getValue();
> -  if (LibName == "compiler-rt") {
> -if (GetRuntimeLibType(Args) == RLT_Libgcc)
> -  getDriver().Diag(diag::err_drv_incompatible_unwindlib);
> -return ToolChain::RLT_CompilerRT;
> -

[PATCH] D57404: build: remove use of llvm-config

2019-01-29 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: chandlerc, rnk.
Herald added a subscriber: mgorny.

Update the CMake build to use the LLVM CMake Config package rather than 
invoking `llvm-config` to find the parameters.  Users can specify `-DLLVM_DIR=` 
to CMake to indicate where the LLVM build is (as opposed to `-DLLVM_CONFIG=`.  
For uses where the system provides LLVM or LLVM's build output is in the CMake 
search path, no parameters are necessary.  This removes use of `llvm-config` 
which is helpful on the path to removing `llvm-config` from LLVM.


Repository:
  rC Clang

https://reviews.llvm.org/D57404

Files:
  CMakeLists.txt
  lib/Basic/CMakeLists.txt
  runtime/CMakeLists.txt

Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -22,7 +22,7 @@
   endif()
 endfunction()
 
-set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
+set(COMPILER_RT_SRC_ROOT ${LLVM_BUILD_MAIN_SRC_DIR}/projects/compiler-rt)
 # Fallback to the external path, if the other one isn't available.
 # This is the same behavior (try "internal", then check the LLVM_EXTERNAL_...
 # variable) as in add_llvm_external_project
Index: lib/Basic/CMakeLists.txt
===
--- lib/Basic/CMakeLists.txt
+++ lib/Basic/CMakeLists.txt
@@ -4,7 +4,7 @@
   Support
   )
 
-find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}")
+find_first_existing_vc_file(llvm_vc "${LLVM_BUILD_MAIN_SRC_DIR}")
 find_first_existing_vc_file(clang_vc "${CLANG_SOURCE_DIR}")
 
 # The VC revision include that we want to generate.
@@ -17,7 +17,7 @@
   add_custom_command(OUTPUT "${version_inc}"
 DEPENDS "${llvm_vc}" "${clang_vc}" "${get_svn_script}"
 COMMAND
-${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLVM_MAIN_SRC_DIR}"
+${CMAKE_COMMAND} "-DFIRST_SOURCE_DIR=${LLVM_BUILD_MAIN_SRC_DIR}"
  "-DFIRST_NAME=LLVM"
  "-DSECOND_SOURCE_DIR=${CLANG_SOURCE_DIR}"
  "-DSECOND_NAME=SVN"
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -9,82 +9,34 @@
 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   project(Clang)
 
-  # Rely on llvm-config.
-  set(CONFIG_OUTPUT)
-  if(LLVM_CONFIG)
-set (LLVM_CONFIG_FOUND 1)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
-  instead.  CMake should be able to detect your LLVM install \
-  automatically, but you can also use LLVM_DIR to specify \
-  the path containing LLVMConfig.cmake.")
-set(CONFIG_COMMAND ${LLVM_CONFIG}
-  "--assertion-mode"
-  "--bindir"
-  "--libdir"
-  "--includedir"
-  "--prefix"
-  "--src-root"
-  "--cmakedir")
-execute_process(
-  COMMAND ${CONFIG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE CONFIG_OUTPUT
-)
-if(NOT HAD_ERROR)
-  string(REGEX REPLACE
-"[ \t]*[\r\n]+[ \t]*" ";"
-CONFIG_OUTPUT ${CONFIG_OUTPUT})
-else()
-  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
-  message(STATUS "${CONFIG_COMMAND_STR}")
-  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif()
-
-list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
-list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
-list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
-list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
-list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
-list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
-list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
-
-# Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
-# CMake assumes slashes as PATH.
-file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} LLVM_CMAKE_PATH)
-  endif()
-
-
-  if(NOT MSVC_IDE)
-set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
-  CACHE BOOL "Enable assertions")
-# Assertions should follow llvm-config's.
-mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
-  endif()
-
-  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_PATH}")
+  find_package(LLVM REQUIRED CONFIG NO_CMAKE_FIND_ROOT_PATH)
   list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
 
-  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-  # LLVM_CONFIG.
-  if (NOT LLVM_CONFIG_FOUND)
-# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-# path is removed.
-set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
-set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
-set(INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-  endif()
+  if(CMAKE_CROSSCOMPILING)
+set(LLVM_NATIVE_BUILD "${LLVM_BINARY_DIR}/NATIVE")
+if(NOT EXISTS "${LLVM_NATIVE_BUILD}")
+  message(FATAL_ERROR
+"Attempting to cross-compile Clang s

r352526 - [OPENMP]Make the loop with unsigned counter countable.

2019-01-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jan 29 10:51:58 2019
New Revision: 352526

URL: http://llvm.org/viewvc/llvm-project?rev=352526&view=rev
Log:
[OPENMP]Make the loop with unsigned counter countable.

According to the report, better to keep the original strict compare
operation as the loop condition with unsigned loop counters to make the
loop countable. This allows further loop transformations.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/ordered_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=352526&r1=352525&r2=352526&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 29 10:51:58 2019
@@ -4008,6 +4008,8 @@ public:
   SourceRange getIncrementSrcRange() const { return IncrementSrcRange; }
   /// True if the step should be subtracted.
   bool shouldSubtractStep() const { return SubtractStep; }
+  /// True, if the compare operator is strict (<, > or !=).
+  bool isStrictTestOp() const { return TestIsStrictOp; }
   /// Build the expression to calculate the number of iterations.
   Expr *buildNumIterations(
   Scope *S, const bool LimitedType,
@@ -4080,7 +4082,8 @@ bool OpenMPIterationSpaceChecker::setLCD
   return false;
 }
 
-bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB, llvm::Optional 
LessOp,
+bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB,
+llvm::Optional LessOp,
 bool StrictOp, SourceRange SR,
 SourceLocation SL) {
   // State consistency checking to ensure correct usage.
@@ -4647,10 +4650,12 @@ Expr *OpenMPIterationSpaceChecker::build
   if (VarType->isIntegerType() || VarType->isPointerType() ||
   SemaRef.getLangOpts().CPlusPlus) {
 // Upper - Lower
-Expr *Upper =
-TestIsLessOp.getValue() ? Cnt : tryBuildCapture(SemaRef, UB, 
Captures).get();
-Expr *Lower =
-TestIsLessOp.getValue() ? tryBuildCapture(SemaRef, LB, Captures).get() 
: Cnt;
+Expr *Upper = TestIsLessOp.getValue()
+  ? Cnt
+  : tryBuildCapture(SemaRef, UB, Captures).get();
+Expr *Lower = TestIsLessOp.getValue()
+  ? tryBuildCapture(SemaRef, LB, Captures).get()
+  : Cnt;
 if (!Upper || !Lower)
   return nullptr;
 
@@ -4686,6 +4691,9 @@ Expr *OpenMPIterationSpaceChecker::build
 
 /// Iteration space of a single for loop.
 struct LoopIterationSpace final {
+  /// True if the condition operator is the strict compare operator (<, > or
+  /// !=).
+  bool IsStrictCompare = false;
   /// Condition of the loop.
   Expr *PreCond = nullptr;
   /// This expression calculates the number of iterations in the loop.
@@ -4892,6 +4900,7 @@ static bool checkOpenMPIterationSpace(
   ResultIterSpace.CondSrcRange = ISC.getConditionSrcRange();
   ResultIterSpace.IncSrcRange = ISC.getIncrementSrcRange();
   ResultIterSpace.Subtract = ISC.shouldSubtractStep();
+  ResultIterSpace.IsStrictCompare = ISC.isStrictTestOp();
 
   HasErrors |= (ResultIterSpace.PreCond == nullptr ||
 ResultIterSpace.NumIterations == nullptr ||
@@ -5139,8 +5148,8 @@ checkOpenMPLoop(OpenMPDirectiveKind DKin
   // This is helper routine for loop directives (e.g., 'for', 'simd',
   // 'for simd', etc.).
   llvm::MapVector Captures;
-  SmallVector IterSpaces;
-  IterSpaces.resize(std::max(OrderedLoopCount, NestedLoopCount));
+  SmallVector IterSpaces(
+  std::max(OrderedLoopCount, NestedLoopCount));
   Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true);
   for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) {
 if (checkOpenMPIterationSpace(
@@ -5446,25 +5455,55 @@ checkOpenMPLoop(OpenMPDirectiveKind DKin
 }
   }
 
-  // Loop condition (IV < NumIterations) or (IV <= UB) for worksharing loops.
+  bool UseStrictCompare =
+  RealVType->hasUnsignedIntegerRepresentation() &&
+  llvm::all_of(IterSpaces, [](const LoopIterationSpace &LIS) {
+return LIS.IsStrictCompare;
+  });
+  // Loop condition (IV < NumIterations) or (IV <= UB or IV < UB + 1 (for
+  // unsigned IV)) for worksharing loops.
   SourceLocation CondLoc = AStmt->getBeginLoc();
+  Expr *BoundUB = UB.get();
+  if (UseStrictCompare) {
+BoundUB =
+SemaRef
+.BuildBinOp(CurScope, CondLoc, BO_Add, BoundUB,
+SemaRef.ActOnIntegerConstant(SourceLocation(), 
1).get())
+.get();
+BoundUB =
+SemaRef.ActOnFinishFullExpr(BoundUB, /*DiscardedValue*/ false).get();
+  }
   ExprResult Cond =
   (isOpenMPWorksharingDirective(DKind) ||
isOpenMPTaskLoopDirective(DKind) || isOpenMPDistributeDirective(DKind))
-  ? SemaRef.

r352524 - Rollback unwindlib patch.

2019-01-29 Thread Sterling Augustine via cfe-commits
Author: saugustine
Date: Tue Jan 29 10:27:51 2019
New Revision: 352524

URL: http://llvm.org/viewvc/llvm-project?rev=352524&view=rev
Log:
Rollback unwindlib patch.

Removed:
cfe/trunk/test/Driver/compiler-rt-unwind.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=352524&r1=352523&r2=352524&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Jan 29 10:27:51 
2019
@@ -51,10 +51,6 @@ def err_drv_invalid_rtlib_name : Error<
   "invalid runtime library name in argument '%0'">;
 def err_drv_unsupported_rtlib_for_platform : Error<
   "unsupported runtime library '%0' for platform '%1'">;
-def err_drv_invalid_unwindlib_name : Error<
-  "invalid unwind library name in argument '%0'">;
-def err_drv_incompatible_unwindlib : Error<
-  "--rtlib=libgcc requires --unwindlib=libgcc">;
 def err_drv_invalid_stdlib_name : Error<
   "invalid library name in argument '%0'">;
 def err_drv_invalid_output_with_multiple_archs : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352524&r1=352523&r2=352524&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jan 29 10:27:51 2019
@@ -2568,8 +2568,6 @@ def std_EQ : Joined<["-", "--"], "std=">
   }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
-def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
-  HelpText<"Unwind library to use">, Values<"libgcc,compiler-rt,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;
 def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
 def system_header_prefix : Joined<["--"], "system-header-prefix=">,

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=352524&r1=352523&r2=352524&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Jan 29 10:27:51 2019
@@ -367,10 +367,6 @@ public:
 return ToolChain::CST_Libstdcxx;
   }
 
-  virtual RuntimeLibType GetDefaultUnwindLibType() const {
-return ToolChain::RLT_Libgcc;
-  }
-
   virtual std::string getCompilerRTPath() const;
 
   virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
@@ -515,10 +511,6 @@ public:
   // given compilation arguments.
   virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
 
-  // GetUnwindLibType - Determine the unwind library type to use with the
-  // given compilation arguments.
-  virtual RuntimeLibType GetUnwindLibType(const llvm::opt::ArgList &Args) 
const;
-
   /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
   /// the include paths to use for the given C++ standard library type.
   virtual void

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=352524&r1=352523&r2=352524&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Jan 29 10:27:51 2019
@@ -679,33 +679,6 @@ ToolChain::RuntimeLibType ToolChain::Get
   return GetDefaultRuntimeLibType();
 }
 
-ToolChain::RuntimeLibType ToolChain
-::GetUnwindLibType(
-const ArgList &Args) const {
-  const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
-  // If nothing has been specified, follow the runtime lib type.
-  if (!A)
-return GetRuntimeLibType(Args);
-
-  StringRef LibName = A->getValue();
-  if (LibName == "compiler-rt") {
-if (GetRuntimeLibType(Args) == RLT_Libgcc)
-  getDriver().Diag(diag::err_drv_incompatible_unwindlib);
-return ToolChain::RLT_CompilerRT;
-  }
-  else if (LibName == "libgcc")
-return ToolChain::RLT_Libgcc;
-  else if (LibName == "platform") {
-return GetRuntimeLibType(Args);
-  }
-
-  if (A)
-getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
-<< A->getAsString(Args);
-
-  return GetDefaultUnwindLibType();
-}
-
 ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) 
const{
   const Arg *A = Args.getLastArg(options::

[PATCH] D18914: [clang-tidy] new readability-redundant-inline

2019-01-29 Thread Samuel Benzaquen via Phabricator via cfe-commits
sbenza added a comment.

In D18914#396149 , @mgehre wrote:

> ...
>  I personally think that 1) should be used, because late one could move the 
> function definition to a source file (removing the inline) without having to 
> touch
>  the class declaration. I can extend this patch to transform 2) and 3) into 
> 1).
>
> Alternatively, I could add an option to choose between 1), 2) or 3).
>  What do you think?


I agree that (1) is preferred as it makes `inline` an implementation detail and 
doesn't pollute the class, but that is a style choice.
What we could do is transform (3) to (1). That is, if you provide _both_ 
`inline`s we remove one as it is redundant. That matches with the purpose of 
this check.

But changing (2) to (1) is not removing anything redundant, it is a style 
change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D18914/new/

https://reviews.llvm.org/D18914



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


[PATCH] D56927: Disable PIC/PIE for MSP430 target

2019-01-29 Thread Dmitry Mikushin via Phabricator via cfe-commits
dmikushin updated this revision to Diff 184118.
dmikushin added a comment.

Unbreaking patch by providing an appropriate toolchain requirement


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56927/new/

https://reviews.llvm.org/D56927

Files:
  lib/Driver/ToolChains/MSP430.h
  test/CodeGen/msp430-reloc.c


Index: test/CodeGen/msp430-reloc.c
===
--- /dev/null
+++ test/CodeGen/msp430-reloc.c
@@ -0,0 +1,30 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s
+
+// Check the compilation does not crash as it was crashing before with "-fPIC" 
enabled
+
+void *alloca(unsigned int size);
+
+// CHECK: .globl foo
+short foo(char** data, char encoding)
+{
+   char* encoding_addr = alloca(sizeof(char));
+   *encoding_addr = encoding;
+
+   char tmp3 = *encoding_addr;
+   short conv2 = tmp3;
+   short and = conv2 & 0xf;
+
+   switch (and)
+   {
+   case 0 :
+   case 4 :
+   case 10 :
+   return 1;
+   case 11 :
+   return 2;
+   }
+
+   return 0;
+}
+
Index: lib/Driver/ToolChains/MSP430.h
===
--- lib/Driver/ToolChains/MSP430.h
+++ lib/Driver/ToolChains/MSP430.h
@@ -36,6 +36,10 @@
  llvm::opt::ArgStringList &CC1Args,
  Action::OffloadKind) const override;
 
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
+
 protected:
   Tool *buildLinker() const override;
 


Index: test/CodeGen/msp430-reloc.c
===
--- /dev/null
+++ test/CodeGen/msp430-reloc.c
@@ -0,0 +1,30 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s
+
+// Check the compilation does not crash as it was crashing before with "-fPIC" enabled
+
+void *alloca(unsigned int size);
+
+// CHECK: .globl foo
+short foo(char** data, char encoding)
+{
+	char* encoding_addr = alloca(sizeof(char));
+	*encoding_addr = encoding;
+
+	char tmp3 = *encoding_addr;
+	short conv2 = tmp3;
+	short and = conv2 & 0xf;
+
+	switch (and)
+	{
+	case 0 :
+	case 4 :
+	case 10 :
+		return 1;
+	case 11 :
+		return 2;
+	}
+
+	return 0;
+}
+
Index: lib/Driver/ToolChains/MSP430.h
===
--- lib/Driver/ToolChains/MSP430.h
+++ lib/Driver/ToolChains/MSP430.h
@@ -36,6 +36,10 @@
  llvm::opt::ArgStringList &CC1Args,
  Action::OffloadKind) const override;
 
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return true; }
+
 protected:
   Tool *buildLinker() const override;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57390: OpenCL: Don't promote vector args to printf

2019-01-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/AST/FormatString.h:70
 AsShort,  // 'h'
+AsInt,// 'hl' (OpenCL float/int vector element)
 AsLong,   // 'l'

I think giving this a weird name like `AsShortLong` might help make it clearer 
to readers below that it's a non-standard modifier.



Comment at: lib/AST/FormatString.cpp:728
+  return true;
+  }
+

Your comment here doesn't match the code: you're accepting if this is a FP 
vector, but otherwise you're falling through.  The comment sounds like this 
check should be `if (CS.isDoubleArg()) return !VectorNumElts.isInvalid();`.



Comment at: lib/AST/FormatString.cpp:775
+  if (LO.OpenCL && VectorNumElts.isInvalid() && CS.isDoubleArg())
+return false;
+

Can you just break the FP args out of the switch below and add this check there?



Comment at: lib/Sema/SemaExpr.cpp:755
 }
   }
 

Can you just do this as a separate patch without the printf checking?  We're 
going to want to merge this to the release branch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57390/new/

https://reviews.llvm.org/D57390



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


[PATCH] D56925: Do not use frame pointer by default for MSP430

2019-01-29 Thread Dmitry Mikushin via Phabricator via cfe-commits
dmikushin updated this revision to Diff 184116.
dmikushin edited the summary of this revision.
dmikushin added a comment.

Unbreaking clang driver patch. Not using calla asm instruction, as recomended.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56925/new/

https://reviews.llvm.org/D56925

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGen/msp430-fp-elim.c


Index: test/CodeGen/msp430-fp-elim.c
===
--- /dev/null
+++ test/CodeGen/msp430-fp-elim.c
@@ -0,0 +1,19 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang_cc1 -mdisable-fp-elim -triple msp430 -S %s -o - | FileCheck %s 
--check-prefix=FP_ENFORCED
+// RUN: %clang_cc1 -triple msp430 -S %s -o - | FileCheck %s 
--check-prefix=FP_DEFAULT
+
+// Check the frame pointer is not used on MSP430 by default, but can be 
forcibly turned on.
+
+// FP_ENFORCED: push r4
+// FP_ENFORCED: mov r4, r4
+// FP_ENFORCED: pop r4
+// FP_DEFAULT: .globl fp_elim_check
+// FP_DEFAULT-NOT: push r4
+// FP_DEFAULT: mov r4, r4
+// FP_DEFAULT-NOT: pop r4
+
+void fp_elim_check()
+{
+   asm volatile ("mov r4, r4");
+}
+
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -519,6 +519,7 @@
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:
+  case llvm::Triple::msp430:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;


Index: test/CodeGen/msp430-fp-elim.c
===
--- /dev/null
+++ test/CodeGen/msp430-fp-elim.c
@@ -0,0 +1,19 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang_cc1 -mdisable-fp-elim -triple msp430 -S %s -o - | FileCheck %s --check-prefix=FP_ENFORCED
+// RUN: %clang_cc1 -triple msp430 -S %s -o - | FileCheck %s --check-prefix=FP_DEFAULT
+
+// Check the frame pointer is not used on MSP430 by default, but can be forcibly turned on.
+
+// FP_ENFORCED: push r4
+// FP_ENFORCED: mov r4, r4
+// FP_ENFORCED: pop r4
+// FP_DEFAULT: .globl fp_elim_check
+// FP_DEFAULT-NOT: push r4
+// FP_DEFAULT: mov r4, r4
+// FP_DEFAULT-NOT: pop r4
+
+void fp_elim_check()
+{
+	asm volatile ("mov r4, r4");
+}
+
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -519,6 +519,7 @@
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
   case llvm::Triple::wasm64:
+  case llvm::Triple::msp430:
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33841: [clang-tidy] redundant keyword check

2019-01-29 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 184111.
koldaniel added a comment.

As it was mentioned earlier, I think it would be a better way forward to handle 
the check of redundant inlines in the scope of the other checker: 
https://reviews.llvm.org/D18914


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D33841/new/

https://reviews.llvm.org/D33841

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantExternCheck.cpp
  clang-tidy/readability/RedundantExternCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-extern.rst
  test/clang-tidy/readability-redundant-extern.cpp

Index: test/clang-tidy/readability-redundant-extern.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-extern.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s readability-redundant-extern %t
+
+extern int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f();
+
+extern int f() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f() { return 0; }
+
+extern "C" int g();
+
+extern "C" int g() { return 0; }
+
+extern "C++" int h();
+
+extern "C++" int h() { return 0; }
+
+inline extern void foo_inline();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: inline void foo_inline();
+
+#define FOO_EXTERN extern
+FOO_EXTERN void foo_macro_1();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+
+#define FOO_INLINE inline
+FOO_INLINE extern void foo_macro_3();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+
+#define FOO_EXTERN_INLINE inline extern
+FOO_EXTERN_INLINE void foo_macro_2();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
Index: docs/clang-tidy/checks/readability-redundant-extern.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-extern.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - readability-redundant-extern
+
+readability-redundant-extern
+=
+
+This checker removes the redundant `extern` keywords from code.
+
+`extern` is redundant in function declarations
+
+.. code-block:: c++
+
+  extern void h();
+  
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -224,6 +224,7 @@
readability-non-const-parameter
readability-redundant-control-flow
readability-redundant-declaration
+   readability-redundant-extern
readability-redundant-function-ptr-dereference
readability-redundant-member-init
readability-redundant-smartptr-get
Index: clang-tidy/readability/RedundantExternCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantExternCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantExternCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_EXTERN_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_EXTERN_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Finds redundant 'extern' keywords
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-extern.html
+class RedundantExternCheck : public ClangTidyCheck {
+public:
+  RedundantExternCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_EXTERN_H
Index: clang-tidy/readability/RedundantExternCheck.cpp
===
--- /dev/null
+++ clang-tidy/readability/RedundantExternCheck.cpp
@@ -0,0 +1,54 @@
+//===--- RedundantExternCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License

[PATCH] D44823: [libcxx] Improving std::vector and std::deque perfomance

2019-01-29 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

In D44823#1375590 , @mclow.lists wrote:

> I just tried this (on Compiler Explorer) using LLVM 7, and the code for my 
> original test in https://bugs.llvm.org/show_bug.cgi?id=35637 is now optimal.


Pilot error - it's still the same.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D44823/new/

https://reviews.llvm.org/D44823



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


  1   2   >