[Ping] StaticAnalyzer: Fix GCC 6 indention warning in ArrayBoundCheckerV2.cpp

2016-08-17 Thread Christoph Grüninger via cfe-commits
Hi!

I know my patch is of minor importantance. Could still somebody be so
kind to review and maybe to apply it to trunk?

Thanks
Christoph

Am 16.08.2016 um 15:41 schrieb Christoph Grüninger via cfe-commits:
> Dear Clang developers,
> please find attached a tiny patch which fixes a indentation warning from
> GCC 6 within ArrayBoundCheckerV2.cpp
> 
> Proposed commit message:
>> StaticAnalyzer: Fix GCC 6 indention warning in ArrayBoundCheckerV2.cpp
>>
>> Patch by Christoph Grüninger
> 
> Bye
> Christoph
> 
> 
> 
> ___
> 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


[PATCH] D23643: [Driver] Report invalid -mtune/-mcpu parameters when -arch=arm64

2016-08-17 Thread Vedant Kumar via cfe-commits
vsk created this revision.
vsk added reviewers: t.p.northover, rengolin.
vsk added a subscriber: cfe-commits.
Herald added subscribers: samparker, rengolin, aemerson.

Fix a crash-on-invalid in which -mtune/-mcpu are set to nonsense values while 
-arch=arm64.

This patch extends an arm cortex test out of convenience. I'd be happy to move 
the test if there is a better spot for it.

https://reviews.llvm.org/D23643

Files:
  lib/Driver/Tools.cpp
  test/Driver/arm-cortex-cpus.c

Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -303,7 +303,10 @@
 
 // == Check that a bogus CPU gives an error
 // RUN: %clang -target arm -mcpu=bogus -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BOGUS-CPU %s
+// RUN: %clang -arch arm64 -mcpu=bogus -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BOGUS-CPU %s
 // CHECK-BOGUS-CPU: error: {{.*}} does not support '-mcpu=bogus'
+// RUN: %clang -arch arm64 -mtune=bogus -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BOGUS-TUNE %s
+// CHECK-BOGUS-TUNE: error: {{.*}} does not support '-mtune=bogus'
 
 // == Check default Architecture on each ARM11 CPU
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136j-s -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV6 %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1140,9 +1140,9 @@
 // ARM tools end.
 
 /// getAArch64TargetCPU - Get the (LLVM) name of the AArch64 cpu we are
-/// targeting.
-static std::string getAArch64TargetCPU(const ArgList ) {
-  Arg *A;
+/// targeting. Set \p A to the Arg corresponding to the name if one exists, and
+/// to nullptr otherwise.
+static std::string getAArch64TargetCPU(const ArgList , Arg *) {
   std::string CPU;
   // If we have -mtune or -mcpu, use that.
   if ((A = Args.getLastArg(options::OPT_mtune_EQ))) {
@@ -1160,7 +1160,7 @@
 
   // Make sure we pick "cyclone" if -arch is used.
   // FIXME: Should this be picked by checking the target triple instead?
-  if (Args.getLastArg(options::OPT_arch))
+  if ((A = Args.getLastArg(options::OPT_arch)))
 return "cyclone";
 
   return "generic";
@@ -1919,13 +1919,15 @@
 
 static std::string getCPUName(const ArgList , const llvm::Triple ,
   bool FromAs = false) {
+  Arg *A;
+
   switch (T.getArch()) {
   default:
 return "";
 
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
-return getAArch64TargetCPU(Args);
+return getAArch64TargetCPU(Args, A);
 
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
@@ -2443,18 +2445,18 @@
   else if ((A = Args.getLastArg(options::OPT_mcpu_EQ)))
 success = getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Features);
   else if (Args.hasArg(options::OPT_arch))
-success = getAArch64ArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args), 
Args,
- Features);
+success = getAArch64ArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args, A),
+ Args, Features);
 
   if (success && (A = Args.getLastArg(options::OPT_mtune_EQ)))
 success =
 getAArch64MicroArchFeaturesFromMtune(D, A->getValue(), Args, Features);
   else if (success && (A = Args.getLastArg(options::OPT_mcpu_EQ)))
 success =
 getAArch64MicroArchFeaturesFromMcpu(D, A->getValue(), Args, Features);
-  else if (Args.hasArg(options::OPT_arch))
-success = getAArch64MicroArchFeaturesFromMcpu(D, getAArch64TargetCPU(Args),
-  Args, Features);
+  else if (success && Args.hasArg(options::OPT_arch))
+success = getAArch64MicroArchFeaturesFromMcpu(
+D, getAArch64TargetCPU(Args, A), Args, Features);
 
   if (!success)
 D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);


Index: test/Driver/arm-cortex-cpus.c
===
--- test/Driver/arm-cortex-cpus.c
+++ test/Driver/arm-cortex-cpus.c
@@ -303,7 +303,10 @@
 
 // == Check that a bogus CPU gives an error
 // RUN: %clang -target arm -mcpu=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-CPU %s
+// RUN: %clang -arch arm64 -mcpu=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-CPU %s
 // CHECK-BOGUS-CPU: error: {{.*}} does not support '-mcpu=bogus'
+// RUN: %clang -arch arm64 -mtune=bogus -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BOGUS-TUNE %s
+// CHECK-BOGUS-TUNE: error: {{.*}} does not support '-mtune=bogus'
 
 // == Check default Architecture on each ARM11 CPU
 // RUN: %clang -target arm-linux-gnueabi -mcpu=arm1136j-s -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CPUV6 %s
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ 

r279028 - [sanitizer-coverag] update the docs in __sanitizer_cov_trace_cmp

2016-08-17 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Wed Aug 17 20:26:36 2016
New Revision: 279028

URL: http://llvm.org/viewvc/llvm-project?rev=279028=rev
Log:
[sanitizer-coverag] update the docs in __sanitizer_cov_trace_cmp

Modified:
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=279028=279027=279028=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Wed Aug 17 20:26:36 2016
@@ -333,11 +333,11 @@ they will be called by the instrumented
 .. code-block:: c++
 
   // Called before a comparison instruction.
-  // SizeAndType is a packed value containing
-  //   - [63:32] the Size of the operands of comparison in bits
-  //   - [31:0] the Type of comparison (one of ICMP_EQ, ... ICMP_SLE)
   // Arg1 and Arg2 are arguments of the comparison.
-  void __sanitizer_cov_trace_cmp(uint64_t SizeAndType, uint64_t Arg1, uint64_t 
Arg2);
+  void __sanitizer_cov_trace_cmp1(uint8_t Arg1, uint8_t Arg2);
+  void __sanitizer_cov_trace_cmp2(uint16_t Arg1, uint16_t Arg2);
+  void __sanitizer_cov_trace_cmp4(uint32_t Arg1, uint32_t Arg2);
+  void __sanitizer_cov_trace_cmp8(uint64_t Arg1, uint64_t Arg2);
 
   // Called before a switch statement.
   // Val is the switch operand.


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


r279024 - PR28438: Update the information on an identifier with local definitions before

2016-08-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Aug 17 20:16:55 2016
New Revision: 279024

URL: http://llvm.org/viewvc/llvm-project?rev=279024=rev
Log:
PR28438: Update the information on an identifier with local definitions before
trying to write out its macro graph, in case we imported a module that added
another module macro between the most recent local definition and the end of
the module.

