[PATCH] D30032: Process attributes 'ifunc' and 'alias' when checking for redefinition

2017-02-17 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295541: Process attributes 'ifunc' and 'alias' when checking 
for redefinition (authored by sepavloff).

Changed prior to commit:
  https://reviews.llvm.org/D30032?vs=88700=89017#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30032

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/alias-redefinition.c
  cfe/trunk/test/Sema/attr-ifunc.c


Index: cfe/trunk/test/Sema/alias-redefinition.c
===
--- cfe/trunk/test/Sema/alias-redefinition.c
+++ cfe/trunk/test/Sema/alias-redefinition.c
@@ -19,9 +19,8 @@
 void fun4(void) __attribute((alias("f4")));
 void fun4(void);
 
-// FIXME: We should produce a special case error for this.
 void f5() {}
-void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition 
of 'fun5'}} // expected-note {{previous definition}}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 
'fun5' cannot also be an alias}}
 
 int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' 
cannot also be an alias}}
 static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 
'var2' cannot also be an alias}}
Index: cfe/trunk/test/Sema/attr-ifunc.c
===
--- cfe/trunk/test/Sema/attr-ifunc.c
+++ cfe/trunk/test/Sema/attr-ifunc.c
@@ -39,5 +39,9 @@
 //expected-error@-1 {{definition with same mangled name as another definition}}
 void* f1_ifunc() { return 0; }
 
+void* f6_ifunc(int i);
+void __attribute__((ifunc("f6_ifunc"))) f6() {}
+//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #endif
 #endif
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -11786,6 +11786,18 @@
   else
 FD = cast(D);
 
+  // Check for defining attributes before the check for redefinition.
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 1;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+
   // See if this is a redefinition.
   if (!FD->isLateTemplateParsed()) {
 CheckForFunctionRedefinition(FD, nullptr, SkipBody);


Index: cfe/trunk/test/Sema/alias-redefinition.c
===
--- cfe/trunk/test/Sema/alias-redefinition.c
+++ cfe/trunk/test/Sema/alias-redefinition.c
@@ -19,9 +19,8 @@
 void fun4(void) __attribute((alias("f4")));
 void fun4(void);
 
-// FIXME: We should produce a special case error for this.
 void f5() {}
-void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 'fun5' cannot also be an alias}}
 
 int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}}
 static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}}
Index: cfe/trunk/test/Sema/attr-ifunc.c
===
--- cfe/trunk/test/Sema/attr-ifunc.c
+++ cfe/trunk/test/Sema/attr-ifunc.c
@@ -39,5 +39,9 @@
 //expected-error@-1 {{definition with same mangled name as another definition}}
 void* f1_ifunc() { return 0; }
 
+void* f6_ifunc(int i);
+void __attribute__((ifunc("f6_ifunc"))) f6() {}
+//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #endif
 #endif
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -11786,6 +11786,18 @@
   else
 FD = cast(D);
 
+  // Check for defining attributes before the check for redefinition.
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 1;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+
   // See if this is a redefinition.
   if (!FD->isLateTemplateParsed()) {
 CheckForFunctionRedefinition(FD, nullptr, SkipBody);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295541 - Process attributes 'ifunc' and 'alias' when checking for redefinition

2017-02-17 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Sat Feb 18 00:04:15 2017
New Revision: 295541

URL: http://llvm.org/viewvc/llvm-project?rev=295541=rev
Log:
Process attributes 'ifunc' and 'alias' when checking for redefinition

These attributes effectively turn a non-defining declaration into a
definition, so the case when the declaration already has a body must
be diagnosed properly.

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/alias-redefinition.c
cfe/trunk/test/Sema/attr-ifunc.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=295541=295540=295541=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Feb 18 00:04:15 2017
@@ -11786,6 +11786,18 @@ Decl *Sema::ActOnStartOfFunctionDef(Scop
   else
 FD = cast(D);
 
+  // Check for defining attributes before the check for redefinition.
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+  if (const auto *Attr = FD->getAttr()) {
+Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 1;
+FD->dropAttr();
+FD->setInvalidDecl();
+  }
+
   // See if this is a redefinition.
   if (!FD->isLateTemplateParsed()) {
 CheckForFunctionRedefinition(FD, nullptr, SkipBody);

Modified: cfe/trunk/test/Sema/alias-redefinition.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-redefinition.c?rev=295541=295540=295541=diff
==
--- cfe/trunk/test/Sema/alias-redefinition.c (original)
+++ cfe/trunk/test/Sema/alias-redefinition.c Sat Feb 18 00:04:15 2017
@@ -19,9 +19,8 @@ void f4() {}
 void fun4(void) __attribute((alias("f4")));
 void fun4(void);
 
-// FIXME: We should produce a special case error for this.
 void f5() {}
-void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition 
of 'fun5'}} // expected-note {{previous definition}}
+void __attribute((alias("f5"))) fun5(void) {} // expected-error {{definition 
'fun5' cannot also be an alias}}
 
 int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' 
cannot also be an alias}}
 static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 
'var2' cannot also be an alias}}