Added:
cfe/trunk/test/Modules/Inputs/PR28438/
cfe/trunk/test/Modules/Inputs/PR28438/a.h
cfe/trunk/test/Modules/Inputs/PR28438/b1.h
cfe/trunk/test/Modules/Inputs/PR28438/b2.h
cfe/trunk/test/Modules/Inputs/PR28438/module.modulemap
cfe/trunk/test/Modules/pr28438.cpp
Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=279024=279023=279024=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Aug 17 20:16:55 2016
@@ -398,6 +398,8 @@ class Preprocessor : public RefCountedBa
 
 ModuleMacroInfo *getModuleInfo(Preprocessor ,
const IdentifierInfo *II) const {
+  if (II->isOutOfDate())
+PP.updateOutOfDateIdentifier(const_cast(*II));
   // FIXME: Find a spare bit on IdentifierInfo and store a
   //HasModuleMacros flag.
   if (!II->hasMacroDefinition() ||
@@ -653,6 +655,8 @@ class Preprocessor : public RefCountedBa
   };
   DeserializedMacroInfoChain *DeserialMIChainHead;
 
+  void updateOutOfDateIdentifier(IdentifierInfo ) const;
+
 public:
   Preprocessor(IntrusiveRefCntPtr PPOpts,
DiagnosticsEngine , LangOptions ,
@@ -900,6 +904,8 @@ public:
 
   /// \brief Get the list of leaf (non-overridden) module macros for a name.
   ArrayRef getLeafModuleMacros(const IdentifierInfo *II) const {
+if (II->isOutOfDate())
+  updateOutOfDateIdentifier(const_cast(*II));
 auto I = LeafModuleMacros.find(II);
 if (I != LeafModuleMacros.end())
   return I->second;

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=279024=279023=279024=diff
==
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Aug 17 20:16:55 2016
@@ -618,6 +618,11 @@ static diag::kind getFutureCompatDiagKin
   "Keyword not known to come from a newer Standard or proposed Standard");
 }
 
+void Preprocessor::updateOutOfDateIdentifier(IdentifierInfo ) const {
+  assert(II.isOutOfDate() && "not out of date");
+  getExternalSource()->updateOutOfDateIdentifier(II);
+}
+
 /// HandleIdentifier - This callback is invoked when the lexer reads an
 /// identifier.  This callback looks up the identifier in the map and/or
 /// potentially macro expands it or turns it into a named token (like 'for').
@@ -642,7 +647,7 @@ bool Preprocessor::HandleIdentifier(Toke
 if ( == Ident__VA_ARGS__)
   CurrentIsPoisoned = Ident__VA_ARGS__->isPoisoned();
 
-ExternalSource->updateOutOfDateIdentifier(II);
+updateOutOfDateIdentifier(II);
 Identifier.setKind(II.getTokenID());
 
 if ( == Ident__VA_ARGS__)

Added: cfe/trunk/test/Modules/Inputs/PR28438/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28438/a.h?rev=279024=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28438/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR28438/a.h Wed Aug 17 20:16:55 2016
@@ -0,0 +1 @@
+#define FOO

Added: cfe/trunk/test/Modules/Inputs/PR28438/b1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28438/b1.h?rev=279024=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28438/b1.h (added)
+++ cfe/trunk/test/Modules/Inputs/PR28438/b1.h Wed Aug 17 20:16:55 2016
@@ -0,0 +1,2 @@
+#define FOO
+#include "a.h"

Added: cfe/trunk/test/Modules/Inputs/PR28438/b2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28438/b2.h?rev=279024=auto
==
(empty)

Added: cfe/trunk/test/Modules/Inputs/PR28438/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/PR28438/module.modulemap?rev=279024=auto
==
--- cfe/trunk/test/Modules/Inputs/PR28438/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/PR28438/module.modulemap Wed Aug 17 20:16:55 
2016
@@ -0,0 +1,2 @@
+module A { header "a.h" export * }
+module B { module B1 { header "b1.h" export * } module B2 

Re: [libcxx] r279008 - make the associative containers do the right thing for propogate_on_container_assignment. Fixes bug #29001. Tests are only for right now - more complete tests will come wh

2016-08-17 Thread Hans Wennborg via cfe-commits
On Wed, Aug 17, 2016 at 4:24 PM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Wed Aug 17 18:24:02 2016
> New Revision: 279008
>
> URL: http://llvm.org/viewvc/llvm-project?rev=279008=rev
> Log:
> make the associative containers do the right thing for 
> propogate_on_container_assignment. Fixes bug #29001. Tests are only for  
> right now - more complete tests will come when we revamp our allocator 
> testing structure.
>
> Modified:
> libcxx/trunk/include/__tree
> 
> libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp

Merged to 3.9 in r279017.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Please take r279008 for the release

2016-08-17 Thread Hans Wennborg via cfe-commits
On Wed, Aug 17, 2016 at 5:27 PM, Marshall Clow  wrote:
> Unlike the #278904, this does fix a bug - and a non-trivial one at that.

Thanks! I've merged it in r279017.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r279017 - Merging r279008:

2016-08-17 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Aug 17 19:23:33 2016
New Revision: 279017

URL: http://llvm.org/viewvc/llvm-project?rev=279017=rev
Log:
Merging r279008:

r279008 | marshall | 2016-08-17 16:24:02 -0700 (Wed, 17 Aug 2016) | 1 line

make the associative containers do the right thing for 
propogate_on_container_assignment. Fixes bug #29001. Tests are only for  
right now - more complete tests will come when we revamp our allocator testing 
structure.


Modified:
libcxx/branches/release_39/   (props changed)
libcxx/branches/release_39/include/__tree

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp

Propchange: libcxx/branches/release_39/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 17 19:23:33 2016
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:278282,278357,278387,278904
+/libcxx/trunk:278282,278357,278387,278904,279008

Modified: libcxx/branches/release_39/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_39/include/__tree?rev=279017=279016=279017=diff
==
--- libcxx/branches/release_39/include/__tree (original)
+++ libcxx/branches/release_39/include/__tree Wed Aug 17 19:23:33 2016
@@ -1419,7 +1419,11 @@ private:
 
 _LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const __tree& __t, true_type)
-{__node_alloc() = __t.__node_alloc();}
+{
+if (__node_alloc() != __t.__node_alloc())
+   clear();
+__node_alloc() = __t.__node_alloc();
+}
 _LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const __tree& __t, false_type) {}
 

Modified: 
libcxx/branches/release_39/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_39/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp?rev=279017=279016=279017=diff
==
--- 
libcxx/branches/release_39/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
 (original)
+++ 
libcxx/branches/release_39/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
 Wed Aug 17 19:23:33 2016
@@ -15,11 +15,99 @@
 
 #include 
 #include 
+#include 
+#include 
+
+#include 
 
 #include "../../../test_compare.h"
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#if TEST_STD_VER >= 11
+std::vector ca_allocs;
+std::vector ca_deallocs;
+
+template 
+class counting_allocatorT {
+public:
+typedef T value_type;
+int foo{0};
+counting_allocatorT(int f) noexcept : foo(f) {}
+
+using propagate_on_container_copy_assignment = std::true_type;
+template  counting_allocatorT(const counting_allocatorT& 
other) noexcept {foo = other.foo;}
+template  bool operator==(const counting_allocatorT& other) 
const noexcept { return foo == other.foo; }
+template  bool operator!=(const counting_allocatorT& other) 
const noexcept { return foo != other.foo; }
+
+T * allocate(const size_t n) const {
+ca_allocs.push_back(foo);
+void * const pv = ::malloc(n * sizeof(T));
+return static_cast(pv);
+}
+void deallocate(T * const p, size_t) const noexcept {
+ca_deallocs.push_back(foo);
+free(p);
+}
+};
+
+template 
+class counting_allocatorF {
+public:
+typedef T value_type;
+int foo{0};
+counting_allocatorF(int f) noexcept : foo(f) {}
+
+using propagate_on_container_copy_assignment = std::false_type;
+template  counting_allocatorF(const counting_allocatorF& 
other) noexcept {foo = other.foo;}
+template  bool operator==(const counting_allocatorF& other) 
const noexcept { return foo == other.foo; }
+template  bool operator!=(const counting_allocatorF& other) 
const noexcept { return foo != other.foo; }
+
+T * allocate(const size_t n) const {
+ca_allocs.push_back(foo);
+void * const pv = ::malloc(n * sizeof(T));
+return static_cast(pv);
+}
+void deallocate(T * const p, size_t) const noexcept {
+ca_deallocs.push_back(foo);
+free(p);
+}
+};
+
+bool balanced_allocs() {
+std::vector temp1, temp2;
+
+std::cout << "Allocations = " << ca_allocs.size() << ", deallocatons = " 
<< ca_deallocs.size() << std::endl;
+if (ca_allocs.size() != ca_deallocs.size())
+return false;
+
+temp1 = ca_allocs;
+std::sort(temp1.begin(), temp1.end());
+temp2.clear();
+std::unique_copy(temp1.begin(), temp1.end(), 
std::back_inserter(temp2));
+std::cout << "There were " << temp2.size() << " different allocators\n";
+
+for (std::vector::const_iterator it = 

[libcxx] r279015 - Merging r278904:

2016-08-17 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Aug 17 19:20:59 2016
New Revision: 279015

URL: http://llvm.org/viewvc/llvm-project?rev=279015=rev
Log:
Merging r278904:

r278904 | marshall | 2016-08-16 22:58:40 -0700 (Tue, 16 Aug 2016) | 1 line

Support allocators with explicit conversion constructors. Fixes bug #29000


Modified:
libcxx/branches/release_39/   (props changed)
libcxx/branches/release_39/include/map
libcxx/branches/release_39/include/unordered_map

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/default.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp

libcxx/branches/release_39/test/std/containers/associative/set/set.cons/default.pass.cpp

libcxx/branches/release_39/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/sequences/list/list.cons/default.pass.cpp

libcxx/branches/release_39/test/std/containers/sequences/vector.bool/construct_default.pass.cpp

libcxx/branches/release_39/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp

libcxx/branches/release_39/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp

libcxx/branches/release_39/test/std/strings/basic.string/string.cons/alloc.pass.cpp
libcxx/branches/release_39/test/support/min_allocator.h

Propchange: libcxx/branches/release_39/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Aug 17 19:20:59 2016
@@ -1,2 +1,2 @@
 

Re: [libcxx] r278904 - Support allocators with explicit conversion constructors. Fixes bug #29000

2016-08-17 Thread Hans Wennborg via cfe-commits
On Wed, Aug 17, 2016 at 5:25 PM, Marshall Clow  wrote:
> On Wed, Aug 17, 2016 at 3:14 PM, Hans Wennborg  wrote:
>>
>> I'd rather not take this actually, as it looks like a large change,
>> isn't fixing a regression, and it's time to start wrapping up the
>> release.
>>
> This is actually a pretty small change - almost all the changes are in the
> tests.
>
> I'd like to see it in the release, but I won't be heartbroken if it doesn't
> get in.

Okay, let's merge it then :-) r279015.

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


Please take r279008 for the release

2016-08-17 Thread Marshall Clow via cfe-commits
Unlike the #278904, this does fix a bug - and a non-trivial one at that.

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


Re: [libcxx] r278904 - Support allocators with explicit conversion constructors. Fixes bug #29000

2016-08-17 Thread Marshall Clow via cfe-commits
On Wed, Aug 17, 2016 at 3:14 PM, Hans Wennborg  wrote:

> I'd rather not take this actually, as it looks like a large change,
> isn't fixing a regression, and it's time to start wrapping up the
> release.
>
> This is actually a pretty small change - almost all the changes are in the
tests.

I'd like to see it in the release, but I won't be heartbroken if it doesn't
get in.

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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:1503
@@ +1502,3 @@
+if (!Module || !Module->getASTFile() ||
+std::string(Module->getASTFile()->getName()) != ModuleFileName) {
+  // Error out if Module does not refer to the file in the prebuilt

rsmith wrote:
> It'd be safer to check that `FileMgr.getFile(ModuleFileName) == 
> Module->getASTFile()` in case the filename gets canonicalized by the file 
> manager in some way.
Yes you are right. I will update the patch and commit the change.

Thanks for all the useful information!



https://reviews.llvm.org/D23125



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


Re: [PATCH] D23627: [CUDA] Improve handling of math functions.

2016-08-17 Thread Artem Belevich via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM, but we may want someone familiar with math library to take a look.



Comment at: clang/lib/Headers/__clang_cuda_cmath.h:125-133
@@ -122,8 +124,11 @@
 __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); 
}
-__DEVICE__ float nexttoward(float __from, float __to) {
+__DEVICE__ float nexttoward(float __from, double __to) {
   return __builtin_nexttowardf(__from, __to);
 }
 __DEVICE__ double nexttoward(double __from, double __to) {
   return __builtin_nexttoward(__from, __to);
 }
+__DEVICE__ float nexttowardf(float __from, double __to) {
+  return __builtin_nexttowardf(__from, __to);
+}
 __DEVICE__ float pow(float __base, float __exp) {

jlebar wrote:
> tra wrote:
> > You've got two identical `nexttoward(float, double)` now.
> > Perhaps first one was supposed to remain `nexttoward(float, float)` ?
> > 
> > 
> It's hard to see, but one is nexttowardf.
Indeed, I've missed that. 


https://reviews.llvm.org/D23627



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:1503
@@ +1502,3 @@
+if (!Module || !Module->getASTFile() ||
+std::string(Module->getASTFile()->getName()) != ModuleFileName) {
+  // Error out if Module does not refer to the file in the prebuilt

It'd be safer to check that `FileMgr.getFile(ModuleFileName) == 
Module->getASTFile()` in case the filename gets canonicalized by the file 
manager in some way.


https://reviews.llvm.org/D23125



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

Cheers,

Manman



Comment at: lib/Frontend/CompilerInstance.cpp:1502
@@ +1501,3 @@
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+if (!Module || !Module->getASTFile() ||
+std::string(Module->getASTFile()->getName()) != ModuleFileName) {

Thanks for the explanation, it makes sense.

Updated the patch accordingly.


https://reviews.llvm.org/D23125



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 68456.

https://reviews.llvm.org/D23125

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/Module.h
  lib/Driver/Tools.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ModuleManager.cpp
  test/Driver/modules.m
  test/Modules/Inputs/prebuilt-module/a.h
  test/Modules/Inputs/prebuilt-module/module.modulemap
  test/Modules/prebuilt-module.m

Index: test/Modules/prebuilt-module.m
===
--- test/Modules/prebuilt-module.m
+++ test/Modules/prebuilt-module.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -fmodules -x objective-c -I %S/Inputs/prebuilt-module -triple %itanium_abi_triple -emit-module %S/Inputs/prebuilt-module/module.modulemap -fmodule-name=prebuilt -o %t/prebuilt.pcm
+// RUN: %clang_cc1 -fmodules -fprebuilt-module-path=%t/ -fdisable-module-hash %s -verify
+
+// expected-no-diagnostics
+@import prebuilt;
+int test() {
+  return a;
+}
Index: test/Modules/Inputs/prebuilt-module/module.modulemap
===
--- test/Modules/Inputs/prebuilt-module/module.modulemap
+++ test/Modules/Inputs/prebuilt-module/module.modulemap
@@ -0,0 +1 @@
+module prebuilt { header "a.h" }
Index: test/Modules/Inputs/prebuilt-module/a.h
===
--- test/Modules/Inputs/prebuilt-module/a.h
+++ test/Modules/Inputs/prebuilt-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -39,6 +39,13 @@
 // RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
 
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH_DEFAULT %s
+// MODULES_PREBUILT_PATH_DEFAULT-NOT: -fprebuilt-module-path
+
+// RUN: %clang -fmodules -fprebuilt-module-path=foo -fprebuilt-module-path=bar -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH %s
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=foo"
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=bar"
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -66,7 +66,7 @@
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
   const FileEntry *Entry;
-  if (Type == MK_ExplicitModule) {
+  if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
 // If we're not expecting to pull this file out of the module cache, it
 // might have a different mtime due to being moved across filesystems in
 // a distributed build. The size must still match, though. (As must the
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1384,7 +1384,7 @@
 // any other module's anonymous namespaces, so don't attach the anonymous
 // namespace at all.
 NamespaceDecl *Anon = cast(Reader.GetDecl(AnonNamespace));
-if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
+if (!F.isModule())
   D->setAnonymousNamespace(Anon);
   }
 }
@@ -3747,8 +3747,7 @@
   // Each module has its own anonymous namespace, which is disjoint from
   // any other module's anonymous namespaces, so don't attach the anonymous
   // namespace at all.
-  if (ModuleFile.Kind != MK_ImplicitModule &&
-  ModuleFile.Kind != MK_ExplicitModule) {
+  if (!ModuleFile.isModule()) {
 if (TranslationUnitDecl *TU = dyn_cast(D))
   TU->setAnonymousNamespace(Anon);
 else
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1312,8 +1312,7 @@
 SrcMgr::CharacteristicKind
   FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
 SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
-if (IncludeLoc.isInvalid() &&
-(F->Kind == 

[clang-tools-extra] r279009 - [Release notes] Mention Emacs integration in Include-fixer.

2016-08-17 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Aug 17 18:36:22 2016
New Revision: 279009

URL: http://llvm.org/viewvc/llvm-project?rev=279009=rev
Log:
[Release notes] Mention Emacs integration in Include-fixer.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=279009=279008=279009=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Aug 17 18:36:22 2016
@@ -88,7 +88,7 @@ Improvements to clang-tidy
 Improvements to include-fixer
 -
 
-The improvements are...
+- Emacs integration was added.
 
 Improvements to modularize
 --


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


[libcxx] r279008 - make the associative containers do the right thing for propogate_on_container_assignment. Fixes bug #29001. Tests are only for right now - more complete tests will come when w

2016-08-17 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Aug 17 18:24:02 2016
New Revision: 279008

URL: http://llvm.org/viewvc/llvm-project?rev=279008=rev
Log:
make the associative containers do the right thing for 
propogate_on_container_assignment. Fixes bug #29001. Tests are only for  
right now - more complete tests will come when we revamp our allocator testing 
structure.

Modified:
libcxx/trunk/include/__tree

libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp

Modified: libcxx/trunk/include/__tree
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=279008=279007=279008=diff
==
--- libcxx/trunk/include/__tree (original)
+++ libcxx/trunk/include/__tree Wed Aug 17 18:24:02 2016
@@ -1419,7 +1419,11 @@ private:
 
 _LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const __tree& __t, true_type)
-{__node_alloc() = __t.__node_alloc();}
+{
+if (__node_alloc() != __t.__node_alloc())
+   clear();
+__node_alloc() = __t.__node_alloc();
+}
 _LIBCPP_INLINE_VISIBILITY
 void __copy_assign_alloc(const __tree& __t, false_type) {}
 

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp?rev=279008=279007=279008=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp 
Wed Aug 17 18:24:02 2016
@@ -15,11 +15,99 @@
 
 #include 
 #include 
+#include 
+#include 
+
+#include 
 
 #include "../../../test_compare.h"
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#if TEST_STD_VER >= 11
+std::vector ca_allocs;
+std::vector ca_deallocs;
+
+template 
+class counting_allocatorT {
+public:
+typedef T value_type;
+int foo{0};
+counting_allocatorT(int f) noexcept : foo(f) {}
+
+using propagate_on_container_copy_assignment = std::true_type;
+template  counting_allocatorT(const counting_allocatorT& 
other) noexcept {foo = other.foo;}
+template  bool operator==(const counting_allocatorT& other) 
const noexcept { return foo == other.foo; }
+template  bool operator!=(const counting_allocatorT& other) 
const noexcept { return foo != other.foo; }
+
+T * allocate(const size_t n) const {
+ca_allocs.push_back(foo);
+void * const pv = ::malloc(n * sizeof(T));
+return static_cast(pv);
+}
+void deallocate(T * const p, size_t) const noexcept {
+ca_deallocs.push_back(foo);
+free(p);
+}
+};
+
+template 
+class counting_allocatorF {
+public:
+typedef T value_type;
+int foo{0};
+counting_allocatorF(int f) noexcept : foo(f) {}
+
+using propagate_on_container_copy_assignment = std::false_type;
+template  counting_allocatorF(const counting_allocatorF& 
other) noexcept {foo = other.foo;}
+template  bool operator==(const counting_allocatorF& other) 
const noexcept { return foo == other.foo; }
+template  bool operator!=(const counting_allocatorF& other) 
const noexcept { return foo != other.foo; }
+
+T * allocate(const size_t n) const {
+ca_allocs.push_back(foo);
+void * const pv = ::malloc(n * sizeof(T));
+return static_cast(pv);
+}
+void deallocate(T * const p, size_t) const noexcept {
+ca_deallocs.push_back(foo);
+free(p);
+}
+};
+
+bool balanced_allocs() {
+std::vector temp1, temp2;
+
+std::cout << "Allocations = " << ca_allocs.size() << ", deallocatons = " 
<< ca_deallocs.size() << std::endl;
+if (ca_allocs.size() != ca_deallocs.size())
+return false;
+
+temp1 = ca_allocs;
+std::sort(temp1.begin(), temp1.end());
+temp2.clear();
+std::unique_copy(temp1.begin(), temp1.end(), 
std::back_inserter(temp2));
+std::cout << "There were " << temp2.size() << " different allocators\n";
+
+for (std::vector::const_iterator it = temp2.begin(); it != 
temp2.end(); ++it ) {
+std::cout << *it << ": " << std::count(ca_allocs.begin(), 
ca_allocs.end(), *it) << " vs " << std::count(ca_deallocs.begin(), 
ca_deallocs.end(), *it) << std::endl;
+if ( std::count(ca_allocs.begin(), ca_allocs.end(), *it) != 
std::count(ca_deallocs.begin(), ca_deallocs.end(), *it))
+return false;
+}
+
+temp1 = ca_allocs;
+std::sort(temp1.begin(), temp1.end());
+temp2.clear();
+std::unique_copy(temp1.begin(), temp1.end(), 
std::back_inserter(temp2));
+std::cout << "There were " << temp2.size() << " different 
(de)allocators\n";
+for (std::vector::const_iterator it = ca_deallocs.begin(); it != 
ca_deallocs.end(); ++it ) {
+std::cout << 

Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

2016-08-17 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279006: [Documentation] Remove duplicated checks groups 
descriptions from clang… (authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D23596?vs=68447=68449#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23596

Files:
  clang-tools-extra/trunk/docs/clang-tidy/index.rst

Index: clang-tools-extra/trunk/docs/clang-tidy/index.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst
@@ -48,6 +48,8 @@
 available checks or with any other value of ``-checks=`` to see which checks 
are
 enabled by this value.
 
+:: _checks-groups-table:
+
 There are currently the following groups of checks:
 
 == 
=
@@ -338,29 +340,13 @@
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
-
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably 
deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  
`_
-* `CERT Secure Coding Standards
-  
`_
-* `Google Style Guide
-  
`_
-* `LLVM Style
-  
`_
-* `modernizing C/C++ code
-  
`_
-* potential `performance problems
-  
`_
-* various `readability issues
-  
`_
-* and `miscellaneous checks
-  
`_
-  that we couldn't find a better category for.
+Next, you need to decide which module the check belongs to. Modules
+are located in subdirectories of
+``clang-tidy/ 
``_
+and contain checks targeting a certain aspect of code quality (performance,
+readability, etc.), certain coding style or standard (Google, LLVM, CERT, etc.)
+or a widely used API (e.g. MPI). Their names are same as user-facing check
+groups names described :ref:`above `.
 
 After choosing the module, you need to create a class for your check:
 


Index: clang-tools-extra/trunk/docs/clang-tidy/index.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst
@@ -48,6 +48,8 @@
 available checks or with any other value of ``-checks=`` to see which checks are
 enabled by this value.
 
+:: _checks-groups-table:
+
 There are currently the following groups of checks:
 
 == =
@@ -338,29 +340,13 @@
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
-
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  `_
-* `CERT Secure Coding Standards
-  `_
-* `Google Style Guide
-  `_
-* `LLVM Style
-  `_
-* `modernizing C/C++ code
-  `_
-* potential `performance problems
-  `_
-* various `readability issues
-  `_
-* and `miscellaneous checks
-  `_
-  that we couldn't find a better category for.
+Next, you need to decide which module the check belongs to. Modules
+are 

[clang-tools-extra] r279006 - [Documentation] Remove duplicated checks groups descriptions from clang-tidy/index.rst.

2016-08-17 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Aug 17 18:20:00 2016
New Revision: 279006

URL: http://llvm.org/viewvc/llvm-project?rev=279006=rev
Log:
[Documentation] Remove duplicated checks groups descriptions from 
clang-tidy/index.rst.

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=279006=279005=279006=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Wed Aug 17 18:20:00 2016
@@ -48,6 +48,8 @@ The ``-list-checks`` option lists all th
 available checks or with any other value of ``-checks=`` to see which checks 
are
 enabled by this value.
 
+:: _checks-groups-table:
+
 There are currently the following groups of checks:
 
 == 
=
@@ -338,29 +340,13 @@ style used in the project. For code revi
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
-
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably 
deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  
`_
-* `CERT Secure Coding Standards
-  
`_
-* `Google Style Guide
-  
`_
-* `LLVM Style
-  
`_
-* `modernizing C/C++ code
-  
`_
-* potential `performance problems
-  
`_
-* various `readability issues
-  
`_
-* and `miscellaneous checks
-  
`_
-  that we couldn't find a better category for.
+Next, you need to decide which module the check belongs to. Modules
+are located in subdirectories of
+``clang-tidy/ 
``_
+and contain checks targeting a certain aspect of code quality (performance,
+readability, etc.), certain coding style or standard (Google, LLVM, CERT, etc.)
+or a widely used API (e.g. MPI). Their names are same as user-facing check
+groups names described :ref:`above `.
 
 After choosing the module, you need to create a class for your check:
 


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


Re: [PATCH] D23627: [CUDA] Improve handling of math functions.

2016-08-17 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: clang/lib/Headers/__clang_cuda_cmath.h:125-133
@@ -122,8 +124,11 @@
 __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); 
}
-__DEVICE__ float nexttoward(float __from, float __to) {
+__DEVICE__ float nexttoward(float __from, double __to) {
   return __builtin_nexttowardf(__from, __to);
 }
 __DEVICE__ double nexttoward(double __from, double __to) {
   return __builtin_nexttoward(__from, __to);
 }
+__DEVICE__ float nexttowardf(float __from, double __to) {
+  return __builtin_nexttowardf(__from, __to);
+}
 __DEVICE__ float pow(float __base, float __exp) {

tra wrote:
> You've got two identical `nexttoward(float, double)` now.
> Perhaps first one was supposed to remain `nexttoward(float, float)` ?
> 
> 
It's hard to see, but one is nexttowardf.


Comment at: clang/lib/Headers/__clang_cuda_cmath.h:184-197
@@ +183,16 @@
+
+// Defines an overload of __fn that accepts one two arithmetic arguments, calls
+// __fn((double)x, (double)y), and returns a double.
+//
+// Note this is different from OVERLOAD_1, which generates an overload that
+// accepts only *integral* arguments.
+#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_2(__retty, __fn)  
\
+  template   
\
+  __DEVICE__ typename __clang_cuda_enable_if<  
\
+  std::numeric_limits<__T1>::is_specialized && 
\
+  std::numeric_limits<__T2>::is_specialized,   
\
+  __retty>::type   
\
+  __fn(__T1 __x, __T2 __y) {   
\
+return __fn((double)__x, (double)__y); 
\
+  }
+

tra wrote:
> `is_specialized` will be true for `long double` args and we'll instantiate 
> the function. Can we/should we produce an error instead?
I think it's OK.  Or at least, long double is kind of screwed up at the moment. 
 Sometimes we pick `__host__` overloads, sometimes we pick `__device__` 
overloads; I made no effort to make it correct.  I'm much more bullish on 
making use of long double a compile error as a way to solve these problems.


https://reviews.llvm.org/D23627



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Frontend/CompilerInstance.cpp:1502
@@ +1501,3 @@
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+if (!Module) {
+  getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)

manmanren wrote:
> Updated the patch to use error diagnostics instead of assertion.
> 
> <<<
> It'd also be good to check that Module->ASTFile actually refers to the file 
> that we found in the prebuilt module path, and not (say) to one of its 
> transitive dependencies that ReadAST also loaded.
> 
> Did we already check this when creating the module in ASTReader?
>   if (!ParentModule) {
> if (const FileEntry *CurFile = CurrentModule->getASTFile()) {
>   if (CurFile != F.File) {
> ...
>   }
> }
> 
> CurrentModule->setASTFile(F.File);
>   }
> 
The AST reader has no idea which module we're trying to load a module file for, 
so it can't check this. The check you quoted is ensuring that we don't have two 
different module files providing the same module.

A testcase for this would be:

  module A is in prebuilt-module-cache/x.pcm
  module B is in prebuilt-module-cache/A.pcm and depends on x.pcm

When trying to load module A, ReadAST will load A.pcm, and we'll find that we 
now have a definition for module A, but we still didn't get the module from the 
expected file.


https://reviews.llvm.org/D23125



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


Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

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

LG. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D23596



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


r279004 - Support object-file-wrapped modules in clang -module-file-info.

2016-08-17 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 17 18:13:53 2016
New Revision: 279004

URL: http://llvm.org/viewvc/llvm-project?rev=279004=rev
Log:
Support object-file-wrapped modules in clang -module-file-info.

rdar://problem/24504815

Modified:
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/module_file_info.m

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=279004=279003=279004=diff
==
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Wed Aug 17 18:13:53 2016
@@ -138,6 +138,7 @@ class DumpModuleInfoAction : public ASTF
 protected:
   std::unique_ptr CreateASTConsumer(CompilerInstance ,
  StringRef InFile) override;
+  bool BeginInvocation(CompilerInstance ) override;
   void ExecuteAction() override;
 
 public:

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=279004=279003=279004=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Aug 17 
18:13:53 2016
@@ -314,25 +314,29 @@ ObjectFilePCHContainerWriter::CreatePCHC
 
 void ObjectFilePCHContainerReader::ExtractPCH(
 llvm::MemoryBufferRef Buffer, llvm::BitstreamReader ) const {
-  if (auto OF = llvm::object::ObjectFile::createObjectFile(Buffer)) {
-auto *Obj = OF.get().get();
-bool IsCOFF = isa(Obj);
+  auto OFOrErr = llvm::object::ObjectFile::createObjectFile(Buffer);
+  if (OFOrErr) {
+auto  = OFOrErr.get();
+bool IsCOFF = isa(*OF);
 // Find the clang AST section in the container.
-for (auto  : OF->get()->sections()) {
+for (auto  : OF->sections()) {
   StringRef Name;
   Section.getName(Name);
-  if ((!IsCOFF && Name == "__clangast") ||
-  ( IsCOFF && Name ==   "clangast")) {
+  if ((!IsCOFF && Name == "__clangast") || (IsCOFF && Name == "clangast")) 
{
 StringRef Buf;
 Section.getContents(Buf);
-StreamFile.init((const unsigned char *)Buf.begin(),
-(const unsigned char *)Buf.end());
-return;
+return StreamFile.init((const unsigned char *)Buf.begin(),
+   (const unsigned char *)Buf.end());
   }
 }
   }
-
-  // As a fallback, treat the buffer as a raw AST.
-  StreamFile.init((const unsigned char *)Buffer.getBufferStart(),
-  (const unsigned char *)Buffer.getBufferEnd());
+  handleAllErrors(OFOrErr.takeError(), [&](const llvm::ErrorInfoBase ) {
+if (EIB.convertToErrorCode() ==
+llvm::object::object_error::invalid_file_type)
+  // As a fallback, treat the buffer as a raw AST.
+  StreamFile.init((const unsigned char *)Buffer.getBufferStart(),
+  (const unsigned char *)Buffer.getBufferEnd());
+else
+  EIB.log(llvm::errs());
+  });
 }

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=279004=279003=279004=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Wed Aug 17 18:13:53 2016
@@ -596,6 +596,13 @@ namespace {
   };
 }
 
+bool DumpModuleInfoAction::BeginInvocation(CompilerInstance ) {
+  // The Object file reader also supports raw ast files and there is no point 
in
+  // being strict about the module file format in -module-file-info mode.
+  CI.getHeaderSearchOpts().ModuleFormat = "obj";
+  return true;
+}
+
 void DumpModuleInfoAction::ExecuteAction() {
   // Set up the output file.
   std::unique_ptr OutFile;
@@ -608,6 +615,7 @@ void DumpModuleInfoAction::ExecuteAction
   llvm::raw_ostream  = OutFile.get()? *OutFile.get() : llvm::outs();
 
   Out << "Information for module file '" << getCurrentFile() << "':\n";
+
   Preprocessor  = getCompilerInstance().getPreprocessor();
   DumpModuleInfoListener Listener(Out);
   HeaderSearchOptions  =

Modified: cfe/trunk/test/Modules/module_file_info.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module_file_info.m?rev=279004=279003=279004=diff
==
--- cfe/trunk/test/Modules/module_file_info.m (original)
+++ cfe/trunk/test/Modules/module_file_info.m Wed Aug 17 18:13:53 2016
@@ -1,10 +1,13 @@
 
 @import DependsOnModule;
 
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -w 

r279005 - Print the module format in clang -module-file-info.

2016-08-17 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 17 18:14:00 2016
New Revision: 279005

URL: http://llvm.org/viewvc/llvm-project?rev=279005=rev
Log:
Print the module format in clang -module-file-info.

Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/module_file_info.m

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=279005=279004=279005=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Wed Aug 17 18:14:00 2016
@@ -615,14 +615,19 @@ void DumpModuleInfoAction::ExecuteAction
   llvm::raw_ostream  = OutFile.get()? *OutFile.get() : llvm::outs();
 
   Out << "Information for module file '" << getCurrentFile() << "':\n";
+  auto  = getCompilerInstance().getFileManager();
+  auto Buffer = FileMgr.getBufferForFile(getCurrentFile());
+  StringRef Magic = (*Buffer)->getMemBufferRef().getBuffer();
+  bool IsRaw = (Magic.size() >= 4 && Magic[0] == 'C' && Magic[1] == 'P' &&
+Magic[2] == 'C' && Magic[3] == 'H');
+  Out << "  Module format: " << (IsRaw ? "raw" : "obj") << "\n";
 
   Preprocessor  = getCompilerInstance().getPreprocessor();
   DumpModuleInfoListener Listener(Out);
   HeaderSearchOptions  =
   PP.getHeaderSearchInfo().getHeaderSearchOpts();
   ASTReader::readASTFileControlBlock(
-  getCurrentFile(), getCompilerInstance().getFileManager(),
-  getCompilerInstance().getPCHContainerReader(),
+  getCurrentFile(), FileMgr, getCompilerInstance().getPCHContainerReader(),
   /*FindModuleFileExtensions=*/true, Listener,
   HSOpts.ModulesValidateDiagnosticOptions);
 }

Modified: cfe/trunk/test/Modules/module_file_info.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module_file_info.m?rev=279005=279004=279005=diff
==
--- cfe/trunk/test/Modules/module_file_info.m (original)
+++ cfe/trunk/test/Modules/module_file_info.m Wed Aug 17 18:14:00 2016
@@ -4,10 +4,14 @@
 // RUN: rm -rf %t %t-obj
 // RUN: %clang_cc1 -w -Wunused -fmodules -fmodule-format=raw 
-fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t -F 
%S/Inputs -DBLARG -DWIBBLE=WOBBLE -fmodule-feature myfeature %s
 // RUN: %clang_cc1 -module-file-info %t/DependsOnModule.pcm | FileCheck %s
+// RUN: %clang_cc1 -module-file-info %t/DependsOnModule.pcm | FileCheck %s 
--check-prefix=RAW
 
 // RUN: %clang_cc1 -w -Wunused -fmodules -fmodule-format=obj 
-fimplicit-module-maps -fdisable-module-hash -fmodules-cache-path=%t-obj -F 
%S/Inputs -DBLARG -DWIBBLE=WOBBLE -fmodule-feature myfeature %s
 // RUN: %clang_cc1 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s
+// RUN: %clang_cc1 -module-file-info %t-obj/DependsOnModule.pcm | FileCheck %s 
--check-prefix=OBJ
 
+// RAW:   Module format: raw
+// OBJ:   Module format: obj
 // CHECK: Generated by this Clang:
 
 // CHECK: Module name: DependsOnModule


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


Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

2016-08-17 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko marked an inline comment as done.
Eugene.Zelenko added a comment.

Repository:
  rL LLVM

https://reviews.llvm.org/D23596



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


Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

2016-08-17 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated this revision to Diff 68447.
Eugene.Zelenko added a comment.

Address Alexander's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D23596

Files:
  docs/clang-tidy/index.rst

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -48,6 +48,8 @@
 available checks or with any other value of ``-checks=`` to see which checks 
are
 enabled by this value.
 
+:: _checks-groups-table:
+
 There are currently the following groups of checks:
 
 == 
=
@@ -338,30 +340,14 @@
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
+Next, you need to decide which module the check belongs to. Modules
+are located in subdirectories of
+``clang-tidy/ 
``_
+and contain checks targeting a certain aspect of code quality (performance,
+readability, etc.), certain coding style or standard (Google, LLVM, CERT, etc.)
+or a widely used API (e.g. MPI). Their names are same as user-facing check
+groups names described :ref:`above `.
 
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably 
deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  
`_
-* `CERT Secure Coding Standards
-  
`_
-* `Google Style Guide
-  
`_
-* `LLVM Style
-  
`_
-* `modernizing C/C++ code
-  
`_
-* potential `performance problems
-  
`_
-* various `readability issues
-  
`_
-* and `miscellaneous checks
-  
`_
-  that we couldn't find a better category for.
-
 After choosing the module, you need to create a class for your check:
 
 .. code-block:: c++


Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -48,6 +48,8 @@
 available checks or with any other value of ``-checks=`` to see which checks are
 enabled by this value.
 
+:: _checks-groups-table:
+
 There are currently the following groups of checks:
 
 == =
@@ -338,30 +340,14 @@
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
+Next, you need to decide which module the check belongs to. Modules
+are located in subdirectories of
+``clang-tidy/ ``_
+and contain checks targeting a certain aspect of code quality (performance,
+readability, etc.), certain coding style or standard (Google, LLVM, CERT, etc.)
+or a widely used API (e.g. MPI). Their names are same as user-facing check
+groups names described :ref:`above `.
 
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  `_
-* `CERT Secure Coding Standards
-  `_
-* `Google Style Guide
-  `_
-* `LLVM Style
-  `_
-* `modernizing C/C++ code
-  `_
-* potential `performance problems
-  `_
-* various `readability issues
-  `_
-* and `miscellaneous checks
-  

Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

2016-08-17 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko marked 3 inline comments as done.
Eugene.Zelenko added a comment.

Repository:
  rL LLVM

https://reviews.llvm.org/D23596



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren added a comment.

Thanks,

Manman



Comment at: lib/Frontend/CompilerInstance.cpp:1502
@@ +1501,3 @@
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+if (!Module) {
+  getDiagnostics().Report(ModuleNameLoc, diag::err_module_prebuilt)

Updated the patch to use error diagnostics instead of assertion.

<<<
It'd also be good to check that Module->ASTFile actually refers to the file 
that we found in the prebuilt module path, and not (say) to one of its 
transitive dependencies that ReadAST also loaded.

Did we already check this when creating the module in ASTReader?
  if (!ParentModule) {
if (const FileEntry *CurFile = CurrentModule->getASTFile()) {
  if (CurFile != F.File) {
...
  }
}

CurrentModule->setASTFile(F.File);
  }



https://reviews.llvm.org/D23125



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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 68442.

https://reviews.llvm.org/D23125

Files:
  docs/Modules.rst
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearch.h
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/Module.h
  lib/Driver/Tools.cpp
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Lex/HeaderSearch.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ModuleManager.cpp
  test/Driver/modules.m
  test/Modules/Inputs/prebuilt-module/a.h
  test/Modules/Inputs/prebuilt-module/module.modulemap
  test/Modules/prebuilt-module.m

Index: test/Modules/prebuilt-module.m
===
--- test/Modules/prebuilt-module.m
+++ test/Modules/prebuilt-module.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -fmodules -x objective-c -I %S/Inputs/prebuilt-module -triple %itanium_abi_triple -emit-module %S/Inputs/prebuilt-module/module.modulemap -fmodule-name=prebuilt -o %t/prebuilt.pcm
+// RUN: %clang_cc1 -fmodules -fprebuilt-module-path=%t/ -fdisable-module-hash %s -verify
+
+// expected-no-diagnostics
+@import prebuilt;
+int test() {
+  return a;
+}
Index: test/Modules/Inputs/prebuilt-module/module.modulemap
===
--- test/Modules/Inputs/prebuilt-module/module.modulemap
+++ test/Modules/Inputs/prebuilt-module/module.modulemap
@@ -0,0 +1 @@
+module prebuilt { header "a.h" }
Index: test/Modules/Inputs/prebuilt-module/a.h
===
--- test/Modules/Inputs/prebuilt-module/a.h
+++ test/Modules/Inputs/prebuilt-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -39,6 +39,13 @@
 // RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
 
+// RUN: %clang -fmodules -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH_DEFAULT %s
+// MODULES_PREBUILT_PATH_DEFAULT-NOT: -fprebuilt-module-path
+
+// RUN: %clang -fmodules -fprebuilt-module-path=foo -fprebuilt-module-path=bar -### %s 2>&1 | FileCheck -check-prefix=MODULES_PREBUILT_PATH %s
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=foo"
+// MODULES_PREBUILT_PATH: "-fprebuilt-module-path=bar"
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -66,7 +66,7 @@
   // Look for the file entry. This only fails if the expected size or
   // modification time differ.
   const FileEntry *Entry;
-  if (Type == MK_ExplicitModule) {
+  if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
 // If we're not expecting to pull this file out of the module cache, it
 // might have a different mtime due to being moved across filesystems in
 // a distributed build. The size must still match, though. (As must the
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1384,7 +1384,7 @@
 // any other module's anonymous namespaces, so don't attach the anonymous
 // namespace at all.
 NamespaceDecl *Anon = cast(Reader.GetDecl(AnonNamespace));
-if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
+if (!F.isModule())
   D->setAnonymousNamespace(Anon);
   }
 }
@@ -3747,8 +3747,7 @@
   // Each module has its own anonymous namespace, which is disjoint from
   // any other module's anonymous namespaces, so don't attach the anonymous
   // namespace at all.
-  if (ModuleFile.Kind != MK_ImplicitModule &&
-  ModuleFile.Kind != MK_ExplicitModule) {
+  if (!ModuleFile.isModule()) {
 if (TranslationUnitDecl *TU = dyn_cast(D))
   TU->setAnonymousNamespace(Anon);
 else
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -1312,8 +1312,7 @@
 SrcMgr::CharacteristicKind
   FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
 SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
-if (IncludeLoc.isInvalid() &&
-(F->Kind == 

Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-17 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/ExprConstant.cpp:4795-4797
@@ +4794,5 @@
+  if (VD->hasLocalStorage() && Info.CurrentCall->Index > 1) {
+// Only if the DeclContext of VD is the same as the called function do we
+// set the Frame to the Current CallStackFrame, so that we can find its
+// associated value from the variable-objects associated with that frame.
+if (Info.CurrentCall->Callee && isa(VD->getDeclContext()) &&

This is talking too much about the what and not enough about the why. "We 
expect to find a value for a local variable in the current frame, unless the 
variable was actually declared in a lexically-enclosing context." or something 
like that?


Comment at: lib/AST/ExprConstant.cpp:4798-4800
@@ +4797,5 @@
+// associated value from the variable-objects associated with that frame.
+if (Info.CurrentCall->Callee && isa(VD->getDeclContext()) &&
+cast(VD->getDeclContext()->getRedeclContext())
+->getFirstDecl() == Info.CurrentCall->Callee->getFirstDecl()) {
+  Frame = Info.CurrentCall;

This can be specified more simply as:

  if (Info.CurrentCall->Callee &&
  Info.CurrentCall->Callee->Equals(VD->getDeclContext()))


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:190
@@ -189,3 +189,3 @@
   if (A->getCond()->isValueDependent() && !Cond->isValueDependent() &&
-  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(Tmpl),
+  !Expr::isPotentialConstantExprUnevaluated(Cond, cast(New),
 Diags)) {

Do we have existing test coverage for this (tests that fail with the 
ExprConstant change if we don't fix this at the same time)?


Comment at: test/SemaCXX/constant-expression-cxx11.cpp:2091
@@ +2090,3 @@
+  };
+  constexpr int CD = X::f();
+}

Maybe also `static_assert` that we get the correct value here?


https://reviews.llvm.org/D23493



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


Re: [clang-tools-extra] r278949 - [Include-fixer] Install executables and support scripts

2016-08-17 Thread Hans Wennborg via cfe-commits
On Wed, Aug 17, 2016 at 10:27 AM, Eugene Zelenko via cfe-commits
 wrote:
> Author: eugenezelenko
> Date: Wed Aug 17 12:27:56 2016
> New Revision: 278949
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278949=rev
> Log:
> [Include-fixer] Install executables and support scripts
>
> Differential revision: https://reviews.llvm.org/D23045
>
> Modified:
> clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
> clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt

I've merged this (excluding the clang-include-fixer.el part) to 3.9 in r278997.

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


Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: docs/clang-tidy/index.rst:343
@@ +342,3 @@
+are located in subdirectories of
+``clang-tidy/ 
``_.
+Their names are same as user-facing check groups names described above.

`are located in subdirectories of  and contain checks targeting a certain 
aspect of code quality (performance, readability, etc.), certain coding style 
or standard (Google, LLVM, CERT, etc.) or a widely used API (e.g. MPI).`


Comment at: docs/clang-tidy/index.rst:344
@@ +343,3 @@
+``clang-tidy/ 
``_.
+Their names are same as user-facing check groups names described above.
+If the check verifies conformance of the code to a certain coding style, it

Could you linkify `above`?


Comment at: docs/clang-tidy/index.rst:345
@@ +344,3 @@
+Their names are same as user-facing check groups names described above.
+If the check verifies conformance of the code to a certain coding style, it
+probably deserves a separate module and a directory in ``clang-tidy/``.

The "If the check verifies..." sentence is now somewhat tautological, just 
remove it.


Repository:
  rL LLVM

https://reviews.llvm.org/D23596



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


Re: [PATCH] D23627: [CUDA] Improve handling of math functions.

2016-08-17 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: clang/lib/Headers/__clang_cuda_cmath.h:125-133
@@ -122,8 +124,11 @@
 __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); 
}
-__DEVICE__ float nexttoward(float __from, float __to) {
+__DEVICE__ float nexttoward(float __from, double __to) {
   return __builtin_nexttowardf(__from, __to);
 }
 __DEVICE__ double nexttoward(double __from, double __to) {
   return __builtin_nexttoward(__from, __to);
 }
+__DEVICE__ float nexttowardf(float __from, double __to) {
+  return __builtin_nexttowardf(__from, __to);
+}
 __DEVICE__ float pow(float __base, float __exp) {

You've got two identical `nexttoward(float, double)` now.
Perhaps first one was supposed to remain `nexttoward(float, float)` ?




Comment at: clang/lib/Headers/__clang_cuda_cmath.h:184-197
@@ +183,16 @@
+
+// Defines an overload of __fn that accepts one two arithmetic arguments, calls
+// __fn((double)x, (double)y), and returns a double.
+//
+// Note this is different from OVERLOAD_1, which generates an overload that
+// accepts only *integral* arguments.
+#define __CUDA_CLANG_FN_INTEGER_OVERLOAD_2(__retty, __fn)  
\
+  template   
\
+  __DEVICE__ typename __clang_cuda_enable_if<  
\
+  std::numeric_limits<__T1>::is_specialized && 
\
+  std::numeric_limits<__T2>::is_specialized,   
\
+  __retty>::type   
\
+  __fn(__T1 __x, __T2 __y) {   
\
+return __fn((double)__x, (double)__y); 
\
+  }
+

`is_specialized` will be true for `long double` args and we'll instantiate the 
function. Can we/should we produce an error instead?


https://reviews.llvm.org/D23627



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


Re: [libcxx] r278904 - Support allocators with explicit conversion constructors. Fixes bug #29000

2016-08-17 Thread Hans Wennborg via cfe-commits
I'd rather not take this actually, as it looks like a large change,
isn't fixing a regression, and it's time to start wrapping up the
release.

On Wed, Aug 17, 2016 at 3:46 AM, Dimitry Andric  wrote:
> Marshall, this is maybe a good candidate for merging to release_39?
>
> -Dimitry
>
>> On 17 Aug 2016, at 07:58, Marshall Clow via cfe-commits 
>>  wrote:
>>
>> Author: marshall
>> Date: Wed Aug 17 00:58:40 2016
>> New Revision: 278904
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=278904=rev
>> Log:
>> Support allocators with explicit conversion constructors. Fixes bug #29000
>>
>> Modified:
>>libcxx/trunk/include/map
>>libcxx/trunk/include/unordered_map
>>libcxx/trunk/test/std/containers/associative/map/map.cons/alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp
>>libcxx/trunk/test/std/containers/associative/map/map.cons/default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp
>>libcxx/trunk/test/std/containers/associative/set/set.cons/default.pass.cpp
>>libcxx/trunk/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
>>libcxx/trunk/test/std/containers/sequences/list/list.cons/default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
>>
>> libcxx/trunk/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
>>libcxx/trunk/test/std/strings/basic.string/string.cons/alloc.pass.cpp
>>libcxx/trunk/test/support/min_allocator.h
>>
>> Modified: libcxx/trunk/include/map
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=278904=278903=278904=diff
>> ==
>> --- libcxx/trunk/include/map (original)
>> +++ libcxx/trunk/include/map Wed Aug 17 00:58:40 2016
>> @@ -873,7 +873,7 @@ public:
>>
>> _LIBCPP_INLINE_VISIBILITY
>> explicit map(const key_compare& __comp, const allocator_type& __a)
>> -: 

Re: Nomination for 3.9: r278786 - Left shifts of negative values are defined if -fwrapv is set

2016-08-17 Thread Hans Wennborg via cfe-commits
r278989.

Thanks,
Hans

On Tue, Aug 16, 2016 at 6:46 PM, Richard Smith  wrote:
> Looks fine to me. (At one point we were deliberately not following GCC in
> making -fwrapv affect left shift, because it's a bit operation rather than
> an arithmetic one, but this is ultimately supposed to be a GCC-compatible
> flag so behaving as they do seems reasonable.)
>
>
> On Tue, Aug 16, 2016 at 9:38 AM, Aaron Ballman 
> wrote:
>>
>> I'm not Richard, but I agree with merging it into 3.9 nonetheless. :-)
>>
>> ~Aaron
>>
>> On Tue, Aug 16, 2016 at 12:30 PM, Hans Wennborg via cfe-commits
>>  wrote:
>> > Seems reasonable to me if Richard agrees.
>> >
>> > On Tue, Aug 16, 2016 at 3:01 AM, James Molloy 
>> > wrote:
>> >> Hi Hans,
>> >>
>> >> [cc. Richard as code owner]
>> >>
>> >> I'd like to nominate this commit for 3.9. The actual code churn is
>> >> tiny, and
>> >> this fixes a problem noticed by and causing pain to the qemu project.
>> >>
>> >> Cheers,
>> >>
>> >> James
>> >>
>> >> On Tue, 16 Aug 2016 at 10:53 James Molloy via cfe-commits
>> >>  wrote:
>> >>>
>> >>> Author: jamesm
>> >>> Date: Tue Aug 16 04:45:36 2016
>> >>> New Revision: 278786
>> >>>
>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=278786=rev
>> >>> Log:
>> >>> Left shifts of negative values are defined if -fwrapv is set
>> >>>
>> >>> This means we shouldn't emit ubsan detection code or warn.
>> >>> Fixes PR25552.
>> >>>
>> >>> Added:
>> >>> cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
>> >>> cfe/trunk/test/Sema/negative-shift-wrapv.c
>> >>> Modified:
>> >>> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> >>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> >>>
>> >>> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
>> >>> URL:
>> >>>
>> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=278786=278785=278786=diff
>> >>>
>> >>>
>> >>> ==
>> >>> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
>> >>> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Aug 16 04:45:36 2016
>> >>> @@ -2714,7 +2714,8 @@ Value *ScalarExprEmitter::EmitShl(const
>> >>>  RHS = Builder.CreateIntCast(RHS, Ops.LHS->getType(), false,
>> >>> "sh_prom");
>> >>>
>> >>>bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) &&
>> >>> -  Ops.Ty->hasSignedIntegerRepresentation();
>> >>> +  Ops.Ty->hasSignedIntegerRepresentation() &&
>> >>> +  !CGF.getLangOpts().isSignedOverflowDefined();
>> >>>bool SanitizeExponent =
>> >>> CGF.SanOpts.has(SanitizerKind::ShiftExponent);
>> >>>// OpenCL 6.3j: shift values are effectively % word size of LHS.
>> >>>if (CGF.getLangOpts().OpenCL)
>> >>>
>> >>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> >>> URL:
>> >>>
>> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=278786=278785=278786=diff
>> >>>
>> >>>
>> >>> ==
>> >>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> >>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 16 04:45:36 2016
>> >>> @@ -8670,7 +8670,7 @@ static void DiagnoseBadShiftValues(Sema&
>> >>>
>> >>>// If LHS does not have a signed type and non-negative value
>> >>>// then, the behavior is undefined. Warn about it.
>> >>> -  if (Left.isNegative()) {
>> >>> +  if (Left.isNegative() &&
>> >>> !S.getLangOpts().isSignedOverflowDefined()) {
>> >>>  S.DiagRuntimeBehavior(Loc, LHS.get(),
>> >>>S.PDiag(diag::warn_shift_lhs_negative)
>> >>>  << LHS.get()->getSourceRange());
>> >>>
>> >>> Added: cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c
>> >>> URL:
>> >>>
>> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c?rev=278786=auto
>> >>>
>> >>>
>> >>> ==
>> >>> --- cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c (added)
>> >>> +++ cfe/trunk/test/CodeGen/wrapv-lshr-sanitize.c Tue Aug 16 04:45:36
>> >>> 2016
>> >>> @@ -0,0 +1,12 @@
>> >>> +// RUN: %clang_cc1 -fsanitize=shift-base -emit-llvm %s -o - -triple
>> >>> x86_64-linux-gnu -fwrapv | FileCheck %s
>> >>> +
>> >>> +// CHECK-LABEL: @lsh_overflow
>> >>> +int lsh_overflow(int a, int b) {
>> >>> +  // CHECK-NOT: br
>> >>> +  // CHECK-NOT: call void @__ubsan_
>> >>> +  // CHECK-NOT: call void @llvm.trap
>> >>> +
>> >>> +  // CHECK:  %[[RET:.*]] = shl i32
>> >>> +  // CHECK-NEXT: ret i32 %[[RET]]
>> >>> +  return a << b;
>> >>> +}
>> >>>
>> >>> Added: cfe/trunk/test/Sema/negative-shift-wrapv.c
>> >>> URL:
>> >>>
>> >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/negative-shift-wrapv.c?rev=278786=auto
>> >>>
>> >>>
>> >>> ==

Re: [PATCH] D23531: [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-17 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278988: [Darwin] Stop linking libclang_rt.eprintf.a 
(authored by cbieneman).

Changed prior to commit:
  https://reviews.llvm.org/D23531?vs=68102=68429#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23531

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp

Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -472,21 +472,26 @@
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -472,21 +472,26 @@
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278988 - [Darwin] Stop linking libclang_rt.eprintf.a

2016-08-17 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Wed Aug 17 16:54:30 2016
New Revision: 278988

URL: http://llvm.org/viewvc/llvm-project?rev=278988=rev
Log:
[Darwin] Stop linking libclang_rt.eprintf.a

Summary:
The eprintf library was added before the general OS X builtins library existed 
as a place to store one builtin function. Since we have for several years had 
an actual mandated builtin library for OS X > 10.5, we should just merge 
eprintf into the main library.

This change will resolve PR28855.

As a follow up I'll also patch compiler-rt to not generate the eprintf library 
anymore.

Reviewers: ddunbar, bob.wilson

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=278988=278987=278988=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Aug 17 16:54:30 2016
@@ -472,21 +472,26 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 else if (isMacosxVersionLT(10, 6))
   CmdArgs.push_back("-lgcc_s.10.5");
 
-// For OS X, we thought we would only need a static runtime library when
-// targeting 10.4, to provide versions of the static functions which were
-// omitted from 10.4.dylib.
+// Originally for OS X, we thought we would only need a static runtime
+// library when targeting 10.4, to provide versions of the static functions
+// which were omitted from 10.4.dylib. This led to the creation of the 10.4
+// builtins library.
 //
 // Unfortunately, that turned out to not be true, because Darwin system
 // headers can still use eprintf on i386, and it is not exported from
 // libSystem. Therefore, we still must provide a runtime library just for
 // the tiny tiny handful of projects that *might* use that symbol.
-if (isMacosxVersionLT(10, 5)) {
+//
+// Then over time, we figured out it was useful to add more things to the
+// runtime so we created libclang_rt.osx.a to provide new functions when
+// deploying to old OS builds, and for a long time we had both eprintf and
+// osx builtin libraries. Which just seems excessive. So with PR 28855, we
+// are removing the eprintf library and expecting eprintf to be provided by
+// the OS X builtins library.
+if (isMacosxVersionLT(10, 5))
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.10.4.a");
-} else {
-  if (getTriple().getArch() == llvm::Triple::x86)
-AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.eprintf.a");
+else
   AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.osx.a");
-}
   }
 }
 


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


Re: [PATCH] D23125: Modules: add command line option to support loading prebuilt modules on demand, without parsing any module map

2016-08-17 Thread Richard Smith via cfe-commits
rsmith added a comment.

Just a couple of things, but this basically LGTM.



Comment at: docs/Modules.rst:217
@@ +216,3 @@
+``-fprebuilt-module-path=``
+  Specify the path to the prebuilt modules. If specified, we will look for 
modules in this directory for a given top-level module name. We don't need a 
module map for loading prebuilt modules in this directory and the compiler will 
not try to rebuild these modules.
+

Please document that the option can be given multiple times.


Comment at: lib/Frontend/CompilerInstance.cpp:1502
@@ +1501,3 @@
+Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);
+assert(Module && "ReadAST should construct a Module instance");
+  }

This should have a real diagnostic rather than an assertion. This would happen 
if the pcm file in the prebuilt module path had the wrong filename, for 
instance.

It'd also be good to check that `Module->ASTFile` actually refers to the file 
that we found in the prebuilt module path, and not (say) to one of its 
transitive dependencies that `ReadAST` also loaded.


https://reviews.llvm.org/D23125



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


r278987 - [CMake] Adding toolchain targets to PGO and Apple CMake caches

2016-08-17 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Wed Aug 17 16:51:38 2016
New Revision: 278987

URL: http://llvm.org/viewvc/llvm-project?rev=278987=rev
Log:
[CMake] Adding toolchain targets to PGO and Apple CMake caches

The Xcode toolchain targets are useful on OS X hosts because you can construct 
and install multiple toolchians that can be used seamlessly.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake
cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
cfe/trunk/cmake/caches/PGO.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=278987=278986=278987=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Wed Aug 17 16:51:38 2016
@@ -20,6 +20,8 @@ set(BUG_REPORT_URL "http://developer.app
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "Build Compiler-RT with 
just-built clang")
 set(COMPILER_RT_ENABLE_IOS ON CACHE BOOL "Build iOS Compiler-RT libraries")
 
+set(LLVM_CREATE_XCODE_TOOLCHAIN ON CACHE BOOL "Generate targets to create and 
install an Xcode compatable toolchain")
+
 # Make unit tests (if present) part of the ALL target
 set(LLVM_BUILD_TESTS ON CACHE BOOL "")
 

Modified: cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake?rev=278987=278986=278987=diff
==
--- cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake (original)
+++ cfe/trunk/cmake/caches/PGO-stage2-instrumented.cmake Wed Aug 17 16:51:38 
2016
@@ -2,6 +2,7 @@ set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL
 set(CLANG_BOOTSTRAP_TARGETS
   distribution
   install-distribution
+  install-distribution-toolchain
   check-all
   check-llvm
   check-clang

Modified: cfe/trunk/cmake/caches/PGO.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/PGO.cmake?rev=278987=278986=278987=diff
==
--- cfe/trunk/cmake/caches/PGO.cmake (original)
+++ cfe/trunk/cmake/caches/PGO.cmake Wed Aug 17 16:51:38 2016
@@ -9,6 +9,7 @@ set(CLANG_BOOTSTRAP_TARGETS
   stage2
   stage2-distribution
   stage2-install-distribution
+  stage2-install-distribution-toolchain
   stage2-check-all
   stage2-check-llvm
   stage2-check-clang


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


r278984 - Add test missed from r278983.

2016-08-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Aug 17 16:42:10 2016
New Revision: 278984

URL: http://llvm.org/viewvc/llvm-project?rev=278984=rev
Log:
Add test missed from r278983.

Added:
cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp

Added: cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp?rev=278984=auto
==
--- cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp Wed Aug 17 
16:42:10 2016
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-backtrace-limit 2 %s
+
+template struct X : X {};
+// expected-error-re@3 {{recursive template instantiation exceeded maximum 
depth of 1024{{$
+// expected-note@3 {{instantiation of template class}}
+// expected-note@3 {{skipping 1023 contexts in backtrace}}
+// expected-note@3 {{use -ftemplate-depth=N to increase recursive template 
instantiation depth}}
+
+X<0, int> x; // expected-note {{in instantiation of}}


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


r278983 - PR18417: Increase -ftemplate-depth to the value 1024 recommended by the C++

2016-08-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Aug 17 16:41:45 2016
New Revision: 278983

URL: http://llvm.org/viewvc/llvm-project?rev=278983=rev
Log:
PR18417: Increase -ftemplate-depth to the value 1024 recommended by the C++
standard's Annex B. We now attempt to increase the process's stack rlimit to
8MiB on startup, which appears to be enough to allow this to work reliably.
(And if it turns out not to be, we can investigate increasing it further.)

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=278983=278982=278983=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Aug 17 16:41:45 2016
@@ -235,7 +235,7 @@ ENUM_LANGOPT(SignedOverflowBehavior, Sig
 
 BENIGN_LANGOPT(ArrowDepth, 32, 256,
"maximum number of operator->s to follow")
-BENIGN_LANGOPT(InstantiationDepth, 32, 256,
+BENIGN_LANGOPT(InstantiationDepth, 32, 1024,
"maximum template instantiation depth")
 BENIGN_LANGOPT(ConstexprCallDepth, 32, 512,
"maximum constexpr call depth")

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=278983=278982=278983=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Aug 17 16:41:45 2016
@@ -1910,7 +1910,7 @@ static void ParseLangArgs(LangOptions 
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);
   Opts.MathErrno = !Opts.OpenCL && Args.hasArg(OPT_fmath_errno);
   Opts.InstantiationDepth =
-  getLastArgIntValue(Args, OPT_ftemplate_depth, 256, Diags);
+  getLastArgIntValue(Args, OPT_ftemplate_depth, 1024, Diags);
   Opts.ArrowDepth =
   getLastArgIntValue(Args, OPT_foperator_arrow_depth, 256, Diags);
   Opts.ConstexprCallDepth =


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


[PATCH] D23628: Fix unittests after windows command line parsing

2016-08-17 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added a reviewer: alexfh.
zturner added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

After submitting the windows command line parsing patch, it broke all the 
command line parsing unittests, because now they were trying parse gnu command 
lines using the windows command line parser.  The patch is reverted for now 
until we get these unit tests fixed.

I'm not sure what the best solution is.  One option is to disable those tests 
on Windows.  But that seems undesirable because it was only some of the tests, 
and others worked fine.  Not all the tests even depended on a command line in 
the first place.  So I decided to expose the command syntax through the API.  
You can either force it to Gnu, force it to Windows, and let it auto-detect.  
The unit tests all force it to Gnu for the sake of simplicity, since the 
Windows command line tokenizer is already rigorously tested in LLVM.

This also kind of lines up with the idea I had in the previous code review for 
exposing a command line option in `CommonOptions.cpp` to override the command 
syntax so we don't have to guess.  So if someone decides to do that in the 
future that should be easier now.

https://reviews.llvm.org/D23628

Files:
  include/clang/Tooling/JSONCompilationDatabase.h
  lib/Tooling/JSONCompilationDatabase.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp

Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -21,9 +21,10 @@
 
 static void expectFailure(StringRef JSONDatabase, StringRef Explanation) {
   std::string ErrorMessage;
-  EXPECT_EQ(nullptr, JSONCompilationDatabase::loadFromBuffer(JSONDatabase,
- ErrorMessage))
-<< "Expected an error because of: " << Explanation.str();
+  EXPECT_EQ(nullptr,
+JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage,
+JSONCommandLineSyntax::Gnu))
+  << "Expected an error because of: " << Explanation.str();
 }
 
 TEST(JSONCompilationDatabase, ErrsOnInvalidFormat) {
@@ -46,20 +47,24 @@
 }
 
 static std::vector getAllFiles(StringRef JSONDatabase,
-std::string ) {
+std::string ,
+JSONCommandLineSyntax Syntax) {
   std::unique_ptr Database(
-  JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage));
+  JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage,
+  Syntax));
   if (!Database) {
 ADD_FAILURE() << ErrorMessage;
 return std::vector();
   }
   return Database->getAllFiles();
 }
 
-static std::vector getAllCompileCommands(StringRef JSONDatabase,
-std::string ) {
+static std::vector
+getAllCompileCommands(JSONCommandLineSyntax Syntax, StringRef JSONDatabase,
+  std::string ) {
   std::unique_ptr Database(
-  JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage));
+  JSONCompilationDatabase::loadFromBuffer(JSONDatabase, ErrorMessage,
+  Syntax));
   if (!Database) {
 ADD_FAILURE() << ErrorMessage;
 return std::vector();
@@ -70,28 +75,32 @@
 TEST(JSONCompilationDatabase, GetAllFiles) {
   std::string ErrorMessage;
   EXPECT_EQ(std::vector(),
-getAllFiles("[]", ErrorMessage)) << ErrorMessage;
+getAllFiles("[]", ErrorMessage, JSONCommandLineSyntax::Gnu))
+  << ErrorMessage;
 
   std::vector expected_files;
   SmallString<16> PathStorage;
   llvm::sys::path::native("//net/dir/file1", PathStorage);
   expected_files.push_back(PathStorage.str());
   llvm::sys::path::native("//net/dir/file2", PathStorage);
   expected_files.push_back(PathStorage.str());
-  EXPECT_EQ(expected_files, getAllFiles(
-"[{\"directory\":\"//net/dir\","
-  "\"command\":\"command\","
-  "\"file\":\"file1\"},"
-" {\"directory\":\"//net/dir\","
-  "\"command\":\"command\","
-  "\"file\":\"file2\"}]",
-ErrorMessage)) << ErrorMessage;
+  EXPECT_EQ(expected_files,
+getAllFiles("[{\"directory\":\"//net/dir\","
+"\"command\":\"command\","
+"\"file\":\"file1\"},"
+" {\"directory\":\"//net/dir\","
+"\"command\":\"command\","
+"\"file\":\"file2\"}]",
+ErrorMessage, JSONCommandLineSyntax::Gnu))
+  << ErrorMessage;
 }
 
 TEST(JSONCompilationDatabase, GetAllCompileCommands) {
   std::string ErrorMessage;
-  EXPECT_EQ(0u,
-getAllCompileCommands("[]", ErrorMessage).size()) << ErrorMessage;
+  EXPECT_EQ(

[PATCH] D23627: [CUDA] Improve handling of math functions.

2016-08-17 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

A bunch of related changes here to our CUDA math headers.

- The second arg to nexttoward is a double (well, technically, long
  double, but we don't have that), not a float.

- Add a forward-declare of llround(float), which is defined in the CUDA
  headers.  We need this for the same reason we need most of the other
  forward-declares: To prevent a constexpr function in our standard
  library from becoming host+device.

- Add nexttowardf implementation.

- Pull "foobarf" functions defined by the CUDA headers in the global
  namespace into namespace std.  This lets you do e.g. std::sinf.

- Add overloads for math functions accepting integer types.  This lets
  you do e.g. std::sin(0) without having an ambiguity between the
  overload that takes a float and the one that takes a double.

With these changes, we pass testcases derived from libc++ for cmath and
math.h.  We can check these testcases in to the test-suite once support
for CUDA lands there.

https://reviews.llvm.org/D23627

Files:
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h

Index: clang/lib/Headers/__clang_cuda_math_forward_declares.h
===
--- clang/lib/Headers/__clang_cuda_math_forward_declares.h
+++ clang/lib/Headers/__clang_cuda_math_forward_declares.h
@@ -140,6 +140,7 @@
 __DEVICE__ long lrint(float);
 __DEVICE__ long lround(double);
 __DEVICE__ long lround(float);
+__DEVICE__ long long llround(float); // No llround(double).
 __DEVICE__ double modf(double, double *);
 __DEVICE__ float modf(float, float *);
 __DEVICE__ double nan(const char *);
@@ -149,7 +150,8 @@
 __DEVICE__ double nextafter(double, double);
 __DEVICE__ float nextafter(float, float);
 __DEVICE__ double nexttoward(double, double);
-__DEVICE__ float nexttoward(float, float);
+__DEVICE__ float nexttoward(float, double);
+__DEVICE__ float nexttowardf(float, double);
 __DEVICE__ double pow(double, double);
 __DEVICE__ double pow(double, int);
 __DEVICE__ float pow(float, float);
@@ -235,6 +237,7 @@
 using ::logb;
 using ::lrint;
 using ::lround;
+using ::llround;
 using ::modf;
 using ::nan;
 using ::nanf;
Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -26,13 +26,15 @@
 #error "This file is for CUDA compilation only."
 #endif
 
+#include 
+
 // CUDA lets us use various std math functions on the device side.  This file
 // works in concert with __clang_cuda_math_forward_declares.h to make this work.
 //
 // Specifically, the forward-declares header declares __device__ overloads for
 // these functions in the global namespace, then pulls them into namespace std
 // with 'using' statements.  Then this file implements those functions, after
-// the implementations have been pulled in.
+// their implementations have been pulled in.
 //
 // It's important that we declare the functions in the global namespace and pull
 // them into namespace std with using statements, as opposed to simply declaring
@@ -120,12 +122,15 @@
 __DEVICE__ float log(float __x) { return ::logf(__x); }
 __DEVICE__ float log10(float __x) { return ::log10f(__x); }
 __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); }
-__DEVICE__ float nexttoward(float __from, float __to) {
+__DEVICE__ float nexttoward(float __from, double __to) {
   return __builtin_nexttowardf(__from, __to);
 }
 __DEVICE__ double nexttoward(double __from, double __to) {
   return __builtin_nexttoward(__from, __to);
 }
+__DEVICE__ float nexttowardf(float __from, double __to) {
+  return __builtin_nexttowardf(__from, __to);
+}
 __DEVICE__ float pow(float __base, float __exp) {
   return ::powf(__base, __exp);
 }
@@ -143,6 +148,280 @@
 __DEVICE__ float tan(float __x) { return ::tanf(__x); }
 __DEVICE__ float tanh(float __x) { return ::tanhf(__x); }
 
+// Now we've defined everything we promised we'd define in
+// __clang_cuda_math_forward_declares.h.  We need to do two additional things to
+// fix up our math functions.
+//
+// 1) Define __device__ overloads for e.g. sin(int).  The CUDA headers define
+//only sin(float) and sin(double), which means that e.g. sin(0) is
+//ambiguous.
+//
+// 2) Pull the __device__ overloads of "foobarf" math functions into namespace
+//std.  These are defined in the CUDA headers in the global namespace,
+//independent of everything else we've done here.
+
+// We can't use std::enable_if, because we want to be pre-C++11 compatible.  But
+// we go ahead and unconditionally define functions that are only available when
+// compiling for C++11 to match the behavior of the CUDA headers.
+template
+struct __clang_cuda_enable_if {};
+
+template  struct __clang_cuda_enable_if {
+  typedef __T type;
+};
+

Re: [PATCH] D20132: [libclang] Add clang_getAllSkippedRanges function

2016-08-17 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
This revision is now accepted and ready to land.


Comment at: unittests/libclang/LibclangTest.cpp:16-20
@@ -15,4 +15,7 @@
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
+#include 
+#include 
 #define DEBUG_TYPE "libclang-test"

Please put these in alphabetical order.


https://reviews.llvm.org/D20132



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


Re: [PATCH] D23314: [analyzer] CloneDetector allows comparing clones for suspicious variable pattern errors.

2016-08-17 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 68422.
teemperor marked 11 inline comments as done.
teemperor added a comment.

- Made warning messages more 'clangish' as pointed out by Vassil (Thanks!)
- Improved the class/variable names as pointed out by Artem (Thanks a lot!)
- CloneChecker's functions are now out-of-line.


https://reviews.llvm.org/D23314

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/suspicious-clones.cpp

Index: test/Analysis/copypaste/suspicious-clones.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/suspicious-clones.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:ReportSuspiciousClones=true  -analyzer-config alpha.clone.CloneChecker:ReportNormalClones=false -verify %s
+
+// Tests finding a suspicious clone that references local variables.
+
+void log();
+
+int max(int a, int b) {
+  log();
+  if (a > b)
+return a;
+  return b; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+}
+
+int maxClone(int x, int y, int z) {
+  log();
+  if (x > y)
+return x;
+  return z; // expected-warning{{suspicious code clone detected; did you mean to use 'y'?}}
+}
+
+// Tests finding a suspicious clone that references global variables.
+
+struct mutex {
+  bool try_lock();
+  void unlock();
+};
+
+mutex m1;
+mutex m2;
+int i;
+
+void busyIncrement() {
+  while (true) {
+if (m1.try_lock()) {
+  ++i;
+  m1.unlock(); // expected-note{{suggestion is based on the usage of this variable in a similar piece of code}}
+  if (i > 1000) {
+return;
+  }
+}
+  }
+}
+
+void faultyBusyIncrement() {
+  while (true) {
+if (m1.try_lock()) {
+  ++i;
+  m2.unlock();  // expected-warning{{suspicious code clone detected; did you mean to use 'm1'?}}
+  if (i > 1000) {
+return;
+  }
+}
+  }
+}
+
+// Tests that we provide two suggestions in cases where two fixes are possible.
+
+int foo(int a, int b, int c) {
+  a += b + c;
+  b /= a + b;
+  c -= b * a; // expected-warning{{suspicious code clone detected; did you mean to use 'a'?}}
+  return c;
+}
+
+int fooClone(int a, int b, int c) {
+  a += b + c;
+  b /= a + b;
+  c -= a * a; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}}
+  return c;
+}
+
+
+// Tests that for clone groups with a many possible suspicious clone pairs, at
+// most one warning per clone group is generated and every relevant clone is
+// reported through either a warning or a note.
+
+long bar1(long a, long b, long c, long d) {
+  c = a - b;
+  c = c / d * a;
+  d = b * b - c; // expected-warning{{suspicious code clone detected; did you mean to use 'c'?}}
+  return d;
+}
+
+long bar2(long a, long b, long c, long d) {
+  c = a - b;
+  c = c / d * a;
+  d = c * b - c; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'b'?}} \
+ // expected-warning{{suspicious code clone detected; did you mean to use 'a'?}}
+  return d;
+}
+
+long bar3(long a, long b, long c, long d) {
+  c = a - b;
+  c = c / d * a;
+  d = a * b - c; // expected-note{{suggestion is based on the usage of this variable in a similar piece of code; did you mean to use 'c'?}}
+  return d;
+}
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CloneChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -26,22 +26,31 @@
 namespace {
 class CloneChecker
 : public Checker {
-  mutable CloneDetector CloneDetector;
+  mutable CloneDetector Detector;
 
 public:
   void checkASTCodeBody(const Decl *D, AnalysisManager ,
 BugReporter ) const;
 
   void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
  AnalysisManager , BugReporter ) const;
+
+  /// \brief Reports all clones to the user.
+  void reportClones(SourceManager , AnalysisManager ,
+int MinComplexity) const;
+
+  /// \brief Reports only suspicious clones to the user along with informaton
+  ///that explain why they are suspicious.
+  void reportSuspiciousClones(SourceManager , AnalysisManager ,
+  int MinComplexity) const;
 };
 } // end anonymous namespace
 
 void CloneChecker::checkASTCodeBody(const Decl *D, AnalysisManager ,
 BugReporter ) const {
   // Every statement that should be included in the search for clones needs to
   // be passed to the CloneDetector.
-  CloneDetector.analyzeCodeBody(D);
+  Detector.analyzeCodeBody(D);
 }
 
 void 

Re: [PATCH] D23314: [analyzer] CloneDetector allows comparing clones for suspicious variable pattern errors.

2016-08-17 Thread Raphael Isemann via cfe-commits
teemperor added inline comments.


Comment at: test/Analysis/copypaste/suspicious-clones.cpp:11
@@ +10,3 @@
+return a;
+  return b; // expected-note{{Suggestion is based on the useage of this 
variable in a similar piece of code.}}
+}

v.g.vassilev wrote:
> This note here is very obscure. It doesn't contain a lot of meaningful 
> information. It should give a hint where is this similar piece of code.
The note is paired with a warning as discussed in last meeting, so I'll mark 
this as done :).


https://reviews.llvm.org/D23314



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


Re: [PATCH] D23595: [Clang] Fix some Clang-tidy modernize-use-using and Include What You Use warnings

2016-08-17 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko marked an inline comment as done.


Comment at: include/clang/Basic/IdentifierTable.h:103
@@ -95,1 +102,3 @@
+return getLength() == StrLen-1 &&
+   memcmp(getNameStart(), Str, StrLen-1) == 0;
   }

memcpy result is three state, so applying Boolean operator is not correct.


Comment at: include/clang/Lex/PreprocessorOptions.h:22
@@ -23,2 +21,3 @@
 namespace llvm {
+
   class MemoryBuffer;

I wanted to make spacing consistent. Same in other places.

Actually, Include What You Use recommended to include MemoryBuffer.h. 
MemoryBuffer is used in smart pointers, but I remember that I encountered 
problems in LLDB MSVC builds, where forward declaration was not enough for such 
usage.


Repository:
  rL LLVM

https://reviews.llvm.org/D23595



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


Re: [PATCH] D23492: Make function local tags visible.

2016-08-17 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3608-3609
@@ -3600,1 +3607,4 @@
+
+  // TODO: Check if we could sink these diagnostics in
+  // DiagnoseUninstantiableTemplate.
   if (!Pattern && !PatternDecl->isDefaulted()) {

If you can do that, it would be preferable. You'll presumably need to change 
the `PatternDecl` argument to `PatternDecl->isThisDeclarationADefinition() || 
PatternDecl->isDefaulted() ? PatternDecl : nullptr` or similar.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3670-3673
@@ -3662,1 +3669,6 @@
 
+  // Q: Shall we add this here for consistency with InstantiateClass and 
InstantiateEnum.
+  // The instantiation is visible here, even if it was first declared in an
+  // unimported module.
+  //Function->setHidden(false);
+

Yes, let's do this. It's not quite right, but the same is true for the 
`InstantiateClass` and `InstantiateEnum` cases, and it makes sense to handle 
all those cases the same way.


https://reviews.llvm.org/D23492



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


Re: [PATCH] D23595: [Clang] Fix some Clang-tidy modernize-use-using and Include What You Use warnings

2016-08-17 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated this revision to Diff 68423.
Eugene.Zelenko added a comment.

Apply Clang-format.


Repository:
  rL LLVM

https://reviews.llvm.org/D23595

Files:
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/IdentifierTable.h
  include/clang/Frontend/ASTUnit.h
  include/clang/Lex/PreprocessorOptions.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/Scope.h

Index: include/clang/Lex/PreprocessorOptions.h
===
--- include/clang/Lex/PreprocessorOptions.h
+++ include/clang/Lex/PreprocessorOptions.h
@@ -7,28 +7,25 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H_
-#define LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H_
+#ifndef LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H
+#define LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H
 
-#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
-#include 
 #include 
 #include 
 #include 
 #include 
 
 namespace llvm {
+
   class MemoryBuffer;
-}
 
+} // end namespace llvm
+
 namespace clang {
 
-class Preprocessor;
-class LangOptions;
-
 /// \brief Enumerate the kinds of standard library that 
 enum ObjCXXARCStandardLibraryKind {
   ARCXX_nolib,
@@ -175,10 +172,10 @@
 TokenCache.clear();
 RetainRemappedFileBuffers = true;
 PrecompiledPreambleBytes.first = 0;
-PrecompiledPreambleBytes.second = 0;
+PrecompiledPreambleBytes.second = false;
   }
 };
 
 } // end namespace clang
 
-#endif
+#endif // LLVM_CLANG_LEX_PREPROCESSOROPTIONS_H
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -11,13 +11,14 @@
 //  traverses the entire AST.
 //
 //===--===//
+
 #ifndef LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
 #define LLVM_CLANG_AST_RECURSIVEASTVISITOR_H
 
-#include 
-
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -27,7 +28,9 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
+#include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
@@ -36,6 +39,15 @@
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/OpenMPKinds.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Casting.h"
+#include 
+#include 
+#include 
 
 // The following three macros are used for meta programming.  The code
 // using them is responsible for defining macro OPERATOR().
@@ -70,7 +82,7 @@
   do { \
 if (!getDerived().CALL_EXPR)   \
   return false;\
-  } while (0)
+  } while (false)
 
 /// \brief A class that does preordor or postorder
 /// depth-first traversal on the entire Clang AST and visits each node.
@@ -329,7 +341,7 @@
   do { \
 if (!TRAVERSE_STMT_BASE(Stmt, Stmt, S, Queue)) \
   return false;\
-  } while (0)
+  } while (false)
 
 public:
 // Declare Traverse*() for all concrete Stmt classes.
@@ -567,7 +579,6 @@
 
 #undef DISPATCH_STMT
 
-
 template 
 bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
   switch (S->getStmtClass()) {
@@ -756,7 +767,6 @@
   case DeclarationName::CXXConversionFunctionName:
 if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
   TRY_TO(TraverseTypeLoc(TSInfo->getTypeLoc()));
-
 break;
 
   case DeclarationName::Identifier:
@@ -2058,6 +2068,7 @@
 DEF_TRAVERSE_STMT(ObjCAtTryStmt, {})
 DEF_TRAVERSE_STMT(ObjCForCollectionStmt, {})
 DEF_TRAVERSE_STMT(ObjCAutoreleasePoolStmt, {})
+
 DEF_TRAVERSE_STMT(CXXForRangeStmt, {
   if (!getDerived().shouldVisitImplicitCode()) {
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLoopVarStmt());
@@ -2067,10 +2078,12 @@
 ShouldVisitChildren = false;
   }
 })
+
 DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
   TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
   TRY_TO(TraverseDeclarationNameInfo(S->getNameInfo()));
 })
+
 DEF_TRAVERSE_STMT(ReturnStmt, {})
 DEF_TRAVERSE_STMT(SwitchStmt, {})
 DEF_TRAVERSE_STMT(WhileStmt, 

Re: [PATCH] D23492: Make function local tags visible.

2016-08-17 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3597-3599
@@ -3595,4 +3596,5 @@
 
   // FIXME: Check that the definition is visible before trying to instantiate
   // it. This requires us to track the instantiation stack in order to know
   // which definitions should be visible.
+  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Function,

Please update this FIXME to just "We need to track the instantiation stack in 
order to know which definitions should be visible within this instantiation."


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3600-3605
@@ -3598,2 +3599,8 @@
   // which definitions should be visible.
+  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Function,
+Function->getInstantiatedFromMemberFunction(),
+ PatternDecl,
+ const_cast(PatternDecl),
+ TSK, /*Complain*/DefinitionRequired))
+ return;
 

I think this should be checked before we deal with late-parsed templates -- if 
the template definition isn't visible, an attempt to instantiate it shouldn't 
trigger it being parsed.


https://reviews.llvm.org/D23492



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


[clang-tools-extra] r278979 - Revert "Add a test for clang-tidy using the clang-cl driver."

2016-08-17 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Aug 17 16:01:13 2016
New Revision: 278979

URL: http://llvm.org/viewvc/llvm-project?rev=278979=rev
Log:
Revert "Add a test for clang-tidy using the clang-cl driver."

This reverts commit fd1908ce445eba4544d64cc68b3c03249e4bf614.

This should be the correct CL to revert.  The clang-side patch
that enabled this functionality was reverted, so this test needs
to be reverted until it gets fixed.

Removed:
clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp

Removed: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp?rev=278978=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- --driver-mode=cl 
/DTEST1 /DFOO=foo /DBAR=bar | FileCheck 
-implicit-check-not="{{warning|error}}:" %s
-int *a = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#ifdef TEST1
-int *b = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#endif
-#define foo 1
-#define bar 1
-#if FOO
-int *c = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#endif
-#if BAR
-int *d = 0;
-// CHECK: :[[@LINE-1]]:10: warning: use nullptr
-#endif


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


[clang-tools-extra] r278978 - Revert "Revert "[Include-fixer] Install executables and support scripts""

2016-08-17 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Aug 17 15:58:14 2016
New Revision: 278978

URL: http://llvm.org/viewvc/llvm-project?rev=278978=rev
Log:
Revert "Revert "[Include-fixer] Install executables and support scripts""

This reverts commit 2aff596257e1c45fa54baae823ecbe61a785174e.

I'm having a bad day apparently.  I reverted the wrong CL.  This
puts it back.

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt?rev=278978=278977=278978=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt 
Wed Aug 17 15:58:14 2016
@@ -1,8 +1,10 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols FindAllSymbolsMain.cpp)
-target_link_libraries(find-all-symbols
+add_clang_executable(find-all-symbols
+  FindAllSymbolsMain.cpp
+  )
 
+target_link_libraries(find-all-symbols
   clangAST
   clangASTMatchers
   clangBasic
@@ -11,3 +13,10 @@ target_link_libraries(find-all-symbols
   clangTooling
   findAllSymbols
   )
+
+install(TARGETS find-all-symbols
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS run-find-all-symbols.py
+  DESTINATION share/clang
+  COMPONENT find-all-symbols)

Modified: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt?rev=278978=278977=278978=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt Wed Aug 17 
15:58:14 2016
@@ -1,6 +1,9 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-include-fixer ClangIncludeFixer.cpp)
+add_clang_executable(clang-include-fixer
+  ClangIncludeFixer.cpp
+  )
+
 target_link_libraries(clang-include-fixer
   clangBasic
   clangFormat
@@ -11,3 +14,13 @@ target_link_libraries(clang-include-fixe
   clangToolingCore
   findAllSymbols
   )
+
+install(TARGETS clang-include-fixer
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-include-fixer.el
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)
+install(PROGRAMS clang-include-fixer.py
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)


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


[clang-tools-extra] r278977 - Revert "[Include-fixer] Install executables and support scripts"

2016-08-17 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Aug 17 15:56:47 2016
New Revision: 278977

URL: http://llvm.org/viewvc/llvm-project?rev=278977=rev
Log:
Revert "[Include-fixer] Install executables and support scripts"

This reverts commit b725a314a9b7f746c37f70909ec3c4dcb6d9f6b5.

The patch that made this test work needed to be reverted, so this
test needs to be reverted as well.

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt?rev=278977=278976=278977=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt 
Wed Aug 17 15:56:47 2016
@@ -1,10 +1,8 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols
-  FindAllSymbolsMain.cpp
-  )
-
+add_clang_executable(find-all-symbols FindAllSymbolsMain.cpp)
 target_link_libraries(find-all-symbols
+
   clangAST
   clangASTMatchers
   clangBasic
@@ -13,10 +11,3 @@ target_link_libraries(find-all-symbols
   clangTooling
   findAllSymbols
   )
-
-install(TARGETS find-all-symbols
-  RUNTIME DESTINATION bin)
-
-install(PROGRAMS run-find-all-symbols.py
-  DESTINATION share/clang
-  COMPONENT find-all-symbols)

Modified: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt?rev=278977=278976=278977=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt Wed Aug 17 
15:56:47 2016
@@ -1,9 +1,6 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-include-fixer
-  ClangIncludeFixer.cpp
-  )
-
+add_clang_executable(clang-include-fixer ClangIncludeFixer.cpp)
 target_link_libraries(clang-include-fixer
   clangBasic
   clangFormat
@@ -14,13 +11,3 @@ target_link_libraries(clang-include-fixe
   clangToolingCore
   findAllSymbols
   )
-
-install(TARGETS clang-include-fixer
-  RUNTIME DESTINATION bin)
-
-install(PROGRAMS clang-include-fixer.el
-  DESTINATION share/clang
-  COMPONENT clang-include-fixer)
-install(PROGRAMS clang-include-fixer.py
-  DESTINATION share/clang
-  COMPONENT clang-include-fixer)


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


r278976 - Revert "[Tooling] Parse compilation database command lines on Windows."

2016-08-17 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Aug 17 15:55:35 2016
New Revision: 278976

URL: http://llvm.org/viewvc/llvm-project?rev=278976=rev
Log:
Revert "[Tooling] Parse compilation database command lines on Windows."

This reverts commit 27a874790fc79f6391ad3703d7c790f51ac6ae1f.

After the introduction of windows command line parsing, some unit tests
began failing that expect to test gnu style command line quirks.  The
fix is mechanical but time consuming, so revert this for now.

Modified:
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp

Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=278976=278975=278976=diff
==
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp Wed Aug 17 15:55:35 2016
@@ -16,10 +16,7 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/StringSaver.h"
 #include 
 
 namespace clang {
@@ -116,21 +113,6 @@ class CommandLineArgumentParser {
 
 std::vector unescapeCommandLine(
 StringRef EscapedCommandLine) {
-  llvm::Triple Triple(llvm::sys::getProcessTriple());
-  if (Triple.getOS() == llvm::Triple::OSType::Win32) {
-// Assume Windows command line parsing on Win32 unless the triple 
explicitly
-// tells us otherwise.
-if (!Triple.hasEnvironment() ||
-Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC) {
-  llvm::BumpPtrAllocator Alloc;
-  llvm::StringSaver Saver(Alloc);
-  llvm::SmallVector T;
-  llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
-  std::vector Result(T.begin(), T.end());
-  return Result;
-}
-  }
-
   CommandLineArgumentParser parser(EscapedCommandLine);
   return parser.parse();
 }


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


Re: [PATCH] D23524: [libc++abi] Fix backtrace_test.pass.cpp failure seemingly caused by inlining differences.

2016-08-17 Thread Dan Albert via cfe-commits
danalbert added a comment.

Maybe `__attribute__((noinline))` every function instead?


https://reviews.llvm.org/D23524



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


Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-08-17 Thread Krzysztof Parzyszek via cfe-commits
kparzysz updated this revision to Diff 68416.
kparzysz added a comment.

Moving mno_long_calls to m_Group as well.

I'm hoping this is all that's needed: what I understand as "custom handling" is 
still needed, since this option is only valid for ARM and Hexagon.  The Hexagon 
way of handling target features will be cleaned up in a subsequent patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D22766

Files:
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  test/Driver/hexagon-long-calls.c

Index: test/Driver/hexagon-long-calls.c
===
--- /dev/null
+++ test/Driver/hexagon-long-calls.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target hexagon -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target hexagon -### -mlong-calls %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LONG-CALLS
+
+// RUN: %clang -target hexagon -### -mlong-calls -mno-long-calls %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-LONG-CALLS
+
+// CHECK-DEFAULT-NOT: "-target-feature" "+long-calls"
+
+// CHECK-LONG-CALLS: "-target-feature" "+long-calls"
+
+// CHECK-NO-LONG-CALLS-NOT: "-target-feature" "+long-calls"
+
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2484,7 +2484,7 @@
 
 static void getHexagonTargetFeatures(const ArgList ,
  std::vector ) {
-  bool HasHVX = false, HasHVXD = false;
+  bool HasHVX = false, HasHVXD = false, UseLongCalls = false;
 
   // FIXME: This should be able to use handleTargetFeaturesGroup except it is
   // doing dependent option handling here rather than in initFeatureMap or a
@@ -2499,13 +2499,18 @@
   HasHVXD = HasHVX = true;
 else if (Opt.matches(options::OPT_mno_hexagon_hvx_double))
   HasHVXD = false;
+else if (Opt.matches(options::OPT_mlong_calls))
+  UseLongCalls = true;
+else if (Opt.matches(options::OPT_mno_long_calls))
+  UseLongCalls = false;
 else
   continue;
 A->claim();
   }
 
   Features.push_back(HasHVX  ? "+hvx" : "-hvx");
   Features.push_back(HasHVXD ? "+hvx-double" : "-hvx-double");
+  Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
 }
 
 static void getWebAssemblyTargetFeatures(const ArgList ,
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6104,6 +6104,7 @@
   static const TargetInfo::GCCRegAlias GCCRegAliases[];
   std::string CPU;
   bool HasHVX, HasHVXDouble;
+  bool UseLongCalls;
 
 public:
   HexagonTargetInfo(const llvm::Triple , const TargetOptions &)
@@ -6128,6 +6129,7 @@
 UseBitFieldTypeAlignment = true;
 ZeroLengthBitfieldBoundary = 32;
 HasHVX = HasHVXDouble = false;
+UseLongCalls = false;
   }
 
   ArrayRef getTargetBuiltins() const override {
@@ -6162,6 +6164,7 @@
   .Case("hexagon", true)
   .Case("hvx", HasHVX)
   .Case("hvx-double", HasHVXDouble)
+  .Case("long-calls", UseLongCalls)
   .Default(false);
   }
 
@@ -6251,6 +6254,9 @@
   HasHVX = HasHVXDouble = true;
 else if (F == "-hvx-double")
   HasHVXDouble = false;
+
+if (F == "+long-calls")
+  UseLongCalls = true;
   }
   return true;
 }
@@ -6261,11 +6267,11 @@
   // Default for v60: -hvx, -hvx-double.
   Features["hvx"] = false;
   Features["hvx-double"] = false;
+  Features["long-calls"] = false;
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
-
 const char *const HexagonTargetInfo::GCCRegNames[] = {
   "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
   "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1376,6 +1376,10 @@
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, Group;
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, Group;
+def mlong_calls : Flag<["-"], "mlong-calls">, Group,
+  HelpText<"ARM: Generate an indirect jump to enable jumps further than 64M, Hexagon: Generate constant-extended branches.">;
+def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
+  HelpText<"Restore the default behaviour of not generating long calls">;
 def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group;
 def mappletvos_version_min_EQ : Joined<["-"], "mappletvos-version-min=">, Alias;
 def mtvos_simulator_version_min_EQ : Joined<["-"], "mtvos-simulator-version-min=">, Alias;
@@ -1520,10 +1524,6 @@
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group,
   HelpText<"Disallow use of CRC instructions (ARM only)">;
-def mlong_calls : Flag<["-"], "mlong-calls">, Group,
-  

Re: [PATCH] D23573: [OpenCL] AMDGPU: add support of cl_khr_subgroups

2016-08-17 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278972: [OpenCL] AMDGPU: add support of cl_khr_subgroups 
(authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D23573?vs=68227=68418#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23573

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
  cfe/trunk/test/SemaOpenCL/extension-version.cl

Index: cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -199,11 +199,17 @@
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
 // expected-warning@-1{{unsupported OpenCL extension 
'cl_khr_srgb_image_writes' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroups
+#error "Missing cl_khr_subgroups define"
+#endif
+#else
 #ifdef cl_khr_subgroups
 #error "Incorrect cl_khr_subgroups define"
 #endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
+#endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
-// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 
 #ifdef cl_khr_terminate_context
 #error "Incorrect cl_khr_terminate_context define"
Index: cfe/trunk/test/SemaOpenCL/extension-version.cl
===
--- cfe/trunk/test/SemaOpenCL/extension-version.cl
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl
@@ -247,6 +247,9 @@
 #error "Missing cl_khr_subgroups define"
 #endif
 #else
+#ifdef cl_khr_subgroups
+#error "Incorrect cl_khr_subgroups define"
+#endif
 // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2152,6 +2152,7 @@
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
+  Opts.cl_khr_subgroups = 1;
   Opts.cl_khr_3d_image_writes = 1;
   Opts.cl_amd_media_ops = 1;
   Opts.cl_amd_media_ops2 = 1;


Index: cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
===
--- cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
+++ cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
@@ -199,11 +199,17 @@
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_srgb_image_writes' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroups
+#error "Missing cl_khr_subgroups define"
+#endif
+#else
 #ifdef cl_khr_subgroups
 #error "Incorrect cl_khr_subgroups define"
 #endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
+#endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
-// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
 
 #ifdef cl_khr_terminate_context
 #error "Incorrect cl_khr_terminate_context define"
Index: cfe/trunk/test/SemaOpenCL/extension-version.cl
===
--- cfe/trunk/test/SemaOpenCL/extension-version.cl
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl
@@ -247,6 +247,9 @@
 #error "Missing cl_khr_subgroups define"
 #endif
 #else
+#ifdef cl_khr_subgroups
+#error "Incorrect cl_khr_subgroups define"
+#endif
 // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -2152,6 +2152,7 @@
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
+  Opts.cl_khr_subgroups = 1;
   Opts.cl_khr_3d_image_writes = 1;
   Opts.cl_amd_media_ops = 1;
   Opts.cl_amd_media_ops2 = 1;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278972 - [OpenCL] AMDGPU: add support of cl_khr_subgroups

2016-08-17 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Wed Aug 17 15:39:49 2016
New Revision: 278972

URL: http://llvm.org/viewvc/llvm-project?rev=278972=rev
Log:
[OpenCL] AMDGPU: add support of cl_khr_subgroups

Patch by Aaron En Ye Shi.

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
cfe/trunk/test/SemaOpenCL/extension-version.cl

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=278972=278971=278972=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Aug 17 15:39:49 2016
@@ -2152,6 +2152,7 @@ public:
   Opts.cl_khr_int64_base_atomics = 1;
   Opts.cl_khr_int64_extended_atomics = 1;
   Opts.cl_khr_mipmap_image = 1;
+  Opts.cl_khr_subgroups = 1;
   Opts.cl_khr_3d_image_writes = 1;
   Opts.cl_amd_media_ops = 1;
   Opts.cl_amd_media_ops2 = 1;

Modified: cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl?rev=278972=278971=278972=diff
==
--- cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl (original)
+++ cfe/trunk/test/Misc/amdgcn.languageOptsOpenCL.cl Wed Aug 17 15:39:49 2016
@@ -199,11 +199,17 @@
 #pragma OPENCL EXTENSION cl_khr_srgb_image_writes: enable
 // expected-warning@-1{{unsupported OpenCL extension 
'cl_khr_srgb_image_writes' - ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 200)
+#ifndef cl_khr_subgroups
+#error "Missing cl_khr_subgroups define"
+#endif
+#else
 #ifdef cl_khr_subgroups
 #error "Incorrect cl_khr_subgroups define"
 #endif
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
+#endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
-// expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 
 #ifdef cl_khr_terminate_context
 #error "Incorrect cl_khr_terminate_context define"

Modified: cfe/trunk/test/SemaOpenCL/extension-version.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=278972=278971=278972=diff
==
--- cfe/trunk/test/SemaOpenCL/extension-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/extension-version.cl Wed Aug 17 15:39:49 2016
@@ -247,6 +247,9 @@
 #error "Missing cl_khr_subgroups define"
 #endif
 #else
+#ifdef cl_khr_subgroups
+#error "Incorrect cl_khr_subgroups define"
+#endif
 // expected-warning@+2{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 #endif
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable


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


[clang-tools-extra] r278968 - Add a test for clang-tidy using the clang-cl driver.

2016-08-17 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Aug 17 15:14:10 2016
New Revision: 278968

URL: http://llvm.org/viewvc/llvm-project?rev=278968=rev
Log:
Add a test for clang-tidy using the clang-cl driver.

Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D23480

Added:
clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp

Added: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp?rev=278968=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp Wed Aug 17 
15:14:10 2016
@@ -0,0 +1,17 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- --driver-mode=cl 
/DTEST1 /DFOO=foo /DBAR=bar | FileCheck 
-implicit-check-not="{{warning|error}}:" %s
+int *a = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#ifdef TEST1
+int *b = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#define foo 1
+#define bar 1
+#if FOO
+int *c = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#if BAR
+int *d = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif


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


Re: [PATCH] D23480: Add a test for clang-tidy using the clang cl driver

2016-08-17 Thread Zachary Turner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278968: Add a test for clang-tidy using the clang-cl driver. 
(authored by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D23480?vs=67948=68413#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23480

Files:
  clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- --driver-mode=cl 
/DTEST1 /DFOO=foo /DBAR=bar | FileCheck 
-implicit-check-not="{{warning|error}}:" %s
+int *a = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#ifdef TEST1
+int *b = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#define foo 1
+#define bar 1
+#if FOO
+int *c = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#if BAR
+int *d = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif


Index: clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/clang-cl-driver.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr %s -- --driver-mode=cl /DTEST1 /DFOO=foo /DBAR=bar | FileCheck -implicit-check-not="{{warning|error}}:" %s
+int *a = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#ifdef TEST1
+int *b = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#define foo 1
+#define bar 1
+#if FOO
+int *c = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
+#if BAR
+int *d = 0;
+// CHECK: :[[@LINE-1]]:10: warning: use nullptr
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21724: [RFC] Enhance synchscope representation (clang)

2016-08-17 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl abandoned this revision.
kzhuravl added a comment.

This patch is not required at this point since we left SynchronizationScope 
enum intact and did not rename existing members


https://reviews.llvm.org/D21724



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


r278964 - [Tooling] Parse compilation database command lines on Windows.

2016-08-17 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Aug 17 15:04:35 2016
New Revision: 278964

URL: http://llvm.org/viewvc/llvm-project?rev=278964=rev
Log:
[Tooling] Parse compilation database command lines on Windows.

When a compilation database is used on Windows, the command lines cannot
be parsed using the standard GNU style syntax. LLVM provides functions for
parsing Windows style command lines, so use them where appropriate.

After this patch, clang-tidy runs correctly on Windows.

Reviewed by: alexfh
Differential Revision: https://reviews.llvm.org/D23455

Modified:
cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp

Modified: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp?rev=278964=278963=278964=diff
==
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp Wed Aug 17 15:04:35 2016
@@ -16,7 +16,10 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 
 namespace clang {
@@ -113,6 +116,21 @@ class CommandLineArgumentParser {
 
 std::vector unescapeCommandLine(
 StringRef EscapedCommandLine) {
+  llvm::Triple Triple(llvm::sys::getProcessTriple());
+  if (Triple.getOS() == llvm::Triple::OSType::Win32) {
+// Assume Windows command line parsing on Win32 unless the triple 
explicitly
+// tells us otherwise.
+if (!Triple.hasEnvironment() ||
+Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC) {
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver(Alloc);
+  llvm::SmallVector T;
+  llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
+  std::vector Result(T.begin(), T.end());
+  return Result;
+}
+  }
+
   CommandLineArgumentParser parser(EscapedCommandLine);
   return parser.parse();
 }


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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-17 Thread Zachary Turner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278964: [Tooling] Parse compilation database command lines 
on Windows. (authored by zturner).

Changed prior to commit:
  https://reviews.llvm.org/D23455?vs=67947=68407#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23455

Files:
  cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp

Index: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,7 +16,10 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 
 namespace clang {
@@ -113,6 +116,21 @@
 
 std::vector unescapeCommandLine(
 StringRef EscapedCommandLine) {
+  llvm::Triple Triple(llvm::sys::getProcessTriple());
+  if (Triple.getOS() == llvm::Triple::OSType::Win32) {
+// Assume Windows command line parsing on Win32 unless the triple 
explicitly
+// tells us otherwise.
+if (!Triple.hasEnvironment() ||
+Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC) {
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver(Alloc);
+  llvm::SmallVector T;
+  llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
+  std::vector Result(T.begin(), T.end());
+  return Result;
+}
+  }
+
   CommandLineArgumentParser parser(EscapedCommandLine);
   return parser.parse();
 }


Index: cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,7 +16,10 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
 #include 
 
 namespace clang {
@@ -113,6 +116,21 @@
 
 std::vector unescapeCommandLine(
 StringRef EscapedCommandLine) {
+  llvm::Triple Triple(llvm::sys::getProcessTriple());
+  if (Triple.getOS() == llvm::Triple::OSType::Win32) {
+// Assume Windows command line parsing on Win32 unless the triple explicitly
+// tells us otherwise.
+if (!Triple.hasEnvironment() ||
+Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC) {
+  llvm::BumpPtrAllocator Alloc;
+  llvm::StringSaver Saver(Alloc);
+  llvm::SmallVector T;
+  llvm::cl::TokenizeWindowsCommandLine(EscapedCommandLine, Saver, T);
+  std::vector Result(T.begin(), T.end());
+  return Result;
+}
+  }
+
   CommandLineArgumentParser parser(EscapedCommandLine);
   return parser.parse();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23581: [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

2016-08-17 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278963: [GraphWriter] Change GraphWriter to use NodeRef in 
GraphTraits (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23581?vs=68258=68406#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23581

Files:
  cfe/trunk/lib/Serialization/ModuleManager.cpp

Index: cfe/trunk/lib/Serialization/ModuleManager.cpp
===
--- cfe/trunk/lib/Serialization/ModuleManager.cpp
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 


Index: cfe/trunk/lib/Serialization/ModuleManager.cpp
===
--- cfe/trunk/lib/Serialization/ModuleManager.cpp
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp
@@ -434,6 +434,7 @@
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278963 - [GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

2016-08-17 Thread Tim Shen via cfe-commits
Author: timshen
Date: Wed Aug 17 15:02:38 2016
New Revision: 278963

URL: http://llvm.org/viewvc/llvm-project?rev=278963=rev
Log:
[GraphWriter] Change GraphWriter to use NodeRef in GraphTraits

Summary: Corresponding LLVM patch: D23580

Reviewers: dblaikie

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=278963=278962=278963=diff
==
--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)
+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Wed Aug 17 15:02:38 2016
@@ -434,6 +434,7 @@ namespace llvm {
   template<>
   struct GraphTraits {
 typedef ModuleFile NodeType;
+typedef ModuleFile *NodeRef;
 typedef llvm::SetVector::const_iterator ChildIteratorType;
 typedef ModuleManager::ModuleConstIterator nodes_iterator;
 


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


[libclc] r278962 - Implement vstore_half{,n}

2016-08-17 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Aug 17 15:02:11 2016
New Revision: 278962

URL: http://llvm.org/viewvc/llvm-project?rev=278962=rev
Log:
Implement vstore_half{,n}

Signed-off-by: Jan Vesely 

Added:
libclc/trunk/generic/lib/shared/vstore_half.inc
Modified:
libclc/trunk/generic/include/clc/shared/vstore.h
libclc/trunk/generic/lib/shared/vstore.cl

Modified: libclc/trunk/generic/include/clc/shared/vstore.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/vstore.h?rev=278962=278961=278962=diff
==
--- libclc/trunk/generic/include/clc/shared/vstore.h (original)
+++ libclc/trunk/generic/include/clc/shared/vstore.h Wed Aug 17 15:02:11 2016
@@ -1,17 +1,20 @@
-#define _CLC_VSTORE_DECL(PRIM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \
-  _CLC_OVERLOAD _CLC_DECL void vstore##WIDTH(VEC_TYPE vec, size_t offset, 
ADDR_SPACE PRIM_TYPE *out);
+#define _CLC_VSTORE_DECL(SUFFIX, PRIM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \
+  _CLC_OVERLOAD _CLC_DECL void vstore##SUFFIX##WIDTH(VEC_TYPE vec, size_t 
offset, ADDR_SPACE PRIM_TYPE *out);
 
-#define _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, ADDR_SPACE) \
-  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
-  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
-  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
-  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
-  _CLC_VSTORE_DECL(PRIM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
+#define _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, ADDR_SPACE) \
+  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
+  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
+  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
+  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
+  _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
+
+#define _CLC_VECTOR_VSTORE_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE) \
+  _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private) \
+  _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local) \
+  _CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global) \
 
 #define _CLC_VECTOR_VSTORE_PRIM1(PRIM_TYPE) \
-  _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __private) \
-  _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __local) \
-  _CLC_VECTOR_VSTORE_DECL(PRIM_TYPE, __global) \
+  _CLC_VECTOR_VSTORE_PRIM3(,PRIM_TYPE, PRIM_TYPE) \
 
 #define _CLC_VECTOR_VSTORE_PRIM() \
 _CLC_VECTOR_VSTORE_PRIM1(char) \
@@ -23,14 +26,18 @@
 _CLC_VECTOR_VSTORE_PRIM1(long) \
 _CLC_VECTOR_VSTORE_PRIM1(ulong) \
 _CLC_VECTOR_VSTORE_PRIM1(float) \
-
+_CLC_VECTOR_VSTORE_PRIM3(_half, half, float)
+
 #ifdef cl_khr_fp64
-#define _CLC_VECTOR_VSTORE() \
-  _CLC_VECTOR_VSTORE_PRIM1(double) \
-  _CLC_VECTOR_VSTORE_PRIM()
-#else
-#define _CLC_VECTOR_VSTORE() \
-  _CLC_VECTOR_VSTORE_PRIM()
+#pragma cl_khr_fp64: enable
+  _CLC_VECTOR_VSTORE_PRIM1(double)
+  _CLC_VECTOR_VSTORE_PRIM3(_half, half, double)
+  _CLC_VSTORE_DECL(_half, half, double, , __private)
+  _CLC_VSTORE_DECL(_half, half, double, , __local)
+  _CLC_VSTORE_DECL(_half, half, double, , __global)
 #endif
 
-_CLC_VECTOR_VSTORE()
+_CLC_VECTOR_VSTORE_PRIM()
+_CLC_VSTORE_DECL(_half, half, float, , __private)
+_CLC_VSTORE_DECL(_half, half, float, , __local)
+_CLC_VSTORE_DECL(_half, half, float, , __global)

Modified: libclc/trunk/generic/lib/shared/vstore.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/vstore.cl?rev=278962=278961=278962=diff
==
--- libclc/trunk/generic/lib/shared/vstore.cl (original)
+++ libclc/trunk/generic/lib/shared/vstore.cl Wed Aug 17 15:02:11 2016
@@ -50,3 +50,35 @@ VSTORE_TYPES()
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 VSTORE_ADDR_SPACES(double)
 #endif
+
+/* vstore_half are legal even without cl_khr_fp16 */
+
+#define VEC_STORE1(val) mem[offset++] = val;
+#define VEC_STORE2(val) \
+   VEC_STORE1(val.lo) \
+   VEC_STORE1(val.hi)
+#define VEC_STORE3(val) \
+   VEC_STORE1(val.s0) \
+   VEC_STORE1(val.s1) \
+   VEC_STORE1(val.s2)
+#define VEC_STORE4(val) \
+   VEC_STORE2(val.lo) \
+   VEC_STORE2(val.hi)
+#define VEC_STORE8(val) \
+   VEC_STORE4(val.lo) \
+   VEC_STORE4(val.hi)
+#define VEC_STORE16(val) \
+   VEC_STORE8(val.lo) \
+   VEC_STORE8(val.hi)
+
+#define __FUNC(SUFFIX, VEC_SIZE, TYPE, AS) \
+  _CLC_OVERLOAD _CLC_DEF void vstore_half##SUFFIX(TYPE vec, size_t offset, AS 
half *mem) { \
+offset *= VEC_SIZE; \
+VEC_STORE##VEC_SIZE(vec) \
+  }
+
+#define FUNC(SUFFIX, VEC_SIZE, TYPE, AS) __FUNC(SUFFIX, VEC_SIZE, TYPE, AS)
+
+#define __CLC_BODY "vstore_half.inc"
+#include 
+

Added: libclc/trunk/generic/lib/shared/vstore_half.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/vstore_half.inc?rev=278962=auto

Re: [PATCH] D23618: [LibTooling] Allow compilation database to explicitly specify compilation database file and source root

2016-08-17 Thread Zachary Turner via cfe-commits
zturner updated this revision to Diff 68404.
zturner added a comment.

Added full context diff.


https://reviews.llvm.org/D23618

Files:
  include/clang/Tooling/CompilationDatabase.h
  include/clang/Tooling/JSONCompilationDatabase.h
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/JSONCompilationDatabase.cpp
  lib/Tooling/Tooling.cpp
  tools/libclang/CXCompilationDatabase.cpp

Index: tools/libclang/CXCompilationDatabase.cpp
===
--- tools/libclang/CXCompilationDatabase.cpp
+++ tools/libclang/CXCompilationDatabase.cpp
@@ -17,7 +17,7 @@
   CXCompilationDatabase_Error Err = CXCompilationDatabase_NoError;
 
   std::unique_ptr db =
-  CompilationDatabase::loadFromDirectory(BuildDir, ErrorMsg);
+  CompilationDatabase::loadFromDirectory(BuildDir, StringRef(), ErrorMsg);
 
   if (!db) {
 fprintf(stderr, "LIBCLANG TOOLING ERROR: %s\n", ErrorMsg.c_str());
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -407,10 +407,12 @@
   // difference for example on network filesystems, where symlinks might be
   // switched during runtime of the tool. Fixing this depends on having a
   // file system abstraction that allows openat() style interactions.
-  if (OverlayFileSystem->setCurrentWorkingDirectory(
-  CompileCommand.Directory))
-llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+  if (!CompileCommand.Directory.empty()) {
+if (OverlayFileSystem->setCurrentWorkingDirectory(
+CompileCommand.Directory))
+  llvm::report_fatal_error("Cannot chdir into \"" +
+   Twine(CompileCommand.Directory) + "\n!");
+  }
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: lib/Tooling/JSONCompilationDatabase.cpp
===
--- lib/Tooling/JSONCompilationDatabase.cpp
+++ lib/Tooling/JSONCompilationDatabase.cpp
@@ -16,10 +16,12 @@
 #include "clang/Tooling/CompilationDatabasePluginRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
+#include 
 #include 
 
 namespace clang {
@@ -137,11 +139,18 @@
 
 class JSONCompilationDatabasePlugin : public CompilationDatabasePlugin {
   std::unique_ptr
-  loadFromDirectory(StringRef Directory, std::string ) override {
+  loadFromDirectory(StringRef Directory, StringRef SourceRoot,
+std::string ) override {
 SmallString<1024> JSONDatabasePath(Directory);
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
+return loadFromFile(JSONDatabasePath, SourceRoot, ErrorMessage);
+  }
+
+  std::unique_ptr
+  loadFromFile(StringRef File, StringRef SourceRoot,
+   std::string ) override {
 std::unique_ptr Database(
-JSONCompilationDatabase::loadFromFile(JSONDatabasePath, ErrorMessage));
+JSONCompilationDatabase::loadFromFile(File, SourceRoot, ErrorMessage));
 if (!Database)
   return nullptr;
 return Database;
@@ -160,16 +169,16 @@
 volatile int JSONAnchorSource = 0;
 
 std::unique_ptr
-JSONCompilationDatabase::loadFromFile(StringRef FilePath,
+JSONCompilationDatabase::loadFromFile(StringRef FilePath, StringRef SourceRoot,
   std::string ) {
   llvm::ErrorOr DatabaseBuffer =
   llvm::MemoryBuffer::getFile(FilePath);
   if (std::error_code Result = DatabaseBuffer.getError()) {
 ErrorMessage = "Error while opening JSON database: " + Result.message();
 return nullptr;
   }
   std::unique_ptr Database(
-  new JSONCompilationDatabase(std::move(*DatabaseBuffer)));
+  new JSONCompilationDatabase(SourceRoot, std::move(*DatabaseBuffer)));
   if (!Database->parse(ErrorMessage))
 return nullptr;
   return Database;
@@ -181,7 +190,7 @@
   std::unique_ptr DatabaseBuffer(
   llvm::MemoryBuffer::getMemBuffer(DatabaseString));
   std::unique_ptr Database(
-  new JSONCompilationDatabase(std::move(DatabaseBuffer)));
+  new JSONCompilationDatabase("", std::move(DatabaseBuffer)));
   if (!Database->parse(ErrorMessage))
 return nullptr;
   return Database;
@@ -245,12 +254,13 @@
 ArrayRef CommandsRef,
 std::vector ) const {
   for (int I = 0, E = CommandsRef.size(); I != E; ++I) {
-SmallString<8> DirectoryStorage;
+SmallString<128> DirectoryStorage;
 SmallString<32> FilenameStorage;
+getDirectoryForCommand(*std::get<0>(CommandsRef[I]), DirectoryStorage);
 

Re: [PATCH] D22929: [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl

2016-08-17 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278956: [CodeGen][ObjC] Fix infinite recursion in 
getObjCEncodingForTypeImpl. (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D22929?vs=65969=68400#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22929

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/test/CodeGenObjCXX/encode.mm

Index: cfe/trunk/test/CodeGenObjCXX/encode.mm
===
--- cfe/trunk/test/CodeGenObjCXX/encode.mm
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm
@@ -224,3 +224,24 @@
   // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
   extern const char x[] = @encode(E);
 }
+
+// This test used to cause infinite recursion.
+template
+struct S {
+  typedef T Ty;
+  Ty *t;
+};
+
+@interface N
+{
+  S a;
+}
+@end
+
+@implementation N
+@end
+
+const char *expand_struct() {
+  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] 
c"{N={S=^{N}}}\00"
+  return @encode(N);
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -5906,18 +5906,20 @@
 ObjCInterfaceDecl *OI = T->castAs()->getInterface();
 S += '{';
 S += OI->getObjCRuntimeNameAsString();
-S += '=';
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  const FieldDecl *Field = cast(Ivars[i]);
-  if (Field->isBitField())
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
-  else
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
-   false, false, false, false, false,
-   EncodePointerToObjCTypedef,
-   NotEncodedT);
+if (ExpandStructures) {
+  S += '=';
+  SmallVector Ivars;
+  DeepCollectObjCIvars(OI, true, Ivars);
+  for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
+const FieldDecl *Field = cast(Ivars[i]);
+if (Field->isBitField())
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
+ false, false, false, false, false,
+ EncodePointerToObjCTypedef,
+ NotEncodedT);
+  }
 }
 S += '}';
 return;


Index: cfe/trunk/test/CodeGenObjCXX/encode.mm
===
--- cfe/trunk/test/CodeGenObjCXX/encode.mm
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm
@@ -224,3 +224,24 @@
   // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
   extern const char x[] = @encode(E);
 }
+
+// This test used to cause infinite recursion.
+template
+struct S {
+  typedef T Ty;
+  Ty *t;
+};
+
+@interface N
+{
+  S a;
+}
+@end
+
+@implementation N
+@end
+
+const char *expand_struct() {
+  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] c"{N={S=^{N}}}\00"
+  return @encode(N);
+}
Index: cfe/trunk/lib/AST/ASTContext.cpp
===
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -5906,18 +5906,20 @@
 ObjCInterfaceDecl *OI = T->castAs()->getInterface();
 S += '{';
 S += OI->getObjCRuntimeNameAsString();
-S += '=';
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  const FieldDecl *Field = cast(Ivars[i]);
-  if (Field->isBitField())
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
-  else
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
-   false, false, false, false, false,
-   EncodePointerToObjCTypedef,
-   NotEncodedT);
+if (ExpandStructures) {
+  S += '=';
+  SmallVector Ivars;
+  DeepCollectObjCIvars(OI, true, Ivars);
+  for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
+const FieldDecl *Field = cast(Ivars[i]);
+if (Field->isBitField())
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
+ false, false, false, false, false,
+ EncodePointerToObjCTypedef,
+ NotEncodedT);
+  }
 }
 S += '}';
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278956 - [CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl.

2016-08-17 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Aug 17 14:42:22 2016
New Revision: 278956

URL: http://llvm.org/viewvc/llvm-project?rev=278956=rev
Log:
[CodeGen][ObjC] Fix infinite recursion in getObjCEncodingForTypeImpl.

Check that ExpandStructures is true before visiting the list of ivars.

rdar://problem/27135221

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

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGenObjCXX/encode.mm

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=278956=278955=278956=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Aug 17 14:42:22 2016
@@ -5906,18 +5906,20 @@ void ASTContext::getObjCEncodingForTypeI
 ObjCInterfaceDecl *OI = T->castAs()->getInterface();
 S += '{';
 S += OI->getObjCRuntimeNameAsString();
-S += '=';
-SmallVector Ivars;
-DeepCollectObjCIvars(OI, true, Ivars);
-for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-  const FieldDecl *Field = cast(Ivars[i]);
-  if (Field->isBitField())
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
-  else
-getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
-   false, false, false, false, false,
-   EncodePointerToObjCTypedef,
-   NotEncodedT);
+if (ExpandStructures) {
+  S += '=';
+  SmallVector Ivars;
+  DeepCollectObjCIvars(OI, true, Ivars);
+  for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
+const FieldDecl *Field = cast(Ivars[i]);
+if (Field->isBitField())
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
+else
+  getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
+ false, false, false, false, false,
+ EncodePointerToObjCTypedef,
+ NotEncodedT);
+  }
 }
 S += '}';
 return;

Modified: cfe/trunk/test/CodeGenObjCXX/encode.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/encode.mm?rev=278956=278955=278956=diff
==
--- cfe/trunk/test/CodeGenObjCXX/encode.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm Wed Aug 17 14:42:22 2016
@@ -224,3 +224,24 @@ namespace PR17142 {
   // CHECK: @_ZN7PR171421xE = constant [14 x i8] c"{E=^^?i^^?ii}\00"
   extern const char x[] = @encode(E);
 }
+
+// This test used to cause infinite recursion.
+template
+struct S {
+  typedef T Ty;
+  Ty *t;
+};
+
+@interface N
+{
+  S a;
+}
+@end
+
+@implementation N
+@end
+
+const char *expand_struct() {
+  // CHECK: @{{.*}} = private unnamed_addr constant [16 x i8] 
c"{N={S=^{N}}}\00"
+  return @encode(N);
+}


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


Re: [PATCH] D23618: [LibTooling] Allow compilation database to explicitly specify compilation database file and source root

2016-08-17 Thread Zachary Turner via cfe-commits
Strange, I thought i did. Will re upload
On Wed, Aug 17, 2016 at 12:14 PM Alexander Kornienko 
wrote:

> alexfh added a comment.
>
> Full context diffs, please (
> http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface
> ).
>
>
> https://reviews.llvm.org/D23618
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23610: [ARM] Add pre-defined macros for ROPI, RWPI and FPIC

2016-08-17 Thread Tim Northover via cfe-commits
t.p.northover added inline comments.


Comment at: lib/Basic/Targets.cpp:5316
@@ +5315,3 @@
+if (Opts.PICLevel)
+  Builder.defineMacro("__APCS_FPIC", "1");
+if (Opts.ROPI)

These names are pretty bad from a modern perspective (with APCS deprecated and 
almost entirely forgotten outside iOS). It's the kind of thing it would be good 
for the ACLE to cover, would they be likely to consider it?


Repository:
  rL LLVM

https://reviews.llvm.org/D23610



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


Re: [PATCH] D23618: [LibTooling] Allow compilation database to explicitly specify compilation database file and source root

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Full context diffs, please 
(http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface).


https://reviews.llvm.org/D23618



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D23455#518317, @zturner wrote:

> We could also provide a command line option to clang-tidy that lets the user 
> specify the command line syntax of the compilation database.  It could choose 
> a smart default (i.e. what we do in this patch after using 
> `llvm::sys::getProcessTriple()`) but if the command line option is specified 
> it could just force that parsing mode.  This way we don't have to get in the 
> business of guessing, which could itself end up having unforeseen edge cases.


If someone is actually interested in this, the option can be added to 
`CommonOptionsParser`.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

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

In https://reviews.llvm.org/D23455#518312, @rnk wrote:

> So, I actually went ahead and generated some MSYS makefiles and made a 
> compile_commands.json, and it doesn't work with clang-tidy. You get this kind 
> of output:
>
>   [
>   {
> "directory": "C:/src/test_proj",
> "command": "\"/C/Program 
> Files/mingw-w64/x86_64-6.1.0-win32-seh-rt_v5-rev0/mingw64/bin/g++.exe\"
> -Dsomething\\evil -o CMakeFiles/foo.dir/foo.obj -c /C/src/test_proj/foo.cpp",
> "file": "C:/src/test_proj/foo.cpp"
>   }
>   ]
>   ...
>   $ clang-tidy foo.cpp
>   1 error generated.
>   Error while processing C:\src\test_proj\foo.cpp.
>   error: error reading '/C/src/test_proj/foo.cpp' [clang-diagnostic-error]
>
>
> Hypothetically we could make this work, but there are bigger problems here. 
> In that light, I think we should go with this patch. Long term, we should 
> solve this problem by emitting "arguments" or "command_shell" in cmake.


Yep, if we're not breaking anything with this change, let's proceed. LG


https://reviews.llvm.org/D23455



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


[PATCH] D23618: [LibTooling] Allow compilation database to explicitly specify compilation database file and source root

2016-08-17 Thread Zachary Turner via cfe-commits
zturner created this revision.
zturner added reviewers: djasper, alexfh, klimek.
zturner added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Allow explicit specification of a compilation database file and source root.

While trying to create a compilation database test for D23455, I ran into the 
problem that compilation database tests require shell.  Shell tests are 
inefficient and cumbersome for a number of reasons.  For one it takes a long 
time reading the test to understand what it does.  Secondly it makes it harder 
to modify the test.  Third creating many processes as is common with a shell 
test is slow on Windows.

I decided to solve this by introducing a new command line parameter and 
slightly enhancing the functionality of an existing one, detailed below:

1. There was no way to specify an arbitrary compilation database.  At best you 
could specify the directory of a compilation database, but it would still be 
forced to look for `compile_commands.json`.  This is an inflexible design when 
you want to have multiple tests which each use their own compilation database.  
You could put them in different folders and call each one 
`compile_commands.json`, but that leads to many different directories with only 
one file, which is kind of silly.

The `-p` option let you specify a build path, which would be the folder where a 
compilation database existed, but it did not let you specify a *specific file* 
to use as a compilation database.  I improved expanded this behavior of this 
option to check if the specified path is a regular file or a directory.  If it 
is a regular file it doesn't search for a compilation database, and instead 
just uses the file you specify.  The nice thing about this is that now we can 
put many compilation databases for various tests in the same directory, and 
have the run line of the test reference the exact compilation database needed 
for the test.

2. Instead of a "real" compilation database, the test consisted of a template.  
And the test used shell in order to invoke `sed` to modify the template so that 
the files and directories would be correct.  So the test would output the 
modified template into the CMake output directory, and then it had to use more 
shell commands to copy the source files over to the CMake output directory so 
that they would be in the right hierarchy in order to be found by the relative 
paths written to the compilation database.

In order to remove the dependency on shell commands, we need a way to reference 
the source files in their original location in the source tree, and not require 
them to be copied to the output tree.  To do this I introduced a new command 
line option `-r` that lets you specify the root at which relative paths are 
resolved against.  

These two things combined eliminate the need to modify the compilation database 
with `sed` and write it to the output folder because we can write *actual* 
source code on disk and check it in for the tests, and the compilation database 
can refer to these files using actual relative paths.  Then because of #1, the 
run line can point directly to the compilation database in question.

I re-wrote the compilation database test to use this new method, and it now no 
longer depends on shell.  I will upload the re-written test in a separate patch 
since I can't do cross-repo diffs.

After applying this patch, the compilation database test can be written using a 
single run line.  A patch that does exactly that is in D23533

https://reviews.llvm.org/D23618

Files:
  include/clang/Tooling/CompilationDatabase.h
  include/clang/Tooling/JSONCompilationDatabase.h
  lib/Tooling/CommonOptionsParser.cpp
  lib/Tooling/CompilationDatabase.cpp
  lib/Tooling/JSONCompilationDatabase.cpp
  lib/Tooling/Tooling.cpp

Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -407,10 +407,12 @@
   // difference for example on network filesystems, where symlinks might be
   // switched during runtime of the tool. Fixing this depends on having a
   // file system abstraction that allows openat() style interactions.
-  if (OverlayFileSystem->setCurrentWorkingDirectory(
-  CompileCommand.Directory))
-llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+  if (!CompileCommand.Directory.empty()) {
+if (OverlayFileSystem->setCurrentWorkingDirectory(
+CompileCommand.Directory))
+  llvm::report_fatal_error("Cannot chdir into \"" +
+   Twine(CompileCommand.Directory) + "\n!");
+  }
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that
Index: lib/Tooling/JSONCompilationDatabase.cpp

Re: [PATCH] D23596: [Documentation] Remove duplicated checks groups descriptions form clang-tidy/index.rst

2016-08-17 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a reviewer: aaron.ballman.
Eugene.Zelenko updated this revision to Diff 68390.
Eugene.Zelenko added a comment.

Rephrase text and add link to Clang-tidy directory. Will be good idea is native 
English speaker will look on this change.


Repository:
  rL LLVM

https://reviews.llvm.org/D23596

Files:
  docs/clang-tidy/index.rst

Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -338,30 +338,13 @@
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
+Next, you need to decide which module the check belongs to. Modules
+are located in subdirectories of
+``clang-tidy/ 
``_.
+Their names are same as user-facing check groups names described above.
+If the check verifies conformance of the code to a certain coding style, it
+probably deserves a separate module and a directory in ``clang-tidy/``.
 
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably 
deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  
`_
-* `CERT Secure Coding Standards
-  
`_
-* `Google Style Guide
-  
`_
-* `LLVM Style
-  
`_
-* `modernizing C/C++ code
-  
`_
-* potential `performance problems
-  
`_
-* various `readability issues
-  
`_
-* and `miscellaneous checks
-  
`_
-  that we couldn't find a better category for.
-
 After choosing the module, you need to create a class for your check:
 
 .. code-block:: c++


Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -338,30 +338,13 @@
 .. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
 .. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
 
+Next, you need to decide which module the check belongs to. Modules
+are located in subdirectories of
+``clang-tidy/ ``_.
+Their names are same as user-facing check groups names described above.
+If the check verifies conformance of the code to a certain coding style, it
+probably deserves a separate module and a directory in ``clang-tidy/``.
 
-Next, you need to decide which module the check belongs to. If the check
-verifies conformance of the code to a certain coding style, it probably deserves
-a separate module and a directory in ``clang-tidy/``. There are already modules
-implementing checks related to:
-
-* `C++ Core Guidelines
-  `_
-* `CERT Secure Coding Standards
-  `_
-* `Google Style Guide
-  `_
-* `LLVM Style
-  `_
-* `modernizing C/C++ code
-  `_
-* potential `performance problems
-  `_
-* various `readability issues
-  `_
-* and `miscellaneous checks
-  `_
-  that we couldn't find a better category for.
-
 After choosing the module, you need to create a class for your check:
 
 .. code-block:: c++
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278952 - Module debug info: Fix a bug in handling record decls without fields.

2016-08-17 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 17 13:27:24 2016
New Revision: 278952

URL: http://llvm.org/viewvc/llvm-project?rev=278952=rev
Log:
Module debug info: Fix a bug in handling record decls without fields.

The previous condition would erroneously mark all CXXRecordDecls
that didn't have any fields as being defined in a clang module.
This patch fixes the condition to only apply to explicit template
instantiations.



Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/ExtDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=278952=278951=278952=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 17 13:27:24 2016
@@ -1656,12 +1656,15 @@ static bool isDefinedInClangModule(const
 return false;
   if (auto *CXXDecl = dyn_cast(RD)) {
 assert(CXXDecl->isCompleteDefinition() && "incomplete record definition");
-if (CXXDecl->getTemplateSpecializationKind() != TSK_Undeclared)
-  // Make sure the instantiation is actually in a module.
-  if (CXXDecl->field_begin() != CXXDecl->field_end())
-return CXXDecl->field_begin()->isFromASTFile();
+auto TemplateKind = CXXDecl->getTemplateSpecializationKind();
+if (TemplateKind != TSK_Undeclared) {
+  // This is a template, check the origin of the first member.
+  if (CXXDecl->field_begin() == CXXDecl->field_end())
+return TemplateKind == TSK_ExplicitInstantiationDeclaration;
+  if (!CXXDecl->field_begin()->isFromASTFile())
+return false;
+}
   }
-
   return true;
 }
 

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=278952=278951=278952=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Wed Aug 17 13:27:24 2016
@@ -63,6 +63,10 @@ struct Specialized::Member definedL
 template  struct FwdDeclTemplateMember::Member { T t; };
 TypedefFwdDeclTemplateMember tdfdtm;
 
+SpecializedBase definedLocally3;
+extern template class WithSpecializedBase;
+WithSpecializedBase definedLocally4;
+
 void foo() {
   anon.i = GlobalStruct.i = GlobalUnion.i = GlobalEnum;
 }
@@ -103,6 +107,7 @@ void foo() {
 // CHECK: !DICompositeType(tag: DW_TAG_class_type,
 // CHECK-SAME: name: "Template",
 // CHECK-SAME: scope: ![[NS]],
+// CHECK-SAME: elements:
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: 
"_ZTSN8DebugCXX8TemplateIfNS_6traitsIf")
 
@@ -112,10 +117,11 @@ void foo() {
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX6traitsIfEE")
 
 
-// This type is anchored in the module by an explicit template instantiation.
+// This type is anchored in the module via a function argument,
+// but we don't know this (yet).
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A",
 // CHECK-SAME: scope: ![[NS]],
-// CHECK-SAME: flags: DIFlagFwdDecl,
+// CHECK-SAME: elements:
 // CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
 
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_member",
@@ -133,6 +139,7 @@ void foo() {
 
 // This one isn't.
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "Template1",
+// CHECK-SAME: elements:
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTS9Template1IPvE")
 
@@ -142,6 +149,7 @@ void foo() {
 // CHECK-SAME: identifier: "_ZTS9Template1IiE")
 
 // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: 
"FwdDeclTemplate",
+// CHECK-SAME: elements:
 // CHECK-SAME: templateParams:
 // CHECK-SAME: identifier: "_ZTS15FwdDeclTemplateIiE")
 
@@ -160,6 +168,19 @@ void foo() {
 // CHECK-SAME: elements:
 // CHECK-SAME: identifier: 
"_ZTSN21FwdDeclTemplateMemberIiE6MemberE")
 
+// This type is defined locally and forward-declared in the module.
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "SpecializedBase",
+// CHECK-SAME:   baseType: ![[SPECIALIZEDBASE:.*]])
+// CHECK: ![[SPECIALIZEDBASE]] =
+// CHECK-SAME: !DICompositeType(tag: DW_TAG_class_type,
+// CHECK-SAME:  name: "WithSpecializedBase",
+// CHECK-SAME:  elements:
+// CHECK-SAME:  identifier: "_ZTS19WithSpecializedBaseIfE")
+
+// This type is explicitly specialized locally.
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: 
"WithSpecializedBase",
+// CHECK-SAME: elements:
+// CHECK-SAME: identifier: 

Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-17 Thread Zachary Turner via cfe-commits
zturner added a comment.

We could also provide a command line option to clang-tidy that lets the user 
specify the command line syntax of the compilation database.  It could choose a 
smart default (i.e. what we do in this patch after using 
`llvm::sys::getProcessTriple()`) but if the command line option is specified it 
could just force that parsing mode.  This way we don't have to get in the 
business of guessing, which could itself end up having unforeseen edge cases.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-17 Thread Reid Kleckner via cfe-commits
rnk added a comment.

So, I actually went ahead and generated some MSYS makefiles and made a 
compile_commands.json, and it doesn't work with clang-tidy. You get this kind 
of output:

  [
  {
"directory": "C:/src/test_proj",
"command": "\"/C/Program 
Files/mingw-w64/x86_64-6.1.0-win32-seh-rt_v5-rev0/mingw64/bin/g++.exe\"
-Dsomething\\evil -o CMakeFiles/foo.dir/foo.obj -c /C/src/test_proj/foo.cpp",
"file": "C:/src/test_proj/foo.cpp"
  }
  ]
  ...
  $ clang-tidy foo.cpp
  1 error generated.
  Error while processing C:\src\test_proj\foo.cpp.
  error: error reading '/C/src/test_proj/foo.cpp' [clang-diagnostic-error]

Hypothetically we could make this work, but there are bigger problems here. In 
that light, I think we should go with this patch. Long term, we should solve 
this problem by emitting "arguments" or "command_shell" in cmake.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23455: [Tooling] Parse compilation database command lines properly on Windows

2016-08-17 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D23455#517774, @alexfh wrote:

> In https://reviews.llvm.org/D23455#516760, @zturner wrote:
>
> > In https://reviews.llvm.org/D23455#516753, @alexfh wrote:
> >
> > > In https://reviews.llvm.org/D23455#515527, @rnk wrote:
> > >
> > > > In https://reviews.llvm.org/D23455#515486, @brad.king wrote:
> > > >
> > > > > > the feasibility of emitting 'arguments' instead of 'command' into 
> > > > > > the JSON compilation database.
> > > > >
> > > > >
> > > > > CMake constructs the command lines internally using string 
> > > > > replacement on templates.  We never actually know the exact 
> > > > > arguments.  Therefore providing arguments instead of the whole 
> > > > > command would require parsing to be done on the CMake side instead.  
> > > > > This is theoretically possible because we do know the shell for which 
> > > > > we are generating (Windows `cmd` versus MSYS `sh`).  However, it may 
> > > > > also require a bunch of logic we don't have yet but that LLVM does.
> > > > >
> > > > > Alternatively, the JSON could have an additional 
> > > > > `command_shell="..."` field that indicates the shell for which the 
> > > > > command line is encoded.
> > > >
> > > >
> > > > Bummer. Given that this is hard to do in CMake, then I think we should 
> > > > just tokenize in Clang. Let's use llvm::sys::getProcessTriple() instead 
> > > > of LLVM_ON_WIN32 and check if that is an MSVC environment as a proxy 
> > > > for the shell type.
> > >
> > >
> > > Do I understand correctly that `llvm::sys::getProcessTriple()` returns 
> > > basically a compile-time constant? If yes, it won't allow the same clang 
> > > tool binary to be used with both command line formats. Should we instead 
> > > allow runtime selection of the command line format? For example, by 
> > > extending JSON compilation database with the aforementioned 
> > > `command_shell="..."` option.
> >
> >
> > It does return a compile time constant, but it is a compile time constant 
> > representing the platform that clang-tidy is running on.  I don't see a 
> > need to have a single clang-tidy binary be able to parse both command line 
> > formats.  In fact, it seems actively harmful.
> >
> > If you are running on a Windows system with windows command line parsing 
> > rules, and someone has generated a command line on linux, then this command 
> > line was never intended to be run on Windows in the first place.  The JSON 
> > compilation database spec already says that the command line represents 
> > "the exact command to be run **in the environment of the build system**".  
> > By adding the flexibility to change the environment, this is no longer 
> > true.  If I try to run a command generated for one build system in the 
> > environment of another build system, even if I tokenize it correctly whose 
> > to say it will work?
> >
> > I understand the desire to make sure we get the right change so we don't 
> > have to revisit this in the future, but to me this sounds like YAGNI and 
> > actually increasing the risk of someone using the software and getting 
> > unexpected results, not less risk.
>
>
> Now I'm less sure. And I might be misunderstanding something here. Folks 
> actually using clang tools on Windows (Aaron?) can tell with more confidence 
> whether Linux-style command line tokenization is of any use on Windows. I had 
> an impression that it allowed clang tools to be used with mingw (and msys 
> shell), but I'm not sure whether it's an important use case for anyone.


I agree with @zturner's perspective -- if the command was generated on Linux, I 
would not expect it to work on Windows (and vice versa). Not only are path 
separators an issue, you run into other things like reserved file names, 
different -D flags, different triples, etc. I can't think of a situation where 
I would expect that to work.


https://reviews.llvm.org/D23455



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


Re: [PATCH] D23045: [Include-fixer] Install executables and support scripts

2016-08-17 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278949: [Include-fixer] Install executables and support 
scripts (authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D23045?vs=66414=68384#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23045

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
  clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt

Index: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
@@ -1,6 +1,9 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-include-fixer ClangIncludeFixer.cpp)
+add_clang_executable(clang-include-fixer
+  ClangIncludeFixer.cpp
+  )
+
 target_link_libraries(clang-include-fixer
   clangBasic
   clangFormat
@@ -11,3 +14,13 @@
   clangToolingCore
   findAllSymbols
   )
+
+install(TARGETS clang-include-fixer
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-include-fixer.el
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)
+install(PROGRAMS clang-include-fixer.py
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)
Index: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
@@ -1,13 +1,22 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols FindAllSymbolsMain.cpp)
-target_link_libraries(find-all-symbols
+add_clang_executable(find-all-symbols
+  FindAllSymbolsMain.cpp
+  )
 
+target_link_libraries(find-all-symbols
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangLex
   clangTooling
   findAllSymbols
   )
+
+install(TARGETS find-all-symbols
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS run-find-all-symbols.py
+  DESTINATION share/clang
+  COMPONENT find-all-symbols)


Index: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
@@ -1,6 +1,9 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-include-fixer ClangIncludeFixer.cpp)
+add_clang_executable(clang-include-fixer
+  ClangIncludeFixer.cpp
+  )
+
 target_link_libraries(clang-include-fixer
   clangBasic
   clangFormat
@@ -11,3 +14,13 @@
   clangToolingCore
   findAllSymbols
   )
+
+install(TARGETS clang-include-fixer
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-include-fixer.el
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)
+install(PROGRAMS clang-include-fixer.py
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
@@ -1,13 +1,22 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols FindAllSymbolsMain.cpp)
-target_link_libraries(find-all-symbols
+add_clang_executable(find-all-symbols
+  FindAllSymbolsMain.cpp
+  )
 
+target_link_libraries(find-all-symbols
   clangAST
   clangASTMatchers
   clangBasic
   clangFrontend
   clangLex
   clangTooling
   findAllSymbols
   )
+
+install(TARGETS find-all-symbols
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS run-find-all-symbols.py
+  DESTINATION share/clang
+  COMPONENT find-all-symbols)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r278949 - [Include-fixer] Install executables and support scripts

2016-08-17 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Aug 17 12:27:56 2016
New Revision: 278949

URL: http://llvm.org/viewvc/llvm-project?rev=278949=rev
Log:
[Include-fixer] Install executables and support scripts

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

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt?rev=278949=278948=278949=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/CMakeLists.txt 
Wed Aug 17 12:27:56 2016
@@ -1,8 +1,10 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(find-all-symbols FindAllSymbolsMain.cpp)
-target_link_libraries(find-all-symbols
+add_clang_executable(find-all-symbols
+  FindAllSymbolsMain.cpp
+  )
 
+target_link_libraries(find-all-symbols
   clangAST
   clangASTMatchers
   clangBasic
@@ -11,3 +13,10 @@ target_link_libraries(find-all-symbols
   clangTooling
   findAllSymbols
   )
+
+install(TARGETS find-all-symbols
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS run-find-all-symbols.py
+  DESTINATION share/clang
+  COMPONENT find-all-symbols)

Modified: clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt?rev=278949=278948=278949=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/tool/CMakeLists.txt Wed Aug 17 
12:27:56 2016
@@ -1,6 +1,9 @@
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-add_clang_executable(clang-include-fixer ClangIncludeFixer.cpp)
+add_clang_executable(clang-include-fixer
+  ClangIncludeFixer.cpp
+  )
+
 target_link_libraries(clang-include-fixer
   clangBasic
   clangFormat
@@ -11,3 +14,13 @@ target_link_libraries(clang-include-fixe
   clangToolingCore
   findAllSymbols
   )
+
+install(TARGETS clang-include-fixer
+  RUNTIME DESTINATION bin)
+
+install(PROGRAMS clang-include-fixer.el
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)
+install(PROGRAMS clang-include-fixer.py
+  DESTINATION share/clang
+  COMPONENT clang-include-fixer)


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


Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:29
@@ +28,3 @@
+/// Provides information about the evaluation order of (sub-)expressions within
+/// a CFGBlock.
+///

Please enclose inline code snippets in double backquotes (doxygen supports 
markdown to a certain degree).


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:46
@@ +45,3 @@
+///   API),
+/// - Removing the dependency of SequenceChecker on Sema, and
+/// - (Probably) modifying SequenceChecker to make it suitable to be used in

Does it look feasible?


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:135
@@ +134,3 @@
+class UseAfterMoveFinder {
+public:
+  UseAfterMoveFinder(ASTContext *TheContext);

It's definitely subjective, but I don't think it's scary. And the size of the 
file doesn't seem to be an issue yet. IMO, a reason to move this to a header 
would appear once this class is needed elsewhere. 


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:216
@@ +215,3 @@
+: Context(TheContext) {
+  for (CFG::synthetic_stmt_iterator I = TheCFG->synthetic_stmt_begin(),
+E = TheCFG->synthetic_stmt_end();

nit: How about `for (const auto  : 
llvm::make_range(TheCFG->synthetic_stmt_begin(), TheCFG->synthetic_stmt_end())) 
...`?

Alternatively, we could add `CFG::synthetic_stmt()` method that would return an 
`iterator_range<...>`.


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:435
@@ +434,3 @@
+  if (Reinits.empty()) {
+for (CFGBlock::const_succ_iterator I = Block->succ_begin(),
+   E = Block->succ_end();

Use `llvm::make_range` and a range-for loop?


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:465
@@ +464,3 @@
+  std::sort(Uses->begin(), Uses->end(),
+[](const DeclRefExpr *d1, const DeclRefExpr *d2) {
+  return d1->getExprLoc() < d2->getExprLoc();

nit: Variable names should start with a capital letter.


https://reviews.llvm.org/D23353



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-08-17 Thread Saleem Abdulrasool via cfe-commits
compnerd added a subscriber: compnerd.


Comment at: CMakeLists.txt:139
@@ -138,1 +138,3 @@
 option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread 
API" OFF)
+option(LIBCXX_HAS_EXTERNAL_THREAD_API
+  "Build libc++ with an externalized threading API.

Can you use `cmake_dependent_option` here instead please?


Comment at: include/__config:830
@@ -829,1 +829,3 @@
+!defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \
+!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
 # if defined(__FreeBSD__) || \

clang-format?


https://reviews.llvm.org/D21968



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


Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-08-17 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 68376.
sepavloff added a comment.

Rebased the patch


https://reviews.llvm.org/D16989

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/PR25848.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- /dev/null
+++ test/SemaCXX/friend2.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// If a friend function is defined in several non-template classes,
+// it is an error.
+
+void func1(int);
+struct C1a {
+  friend void func1(int) {}  // expected-note{{previous definition is here}}
+};
+struct C1b {
+  friend void func1(int) {}  // expected-error{{redefinition of 'func1'}}
+};
+
+
+// If a friend function is defined in both non-template and template
+// classes it is an error only if the template is instantiated.
+
+void func2(int);
+struct C2a {
+  friend void func2(int) {}
+};
+template struct C2b {
+  friend void func2(int) {}
+};
+
+void func3(int);
+struct C3a {
+  friend void func3(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C3b {
+  friend void func3(int) {}  // expected-error{{redefinition of 'func3'}}
+};
+C3b c3;  // expected-note{{in instantiation of template class 'C3b' requested here}}
+
+
+// If a friend function is defined in several template classes it is an error
+// only if several templates are instantiated.
+
+void func4(int);
+template struct C4a {
+  friend void func4(int) {}
+};
+template struct C4b {
+  friend void func4(int) {}
+};
+
+
+void func5(int);
+template struct C5a {
+  friend void func5(int) {}
+};
+template struct C5b {
+  friend void func5(int) {}
+};
+C5a c5a;
+
+void func6(int);
+template struct C6a {
+  friend void func6(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C6b {
+  friend void func6(int) {}  // expected-error{{redefinition of 'func6'}}
+};
+C6a c6a;
+C6b c6b;  // expected-note{{in instantiation of template class 'C6b' requested here}}
+
+void func7(int);
+template struct C7 {
+  friend void func7(int) {}  // expected-error{{redefinition of 'func7'}}
+ // expected-note@-1{{previous definition is here}}
+};
+C7 c7a;
+C7 c7b;  // expected-note{{in instantiation of template class 'C7' requested here}}
+
+
+// Even if clases are not instantiated and hence friend functions defined in them are not
+// available, their declarations can be checked.
+
+void func8(int);  // expected-note{{previous declaration is here}}
+template struct C8a {
+  friend long func8(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func9(int);  // expected-note{{previous declaration is here}}
+template struct C9a {
+  friend int func9(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func10(int);  // expected-note{{previous declaration is here}}
+template struct C10a {
+  friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+
+namespace pr22307 {
+
+struct t {
+  friend int leak(t);
+};
+
+template
+struct m {
+  friend int leak(t) { return sizeof(v); }  // expected-error{{redefinition of 'leak'}} expected-note{{previous definition is here}}
+};
+
+template struct m;
+template struct m;  // expected-note{{in instantiation of template class 'pr22307::m' requested here}}
+
+int main() {
+  leak(t());
+}
+
+}
+
+namespace pr17923 {
+
+void f(unsigned long long);
+
+template struct X {
+  friend void f(unsigned long long) {
+ T t;
+  }
+};
+
+int main() { f(1234); }
+
+}
+
+namespace pr17923a {
+
+int get();
+
+template< int value >
+class set {
+  friend int get()
+{ return value; } // return 0; is OK
+};
+
+template class set< 5 >;
+
+int main() {
+  get();
+}
+
+}
Index: test/SemaCXX/PR25848.cpp
===
--- /dev/null
+++ test/SemaCXX/PR25848.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+
+inline int g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend int g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8640,6 +8640,49 @@
   return NewFD;
 }
 
+/// \brief Checks if the new declaration declared in dependent context must be
+/// put in the same redeclaration chain as the specified declaration.
+///
+/// \param D Declaration that is checked.
+/// \param PrevDecl Previous declaration found with proper lookup method for the
+/// same declaration name.
+/// \returns True if D must be added to the redeclaration chain which PrevDecl
+///  belongs to.
+///
+bool 

Re: [PATCH] D21675: New ODR checker for modules

2016-08-17 Thread David Blaikie via cfe-commits
dblaikie added inline comments.


Comment at: lib/AST/DeclBase.cpp:1810-1812
@@ +1809,5 @@
+  void VisitNamedDecl(const NamedDecl *D) {
+if (IdentifierInfo *II = D->getIdentifier()) {
+  ID.AddString(II->getName());
+}
+Inherited::VisitNamedDecl(D);

Inconsistent {} on single line block (in VisitEnumConstantDecl above {} are not 
used on a single line block) - usually drop the {} on single line blocks.

(several other instances in this patch)


Comment at: test/Modules/Inputs/odr_hash/first.h:5-8
@@ +4,6 @@
+
+struct S2Friend2 {};
+struct S2 {
+  friend S2Friend2;
+};
+

It might make this test more readable if all the types were in one file, maybe 
like this:

  #ifdef FIRST
struct S2 { friend S2Friend1 };
  #endif
struct S2 { friend S2Friend2 };
  #endif

Etc... - and it could just be a textual header that the two headers include 
(one header #defines/#undefs the appropriate thing and one doesn't). But maybe 
that's too complicated - I'm not sure.


https://reviews.llvm.org/D21675



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


Re: [PATCH] D23353: [clang-tidy] Add check 'misc-use-after-move'

2016-08-17 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D23353#516314, @mboehme wrote:

> In https://reviews.llvm.org/D23353#511362, @Prazek wrote:
>
> > I will review it later, but my first thoughts:
> >
> > 1. I think we should make some other group, because misc seems to be 
> > overloaded. I discussed it with Alex months ago - something like bugprone 
> > would be good.
>
>
> Agree that "misc" seems pretty overcrowded. I'll defer to those who have been 
> working on clang-tidy longer than me to make this call.
>
> > 2. Also it would be good to make link in cppcoreguidelines.
>
>
> How exactly would I create such a "link"? Are you just thinking of a link in 
> the documentation, or is there a way to have one clang-tidy check activate 
> another (and is this what you're thinking of)?


I am not sure if there is any other mechanism than just links in documentation. 
In the perfect word it would be nice to invoke this check using 
cppcoreguidelines-use-after-move also with some special options like Pedantic=1 
(That would warn about any use after move, even after reinitialization - this 
is what cppcoreguidelines says)



Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:134
@@ +133,3 @@
+/// various internal helper functions).
+class UseAfterMoveFinder {
+public:

What do you think about moving this, and maybe other things to some different 
header file to make it not so scary?


Comment at: clang-tidy/misc/UseAfterMoveCheck.cpp:649-652
@@ +648,6 @@
+FunctionBody = ContainingFunc->getBody();
+  }
+
+  if (!FunctionBody)
+return;
+

you can replace it with 
  else
return;


Comment at: test/clang-tidy/misc-use-after-move.cpp:504-505
@@ +503,4 @@
+std::move(a);
+a = A();
+a.foo();
+  }

I would like to mark it as use after move with some pedantic flag


https://reviews.llvm.org/D23353



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


r278946 - Simplify condition. (NFC)

2016-08-17 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 17 11:42:15 2016
New Revision: 278946

URL: http://llvm.org/viewvc/llvm-project?rev=278946=rev
Log:
Simplify condition. (NFC)

Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=278946=278945=278946=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Aug 17 11:42:15 2016
@@ -2657,13 +2657,14 @@ bool FunctionDecl::isGlobal() const {
 }
 
 bool FunctionDecl::isNoReturn() const {
-  bool HasNoReturnAttr = hasAttr() || 
hasAttr()
- || hasAttr();
-  const auto *FuncType = getType()->getAs();
-  bool TypeHasNoReturnAttr = false;
-  if (FuncType)
-TypeHasNoReturnAttr = FuncType->getNoReturnAttr();
-  return HasNoReturnAttr || TypeHasNoReturnAttr;
+  if (hasAttr() || hasAttr() ||
+  hasAttr())
+return true;
+
+  if (auto *FnTy = getType()->getAs())
+return FnTy->getNoReturnAttr();
+
+  return false;
 }
 
 void


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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:35
@@ +34,3 @@
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(anyOf(isPrivate(), isProtected(;
+

Prazek wrote:
> alexfh wrote:
> > Prazek wrote:
> > > aaron.ballman wrote:
> > > > Prazek wrote:
> > > > > aaron.ballman wrote:
> > > > > > Perhaps: `unless(isPublic())` instead of `anyOf(isPrivate(), 
> > > > > > isProtected())`?
> > > > > POD types doesn't have public constructors so it will fail :)
> > > > Don't they have an implicit one for the purposes of a CXXConstructExpr? 
> > > > Looking at an AST dump for:
> > > > ```
> > > > struct S {
> > > >   int i;
> > > > };
> > > > ```
> > > > yields:
> > > > ```
> > > > |-CXXRecordDecl 0x26d74ae5348  line:25:8 
> > > > referenced struct S definition
> > > > | |-CXXRecordDecl 0x26d74ae5460  col:8 implicit struct S
> > > > | |-FieldDecl 0x26d74ae7880  col:7 i 'int'
> > > > | |-CXXConstructorDecl 0x26d74ae87b8  col:8 implicit used S 
> > > > 'void (void) noexcept' inline
> > > > | | `-CompoundStmt 0x26d74ae3850 
> > > > | |-CXXConstructorDecl 0x26d74ae34a8  col:8 implicit constexpr S 
> > > > 'void (const struct S &)' inline noexcept-unevaluated 0x26d74ae34a8
> > > > | | `-ParmVarDecl 0x26d74ae35e0  col:8 'const struct S &'
> > > > | `-CXXConstructorDecl 0x26d74ae3678  col:8 implicit constexpr S 
> > > > 'void (struct S &&)' inline noexcept-unevaluated 0x26d74ae3678
> > > > |   `-ParmVarDecl 0x26d74ae37b0  col:8 'struct S &&'
> > > > ```
> > > what about std::shared_ptr x = std::shared_ptr(new int); ?
> > > If I recall correctly, it didn't work on this test.
> > There's no `CXXConstructExpr` for primitive types:
> > ```
> > $ cat /tmp/qq.cc 
> > #include 
> > 
> > struct S { S(); };
> > void () {
> >   std::shared_ptr p1 = std::shared_ptr(new int);
> >   std::shared_ptr p2 = std::shared_ptr(new S);
> > }
> > $ clang-check -ast-dump -ast-dump-filter= /tmp/qq.cc -- -std=c++11
> > Dumping :
> > FunctionDecl 0x7f48270fb6e0  line:4:6  'void 
> > (void)'
> > `-CompoundStmt 0x7f48271582a8 
> >   |-DeclStmt 0x7f4827131000 
> >   | `-VarDecl 0x7f48270fb9c8  col:24 p1 
> > 'std::shared_ptr':'class std::shared_ptr' cinit
> >   |   `-ExprWithCleanups 0x7f4827130fe8  
> > 'std::shared_ptr':'class std::shared_ptr'
> >   | `-CXXConstructExpr 0x7f4827130fb0  
> > 'std::shared_ptr':'class std::shared_ptr' 'void (class 
> > std::shared_ptr &&) noexcept' elidable
> >   |   `-MaterializeTemporaryExpr 0x7f4827130f98  'class 
> > std::shared_ptr' xvalue
> >   | `-CXXFunctionalCastExpr 0x7f48271303c8  
> > 'std::shared_ptr':'class std::shared_ptr' functional cast to 
> > std::shared_ptr 
> >   |   `-CXXBindTemporaryExpr 0x7f48271303a8  
> > 'std::shared_ptr':'class std::shared_ptr' (CXXTemporary 
> > 0x7f48271303a0)
> >   | `-CXXConstructExpr 0x7f4827130338  
> > 'std::shared_ptr':'class std::shared_ptr' 'void (int *)'
> >   |   `-CXXNewExpr 0x7f48270fbb58  'int *' 
> > Function 0x7f4826a1c000 'operator new' 'void *(std::size_t)'
> >   `-DeclStmt 0x7f4827158290 
> > `-VarDecl 0x7f4827131238  col:22 p2 
> > 'std::shared_ptr':'class std::shared_ptr' cinit
> >   `-ExprWithCleanups 0x7f4827158278  
> > 'std::shared_ptr':'class std::shared_ptr'
> > `-CXXConstructExpr 0x7f4827158240  
> > 'std::shared_ptr':'class std::shared_ptr' 'void (class 
> > std::shared_ptr &&) noexcept' elidable
> >   `-MaterializeTemporaryExpr 0x7f4827158228  'class 
> > std::shared_ptr' xvalue
> > `-CXXFunctionalCastExpr 0x7f4827157658  
> > 'std::shared_ptr':'class std::shared_ptr' functional cast to 
> > std::shared_ptr 
> >   `-CXXBindTemporaryExpr 0x7f4827157638  
> > 'std::shared_ptr':'class std::shared_ptr' (CXXTemporary 
> > 0x7f4827157630)
> > `-CXXConstructExpr 0x7f48271575c8  
> > 'std::shared_ptr':'class std::shared_ptr' 'void (struct S *)'
> >   `-CXXNewExpr 0x7f4827131838  'struct S *' 
> > Function 0x7f4826a1c000 'operator new' 'void *(std::size_t)'
> > `-CXXConstructExpr 0x7f4827131808  'struct S' 
> > 'void (void)'
> > ```
> exactly.
But this means that `unless(isPublic())` should work, IIUC.


https://reviews.llvm.org/D23343



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-17 Thread Piotr Padlewski via cfe-commits
Prazek marked 2 inline comments as done.
Prazek added a comment.

https://reviews.llvm.org/D23343



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-17 Thread Piotr Padlewski via cfe-commits
Prazek marked 8 inline comments as done.


Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:35
@@ +34,3 @@
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+  hasDeclaration(decl(anyOf(isPrivate(), isProtected(;
+

alexfh wrote:
> Prazek wrote:
> > aaron.ballman wrote:
> > > Prazek wrote:
> > > > aaron.ballman wrote:
> > > > > Perhaps: `unless(isPublic())` instead of `anyOf(isPrivate(), 
> > > > > isProtected())`?
> > > > POD types doesn't have public constructors so it will fail :)
> > > Don't they have an implicit one for the purposes of a CXXConstructExpr? 
> > > Looking at an AST dump for:
> > > ```
> > > struct S {
> > >   int i;
> > > };
> > > ```
> > > yields:
> > > ```
> > > |-CXXRecordDecl 0x26d74ae5348  line:25:8 referenced 
> > > struct S definition
> > > | |-CXXRecordDecl 0x26d74ae5460  col:8 implicit struct S
> > > | |-FieldDecl 0x26d74ae7880  col:7 i 'int'
> > > | |-CXXConstructorDecl 0x26d74ae87b8  col:8 implicit used S 
> > > 'void (void) noexcept' inline
> > > | | `-CompoundStmt 0x26d74ae3850 
> > > | |-CXXConstructorDecl 0x26d74ae34a8  col:8 implicit constexpr S 
> > > 'void (const struct S &)' inline noexcept-unevaluated 0x26d74ae34a8
> > > | | `-ParmVarDecl 0x26d74ae35e0  col:8 'const struct S &'
> > > | `-CXXConstructorDecl 0x26d74ae3678  col:8 implicit constexpr S 
> > > 'void (struct S &&)' inline noexcept-unevaluated 0x26d74ae3678
> > > |   `-ParmVarDecl 0x26d74ae37b0  col:8 'struct S &&'
> > > ```
> > what about std::shared_ptr x = std::shared_ptr(new int); ?
> > If I recall correctly, it didn't work on this test.
> There's no `CXXConstructExpr` for primitive types:
> ```
> $ cat /tmp/qq.cc 
> #include 
> 
> struct S { S(); };
> void () {
>   std::shared_ptr p1 = std::shared_ptr(new int);
>   std::shared_ptr p2 = std::shared_ptr(new S);
> }
> $ clang-check -ast-dump -ast-dump-filter= /tmp/qq.cc -- -std=c++11
> Dumping :
> FunctionDecl 0x7f48270fb6e0  line:4:6  'void 
> (void)'
> `-CompoundStmt 0x7f48271582a8 
>   |-DeclStmt 0x7f4827131000 
>   | `-VarDecl 0x7f48270fb9c8  col:24 p1 
> 'std::shared_ptr':'class std::shared_ptr' cinit
>   |   `-ExprWithCleanups 0x7f4827130fe8  
> 'std::shared_ptr':'class std::shared_ptr'
>   | `-CXXConstructExpr 0x7f4827130fb0  
> 'std::shared_ptr':'class std::shared_ptr' 'void (class 
> std::shared_ptr &&) noexcept' elidable
>   |   `-MaterializeTemporaryExpr 0x7f4827130f98  'class 
> std::shared_ptr' xvalue
>   | `-CXXFunctionalCastExpr 0x7f48271303c8  
> 'std::shared_ptr':'class std::shared_ptr' functional cast to 
> std::shared_ptr 
>   |   `-CXXBindTemporaryExpr 0x7f48271303a8  
> 'std::shared_ptr':'class std::shared_ptr' (CXXTemporary 
> 0x7f48271303a0)
>   | `-CXXConstructExpr 0x7f4827130338  
> 'std::shared_ptr':'class std::shared_ptr' 'void (int *)'
>   |   `-CXXNewExpr 0x7f48270fbb58  'int *' 
> Function 0x7f4826a1c000 'operator new' 'void *(std::size_t)'
>   `-DeclStmt 0x7f4827158290 
> `-VarDecl 0x7f4827131238  col:22 p2 
> 'std::shared_ptr':'class std::shared_ptr' cinit
>   `-ExprWithCleanups 0x7f4827158278  
> 'std::shared_ptr':'class std::shared_ptr'
> `-CXXConstructExpr 0x7f4827158240  
> 'std::shared_ptr':'class std::shared_ptr' 'void (class 
> std::shared_ptr &&) noexcept' elidable
>   `-MaterializeTemporaryExpr 0x7f4827158228  'class 
> std::shared_ptr' xvalue
> `-CXXFunctionalCastExpr 0x7f4827157658  
> 'std::shared_ptr':'class std::shared_ptr' functional cast to 
> std::shared_ptr 
>   `-CXXBindTemporaryExpr 0x7f4827157638  
> 'std::shared_ptr':'class std::shared_ptr' (CXXTemporary 
> 0x7f4827157630)
> `-CXXConstructExpr 0x7f48271575c8  
> 'std::shared_ptr':'class std::shared_ptr' 'void (struct S *)'
>   `-CXXNewExpr 0x7f4827131838  'struct S *' 
> Function 0x7f4826a1c000 'operator new' 'void *(std::size_t)'
> `-CXXConstructExpr 0x7f4827131808  'struct S' 
> 'void (void)'
> ```
exactly.


https://reviews.llvm.org/D23343



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-17 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:32-33
@@ -31,1 +31,4 @@
 
+  // Calling make_smart_ptr from within a member function of a type with a
+  // private or protected constructor would be ill-formed.
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(

alexfh wrote:
> malcolm.parsons wrote:
> > The private constructor could also be called from a friend class.
> It might only be relevant, if `std::make_(shared|unique)` is declared as a 
> friend of the class in question, which is unlikely to be a common case and I 
> don't think we need to focus on this now.
I am totally aware of it, but I never saw a friend delcaration for any 
class/function from libc++.


https://reviews.llvm.org/D23343



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-17 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:32-33
@@ -31,1 +31,4 @@
 
+  // Calling make_smart_ptr from within a member function of a type with a
+  // private or protected constructor would be ill-formed.
+  auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(

malcolm.parsons wrote:
> The private constructor could also be called from a friend class.
It might only be relevant, if `std::make_(shared|unique)` is declared as a 
friend of the class in question, which is unlikely to be a common case and I 
don't think we need to focus on this now.


https://reviews.llvm.org/D23343



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


Re: [PATCH] D23168: emit_DW_AT_noreturn flag

2016-08-17 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Committed as r278942. Thanks!


https://reviews.llvm.org/D23168



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


r278942 - Debug info: Mark noreturn functions with DIFlagNoReturn.

2016-08-17 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Wed Aug 17 11:20:32 2016
New Revision: 278942

URL: http://llvm.org/viewvc/llvm-project?rev=278942=rev
Log:
Debug info: Mark noreturn functions with DIFlagNoReturn.

This affects functions with the C++11 [[ noreturn ]] and C11 _Noreturn
specifiers.

Patch by Victor Leschuk!

https://reviews.llvm.org/D23168

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=278942=278941=278942=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Aug 17 11:20:32 2016
@@ -2657,9 +2657,13 @@ bool FunctionDecl::isGlobal() const {
 }
 
 bool FunctionDecl::isNoReturn() const {
-  return hasAttr() || hasAttr() ||
- hasAttr() ||
- getType()->getAs()->getNoReturnAttr();
+  bool HasNoReturnAttr = hasAttr() || 
hasAttr()
+ || hasAttr();
+  const auto *FuncType = getType()->getAs();
+  bool TypeHasNoReturnAttr = false;
+  if (FuncType)
+TypeHasNoReturnAttr = FuncType->getNoReturnAttr();
+  return HasNoReturnAttr || TypeHasNoReturnAttr;
 }
 
 void

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=278942=278941=278942=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 17 11:20:32 2016
@@ -2646,6 +2646,9 @@ void CGDebugInfo::collectFunctionDeclPro
   llvm::DIScope *Mod = getParentModuleOrNull(RDecl);
   FDContext = getContextDescriptor(RDecl, Mod ? Mod : TheCU);
 }
+// Check if it is a noreturn-marked function
+if (FD->isNoReturn())
+  Flags |= llvm::DINode::FlagNoReturn;
 // Collect template parameters.
 TParamsArray = CollectFunctionTemplateParams(FD, Unit);
   }


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


Re: [PATCH] D23168: emit_DW_AT_noreturn flag

2016-08-17 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Note that I moved the test cases to the appropriate CodeGenXYZ directories.


https://reviews.llvm.org/D23168



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


Re: [PATCH] D23167: emit_DW_AT_noreturn flag

2016-08-17 Thread Adrian Prantl via cfe-commits
aprantl closed this revision.
aprantl added a comment.

Committed as r278940. Thanks!


https://reviews.llvm.org/D23167



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


Re: [PATCH] D13126: New static analyzer checker for loss of sign/precision

2016-08-17 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL278941: [analyzer] Add a checker for loss of sign or 
precision in integral casts. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D13126?vs=67817=68372#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D13126

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
  cfe/trunk/test/Analysis/conversion.c

Index: cfe/trunk/test/Analysis/conversion.c
===
--- cfe/trunk/test/Analysis/conversion.c
+++ cfe/trunk/test/Analysis/conversion.c
@@ -0,0 +1,125 @@
+// RUN: %clang_cc1 -Wno-conversion -analyze -analyzer-checker=core,alpha.core.Conversion -verify %s
+
+unsigned char U8;
+signed char S8;
+
+void assign(unsigned U, signed S) {
+  if (S < -10)
+U8 = S; // expected-warning {{Loss of sign in implicit conversion}}
+  if (U > 300)
+S8 = U; // expected-warning {{Loss of precision in implicit conversion}}
+  if (S > 10)
+U8 = S;
+  if (U < 200)
+S8 = U;
+}
+
+void init1() {
+  long long A = 1LL << 60;
+  short X = A; // expected-warning {{Loss of precision in implicit conversion}}
+}
+
+void relational(unsigned U, signed S) {
+  if (S > 10) {
+if (U < S) {
+}
+  }
+  if (S < -10) {
+if (U < S) { // expected-warning {{Loss of sign in implicit conversion}}
+}
+  }
+}
+
+void multiplication(unsigned U, signed S) {
+  if (S > 5)
+S = U * S;
+  if (S < -10)
+S = U * S; // expected-warning {{Loss of sign}}
+}
+
+void division(unsigned U, signed S) {
+  if (S > 5)
+S = U / S;
+  if (S < -10)
+S = U / S; // expected-warning {{Loss of sign}}
+}
+
+void dontwarn1(unsigned U, signed S) {
+  U8 = S; // It might be known that S is always 0x00-0xff.
+  S8 = U; // It might be known that U is always 0x00-0xff.
+
+  U8 = -1;  // Explicit conversion.
+  S8 = ~0U; // Explicit conversion.
+  if (U > 300)
+U8 &= U; // No loss of precision since there is &=.
+}
+
+void dontwarn2(unsigned int U) {
+  if (U <= 4294967295) {
+  }
+  if (U <= (2147483647 * 2U + 1U)) {
+  }
+}
+
+void dontwarn3(int X) {
+  S8 = X ? 'a' : 'b';
+}
+
+// don't warn for macros
+#define DOSTUFF ({ unsigned X = 1000; U8 = X; })
+void dontwarn4() {
+  DOSTUFF;
+}
+
+// don't warn for calculations
+// seen some fp. For instance:  c2 = (c2 >= 'A' && c2 <= 'Z') ? c2 - 'A' + 'a' : c2;
+// there is a todo in the checker to handle calculations
+void dontwarn5() {
+  signed S = -32;
+  U8 = S + 10;
+}
+
+
+// false positives..
+
+int isascii(int c);
+void falsePositive1() {
+  char kb2[5];
+  int X = 1000;
+  if (isascii(X)) {
+// FIXME: should not warn here:
+kb2[0] = X; // expected-warning {{Loss of precision}}
+  }
+}
+
+
+typedef struct FILE {} FILE; int getc(FILE *stream);
+# define EOF (-1)
+char reply_string[8192];
+FILE *cin;
+extern int dostuff (void);
+int falsePositive2() {
+  int c, n;
+  int dig;
+  char *cp = reply_string;
+  int pflag = 0;
+  int code;
+
+  for (;;) {
+dig = n = code = 0;
+while ((c = getc(cin)) != '\n') {
+  if (dig < 4 && dostuff())
+code = code * 10 + (c - '0');
+  if (!pflag && code == 227)
+pflag = 1;
+  if (n == 0)
+n = c;
+  if (c == EOF)
+return(4);
+  if (cp < _string[sizeof(reply_string) - 1])
+// FIXME: should not warn here:
+*cp++ = c; // expected-warning {{Loss of precision}}
+}
+  }
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -23,6 +23,7 @@
   ChrootChecker.cpp
   ClangCheckers.cpp
   CloneChecker.cpp
+  ConversionChecker.cpp
   CXXSelfAssignmentChecker.cpp
   DeadStoresChecker.cpp
   DebugCheckers.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ConversionChecker.cpp
@@ -0,0 +1,192 @@
+//=== ConversionChecker.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Check that there is no loss of sign/precision in assignments, comparisons
+// and multiplications.
+//
+// ConversionChecker uses path sensitive analysis to determine possible values
+// of expressions. A warning is reported when:
+// * a negative value is implicitly converted to an unsigned value in an
+//   assignment, comparison or 

r278937 - [analyzer] Add LocationContext information to SymbolMetadata.

2016-08-17 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Aug 17 10:37:52 2016
New Revision: 278937

URL: http://llvm.org/viewvc/llvm-project?rev=278937=rev
Log:
[analyzer] Add LocationContext information to SymbolMetadata.

Like SymbolConjured, SymbolMetadata also needs to be uniquely
identified by the moment of its birth.

Such moments are coded by the (Statement, LocationContext, Block count) triples.
Each such triple represents the moment of analyzing a statement with a certain
call backtrace, with corresponding CFG block having been entered a given amount
of times during analysis of the current code body.

The LocationContext information was accidentally omitted for SymbolMetadata,
which leads to reincarnation of SymbolMetadata upon re-entering a code body
with a different backtrace; the new symbol is incorrectly unified with
the old symbol, which leads to unsound assumptions.

Patch by Alexey Sidorin!

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SymbolManager.cpp
cfe/trunk/test/Analysis/string.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=278937=278936=278937=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Wed 
Aug 17 10:37:52 2016
@@ -198,9 +198,11 @@ public:
   DefinedOrUnknownSVal getDerivedRegionValueSymbolVal(
   SymbolRef parentSymbol, const TypedValueRegion *region);
 
-  DefinedSVal getMetadataSymbolVal(
-  const void *symbolTag, const MemRegion *region,
-  const Expr *expr, QualType type, unsigned count);
+  DefinedSVal getMetadataSymbolVal(const void *symbolTag,
+   const MemRegion *region,
+   const Expr *expr, QualType type,
+   const LocationContext *LCtx,
+   unsigned count);
 
   DefinedSVal getFunctionPointer(const FunctionDecl *func);
   

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=278937=278936=278937=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
Wed Aug 17 10:37:52 2016
@@ -186,15 +186,18 @@ class SymbolMetadata : public SymbolData
   const MemRegion* R;
   const Stmt *S;
   QualType T;
+  const LocationContext *LCtx;
   unsigned Count;
   const void *Tag;
 public:
   SymbolMetadata(SymbolID sym, const MemRegion* r, const Stmt *s, QualType t,
- unsigned count, const void *tag)
-  : SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), Count(count), 
Tag(tag) {}
+ const LocationContext *LCtx, unsigned count, const void *tag)
+  : SymbolData(SymbolMetadataKind, sym), R(r), S(s), T(t), LCtx(LCtx),
+Count(count), Tag(tag) {}
 
   const MemRegion *getRegion() const { return R; }
   const Stmt *getStmt() const { return S; }
+  const LocationContext *getLocationContext() const { return LCtx; }
   unsigned getCount() const { return Count; }
   const void *getTag() const { return Tag; }
 
@@ -203,18 +206,19 @@ public:
   void dumpToStream(raw_ostream ) const override;
 
   static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion *R,
-  const Stmt *S, QualType T, unsigned Count,
-  const void *Tag) {
+  const Stmt *S, QualType T, const LocationContext *LCtx,
+  unsigned Count, const void *Tag) {
 profile.AddInteger((unsigned) SymbolMetadataKind);
 profile.AddPointer(R);
 profile.AddPointer(S);
 profile.Add(T);
+profile.AddPointer(LCtx);
 profile.AddInteger(Count);
 profile.AddPointer(Tag);
   }
 
   void Profile(llvm::FoldingSetNodeID& profile) override {
-Profile(profile, R, S, T, Count, Tag);
+Profile(profile, R, S, T, LCtx, Count, Tag);
   }
 
   // Implement isa support.
@@ -435,7 +439,9 @@ public:
   /// VisitCount can be used to differentiate regions corresponding to
   /// different loop iterations, thus, making the symbol path-dependent.
   const SymbolMetadata *getMetadataSymbol(const MemRegion *R, const Stmt *S,
-  QualType T, 

  1   2   >