Modified: cfe/trunk/test/Sema/attr-ifunc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ifunc.c?rev=295541=295540=295541=diff
==
--- cfe/trunk/test/Sema/attr-ifunc.c (original)
+++ cfe/trunk/test/Sema/attr-ifunc.c Sat Feb 18 00:04:15 2017
@@ -39,5 +39,9 @@ void f1() __attribute__((ifunc("f1_ifunc
 //expected-error@-1 {{definition with same mangled name as another definition}}
 void* f1_ifunc() { return 0; }
 
+void* f6_ifunc(int i);
+void __attribute__((ifunc("f6_ifunc"))) f6() {}
+//expected-error@-1 {{definition 'f6' cannot also be an ifunc}}
+
 #endif
 #endif


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


[libcxxabi] r295540 - [CMake][libcxxabi] Update the libc++ test module path

2017-02-17 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Feb 17 22:37:59 2017
New Revision: 295540

URL: http://llvm.org/viewvc/llvm-project?rev=295540=rev
Log:
[CMake][libcxxabi] Update the libc++ test module path

The libcxx/test/libcxx Python package has been moved into
libcxx/utils/libcxx in r294651, but libcxxabi's CMakeLists.txt still
looks for the old path.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=295540=295539=295540=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Fri Feb 17 22:37:59 2017
@@ -190,7 +190,7 @@ set(LIBCXXABI_LIBCXX_INCLUDES "${LIBCXXA
 
 find_path(
   LIBCXXABI_LIBCXX_PATH
-  test/libcxx/__init__.py
+  utils/libcxx/test/__init__.py
   PATHS ${LIBCXXABI_LIBCXX_PATH}
 ${LIBCXXABI_LIBCXX_INCLUDES}/../
 ${LIBCXXABI_LIBCXX_SRC_DIRS}


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


[PATCH] D30131: [profiling] Don't skip non-base constructors if there is a virtual base (fixes PR31992)

2017-02-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/CodeGen/CodeGenPGO.cpp:631
+  ((isa(D) && GD.getCtorType() != Ctor_Base &&
+!cast(D)->getParent()->getNumVBases()) ||
(isa(D) && GD.getDtorType() != Dtor_Base))) {

I think it would be more appropriate to use the `IsConstructorDelegationValid` 
static function from `CGClass.cpp` instead of using the `numVBases` check, as 
some virtual inheritance constructors might get delegated in the future (as 
stated in the comments inside of `IsConstructorDelegationValid`).


https://reviews.llvm.org/D30131



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


[PATCH] D30131: [profiling] Don't skip non-base constructors if there is a virtual base (fixes PR31992)

2017-02-17 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

We don't assign profile counters to non-base constructors. That results
in a loss coverage for constructors in classes with virtual bases, which
are complete constructors.

Make an exception for non-base constructors in classes with virtual
bases.

I checked that we get a proper code coverage report for both tests.

@Alex, after I finished drafting this patch I noticed that you recommended 
using IsConstructorDelegationValid(), but imo that predicate seems a little 
hacked-up. Wdyt of starting with the virtual bases case, and then checking if 
there's anything else left?


https://reviews.llvm.org/D30131

Files:
  lib/CodeGen/CodeGenPGO.cpp
  test/Profile/Inputs/cxx-class.proftext
  test/Profile/cxx-class.cpp
  test/Profile/cxx-structors.cpp

Index: test/Profile/cxx-structors.cpp
===
--- test/Profile/cxx-structors.cpp
+++ test/Profile/cxx-structors.cpp
@@ -16,12 +16,22 @@
   ~Bar();
 };
 
+struct Baz : virtual public Foo {
+  Baz() {}
+  Baz(int x) : Foo(x) {}
+  ~Baz();
+};
+
 Foo foo;
 Foo foo2(1);
 Bar bar;
+Baz baz;
+Baz baz2(1);
 
 // Profile data for complete constructors and destructors must absent.
 
+// INSTR: @__profc__ZN3BazC1Ev =
+// INSTR: @__profc__ZN3BazC1Ei =
 // INSTR: @__profc_main =
 // INSTR: @__profc__ZN3FooC2Ev =
 // INSTR: @__profc__ZN3FooD2Ev =
Index: test/Profile/cxx-class.cpp
===
--- test/Profile/cxx-class.cpp
+++ test/Profile/cxx-class.cpp
@@ -5,17 +5,21 @@
 // RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s
 // RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s
+// RUN: FileCheck --input-file=%tgen -check-prefix=VCTRGEN %s
+// RUN: FileCheck --input-file=%tgen -check-prefix=VDTRGEN %s
 
 // RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata
 // RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -triple %itanium_abi_triple > %tuse
 // RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s
 // RUN: FileCheck --input-file=%tuse -check-prefix=WRPUSE %s
+// RUN: FileCheck --input-file=%tuse -check-prefix=VCTRUSE %s
+// RUN: FileCheck --input-file=%tuse -check-prefix=VDTRUSE %s
 
 class Simple {
-  int Member;
 public:
+  int Member;
   // CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
   // CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
   // CTRGEN: store {{.*}} @[[SCC:__profc__ZN6SimpleC2Ei]], i64 0, i64 0
@@ -56,13 +60,43 @@
   // MTHUSE: ![[SM1]] = !{!"branch_weights", i32 100, i32 2}
 };
 
+class Derived : virtual public Simple {
+public:
+  // VCTRGEN-LABEL: define {{.*}} @_ZN7DerivedC1Ev(
+  // VCTRUSE-LABEL: define {{.*}} @_ZN7DerivedC1Ev(
+  // VCTRGEN: store {{.*}} @[[SCC:__profc__ZN7DerivedC1Ev]], i64 0, i64 0
+  Derived() : Simple(0) {
+// VCTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1
+// VCTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]]
+if (Member) {}
+// VCTRGEN-NOT: store {{.*}} @[[SCC]],
+// VCTRUSE-NOT: br {{.*}} !prof ![0-9]+
+// VCTRUSE: ret
+  }
+  // VCTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2}
+
+  // VDTRGEN-LABEL: define {{.*}} @_ZN7DerivedD2Ev(
+  // VDTRUSE-LABEL: define {{.*}} @_ZN7DerivedD2Ev(
+  // VDTRGEN: store {{.*}} @[[SDC:__profc__ZN7DerivedD2Ev]], i64 0, i64 0
+  ~Derived() {
+// VDTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1
+// VDTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]]
+if (Member) {}
+// VDTRGEN-NOT: store {{.*}} @[[SDC]],
+// VDTRUSE-NOT: br {{.*}} !prof ![0-9]+
+// VDTRUSE: ret
+  }
+  // VDTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2}
+};
+
 // WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv(
 // WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv(
 // WRPGEN: store {{.*}} @[[SWC:__profc__Z14simple_wrapperv]], i64 0, i64 0
 void simple_wrapper() {
   // WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1
   // WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]]
   for (int I = 0; I < 100; ++I) {
+Derived d;
 Simple S(I);
 S.method();
   }
Index: test/Profile/Inputs/cxx-class.proftext
===
--- test/Profile/Inputs/cxx-class.proftext
+++ test/Profile/Inputs/cxx-class.proftext
@@ -39,3 +39,14 @@
 100
 99
 
+_ZN7DerivedC1Ev
+10
+2
+100
+99
+
+_ZN7DerivedD2Ev
+10
+2
+100
+99
Index: lib/CodeGen/CodeGenPGO.cpp
===
--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -627,7 +627,8 @@
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants() &&
-  ((isa(D) && GD.getCtorType() != Ctor_Base) ||
+  ((isa(D) && GD.getCtorType() != 

[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-17 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


https://reviews.llvm.org/D30082



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


r295536 - [AVR] Move definition of IsIntegratedAssemblerDefault

2017-02-17 Thread Dylan McKay via cfe-commits
Author: dylanmckay
Date: Fri Feb 17 20:42:36 2017
New Revision: 295536

URL: http://llvm.org/viewvc/llvm-project?rev=295536=rev
Log:
[AVR] Move definition of IsIntegratedAssemblerDefault

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=295536=295535=295536=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Feb 17 20:42:36 2017
@@ -2922,6 +2922,7 @@ bool Generic_GCC::IsIntegratedAssemblerD
   case llvm::Triple::aarch64_be:
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
+  case llvm::Triple::avr:
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
   case llvm::Triple::thumb:

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=295536=295535=295536=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Feb 17 20:42:36 2017
@@ -1377,7 +1377,6 @@ protected:
 public:
   AVRToolChain(const Driver , const llvm::Triple ,
const llvm::opt::ArgList );
-  bool IsIntegratedAssemblerDefault() const override { return true; }
 };
 
 


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


[PATCH] D30118: [XRay] Merge xray clang flag tests, and add powerpc64le.

2017-02-17 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM

Actually, now that you mention this, I don't think there was a good reason to 
do it this way.

Thanks @timshen!


https://reviews.llvm.org/D30118



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


r295533 - Part of adding an improved ODR checker.

2017-02-17 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 17 20:09:28 2017
New Revision: 295533

URL: http://llvm.org/viewvc/llvm-project?rev=295533=rev
Log:
Part of adding an improved ODR checker.

Reserve a spot for ODR hash in CXXRecordDecl and in its modules storage.
Default the hash value to 0 for all classes.

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

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=295533=295532=295533=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Feb 17 20:09:28 2017
@@ -458,6 +458,9 @@ class CXXRecordDecl : public RecordDecl
 /// \brief Whether we are currently parsing base specifiers.
 unsigned IsParsingBaseSpecifiers : 1;
 
+/// \brief A hash of parts of the class to help in ODR checking.
+unsigned ODRHash;
+
 /// \brief The number of base class specifiers in Bases.
 unsigned NumBases;
 
@@ -703,6 +706,9 @@ public:
 return data().IsParsingBaseSpecifiers;
   }
 
+  void computeODRHash();
+  unsigned getODRHash() const { return data().ODRHash; }
+
   /// \brief Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
 

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=295533=295532=295533=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Feb 17 20:09:28 2017
@@ -71,8 +71,8 @@ CXXRecordDecl::DefinitionData::Definitio
   ImplicitCopyAssignmentHasConstParam(true),
   HasDeclaredCopyConstructorWithConstParam(false),
   HasDeclaredCopyAssignmentWithConstParam(false), IsLambda(false),
-  IsParsingBaseSpecifiers(false), NumBases(0), NumVBases(0), Bases(),
-  VBases(), Definition(D), FirstFriend() {}
+  IsParsingBaseSpecifiers(false), ODRHash(0), NumBases(0), NumVBases(0),
+  Bases(), VBases(), Definition(D), FirstFriend() {}
 
 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const {
   return Bases.get(Definition->getASTContext().getExternalSource());
@@ -371,6 +371,8 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
   data().IsParsingBaseSpecifiers = false;
 }
 
+void CXXRecordDecl::computeODRHash() {}
+
 void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) {
   // C++11 [class.copy]p11:
   //   A defaulted copy/move constructor for a class X is defined as

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=295533=295532=295533=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 17 20:09:28 2017
@@ -13771,8 +13771,11 @@ void Sema::ActOnTagFinishDefinition(Scop
   RD->completeDefinition();
   }
 
-  if (isa(Tag))
+  if (auto *RD = dyn_cast(Tag)) {
 FieldCollector->FinishClass();
+if (Context.getLangOpts().Modules)
+  RD->computeODRHash();
+  }
 
   // Exit this scope of this tag's definition.
   PopDeclContext();

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=295533=295532=295533=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Feb 17 20:09:28 2017
@@ -1528,6 +1528,7 @@ void ASTDeclReader::ReadCXXDefinitionDat
   Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
   Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
   Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
+  Data.ODRHash = Record.readInt();
 
   Data.NumBases = Record.readInt();
   if (Data.NumBases)
@@ -1658,6 +1659,7 @@ void ASTDeclReader::MergeDefinitionData(
   OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
   OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
   MATCH_FIELD(IsLambda)
+  MATCH_FIELD(ODRHash)
 #undef OR_FIELD
 #undef MATCH_FIELD
 

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=295533=295532=295533=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Fri Feb 17 20:09:28 2017
@@ -5707,6 +5707,7 @@ void ASTRecordWriter::AddCXXDefinitionDa
   

r295532 - [profiling] Make a test more explicit. NFC.

2017-02-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 17 20:02:55 2017
New Revision: 295532

URL: http://llvm.org/viewvc/llvm-project?rev=295532=rev
Log:
[profiling] Make a test more explicit. NFC.

The cxx-structors.cpp test checks that some instrumentation doesn't
appear, but it should be more explicit about which instrumentation it
actually expects to appear.

Modified:
cfe/trunk/test/Profile/cxx-structors.cpp

Modified: cfe/trunk/test/Profile/cxx-structors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-structors.cpp?rev=295532=295531=295532=diff
==
--- cfe/trunk/test/Profile/cxx-structors.cpp (original)
+++ cfe/trunk/test/Profile/cxx-structors.cpp Fri Feb 17 20:02:55 2017
@@ -1,6 +1,8 @@
 // Tests for instrumentation of C++ constructors and destructors.
 //
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o - 
-emit-llvm -fprofile-instrument=clang | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o %t 
-emit-llvm -fprofile-instrument=clang
+// RUN: FileCheck %s -input-file=%t -check-prefix=INSTR
+// RUN: FileCheck %s -input-file=%t -check-prefix=NOINSTR
 
 struct Foo {
   Foo() {}
@@ -20,12 +22,18 @@ Bar bar;
 
 // Profile data for complete constructors and destructors must absent.
 
-// CHECK-NOT: @__profc__ZN3FooC1Ev
-// CHECK-NOT: @__profc__ZN3FooC1Ei
-// CHECK-NOT: @__profc__ZN3FooD1Ev
-// CHECK-NOT: @__profc__ZN3BarC1Ev
-// CHECK-NOT: @__profc__ZN3BarD1Ev
-// CHECK-NOT: @__profc__ZN3FooD1Ev
+// INSTR: @__profc_main =
+// INSTR: @__profc__ZN3FooC2Ev =
+// INSTR: @__profc__ZN3FooD2Ev =
+// INSTR: @__profc__ZN3FooC2Ei =
+// INSTR: @__profc__ZN3BarC2Ev =
+
+// NOINSTR-NOT: @__profc__ZN3FooC1Ev
+// NOINSTR-NOT: @__profc__ZN3FooC1Ei
+// NOINSTR-NOT: @__profc__ZN3FooD1Ev
+// NOINSTR-NOT: @__profc__ZN3BarC1Ev
+// NOINSTR-NOT: @__profc__ZN3BarD1Ev
+// NOINSTR-NOT: @__profc__ZN3FooD1Ev
 
 int main() {
 }


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


Re: r276514 - [cxx1z-constexpr-lambda] Make a lambda's closure type eligible as a literal-type in C++1z

2017-02-17 Thread Richard Smith via cfe-commits
On 22 July 2016 at 21:05, Faisal Vali via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: faisalv
> Date: Fri Jul 22 23:05:19 2016
> New Revision: 276514
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276514=rev
> Log:
> [cxx1z-constexpr-lambda] Make a lambda's closure type eligible as a
> literal-type in C++1z
>
>
> Additionally, for pre-C++1z, instead of forbidding a lambda's closure type
> from being a literal type through circumlocutorily setting
> HasNonLiteralTypeFieldsOrBases falsely to true -- handle lambda's more
> directly in CXXRecordDecl::isLiteral().
>
> One additional small step towards implementing constexpr-lambdas.
>

I don't know if this problem started with this change, but we now accept
this invalid code in C++14 mode:

constexpr auto a = [] {};


> Thanks to Richard Smith for his review!
> https://reviews.llvm.org/D22662
>
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=276514=276513=276514=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Jul 22 23:05:19 2016
> @@ -535,11 +535,10 @@ class CXXRecordDecl : public RecordDecl
>  MethodTyInfo(Info) {
>IsLambda = true;
>
> -  // C++11 [expr.prim.lambda]p3:
> -  //   This class type is neither an aggregate nor a literal type.
> +  // C++1z [expr.prim.lambda]p4:
> +  //   This class type is not an aggregate type.
>Aggregate = false;
>PlainOldData = false;
> -  HasNonLiteralTypeFieldsOrBases = true;
>  }
>
>  /// \brief Whether this lambda is known to be dependent, even if its
> @@ -1338,11 +1337,15 @@ public:
>///
>/// We resolve DR1361 by ignoring the second bullet. We resolve DR1452
> by
>/// treating types with trivial default constructors as literal types.
> +  ///
> +  /// Only in C++1z and beyond, are lambdas literal types.
>bool isLiteral() const {
>  return hasTrivialDestructor() &&
> -   (isAggregate() || hasConstexprNonCopyMoveConstructor() ||
> -hasTrivialDefaultConstructor()) &&
> -   !hasNonLiteralTypeFieldsOrBases();
> +   (!isLambda() || getASTContext().getLangOpts().CPlusPlus1z) &&
> +   !hasNonLiteralTypeFieldsOrBases() &&
> +   (isAggregate() || isLambda() ||
> +hasConstexprNonCopyMoveConstructor() ||
> +hasTrivialDefaultConstructor());
>}
>
>/// \brief If this record is an instantiation of a member class,
>
> Modified: cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaCXX/cxx1z-constexpr-lambdas.cpp?rev=276514=
> 276513=276514=diff
> 
> ==
> --- cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp (original)
> +++ cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Fri Jul 22
> 23:05:19 2016
> @@ -1,8 +1,8 @@
>  // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks %s
>  // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks
> -fdelayed-template-parsing %s
> -// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks
> -fms-extensions %s
> -// RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks
> -fdelayed-template-parsing -fms-extensions %s
> +// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -fblocks %s
> -DCPP14_AND_EARLIER
>
> +#ifndef CPP14_AND_EARLIER
>  namespace test_constexpr_checking {
>
>  namespace ns1 {
> @@ -33,4 +33,16 @@ namespace ns3 {
>L(3); //expected-note{{non-constexpr function}}
>  }
>
> -} // end ns test_constexpr_call
> \ No newline at end of file
> +} // end ns test_constexpr_call
> +
> +#endif
> +
> +namespace test_lambda_is_literal {
> +#ifdef CPP14_AND_EARLIER
> +//expected-error@+4{{not a literal type}}
> +//expected-note@+2{{not an aggregate and has no constexpr constructors}}
> +#endif
> +auto L = [] { };
> +constexpr int foo(decltype(L) l) { return 0; }
> +
> +}
> \ No newline at end of file
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295527 - Reuse a local variable. NFC.

2017-02-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 17 19:50:11 2017
New Revision: 295527

URL: http://llvm.org/viewvc/llvm-project?rev=295527=rev
Log:
Reuse a local variable. NFC.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=295527=295526=295527=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Fri Feb 17 19:50:11 2017
@@ -627,11 +627,9 @@ void CodeGenPGO::assignRegionCounters(Gl
   // If so, instrument only base variant, others are implemented by delegation
   // to the base one, it would be counted twice otherwise.
   if (CGM.getTarget().getCXXABI().hasConstructorVariants() &&
-  ((isa(GD.getDecl()) &&
-GD.getCtorType() != Ctor_Base) ||
-   (isa(GD.getDecl()) &&
-GD.getDtorType() != Dtor_Base))) {
-  return;
+  ((isa(D) && GD.getCtorType() != Ctor_Base) ||
+   (isa(D) && GD.getDtorType() != Dtor_Base))) {
+return;
   }
   CGM.ClearUnusedCoverageMapping(D);
   setFuncName(Fn);


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


r295528 - [profiling] Tighten test cases which refer to "profn" vars. NFC.

2017-02-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 17 19:50:14 2017
New Revision: 295528

URL: http://llvm.org/viewvc/llvm-project?rev=295528=rev
Log:
[profiling] Tighten test cases which refer to "profn" vars. NFC.

The frontend can't see "__profn" profile name variables after IRGen
because llvm throws these away now. Tighten up some test cases which
checked for the non-existence of those variables.

Modified:
cfe/trunk/test/Profile/c-generate.c
cfe/trunk/test/Profile/cxx-structors.cpp

Modified: cfe/trunk/test/Profile/c-generate.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/c-generate.c?rev=295528=295527=295528=diff
==
--- cfe/trunk/test/Profile/c-generate.c (original)
+++ cfe/trunk/test/Profile/c-generate.c Fri Feb 17 19:50:14 2017
@@ -5,7 +5,8 @@
 //
 // PROF-INSTR-PATH: constant [24 x i8] c"c-generate-test.profraw\00"
 //
-// PROF-INSTR-NONE-NOT: @__profn_main
+// PROF-INSTR-NONE-NOT: __llvm_prf
+//
 // PROF-INSTR-GARBAGE: invalid PGO instrumentor in argument 
'-fprofile-instrument=garbage'
 
 int main(void) {

Modified: cfe/trunk/test/Profile/cxx-structors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Profile/cxx-structors.cpp?rev=295528=295527=295528=diff
==
--- cfe/trunk/test/Profile/cxx-structors.cpp (original)
+++ cfe/trunk/test/Profile/cxx-structors.cpp Fri Feb 17 19:50:14 2017
@@ -20,13 +20,12 @@ Bar bar;
 
 // Profile data for complete constructors and destructors must absent.
 
-// CHECK-NOT: @__profn__ZN3FooC1Ev
-// CHECK-NOT: @__profn__ZN3FooC1Ei
-// CHECK-NOT: @__profn__ZN3FooD1Ev
-// CHECK-NOT: @__profn__ZN3BarC1Ev
-// CHECK-NOT: @__profn__ZN3BarD1Ev
+// CHECK-NOT: @__profc__ZN3FooC1Ev
+// CHECK-NOT: @__profc__ZN3FooC1Ei
+// CHECK-NOT: @__profc__ZN3FooD1Ev
+// CHECK-NOT: @__profc__ZN3BarC1Ev
+// CHECK-NOT: @__profc__ZN3BarD1Ev
 // CHECK-NOT: @__profc__ZN3FooD1Ev
-// CHECK-NOT: @__profd__ZN3FooD1Ev
 
 int main() {
 }


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


[PATCH] D21675: New ODR checker for modules

2017-02-17 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

This patch will be landing in small chunks to hopefully avoid the large reverts.


Repository:
  rL LLVM

https://reviews.llvm.org/D21675



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


[PATCH] D29303: In VirtualCallChecker, handle indirect calls

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

Has this been cherry-picked into the clang 4.0 release branch? If not, we 
should definitely do that!


Repository:
  rL LLVM

https://reviews.llvm.org/D29303



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


[PATCH] D29643: [analyzer] Do not duplicate call graph nodes for function that has definition and forward declaration.

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

Looks good. Thank you for catching this!

Do you have commit access or should I commit on your behalf?


https://reviews.llvm.org/D29643



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


r295524 - Cleanup: use range-based for rather than separate calls to begin and end.

2017-02-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 17 19:14:43 2017
New Revision: 295524

URL: http://llvm.org/viewvc/llvm-project?rev=295524=rev
Log:
Cleanup: use range-based for rather than separate calls to begin and end.

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=295524=295523=295524=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Feb 17 19:14:43 2017
@@ -1456,16 +1456,15 @@ void Driver::BuildInputs(const ToolChain
 ? types::TY_C
 : types::TY_CXX;
 
-arg_iterator it =
-Args.filtered_begin(options::OPT__SLASH_TC, options::OPT__SLASH_TP);
-const arg_iterator ie = Args.filtered_end();
-Arg *Previous = *it++;
+Arg *Previous = nullptr;
 bool ShowNote = false;
-while (it != ie) {
-  Diag(clang::diag::warn_drv_overriding_flag_option)
-  << Previous->getSpelling() << (*it)->getSpelling();
-  Previous = *it++;
-  ShowNote = true;
+for (Arg *A : Args.filtered(options::OPT__SLASH_TC, 
options::OPT__SLASH_TP)) {
+  if (Previous) {
+Diag(clang::diag::warn_drv_overriding_flag_option)
+  << Previous->getSpelling() << A->getSpelling();
+ShowNote = true;
+  }
+  Previous = A;
 }
 if (ShowNote)
   Diag(clang::diag::note_drv_t_option_is_global);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=295524=295523=295524=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Fri Feb 17 19:14:43 2017
@@ -212,13 +212,11 @@ bool AssemblerInvocation::CreateFromArgs
   // Frontend Options
   if (Args.hasArg(OPT_INPUT)) {
 bool First = true;
-for (arg_iterator it = Args.filtered_begin(OPT_INPUT),
-  ie = Args.filtered_end();
- it != ie; ++it, First = false) {
-  const Arg *A = it;
-  if (First)
+for (const Arg *A : Args.filtered(OPT_INPUT)) {
+  if (First) {
 Opts.InputFile = A->getValue();
-  else {
+First = false;
+  } else {
 Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args);
 Success = false;
   }


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


Re: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via cfe-commits
What's strange is that I copied this pattern from
clang-tidy-run-with-database.cpp, and I'm not sure why it would work there
and not here..

On Fri, Feb 17, 2017 at 8:16 PM, Ehsan Akhgari 
wrote:

> Hi Douglas,
>
> Sorry about this.  It seems to me that the reason for this test failure is
> the slashes that appear in the -path argument in the log:
>
> "-path" 
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\clang-tidy\Output/compilation-database-test"
> $ "FileCheck" "-check-prefix=CHECK" 
> "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
>
> However I'm not sure how to fix this.  I'm using slashes as the path 
> separator in the test RUN command.  Is there a safer platform independent 
> token I should use instead?
>
>
> On Fri, Feb 17, 2017 at 3:57 PM, Yung, Douglas 
> wrote:
>
>> Hi Ehsan,
>>
>> Your commit has caused the PS4 Windows bot to go red. Can you take a look?
>>
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-windows10pro-fast/builds/5661
>>
>> $ "FileCheck" "-check-prefix=CHECK" "C:\Buildbot\Slave\llvm-clang-
>> lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\
>> tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
>> # command stderr:
>> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pr
>> o-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp:17:11:
>> error: expected string not found in input
>>
>> // CHECK: [[@LINE-2]]:8: warning: annotate this
>>
>>   ^
>>
>> :1:1: note: scanning from here
>>
>> YAML:1:1: error: Unrecognized escape code!
>>
>> ^
>>
>> :1:1: note: with expression "@LINE-2" equal to "15"
>>
>> YAML:1:1: error: Unrecognized escape code!
>>
>> ^
>>
>> :1:7: note: possible intended match here
>>
>> YAML:1:1: error: Unrecognized escape code!
>>
>>   ^
>>
>>
>> error: command failed with exit status: 1
>>
>> Douglas Yung
>>
>> > -Original Message-
>> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On
>> Behalf Of
>> > Ehsan Akhgari via cfe-commits
>> > Sent: Friday, February 17, 2017 11:32
>> > To: cfe-commits@lists.llvm.org
>> > Subject: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to
>> clang-
>> > tidy-diff.py
>> >
>> > Author: ehsan
>> > Date: Fri Feb 17 13:31:43 2017
>> > New Revision: 295482
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
>> > Log:
>> > [clang-tidy] Add -path option to clang-tidy-diff.py
>> >
>> > Summary:
>> > This flag allows specifying a custom path for the compilation database.
>> > Unfortunately we can't use the -p flag like other clang-tidy tools
>> because
>> > it's already taken.
>> >
>> > Reviewers: alexfh
>> >
>> > Subscribers: JDevlieghere, cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D29806
>> >
>> > Modified:
>> > clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
>> >
>> > Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
>> > tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
>> > 
>> ==
>> > --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>> (original)
>> > +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb
>> > +++ 17 13:31:43 2017
>> > @@ -55,6 +55,8 @@ def main():
>> >help='checks filter, when not specified, use
>> clang-tidy
>> > '
>> >'default',
>> >default='')
>> > +  parser.add_argument('-path', dest='build_path',
>> > +  help='Path used to read a compile command
>> > + database.')
>> >parser.add_argument('-extra-arg', dest='extra_arg',
>> >action='append', default=[],
>> >help='Additional argument to append to the
>> compiler '
>> > @@ -124,6 +126,8 @@ def main():
>> >  command.append('-checks=' + quote + args.checks + quote)
>> >if args.quiet:
>> >  command.append('-quiet')
>> > +  if args.build_path is not None:
>> > +command.append('-p=%s' % args.build_path)
>> >command.extend(lines_by_file.keys())
>> >for arg in args.extra_arg:
>> >command.append('-extra-arg=%s' % arg)
>> >
>> > Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
>> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> test/clang-
>> > tidy/clang-tidy-diff.cpp?rev=295482=295481=295482=diff
>> > 
>> ==
>> > --- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
>> (original)
>> > +++ 

Re: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via cfe-commits
Hi Douglas,

Sorry about this.  It seems to me that the reason for this test failure is
the slashes that appear in the -path argument in the log:

"-path" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\clang\tools\extra\test\clang-tidy\Output/compilation-database-test"
$ "FileCheck" "-check-prefix=CHECK"
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"

However I'm not sure how to fix this.  I'm using slashes as the path
separator in the test RUN command.  Is there a safer platform
independent token I should use instead?


On Fri, Feb 17, 2017 at 3:57 PM, Yung, Douglas 
wrote:

> Hi Ehsan,
>
> Your commit has caused the PS4 Windows bot to go red. Can you take a look?
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_
> 64-scei-ps4-windows10pro-fast/builds/5661
>
> $ "FileCheck" "-check-prefix=CHECK" "C:\Buildbot\Slave\llvm-clang-
> lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\
> tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
> # command stderr:
> C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-
> windows10pro-fast\llvm.src\tools\clang\tools\extra\test\
> clang-tidy\clang-tidy-diff.cpp:17:11: error: expected string not found in
> input
>
> // CHECK: [[@LINE-2]]:8: warning: annotate this
>
>   ^
>
> :1:1: note: scanning from here
>
> YAML:1:1: error: Unrecognized escape code!
>
> ^
>
> :1:1: note: with expression "@LINE-2" equal to "15"
>
> YAML:1:1: error: Unrecognized escape code!
>
> ^
>
> :1:7: note: possible intended match here
>
> YAML:1:1: error: Unrecognized escape code!
>
>   ^
>
>
> error: command failed with exit status: 1
>
> Douglas Yung
>
> > -Original Message-
> > From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf
> Of
> > Ehsan Akhgari via cfe-commits
> > Sent: Friday, February 17, 2017 11:32
> > To: cfe-commits@lists.llvm.org
> > Subject: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to
> clang-
> > tidy-diff.py
> >
> > Author: ehsan
> > Date: Fri Feb 17 13:31:43 2017
> > New Revision: 295482
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
> > Log:
> > [clang-tidy] Add -path option to clang-tidy-diff.py
> >
> > Summary:
> > This flag allows specifying a custom path for the compilation database.
> > Unfortunately we can't use the -p flag like other clang-tidy tools
> because
> > it's already taken.
> >
> > Reviewers: alexfh
> >
> > Subscribers: JDevlieghere, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D29806
> >
> > Modified:
> > clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> > clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> >
> > Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
> > tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> (original)
> > +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb
> > +++ 17 13:31:43 2017
> > @@ -55,6 +55,8 @@ def main():
> >help='checks filter, when not specified, use
> clang-tidy
> > '
> >'default',
> >default='')
> > +  parser.add_argument('-path', dest='build_path',
> > +  help='Path used to read a compile command
> > + database.')
> >parser.add_argument('-extra-arg', dest='extra_arg',
> >action='append', default=[],
> >help='Additional argument to append to the
> compiler '
> > @@ -124,6 +126,8 @@ def main():
> >  command.append('-checks=' + quote + args.checks + quote)
> >if args.quiet:
> >  command.append('-quiet')
> > +  if args.build_path is not None:
> > +command.append('-p=%s' % args.build_path)
> >command.extend(lines_by_file.keys())
> >for arg in args.extra_arg:
> >command.append('-extra-arg=%s' % arg)
> >
> > Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-
> > tidy/clang-tidy-diff.cpp?rev=295482=295481=295482=diff
> > 
> ==
> > --- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> (original)
> > +++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp Fri Feb
> > +++ 17 13:31:43 2017
> > @@ -2,6 +2,9 @@
> >  // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp --
> -std=c++11 |
> > FileCheck -check-prefix=CHECK-SANITY %s  // RUN: not diff -U0 %s %t.cpp |
> > %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 |
> > FileCheck %s  // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 

r295521 - Handle deduction guides better in -ast-print.

2017-02-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 17 19:01:48 2017
New Revision: 295521

URL: http://llvm.org/viewvc/llvm-project?rev=295521=rev
Log:
Handle deduction guides better in -ast-print.

Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/test/Misc/ast-dump-templates.cpp

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=295521=295520=295521=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Fri Feb 17 19:01:48 2017
@@ -481,6 +481,7 @@ void DeclPrinter::VisitFunctionDecl(Func
 
   CXXConstructorDecl *CDecl = dyn_cast(D);
   CXXConversionDecl *ConversionDecl = dyn_cast(D);
+  CXXDeductionGuideDecl *GuideDecl = dyn_cast(D);
   if (!Policy.SuppressSpecifiers) {
 switch (D->getStorageClass()) {
 case SC_None: break;
@@ -496,13 +497,16 @@ void DeclPrinter::VisitFunctionDecl(Func
 if (D->isModulePrivate())Out << "__module_private__ ";
 if (D->isConstexpr() && !D->isExplicitlyDefaulted()) Out << "constexpr ";
 if ((CDecl && CDecl->isExplicitSpecified()) ||
-(ConversionDecl && ConversionDecl->isExplicit()))
+(ConversionDecl && ConversionDecl->isExplicitSpecified()) ||
+(GuideDecl && GuideDecl->isExplicitSpecified()))
   Out << "explicit ";
   }
 
   PrintingPolicy SubPolicy(Policy);
   SubPolicy.SuppressSpecifiers = false;
   std::string Proto = D->getNameInfo().getAsString();
+  if (GuideDecl)
+Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
   if (const TemplateArgumentList *TArgs = D->getTemplateSpecializationArgs()) {
 llvm::raw_string_ostream POut(Proto);
 DeclPrinter TArgPrinter(POut, SubPolicy, Indentation);
@@ -652,7 +656,9 @@ void DeclPrinter::VisitFunctionDecl(Func
   }
 } else if (!ConversionDecl && !isa(D)) {
   if (FT && FT->hasTrailingReturn()) {
-Out << "auto " << Proto << " -> ";
+if (!GuideDecl)
+  Out << "auto ";
+Out << Proto << " -> ";
 Proto.clear();
   }
   AFT->getReturnType().print(Out, Policy, Proto);
@@ -1044,7 +1050,10 @@ void DeclPrinter::VisitFunctionTemplateD
   prettyPrintPragmas(D->getTemplatedDecl());
   VisitRedeclarableTemplateDecl(D);
 
-  if (PrintInstantiation) {
+  // Never print "instantiations" for deduction guides (they don't really
+  // have them).
+  if (PrintInstantiation &&
+  !isa(D->getTemplatedDecl())) {
 FunctionDecl *PrevDecl = D->getTemplatedDecl();
 const FunctionDecl *Def;
 if (PrevDecl->isDefined(Def) && Def != PrevDecl)

Modified: cfe/trunk/test/Misc/ast-dump-templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-templates.cpp?rev=295521=295520=295521=diff
==
--- cfe/trunk/test/Misc/ast-dump-templates.cpp (original)
+++ cfe/trunk/test/Misc/ast-dump-templates.cpp Fri Feb 17 19:01:48 2017
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -ast-print %s > %t
+// RUN: %clang_cc1 -std=c++1z -ast-print %s > %t
 // RUN: FileCheck < %t %s -check-prefix=CHECK1
 // RUN: FileCheck < %t %s -check-prefix=CHECK2
-// RUN: %clang_cc1 -ast-dump %s | FileCheck --check-prefix=DUMP %s
+// RUN: %clang_cc1 -std=c++1z -ast-dump %s | FileCheck --check-prefix=DUMP %s
 
 template 
 struct foo {
@@ -61,3 +61,9 @@ void tmpl() {
 
 // DUMP: UnresolvedLookupExpr {{.*}}  '' 
lvalue (ADL) = 'func'
 }
+
+namespace test3 {
+  template struct A {};
+  template A(T) -> A;
+  // CHECK1: template  A(T) -> A;
+}


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


[PATCH] D28348: [analyzer] Taught the analyzer about Glib API to check Memory-leak

2017-02-17 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:885
+return;
+  State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State);
+  State = ProcessZeroAllocation(C, CE, 0, State);

I am not sure this is correct as the third argument is "size of allocation", 
which in this case would be the value of CE->getArg(0) times the value of 
CE->getArg(2).

The current implementation of MallocMemAux would need to be extended to 
incorporate this:
`  // Set the region's extent equal to the Size parameter.
  const SymbolicRegion *R =
  dyn_cast_or_null(RetVal.getAsRegion());
  if (!R)
return nullptr;
  if (Optional DefinedSize =
  Size.getAs()) {
SValBuilder  = C.getSValBuilder();
DefinedOrUnknownSVal Extent = R->getExtent(svalBuilder);
DefinedOrUnknownSVal extentMatchesSize =
svalBuilder.evalEQ(State, Extent, *DefinedSize);

State = State->assume(extentMatchesSize, true);
assert(State);
  }`

My suggestion is to submit the patch without the 'n' variants and extend 
MallocMemAux to deal with them as a follow up patch.



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:889
+} else if (FunI == II_g_realloc_n || FunI == II_g_try_realloc_n) {
+  if (CE->getNumArgs() < 2)
+return;

Should this be 'getNumArgs() < 3' ?



Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:891
+return;
+  State = ReallocMem(C, CE, false, State);
+  State = ProcessZeroAllocation(C, CE, 1, State);

Unfortunately, ReallocMem also assumes a single size argument:

`  // Get the size argument. If there is no size arg then give up.
  const Expr *Arg1 = CE->getArg(1);
  if (!Arg1)
return nullptr;`


Repository:
  rL LLVM

https://reviews.llvm.org/D28348



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


r295517 - [modules] Load the ModuleOffsetMap from the module header lazily.

2017-02-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 17 18:32:02 2017
New Revision: 295517

URL: http://llvm.org/viewvc/llvm-project?rev=295517=rev
Log:
[modules] Load the ModuleOffsetMap from the module header lazily.

If we never need to map any ID within the module to its global ID, we don't
need the module offset map. If a compilation transitively depends on lots of
unused module files, this can result in a modest performance improvement.

Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/include/clang/Serialization/ModuleManager.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=295517=295516=295517=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Feb 17 18:32:02 2017
@@ -1188,6 +1188,7 @@ private:
   std::string , bool ValidateDiagnosticOptions);
   ASTReadResult ReadASTBlock(ModuleFile , unsigned ClientLoadCapabilities);
   ASTReadResult ReadExtensionBlock(ModuleFile );
+  void ReadModuleOffsetMap(ModuleFile ) const;
   bool ParseLineTable(ModuleFile , const RecordData );
   bool ReadSourceManagerBlock(ModuleFile );
   llvm::BitstreamCursor (int ID);
@@ -1322,9 +1323,9 @@ private:
   ///
   /// This routine should only be used for fatal errors that have to
   /// do with non-routine failures (e.g., corrupted AST file).
-  void Error(StringRef Msg);
+  void Error(StringRef Msg) const;
   void Error(unsigned DiagID, StringRef Arg1 = StringRef(),
- StringRef Arg2 = StringRef());
+ StringRef Arg2 = StringRef()) const;
 
   ASTReader(const ASTReader &) = delete;
   void operator=(const ASTReader &) = delete;
@@ -1905,10 +1906,10 @@ public:
SmallVectorImpl *Decls = nullptr);
 
   /// \brief Report a diagnostic.
-  DiagnosticBuilder Diag(unsigned DiagID);
+  DiagnosticBuilder Diag(unsigned DiagID) const;
 
   /// \brief Report a diagnostic.
-  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
+  DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const;
 
   IdentifierInfo *DecodeIdentifierInfo(serialization::IdentifierID ID);
 
@@ -2060,6 +2061,8 @@ public:
   /// location space into ours.
   SourceLocation TranslateSourceLocation(ModuleFile ,
  SourceLocation Loc) const {
+if (!ModuleFile.ModuleOffsetMap.empty())
+  ReadModuleOffsetMap(ModuleFile);
 assert(ModuleFile.SLocRemap.find(Loc.getOffset()) !=
ModuleFile.SLocRemap.end() &&
"Cannot find offset to remap.");

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=295517=295516=295517=diff
==
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Fri Feb 17 18:32:02 2017
@@ -201,6 +201,10 @@ public:
   /// file.
   std::vector ExtensionReaders;
 
+  /// The module offset map data for this file. If non-empty, the various
+  /// ContinuousRangeMaps described below have not yet been populated.
+  StringRef ModuleOffsetMap;
+
   // === Input Files ===
   /// \brief The cursor to the start of the input-files block.
   llvm::BitstreamCursor InputFilesCursor;

Modified: cfe/trunk/include/clang/Serialization/ModuleManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ModuleManager.h?rev=295517=295516=295517=diff
==
--- cfe/trunk/include/clang/Serialization/ModuleManager.h (original)
+++ cfe/trunk/include/clang/Serialization/ModuleManager.h Fri Feb 17 18:32:02 
2017
@@ -160,10 +160,10 @@ public:
   ModuleFile [](unsigned Index) const { return *Chain[Index]; }
   
   /// \brief Returns the module associated with the given name
-  ModuleFile *lookup(StringRef Name);
+  ModuleFile *lookup(StringRef Name) const;
 
   /// \brief Returns the module associated with the given module file.
-  ModuleFile *lookup(const FileEntry *File);
+  ModuleFile *lookup(const FileEntry *File) const;
 
   /// \brief Returns the in-memory (virtual file) buffer with the given name
   std::unique_ptr lookupBuffer(StringRef Name);

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=295517=295516=295517=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ 

[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-17 Thread David Herzka via Phabricator via cfe-commits
herzka added a comment.

@compnerd, yes please. I don't have commit access. Thanks for the review!


https://reviews.llvm.org/D29967



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


[PATCH] D29944: libclang: Print namespaces for typedefs and type aliases

2017-02-17 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/Misc/diag-template-diffing.cpp:27
 // CHECK-ELIDE-NOTREE: no matching function for call to 'f'
-// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 
'vector' to 'vector' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 
'vector' to 'vector' for 1st argument
 // CHECK-NOELIDE-NOTREE: no matching function for call to 'f'

I think the majority of test changes make sense, we are just adding qualifiers 
to the typedefs in the diagnostics. I'm curious about this one though, as we 
are essentially replacing the old diagnostic note `no known conversion from 
'vector' to 'vector' for 1st argument` by the 
new note `no known conversion from 'vector' to 'vector' 
for 1st argument`. Is one better than the other? It seems that GCC prefers the 
former, while ICC the latter. Does it even matter which one we have?


https://reviews.llvm.org/D29944



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


[PATCH] D29772: Create msbuild only when using MSVC

2017-02-17 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

Commit it please when you aren't busy.
Thanks in advance.


https://reviews.llvm.org/D29772



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


[PATCH] D29772: Create msbuild only when using MSVC

2017-02-17 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D29772



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


r295514 - [ubsan] Pass a set of checks to skip to EmitTypeCheck() (NFC)

2017-02-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 17 17:22:55 2017
New Revision: 295514

URL: http://llvm.org/viewvc/llvm-project?rev=295514=rev
Log:
[ubsan] Pass a set of checks to skip to EmitTypeCheck() (NFC)

CodeGenFunction::EmitTypeCheck accepts a bool flag which controls
whether or not null checks are emitted. Make this a bit more flexible by
changing the bool to a SanitizerSet.

Needed for an upcoming change which deals with a scenario in which we
only want to emit null checks.

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=295514=295513=295514=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Feb 17 17:22:55 2017
@@ -309,8 +309,10 @@ Address CodeGenFunction::GetAddressOfBas
   // just do a bitcast; null checks are unnecessary.
   if (NonVirtualOffset.isZero() && !VBase) {
 if (sanitizePerformTypeCheck()) {
+  SanitizerSet SkippedChecks;
+  SkippedChecks.set(SanitizerKind::Null, !NullCheckValue);
   EmitTypeCheck(TCK_Upcast, Loc, Value.getPointer(),
-DerivedTy, DerivedAlign, !NullCheckValue);
+DerivedTy, DerivedAlign, SkippedChecks);
 }
 return Builder.CreateBitCast(Value, BasePtrTy);
   }
@@ -331,8 +333,10 @@ Address CodeGenFunction::GetAddressOfBas
   }
 
   if (sanitizePerformTypeCheck()) {
+SanitizerSet SkippedChecks;
+SkippedChecks.set(SanitizerKind::Null, true);
 EmitTypeCheck(VBase ? TCK_UpcastToVirtualBase : TCK_Upcast, Loc,
-  Value.getPointer(), DerivedTy, DerivedAlign, true);
+  Value.getPointer(), DerivedTy, DerivedAlign, SkippedChecks);
   }
 
   // Compute the virtual offset.

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=295514=295513=295514=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Feb 17 17:22:55 2017
@@ -534,7 +534,8 @@ bool CodeGenFunction::sanitizePerformTyp
 
 void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc,
 llvm::Value *Ptr, QualType Ty,
-CharUnits Alignment, bool SkipNullCheck) {
+CharUnits Alignment,
+SanitizerSet SkippedChecks) {
   if (!sanitizePerformTypeCheck())
 return;
 
@@ -552,7 +553,7 @@ void CodeGenFunction::EmitTypeCheck(Type
   bool AllowNullPointers = TCK == TCK_DowncastPointer || TCK == TCK_Upcast ||
TCK == TCK_UpcastToVirtualBase;
   if ((SanOpts.has(SanitizerKind::Null) || AllowNullPointers) &&
-  !SkipNullCheck) {
+  !SkippedChecks.has(SanitizerKind::Null)) {
 // The glvalue must not be an empty glvalue.
 llvm::Value *IsNonNull = Builder.CreateIsNotNull(Ptr);
 
@@ -568,7 +569,9 @@ void CodeGenFunction::EmitTypeCheck(Type
 }
   }
 
-  if (SanOpts.has(SanitizerKind::ObjectSize) && !Ty->isIncompleteType()) {
+  if (SanOpts.has(SanitizerKind::ObjectSize) &&
+  !SkippedChecks.has(SanitizerKind::ObjectSize) &&
+  !Ty->isIncompleteType()) {
 uint64_t Size = getContext().getTypeSizeInChars(Ty).getQuantity();
 
 // The glvalue must refer to a large enough storage region.
@@ -587,7 +590,8 @@ void CodeGenFunction::EmitTypeCheck(Type
 
   uint64_t AlignVal = 0;
 
-  if (SanOpts.has(SanitizerKind::Alignment)) {
+  if (SanOpts.has(SanitizerKind::Alignment) &&
+  !SkippedChecks.has(SanitizerKind::Alignment)) {
 AlignVal = Alignment.getQuantity();
 if (!Ty->isIncompleteType() && !AlignVal)
   AlignVal = getContext().getTypeAlignInChars(Ty).getQuantity();
@@ -624,6 +628,7 @@ void CodeGenFunction::EmitTypeCheck(Type
   //   or call a non-static member function
   CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
   if (SanOpts.has(SanitizerKind::Vptr) &&
+  !SkippedChecks.has(SanitizerKind::Vptr) &&
   (TCK == TCK_MemberAccess || TCK == TCK_MemberCall ||
TCK == TCK_DowncastPointer || TCK == TCK_DowncastReference ||
TCK == TCK_UpcastToVirtualBase) &&

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=295514=295513=295514=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Feb 17 17:22:55 2017
@@ -2252,7 +2252,7 @@ public:
   /// appropriate size and alignment for an object of type \p Type.
   void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *V,
 

r295515 - Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 17 17:22:59 2017
New Revision: 295515

URL: http://llvm.org/viewvc/llvm-project?rev=295515=rev
Log:
Retry^2: [ubsan] Reduce null checking of C++ object pointers (PR27581)

This patch teaches ubsan to insert exactly one null check for the 'this'
pointer per method/lambda.

Previously, given a load of a member variable from an instance method
('this->x'), ubsan would insert a null check for 'this', and another
null check for '>x', before allowing the load to occur.

Similarly, given a call to a method from another method bound to the
same instance ('this->foo()'), ubsan would a redundant null check for
'this'. There is also a redundant null check in the case where the
object pointer is a reference ('Ref.foo()').

This patch teaches ubsan to remove the redundant null checks identified
above.

Testing: check-clang, check-ubsan, and a stage2 ubsan build.

I also compiled X86FastISel.cpp with -fsanitize=null using
patched/unpatched clangs based on r293572. Here are the number of null
checks emitted:

  -
  | Setup  | # of null checks |
  -
  | unpatched, -O0 |21767 |
  | patched, -O0   |10758 |
  -

Changes since the initial commit:
- Don't introduce any unintentional object-size or alignment checks.
- Don't rely on IRGen of C labels in the test.

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

Added:
cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=295515=295514=295515=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Feb 17 17:22:59 2017
@@ -952,15 +952,46 @@ LValue CodeGenFunction::EmitUnsupportedL
 E->getType());
 }
 
+bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) {
+  if (isa(Obj))
+return true;
+
+  const Expr *Base = Obj;
+  while (!isa(Base)) {
+// The result of a dynamic_cast can be null.
+if (isa(Base))
+  return false;
+
+if (const auto *CE = dyn_cast(Base)) {
+  Base = CE->getSubExpr();
+} else if (const auto *PE = dyn_cast(Base)) {
+  Base = PE->getSubExpr();
+} else if (const auto *UO = dyn_cast(Base)) {
+  if (UO->getOpcode() == UO_Extension)
+Base = UO->getSubExpr();
+  else
+return false;
+} else {
+  return false;
+}
+  }
+  return true;
+}
+
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
   if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
-  if (!isa(E) && !LV.isBitField() && LV.isSimple())
+  if (!isa(E) && !LV.isBitField() && LV.isSimple()) {
+SanitizerSet SkippedChecks;
+if (const auto *ME = dyn_cast(E))
+  if (CanElideObjectPointerNullCheck(ME->getBase()))
+SkippedChecks.set(SanitizerKind::Null, true);
 EmitTypeCheck(TCK, E->getExprLoc(), LV.getPointer(),
-  E->getType(), LV.getAlignment());
+  E->getType(), LV.getAlignment(), SkippedChecks);
+  }
   return LV;
 }
 
@@ -3340,7 +3371,11 @@ LValue CodeGenFunction::EmitMemberExpr(c
 AlignmentSource AlignSource;
 Address Addr = EmitPointerWithAlignment(BaseExpr, );
 QualType PtrTy = BaseExpr->getType()->getPointeeType();
-EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy);
+SanitizerSet SkippedChecks;
+if (CanElideObjectPointerNullCheck(BaseExpr))
+  SkippedChecks.set(SanitizerKind::Null, true);
+EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy,
+  /*Alignment=*/CharUnits::Zero(), SkippedChecks);
 BaseLV = MakeAddrLValue(Addr, PtrTy, AlignSource);
   } else
 BaseLV = EmitCheckedLValue(BaseExpr, TCK_MemberAccess);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=295515=295514=295515=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Feb 17 17:22:59 2017
@@ -290,10 +290,15 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   if (CE)
 CallLoc = CE->getExprLoc();
 
-  EmitTypeCheck(isa(CalleeDecl)
-? CodeGenFunction::TCK_ConstructorCall
-: 

[libcxx] r295510 - math: fix typo in macro

2017-02-17 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Feb 17 17:08:44 2017
New Revision: 295510

URL: http://llvm.org/viewvc/llvm-project?rev=295510=rev
Log:
math: fix typo in macro

MAJOR was misspelt as NAJOR.  Fix the spelling.

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/include/math.h

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=295510=295509=295510=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Fri Feb 17 17:08:44 2017
@@ -398,7 +398,7 @@ using ::cbrtf;
 using ::copysign;
 using ::copysignf;
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 using ::erf;
 using ::erff;
 using ::erfc;
@@ -435,12 +435,12 @@ using ::lrint;
 using ::lrintf;
 using ::lround;
 using ::lroundf;
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 using ::nan;
 using ::nanf;
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 using ::nearbyint;
 using ::nearbyintf;
 using ::nextafter;
@@ -463,7 +463,7 @@ using ::tgamma;
 using ::tgammaf;
 using ::trunc;
 using ::truncf;
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 using ::acosl;
 using ::asinl;
@@ -495,7 +495,7 @@ using ::cbrtl;
 
 using ::copysignl;
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 using ::erfl;
 using ::erfcl;
 using ::exp2l;
@@ -526,7 +526,7 @@ using ::scalblnl;
 using ::scalbnl;
 using ::tgammal;
 using ::truncl;
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 #if _LIBCPP_STD_VER > 14
 inline _LIBCPP_INLINE_VISIBILITY float   hypot(   float x,   float 
y,   float z ) { return sqrt(x*x + y*y + z*z); }

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=295510=295509=295510=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Fri Feb 17 17:08:44 2017
@@ -1020,7 +1020,7 @@ copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NO
 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
 }
 
-#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 // erf
 
@@ -1404,7 +1404,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 typename std::enable_if::value, double>::type
 trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
 
-#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_MAJOR_VERSION-0) < 14))
 
 } // extern "C++"
 


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


[libcxx] r295511 - test: prevent incorrect quoting of paths

2017-02-17 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Feb 17 17:08:46 2017
New Revision: 295511

URL: http://llvm.org/viewvc/llvm-project?rev=295511=rev
Log:
test: prevent incorrect quoting of paths

The path would previously get an extra leading space as the arguments
would be parsed when generating the final command to run.  Pretokenise
the arguments to permit proper quoting of the paths.  This avoids a
number of ignoring non-existent path warnings from clang.

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

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=295511=295510=295511=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Fri Feb 17 17:08:46 2017
@@ -229,21 +229,19 @@ class Configuration(object):
 self.cxx.compile_env['CCACHE_CPP2'] = '1'
 
 def _configure_clang_cl(self, clang_path):
+def _split_env_var(var):
+return [p.strip() for p in os.environ.get(var, '').split(';') if 
p.strip()]
+
+def _prefixed_env_list(var, prefix):
+from itertools import chain
+return list(chain.from_iterable((prefix, path) for path in 
_split_env_var(var)))
+
 assert self.cxx_is_clang_cl
 flags = []
-compile_flags = []
-link_flags = []
-if 'INCLUDE' in os.environ:
-compile_flags += ['-isystem %s' % p.strip()
-  for p in os.environ['INCLUDE'].split(';')
-  if p.strip()]
-if 'LIB' in os.environ:
-for p in os.environ['LIB'].split(';'):
-p = p.strip()
-if not p:
-continue
-link_flags += ['-L%s' % p]
-self.add_path(self.exec_env, p)
+compile_flags = _prefixed_env_list('INCLUDE', '-isystem')
+link_flags = _prefixed_env_list('LIB', '-L')
+for path in _list_env_var('LIB'):
+self.add_path(self.exec_env, path)
 return CXXCompiler(clang_path, flags=flags,
compile_flags=compile_flags,
link_flags=link_flags)


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


[libcxx] r295509 - cmath: Use c99 math on a new enough msvcrt

2017-02-17 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Feb 17 17:08:42 2017
New Revision: 295509

URL: http://llvm.org/viewvc/llvm-project?rev=295509=rev
Log:
cmath: Use c99 math on a new enough msvcrt

MSVCRT 14+ supports the C99 math routines that we need.  Use them
accordingly.

Modified:
libcxx/trunk/include/cmath

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=295509=295508=295509=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Fri Feb 17 17:08:42 2017
@@ -440,7 +440,7 @@ using ::lroundf;
 using ::nan;
 using ::nanf;
 
-#ifndef _LIBCPP_MSVCRT
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 using ::nearbyint;
 using ::nearbyintf;
 using ::nextafter;
@@ -463,7 +463,7 @@ using ::tgamma;
 using ::tgammaf;
 using ::trunc;
 using ::truncf;
-#endif // !_LIBCPP_MSVCRT
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 using ::acosl;
 using ::asinl;
@@ -495,7 +495,7 @@ using ::cbrtl;
 
 using ::copysignl;
 
-#if !defined(_LIBCPP_MSVCRT) || (_VC_CRT_MAJOR_VERSION-0) >= 14
+#if !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 using ::erfl;
 using ::erfcl;
 using ::exp2l;
@@ -526,7 +526,7 @@ using ::scalblnl;
 using ::scalbnl;
 using ::tgammal;
 using ::truncl;
-#endif // !defined(_LIBCPP_MSVCRT) || (_VC_CRT_MAJOR_VERSION-0) >= 14
+#endif // !(defined(_LIBCPP_MSVCRT) && ((_VC_CRT_NAJOR_VERSION-0) < 14))
 
 #if _LIBCPP_STD_VER > 14
 inline _LIBCPP_INLINE_VISIBILITY float   hypot(   float x,   float 
y,   float z ) { return sqrt(x*x + y*y + z*z); }


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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a reviewer: rnk.
pirama added a subscriber: rnk.
pirama added a comment.

@rnk: This patch was to address discussion in 
http://lists.llvm.org/pipermail/openmp-dev/2017-February/001659.html but now 
also addresses 
http://lists.llvm.org/pipermail/cfe-dev/2017-January/052512.html.  Can you take 
a look?


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

mgorny wrote:
> pirama wrote:
> > Hahnfeld wrote:
> > > Can you split that into two lines? Then it won't fail if there is some 
> > > argument added in between
> > Splitting into two lines makes FileCheck eagerly match the arch-subdir and 
> > -rpath into the {{.*}} next to the "-L".  This causes the check for -rpath 
> > to fail.
> > 
> > The test accepts intermediate arguments because of the wildcard right after 
> > the -L...Inputs/...
> Please do not rely on implicit assumptions like that. One day someone may 
> decide to 'fix' the wildcard not to match whitespace, and make the wrong 
> assumption about order. If for anything, splitting in two would make this 
> more readable.
Do you have any suggestions?  Right now, if I split it into two lines, the 
second check fails due to the eager regex match.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.

LGTM modulo the test match split. But please wait for someone who has been 
longer here to confirm.




Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

pirama wrote:
> Hahnfeld wrote:
> > Can you split that into two lines? Then it won't fail if there is some 
> > argument added in between
> Splitting into two lines makes FileCheck eagerly match the arch-subdir and 
> -rpath into the {{.*}} next to the "-L".  This causes the check for -rpath to 
> fail.
> 
> The test accepts intermediate arguments because of the wildcard right after 
> the -L...Inputs/...
Please do not rely on implicit assumptions like that. One day someone may 
decide to 'fix' the wildcard not to match whitespace, and make the wrong 
assumption about order. If for anything, splitting in two would make this more 
readable.


https://reviews.llvm.org/D30015



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


[PATCH] D30118: [XRay] Merge xray clang flag tests, and add powerpc64le.

2017-02-17 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
Herald added a subscriber: nemanjai.

I'm not sure why they were in different files, but it's kind of harder to 
maintain. I create this patch partially for initiate a discussion.


https://reviews.llvm.org/D30118

Files:
  clang/test/CodeGen/xray-attributes-supported-arm.cpp
  clang/test/CodeGen/xray-attributes-supported-mips.cpp
  clang/test/CodeGen/xray-attributes-supported.cpp


Index: clang/test/CodeGen/xray-attributes-supported.cpp
===
--- clang/test/CodeGen/xray-attributes-supported.cpp
+++ clang/test/CodeGen/xray-attributes-supported.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
 [[clang::xray_always_instrument]] void foo() {
Index: clang/test/CodeGen/xray-attributes-supported-mips.cpp
===
--- clang/test/CodeGen/xray-attributes-supported-mips.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mipsel-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64-unknown-linux-gnu | FileCheck %s
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple mips64el-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: clang/test/CodeGen/xray-attributes-supported-arm.cpp
===
--- clang/test/CodeGen/xray-attributes-supported-arm.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - 
-triple arm-unknown-linux-gnu | FileCheck %s
-
-// Make sure that the LLVM attribute for XRay-annotated functions do show up.
-[[clang::xray_always_instrument]] void foo() {
-// CHECK: define void @_Z3foov() #0
-};
-
-[[clang::xray_never_instrument]] void bar() {
-// CHECK: define void @_Z3barv() #1
-};
-
-// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
-// CHECK: #1 = {{.*}}"function-instrument"="xray-never"


Index: clang/test/CodeGen/xray-attributes-supported.cpp
===
--- clang/test/CodeGen/xray-attributes-supported.cpp
+++ clang/test/CodeGen/xray-attributes-supported.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple arm-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mipsel-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple mips64el-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple powerpc64le-unknown-linux-gnu | FileCheck %s
 
 // Make sure that the LLVM attribute for XRay-annotated functions do show up.
 [[clang::xray_always_instrument]] void foo() {
Index: clang/test/CodeGen/xray-attributes-supported-mips.cpp
===
--- clang/test/CodeGen/xray-attributes-supported-mips.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm 

[PATCH] D24812: Lit C++11 Compatibility Patch #11

2017-02-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295484: [Test] Make Lit tests C++11 compatible - misc 
(authored by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D24812?vs=88617=88961#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24812

Files:
  cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
  cfe/trunk/test/CodeGenCXX/static-init.cpp
  cfe/trunk/test/CodeGenCXX/volatile-1.cpp
  cfe/trunk/test/CodeGenCXX/volatile.cpp
  cfe/trunk/test/PCH/macro-undef.cpp

Index: cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
===
--- cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
+++ cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
@@ -48,17 +48,19 @@
   return a;
 }
 
+#if __cplusplus <= 199711L
 int f6() {
   static union {
 union {
   int : 1;
 };
 int b;
   };
   
-  // CHECK: _ZZ2f6vE1b
+  // CXX98: _ZZ2f6vE1b
   return b;
 }
+#endif
 
 int f7() {
   static union {
Index: cfe/trunk/test/CodeGenCXX/static-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/static-init.cpp
+++ cfe/trunk/test/CodeGenCXX/static-init.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++98 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
 // CHECK: @base_req = global [4 x i8] c"foo\00", align 1
@@ -9,7 +10,8 @@
 // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat, align 4
 // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat, align 8{{$}}
 // CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16
-// CHECK: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global %"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK98: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global %"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK11: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global { i8** } { i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTVN5test49HasVTableE, i32 0, inrange i32 0, i32 2) }, comdat, align 8
 
 struct A {
   A();
@@ -169,5 +171,5 @@
   useStaticLocal();
 }
 // CHECK: define linkonce_odr dereferenceable(8) %"struct.test4::HasVTable"* @_ZN5test414useStaticLocalEv()
-// CHECK: ret %"struct.test4::HasVTable"* @_ZZN5test414useStaticLocalEvE3obj
+// CHECK: ret %"struct.test4::HasVTable"*{{.*}} @_ZZN5test414useStaticLocalEvE3obj
 }
Index: cfe/trunk/test/CodeGenCXX/volatile-1.cpp
===
--- cfe/trunk/test/CodeGenCXX/volatile-1.cpp
+++ cfe/trunk/test/CodeGenCXX/volatile-1.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -std=c++98 -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // CHECK: @i = global [[INT:i[0-9]+]] 0
 volatile int i, j, k;
@@ -22,18 +23,22 @@
 
   asm("nop"); // CHECK: call void asm
 
-  // should not load
+  // should not load in C++98
   i;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @i
 
   (float)(ci);
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
   // CHECK-NEXT: sitofp [[INT]]
 
-  // These are not uses in C++:
+  // These are not uses in C++98:
   //   [expr.static.cast]p6:
   // The lvalue-to-rvalue . . . conversions are not applied to the expression.
   (void)ci;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
+
   (void)a;
 
   (void)(ci=ci);
@@ -126,7 +131,8 @@
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: sitofp
 
-  (void)i;
+  (void)i; // This is now a load in C++11
+  // CHECK11-NEXT: load volatile
 
   i=i;
   // CHECK-NEXT: load volatile
@@ -155,25 +161,30 @@
   // CHECK-NEXT: br label
   // CHECK:  phi
 
-  (void)(i,(i=i));
+  (void)(i,(i=i)); // first i is also a load in C++11
+  // CHECK11-NEXT: load volatile
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: store volatile
 
-  i=i,k;
+  i=i,k; // k is also a load in C++11
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @i
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* 

[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295482: [clang-tidy] Add -path option to clang-tidy-diff.py 
(authored by ehsan).

Changed prior to commit:
  https://reviews.llvm.org/D29806?vs=88879=88959#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29806

Files:
  clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
@@ -2,6 +2,9 @@
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | 
FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck 
-check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 
%t.cpp", "file": "%t.cpp"}]' > 
%T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | 
FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}
Index: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
@@ -55,6 +55,8 @@
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-path', dest='build_path',
+  help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -124,6 +126,8 @@
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
+  if args.build_path is not None:
+command.append('-p=%s' % args.build_path)
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)


Index: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
@@ -2,6 +2,9 @@
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 %t.cpp", "file": "%t.cpp"}]' > %T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}
Index: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
@@ -55,6 +55,8 @@
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-path', dest='build_path',
+  help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -124,6 +126,8 @@
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
+  if args.build_path is not None:
+command.append('-p=%s' % args.build_path)
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26654: [CMake] Add Fuchsia toolchain CMake cache files

2017-02-17 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295480: [CMake] Add Fuchsia toolchain CMake cache files 
(authored by phosek).

Changed prior to commit:
  https://reviews.llvm.org/D26654?vs=88770=88958#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26654

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

Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -0,0 +1,62 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;AArch64 CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+endif()
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  lldb
+  liblldb
+  LTO
+  clang-format
+  clang-headers
+  builtins-x86_64-fuchsia-none
+  builtins-aarch64-fuchsia-none
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-17 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 88943.
EricWF marked 2 inline comments as done.
EricWF added a comment.

Address @rsmith's review comments.


https://reviews.llvm.org/D30082

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-template-deduction-guide.cpp


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - 
-std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,8 +2475,9 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
-case Type::Auto: {
-  QualType DT = cast(T)->getDeducedType();
+case Type::Auto:
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
   T = DT;
   break;


Index: test/CodeGenCXX/debug-info-template-deduction-guide.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-template-deduction-guide.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang -S -emit-llvm -target x86_64-unknown_unknown -g %s -o - -std=c++1z | FileCheck %s
+
+// Verify that we don't crash when emitting debug information for objects
+// created from a deduced template specialization.
+
+template 
+struct S {
+  S(T) {}
+};
+
+// CHECK: !DIGlobalVariable(name: "s1"
+// CHECK-SAME: type: [[TYPE_NUM:![0-9]+]]
+// CHECK: !DIGlobalVariable(name: "s2"
+// CHECK-SAME: type: [[TYPE_NUM]]
+// CHECK: [[TYPE_NUM]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S",
+S s1(42);
+S s2(42);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2475,8 +2475,9 @@
 case Type::SubstTemplateTypeParm:
   T = cast(T)->getReplacementType();
   break;
-case Type::Auto: {
-  QualType DT = cast(T)->getDeducedType();
+case Type::Auto:
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();
   assert(!DT.isNull() && "Undeduced types shouldn't reach here.");
   T = DT;
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29772: Create msbuild only when using MSVC

2017-02-17 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a reviewer: rnk.
mati865 added a comment.

https://reviews.llvm.org/D29952 depends on this.


https://reviews.llvm.org/D29772



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


[PATCH] D29922: [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for'

2017-02-17 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli added a comment.

Committed revision r295497


Repository:
  rL LLVM

https://reviews.llvm.org/D29922



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


[PATCH] D30035: Add const to function parameters

2017-02-17 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.

Adding const could help compiler, I do not have any specific performance 
numbers yet. So if this is too much trouble then we don't have to merge this.


https://reviews.llvm.org/D30035



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


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

2017-02-17 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



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

What is tested here? Brace styles?



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

This does not check precisely what the comment says, because the comment 
affects the indentation decisions. Better put the comment before the class 
declaration.



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

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



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

Trailing comments affect line breaking, so this is not really testing what the 
comments say. Suggest to put them on a line before the template.



Comment at: test/Format/check-coding-style-mozilla.cpp:102
+
+T* p; // GOOD
+

I suggest either the comment to be more specific what exactly is "GOOD" or 
remove the comment altogether.



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

What does this fragment and the following ones test?


https://reviews.llvm.org/D30111



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

I believe I've addressed all open issues, but this patch has changed a lot 
since Dan marked it accepted.  @Hahnfeld or @mgorny:  Can one of you give a 
LGTM if you are satisfied?


https://reviews.llvm.org/D30015



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


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

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

> In this checker, I give warnings for values which are both tainted and were 
> also not checked by the programmer. So unlike GenericTaintChecker, I do 
> implement the boundedness check here for certain, interesting constructs 
> (which is controlled by the critical option). GenericTaintChecker focuses 
> purely on taintedness, almost like a service for other checkers. I've added a 
> new rule to it, improving the taintedness logic, but I felt mixing the bound 
> checking logic into it would make the two ideas inseparable.

I'd like to step back a bit. In my view, the taint implementation should 
consist of three elements:

1. taint source
2. taint sink
3. cleansing rules

I always considered the taint analysis in the analyzer not fully implemented 
because #3 was missing. It sounds a lot like non-"dirty" scalars would be the 
same as values that went through cleansing - they should be considered not 
tainted anymore. Now, are cleansing rules checker specific or generic? If they 
are generic, these rules should definitely be part of GenericTaintChecker and 
every checker using taint would utilize them.

WDYT?

(We can talk about the array bound checking part separately.)


https://reviews.llvm.org/D27753



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


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

2017-02-17 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.

To avoid potential regressions and checking most of the coding style aspects at 
once


https://reviews.llvm.org/D30111

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

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


[clang-tools-extra] r295498 - Fix windows buildbots that don't have full shell support

2017-02-17 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Feb 17 15:31:31 2017
New Revision: 295498

URL: http://llvm.org/viewvc/llvm-project?rev=295498=rev
Log:
Fix windows buildbots that don't have full shell support

Modified:
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp?rev=295498=295497=295498=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp Fri Feb 17 
15:31:31 2017
@@ -1,3 +1,4 @@
+// REQUIRES: shell
 // RUN: sed 's/placeholder_for_f/f/' %s > %t.cpp
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | 
FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s


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


r295497 - [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for'

2017-02-17 Thread Carlo Bertolli via cfe-commits
Author: cbertol
Date: Fri Feb 17 15:29:13 2017
New Revision: 295497

URL: http://llvm.org/viewvc/llvm-project?rev=295497=rev
Log:
[OpenMP] Prepare Sema for initial implementation for pragma 'distribute 
parallel for'

https://reviews.llvm.org/D29922

This patch adds two fields for use in the implementation of 'distribute 
parallel for':

The increment expression for the distribute loop. As the chunk assigned to a 
team is executed by multiple threads within the 'parallel for' region, the 
increment expression has to correspond to the value returned by the related 
runtime call (for_static_init).
The upper bound of the innermost loop ('for' in 'distribute parallel for') is 
not the globalUB expression normally used for pragma 'for' when found in 
isolation. It is instead the upper bound of the chunk assigned to the team 
('distribute' loop). In this way, we prevent teams from executing chunks 
assigned to other teams.
The use of these two fields can be see in a related explanatory patch:
https://reviews.llvm.org/D29508



Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/lib/AST/StmtOpenMP.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=295497=295496=295497=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Feb 17 15:29:13 2017
@@ -324,6 +324,11 @@ class OMPLoopDirective : public OMPExecu
   /// allocated: loop counters, their updates and final values.
   /// PrevLowerBound and PrevUpperBound are used to communicate blocking
   /// information in composite constructs which require loop blocking
+  /// DistInc is used to generate the increment expression for the distribute
+  /// loop when combined with a further nested loop
+  /// PrevEnsureUpperBound is used as the EnsureUpperBound expression for the
+  /// for loop when combined with a previous distribute loop in the same pragma
+  /// (e.g. 'distribute parallel for')
   ///
   enum {
 AssociatedStmtOffset = 0,
@@ -339,7 +344,7 @@ class OMPLoopDirective : public OMPExecu
 // specify the offset to the end (and start of the following counters/
 // updates/finals arrays).
 DefaultEnd = 9,
-// The following 7 exprs are used by worksharing loops only.
+// The following 12 exprs are used by worksharing and distribute loops 
only.
 IsLastIterVariableOffset = 9,
 LowerBoundVariableOffset = 10,
 UpperBoundVariableOffset = 11,
@@ -350,9 +355,11 @@ class OMPLoopDirective : public OMPExecu
 NumIterationsOffset = 16,
 PrevLowerBoundVariableOffset = 17,
 PrevUpperBoundVariableOffset = 18,
+DistIncOffset = 19,
+PrevEnsureUpperBoundOffset = 20,
 // Offset to the end (and start of the following counters/updates/finals
 // arrays) for worksharing loop directives.
-WorksharingEnd = 19,
+WorksharingEnd = 21,
   };
 
   /// \brief Get the counters storage.
@@ -521,6 +528,20 @@ protected:
"expected worksharing loop directive");
 *std::next(child_begin(), PrevUpperBoundVariableOffset) = PrevUB;
   }
+  void setDistInc(Expr *DistInc) {
+assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
+   "expected worksharing loop directive");
+*std::next(child_begin(), DistIncOffset) = DistInc;
+  }
+  void setPrevEnsureUpperBound(Expr *PrevEUB) {
+assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
+isOpenMPTaskLoopDirective(getDirectiveKind()) ||
+isOpenMPDistributeDirective(getDirectiveKind())) &&
+   "expected worksharing loop directive");
+*std::next(child_begin(), PrevEnsureUpperBoundOffset) = PrevEUB;
+  }
   void setCounters(ArrayRef A);
   void setPrivateCounters(ArrayRef A);
   void setInits(ArrayRef A);
@@ -555,7 +576,7 @@ public:
 Expr *UB;
 /// \brief Stride - local variable passed to runtime.
 Expr *ST;
-/// \brief EnsureUpperBound -- expression LB = min(LB, NumIterations).
+/// \brief EnsureUpperBound -- expression UB = min(UB, NumIterations).
 Expr *EUB;
 /// \brief Update of LowerBound for statically sheduled 'omp for' loops.
 Expr *NLB;
@@ -567,6 +588,16 @@ public:
 /// \brief PreviousUpperBound - local variable passed to runtime in the
 /// enclosing schedule or null if that does not apply.
 Expr *PrevUB;
+/// \brief DistInc - increment expression for distribute loop when found
+/// combined with a further loop level (e.g. in 'distribute parallel for')
+/// expression IV = IV + ST
+Expr *DistInc;
+/// 

r295494 - Revert "Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)"

2017-02-17 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Feb 17 14:59:40 2017
New Revision: 295494

URL: http://llvm.org/viewvc/llvm-project?rev=295494=rev
Log:
Revert "Retry: [ubsan] Reduce null checking of C++ object pointers (PR27581)"

This reverts commit r295401. It breaks the ubsan self-host. It inserts
object size checks once per C++ method which fire when the structure is
empty.

Removed:
cfe/trunk/test/CodeGenCXX/ubsan-suppress-null-checks.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/catch-undef-behavior.c
cfe/trunk/test/CodeGen/sanitize-recover.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=295494=295493=295494=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Feb 17 14:59:40 2017
@@ -947,45 +947,15 @@ LValue CodeGenFunction::EmitUnsupportedL
 E->getType());
 }
 
-bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) {
-  if (isa(Obj))
-return true;
-
-  const Expr *Base = Obj;
-  while (!isa(Base)) {
-// The result of a dynamic_cast can be null.
-if (isa(Base))
-  return false;
-
-if (const auto *CE = dyn_cast(Base)) {
-  Base = CE->getSubExpr();
-} else if (const auto *PE = dyn_cast(Base)) {
-  Base = PE->getSubExpr();
-} else if (const auto *UO = dyn_cast(Base)) {
-  if (UO->getOpcode() == UO_Extension)
-Base = UO->getSubExpr();
-  else
-return false;
-} else {
-  return false;
-}
-  }
-  return true;
-}
-
 LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
   LValue LV;
   if (SanOpts.has(SanitizerKind::ArrayBounds) && isa(E))
 LV = EmitArraySubscriptExpr(cast(E), /*Accessed*/true);
   else
 LV = EmitLValue(E);
-  if (!isa(E) && !LV.isBitField() && LV.isSimple()) {
-bool SkipNullCheck = false;
-if (const auto *ME = dyn_cast(E))
-  SkipNullCheck = CanElideObjectPointerNullCheck(ME->getBase());
+  if (!isa(E) && !LV.isBitField() && LV.isSimple())
 EmitTypeCheck(TCK, E->getExprLoc(), LV.getPointer(),
-  E->getType(), LV.getAlignment(), SkipNullCheck);
-  }
+  E->getType(), LV.getAlignment());
   return LV;
 }
 
@@ -3365,9 +3335,7 @@ LValue CodeGenFunction::EmitMemberExpr(c
 AlignmentSource AlignSource;
 Address Addr = EmitPointerWithAlignment(BaseExpr, );
 QualType PtrTy = BaseExpr->getType()->getPointeeType();
-bool SkipNullCheck = CanElideObjectPointerNullCheck(BaseExpr);
-EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy,
-  /*Alignment=*/CharUnits::Zero(), SkipNullCheck);
+EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy);
 BaseLV = MakeAddrLValue(Addr, PtrTy, AlignSource);
   } else
 BaseLV = EmitCheckedLValue(BaseExpr, TCK_MemberAccess);

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=295494=295493=295494=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Feb 17 14:59:40 2017
@@ -290,15 +290,10 @@ RValue CodeGenFunction::EmitCXXMemberOrO
   if (CE)
 CallLoc = CE->getExprLoc();
 
-  bool SkipNullCheck = false;
-  if (const auto *CMCE = dyn_cast(CE))
-SkipNullCheck =
-CanElideObjectPointerNullCheck(CMCE->getImplicitObjectArgument());
-  EmitTypeCheck(
-  isa(CalleeDecl) ? 
CodeGenFunction::TCK_ConstructorCall
-  : CodeGenFunction::TCK_MemberCall,
-  CallLoc, This.getPointer(), C.getRecordType(CalleeDecl->getParent()),
-  /*Alignment=*/CharUnits::Zero(), SkipNullCheck);
+  EmitTypeCheck(isa(CalleeDecl)
+? CodeGenFunction::TCK_ConstructorCall
+: CodeGenFunction::TCK_MemberCall,
+CallLoc, This.getPointer(), 
C.getRecordType(CalleeDecl->getParent()));
 
   // FIXME: Uses of 'MD' past this point need to be audited. We may need to use
   // 'CalleeDecl' instead.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=295494=295493=295494=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Feb 17 14:59:40 2017
@@ -948,11 +948,6 @@ void CodeGenFunction::StartFunction(Glob
   // fast register allocator would be happier...
   CXXThisValue = CXXABIThisValue;
 }
-
-// Sanitize the 'this' pointer once per function, if it's 

RE: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Yung, Douglas via cfe-commits
Hi Ehsan,

Your commit has caused the PS4 Windows bot to go red. Can you take a look?

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/5661

$ "FileCheck" "-check-prefix=CHECK" 
"C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp"
# command stderr:
C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\clang-tidy-diff.cpp:17:11:
 error: expected string not found in input

// CHECK: [[@LINE-2]]:8: warning: annotate this

  ^

:1:1: note: scanning from here

YAML:1:1: error: Unrecognized escape code!

^

:1:1: note: with expression "@LINE-2" equal to "15"

YAML:1:1: error: Unrecognized escape code!

^

:1:7: note: possible intended match here

YAML:1:1: error: Unrecognized escape code!

  ^


error: command failed with exit status: 1

Douglas Yung

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Ehsan Akhgari via cfe-commits
> Sent: Friday, February 17, 2017 11:32
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-
> tidy-diff.py
> 
> Author: ehsan
> Date: Fri Feb 17 13:31:43 2017
> New Revision: 295482
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
> Log:
> [clang-tidy] Add -path option to clang-tidy-diff.py
> 
> Summary:
> This flag allows specifying a custom path for the compilation database.
> Unfortunately we can't use the -p flag like other clang-tidy tools because
> it's already taken.
> 
> Reviewers: alexfh
> 
> Subscribers: JDevlieghere, cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D29806
> 
> Modified:
> clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> 
> Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-
> tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
> +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb
> +++ 17 13:31:43 2017
> @@ -55,6 +55,8 @@ def main():
>help='checks filter, when not specified, use clang-tidy
> '
>'default',
>default='')
> +  parser.add_argument('-path', dest='build_path',
> +  help='Path used to read a compile command
> + database.')
>parser.add_argument('-extra-arg', dest='extra_arg',
>action='append', default=[],
>help='Additional argument to append to the compiler '
> @@ -124,6 +126,8 @@ def main():
>  command.append('-checks=' + quote + args.checks + quote)
>if args.quiet:
>  command.append('-quiet')
> +  if args.build_path is not None:
> +command.append('-p=%s' % args.build_path)
>command.extend(lines_by_file.keys())
>for arg in args.extra_arg:
>command.append('-extra-arg=%s' % arg)
> 
> Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-
> tidy/clang-tidy-diff.cpp?rev=295482=295481=295482=diff
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp Fri Feb
> +++ 17 13:31:43 2017
> @@ -2,6 +2,9 @@
>  // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 |
> FileCheck -check-prefix=CHECK-SANITY %s  // RUN: not diff -U0 %s %t.cpp |
> %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 |
> FileCheck %s  // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-
> *,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-
> prefix=CHECK-QUIET %s
> +// RUN: mkdir -p %T/compilation-database-test/ // RUN: echo
> +'[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 %t.cpp",
> +"file": "%t.cpp"}]' >
> +%T/compilation-database-test/compile_commands.json
> +// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff
> +-checks=-*,modernize-use-override -path %T/compilation-database-test
> +2>&1 | FileCheck -check-prefix=CHECK %s
>  struct A {
>virtual void f() {}
>virtual void g() {}
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295484 - [Test] Make Lit tests C++11 compatible - misc

2017-02-17 Thread Charles Li via cfe-commits
Author: lcharles
Date: Fri Feb 17 13:36:19 2017
New Revision: 295484

URL: http://llvm.org/viewvc/llvm-project?rev=295484=rev
Log:
[Test] Make Lit tests C++11 compatible - misc

Updated 5 tests.

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

Modified:
cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
cfe/trunk/test/CodeGenCXX/static-init.cpp
cfe/trunk/test/CodeGenCXX/volatile-1.cpp
cfe/trunk/test/CodeGenCXX/volatile.cpp
cfe/trunk/test/PCH/macro-undef.cpp

Modified: cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp?rev=295484=295483=295484=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp Fri Feb 17 13:36:19 2017
@@ -48,6 +48,7 @@ int f5() {
   return a;
 }
 
+#if __cplusplus <= 199711L
 int f6() {
   static union {
 union {
@@ -56,9 +57,10 @@ int f6() {
 int b;
   };
   
-  // CHECK: _ZZ2f6vE1b
+  // CXX98: _ZZ2f6vE1b
   return b;
 }
+#endif
 
 int f7() {
   static union {

Modified: cfe/trunk/test/CodeGenCXX/static-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/static-init.cpp?rev=295484=295483=295484=diff
==
--- cfe/trunk/test/CodeGenCXX/static-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/static-init.cpp Fri Feb 17 13:36:19 2017
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++98 -o - | 
FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-linuxs -emit-llvm -std=c++11 -o - | 
FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // CHECK: @_ZZ1hvE1i = internal global i32 0, align 4
 // CHECK: @base_req = global [4 x i8] c"foo\00", align 1
@@ -9,7 +10,8 @@
 // CHECK: @_ZZ2h2vE1i = linkonce_odr global i32 0, comdat, align 4
 // CHECK: @_ZGVZ2h2vE1i = linkonce_odr global i64 0, comdat, align 8{{$}}
 // CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 
0, i32 2, i32 4], align 16
-// CHECK: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global 
%"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK98: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global 
%"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK11: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global { i8** } 
{ i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN5test49HasVTableE, i32 0, inrange i32 0, i32 2) }, comdat, align 8
 
 struct A {
   A();
@@ -169,5 +171,5 @@ void useit() {
   useStaticLocal();
 }
 // CHECK: define linkonce_odr dereferenceable(8) %"struct.test4::HasVTable"* 
@_ZN5test414useStaticLocalEv()
-// CHECK: ret %"struct.test4::HasVTable"* @_ZZN5test414useStaticLocalEvE3obj
+// CHECK: ret %"struct.test4::HasVTable"*{{.*}} 
@_ZZN5test414useStaticLocalEvE3obj
 }

Modified: cfe/trunk/test/CodeGenCXX/volatile-1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/volatile-1.cpp?rev=295484=295483=295484=diff
==
--- cfe/trunk/test/CodeGenCXX/volatile-1.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/volatile-1.cpp Fri Feb 17 13:36:19 2017
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s 
-o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s 
-std=c++98 -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s 
-std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // CHECK: @i = global [[INT:i[0-9]+]] 0
 volatile int i, j, k;
@@ -22,18 +23,22 @@ void test() {
 
   asm("nop"); // CHECK: call void asm
 
-  // should not load
+  // should not load in C++98
   i;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @i
 
   (float)(ci);
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds 
([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds 
([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
   // CHECK-NEXT: sitofp [[INT]]
 
-  // These are not uses in C++:
+  // These are not uses in C++98:
   //   [expr.static.cast]p6:
   // The lvalue-to-rvalue . . . conversions are not applied to the 
expression.
   (void)ci;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds 
([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds 
([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
+
   (void)a;
 
   (void)(ci=ci);
@@ -126,7 +131,8 @@ void test() {
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: sitofp
 
-  (void)i;
+  (void)i; // This is now a load in C++11
+  

r295491 - Add an explicit derived class of FunctionDecl to model deduction guides rather

2017-02-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 17 14:05:37 2017
New Revision: 295491

URL: http://llvm.org/viewvc/llvm-project?rev=295491=rev
Log:
Add an explicit derived class of FunctionDecl to model deduction guides rather
than just treating them as FunctionDecls with a funny name.

No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/DeclNodes.td
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=295491=295490=295491=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Feb 17 14:05:37 2017
@@ -1608,7 +1608,11 @@ private:
   unsigned SClass : 2;
   unsigned IsInline : 1;
   unsigned IsInlineSpecified : 1;
+protected:
+  // This is shared by CXXConstructorDecl, CXXConversionDecl, and
+  // CXXDeductionGuideDecl.
   unsigned IsExplicitSpecified : 1;
+private:
   unsigned IsVirtualAsWritten : 1;
   unsigned IsPure : 1;
   unsigned HasInheritedPrototype : 1;
@@ -1855,19 +1859,6 @@ public:
   bool isVirtualAsWritten() const { return IsVirtualAsWritten; }
   void setVirtualAsWritten(bool V) { IsVirtualAsWritten = V; }
 
-  /// Whether this function is marked as explicit explicitly.
-  bool isExplicitSpecified() const { return IsExplicitSpecified; }
-  void setExplicitSpecified() {
-assert((getKind() == CXXConstructor || getKind() == CXXConversion ||
-isDeductionGuide()) && "cannot be explicit");
-IsExplicitSpecified = true;
-  }
-
-  /// Whether this function is explicit.
-  bool isExplicit() const {
-return getFirstDecl()->isExplicitSpecified();
-  }
-
   /// Whether this virtual function is pure, i.e. makes the containing class
   /// abstract.
   bool isPure() const { return IsPure; }
@@ -1946,12 +1937,6 @@ public:
   bool isDeletedAsWritten() const { return IsDeleted && !IsDefaulted; }
   void setDeletedAsWritten(bool D = true) { IsDeleted = D; }
 
-  /// \brief Determines whether this function is a deduction guide.
-  bool isDeductionGuide() const {
-return getDeclName().getNameKind() ==
-   DeclarationName::CXXDeductionGuideName;
-  }
-
   /// \brief Determines whether this function is "main", which is the
   /// entry point into an executable program.
   bool isMain() const;

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=295491=295490=295491=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Feb 17 14:05:37 2017
@@ -1738,6 +1738,58 @@ public:
   friend class ASTWriter;
 };
 
+/// \brief Represents a C++ deduction guide declaration.
+///
+/// \code
+/// template struct A { A(); A(T); };
+/// A() -> A;
+/// \endcode
+///
+/// In this example, there will be an explicit deduction guide from the
+/// second line, and implicit deduction guide templates synthesized from
+/// the constructors of \c A.
+class CXXDeductionGuideDecl : public FunctionDecl {
+  void anchor() override;
+private:
+  CXXDeductionGuideDecl(ASTContext , DeclContext *DC, SourceLocation 
StartLoc,
+bool IsExplicit, const DeclarationNameInfo ,
+QualType T, TypeSourceInfo *TInfo,
+SourceLocation EndLocation)
+  : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
+ SC_None, false, false) {
+if (EndLocation.isValid())
+  setRangeEnd(EndLocation);
+IsExplicitSpecified = IsExplicit;
+  }
+
+public:
+  static CXXDeductionGuideDecl *Create(ASTContext , DeclContext *DC,
+   SourceLocation StartLoc, bool 
IsExplicit,
+   const DeclarationNameInfo ,
+   QualType T, TypeSourceInfo *TInfo,
+   SourceLocation EndLocation);
+
+  static CXXDeductionGuideDecl *CreateDeserialized(ASTContext , unsigned ID);
+
+  /// Whether this deduction 

Re: r294954 - Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.

2017-02-17 Thread Michał Górny via cfe-commits
W dniu 16.02.2017, czw o godzinie 08∶17 +, użytkownik NAKAMURA
Takumi napisał:
> Michał,
> 
> It'd make sense to use file(TO_CMAKE_PATH). I forgot it.
> I think get_file_component() satisfies in this case. Do you think to use
> file(TO_CMAKE_PATH) anyways?
> I'll wait for you as an opinion before proposing this fix to release_40.
> The bug is still in release_40.

I won't say it's very important but I'd rather have it done
consistently, just in case it could break something.

> 
> I don't think we could twiddle llvm-config stuff in future. FYI, I explain
> its history.
> 
> - When autoconf was alive, I tweaked it to let cmake configure against
> installed tree generated by autoconf.
> - Brad King (@kitware) proposed a mechanism for autoconf to provide cmake
> information in llvm.
> - Autoconf was killed.
> 
> In the ecosystem of cmake, we may go w/o llvm-config but find_package() by
> cmake's way.
> Then, I suggest to rip out llvm-config here.
> 
> Why I introduced cache variables for items supplied by llvm-config;
> I thought they are configurable w/o autoconf to specify their variables
> manually.

I generally support the idea of ridding of llvm-config whenever
possible. I simply didn't have the time to play with CMake more, so went
for the easiest solution that solved my problem.

> 
> BTW, do you think if llvm-config had an option like "--emit-cmake-tmpl"
> to help creating cmake project?

Nah, I think that would be too much. I'd rather keep it providing
whatever it needs to provide, and eventually discourage it.

One issue that needs to be solved long term, however, is how to properly
find CMake modules with different libdir/multilib systems. I'm thinking
of stand-alone runtime builds in particular.

For example, when building libcxx separately for three different ABIs,
all of them need to use CMake files from the host build of LLVM. It may
require splitting CMake files more; having things like LLVMConfig in
lib*/cmake and generic LLVM macros in share.

> 
> On Tue, Feb 14, 2017 at 12:45 AM Michał Górny  wrote:
> 
> > W dniu 13.02.2017, pon o godzinie 14∶59 +, użytkownik NAKAMURA
> > Takumi via cfe-commits napisał:
> > > Author: chapuni
> > > Date: Mon Feb 13 08:59:53 2017
> > > New Revision: 294954
> > > 
> > > URL: http://llvm.org/viewvc/llvm-project?rev=294954=rev
> > > Log:
> > > Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.
> > > 
> > > CMake handles paths with slashes. It caused cmake/install failure on
> > 
> > msbuild.exe.
> > > 
> > > Note, Other llvm-config-oriented variables have been normalized since
> > 
> > they are stored in the cache attributed with PATH.
> > > 
> > > Modified:
> > > cfe/trunk/CMakeLists.txt
> > > 
> > > Modified: cfe/trunk/CMakeLists.txt
> > > URL:
> > 
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=294954=294953=294954=diff
> > > 
> > 
> > ==
> > > --- cfe/trunk/CMakeLists.txt (original)
> > > +++ cfe/trunk/CMakeLists.txt Mon Feb 13 08:59:53 2017
> > > @@ -42,7 +42,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> > >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_CMAKE_PATH)
> > > +  list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
> > > 
> > >if(NOT MSVC_IDE)
> > >  set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
> > > @@ -57,6 +57,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
> > >set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build
> > 
> > tree")
> > >set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source
> > 
> > tree")
> > > 
> > > +  # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
> > > +  # CMake assumes slashes as PATH.
> > > +  get_filename_component(LLVM_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH}
> > 
> > ABSOLUTE)
> > 
> > Are you sure this is the best way of doing it? I'm not a Windows expert
> > but I've seen others using file(TO_CMAKE_PATH ...) for what I suppose
> > was the same goal.
> > 
> > > +
> > >find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
> > >  NO_DEFAULT_PATH)
> > > 
> > > 
> > > 
> > > ___
> > > cfe-commits mailing list
> > > cfe-commits@lists.llvm.org
> > > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > 
> > --
> > Best regards,
> > Michał Górny
> > 

-- 
Best regards,
Michał Górny


signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r295482 - [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via cfe-commits
Author: ehsan
Date: Fri Feb 17 13:31:43 2017
New Revision: 295482

URL: http://llvm.org/viewvc/llvm-project?rev=295482=rev
Log:
[clang-tidy] Add -path option to clang-tidy-diff.py

Summary:
This flag allows specifying a custom path for the compilation
database.  Unfortunately we can't use the -p flag like other
clang-tidy tools because it's already taken.

Reviewers: alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=295482=295481=295482=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Feb 17 
13:31:43 2017
@@ -55,6 +55,8 @@ def main():
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-path', dest='build_path',
+  help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -124,6 +126,8 @@ def main():
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
+  if args.build_path is not None:
+command.append('-p=%s' % args.build_path)
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)

Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp?rev=295482=295481=295482=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp Fri Feb 17 
13:31:43 2017
@@ -2,6 +2,9 @@
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | 
FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck 
-check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 
%t.cpp", "file": "%t.cpp"}]' > 
%T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | 
FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}


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


r295480 - [CMake] Add Fuchsia toolchain CMake cache files

2017-02-17 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Feb 17 13:28:54 2017
New Revision: 295480

URL: http://llvm.org/viewvc/llvm-project?rev=295480=rev
Log:
[CMake] Add Fuchsia toolchain CMake cache files

These cache files can be used to build Fuchsia toolchain. They also
demonstrate the use of multi-target builtins build.

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

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

Added: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=295480=auto
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (added)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Fri Feb 17 13:28:54 2017
@@ -0,0 +1,62 @@
+# This file sets up a CMakeCache for the second stage of a Fuchsia toolchain
+# build.
+
+set(LLVM_TARGETS_TO_BUILD X86;AArch64 CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_TOOL_CLANG_TOOLS_EXTRA_BUILD OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_EXTERNALIZE_DEBUGINFO ON CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(LLVM_ENABLE_LLD ON CACHE BOOL "")
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
+endif()
+
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
+
+set(LLVM_BUILTIN_TARGETS "x86_64-fuchsia-none;aarch64-fuchsia-none" CACHE 
STRING "")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE STRING 
"")
+set(BUILTINS_x86_64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSROOT ${FUCHSIA_SYSROOT} CACHE 
STRING "")
+set(BUILTINS_aarch64-fuchsia-none_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
+
+# Setup toolchain.
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-dsymutil
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  lldb
+  liblldb
+  LTO
+  clang-format
+  clang-headers
+  builtins-x86_64-fuchsia-none
+  builtins-aarch64-fuchsia-none
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")

Added: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=295480=auto
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (added)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Fri Feb 17 13:28:54 2017
@@ -0,0 +1,44 @@
+# This file sets up a CMakeCache for a Fuchsia toolchain build.
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+set(PACKAGE_VENDOR Fuchsia CACHE STRING "")
+
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
+
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
+if(NOT APPLE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
+set(CLANG_BOOTSTRAP_TARGETS
+  check-all
+  check-llvm
+  check-clang
+  llvm-config
+  test-suite
+  test-depends
+  llvm-test-depends
+  clang-test-depends
+  distribution
+  install-distribution
+  clang CACHE STRING "")
+
+if(FUCHSIA_SYSROOT)
+  set(EXTRA_ARGS -DFUCHSIA_SYSROOT=${FUCHSIA_SYSROOT})
+endif()
+
+# Setup the bootstrap build.
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+set(CLANG_BOOTSTRAP_CMAKE_ARGS
+  ${EXTRA_ARGS}
+  -C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
+  CACHE STRING "")


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


[PATCH] D30107: Make DynamicLibrary::getPermanentLibrary on Windows have a defined ordering.

2017-02-17 Thread Frederich Munch via Phabricator via cfe-commits
marsupial created this revision.

This is mostly affecting usage of the JIT...
When using DynamicLibrary::getPermanentLibrary(0,0) to get a list of the loaded 
libs, on Windows this is currently stored in a set which makes iteration 
unordered / undefined. Additionally there is a problem as newer Windows are 
using ucrt.dll for a lot of stdlib functions which cause a disagreement between 
the JIT and native code as to what the address and implementation of that 
function is:

JIT: putenv_s("TEST", "VALUE") calls msvcrt.dll, putenv_s
JIT: getenv("TEST") -> "VALUE" calls msvcrt.dll, getenv
BIN: getenv("TEST") -> NULL // calls ucrt.dll, getenv

The patch simply changes the way modules are loaded and stored to how Windows 
says they were.
Searches for symbols in reverse order so newer modules will override older ones.
And always tries to give priority to the process' symbols (what dlsym does I 
believe)


https://reviews.llvm.org/D30107

Files:
  lib/Support/Windows/DynamicLibrary.inc

Index: lib/Support/Windows/DynamicLibrary.inc
===
--- lib/Support/Windows/DynamicLibrary.inc
+++ lib/Support/Windows/DynamicLibrary.inc
@@ -12,16 +12,18 @@
 //===--===//
 
 #include "WindowsSupport.h"
+#include "llvm/ADT/iterator_range.h"
 
 #ifdef __MINGW32__
  #include 
 #else
- #include 
+ #include 
 #endif
 
 #ifdef _MSC_VER
  #include 
 #endif
+#include 
 
 namespace llvm {
 using namespace sys;
@@ -31,25 +33,9 @@
 //===  and must not be UNIX code.
 //===--===//
 
-typedef BOOL (WINAPI *fpEnumerateLoadedModules)(HANDLE,PENUMLOADED_MODULES_CALLBACK64,PVOID);
-static fpEnumerateLoadedModules fEnumerateLoadedModules;
-static DenseSet *OpenedHandles;
-
-static bool loadDebugHelp(void) {
-  HMODULE hLib = ::LoadLibraryW(L"Dbghelp.dll");
-  if (hLib) {
-fEnumerateLoadedModules = (fpEnumerateLoadedModules)
-  ::GetProcAddress(hLib, "EnumerateLoadedModules64");
-  }
-  return fEnumerateLoadedModules != 0;
-}
-
-static BOOL CALLBACK
-ELM_Callback(PCSTR ModuleName, DWORD64 ModuleBase,
- ULONG ModuleSize, PVOID UserContext) {
-  OpenedHandles->insert((HMODULE)ModuleBase);
-  return TRUE;
-}
+typedef std::vector ModuleHandles;
+static std::unique_ptr OpenedHandles;
+static bool KeepFront;
 
 DynamicLibrary DynamicLibrary::getPermanentLibrary(const char *filename,
std::string *errMsg) {
@@ -57,20 +43,58 @@
 
   if (!filename) {
 // When no file is specified, enumerate all DLLs and EXEs in the process.
-if (OpenedHandles == 0)
-  OpenedHandles = new DenseSet();
 
-if (!fEnumerateLoadedModules) {
-  if (!loadDebugHelp()) {
-assert(false && "These APIs should always be available");
+#ifdef _WIN64
+const DWORD Flags = LIST_MODULES_64BIT;
+#else
+const DWORD Flags = LIST_MODULES_32BIT;
+#endif
+
+DWORD Bytes;
+HMODULE Self = (HMODULE)GetCurrentProcess();
+if (!EnumProcessModulesEx(Self, nullptr, 0, , Flags)) {
+  MakeErrMsg(errMsg, "EnumProcessModulesEx failure");
+  return DynamicLibrary();
+}
+
+// Get the most recent list in case any modules added between calls.
+ModuleHandles Current;
+do {
+  assert(Bytes && ((Bytes % sizeof(HMODULE)) == 0) &&
+ "Should have at least one module and be aligned");
+  Current.resize(Bytes / sizeof(HMODULE));
+  if (!EnumProcessModulesEx(Self, Current.data(), Bytes, , Flags)) {
+MakeErrMsg(errMsg, "EnumProcessModulesEx failure");
 return DynamicLibrary();
   }
+} while (Bytes != (Current.size() * sizeof(HMODULE)));
+
+#ifndef NDEBUG
+if (OpenedHandles) {
+  auto Begin = Current.begin(), End = Current.end();
+  for (HMODULE Mod : *OpenedHandles) {
+assert((std::find(Begin, End, Mod) != End) &&
+   "Module in older list that is not in newer one");
+  }
 }
+#endif
+
+// Keep current process handle at top of list
+if (Current.size() > 1) {
+  Self = Current.front();
+  memmove(Current.data(), Current.data()+1, Bytes - sizeof(HMODULE));
+  Current.back() = Self;
+}
+KeepFront = true;
+
+if (!OpenedHandles)
+  OpenedHandles.reset(new ModuleHandles(std::move(Current)));
+else
+  OpenedHandles->swap(Current);
 
-fEnumerateLoadedModules(GetCurrentProcess(), ELM_Callback, 0);
 // Dummy library that represents "search all handles".
 // This is mostly to ensure that the return value still shows up as "valid".
-return DynamicLibrary();
+return DynamicLibrary(OpenedHandles.get());
   }
 
   SmallVector filenameUnicode;
@@ -79,7 +103,7 @@
 MakeErrMsg(errMsg, std::string(filename) + ": Can't convert to UTF-16");
 return DynamicLibrary();
   }
-  
+
   HMODULE a_handle = 

[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D29806



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


Re: r295473 - [OpenMP] Remove barriers at cancel and cancellation point

2017-02-17 Thread Hahnfeld, Jonas via cfe-commits
Hi Hans, Alexey,

can we merge this commit and r295474 for the 4.0 release or is it
already too late for that? I will totally understand that and can apply
these commits locally prior to installing.
However, I think that these changes are quite focussed and bear minimal
possibility of introducing regressions.

Thanks,
Jonas

Am Freitag, den 17.02.2017, 18:32 + schrieb Jonas Hahnfeld via cfe-
commits:
> Author: hahnfeld
> Date: Fri Feb 17 12:32:51 2017
> New Revision: 295473
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=295473=rev
> Log:
> [OpenMP] Remove barriers at cancel and cancellation point
> 
> This resolves a deadlock with the cancel directive when there is no explicit
> cancellation point. In that case, the implicit barrier acts as cancellation
> point. After removing the barrier after cancel, the now unmatched barrier for
> the explicit cancellation point has to go as well.
> 
> This has probably worked before rL255992: With the calls for the explicit
> barrier, it was sure that all threads passed a barrier before exiting.
> 
> Reported by Simon Convent and Joachim Protze!
> 
> Differential Revision: https://reviews.llvm.org/D30088
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/test/OpenMP/cancel_codegen.cpp
> cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295473=295472=295473=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Feb 17 12:32:51 2017
> @@ -4724,7 +4724,6 @@ void CGOpenMPRuntime::emitCancellationPo
>auto *Result = CGF.EmitRuntimeCall(
>createRuntimeFunction(OMPRTL__kmpc_cancellationpoint), Args);
>// if (__kmpc_cancellationpoint()) {
> -  //  __kmpc_cancel_barrier();
>//   exit from construct;
>// }
>auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
> @@ -4732,8 +4731,6 @@ void CGOpenMPRuntime::emitCancellationPo
>auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
>CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
>CGF.EmitBlock(ExitBB);
> -  // __kmpc_cancel_barrier();
> -  emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
>// exit from construct;
>auto CancelDest =
>CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
> @@ -4762,7 +4759,6 @@ void CGOpenMPRuntime::emitCancelCall(Cod
>auto *Result = CGF.EmitRuntimeCall(
>RT.createRuntimeFunction(OMPRTL__kmpc_cancel), Args);
>// if (__kmpc_cancel()) {
> -  //  __kmpc_cancel_barrier();
>//   exit from construct;
>// }
>auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
> @@ -4770,8 +4766,6 @@ void CGOpenMPRuntime::emitCancelCall(Cod
>auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
>CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
>CGF.EmitBlock(ExitBB);
> -  // __kmpc_cancel_barrier();
> -  RT.emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
>// exit from construct;
>auto CancelDest =
>CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
> 
> Modified: cfe/trunk/test/OpenMP/cancel_codegen.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancel_codegen.cpp?rev=295473=295472=295473=diff
> ==
> --- cfe/trunk/test/OpenMP/cancel_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/cancel_codegen.cpp Fri Feb 17 12:32:51 2017
> @@ -12,6 +12,8 @@ int main (int argc, char **argv) {
>  {
>  #pragma omp cancel parallel if(flag)
>argv[0][0] = argc;
> +#pragma omp barrier
> +  argv[0][0] += argc;
>  }
>  // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
> @__kmpc_fork_call(
>  #pragma omp sections
> @@ -20,7 +22,6 @@ int main (int argc, char **argv) {
>  }
>  // CHECK: call void @__kmpc_for_static_init_4(
>  // CHECK: call i32 @__kmpc_cancel(
> -// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
>  // CHECK: call void @__kmpc_for_static_fini(
>  // CHECK: call void @__kmpc_barrier(%ident_t*
>  #pragma omp sections
> @@ -36,7 +37,6 @@ int main (int argc, char **argv) {
>  // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
>  // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
>  // CHECK: [[EXIT]]
> -// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
>  // CHECK: br label
>  // CHECK: [[CONTINUE]]
>  // CHECK: br label
> @@ -44,7 +44,6 @@ int main (int argc, char **argv) {
>  // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
>  // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
>  // CHECK: [[EXIT]]
> -// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
>  // CHECK: br label
>  // 

[PATCH] D30091: [OpenMP] Fix cancellation point in task with no cancel

2017-02-17 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295474: [OpenMP] Fix cancellation point in task with no 
cancel (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D30091?vs=88878=88922#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30091

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp


Index: cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
===
--- cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
+++ cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
@@ -78,6 +78,12 @@
 }
 // CHECK: call i8* @__kmpc_omp_task_alloc(
 // CHECK: call i32 @__kmpc_omp_task(
+#pragma omp task
+{
+#pragma omp cancellation point taskgroup
+}
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+// CHECK: call i32 @__kmpc_omp_task(
 #pragma omp parallel sections
 {
   {
@@ -125,6 +131,15 @@
 // CHECK: [[RETURN]]
 // CHECK: ret i32 0
 
+// CHECK: define internal i32 @{{[^(]+}}(i32
+// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
{{[^,]+}}, i32 {{[^,]+}}, i32 4)
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
+// CHECK: [[EXIT]]
+// CHECK: br label %[[RETURN:.+]]
+// CHECK: [[RETURN]]
+// CHECK: ret i32 0
+
 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
{{[^,]+}}, i32 [[GTID:%.+]], i32 3)
Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4716,7 +4716,9 @@
   // global_tid, kmp_int32 cncl_kind);
   if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->hasCancel()) {
+// For 'cancellation point taskgroup', the task region info may not have a
+// cancel. This may instead happen in another adjacent task.
+if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
   CGF.Builder.getInt32(getCancellationKind(CancelRegion))};


Index: cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
===
--- cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
+++ cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
@@ -78,6 +78,12 @@
 }
 // CHECK: call i8* @__kmpc_omp_task_alloc(
 // CHECK: call i32 @__kmpc_omp_task(
+#pragma omp task
+{
+#pragma omp cancellation point taskgroup
+}
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+// CHECK: call i32 @__kmpc_omp_task(
 #pragma omp parallel sections
 {
   {
@@ -125,6 +131,15 @@
 // CHECK: [[RETURN]]
 // CHECK: ret i32 0
 
+// CHECK: define internal i32 @{{[^(]+}}(i32
+// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 4)
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
+// CHECK: [[EXIT]]
+// CHECK: br label %[[RETURN:.+]]
+// CHECK: [[RETURN]]
+// CHECK: ret i32 0
+
 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3)
Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4716,7 +4716,9 @@
   // global_tid, kmp_int32 cncl_kind);
   if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->hasCancel()) {
+// For 'cancellation point taskgroup', the task region info may not have a
+// cancel. This may instead happen in another adjacent task.
+if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
   CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295473 - [OpenMP] Remove barriers at cancel and cancellation point

2017-02-17 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Fri Feb 17 12:32:51 2017
New Revision: 295473

URL: http://llvm.org/viewvc/llvm-project?rev=295473=rev
Log:
[OpenMP] Remove barriers at cancel and cancellation point

This resolves a deadlock with the cancel directive when there is no explicit
cancellation point. In that case, the implicit barrier acts as cancellation
point. After removing the barrier after cancel, the now unmatched barrier for
the explicit cancellation point has to go as well.

This has probably worked before rL255992: With the calls for the explicit
barrier, it was sure that all threads passed a barrier before exiting.

Reported by Simon Convent and Joachim Protze!

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/cancel_codegen.cpp
cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295473=295472=295473=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Feb 17 12:32:51 2017
@@ -4724,7 +4724,6 @@ void CGOpenMPRuntime::emitCancellationPo
   auto *Result = CGF.EmitRuntimeCall(
   createRuntimeFunction(OMPRTL__kmpc_cancellationpoint), Args);
   // if (__kmpc_cancellationpoint()) {
-  //  __kmpc_cancel_barrier();
   //   exit from construct;
   // }
   auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
@@ -4732,8 +4731,6 @@ void CGOpenMPRuntime::emitCancellationPo
   auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
   CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
   CGF.EmitBlock(ExitBB);
-  // __kmpc_cancel_barrier();
-  emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
   // exit from construct;
   auto CancelDest =
   CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
@@ -4762,7 +4759,6 @@ void CGOpenMPRuntime::emitCancelCall(Cod
   auto *Result = CGF.EmitRuntimeCall(
   RT.createRuntimeFunction(OMPRTL__kmpc_cancel), Args);
   // if (__kmpc_cancel()) {
-  //  __kmpc_cancel_barrier();
   //   exit from construct;
   // }
   auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
@@ -4770,8 +4766,6 @@ void CGOpenMPRuntime::emitCancelCall(Cod
   auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
   CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
   CGF.EmitBlock(ExitBB);
-  // __kmpc_cancel_barrier();
-  RT.emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
   // exit from construct;
   auto CancelDest =
   CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());

Modified: cfe/trunk/test/OpenMP/cancel_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancel_codegen.cpp?rev=295473=295472=295473=diff
==
--- cfe/trunk/test/OpenMP/cancel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/cancel_codegen.cpp Fri Feb 17 12:32:51 2017
@@ -12,6 +12,8 @@ int main (int argc, char **argv) {
 {
 #pragma omp cancel parallel if(flag)
   argv[0][0] = argc;
+#pragma omp barrier
+  argv[0][0] += argc;
 }
 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) 
@__kmpc_fork_call(
 #pragma omp sections
@@ -20,7 +22,6 @@ int main (int argc, char **argv) {
 }
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: call i32 @__kmpc_cancel(
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_barrier(%ident_t*
 #pragma omp sections
@@ -36,7 +37,6 @@ int main (int argc, char **argv) {
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -44,7 +44,6 @@ int main (int argc, char **argv) {
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -62,7 +61,6 @@ for (int i = 0; i < argc; ++i) {
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -109,9 +107,10 @@ for (int i = 0; i < argc; ++i) {
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label %[[RETURN:.+]]
 // CHECK: 

[PATCH] D30088: [OpenMP] Remove barriers at cancel and cancellation point

2017-02-17 Thread Jonas Hahnfeld via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295473: [OpenMP] Remove barriers at cancel and cancellation 
point (authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D30088?vs=88872=88921#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30088

Files:
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/test/OpenMP/cancel_codegen.cpp
  cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp

Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4724,16 +4724,13 @@
   auto *Result = CGF.EmitRuntimeCall(
   createRuntimeFunction(OMPRTL__kmpc_cancellationpoint), Args);
   // if (__kmpc_cancellationpoint()) {
-  //  __kmpc_cancel_barrier();
   //   exit from construct;
   // }
   auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
   auto *ContBB = CGF.createBasicBlock(".cancel.continue");
   auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
   CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
   CGF.EmitBlock(ExitBB);
-  // __kmpc_cancel_barrier();
-  emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
   // exit from construct;
   auto CancelDest =
   CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
@@ -4762,16 +4759,13 @@
   auto *Result = CGF.EmitRuntimeCall(
   RT.createRuntimeFunction(OMPRTL__kmpc_cancel), Args);
   // if (__kmpc_cancel()) {
-  //  __kmpc_cancel_barrier();
   //   exit from construct;
   // }
   auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
   auto *ContBB = CGF.createBasicBlock(".cancel.continue");
   auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
   CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
   CGF.EmitBlock(ExitBB);
-  // __kmpc_cancel_barrier();
-  RT.emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
   // exit from construct;
   auto CancelDest =
   CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
Index: cfe/trunk/test/OpenMP/cancel_codegen.cpp
===
--- cfe/trunk/test/OpenMP/cancel_codegen.cpp
+++ cfe/trunk/test/OpenMP/cancel_codegen.cpp
@@ -12,15 +12,16 @@
 {
 #pragma omp cancel parallel if(flag)
   argv[0][0] = argc;
+#pragma omp barrier
+  argv[0][0] += argc;
 }
 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
 #pragma omp sections
 {
 #pragma omp cancel sections
 }
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: call i32 @__kmpc_cancel(
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_barrier(%ident_t*
 #pragma omp sections
@@ -36,15 +37,13 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -62,7 +61,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -109,9 +107,10 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label %[[RETURN:.+]]
 // CHECK: [[ELSE]]
+// The barrier directive should now call __kmpc_cancel_barrier
+// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[RETURN]]
 // CHECK: ret void
@@ -121,15 +120,13 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label %[[RETURN:.+]]
 // CHECK: [[RETURN]]
 // CHECK: ret i32 0
 
 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: call i32 @__kmpc_cancel(
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
@@ -139,15 +136,13 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 

r295474 - [OpenMP] Fix cancellation point in task with no cancel

2017-02-17 Thread Jonas Hahnfeld via cfe-commits
Author: hahnfeld
Date: Fri Feb 17 12:32:58 2017
New Revision: 295474

URL: http://llvm.org/viewvc/llvm-project?rev=295474=rev
Log:
[OpenMP] Fix cancellation point in task with no cancel

With tasks, the cancel may happen in another task. This has a different
region info which means that we can't find it here.

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

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=295474=295473=295474=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Feb 17 12:32:58 2017
@@ -4716,7 +4716,9 @@ void CGOpenMPRuntime::emitCancellationPo
   // global_tid, kmp_int32 cncl_kind);
   if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->hasCancel()) {
+// For 'cancellation point taskgroup', the task region info may not have a
+// cancel. This may instead happen in another adjacent task.
+if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
   CGF.Builder.getInt32(getCancellationKind(CancelRegion))};

Modified: cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp?rev=295474=295473=295474=diff
==
--- cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/cancellation_point_codegen.cpp Fri Feb 17 12:32:58 
2017
@@ -78,6 +78,12 @@ for (int i = 0; i < argc; ++i) {
 }
 // CHECK: call i8* @__kmpc_omp_task_alloc(
 // CHECK: call i32 @__kmpc_omp_task(
+#pragma omp task
+{
+#pragma omp cancellation point taskgroup
+}
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+// CHECK: call i32 @__kmpc_omp_task(
 #pragma omp parallel sections
 {
   {
@@ -118,6 +124,15 @@ for (int i = 0; i < argc; ++i) {
 
 // CHECK: define internal i32 @{{[^(]+}}(i32
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
{{[^,]+}}, i32 {{[^,]+}}, i32 4)
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
+// CHECK: [[EXIT]]
+// CHECK: br label %[[RETURN:.+]]
+// CHECK: [[RETURN]]
+// CHECK: ret i32 0
+
+// CHECK: define internal i32 @{{[^(]+}}(i32
+// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
{{[^,]+}}, i32 {{[^,]+}}, i32 4)
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
 // CHECK: [[EXIT]]


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


[PATCH] D30087: [Driver] Unify linking of OpenMP runtime

2017-02-17 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/Tools.cpp:8683
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
-addOpenMPRuntime(CmdArgs, getToolChain(), Args);
+addOpenMPRuntime(CmdArgs, getToolChain(), Args, JA);
 

pirama wrote:
> `addOpenMPRuntime` would add `-lomptarget` even for this call if JA satisfies 
> the newly added check.  That's a deviation from exisiting behavior.  Am I 
> missing some invariant here where `JobAction`s along this path don't have an 
> offloading action?
Right, as I noted in the summary: `This enables libomptarget for Darwin, 
FreeBSD and NetBSD`

I don't see a problem with that, it's rather an inconsistency in the current 
code.


https://reviews.llvm.org/D30087



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


[PATCH] D29692: [clang-tidy] add check modernize-use-const-instead-of-define

2017-02-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D29692#676559, @AlexanderLanin wrote:

> Thanks for the feedback. As I'm new to this I cannot say whether checking 
> only the file in question fits better with clang-tidy’s policy or not.
>  Also, I’m not sure about ODR. Of course, it’s a possibility, but isn’t the 
> programmer responsible for that? This will be more of an issue as soon as 
> this check provides a Fix-It solution.


It's still an issue without the FixIt because the diagnostic guides the user to 
do something that may make their well-formed code into ill-formed (no 
diagnostic required!) code. I think the correct way to handle this is to ensure 
we don't diagnose macro definitions that exist in a header file, at least for 
C++ code.

> As for the other part, I've checked some guidelines (without any order or 
> selection process)
>  MISRA C++: Don’t use `#define`, use `const` variables; Also don’t do math on 
> enums
>  CppCoreGuidelines: Don’t use `#define`, use `constexpr` variables 
>  SEI CERT C++: No mention of `#define` as far as I can tell
>  JSF AV C++: Don’t use `#define`, use `const` variables
>  HIC++: Don’t use `#define`, use `const` objects (reference to JSF AV C++ and 
> MISRA C++)
> 
> So basically they're all the same. The only question is `const` vs `constexpr`

I don't think the guidance in this check is incorrect, I just think the check 
is implemented too broadly. As for 'const' vs 'constexpr', such a decision may 
differ when compiling in C vs C++ mode.


https://reviews.llvm.org/D29692



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


[clang-tools-extra] r295471 - [Docs] 'Limitations' should be a subsection

2017-02-17 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Feb 17 12:11:08 2017
New Revision: 295471

URL: http://llvm.org/viewvc/llvm-project?rev=295471=rev
Log:
[Docs] 'Limitations' should be a subsection

The 'Limitations' section in thedocumentation for
readability-misleading-indentation should be a subsection, as otherwise the link
to 'Limitations' isn't indented in the 'Clang-Tidy Checks' documentation page.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-misleading-indentation.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-misleading-indentation.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-misleading-indentation.rst?rev=295471=295470=295471=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-misleading-indentation.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-misleading-indentation.rst
 Fri Feb 17 12:11:08 2017
@@ -32,7 +32,7 @@ Examples:
 foo2();  // Not guarded by if(cond1).
 
 Limitations
-===
+---
 
 Note that this check only works as expected when the tabs or spaces are used
 consistently and not mixed.


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


[PATCH] D30087: [Driver] Unify linking of OpenMP runtime

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Driver/Tools.cpp:8683
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
-addOpenMPRuntime(CmdArgs, getToolChain(), Args);
+addOpenMPRuntime(CmdArgs, getToolChain(), Args, JA);
 

`addOpenMPRuntime` would add `-lomptarget` even for this call if JA satisfies 
the newly added check.  That's a deviation from exisiting behavior.  Am I 
missing some invariant here where `JobAction`s along this path don't have an 
offloading action?


https://reviews.llvm.org/D30087



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


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2017-02-17 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hello Zoltan. Sorry, I'm a bit busy now. Here are my thoughts about the design.

1. I think we should not add new warnings to GenericTaintChecker. Instead, it 
is better to move warnings out of it.  After that it will become just a plugin 
used by other checkers. Such split will make it cleaner because we avoid mixing 
taint propagating logic and checks. It is not an item for this patch, of 
course. This new checker follows my preferences in this part.
2. For me, taint-related check for array index in this checker and in 
ArrayBoundCheckerV2 look almost the same if the offset is known (with just a 
single difference). However, in case of tainted check we can be less 
conservative so approach used in this checker when a warning is emitted even if 
base region or offset are unknown looks better for me. I think we should remove 
tainted check from ArrayBoundV2 and leave it in this new checker. But this 
causes a situation where out-of-bound check is not done in checker intended for 
this.  A possible solution here is to move array-related logic of DirtyScalar 
to a separate checker that is enabled when ArrayBound or DirtyScalar are 
enabled. Zoltán, could you confirm that your checker emits same warnings on 
ArrayBoundChecker test cases with taint?

Anna, what's your opinion? Did I miss something?




Comment at: lib/StaticAnalyzer/Checkers/DirtyScalarChecker.cpp:184
+Ty = Ctx.IntTy;
+  if (!Ty->isIntegerType() || Ctx.getIntWidth(Ty) <= TooNarrowForBoundCheck)
+return false;

Does the second check means that we exclude boolean and char values? I cannot 
find any reason to do it for chars.


https://reviews.llvm.org/D27753



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


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-17 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2478
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();

EricWF wrote:
> I'll put this in alphabetical order before committing. 
Reuse the Type::Auto case here rather than duplicating it. (You'll need to 
change its AutoType to the DeducedType common base class.)


https://reviews.llvm.org/D30082



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


r295466 - Rename DiagnosticInfoWithDebugLoc to WithLocation to match LLVM

2017-02-17 Thread Justin Bogner via cfe-commits
Author: bogner
Date: Fri Feb 17 11:34:49 2017
New Revision: 295466

URL: http://llvm.org/viewvc/llvm-project?rev=295466=rev
Log:
Rename DiagnosticInfoWithDebugLoc to WithLocation to match LLVM

Updates for llvm r295465.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=295466=295465=295466=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Feb 17 11:34:49 2017
@@ -287,7 +287,7 @@ namespace clang {
 /// Get the best possible source location to represent a diagnostic that
 /// may have associated debug info.
 const FullSourceLoc
-getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithDebugLocBase ,
+getBestLocationFromDebugLoc(const llvm::DiagnosticInfoWithLocationBase ,
 bool , StringRef ,
 unsigned , unsigned ) const;
 
@@ -488,8 +488,8 @@ BackendConsumer::StackSizeDiagHandler(co
 }
 
 const FullSourceLoc BackendConsumer::getBestLocationFromDebugLoc(
-const llvm::DiagnosticInfoWithDebugLocBase , bool , 
StringRef ,
-unsigned , unsigned ) const {
+const llvm::DiagnosticInfoWithLocationBase , bool ,
+StringRef , unsigned , unsigned ) const {
   SourceManager  = Context->getSourceManager();
   FileManager  = SourceMgr.getFileManager();
   SourceLocation DILoc;


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


[PATCH] D29967: Get class property selectors from property decl if it exists

2017-02-17 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Ah, I had missed the `-verify` option on the test.  Yes, that makes sense.  
Ternary may have flowed the conditional code better.  Do you need someone to 
commit this on your behalf?


https://reviews.llvm.org/D29967



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: test/Driver/arch-specific-libdir-rpath.c:18
+//
+// CHECK-ARCHDIR: 
-L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" 
{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir

Hahnfeld wrote:
> Can you split that into two lines? Then it won't fail if there is some 
> argument added in between
Splitting into two lines makes FileCheck eagerly match the arch-subdir and 
-rpath into the {{.*}} next to the "-L".  This causes the check for -rpath to 
fail.

The test accepts intermediate arguments because of the wildcard right after the 
-L...Inputs/...


https://reviews.llvm.org/D30015



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


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2017-02-17 Thread Zoltán Gera via Phabricator via cfe-commits
gerazo added a comment.

Hi, did you have time to check my changes?


https://reviews.llvm.org/D27753



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-17 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

Hello again. Just wondering if anyone could take a look at this? I updated the 
patch a week ago :) Thanks!


https://reviews.llvm.org/D29221



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


[PATCH] D30032: Process attributes 'ifunc' and 'alias' when checking for redefinition

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

LGTM


https://reviews.llvm.org/D30032



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


[PATCH] D6550: ASTImporter: Fix missing SourceLoc imports

2017-02-17 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

This patch lacks tests. If you add at least minimal test case (I'm not familiar 
with ObjC and its front-end, unfortunately), I will no have any concerns. Also 
adding Sean.


https://reviews.llvm.org/D6550



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


[PATCH] D6549: ASTImporter: Propagate implicit flag to imported record and field decls

2017-02-17 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D6549#662955, @a.sidorin wrote:

> This should be fixed in r269693.


Indeed, I commandeer than abandon this revision so it is closed.


https://reviews.llvm.org/D6549



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


[PATCH] D6550: ASTImporter: Fix missing SourceLoc imports

2017-02-17 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D6550#663002, @a.sidorin wrote:

> Hi Gabor. One of the bugs fixed in this patch is still present in master, 
> other two are already fixed.


Thanks for checking that! Do you think it is ok for me to commit the missing 
part?


https://reviews.llvm.org/D6550



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


[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Ehsan Akhgari via Phabricator via cfe-commits
ehsan updated this revision to Diff 88879.
ehsan added a comment.

Addressed the review comments.


https://reviews.llvm.org/D29806

Files:
  clang-tidy/tool/clang-tidy-diff.py
  test/clang-tidy/clang-tidy-diff.cpp


Index: test/clang-tidy/clang-tidy-diff.cpp
===
--- test/clang-tidy/clang-tidy-diff.cpp
+++ test/clang-tidy/clang-tidy-diff.cpp
@@ -2,6 +2,9 @@
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | 
FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck 
-check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 
%t.cpp", "file": "%t.cpp"}]' > 
%T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff 
-checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | 
FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}
Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -55,6 +55,8 @@
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-path', dest='build_path',
+  help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -124,6 +126,8 @@
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
+  if args.build_path is not None:
+command.append('-p=%s' % args.build_path)
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)


Index: test/clang-tidy/clang-tidy-diff.cpp
===
--- test/clang-tidy/clang-tidy-diff.cpp
+++ test/clang-tidy/clang-tidy-diff.cpp
@@ -2,6 +2,9 @@
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 // RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 %t.cpp", "file": "%t.cpp"}]' > %T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}
Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -55,6 +55,8 @@
   help='checks filter, when not specified, use clang-tidy '
   'default',
   default='')
+  parser.add_argument('-path', dest='build_path',
+  help='Path used to read a compile command database.')
   parser.add_argument('-extra-arg', dest='extra_arg',
   action='append', default=[],
   help='Additional argument to append to the compiler '
@@ -124,6 +126,8 @@
 command.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
 command.append('-quiet')
+  if args.build_path is not None:
+command.append('-p=%s' % args.build_path)
   command.extend(lines_by_file.keys())
   for arg in args.extra_arg:
   command.append('-extra-arg=%s' % arg)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30091: [OpenMP] Fix cancellation point in task with no cancel

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

With tasks, the cancel may happen in another task. This has a different
region info which means that we can't find it here.


https://reviews.llvm.org/D30091

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/cancellation_point_codegen.cpp


Index: test/OpenMP/cancellation_point_codegen.cpp
===
--- test/OpenMP/cancellation_point_codegen.cpp
+++ test/OpenMP/cancellation_point_codegen.cpp
@@ -78,6 +78,12 @@
 }
 // CHECK: call i8* @__kmpc_omp_task_alloc(
 // CHECK: call i32 @__kmpc_omp_task(
+#pragma omp task
+{
+#pragma omp cancellation point taskgroup
+}
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+// CHECK: call i32 @__kmpc_omp_task(
 #pragma omp parallel sections
 {
   {
@@ -125,6 +131,15 @@
 // CHECK: [[RETURN]]
 // CHECK: ret i32 0
 
+// CHECK: define internal i32 @{{[^(]+}}(i32
+// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
{{[^,]+}}, i32 {{[^,]+}}, i32 4)
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
+// CHECK: [[EXIT]]
+// CHECK: br label %[[RETURN:.+]]
+// CHECK: [[RETURN]]
+// CHECK: ret i32 0
+
 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* 
{{[^,]+}}, i32 [[GTID:%.+]], i32 3)
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4713,7 +4713,9 @@
   // global_tid, kmp_int32 cncl_kind);
   if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->hasCancel()) {
+// For 'cancellation point taskgroup', the task region info may not have a
+// cancel. This may instead happen in another adjacent task.
+if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
   CGF.Builder.getInt32(getCancellationKind(CancelRegion))};


Index: test/OpenMP/cancellation_point_codegen.cpp
===
--- test/OpenMP/cancellation_point_codegen.cpp
+++ test/OpenMP/cancellation_point_codegen.cpp
@@ -78,6 +78,12 @@
 }
 // CHECK: call i8* @__kmpc_omp_task_alloc(
 // CHECK: call i32 @__kmpc_omp_task(
+#pragma omp task
+{
+#pragma omp cancellation point taskgroup
+}
+// CHECK: call i8* @__kmpc_omp_task_alloc(
+// CHECK: call i32 @__kmpc_omp_task(
 #pragma omp parallel sections
 {
   {
@@ -125,6 +131,15 @@
 // CHECK: [[RETURN]]
 // CHECK: ret i32 0
 
+// CHECK: define internal i32 @{{[^(]+}}(i32
+// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 {{[^,]+}}, i32 4)
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
+// CHECK: [[EXIT]]
+// CHECK: br label %[[RETURN:.+]]
+// CHECK: [[RETURN]]
+// CHECK: ret i32 0
+
 // CHECK: define internal void @{{[^(]+}}(i32* {{[^,]+}}, i32* {{[^,]+}})
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID:%.+]], i32 3)
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4713,7 +4713,9 @@
   // global_tid, kmp_int32 cncl_kind);
   if (auto *OMPRegionInfo =
   dyn_cast_or_null(CGF.CapturedStmtInfo)) {
-if (OMPRegionInfo->hasCancel()) {
+// For 'cancellation point taskgroup', the task region info may not have a
+// cancel. This may instead happen in another adjacent task.
+if (CancelRegion == OMPD_taskgroup || OMPRegionInfo->hasCancel()) {
   llvm::Value *Args[] = {
   emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
   CGF.Builder.getInt32(getCancellationKind(CancelRegion))};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30088: [OpenMP] Remove barriers at cancel and cancellation point

2017-02-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D30088



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


[PATCH] D27810: FileManager: mark virtual file entries as valid entries

2017-02-17 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv updated this revision to Diff 88874.
erikjv retitled this revision from "Normalize all filenames before searching 
FileManager caches" to "FileManager: mark virtual file entries as valid 
entries".
erikjv edited the summary of this revision.

https://reviews.llvm.org/D27810

Files:
  lib/Basic/FileManager.cpp


Index: lib/Basic/FileManager.cpp
===
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -386,6 +386,7 @@
   UFE->ModTime = ModificationTime;
   UFE->Dir = DirInfo;
   UFE->UID = NextFileUID++;
+  UFE->IsValid = true;
   UFE->File.reset();
   return UFE;
 }


Index: lib/Basic/FileManager.cpp
===
--- lib/Basic/FileManager.cpp
+++ lib/Basic/FileManager.cpp
@@ -386,6 +386,7 @@
   UFE->ModTime = ModificationTime;
   UFE->Dir = DirInfo;
   UFE->UID = NextFileUID++;
+  UFE->IsValid = true;
   UFE->File.reset();
   return UFE;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30082: Fix assertion when generating debug information for deduced template specialization types.

2017-02-17 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2478
   break;
+case Type::DeducedTemplateSpecialization: {
+  QualType DT = cast(T)->getDeducedType();

I'll put this in alphabetical order before committing. 


https://reviews.llvm.org/D30082



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


[PATCH] D30002: [clang-tidy] Fix handling of methods with try-statement as a body in modernize-use-override

2017-02-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D30002



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


[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-17 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D29806#673489, @ehsan wrote:

> In https://reviews.llvm.org/D29806#673329, @alexfh wrote:
>
> > What's your use case? Can it be addressed by just forwarding the -p flag to 
> > clang-tidy?
>
>
> I just need to pass the full path to the compilation DB to clang-tidy.  The 
> problem is that invoking `clang-tidy-diff.py -- -p PATH` will run `clang-tidy 
> -- -p PATH`, in order words adding -p to the compiler command line, not 
> clang-tidy's.


I meant adding -p flag to the script and forwarding it to clang-tidy the same 
way as -quiet, -checks, etc. But there's already -p flag with a different 
meaning, so calling the new flag -path makes sense. I would still just forward 
it, if it's present.

>> The script shouldn't know anything about implementation details of the 
>> compilation database being used (since it can be something other than JSON 
>> compilation database).
> 
> I copied the code to look for the DB verbatim from run-clang-tidy.py.  I 
> personally don't need the search logic, and just tried to keep this 
> consistent with run-clang-tidy.py.  I'd be happy to remove the search logic 
> if you prefer that.

I see. I guess, this is needed as an optimization or something like that. Not 
useful for clang-tidy-diff.py.




Comment at: clang-tidy/tool/clang-tidy-diff.py:35-45
+def find_compilation_database(path):
+  """Adjusts the directory until a compilation database is found."""
+  result = './'
+  while not os.path.isfile(os.path.join(result, path)):
+if os.path.realpath(result) == '/':
+  print 'Error: could not find compilation database.'
+  sys.exit(1)

Let's remove this.



Comment at: clang-tidy/tool/clang-tidy-diff.py:90-97
+  db_path = 'compile_commands.json'
+
+  if args.build_path is not None:
+build_path = args.build_path
+  else:
+# Find our database
+build_path = find_compilation_database(db_path)

Let's remove this.



Comment at: clang-tidy/tool/clang-tidy-diff.py:149
 command.append('-quiet')
+  command.append('-p=%s' % build_path)
   command.extend(lines_by_file.keys())

Let's only add this flag when `args.build_path is not None`.


https://reviews.llvm.org/D29806



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


[PATCH] D30088: [OpenMP] Remove barriers at cancel and cancellation point

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

This resolves a deadlock with the cancel directive when there is no explicit
cancellation point. In that case, the implicit barrier acts as cancellation
point. After removing the barrier after cancel, the now unmatched barrier for
the explicit cancellation point has to go as well.

This has probably worked before https://reviews.llvm.org/rL255992: With the 
calls for the explicit
barrier, it was sure that all threads passed a barrier before exiting.

Reported by Simon Convent and Joachim Protze!


https://reviews.llvm.org/D30088

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/cancel_codegen.cpp
  test/OpenMP/cancellation_point_codegen.cpp

Index: test/OpenMP/cancellation_point_codegen.cpp
===
--- test/OpenMP/cancellation_point_codegen.cpp
+++ test/OpenMP/cancellation_point_codegen.cpp
@@ -26,7 +26,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -46,15 +45,13 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -69,7 +66,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -116,7 +112,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label %[[RETURN:.+]]
 // CHECK: [[RETURN]]
 // CHECK: ret void
@@ -126,7 +121,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,]+]],
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label %[[RETURN:.+]]
 // CHECK: [[RETURN]]
 // CHECK: ret i32 0
@@ -137,7 +131,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -150,15 +143,13 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancellationpoint(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
@@ -171,7 +162,6 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
Index: test/OpenMP/cancel_codegen.cpp
===
--- test/OpenMP/cancel_codegen.cpp
+++ test/OpenMP/cancel_codegen.cpp
@@ -12,15 +12,16 @@
 {
 #pragma omp cancel parallel if(flag)
   argv[0][0] = argc;
+#pragma omp barrier
+  argv[0][0] += argc;
 }
 // CHECK: call void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
 #pragma omp sections
 {
 #pragma omp cancel sections
 }
 // CHECK: call void @__kmpc_for_static_init_4(
 // CHECK: call i32 @__kmpc_cancel(
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: call void @__kmpc_barrier(%ident_t*
 #pragma omp sections
@@ -36,15 +37,13 @@
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
 // CHECK: [[EXIT]]
-// CHECK: call i32 @__kmpc_cancel_barrier(%ident_t*
 // CHECK: br label
 // CHECK: [[CONTINUE]]
 // CHECK: br label
 // CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
 // CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
 // CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label 

[PATCH] D30087: [Driver] Unify linking of OpenMP runtime

2017-02-17 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Herald added a subscriber: emaste.

This enables libomptarget for Darwin, FreeBSD and NetBSD, NFCI otherwise.
While at it, extend test for FreeBSD and check for -lrt iff on Linux.


https://reviews.llvm.org/D30087

Files:
  lib/Driver/Tools.cpp
  test/Driver/fopenmp.c

Index: test/Driver/fopenmp.c
===
--- test/Driver/fopenmp.c
+++ test/Driver/fopenmp.c
@@ -18,29 +18,33 @@
 // CHECK-CC1-NO-OPENMP-NOT: "-fopenmp"
 //
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
-// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP
+// RUN: %clang -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-RT
 // RUN: %clang -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-linux-gnu -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
 //
 // RUN: %clang -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
-// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP
+// RUN: %clang -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
 // RUN: %clang -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
 // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-darwin -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
 //
-// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
-// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP
-// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
+// RUN: %clang -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
+// RUN: %clang -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
+// RUN: %clang -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
 //
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-freebsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
 //
+// RUN: %clang -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-OMP
+// RUN: %clang -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-GOMP --check-prefix=CHECK-LD-GOMP-NO-RT
+// RUN: %clang -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-LD-IOMP5
+//
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libgomp %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-GOMP
 // RUN: %clang -nostdlib -target x86_64-netbsd -fopenmp=libiomp5 %s -o %t -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-IOMP5
@@ -50,6 +54,8 @@
 //
 // CHECK-LD-GOMP: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-GOMP: "-lgomp"
+// CHECK-LD-GOMP-RT: "-lrt"
+// CHECK-LD-GOMP-NO-RT-NOT: "-lrt"
 //
 // CHECK-LD-IOMP5: "{{.*}}ld{{(.exe)?}}"
 // CHECK-LD-IOMP5: "-liomp5"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3254,26 +3254,37 @@
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 }
 
-static void addOpenMPRuntime(ArgStringList , const ToolChain ,
-  const ArgList ) {
+// Returns true, if an OpenMP runtime has been added.
+static bool addOpenMPRuntime(ArgStringList , const ToolChain ,
+ const ArgList 

r295437 - clang-format: Don't remove existing spaces between identifier and ::.

2017-02-17 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Feb 17 04:44:07 2017
New Revision: 295437

URL: http://llvm.org/viewvc/llvm-project?rev=295437=rev
Log:
clang-format: Don't remove existing spaces between identifier and ::.

This can lead to bad behavior with macros that are used to annotate
functions (e.g. ALWAYS_INLINE).

Before, this:
  ALWAYS_INLINE ::std::string getName() ...

was turned into:
  ALWAYS_INLINE::std::string getName() ...

If it turns out that clang-format is failing to clean up a lot of the
existing spaces now, we can add more analyses of the identifier. It
should not currently. Cases where clang-format breaks nested name
specifiers should be fine as clang-format wraps after the "::". Thus, a
line getting longer and then shorter again should lead to the same
original code.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=295437=295436=295437=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Feb 17 04:44:07 2017
@@ -2343,12 +2343,16 @@ bool TokenAnnotator::spaceRequiredBefore
   if (!Style.SpaceBeforeAssignmentOperators &&
   Right.getPrecedence() == prec::Assignment)
 return false;
+  if (Right.is(tok::coloncolon) && Left.is(tok::identifier))
+// Generally don't remove existing spaces between an identifier and "::".
+// The identifier might actually be a macro name such as ALWAYS_INLINE. If
+// this turns out to be too lenient, add analysis of the identifier itself.
+return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd();
   if (Right.is(tok::coloncolon) && !Left.isOneOf(tok::l_brace, tok::comment))
 return (Left.is(TT_TemplateOpener) &&
 Style.Standard == FormatStyle::LS_Cpp03) ||
-   !(Left.isOneOf(tok::identifier, tok::l_paren, tok::r_paren,
-  tok::l_square) ||
- Left.isOneOf(TT_TemplateCloser, TT_TemplateOpener));
+   !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
+  TT_TemplateCloser, TT_TemplateOpener));
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
   if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=295437=295436=295437=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Feb 17 04:44:07 2017
@@ -139,6 +139,8 @@ TEST_F(FormatTest, NestedNameSpecifiers)
   verifyFormat("::ns::SomeFunction(::ns::SomeOtherFunction())");
   verifyFormat("static constexpr bool Bar = decltype(bar())::value;");
   verifyFormat("bool a = 2 < ::SomeFunction();");
+  verifyFormat("ALWAYS_INLINE ::std::string getName();");
+  verifyFormat("some::string getName();");
 }
 
 TEST_F(FormatTest, OnlyGeneratesNecessaryReplacements) {


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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/Tools.cpp:3267
+  if (llvm::sys::fs::is_directory(CandidateLibPath))
+CmdArgs.push_back(Args.MakeArgString("-L" + CandidateLibPath));
+

pirama wrote:
> mgorny wrote:
> > Don't you also need rpath for it? Or is this purely for static runtime?
> I am doing this for a cross-compiling toolchain (Android NDK) where the 
> actual rpath is not valid at runtime.  The runtime is packaged with the 
> application and made available to the loader behind the scenes.
> 
> That said, I don't think providing an rpath doesn't hurt.  I'll wait for 
> input from @cbergstrom and OpenMP folks to see if this'd be useful.
@cbergstrom says: 'let them know that your comments are equivalent (or better) 
than mine'. But yeah, PathScale's adding rpaths for the libraries on our end, 
so this is consistent with what we do.


https://reviews.llvm.org/D30015



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


[PATCH] D30015: Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88865.
pirama marked an inline comment as done.
pirama added a comment.

Add arch name to -rpath test.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,52 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR-i386: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// CHECK-ARCHDIR-x86_64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-ARCHDIR-arm: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// CHECK-ARCHDIR-aarch64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,20 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir

[PATCH] D30015: [OpenMP] Add arch-specific directory to search path

2017-02-17 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama updated this revision to Diff 88864.
pirama added a comment.

Fix typo.


https://reviews.llvm.org/D30015

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/Tools.cpp
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/arm/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/i386/.keep
  test/Driver/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64/.keep
  test/Driver/arch-specific-libdir-rpath.c
  test/Driver/arch-specific-libdir.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -392,6 +392,10 @@
 if config.host_triple == config.target_triple:
 config.available_features.add("native")
 
+# Test Driver/arch-specific-libdir-rpath.c is restricted to x86_64-linux
+if re.match(r'^x86_64.*-linux', config.target_triple):
+config.available_features.add("x86_64-linux")
+
 # Case-insensitive file system
 def is_filesystem_case_insensitive():
 handle, path = tempfile.mkstemp(prefix='case-test', dir=config.test_exec_root)
Index: test/Driver/arch-specific-libdir.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir.c
@@ -0,0 +1,52 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the search path.
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i386-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-i386 %s
+//
+// RUN: %clang %s -### 2>&1 -target i686-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-x86_64 %s
+//
+// RUN: %clang %s -### 2>&1 -target x86_64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-arm %s
+//
+// RUN: %clang %s -### 2>&1 -target arm-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR-aarch64 %s
+//
+// RUN: %clang %s -### 2>&1 -target aarch64-unknown-linux \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR-i386: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/i386
+// CHECK-ARCHDIR-x86_64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/x86_64
+// CHECK-ARCHDIR-arm: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/arm
+// CHECK-ARCHDIR-aarch64: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux/aarch64
+//
+// Have a stricter check for no-archdir - that the driver doesn't add any
+// subdirectory from the provided resource directory.
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
Index: test/Driver/arch-specific-libdir-rpath.c
===
--- /dev/null
+++ test/Driver/arch-specific-libdir-rpath.c
@@ -0,0 +1,20 @@
+// Test that the driver adds an arch-specific subdirectory in
+// {RESOURCE_DIR}/lib/linux to the linker search path and to '-rpath' for native
+// compilations.
+//
+// -rpath only gets added during native compilation.  To keep the test simple,
+// just test for x86_64-linux native compilation.
+// REQUIRES: x86_64-linux
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARCHDIR %s
+//
+// RUN: %clang %s -### 2>&1 \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-ARCHDIR %s
+//
+//
+// CHECK-ARCHDIR: -L{{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux{{.*}} "-rpath" {{.*}}/Inputs/resource_dir_with_arch_subdir/lib/linux
+// CHECK-NO-ARCHDIR-NOT: -L{{.*}}Inputs/resource_dir
+// CHECK-NO-ARCHDIR-NOT: "-rpath" {{.*}}/Inputs/resource_dir
Index: lib/Driver/Tools.cpp

[clang-tools-extra] r295435 - [clang-tidy] Add cert-dcl58-cpp (do not modify the 'std' namespace) check.

2017-02-17 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Feb 17 02:52:51 2017
New Revision: 295435

URL: http://llvm.org/viewvc/llvm-project?rev=295435=rev
Log:
[clang-tidy] Add cert-dcl58-cpp (do not modify the 'std' namespace) check.

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

Added:
clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl58-cpp.rst

clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/system-header-simulation.h
clang-tools-extra/trunk/test/clang-tidy/cert-dcl58-cpp.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=295435=295434=295435=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Fri Feb 17 
02:52:51 2017
@@ -17,6 +17,7 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "CommandProcessorCheck.h"
+#include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
 #include "LimitedRandomnessCheck.h"
 #include "SetLongJmpCheck.h"
@@ -37,6 +38,8 @@ public:
 CheckFactories.registerCheck("cert-dcl50-cpp");
 CheckFactories.registerCheck(
 "cert-dcl54-cpp");
+CheckFactories.registerCheck(
+"cert-dcl58-cpp");
 CheckFactories.registerCheck(
 "cert-dcl59-cpp");
 // OOP

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=295435=295434=295435=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Fri Feb 17 02:52:51 
2017
@@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
 add_clang_library(clangTidyCERTModule
   CERTTidyModule.cpp
   CommandProcessorCheck.cpp
+  DontModifyStdNamespaceCheck.cpp
   FloatLoopCounter.cpp
   LimitedRandomnessCheck.cpp
   SetLongJmpCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp?rev=295435=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp Fri 
Feb 17 02:52:51 2017
@@ -0,0 +1,49 @@
+//===--- DontModifyStdNamespaceCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DontModifyStdNamespaceCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(
+  namespaceDecl(unless(isExpansionInSystemHeader()),
+anyOf(hasName("std"), hasName("posix")),
+has(decl(unless(anyOf(
+functionDecl(isExplicitTemplateSpecialization()),
+cxxRecordDecl(isExplicitTemplateSpecialization()))
+  .bind("nmspc"),
+  this);
+}
+
+void DontModifyStdNamespaceCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *N = Result.Nodes.getNodeAs("nmspc");
+
+  // Only consider top level namespaces.
+  if (N->getParent() != Result.Context->getTranslationUnitDecl())
+return;
+
+  diag(N->getLocation(),
+   "modification of %0 namespace can result in undefined behavior")
+  << N;
+}
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h?rev=295435=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h 
(added)
+++ 

[PATCH] D23421: [Clang-tidy] CERT-DCL58-CPP (checker for std namespace modification)

2017-02-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295435: [clang-tidy] Add cert-dcl58-cpp (do not modify the 
'std' namespace) check. (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D23421?vs=88541=88863#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23421

Files:
  clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
  clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl58-cpp.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/test/clang-tidy/Inputs/Headers/system-header-simulation.h
  clang-tools-extra/trunk/test/clang-tidy/cert-dcl58-cpp.cpp

Index: clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.h
@@ -0,0 +1,36 @@
+//===--- DontModifyStdNamespaceCheck.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_CERT_DONT_MODIFY_STD_NAMESPACE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+/// Modification of the std or posix namespace can result in undefined behavior.
+/// This check warns for such modifications.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-msc53-cpp.html
+class DontModifyStdNamespaceCheck : public ClangTidyCheck {
+public:
+  DontModifyStdNamespaceCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_DONT_MODIFY_STD_NAMESPACE_H
Index: clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
@@ -0,0 +1,49 @@
+//===--- DontModifyStdNamespaceCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DontModifyStdNamespaceCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void DontModifyStdNamespaceCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(
+  namespaceDecl(unless(isExpansionInSystemHeader()),
+anyOf(hasName("std"), hasName("posix")),
+has(decl(unless(anyOf(
+functionDecl(isExplicitTemplateSpecialization()),
+cxxRecordDecl(isExplicitTemplateSpecialization()))
+  .bind("nmspc"),
+  this);
+}
+
+void DontModifyStdNamespaceCheck::check(
+const MatchFinder::MatchResult ) {
+  const auto *N = Result.Nodes.getNodeAs("nmspc");
+
+  // Only consider top level namespaces.
+  if (N->getParent() != Result.Context->getTranslationUnitDecl())
+return;
+
+  diag(N->getLocation(),
+   "modification of %0 namespace can result in undefined behavior")
+  << N;
+}
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
@@ -17,6 +17,7 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "CommandProcessorCheck.h"
+#include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
 #include "LimitedRandomnessCheck.h"
 #include "SetLongJmpCheck.h"
@@ -37,6 +38,8 @@
 

[libcxx] r295434 - Update all bug URL's to point to https://bugs.llvm.org/...

2017-02-17 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb 17 02:37:03 2017
New Revision: 295434

URL: http://llvm.org/viewvc/llvm-project?rev=295434=rev
Log:
Update all bug URL's to point to https://bugs.llvm.org/...

Modified:
libcxx/trunk/docs/index.rst
libcxx/trunk/include/memory

libcxx/trunk/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp
libcxx/trunk/test/std/containers/associative/map/compare.pass.cpp

libcxx/trunk/test/std/containers/associative/map/map.access/index_tuple.pass.cpp
libcxx/trunk/test/std/containers/sequences/vector.bool/find.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.map/compare.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.seeks/seekp2.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.match/parse_curly_brackets.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/backup.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/lookahead.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/bad_backref.pass.cpp
libcxx/trunk/test/std/re/re.traits/lookup_classname.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR22806_constrain_tuple_like_ctor.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
libcxx/trunk/test/std/utilities/variant/variant.get/get_index.pass.cpp
libcxx/trunk/test/std/utilities/variant/variant.get/get_type.pass.cpp
libcxx/trunk/utils/libcxx/test/config.py
libcxx/trunk/www/atomic_design.html
libcxx/trunk/www/atomic_design_a.html
libcxx/trunk/www/atomic_design_b.html
libcxx/trunk/www/atomic_design_c.html
libcxx/trunk/www/cxx1y_status.html
libcxx/trunk/www/cxx1z_status.html
libcxx/trunk/www/index.html
libcxx/trunk/www/ts1z_status.html
libcxx/trunk/www/type_traits_design.html
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=295434=295433=295434=diff
==
--- libcxx/trunk/docs/index.rst (original)
+++ libcxx/trunk/docs/index.rst Fri Feb 17 02:37:03 2017
@@ -120,7 +120,7 @@ This list contains known issues with lib
 
 A full list of currently open libc++ bugs can be `found here`__.
 
-.. __:  
https://llvm.org/bugs/buglist.cgi?component=All%20Bugs=libc%2B%2B_format=advanced=---=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id_id=74184
+.. __:  
https://bugs.llvm.org/buglist.cgi?component=All%20Bugs=libc%2B%2B_format=advanced=---=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id_id=74184
 
 Design Documents
 
@@ -180,7 +180,7 @@ Quick Links
 ===
 * `LLVM Homepage `_
 * `libc++abi Homepage `_
-* `LLVM Bugzilla `_
+* `LLVM Bugzilla `_
 * `cfe-commits Mailing List`_
 * `cfe-dev Mailing List`_
 * `Browse libc++ -- SVN `_

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=295434=295433=295434=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Fri Feb 17 02:37:03 2017
@@ -3341,7 +3341,7 @@ uninitialized_move_n(_InputIt __first, _
 
 // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
 // should be sufficient for thread safety.
-// See https://llvm.org/bugs/show_bug.cgi?id=22803
+// See 

r295433 - Update Bugzilla URLs in docs

2017-02-17 Thread Ismail Donmez via cfe-commits
Author: ismail
Date: Fri Feb 17 02:26:54 2017
New Revision: 295433

URL: http://llvm.org/viewvc/llvm-project?rev=295433=rev
Log:
Update Bugzilla URLs in docs

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=295433=295432=295433=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Feb 17 02:26:54 2017
@@ -1879,7 +1879,7 @@ missing from this list, please send an e
 currently excludes C++; see :ref:`C++ Language Features `. Also, this
 list does not include bugs in mostly-implemented features; please see
 the `bug
-tracker 
`_
+tracker 
`_
 for known existing bugs (FIXME: Is there a section for bug-reporting
 guidelines somewhere?).
 
@@ -2516,7 +2516,7 @@ official `MinGW-w64 website `_ on
+`Some tests might fail `_ on
 ``x86_64-w64-mingw32``.
 
 .. _clang-cl:
@@ -2559,7 +2559,7 @@ options are spelled with a leading ``/``
 
 clang-cl.exe: error: no such file or directory: '/foobar'
 
-Please `file a bug 
`_
+Please `file a bug 
`_
 for any valid cl.exe flags that clang-cl does not understand.
 
 Execute ``clang-cl /?`` to see a list of supported options:


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