[libcxxabi] r286337 - [libc++abi] Remove the test for checking using of fallback malloc in case of dynamic memory exhaustion.

2016-11-08 Thread Igor Kudrin via cfe-commits
Author: ikudrin
Date: Tue Nov  8 22:14:31 2016
New Revision: 286337

URL: http://llvm.org/viewvc/llvm-project?rev=286337=rev
Log:
[libc++abi] Remove the test for checking using of fallback malloc in case of 
dynamic memory exhaustion.

This test is too fragile and doesn't add significant value. See 
https://reviews.llvm.org/D26150 for some details.

Removed:
libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp

Removed: libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp?rev=286336=auto
==
--- libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_storage_nodynmem.pass.cpp (removed)
@@ -1,40 +0,0 @@
-//===--- test_exception_storage_nodynmem.cpp 
--===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-// UNSUPPORTED: libcxxabi-no-exceptions
-
-// cxa_exception_storage does not use dynamic memory in the single thread mode.
-// UNSUPPORTED: libcpp-has-no-threads
-
-// Our overwritten calloc() is not compatible with these sanitizers.
-// UNSUPPORTED: msan, tsan
-
-#include 
-#include 
-
-static bool OverwrittenCallocCalled = false;
-
-// Override calloc to simulate exhaustion of dynamic memory
-void *calloc(size_t, size_t) {
-OverwrittenCallocCalled = true;
-return 0;
-}
-
-int main(int argc, char *argv[]) {
-// Run the test a couple of times
-// to ensure that fallback memory doesn't leak.
-for (int I = 0; I < 1000; ++I)
-try {
-throw 42;
-} catch (...) {
-}
-
-assert(OverwrittenCallocCalled);
-return 0;
-}


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


r286336 - Doxygen comments for avxintrin.h.

2016-11-08 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Tue Nov  8 21:58:30 2016
New Revision: 286336

URL: http://llvm.org/viewvc/llvm-project?rev=286336=rev
Log:
Doxygen comments for avxintrin.h.

Added doxygen comments to avxintrin.h's intrinsics. As of now, around 75% of the
intrinsics in this file are documented here. The patches for the other 25% will 
be se
nt out later.

Removed extra spaces in emmitrin.h.

Note: The doxygen comments are automatically generated based on Sony's 
intrinsics document.

I got an OK from Eric Christopher to commit doxygen comments without prior code
review upstream.




Modified:
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=286336=286335=286336=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Tue Nov  8 21:58:30 2016
@@ -2533,12 +2533,65 @@ _mm256_undefined_si256(void)
   return (__m256i)__builtin_ia32_undef256();
 }
 
+/// \brief Constructs a 256-bit floating-point vector of [4 x double]
+///initialized with the specified double-precision floating-point values.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VUNPCKLPD+VINSERTF128 instruction.
+///
+/// \param __a
+///A double-precision floating-point value used to initialize bits 
[255:192]
+///of the result.
+/// \param __b
+///A double-precision floating-point value used to initialize bits 
[191:128]
+///of the result.
+/// \param __c
+///A double-precision floating-point value used to initialize bits [127:64]
+///of the result.
+/// \param __d
+///A double-precision floating-point value used to initialize bits [63:0]
+///of the result.
+/// \returns An initialized 256-bit floating-point vector of [4 x double].
 static __inline __m256d __DEFAULT_FN_ATTRS
 _mm256_set_pd(double __a, double __b, double __c, double __d)
 {
   return (__m256d){ __d, __c, __b, __a };
 }
 
+/// \brief Constructs a 256-bit floating-point vector of [8 x float] 
initialized
+///with the specified single-precision floating-point values.
+///
+/// \headerfile 
+///
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
+///
+/// \param __a
+///A single-precision floating-point value used to initialize bits 
[255:224]
+///of the result.
+/// \param __b
+///A single-precision floating-point value used to initialize bits 
[223:192]
+///of the result.
+/// \param __c
+///A single-precision floating-point value used to initialize bits 
[191:160]
+///of the result.
+/// \param __d
+///A single-precision floating-point value used to initialize bits 
[159:128]
+///of the result.
+/// \param __e
+///A single-precision floating-point value used to initialize bits [127:96]
+///of the result.
+/// \param __f
+///A single-precision floating-point value used to initialize bits [95:64]
+///of the result.
+/// \param __g
+///A single-precision floating-point value used to initialize bits [63:32]
+///of the result.
+/// \param __h
+///A single-precision floating-point value used to initialize bits [31:0]
+///of the result.
+/// \returns An initialized 256-bit floating-point vector of [8 x float].
 static __inline __m256 __DEFAULT_FN_ATTRS
 _mm256_set_ps(float __a, float __b, float __c, float __d,
   float __e, float __f, float __g, float __h)
@@ -2546,6 +2599,31 @@ _mm256_set_ps(float __a, float __b, floa
   return (__m256){ __h, __g, __f, __e, __d, __c, __b, __a };
 }
 
+/// \brief Constructs a 256-bit integer vector initialized with the specified
+///32-bit integral values.
+///
+/// \headerfile 
+///
+/// This intrinsic is a utility function and does not correspond to a specific
+///instruction.
+///
+/// \param __i0
+///A 32-bit integral value used to initialize bits [255:224] of the result.
+/// \param __i1
+///A 32-bit integral value used to initialize bits [223:192] of the result.
+/// \param __i2
+///A 32-bit integral value used to initialize bits [191:160] of the result.
+/// \param __i3
+///A 32-bit integral value used to initialize bits [159:128] of the result.
+/// \param __i4
+///A 32-bit integral value used to initialize bits [127:96] of the result.
+/// \param __i5
+///A 32-bit integral value used to initialize bits [95:64] of the result.
+/// \param __i6
+///A 32-bit integral value used to initialize bits [63:32] of the result.
+/// \param __i7
+///A 32-bit integral value used to initialize bits [31:0] of the result.
+/// \returns An initialized 256-bit integer vector.
 static __inline __m256i __DEFAULT_FN_ATTRS
 _mm256_set_epi32(int __i0, int __i1, int __i2, int __i3,
  int __i4, int __i5, int __i6, int __i7)
@@ -2553,6 +2631,47 @@ _mm256_set_epi32(int __i0, int __i1, 

[libcxx] r286333 - [CMake] Check runtimes subdir when looking for libcxxabi

2016-11-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Nov  8 21:22:28 2016
New Revision: 286333

URL: http://llvm.org/viewvc/llvm-project?rev=286333=rev
Log:
[CMake] Check runtimes subdir when looking for libcxxabi

The runtimes subdir is the new location for runtimes, we should
include it when looking for libcxxabi headers.

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

Modified:
libcxx/trunk/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=286333=286332=286333=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Nov  8 21:22:28 2016
@@ -101,10 +101,17 @@ set_property(CACHE LIBCXX_CXX_ABI PROPER
 
 # Setup the default options if LIBCXX_CXX_ABI is not specified.
 if (NOT LIBCXX_CXX_ABI)
+  find_path(
+LIBCXX_LIBCXXABI_INCLUDES_INTERNAL
+cxxabi.h
+PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxxabi/include
+  ${LLVM_MAIN_SRC_DIR}/runtimes/libcxxabi/include
+NO_DEFAULT_PATH
+  )
   if (NOT DEFINED LIBCXX_STANDALONE_BUILD AND
-  IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
+  IS_DIRECTORY "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
-set(LIBCXX_CXX_ABI_INCLUDE_PATHS 
"${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_LIBCXXABI_INCLUDES_INTERNAL}")
 set(LIBCXX_CXX_ABI_INTREE 1)
   else()
 set(LIBCXX_CXX_ABI_LIBNAME "none")


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


[libcxxabi] r286332 - [CMake] Check runtimes subdir when looking for libcxx and libuwind

2016-11-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Nov  8 21:22:19 2016
New Revision: 286332

URL: http://llvm.org/viewvc/llvm-project?rev=286332=rev
Log:
[CMake] Check runtimes subdir when looking for libcxx and libuwind

The runtimes subdir is the new location for runtimes, we should
include it when looking for libcxx and libunwind headers.

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

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=286332=286331=286332=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Tue Nov  8 21:22:19 2016
@@ -140,7 +140,10 @@ endif()
 if (LLVM_EXTERNAL_LIBCXX_SOURCE_DIR)
   set(LIBCXXABI_LIBCXX_SRC_DIR ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR})
 else()
-  set(LIBCXXABI_LIBCXX_SRC_DIR ${LLVM_MAIN_SRC_DIR}/projects/libcxx)
+  set(LIBCXXABI_LIBCXX_SRC_DIR
+"${LLVM_MAIN_SRC_DIR}/projects/libcxx"
+"${LLVM_MAIN_SRC_DIR}/runtimes/libcxx"
+)
 endif()
 
 find_path(
@@ -380,6 +383,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
   ${LIBCXXABI_LIBUNWIND_PATH}/include
   ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
   ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
+  ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/include
 NO_DEFAULT_PATH
   )
 
@@ -389,6 +393,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_
 PATHS ${LIBCXXABI_LIBUNWIND_PATH}/src/
   ${LIBCXXABI_LIBUNWIND_INCLUDES}/../src/
   ${LLVM_MAIN_SRC_DIR}/projects/libunwind/src/
+  ${LLVM_MAIN_SRC_DIR}/runtimes/libunwind/src/
 NO_DEFAULT_PATH
   )
 


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


[PATCH] D26150: [libc++abi] Fix test_exception_storage_nodynmem on MacOS

2016-11-08 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

The test is too implementation-specific, and trying to override a function like 
`calloc` makes it fragile. Unfortunately, I didn't find a better way to test 
the library's behavior in case of memory exhaustion, but now I believe that 
this test doesn't add any significant value. I'm going to remove it if no one 
objects.


https://reviews.llvm.org/D26150



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


r286331 - [index] Fix issue with protocol name locations in conformance list of an ObjC class when they come from a typedef.

2016-11-08 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Nov  8 20:47:07 2016
New Revision: 286331

URL: http://llvm.org/viewvc/llvm-project?rev=286331=rev
Log:
[index] Fix issue with protocol name locations in conformance list of an ObjC 
class when they come from a typedef.

The ObjC class protocol list assumes there is an associated location for each 
protocol but no location is provided
when the protocol list comes from a typedef, and we end up with a buffer 
overflow when trying to get locations for the protocol names.

Fixes crash of rdar://28980278.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Index/Core/index-source.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=286331=286330=286331=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Nov  8 20:47:07 2016
@@ -7470,6 +7470,7 @@ public:
SourceRange SuperTypeArgsRange);
   
   void ActOnTypedefedProtocols(SmallVectorImpl ,
+   SmallVectorImpl ,
IdentifierInfo *SuperName,
SourceLocation SuperLoc);
 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=286331=286330=286331=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue Nov  8 20:47:07 2016
@@ -369,7 +369,8 @@ Decl *Parser::ParseObjCAtInterfaceDeclar
   }
 
   if (Tok.isNot(tok::less))
-Actions.ActOnTypedefedProtocols(protocols, superClassId, superClassLoc);
+Actions.ActOnTypedefedProtocols(protocols, protocolLocs,
+superClassId, superClassLoc);
   
   Decl *ClsType =
 Actions.ActOnStartClassInterface(getCurScope(), AtLoc, nameId, nameLoc, 

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=286331=286330=286331=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Nov  8 20:47:07 2016
@@ -1028,6 +1028,7 @@ ActOnStartClassInterface(Scope *S, Sourc
 /// typedef'ed use for a qualified super class and adds them to the list
 /// of the protocols.
 void Sema::ActOnTypedefedProtocols(SmallVectorImpl ,
+  SmallVectorImpl 
,
IdentifierInfo *SuperName,
SourceLocation SuperLoc) {
   if (!SuperName)
@@ -1040,8 +1041,14 @@ void Sema::ActOnTypedefedProtocols(Small
   if (const TypedefNameDecl *TDecl = dyn_cast_or_null(IDecl)) 
{
 QualType T = TDecl->getUnderlyingType();
 if (T->isObjCObjectType())
-  if (const ObjCObjectType *OPT = T->getAs())
+  if (const ObjCObjectType *OPT = T->getAs()) {
 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
+// FIXME: Consider whether this should be an invalid loc since the loc
+// is not actually pointing to a protocol name reference but to the
+// typedef reference. Note that the base class name loc is also 
pointing
+// at the typedef.
+ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
+  }
   }
 }
 

Modified: cfe/trunk/test/Index/Core/index-source.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.m?rev=286331=286330=286331=diff
==
--- cfe/trunk/test/Index/Core/index-source.m (original)
+++ cfe/trunk/test/Index/Core/index-source.m Tue Nov  8 20:47:07 2016
@@ -129,3 +129,23 @@ extern int setjmp(jmp_buf);
 // CHECK: [[@LINE+1]]:12 | extension/ObjC |  |  |  
| Decl | rel: 0
 @interface NonExistent()
 @end
+
+@interface MyGenCls : Base
+@end
+
+@protocol MyEnumerating
+@end
+
+// CHECK: [[@LINE+4]]:41 | type-alias/C | MyEnumerator | 
c:index-source.m@T@MyEnumerator |  | Def | rel: 0
+// CHECK: [[@LINE+3]]:26 | protocol/ObjC | MyEnumerating | 
c:objc(pl)MyEnumerating |  | Ref | rel: 0
+// CHECK: [[@LINE+2]]:9 | class/ObjC | MyGenCls | c:objc(cs)MyGenCls | 
_OBJC_CLASS_$_MyGenCls | Ref | rel: 0
+// CHECK: [[@LINE+1]]:18 | class/ObjC | Base | c:objc(cs)Base | 
_OBJC_CLASS_$_Base | Ref | rel: 0
+typedef MyGenCls MyEnumerator;
+
+// CHECK: [[@LINE+5]]:12 | class/ObjC | PermanentEnumerator | 
c:objc(cs)PermanentEnumerator | _OBJC_CLASS_$_PermanentEnumerator | Decl | rel: 0
+// CHECK: [[@LINE+4]]:34 | class/ObjC | MyGenCls | c:objc(cs)MyGenCls | 
_OBJC_CLASS_$_MyGenCls | Ref,RelBase | rel: 1
+// CHECK-NEXT: RelBase | PermanentEnumerator | 

[PATCH] D26109: Warn when 'assume_nonnull' infers nullability within an array.

2016-11-08 Thread Jordan Rose via cfe-commits
jordan_rose added a dependency: D26108: Add 
-Wnullability-completeness-on-arrays..
jordan_rose added a comment.

Depends on https://reviews.llvm.org/D26108 too, for the tests to apply cleanly.


Repository:
  rL LLVM

https://reviews.llvm.org/D26109



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


[PATCH] D26227: Don't require nullability on 'va_list'.

2016-11-08 Thread Jordan Rose via cfe-commits
jordan_rose added a dependency: D26108: Add 
-Wnullability-completeness-on-arrays..
jordan_rose added a comment.

Depends on https://reviews.llvm.org/D26108 too (for the tests to apply cleanly).


Repository:
  rL LLVM

https://reviews.llvm.org/D26227



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


[PATCH] D26108: Add -Wnullability-completeness-on-arrays.

2016-11-08 Thread Jordan Rose via cfe-commits
jordan_rose added a comment.

It works fine for me, though note the "depends on 
https://reviews.llvm.org/D25850;. The other patches in the series do seem to 
have been thrown off by https://reviews.llvm.org/D26226 landing first, though, 
so I'll update those.


Repository:
  rL LLVM

https://reviews.llvm.org/D26108



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


[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-08 Thread Derek Schuff via cfe-commits
dschuff added a comment.

Yeah, I don't mean for this to be the final word; mostly this just matches 
asm.js.
I do agree with you that the unixy stuff goes with the emscripten environment 
rather than wasm per se. I had thought we might define emscripten as an "OS" 
(i.e. the third or maybe even 4th part of the triple) in LLVM, because 
currently it affects not just defines but also things like emscripten exception 
handling (which we currently use a backend flag for).


https://reviews.llvm.org/D26431



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


[PATCH] D26435: Use unique_ptr for cached tokens for default arguments in C++.

2016-11-08 Thread David Tarditi via cfe-commits
dtarditi created this revision.
dtarditi added a subscriber: cfe-commits.

This changes pointers to cached tokens for default arguments in C++ from raw 
pointers to unique_ptrs.  There was a fixme in the code where the cached tokens 
are created  about using a smart pointer.

The change is straightforward, though I did have to track down and fix a memory 
corruption caused by the change.  memcpy was being used to copy parameter 
information.  This duplicated the unique_ptr, which led to the cached token 
buffer being deleted prematurely.


https://reviews.llvm.org/D26435

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseCXXInlineMethods.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDeclCXX.cpp

Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -395,17 +395,15 @@
++argIdx) {
 ParmVarDecl *Param = cast(chunk.Fun.Params[argIdx].Param);
 if (Param->hasUnparsedDefaultArg()) {
-  CachedTokens *Toks = chunk.Fun.Params[argIdx].DefaultArgTokens;
+  std::unique_ptr Toks = std::move(chunk.Fun.Params[argIdx].DefaultArgTokens);
   SourceRange SR;
   if (Toks->size() > 1)
 SR = SourceRange((*Toks)[1].getLocation(),
  Toks->back().getLocation());
   else
 SR = UnparsedDefaultArgLocs[Param];
   Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
 << SR;
-  delete Toks;
-  chunk.Fun.Params[argIdx].DefaultArgTokens = nullptr;
 } else if (Param->getDefaultArg()) {
   Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
 << Param->getDefaultArg()->getSourceRange();
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -229,7 +229,8 @@
   I.Fun.Params = new DeclaratorChunk::ParamInfo[NumParams];
   I.Fun.DeleteParams = true;
 }
-memcpy(I.Fun.Params, Params, sizeof(Params[0]) * NumParams);
+for (unsigned i = 0; i < NumParams; i++)
+  I.Fun.Params[i] = std::move(Params[i]);
   }
 
   // Check what exception specification information we should actually store.
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2039,7 +2039,7 @@
 LateMethod->DefaultArgs.reserve(FTI.NumParams);
 for (unsigned ParamIdx = 0; ParamIdx < FTI.NumParams; ++ParamIdx)
   LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
-FTI.Params[ParamIdx].Param, FTI.Params[ParamIdx].DefaultArgTokens));
+FTI.Params[ParamIdx].Param, std::move(FTI.Params[ParamIdx].DefaultArgTokens)));
   }
 }
 
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -6021,7 +6021,7 @@
 
 // DefArgToks is used when the parsing of default arguments needs
 // to be delayed.
-CachedTokens *DefArgToks = nullptr;
+std::unique_ptr DefArgToks;
 
 // If no parameter was specified, verify that *something* was specified,
 // otherwise we have a missing type and identifier.
@@ -6057,13 +6057,11 @@
   // If we're inside a class definition, cache the tokens
   // corresponding to the default argument. We'll actually parse
   // them when we see the end of the class definition.
-  // FIXME: Can we use a smart pointer for Toks?
-  DefArgToks = new CachedTokens;
+  DefArgToks.reset(new CachedTokens);
 
   SourceLocation ArgStartLoc = NextToken().getLocation();
   if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
-delete DefArgToks;
-DefArgToks = nullptr;
+DefArgToks.release();
 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
   } else {
 Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
@@ -6099,7 +6097,7 @@
 
   ParamInfo.push_back(DeclaratorChunk::ParamInfo(ParmII,
   ParmDeclarator.getIdentifierLoc(), 
-  Param, DefArgToks));
+  Param, std::move(DefArgToks)));
 }
 
 if (TryConsumeToken(tok::ellipsis, EllipsisLoc)) {
Index: lib/Parse/ParseCXXInlineMethods.cpp
===
--- lib/Parse/ParseCXXInlineMethods.cpp
+++ lib/Parse/ParseCXXInlineMethods.cpp
@@ -319,7 +319,8 @@
 // Introduce the parameter into scope.
 bool HasUnparsed = Param->hasUnparsedDefaultArg();
 Actions.ActOnDelayedCXXMethodParameter(getCurScope(), Param);
-if 

[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-08 Thread Jacob Gravelle via cfe-commits
jgravelle-google added a comment.

I think you're right, it's the Emscripten embedding that's unixy, therefore 
Emscripten should be responsible for telling clang to be unixy.

To play devil's advocate, it might be advantageous for all compile-to-wasm code 
to assume a common environment, and unix is a reasonable thing to arbitrarily 
standardize on. But it's probably more advantageous to not decide that at this 
level.

Double-alternatively it might make sense to have a `wasm32-unknown-emscripten` 
triple, and let that determine whether we're unixy or not in clang.


https://reviews.llvm.org/D26431



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


[PATCH] D26423: [clang-move] Support template class.

2016-11-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 77292.
hokein marked 3 inline comments as done.
hokein added a comment.

Add comments.


https://reviews.llvm.org/D26423

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/template_class_test.cpp
  test/clang-move/Inputs/template_class_test.h
  test/clang-move/move-template-class.cpp

Index: test/clang-move/move-template-class.cpp
===
--- /dev/null
+++ test/clang-move/move-template-class.cpp
@@ -0,0 +1,86 @@
+// RUN: mkdir -p %T/move-template-class
+// RUN: cp %S/Inputs/template_class_test*  %T/move-template-class
+// RUN: cd %T/move-template-class
+// RUN: clang-move -names="A,B" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp --
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s
+//
+// RUN: cp %S/Inputs/template_class_test*  %T/move-template-class
+// RUN: clang-move -names="A" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp --
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE2 %s
+//
+//
+// CHECK-OLD-TEST-EMPTY: {{^}}{{$}}
+//
+// CHECK-NEW-TEST-H-CASE1: #ifndef TEMPLATE_CLASS_TEST_H // comment 1
+// CHECK-NEW-TEST-H-CASE1: #define TEMPLATE_CLASS_TEST_H
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: class A {
+// CHECK-NEW-TEST-H-CASE1:  public:
+// CHECK-NEW-TEST-H-CASE1:   void f();
+// CHECK-NEW-TEST-H-CASE1:   void g();
+// CHECK-NEW-TEST-H-CASE1:   template  void h();
+// CHECK-NEW-TEST-H-CASE1:   template  void k();
+// CHECK-NEW-TEST-H-CASE1:   static int b;
+// CHECK-NEW-TEST-H-CASE1:   static int c;
+// CHECK-NEW-TEST-H-CASE1: };
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: void A::f() {}
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: void A::h() {}
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: int A::b = 2;
+// CHECK-NEW-TEST-H-CASE1: class B {
+// CHECK-NEW-TEST-H-CASE1:  public:
+// CHECK-NEW-TEST-H-CASE1:   void f();
+// CHECK-NEW-TEST-H-CASE1: };
+// CHECK-NEW-TEST-H-CASE1: #endif // TEMPLATE_CLASS_TEST_H
+//
+// CHECK-NEW-TEST-CPP-CASE1: #include "{{.*}}new_template_class_test.h"
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: void A::g() {}
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: void A::k() {}
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: int A::c = 2;
+// CHECK-NEW-TEST-CPP-CASE1: void B::f() {}
+//
+// CHECK-OLD-TEST-H-CASE2: #ifndef TEMPLATE_CLASS_TEST_H // comment 1
+// CHECK-OLD-TEST-H-CASE2: #define TEMPLATE_CLASS_TEST_H
+// CHECK-OLD-TEST-H-CASE2: class B {
+// CHECK-OLD-TEST-H-CASE2:  public:
+// CHECK-OLD-TEST-H-CASE2:   void f();
+// CHECK-OLD-TEST-H-CASE2: };
+// CHECK-OLD-TEST-H-CASE2: #endif // TEMPLATE_CLASS_TEST_H
+//
+// CHECK-OLD-TEST-CPP-CASE2: #include "template_class_test.h"
+// CHECK-OLD-TEST-CPP-CASE2:  void B::f() {}
+//
+// CHECK-NEW-TEST-H-CASE2: #ifndef {{.*}}NEW_TEMPLATE_CLASS_TEST_H
+// CHECK-NEW-TEST-H-CASE2: #define {{.*}}NEW_TEMPLATE_CLASS_TEST_H
+// CHECK-NEW-TEST-H-CASE2: template 
+// CHECK-NEW-TEST-H-CASE2: class A {
+// CHECK-NEW-TEST-H-CASE2:  public:
+// CHECK-NEW-TEST-H-CASE2:   void f();
+// CHECK-NEW-TEST-H-CASE2:   void g();
+// CHECK-NEW-TEST-H-CASE2:   template  void h();
+// CHECK-NEW-TEST-H-CASE2:   template  void k();
+// CHECK-NEW-TEST-H-CASE2:   static int b;
+// CHECK-NEW-TEST-H-CASE2:   static int c;
+// CHECK-NEW-TEST-H-CASE2: };
+// CHECK-NEW-TEST-H-CASE2: template  void A::f() {}
+// CHECK-NEW-TEST-H-CASE2: template  template  void A::h() {}
+// CHECK-NEW-TEST-H-CASE2: template  int 

[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-08 Thread Dan Gohman via cfe-commits
sunfish added a comment.

The other main way we could provide __unix et al would be to add them to 
tools/shared.py in Emscripten (see the comment "wasm target does not 
automatically define emscripten stuff"). It's not clear to me whether that's 
better than adding the macros to clang itself or not.

Currently Unixy-like functionality is provided by Emscripten facilities, and 
one could think of (hypothetical future) non-Emscripten clang as targeting more 
of the bare metal of WebAssembly which isn't inherently Unixy. Thoughts?

However, I'm also open to just adding it to clang for now and re-evaluating 
later, which we can do since we don't yet have a stable ABI.


https://reviews.llvm.org/D26431



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


r286322 - Emit debug info for global constants whose address is taken exactly once.

2016-11-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Tue Nov  8 18:42:03 2016
New Revision: 286322

URL: http://llvm.org/viewvc/llvm-project?rev=286322=rev
Log:
Emit debug info for global constants whose address is taken exactly once.

Add a check to the DeclCache before emitting debug info for a
GlobalVariable a second time and just attach the previsously created one to it.



Added:
cfe/trunk/test/CodeGen/debug-info-global-constant.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=286322=286321=286322=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Nov  8 18:42:03 2016
@@ -3675,6 +3675,13 @@ void CGDebugInfo::EmitGlobalVariable(llv
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   if (D->hasAttr())
 return;
+
+  // If we already created a DIGlobalVariable for this declaration, just attach
+  // it to the llvm::GlobalVariable.
+  auto Cached = DeclCache.find(D->getCanonicalDecl());
+  if (Cached != DeclCache.end())
+return Var->addDebugInfo(cast(Cached->second));
+
   // Create global variable debug descriptor.
   llvm::DIFile *Unit = nullptr;
   llvm::DIScope *DContext = nullptr;

Added: cfe/trunk/test/CodeGen/debug-info-global-constant.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-global-constant.c?rev=286322=auto
==
--- cfe/trunk/test/CodeGen/debug-info-global-constant.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-global-constant.c Tue Nov  8 18:42:03 2016
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone \
+// RUN:  -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// Debug info for a global constant whose address is taken should be emitted
+// exactly once.
+
+// CHECK: @i = internal constant i32 1, align 4, !dbg ![[I:[0-9]+]]
+// CHECK: ![[I]] = distinct !DIGlobalVariable(name: "i",
+// CHECK-SAME:expr: ![[EXPR:[0-9]+]]
+// CHECK: !DICompileUnit({{.*}}globals: ![[GLOBALS:[0-9]+]])
+// CHECK: ![[GLOBALS]] = !{![[I]]}
+// CHECK: ![[EXPR]] = !DIExpression(DW_OP_constu, 1, DW_OP_stack_value)
+static const int i = 1;
+
+void g(const int *, int);
+void f() {
+  g(, i);
+}


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


[PATCH] D26071: [CodeCompletion] Show block invocation result for block property setters

2016-11-08 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM.

Manman


Repository:
  rL LLVM

https://reviews.llvm.org/D26071



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


[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-08 Thread Jacob Gravelle via cfe-commits
jgravelle-google added a comment.

For the emscripten testsuite, specifically test_zlib relies on `#ifdef 
__unix__` to `#include `, which it needs. The rest of the unistd 
tests don't actually care. So we could make that test pass by explicitly adding 
a define for __unix__ for it, but I figure it would be better to have things as 
similar as possible between wasm and asmjs.


https://reviews.llvm.org/D26431



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

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

I also don't understand the use case for turning off only some checks for 
third-party headers. Either you care about third-party stuff or not, why only 
switch off certain checks?


https://reviews.llvm.org/D26418



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


[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-08 Thread Dan Gohman via cfe-commits
sunfish added a comment.

When adding new predefined macros, please also add the new macros to 
test/Preprocessor/init.c (and remove negative tests that no longer apply).

Also though, I'd also like to understand this a little more. Even with 
emulation, there will be limits to how Unixy a Web environment could be (though 
a non-Web environment could potentially do more). Which tests start passing 
with this?


https://reviews.llvm.org/D26431



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


[PATCH] D26431: [WebAssembly] Define __unix__ as part of the wasm target

2016-11-08 Thread Jacob Gravelle via cfe-commits
jgravelle-google created this revision.
jgravelle-google added reviewers: dschuff, sunfish.
jgravelle-google added a subscriber: cfe-commits.
Herald added a subscriber: jfb.

Unix is a convenient common denominator for embeddings to implement
syscalls for. This makes it explicit that wasm is unix-y


https://reviews.llvm.org/D26431

Files:
  lib/Basic/Targets.cpp


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -856,6 +856,8 @@
 // Follow g++ convention and predefine _GNU_SOURCE for C++.
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
+
+DefineStd(Builder, "unix", Opts);
   }
 
   // As an optimization, group static init code together in a section.


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -856,6 +856,8 @@
 // Follow g++ convention and predefine _GNU_SOURCE for C++.
 if (Opts.CPlusPlus)
   Builder.defineMacro("_GNU_SOURCE");
+
+DefineStd(Builder, "unix", Opts);
   }
 
   // As an optimization, group static init code together in a section.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286313 - [CUDA] Use only the GVALinkage on function definitions.

2016-11-08 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Tue Nov  8 17:45:51 2016
New Revision: 286313

URL: http://llvm.org/viewvc/llvm-project?rev=286313=rev
Log:
[CUDA] Use only the GVALinkage on function definitions.

Summary:
Previously we'd look at the GVALinkage of whatever FunctionDecl you
happened to be calling.

This is not right.  In the absence of the gnu_inline attribute, to be
handled separately, the function definition determines the function's
linkage.  So we need to wait until we get a def before we can know
whether something is known-emitted.

Reviewers: tra

Subscribers: cfe-commits, rsmith

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

Added:
cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
Modified:
cfe/trunk/lib/Sema/SemaCUDA.cpp

Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=286313=286312=286313=diff
==
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Tue Nov  8 17:45:51 2016
@@ -577,8 +577,22 @@ static bool IsKnownEmitted(Sema , Func
   (T == Sema::CFT_Device || T == Sema::CFT_Global))
 return false;
 
-  // Externally-visible and similar functions are always emitted.
-  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
+  // Check whether this function is externally visible -- if so, it's
+  // known-emitted.
+  //
+  // We have to check the GVA linkage of the function's *definition* -- if we
+  // only have a declaration, we don't know whether or not the function will be
+  // emitted, because (say) the definition could include "inline".
+  FunctionDecl *Def = FD->getDefinition();
+
+  // We may currently be parsing the body of FD, in which case
+  // FD->getDefinition() will be null, but we still want to treat FD as though
+  // it's a definition.
+  if (!Def && FD->willHaveBody())
+Def = FD;
+
+  if (Def &&
+  
!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of

Added: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu?rev=286313=auto
==
--- cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu (added)
+++ cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu Tue Nov  8 17:45:51 2016
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+#ifndef __CUDA_ARCH__
+// expected-no-diagnostics
+#endif
+
+// When compiling for device, foo()'s call to host_fn() is an error, because
+// foo() is known-emitted.
+//
+// The trickiness here comes from the fact that the FunctionDecl bar() sees
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()
+// as known-emitted when we see the call from bar() to foo(), which would
+// prevent us from emitting an error for foo()'s call to host_fn() when we
+// eventually see it.
+
+void host_fn() {}
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{declared here}}
+#endif
+
+__host__ __device__ void foo();
+__device__ void bar() {
+  foo();
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{called by 'bar'}}
+#endif
+}
+inline __host__ __device__ void foo() {
+  host_fn();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+}
+
+// This is similar to the above, except there's no error here.  This code used
+// to trip an assertion due to us noticing, when emitting the definition of
+// boom(), that T::operator S() was (incorrectly) considered a priori
+// known-emitted.
+struct S {};
+struct T {
+  __device__ operator S() const;
+};
+__device__ inline T::operator S() const { return S(); }
+
+__device__ T t;
+__device__ void boom() {
+  S s = t;
+}


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


[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.

2016-11-08 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
jlebar marked 2 inline comments as done.
Closed by commit rL286313: [CUDA] Use only the GVALinkage on function 
definitions. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D26268?vs=76808=77280#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26268

Files:
  cfe/trunk/lib/Sema/SemaCUDA.cpp
  cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu


Index: cfe/trunk/lib/Sema/SemaCUDA.cpp
===
--- cfe/trunk/lib/Sema/SemaCUDA.cpp
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp
@@ -577,8 +577,22 @@
   (T == Sema::CFT_Device || T == Sema::CFT_Global))
 return false;
 
-  // Externally-visible and similar functions are always emitted.
-  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
+  // Check whether this function is externally visible -- if so, it's
+  // known-emitted.
+  //
+  // We have to check the GVA linkage of the function's *definition* -- if we
+  // only have a declaration, we don't know whether or not the function will be
+  // emitted, because (say) the definition could include "inline".
+  FunctionDecl *Def = FD->getDefinition();
+
+  // We may currently be parsing the body of FD, in which case
+  // FD->getDefinition() will be null, but we still want to treat FD as though
+  // it's a definition.
+  if (!Def && FD->willHaveBody())
+Def = FD;
+
+  if (Def &&
+  
!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of
Index: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
===
--- cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
+++ cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+#ifndef __CUDA_ARCH__
+// expected-no-diagnostics
+#endif
+
+// When compiling for device, foo()'s call to host_fn() is an error, because
+// foo() is known-emitted.
+//
+// The trickiness here comes from the fact that the FunctionDecl bar() sees
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()
+// as known-emitted when we see the call from bar() to foo(), which would
+// prevent us from emitting an error for foo()'s call to host_fn() when we
+// eventually see it.
+
+void host_fn() {}
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{declared here}}
+#endif
+
+__host__ __device__ void foo();
+__device__ void bar() {
+  foo();
+#ifdef __CUDA_ARCH__
+  // expected-note@-2 {{called by 'bar'}}
+#endif
+}
+inline __host__ __device__ void foo() {
+  host_fn();
+#ifdef __CUDA_ARCH__
+  // expected-error@-2 {{reference to __host__ function}}
+#endif
+}
+
+// This is similar to the above, except there's no error here.  This code used
+// to trip an assertion due to us noticing, when emitting the definition of
+// boom(), that T::operator S() was (incorrectly) considered a priori
+// known-emitted.
+struct S {};
+struct T {
+  __device__ operator S() const;
+};
+__device__ inline T::operator S() const { return S(); }
+
+__device__ T t;
+__device__ void boom() {
+  S s = t;
+}


Index: cfe/trunk/lib/Sema/SemaCUDA.cpp
===
--- cfe/trunk/lib/Sema/SemaCUDA.cpp
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp
@@ -577,8 +577,22 @@
   (T == Sema::CFT_Device || T == Sema::CFT_Global))
 return false;
 
-  // Externally-visible and similar functions are always emitted.
-  if (!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(FD)))
+  // Check whether this function is externally visible -- if so, it's
+  // known-emitted.
+  //
+  // We have to check the GVA linkage of the function's *definition* -- if we
+  // only have a declaration, we don't know whether or not the function will be
+  // emitted, because (say) the definition could include "inline".
+  FunctionDecl *Def = FD->getDefinition();
+
+  // We may currently be parsing the body of FD, in which case
+  // FD->getDefinition() will be null, but we still want to treat FD as though
+  // it's a definition.
+  if (!Def && FD->willHaveBody())
+Def = FD;
+
+  if (Def &&
+  !isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
 return true;
 
   // Otherwise, the function is known-emitted if it's in our set of
Index: cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
===
--- cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
+++ cfe/trunk/test/SemaCUDA/add-inline-in-definition.cu
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only 

[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.

2016-11-08 Thread Justin Lebar via cfe-commits
jlebar marked 2 inline comments as done.
jlebar added a comment.

Thank you for the review!  Submitting...




Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:13-14
+//
+// The trickiness here comes from the fact that the FunctionDecl bar() sees for
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()

tra wrote:
> "bar() sees for foo()" does not sound right. Did you mean "bar() sees *that* 
> foo()"?
Yes, this is a mistake, thanks!



Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:15
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()
+// as known-emitted, which would prevent us from emitting an error for foo()'s

tra wrote:
> Extra whitespace.
We seem to be pretty evenly-split wrt one or two spaces here in llvm, agreed 
irl it's nbd.


https://reviews.llvm.org/D26268



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


[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel

2016-11-08 Thread Kareem Khazem via cfe-commits
khazem updated this revision to Diff 77277.
khazem added a comment.

If a double-lock or double-release is detected, path notes are now emitted on 
the _first_ lock or release event. Also updated the tests to check for these 
notes.


https://reviews.llvm.org/D26340

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp
  test/Analysis/spinlock_correct.c
  test/Analysis/spinlock_double_lock.c
  test/Analysis/spinlock_double_release.c

Index: test/Analysis/spinlock_double_release.c
===
--- /dev/null
+++ test/Analysis/spinlock_double_release.c
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -analyze -analyzer-output=text -analyzer-checker=magenta.SpinLock -verify %s
+
+typedef unsigned int lock_t;
+
+typedef struct S {
+  int a;
+  lock_t l;
+} S_t;
+
+static S_t st;
+
+void spin_lock(lock_t *lock);
+void spin_unlock(lock_t *lock);
+int bar();
+
+void bar1(lock_t *y) {
+  spin_unlock(y); // expected-note {{First unlocked here}}
+}
+
+void bar2(lock_t *x) {
+  spin_unlock(x); // expected-warning{{Execution path found where spinlock is unlocked twice in a row}}
+  // expected-note@-1 0+ {{Execution path found where spinlock is unlocked twice in a row}}
+}
+
+int foo() {
+  int a = bar();
+  if (a > 0) {  // expected-note {{Assuming 'a' is > 0}} \
+// expected-note {{Taking true branch}}
+spin_lock();
+bar1(); // expected-note {{Calling 'bar1'}} \
+expected-note {{Returning from 'bar1'}}
+  }
+
+  lock_t *c = 
+  bar2(c);  // expected-note {{Calling 'bar2'}}
+  return 0;
+}
+
Index: test/Analysis/spinlock_double_lock.c
===
--- /dev/null
+++ test/Analysis/spinlock_double_lock.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -analyzer-output=text -verify %s
+
+typedef unsigned int lock_t;
+
+static lock_t l;
+
+void spin_lock(lock_t *lock);
+void spin_unlock(lock_t *lock);
+int bar();
+
+int foo() {
+  int a = bar();
+  if (a > 0) // expected-note{{Assuming 'a' is > 0}} \
+expected-note{{Taking true branch}}
+
+spin_lock(); // expected-note{{First locked here}}
+  if (a > 10) // expected-note{{Assuming 'a' is > 10}} \
+ expected-note{{Taking true branch}}
+
+spin_lock(); // expected-warning{{Execution path found where spinlock is locked twice in a row}}
+// expected-note@-1 0+ {{Execution path found where spinlock is locked twice in a row}}
+
+
+  return 0;
+}
+
Index: test/Analysis/spinlock_correct.c
===
--- /dev/null
+++ test/Analysis/spinlock_correct.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s
+// expected-no-diagnostics
+
+typedef unsigned int lock_t;
+
+static lock_t l;
+
+void spin_lock(lock_t *lock);
+void spin_unlock(lock_t *lock);
+int bar();
+
+int foo() {
+  int a = bar();
+  if (a > 0) {
+spin_lock();
+  }
+
+  if (a < -10) {
+spin_lock();
+  }
+
+  if (a > 0)
+spin_unlock();
+
+  if (a < -10)
+spin_unlock();
+
+  return 0;
+}
+
Index: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp
@@ -0,0 +1,262 @@
+//== SpinLockChecker.cpp - SpinLock checker -*- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines SpinLockChecker, a check for the Magenta kernel. It
+// checks that there are no execution paths where spinlocks are locked
+// twice in a row, or unlocked twice in a row.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "llvm/ADT/SmallString.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+struct LockInfo {
+
+  enum Kind { Locked, Released } K;
+
+  LockInfo(Kind kind) : K(kind) {}
+
+  bool operator==(const LockInfo ) const { return K == LI.K; }
+
+  void Profile(llvm::FoldingSetNodeID ) const { ID.AddInteger(K); }
+
+  bool isLocked() const { return K == Locked; }
+
+  bool isReleased() const { return K == Released; }
+
+  static LockInfo getLocked() { return LockInfo(Locked); }
+
+  static LockInfo getReleased() { return LockInfo(Released); }
+
+};
+
+// When we detect a double-lock or double-release, we 

[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.

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

LGTM.




Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:13-14
+//
+// The trickiness here comes from the fact that the FunctionDecl bar() sees for
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()

"bar() sees for foo()" does not sound right. Did you mean "bar() sees *that* 
foo()"?



Comment at: clang/test/SemaCUDA/add-inline-in-definition.cu:15
+// foo() does not have the "inline" keyword, so we might incorrectly think that
+// foo() is a priori known-emitted.  This would prevent us from marking foo()
+// as known-emitted, which would prevent us from emitting an error for foo()'s

Extra whitespace.


https://reviews.llvm.org/D26268



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


[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel

2016-11-08 Thread Kareem Khazem via cfe-commits
khazem updated this revision to Diff 77275.
khazem added a comment.

The strings for Spin{Unl,L}ockFuncName and LockErrorCategory are now 
initialized when constructing a SpinLockChecker object rather than being static 
globals, in order to avoid adverse effects on startup time.

Also, the Spin*FuncName variables are now of type CallDescription. This is to 
enable pointer rather than string comparisons of the function name.


https://reviews.llvm.org/D26340

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp
  test/Analysis/spinlock_correct.c
  test/Analysis/spinlock_double_lock.c
  test/Analysis/spinlock_double_release.c

Index: test/Analysis/spinlock_double_release.c
===
--- /dev/null
+++ test/Analysis/spinlock_double_release.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s
+
+typedef unsigned int lock_t;
+
+typedef struct S {
+  int a;
+  lock_t l;
+} S_t;
+
+static S_t st;
+
+void spin_lock(lock_t *lock);
+void spin_unlock(lock_t *lock);
+int bar();
+
+void bar1(lock_t *y) {
+  spin_unlock(y);
+}
+
+void bar2(lock_t *x) {
+  spin_unlock(x); // expected-warning{{Execution path found where spinlock is unlocked twice in a row}}
+}
+
+int foo() {
+  int a = bar();
+  if (a > 0) {
+spin_lock();
+bar1();
+  }
+
+  lock_t *c = 
+  bar2(c);
+  return 0;
+}
+
Index: test/Analysis/spinlock_double_lock.c
===
--- /dev/null
+++ test/Analysis/spinlock_double_lock.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s
+
+typedef unsigned int lock_t;
+
+static lock_t l;
+
+void spin_lock(lock_t *lock);
+void spin_unlock(lock_t *lock);
+int bar();
+
+int foo() {
+  int a = bar();
+  if (a > 0)
+spin_lock();
+  if (a > 10)
+spin_lock(); // expected-warning{{Execution path found where spinlock is locked twice in a row}}
+
+  return 0;
+}
+
Index: test/Analysis/spinlock_correct.c
===
--- /dev/null
+++ test/Analysis/spinlock_correct.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=magenta.SpinLock -verify %s
+// expected-no-diagnostics
+
+typedef unsigned int lock_t;
+
+static lock_t l;
+
+void spin_lock(lock_t *lock);
+void spin_unlock(lock_t *lock);
+int bar();
+
+int foo() {
+  int a = bar();
+  if (a > 0) {
+spin_lock();
+  }
+
+  if (a < -10) {
+spin_lock();
+  }
+
+  if (a > 0)
+spin_unlock();
+
+  if (a < -10)
+spin_unlock();
+
+  return 0;
+}
+
Index: lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/SpinLockChecker.cpp
@@ -0,0 +1,187 @@
+//== SpinLockChecker.cpp - SpinLock checker -*- C++ -*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines SpinLockChecker, a check for the Magenta kernel. It
+// checks that there are no execution paths where spinlocks are locked
+// twice in a row, or unlocked twice in a row.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "llvm/ADT/SmallString.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+struct LockInfo {
+
+  enum Kind { Locked, Released } K;
+
+  LockInfo(Kind kind) : K(kind) {}
+
+  bool operator==(const LockInfo ) const { return K == LI.K; }
+
+  void Profile(llvm::FoldingSetNodeID ) const { ID.AddInteger(K); }
+
+  bool isLocked() const { return K == Locked; }
+
+  bool isReleased() const { return K == Released; }
+
+  static LockInfo getLocked() { return LockInfo(Locked); }
+
+  static LockInfo getReleased() { return LockInfo(Released); }
+
+};
+
+}
+
+/// We keep track of the locks in a map. SpinLockMap maps the
+/// memory region of a spinlock to its status (locked, released).
+/// The reason that we keep track of spinlocks as memory region is
+/// that the lock/unlock functions take lock arguments as pointers.
+REGISTER_MAP_WITH_PROGRAMSTATE(SpinLockMap, const MemRegion *, LockInfo)
+
+namespace {
+
+class SpinLockChecker : public Checker {
+
+  /// When facing a spin_unlock function call, check the record of the
+  /// corresponding lock in SpinLockMap and make sure that there are no
+  /// problems such as double unlocks.
+  void 

[PATCH] D26340: [analyzer] Add SpinLockChecker for the Magenta kernel

2016-11-08 Thread Kareem Khazem via cfe-commits
khazem added a comment.

Good to meet you too, thanks for the useful comments and pointers to helpful 
examples! I'm going to update the diff twice: the first one to address your 
first two comments, and the second one to address your last two.


https://reviews.llvm.org/D26340



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


[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-11-08 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D25403#590049, @jlebar wrote:

> Use TEST_STD_VER macro.


This is fine with me; @EricWF , @mclow.lists ?


https://reviews.llvm.org/D25403



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


[libunwind] r286308 - [CMake] Get libunwind building under LLVM/runtimes

2016-11-08 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Nov  8 17:02:49 2016
New Revision: 286308

URL: http://llvm.org/viewvc/llvm-project?rev=286308=rev
Log:
[CMake] Get libunwind building under LLVM/runtimes

The new LLVM runtimes directory requires the same conventions to be
followed across the runtime projects. These changes make libunwind
build under the runtimes subdirectory.

This patch contains the following changes:

* Rename LLVM_CONFIG to LLVM_CONFIG_PATH
* Check if compiler supports C++11 (required by libunwind)

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/cmake/config-ix.cmake

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=286308=286307=286308=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Nov  8 17:02:49 2016
@@ -13,15 +13,17 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
 
   # Rely on llvm-config.
   set(CONFIG_OUTPUT)
-  find_program(LLVM_CONFIG "llvm-config")
+  if(NOT LLVM_CONFIG_PATH)
+find_program(LLVM_CONFIG_PATH "llvm-config")
+  endif()
   if (DEFINED LLVM_PATH)
 set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
 set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
 set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
-  elseif (LLVM_CONFIG)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-set(CONFIG_COMMAND ${LLVM_CONFIG} "--includedir" "--prefix" "--src-root")
+  elseif(LLVM_CONFIG_PATH)
+message(STATUS "Found LLVM_CONFIG_PATH as ${LLVM_CONFIG_PATH}")
+set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} "--includedir" "--prefix" 
"--src-root")
 execute_process(COMMAND ${CONFIG_COMMAND}
 RESULT_VARIABLE HAD_ERROR
 OUTPUT_VARIABLE CONFIG_OUTPUT)

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=286308=286307=286308=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Tue Nov  8 17:02:49 2016
@@ -38,6 +38,11 @@ check_cxx_compiler_flag(/EHsc
 check_cxx_compiler_flag(/EHs- LIBUNWIND_HAS_NO_EHS_FLAG)
 check_cxx_compiler_flag(/EHa- LIBUNWIND_HAS_NO_EHA_FLAG)
 check_cxx_compiler_flag(/GR-  LIBUNWIND_HAS_NO_GR_FLAG)
+check_cxx_compiler_flag(-std=c++11LIBUNWIND_HAS_STD_CXX11)
+
+if(LIBUNWIND_HAS_STD_CXX11)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+endif()
 
 check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
 check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)


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


[PATCH] D26268: [CUDA] Use only the GVALinkage on function definitions.

2016-11-08 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Friendly ping


https://reviews.llvm.org/D26268



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Eric Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286307: [change-namespace] shorten namespace qualifier based 
on UsingDecl and… (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D25771?vs=77270=77272#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25771

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
  clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
@@ -67,8 +67,8 @@
 
   void replaceQualifiedSymbolInDeclContext(
   const ast_matchers::MatchFinder::MatchResult ,
-  const Decl *DeclContext, SourceLocation Start, SourceLocation End,
-  llvm::StringRef DeclName);
+  const DeclContext *DeclContext, SourceLocation Start, SourceLocation End,
+  const NamedDecl *FromDecl);
 
   void fixTypeLoc(const ast_matchers::MatchFinder::MatchResult ,
   SourceLocation Start, SourceLocation End, TypeLoc Type);
@@ -139,6 +139,12 @@
   // will be done after removing the code from the old namespace and before
   // inserting it to the new namespace.
   std::map InsertFwdDecls;
+  // Records all using declarations, which can be used to shorten namespace
+  // specifiers.
+  llvm::SmallPtrSet UsingDecls;
+  // Records all using namespace declarations, which can be used to shorten
+  // namespace specifiers.
+  llvm::SmallPtrSet UsingNamespaceDecls;
 };
 
 } // namespace change_namespace
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -189,10 +189,8 @@
 llvm::StringRef NsName) {
   DeclName = DeclName.ltrim(':');
   NsName = NsName.ltrim(':');
-  // If `DeclName` is a global variable, we prepend "::" to it if it is not in
-  // the global namespace.
   if (DeclName.find(':') == llvm::StringRef::npos)
-return NsName.empty() ? DeclName.str() : ("::" + DeclName).str();
+return DeclName;
 
   while (!DeclName.consume_front((NsName + "::").str())) {
 const auto Pos = NsName.find_last_of(':');
@@ -219,6 +217,26 @@
   return Code;
 }
 
+// Returns true if \p D is a nested DeclContext in \p Context
+bool isNestedDeclContext(const DeclContext *D, const DeclContext *Context) {
+  while (D) {
+if (D == Context)
+  return true;
+D = D->getParent();
+  }
+  return false;
+}
+
+// Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx.
+bool isDeclVisibleAtLocation(const SourceManager , const Decl *D,
+ const DeclContext *DeclCtx, SourceLocation Loc) {
+  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation());
+  Loc = SM.getSpellingLoc(Loc);
+  return SM.isBeforeInTranslationUnit(DeclLoc, Loc) &&
+ (SM.getFileID(DeclLoc) == SM.getFileID(Loc) &&
+  isNestedDeclContext(DeclCtx, D->getDeclContext()));
+}
+
 } // anonymous namespace
 
 ChangeNamespaceTool::ChangeNamespaceTool(
@@ -244,17 +262,40 @@
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
-  // Match old namespace blocks.
   std::string FullOldNs = "::" + OldNamespace;
+  // Prefix is the outer-most namespace in DiffOldNamespace. For example, if the
+  // OldNamespace is "a::b::c" and DiffOldNamespace is "b::c", then Prefix will
+  // be "a::b". Declarations in this namespace will not be visible in the new
+  // namespace. If DiffOldNamespace is empty, Prefix will be a invalid name "-".
+  llvm::SmallVector DiffOldNsSplitted;
+  llvm::StringRef(DiffOldNamespace).split(DiffOldNsSplitted, "::");
+  std::string Prefix = "-";
+  if (!DiffOldNsSplitted.empty())
+Prefix = (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) +
+  DiffOldNsSplitted.front())
+ .str();
+  auto IsInMovedNs =
+  allOf(hasAncestor(namespaceDecl(hasName(FullOldNs)).bind("ns_decl")),
+isExpansionInFileMatching(FilePattern));
+  auto IsVisibleInNewNs = anyOf(
+  IsInMovedNs, unless(hasAncestor(namespaceDecl(hasName(Prefix);
+  // Match using declarations.
+  Finder->addMatcher(
+  usingDecl(isExpansionInFileMatching(FilePattern), IsVisibleInNewNs)
+  .bind("using"),
+  this);
+  // Match using namespace declarations.
+  Finder->addMatcher(usingDirectiveDecl(isExpansionInFileMatching(FilePattern),
+IsVisibleInNewNs)
+ .bind("using_namespace"),
+ this);
+
+  

[clang-tools-extra] r286307 - [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Nov  8 16:44:17 2016
New Revision: 286307

URL: http://llvm.org/viewvc/llvm-project?rev=286307=rev
Log:
[change-namespace] shorten namespace qualifier based on UsingDecl and 
UsingDirectiveDecl.

Summary:
when replacing symbol references in moved namespaces, trying to make the replace
name as short as possible by considering UsingDecl (i.e. UsingShadow) and
UsingDirectiveDecl (i.e. using namespace decl).

Reviewers: hokein

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
clang-tools-extra/trunk/change-namespace/ChangeNamespace.h
clang-tools-extra/trunk/unittests/change-namespace/ChangeNamespaceTests.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=286307=286306=286307=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Tue Nov  8 
16:44:17 2016
@@ -189,10 +189,8 @@ std::string getShortestQualifiedNameInNa
 llvm::StringRef NsName) {
   DeclName = DeclName.ltrim(':');
   NsName = NsName.ltrim(':');
-  // If `DeclName` is a global variable, we prepend "::" to it if it is not in
-  // the global namespace.
   if (DeclName.find(':') == llvm::StringRef::npos)
-return NsName.empty() ? DeclName.str() : ("::" + DeclName).str();
+return DeclName;
 
   while (!DeclName.consume_front((NsName + "::").str())) {
 const auto Pos = NsName.find_last_of(':');
@@ -219,6 +217,26 @@ std::string wrapCodeInNamespace(StringRe
   return Code;
 }
 
+// Returns true if \p D is a nested DeclContext in \p Context
+bool isNestedDeclContext(const DeclContext *D, const DeclContext *Context) {
+  while (D) {
+if (D == Context)
+  return true;
+D = D->getParent();
+  }
+  return false;
+}
+
+// Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx.
+bool isDeclVisibleAtLocation(const SourceManager , const Decl *D,
+ const DeclContext *DeclCtx, SourceLocation Loc) {
+  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation());
+  Loc = SM.getSpellingLoc(Loc);
+  return SM.isBeforeInTranslationUnit(DeclLoc, Loc) &&
+ (SM.getFileID(DeclLoc) == SM.getFileID(Loc) &&
+  isNestedDeclContext(DeclCtx, D->getDeclContext()));
+}
+
 } // anonymous namespace
 
 ChangeNamespaceTool::ChangeNamespaceTool(
@@ -244,17 +262,40 @@ ChangeNamespaceTool::ChangeNamespaceTool
 }
 
 void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
-  // Match old namespace blocks.
   std::string FullOldNs = "::" + OldNamespace;
+  // Prefix is the outer-most namespace in DiffOldNamespace. For example, if 
the
+  // OldNamespace is "a::b::c" and DiffOldNamespace is "b::c", then Prefix will
+  // be "a::b". Declarations in this namespace will not be visible in the new
+  // namespace. If DiffOldNamespace is empty, Prefix will be a invalid name 
"-".
+  llvm::SmallVector DiffOldNsSplitted;
+  llvm::StringRef(DiffOldNamespace).split(DiffOldNsSplitted, "::");
+  std::string Prefix = "-";
+  if (!DiffOldNsSplitted.empty())
+Prefix = (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) +
+  DiffOldNsSplitted.front())
+ .str();
+  auto IsInMovedNs =
+  allOf(hasAncestor(namespaceDecl(hasName(FullOldNs)).bind("ns_decl")),
+isExpansionInFileMatching(FilePattern));
+  auto IsVisibleInNewNs = anyOf(
+  IsInMovedNs, unless(hasAncestor(namespaceDecl(hasName(Prefix);
+  // Match using declarations.
+  Finder->addMatcher(
+  usingDecl(isExpansionInFileMatching(FilePattern), IsVisibleInNewNs)
+  .bind("using"),
+  this);
+  // Match using namespace declarations.
+  Finder->addMatcher(usingDirectiveDecl(isExpansionInFileMatching(FilePattern),
+IsVisibleInNewNs)
+ .bind("using_namespace"),
+ this);
+
+  // Match old namespace blocks.
   Finder->addMatcher(
   namespaceDecl(hasName(FullOldNs), isExpansionInFileMatching(FilePattern))
   .bind("old_ns"),
   this);
 
-  auto IsInMovedNs =
-  allOf(hasAncestor(namespaceDecl(hasName(FullOldNs)).bind("ns_decl")),
-isExpansionInFileMatching(FilePattern));
-
   // Match forward-declarations in the old namespace.
   Finder->addMatcher(
   cxxRecordDecl(unless(anyOf(isImplicit(), isDefinition())), IsInMovedNs)
@@ -288,9 +329,9 @@ void ChangeNamespaceTool::registerMatche
 
   // Types in `UsingShadowDecl` is not matched by `typeLoc` above, so we need 
to
   // special case it.
-  Finder->addMatcher(
-  usingDecl(IsInMovedNs, 

[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-11-08 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 77271.
jlebar added a comment.

Use TEST_STD_VER macro.


https://reviews.llvm.org/D25403

Files:
  libcxx/include/cmath
  libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp


Index: libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take
+// floating-point values are evaluatable from constexpr contexts.
+//
+// These functions need to be constexpr in order to be called from CUDA, see
+// https://reviews.llvm.org/D25403.  They don't actually need to be
+// constexpr-evaluatable, but that's what we check here, since we can't check
+// true constexpr-ness.
+
+#include 
+
+#include "test_macros.h"
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+#if TEST_STD_VER >= 11
+constexpr bool a = std::__libcpp_isnan(0.);
+constexpr bool b = std::__libcpp_isinf(0.0);
+constexpr bool c = std::__libcpp_isfinite(0.0);
+#endif
+
+int main()
+{
+  return 0;
+}
Index: libcxx/include/cmath
===
--- libcxx/include/cmath
+++ libcxx/include/cmath
@@ -560,7 +560,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isnan)
@@ -572,15 +572,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 return isnan(__lcpp_x);
 }
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isinf)
@@ -592,15 +592,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 return isinf(__lcpp_x);
 }
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isfinite)
@@ -612,7 +612,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, 
bool>::type
 __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 return isfinite(__lcpp_x);


Index: libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// Check that the overloads of std::__libcpp_{isnan,isinf,isfinite} that take
+// floating-point values are evaluatable from constexpr contexts.
+//
+// These functions need to be constexpr in order to be called from CUDA, see
+// https://reviews.llvm.org/D25403.  They don't actually need to be
+// constexpr-evaluatable, but that's what we check here, since we can't check
+// true constexpr-ness.
+
+#include 
+
+#include "test_macros.h"
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+#if TEST_STD_VER >= 11
+constexpr bool a = std::__libcpp_isnan(0.);
+constexpr bool b = std::__libcpp_isinf(0.0);
+constexpr bool c = std::__libcpp_isfinite(0.0);
+#endif
+
+int main()
+{
+  return 0;
+}
Index: libcxx/include/cmath
===
--- libcxx/include/cmath
+++ libcxx/include/cmath
@@ -560,7 +560,7 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename enable_if::value, bool>::type
+_LIBCPP_CONSTEXPR typename enable_if::value, bool>::type
 __libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
 {
 #if __has_builtin(__builtin_isnan)
@@ -572,15 +572,15 @@
 
 template 
 _LIBCPP_ALWAYS_INLINE
-typename 

[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 77270.
ioeric marked an inline comment as done.
ioeric added a comment.

- Addressed comment.


https://reviews.llvm.org/D25771

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -313,8 +313,8 @@
  "}\n"
  "namespace nb {\n"
  "using nc::SAME;\n"
- "using YO = nc::SAME;\n"
- "typedef nc::SAME IDENTICAL;\n"
+ "using YO = nd::SAME;\n"
+ "typedef nd::SAME IDENTICAL;\n"
  "void f(nd::SAME Same) {}\n"
  "} // namespace nb\n"
  "} // namespace na\n";
@@ -333,93 +333,14 @@
  "namespace x {\n"
  "namespace y {\n"
  "using ::na::nc::SAME;\n"
- "using YO = na::nc::SAME;\n"
- "typedef na::nc::SAME IDENTICAL;\n"
+ "using YO = na::nd::SAME;\n"
+ "typedef na::nd::SAME IDENTICAL;\n"
  "void f(na::nd::SAME Same) {}\n"
  "} // namespace y\n"
  "} // namespace x\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() {\n"
- "  using glob::Glob;\n"
- "  Glob g;\n"
- "}\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() {\n"
- "  using ::glob::Glob;\n"
- "  glob::Glob g;\n"
- "}\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingNamespace) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is "using namespace" decl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
 TEST_F(ChangeNamespaceTest, TypeInNestedNameSpecifier) {
   std::string Code =
   "namespace na {\n"
@@ -625,6 +546,359 @@
   EXPECT_EQ(format(Expected), 

[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.

2016-11-08 Thread Dominic Chen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286306: [analyzer] Provide Contains() on ImmutableMap 
program state partial trait. (authored by ddcc).

Changed prior to commit:
  https://reviews.llvm.org/D26373?vs=77109=77269#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26373

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h


Index: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
===
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
@@ -8,7 +8,7 @@
 
//===--===//
 //
 //  This file defines partial implementations of template specializations of
-//  the class ProgramStateTrait<>.  ProgramStateTrait<> is used by 
ProgramState 
+//  the class ProgramStateTrait<>.  ProgramStateTrait<> is used by ProgramState
 //  to implement set/get methods for manipulating a ProgramState's
 //  generic data map.
 //
@@ -81,6 +81,10 @@
   return F.remove(B, K);
 }
 
+static bool Contains(data_type B, key_type K) {
+  return B.contains(K);
+}
+
 static inline context_type MakeContext(void *p) {
   return *((typename data_type::Factory*) p);
 }
@@ -185,7 +189,7 @@
 }
   };
 
-  
+
   // Partial specialization for bool.
   template <> struct ProgramStatePartialTrait {
 typedef bool data_type;
@@ -198,7 +202,7 @@
   return (void*) (uintptr_t) d;
 }
   };
-  
+
   // Partial specialization for unsigned.
   template <> struct ProgramStatePartialTrait {
 typedef unsigned data_type;


Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
@@ -8,7 +8,7 @@
 //===--===//
 //
 //  This file defines partial implementations of template specializations of
-//  the class ProgramStateTrait<>.  ProgramStateTrait<> is used by ProgramState 
+//  the class ProgramStateTrait<>.  ProgramStateTrait<> is used by ProgramState
 //  to implement set/get methods for manipulating a ProgramState's
 //  generic data map.
 //
@@ -81,6 +81,10 @@
   return F.remove(B, K);
 }
 
+static bool Contains(data_type B, key_type K) {
+  return B.contains(K);
+}
+
 static inline context_type MakeContext(void *p) {
   return *((typename data_type::Factory*) p);
 }
@@ -185,7 +189,7 @@
 }
   };
 
-  
+
   // Partial specialization for bool.
   template <> struct ProgramStatePartialTrait {
 typedef bool data_type;
@@ -198,7 +202,7 @@
   return (void*) (uintptr_t) d;
 }
   };
-  
+
   // Partial specialization for unsigned.
   template <> struct ProgramStatePartialTrait {
 typedef unsigned data_type;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286306 - [analyzer] Provide Contains() on ImmutableMap program state partial trait.

2016-11-08 Thread Dominic Chen via cfe-commits
Author: ddcc
Date: Tue Nov  8 16:39:14 2016
New Revision: 286306

URL: http://llvm.org/viewvc/llvm-project?rev=286306=rev
Log:
[analyzer] Provide Contains() on ImmutableMap program state partial trait.

Reviewers: zaks.anna, dcoughlin

Subscribers: cfe-commits

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h?rev=286306=286305=286306=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h 
Tue Nov  8 16:39:14 2016
@@ -8,7 +8,7 @@
 
//===--===//
 //
 //  This file defines partial implementations of template specializations of
-//  the class ProgramStateTrait<>.  ProgramStateTrait<> is used by 
ProgramState 
+//  the class ProgramStateTrait<>.  ProgramStateTrait<> is used by ProgramState
 //  to implement set/get methods for manipulating a ProgramState's
 //  generic data map.
 //
@@ -81,6 +81,10 @@ namespace ento {
   return F.remove(B, K);
 }
 
+static bool Contains(data_type B, key_type K) {
+  return B.contains(K);
+}
+
 static inline context_type MakeContext(void *p) {
   return *((typename data_type::Factory*) p);
 }
@@ -185,7 +189,7 @@ namespace ento {
 }
   };
 
-  
+
   // Partial specialization for bool.
   template <> struct ProgramStatePartialTrait {
 typedef bool data_type;
@@ -198,7 +202,7 @@ namespace ento {
   return (void*) (uintptr_t) d;
 }
   };
-  
+
   // Partial specialization for unsigned.
   template <> struct ProgramStatePartialTrait {
 typedef unsigned data_type;


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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM with one nit.




Comment at: change-namespace/ChangeNamespace.cpp:275
+   (DiffOldNsSplitted.empty() ? "-" : DiffOldNsSplitted.front()))
+  .str();
+  auto IsInMovedNs =

ioeric wrote:
> hokein wrote:
> > Using an invalid name `-` is not an elegant solution to me. Is it possible 
> > to avoid it? 
> > Maybe we can explicitly specify `IsVisibleInNewNs` using the code like:
> > 
> > ```
> > Optional IsVisibleInNewNs = 
> > IsInMovedNs;
> > if (!DiffOldNsSplitted.empty() )  {
> >   std::string Prefix = ... 
> >   IsVisibleInNewNs = anyOf(*IsVisibleInNewNs, 
> > unless(hasAncestor(namespaceDecl(hasName(Prefix));
> > }
> > ```
> As per offline discussion, this seems to be impossible.
OK, then add a comment explicitly specifying that `"-"` is used as an invalid 
name.

I think the code can be simplified as:

```
std::string Prefix = "-";
if (!DiffOldNsSplitted.empty()) {
  Prefix =  (StringRef(FullOldNs).drop_back(DiffOldNamespace.size()) + 
DiffOldNsSplitted.front()).str();
}
```


https://reviews.llvm.org/D25771



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


[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread John McCall via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D26196#589493, @yaxunl wrote:

> Fixed list initialization of large struct which are mostly initialized by 0 
> through memset.
>  Added tests for casting literal 0 and non-literal integer to pointer.
>
> There are many more places need to be changed. I am wondering if it makes 
> sense to split this feature into multiple pieces, e.g. for C and OpenCL, C++, 
> Objective-C, OpenMP, incrementally.


It's fine to split it up.  Note that at least some of the Objective-C code 
doesn't need to be updated, because Objective-C object pointers can't be in an 
alternate address space.




Comment at: lib/CodeGen/CGExprConstant.cpp:1645
   if (const RecordType *RT = T->getAs()) {
-const CXXRecordDecl *RD = cast(RT->getDecl());
+const RecordDecl *RD = cast(RT->getDecl());
 return ::EmitNullConstant(*this, RD, /*complete object*/ true);

The cast<> here is now unnecessary.



Comment at: lib/CodeGen/CodeGenModule.h:1159
+  /// Does null pointer have zero value.
+  bool isNullPtrZero(llvm::PointerType *T, QualType QT);
+

This can just take QT; it's not optimized by taking T as well, and in some 
cases you wouldn't otherwise need to compute that.



Comment at: lib/CodeGen/TargetInfo.cpp:7040
+ auto AS = PT->getAddressSpace();
+ return AS != Ctx.getTargetAddressSpace(LangAS::opencl_local) && AS != 0;
+}

This check is definitely not correct; this function needs to return true when 
AS == 0, right?

Also, you should really just be checking QT.getAddressSpace().


https://reviews.llvm.org/D26196



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


[PATCH] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.

2016-11-08 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

In https://reviews.llvm.org/D26373#589614, @ddcc wrote:

> Even though there isn't a performance difference, I think it is semantically 
> clearer since it is explicit that the value is unneeded.


Makes sense to me!


https://reviews.llvm.org/D26373



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


[PATCH] D26423: [clang-move] Support template class.

2016-11-08 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D26423

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/template_class_test.cpp
  test/clang-move/Inputs/template_class_test.h
  test/clang-move/move-template-class.cpp

Index: test/clang-move/move-template-class.cpp
===
--- /dev/null
+++ test/clang-move/move-template-class.cpp
@@ -0,0 +1,86 @@
+// RUN: mkdir -p %T/move-template-class
+// RUN: cp %S/Inputs/template_class_test*  %T/move-template-class
+// RUN: cd %T/move-template-class
+// RUN: clang-move -names="A,B" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp --
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-EMPTY -allow-empty %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE1 %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s
+//
+// RUN: cp %S/Inputs/template_class_test*  %T/move-template-class
+// RUN: clang-move -names="A" -new_cc=%T/move-template-class/new_template_class_test.cpp -new_header=%T/move-template-class/new_template_class_test.h -old_cc=%T/move-template-class/template_class_test.cpp -old_header=../move-template-class/template_class_test.h %T/move-template-class/template_class_test.cpp --
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.h -check-prefix=CHECK-OLD-TEST-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-template-class/template_class_test.cpp -check-prefix=CHECK-OLD-TEST-CPP-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.h -check-prefix=CHECK-NEW-TEST-H-CASE2 %s
+// RUN: FileCheck -input-file=%T/move-template-class/new_template_class_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE2 %s
+//
+//
+// CHECK-OLD-TEST-EMPTY: {{^}}{{$}}
+//
+// CHECK-NEW-TEST-H-CASE1: #ifndef TEMPLATE_CLASS_TEST_H // comment 1
+// CHECK-NEW-TEST-H-CASE1: #define TEMPLATE_CLASS_TEST_H
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: class A {
+// CHECK-NEW-TEST-H-CASE1:  public:
+// CHECK-NEW-TEST-H-CASE1:   void f();
+// CHECK-NEW-TEST-H-CASE1:   void g();
+// CHECK-NEW-TEST-H-CASE1:   template  void h();
+// CHECK-NEW-TEST-H-CASE1:   template  void k();
+// CHECK-NEW-TEST-H-CASE1:   static int b;
+// CHECK-NEW-TEST-H-CASE1:   static int c;
+// CHECK-NEW-TEST-H-CASE1: };
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: void A::f() {}
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: void A::h() {}
+// CHECK-NEW-TEST-H-CASE1: template 
+// CHECK-NEW-TEST-H-CASE1: int A::b = 2;
+// CHECK-NEW-TEST-H-CASE1: class B {
+// CHECK-NEW-TEST-H-CASE1:  public:
+// CHECK-NEW-TEST-H-CASE1:   void f();
+// CHECK-NEW-TEST-H-CASE1: };
+// CHECK-NEW-TEST-H-CASE1: #endif // TEMPLATE_CLASS_TEST_H
+//
+// CHECK-NEW-TEST-CPP-CASE1: #include "{{.*}}new_template_class_test.h"
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: void A::g() {}
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: void A::k() {}
+// CHECK-NEW-TEST-CPP-CASE1: template 
+// CHECK-NEW-TEST-CPP-CASE1: int A::c = 2;
+// CHECK-NEW-TEST-CPP-CASE1: void B::f() {}
+//
+// CHECK-OLD-TEST-H-CASE2: #ifndef TEMPLATE_CLASS_TEST_H // comment 1
+// CHECK-OLD-TEST-H-CASE2: #define TEMPLATE_CLASS_TEST_H
+// CHECK-OLD-TEST-H-CASE2: class B {
+// CHECK-OLD-TEST-H-CASE2:  public:
+// CHECK-OLD-TEST-H-CASE2:   void f();
+// CHECK-OLD-TEST-H-CASE2: };
+// CHECK-OLD-TEST-H-CASE2: #endif // TEMPLATE_CLASS_TEST_H
+//
+// CHECK-OLD-TEST-CPP-CASE2: #include "template_class_test.h"
+// CHECK-OLD-TEST-CPP-CASE2:  void B::f() {}
+//
+// CHECK-NEW-TEST-H-CASE2: #ifndef {{.*}}NEW_TEMPLATE_CLASS_TEST_H
+// CHECK-NEW-TEST-H-CASE2: #define {{.*}}NEW_TEMPLATE_CLASS_TEST_H
+// CHECK-NEW-TEST-H-CASE2: template 
+// CHECK-NEW-TEST-H-CASE2: class A {
+// CHECK-NEW-TEST-H-CASE2:  public:
+// CHECK-NEW-TEST-H-CASE2:   void f();
+// CHECK-NEW-TEST-H-CASE2:   void g();
+// CHECK-NEW-TEST-H-CASE2:   template  void h();
+// CHECK-NEW-TEST-H-CASE2:   template  void k();
+// CHECK-NEW-TEST-H-CASE2:   static int b;
+// CHECK-NEW-TEST-H-CASE2:   static int c;
+// CHECK-NEW-TEST-H-CASE2: };
+// CHECK-NEW-TEST-H-CASE2: template  void A::f() {}
+// CHECK-NEW-TEST-H-CASE2: template  template  void A::h() {}
+// CHECK-NEW-TEST-H-CASE2: template  int A::b = 2;
+// 

[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread John McCall via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1340
+  return C;
+return getNullPtr(PT, DestType);
   }

yaxunl wrote:
> efriedma wrote:
> > yaxunl wrote:
> > > yaxunl wrote:
> > > > rjmccall wrote:
> > > > > efriedma wrote:
> > > > > > Consider code like the following:
> > > > > > 
> > > > > > int x = 0;
> > > > > > auto y1 = (__specialaddrspace int*)0;
> > > > > > auto y2 = (__specialaddrspace int*)((void)0, 0);
> > > > > > auto y3 = (__specialaddrspace int*)x;
> > > > > > 
> > > > > > How do you expect these three cases to behave?  (The first case 
> > > > > > involves a C null pointer constant, the second and third cases are 
> > > > > > different ways of writing a general int->ptr conversion.)
> > > > > Yeah, I think you probably need to fix APValue to be unambiguous 
> > > > > about whether the value is a formal null pointer (CK_NullToPointer) 
> > > > > or just a cast of an integer (CK_IntegralToPointer).  It looks like 
> > > > > PointerExprEvaluator will generate the exact same value for both.
> > > > It seems the current implementation generates the correct IR.
> > > > 
> > > > I tried the following sample and I saw correct IR generated.
> > > > 
> > > > 
> > > > ```
> > > > private int* test_cast_0_to_ptr(void) {
> > > >   return (private int*)0;
> > > > }
> > > > 
> > > > private int* test_cast_int_to_ptr1(void) {
> > > >   return (private int*)((void)0, 0);
> > > > }
> > > > 
> > > > private int* test_cast_int_to_ptr2(void) {
> > > >   int x = 0;
> > > >   return (private int*)x;
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > The dumped AST is
> > > > 
> > > > 
> > > > ```
> > > > |-FunctionDecl 0x95fdc88  line:3:14 
> > > > test_cast_0_to_ptr 'int *(void)'
> > > > | `-CompoundStmt 0x95fdde8 
> > > > |   `-ReturnStmt 0x95fddd0 
> > > > | `-CStyleCastExpr 0x95fdda8  'int *' 
> > > > 
> > > > |   `-IntegerLiteral 0x95fdd70  'int' 0
> > > > |-FunctionDecl 0x95fdea0  line:13:14 
> > > > test_cast_int_to_ptr1 'int *(void)'
> > > > | `-CompoundStmt 0x95fe098 
> > > > |   `-ReturnStmt 0x95fe080 
> > > > | `-CStyleCastExpr 0x95fe058  'int *' 
> > > > 
> > > > |   `-ParenExpr 0x95fe038  'int'
> > > > | `-BinaryOperator 0x95fe010  'int' ','
> > > > |   |-CStyleCastExpr 0x95fdf78  'void' 
> > > > |   | `-IntegerLiteral 0x95fdf48  'int' 0
> > > > |   `-IntegerLiteral 0x95fdfa0  'int' 0
> > > > `-FunctionDecl 0x95fe150  line:19:14 
> > > > test_cast_int_to_ptr2 'int *(void)'
> > > >   `-CompoundStmt 0x9620130 
> > > > |-DeclStmt 0x9620080 
> > > > | `-VarDecl 0x95fe210  col:7 used x 'int' cinit
> > > > |   `-IntegerLiteral 0x9620060  'int' 0
> > > > `-ReturnStmt 0x9620118 
> > > >   `-CStyleCastExpr 0x96200f0  'int *' 
> > > > 
> > > > ```
> > > > 
> > > > Since only CK_NullToPointer is translated to null pointer through 
> > > > getNullPtr, CK_IntegralToPointer will result in either zero-valued 
> > > > pointer or inttoptr, the generated IR is correct.
> > > Basically in the second and third case the destination type is not 
> > > pointer, so they do not need to be emitted as null pointer. If a literal 
> > > 0 is casted to a pointer type, then it should be emitted as a null 
> > > pointer.
> > What happens in the following case?
> > 
> > static private int* x = (private int*)((void)0, 0);
> You are right. This needs to be fixed.
Another straightforward test case would be reinterpret_cast(0), 
or (private void*) (1-1) in C++11.


https://reviews.llvm.org/D26196



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Eric Liu via cfe-commits
ioeric marked an inline comment as done.
ioeric added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:275
+   (DiffOldNsSplitted.empty() ? "-" : DiffOldNsSplitted.front()))
+  .str();
+  auto IsInMovedNs =

hokein wrote:
> Using an invalid name `-` is not an elegant solution to me. Is it possible to 
> avoid it? 
> Maybe we can explicitly specify `IsVisibleInNewNs` using the code like:
> 
> ```
> Optional IsVisibleInNewNs = 
> IsInMovedNs;
> if (!DiffOldNsSplitted.empty() )  {
>   std::string Prefix = ... 
>   IsVisibleInNewNs = anyOf(*IsVisibleInNewNs, 
> unless(hasAncestor(namespaceDecl(hasName(Prefix));
> }
> ```
As per offline discussion, this seems to be impossible.


https://reviews.llvm.org/D25771



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


[PATCH] D25403: [CUDA] Mark __libcpp_{isnan, isinf, isfinite} as constexpr.

2016-11-08 Thread Hal Finkel via cfe-commits
hfinkel added inline comments.



Comment at: libcxx/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp:24
+
+#if __cplusplus >= 201103L
+constexpr bool a = std::__libcpp_isnan(0.);

I think the preferred form here is:

#if TEST_STD_VER >= 11


https://reviews.llvm.org/D25403



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


Re: [PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Evgenii Stepanov via cfe-commits
Yes, some bots don't build all the targets.
I think the test should go into Preprocessor/init.c.


On Tue, Nov 8, 2016 at 2:07 PM, Stephen Hines  wrote:
> srhines added a comment.
>
> Reverted because this broke builds:
>
> clang-hexagon-elf
> llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
> clang-ppc64be-linux-multistage
> llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
>
> It isn't clear from the logs why these builds failed, since I did a general 
> build, but perhaps there is something that is stripping out Android-specific 
> targets there.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26422
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

Reverted because this broke builds:

clang-hexagon-elf
llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
clang-ppc64be-linux-multistage
llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast

It isn't clear from the logs why these builds failed, since I did a general 
build, but perhaps there is something that is stripping out Android-specific 
targets there.


Repository:
  rL LLVM

https://reviews.llvm.org/D26422



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


[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286298: Revert "Define __ANDROID_API__ for all Android 
builds." (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D26422?vs=77254=77256#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26422

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Driver/android-targets.cpp

Index: cfe/trunk/test/Driver/android-targets.cpp
===
--- cfe/trunk/test/Driver/android-targets.cpp
+++ cfe/trunk/test/Driver/android-targets.cpp
@@ -1,83 +0,0 @@
-// Test API-related defines for various Android targets.
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-
-// CHECK: __ANDROID__defined
-// LEVEL19: __ANDROID__defined
-// LEVEL20: __ANDROID__defined
-#ifdef __ANDROID__
-void __ANDROID__defined(void) {}
-#endif
-
-// CHECK-NOT: __ANDROID_API__defined
-// LEVEL19: __ANDROID_API__defined
-// LEVEL20: __ANDROID_API__defined
-#ifdef __ANDROID_API__
-void __ANDROID_API__defined(void) {}
-int android_api = __ANDROID_API__;
-#endif
-
-// CHECK-NOT: __ANDROID_API__20
-// LEVEL19-NOT: __ANDROID_API__20
-// LEVEL20: __ANDROID_API__20
-#if __ANDROID_API__ >= 20
-void __ANDROID_API__20(void) {}
-#endif
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -465,8 +465,6 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286298 - Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Nov  8 15:54:49 2016
New Revision: 286298

URL: http://llvm.org/viewvc/llvm-project?rev=286298=rev
Log:
Revert "Define __ANDROID_API__ for all Android builds."

Summary: This reverts commit a8804ddd9fe71304b28e5b834d134fe93e568ee0.

Subscribers: cfe-commits, pirama, eugenis, tberghammer, danalbert

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

Removed:
cfe/trunk/test/Driver/android-targets.cpp
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286298=286297=286298=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov  8 15:54:49 2016
@@ -465,8 +465,6 @@ protected:
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");

Removed: cfe/trunk/test/Driver/android-targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-targets.cpp?rev=286297=auto
==
--- cfe/trunk/test/Driver/android-targets.cpp (original)
+++ cfe/trunk/test/Driver/android-targets.cpp (removed)
@@ -1,83 +0,0 @@
-// Test API-related defines for various Android targets.
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-
-// CHECK: __ANDROID__defined
-// LEVEL19: __ANDROID__defined
-// LEVEL20: __ANDROID__defined
-#ifdef __ANDROID__
-void __ANDROID__defined(void) {}
-#endif
-
-// CHECK-NOT: __ANDROID_API__defined
-// LEVEL19: __ANDROID_API__defined
-// LEVEL20: __ANDROID_API__defined
-#ifdef __ANDROID_API__
-void __ANDROID_API__defined(void) {}
-int android_api = __ANDROID_API__;
-#endif
-
-// CHECK-NOT: __ANDROID_API__20
-// LEVEL19-NOT: __ANDROID_API__20
-// LEVEL20: __ANDROID_API__20
-#if __ANDROID_API__ >= 20
-void __ANDROID_API__20(void) {}
-#endif


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


[PATCH] D26422: Revert "Define __ANDROID_API__ for all Android builds."

2016-11-08 Thread Stephen Hines via cfe-commits
srhines created this revision.
srhines added subscribers: danalbert, eugenis, pirama, cfe-commits.
Herald added a subscriber: tberghammer.

This reverts commit a8804ddd9fe71304b28e5b834d134fe93e568ee0.


https://reviews.llvm.org/D26422

Files:
  lib/Basic/Targets.cpp
  test/Driver/android-targets.cpp

Index: test/Driver/android-targets.cpp
===
--- test/Driver/android-targets.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-// Test API-related defines for various Android targets.
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target arm-linux-androideabi20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target aarch64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target i686-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target x86_64-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mipsel-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-//
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android \
-// RUN:   | FileCheck %s
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android19 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL19
-// RUN: %clang %s -emit-llvm -S -c -o - \
-// RUN: -target mips64el-linux-android20 \
-// RUN:   | FileCheck %s -check-prefix=LEVEL20
-
-// CHECK: __ANDROID__defined
-// LEVEL19: __ANDROID__defined
-// LEVEL20: __ANDROID__defined
-#ifdef __ANDROID__
-void __ANDROID__defined(void) {}
-#endif
-
-// CHECK-NOT: __ANDROID_API__defined
-// LEVEL19: __ANDROID_API__defined
-// LEVEL20: __ANDROID_API__defined
-#ifdef __ANDROID_API__
-void __ANDROID_API__defined(void) {}
-int android_api = __ANDROID_API__;
-#endif
-
-// CHECK-NOT: __ANDROID_API__20
-// LEVEL19-NOT: __ANDROID_API__20
-// LEVEL20: __ANDROID_API__20
-#if __ANDROID_API__ >= 20
-void __ANDROID_API__20(void) {}
-#endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,8 +465,6 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread Yaxun Liu via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1340
+  return C;
+return getNullPtr(PT, DestType);
   }

efriedma wrote:
> yaxunl wrote:
> > yaxunl wrote:
> > > rjmccall wrote:
> > > > efriedma wrote:
> > > > > Consider code like the following:
> > > > > 
> > > > > int x = 0;
> > > > > auto y1 = (__specialaddrspace int*)0;
> > > > > auto y2 = (__specialaddrspace int*)((void)0, 0);
> > > > > auto y3 = (__specialaddrspace int*)x;
> > > > > 
> > > > > How do you expect these three cases to behave?  (The first case 
> > > > > involves a C null pointer constant, the second and third cases are 
> > > > > different ways of writing a general int->ptr conversion.)
> > > > Yeah, I think you probably need to fix APValue to be unambiguous about 
> > > > whether the value is a formal null pointer (CK_NullToPointer) or just a 
> > > > cast of an integer (CK_IntegralToPointer).  It looks like 
> > > > PointerExprEvaluator will generate the exact same value for both.
> > > It seems the current implementation generates the correct IR.
> > > 
> > > I tried the following sample and I saw correct IR generated.
> > > 
> > > 
> > > ```
> > > private int* test_cast_0_to_ptr(void) {
> > >   return (private int*)0;
> > > }
> > > 
> > > private int* test_cast_int_to_ptr1(void) {
> > >   return (private int*)((void)0, 0);
> > > }
> > > 
> > > private int* test_cast_int_to_ptr2(void) {
> > >   int x = 0;
> > >   return (private int*)x;
> > > }
> > > 
> > > ```
> > > 
> > > The dumped AST is
> > > 
> > > 
> > > ```
> > > |-FunctionDecl 0x95fdc88  line:3:14 
> > > test_cast_0_to_ptr 'int *(void)'
> > > | `-CompoundStmt 0x95fdde8 
> > > |   `-ReturnStmt 0x95fddd0 
> > > | `-CStyleCastExpr 0x95fdda8  'int *' 
> > > |   `-IntegerLiteral 0x95fdd70  'int' 0
> > > |-FunctionDecl 0x95fdea0  line:13:14 
> > > test_cast_int_to_ptr1 'int *(void)'
> > > | `-CompoundStmt 0x95fe098 
> > > |   `-ReturnStmt 0x95fe080 
> > > | `-CStyleCastExpr 0x95fe058  'int *' 
> > > 
> > > |   `-ParenExpr 0x95fe038  'int'
> > > | `-BinaryOperator 0x95fe010  'int' ','
> > > |   |-CStyleCastExpr 0x95fdf78  'void' 
> > > |   | `-IntegerLiteral 0x95fdf48  'int' 0
> > > |   `-IntegerLiteral 0x95fdfa0  'int' 0
> > > `-FunctionDecl 0x95fe150  line:19:14 
> > > test_cast_int_to_ptr2 'int *(void)'
> > >   `-CompoundStmt 0x9620130 
> > > |-DeclStmt 0x9620080 
> > > | `-VarDecl 0x95fe210  col:7 used x 'int' cinit
> > > |   `-IntegerLiteral 0x9620060  'int' 0
> > > `-ReturnStmt 0x9620118 
> > >   `-CStyleCastExpr 0x96200f0  'int *' 
> > > 
> > > ```
> > > 
> > > Since only CK_NullToPointer is translated to null pointer through 
> > > getNullPtr, CK_IntegralToPointer will result in either zero-valued 
> > > pointer or inttoptr, the generated IR is correct.
> > Basically in the second and third case the destination type is not pointer, 
> > so they do not need to be emitted as null pointer. If a literal 0 is casted 
> > to a pointer type, then it should be emitted as a null pointer.
> What happens in the following case?
> 
> static private int* x = (private int*)((void)0, 0);
You are right. This needs to be fixed.


https://reviews.llvm.org/D26196



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-11-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

I think will be good idea to mention this in documentation and release notes.


https://reviews.llvm.org/D26418



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

Ugh, phabricator dropped my updated commit message, so that is completely wrong 
now. Oh well. I guess I will just use repo/gerrit for staging things in the 
future (and get consensus there) before asking for any upstream reviews.


Repository:
  rL LLVM

https://reviews.llvm.org/D26385



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286295: Define __ANDROID_API__ for all Android builds. 
(authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D26385?vs=77236=77250#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26385

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Driver/android-targets.cpp

Index: cfe/trunk/test/Driver/android-targets.cpp
===
--- cfe/trunk/test/Driver/android-targets.cpp
+++ cfe/trunk/test/Driver/android-targets.cpp
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK-NOT: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r286295 - Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Nov  8 15:23:26 2016
New Revision: 286295

URL: http://llvm.org/viewvc/llvm-project?rev=286295=rev
Log:
Define __ANDROID_API__ for all Android builds.

Summary:
Bug: https://llvm.org/bugs/show_bug.cgi?id=30940

This macro (along with __ANDROID__) should always be defined for Android
targets. We set it to the major (only) version of the Android API being
compiled for. The Android version is able to be set as an integer suffix
for any valid Android target.

Reviewers: danalbert, eugenis

Subscribers: cfe-commits, pirama, eugenis, tberghammer, danalbert

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

Added:
cfe/trunk/test/Driver/android-targets.cpp
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=286295=286294=286295=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Nov  8 15:23:26 2016
@@ -465,6 +465,8 @@ protected:
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");

Added: cfe/trunk/test/Driver/android-targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-targets.cpp?rev=286295=auto
==
--- cfe/trunk/test/Driver/android-targets.cpp (added)
+++ cfe/trunk/test/Driver/android-targets.cpp Tue Nov  8 15:23:26 2016
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK-NOT: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif


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


[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread Eli Friedman via cfe-commits
efriedma added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1340
+  return C;
+return getNullPtr(PT, DestType);
   }

yaxunl wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > efriedma wrote:
> > > > Consider code like the following:
> > > > 
> > > > int x = 0;
> > > > auto y1 = (__specialaddrspace int*)0;
> > > > auto y2 = (__specialaddrspace int*)((void)0, 0);
> > > > auto y3 = (__specialaddrspace int*)x;
> > > > 
> > > > How do you expect these three cases to behave?  (The first case 
> > > > involves a C null pointer constant, the second and third cases are 
> > > > different ways of writing a general int->ptr conversion.)
> > > Yeah, I think you probably need to fix APValue to be unambiguous about 
> > > whether the value is a formal null pointer (CK_NullToPointer) or just a 
> > > cast of an integer (CK_IntegralToPointer).  It looks like 
> > > PointerExprEvaluator will generate the exact same value for both.
> > It seems the current implementation generates the correct IR.
> > 
> > I tried the following sample and I saw correct IR generated.
> > 
> > 
> > ```
> > private int* test_cast_0_to_ptr(void) {
> >   return (private int*)0;
> > }
> > 
> > private int* test_cast_int_to_ptr1(void) {
> >   return (private int*)((void)0, 0);
> > }
> > 
> > private int* test_cast_int_to_ptr2(void) {
> >   int x = 0;
> >   return (private int*)x;
> > }
> > 
> > ```
> > 
> > The dumped AST is
> > 
> > 
> > ```
> > |-FunctionDecl 0x95fdc88  line:3:14 
> > test_cast_0_to_ptr 'int *(void)'
> > | `-CompoundStmt 0x95fdde8 
> > |   `-ReturnStmt 0x95fddd0 
> > | `-CStyleCastExpr 0x95fdda8  'int *' 
> > |   `-IntegerLiteral 0x95fdd70  'int' 0
> > |-FunctionDecl 0x95fdea0  line:13:14 
> > test_cast_int_to_ptr1 'int *(void)'
> > | `-CompoundStmt 0x95fe098 
> > |   `-ReturnStmt 0x95fe080 
> > | `-CStyleCastExpr 0x95fe058  'int *' 
> > 
> > |   `-ParenExpr 0x95fe038  'int'
> > | `-BinaryOperator 0x95fe010  'int' ','
> > |   |-CStyleCastExpr 0x95fdf78  'void' 
> > |   | `-IntegerLiteral 0x95fdf48  'int' 0
> > |   `-IntegerLiteral 0x95fdfa0  'int' 0
> > `-FunctionDecl 0x95fe150  line:19:14 
> > test_cast_int_to_ptr2 'int *(void)'
> >   `-CompoundStmt 0x9620130 
> > |-DeclStmt 0x9620080 
> > | `-VarDecl 0x95fe210  col:7 used x 'int' cinit
> > |   `-IntegerLiteral 0x9620060  'int' 0
> > `-ReturnStmt 0x9620118 
> >   `-CStyleCastExpr 0x96200f0  'int *' 
> > 
> > ```
> > 
> > Since only CK_NullToPointer is translated to null pointer through 
> > getNullPtr, CK_IntegralToPointer will result in either zero-valued pointer 
> > or inttoptr, the generated IR is correct.
> Basically in the second and third case the destination type is not pointer, 
> so they do not need to be emitted as null pointer. If a literal 0 is casted 
> to a pointer type, then it should be emitted as a null pointer.
What happens in the following case?

static private int* x = (private int*)((void)0, 0);


https://reviews.llvm.org/D26196



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


[PATCH] D26418: Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2016-11-08 Thread Nikita Kakuev via cfe-commits
nkakuev created this revision.
nkakuev added reviewers: malcolm.parsons, alexfh.
nkakuev added a subscriber: cfe-commits.

Currently clang-tidy doesn't provide a practical way to suppress diagnostics 
from headers you don't have control over. If using a function defined in such 
header causes a false positive, there is no easy way to deal with this issue.

Since you //cannot// modify a header, you //cannot// add NOLINT (or any other 
source annotations) to it. And adding NOLINT to each invocation of such 
function is either impossible or hugely impractical if invocations are 
ubiquitous.

Using the '-header-filter' doesn't help to address this issue as well. Unless 
your own headers are strategically named, it is virtually impossible to craft a 
regex that will filter out only the third-party ones.

The '-line-filter' can be used to suppress such warnings, but it's not very 
convenient. Instead of excluding a line that produces a warning you have to 
include all other lines. Plus, it provides no way to suppress only certain 
warnings from a file.

The option I propose solves aforementioned problems. It allows a user to 
specify a set of regular expressions to suppress diagnostics from files whose 
names match these expressions. Additionally, a set of checks can be specified 
to suppress only certain diagnostics.

The option can be used in the following way:
`clang-tidy 
-suppress-checks-filter='[{"name":"falty_header.h"},{"name":"third-party/","checks":"google-explicit-constructor"}]'
 source.cpp -- -c`


https://reviews.llvm.org/D26418

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h
  test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h
  test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h
  test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h
  test/clang-tidy/suppress-checks-filter.cpp

Index: test/clang-tidy/suppress-checks-filter.cpp
===
--- test/clang-tidy/suppress-checks-filter.cpp
+++ test/clang-tidy/suppress-checks-filter.cpp
@@ -0,0 +1,17 @@
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,google-readability-casting' -header-filter='header*' -suppress-checks-filter='[{"name":"header1.h"},{"name":"header2.h","checks":"google-explicit-constructor"},{"name":"2/"}]' %s -- -I %S/Inputs/suppress-checks-filter 2>&1 | FileCheck %s
+
+#include "1/header1.h"
+// CHECK-NOT: header1.h:{{.*}} warning
+
+#include "1/header2.h"
+// CHECK-NOT: 1/header2.h:{{.*}} warning: single-argument constructors {{.*}}
+// CHECK: 1/header2.h:{{.*}} warning: redundant cast to the same type {{.*}}
+
+#include "2/header3.h"
+// CHECK-NOT: 2/header3.h:{{.*}} warning: single-argument constructors
+
+#include "2/header4.h"
+// CHECK-NOT: 2/header4.h:{{.*}} warning: single-argument constructors
+
+// CHECK: Suppressed 4 warnings (4 with suppressed checks filters)
+
Index: test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h
===
--- test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h
+++ test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h
@@ -0,0 +1,2 @@
+class A4 { A4(int); };
+
Index: test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h
===
--- test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h
+++ test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h
@@ -0,0 +1,2 @@
+class A3 { A3(int); };
+
Index: test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h
===
--- test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h
+++ test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h
@@ -0,0 +1,6 @@
+class A2 { A2(int); };
+
+class B2 {
+  B2(int , int ) { Out = (int)In; }
+};
+
Index: test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h
===
--- test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h
+++ test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h
@@ -0,0 +1,2 @@
+class A1 { A1(int); };
+
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -105,6 +105,20 @@
cl::init(""),
cl::cat(ClangTidyCategory));
 
+static cl::opt
+SuppressWarningsFromHeaders("suppress-checks-filter", cl::desc(R"(
+Suppress diagnostics from files whose names match
+provided regular expression. If a list of checks
+is specified, only diagnostics produces by these
+checks will be suppressed. The format of
+the argument is a JSON array of objects:
+[

[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 77238.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Added isNullPtrZero to TargetCodeGenInfo.


https://reviews.llvm.org/D26196

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,414 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test default initialization of pointers.
+
+// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *p1;
+
+// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *p2;
+
+// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *p3;
+
+// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *p4;
+
+// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *p5;
+
+// Test default initialization of sturcture.
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4
+StructTy1 S1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 4
+StructTy2 S2;
+
+// Test default initialization of array.
+// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }], align 4
+StructTy1 A1[2];
+
+// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 4
+StructTy2 A2[2];
+
+// Test comparison with 0.
+
+// CHECK-LABEL: cmp_private
+// CHECK: icmp eq i8* %p, addrspacecast (i8 addrspace(4)* null to i8*)
+void cmp_private(private char* p) {
+  if (p != 0)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_local
+// CHECK: icmp eq i8 addrspace(3)* %p, addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*)
+void cmp_local(local char* p) {
+  if (p != 0)
+*p = 0;
+}
+
+// CHECK-LABEL: cmp_global
+// CHECK: icmp eq i8 

[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Evgeniy Stepanov via cfe-commits
eugenis accepted this revision.
eugenis added a reviewer: eugenis.
eugenis added a comment.

LGTM


https://reviews.llvm.org/D26385



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


[PATCH] D24431: CodeGen: Start using inrange annotations on vtable getelementptr.

2016-11-08 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

Ping


https://reviews.llvm.org/D24431



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Dan Albert via cfe-commits
danalbert accepted this revision.
danalbert added a reviewer: danalbert.
danalbert added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D26385



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines updated this revision to Diff 77236.
srhines added a comment.

Switched to conditionally defining __ANDROID_API__ instead.


https://reviews.llvm.org/D26385

Files:
  lib/Basic/Targets.cpp
  test/Driver/android-targets.cpp

Index: test/Driver/android-targets.cpp
===
--- /dev/null
+++ test/Driver/android-targets.cpp
@@ -0,0 +1,83 @@
+// Test API-related defines for various Android targets.
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target arm-linux-androideabi20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target aarch64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target i686-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target x86_64-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mipsel-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+//
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android \
+// RUN:   | FileCheck %s
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android19 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL19
+// RUN: %clang %s -emit-llvm -S -c -o - \
+// RUN: -target mips64el-linux-android20 \
+// RUN:   | FileCheck %s -check-prefix=LEVEL20
+
+// CHECK: __ANDROID__defined
+// LEVEL19: __ANDROID__defined
+// LEVEL20: __ANDROID__defined
+#ifdef __ANDROID__
+void __ANDROID__defined(void) {}
+#endif
+
+// CHECK-NOT: __ANDROID_API__defined
+// LEVEL19: __ANDROID_API__defined
+// LEVEL20: __ANDROID_API__defined
+#ifdef __ANDROID_API__
+void __ANDROID_API__defined(void) {}
+int android_api = __ANDROID_API__;
+#endif
+
+// CHECK-NOT: __ANDROID_API__20
+// LEVEL19-NOT: __ANDROID_API__20
+// LEVEL20: __ANDROID_API__20
+#if __ANDROID_API__ >= 20
+void __ANDROID_API__20(void) {}
+#endif
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -465,6 +465,8 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
+  if (Maj)
+Builder.defineMacro("__ANDROID_API__", Twine(Maj));
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Haojian Wu via cfe-commits
hokein added a comment.

One more comment, otherwise looks good.




Comment at: change-namespace/ChangeNamespace.cpp:275
+   (DiffOldNsSplitted.empty() ? "-" : DiffOldNsSplitted.front()))
+  .str();
+  auto IsInMovedNs =

Using an invalid name `-` is not an elegant solution to me. Is it possible to 
avoid it? 
Maybe we can explicitly specify `IsVisibleInNewNs` using the code like:

```
Optional IsVisibleInNewNs = 
IsInMovedNs;
if (!DiffOldNsSplitted.empty() )  {
  std::string Prefix = ... 
  IsVisibleInNewNs = anyOf(*IsVisibleInNewNs, 
unless(hasAncestor(namespaceDecl(hasName(Prefix));
}
```


https://reviews.llvm.org/D25771



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


[PATCH] D26236: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.

2016-11-08 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286281: [clang-move] Move all code from old.h/cc directly 
when moving all class… (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D26236?vs=77223=77233#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26236

Files:
  clang-tools-extra/trunk/clang-move/ClangMove.cpp
  clang-tools-extra/trunk/clang-move/ClangMove.h
  clang-tools-extra/trunk/test/clang-move/Inputs/test.h
  clang-tools-extra/trunk/test/clang-move/move-class.cpp
  clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Index: clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
===
--- clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
+++ clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp
@@ -173,24 +173,25 @@
  "} // namespace a\n";
 
 std::map
-runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec ) {
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec ,
+   const char *const Header = TestHeader,
+   const char *const CC = TestCC) {
   clang::RewriterTestContext Context;
 
   std::map FileToFileID;
   std::vector> FileToSourceText = {
-  {TestHeaderName, TestHeader}, {TestCCName, TestCC}};
+  {TestHeaderName, Header}, {TestCCName, CC}};
 
   auto CreateFiles = [, , ](
   llvm::StringRef Name, llvm::StringRef Code) {
 if (!Name.empty()) {
-  FileToSourceText.emplace_back(Name, Code);
   FileToFileID[Name] = Context.createInMemoryFile(Name, Code);
 }
   };
   CreateFiles(Spec.NewCC, "");
   CreateFiles(Spec.NewHeader, "");
-  CreateFiles(Spec.OldHeader, TestHeader);
-  CreateFiles(Spec.OldCC, TestCC);
+  CreateFiles(Spec.OldHeader, Header);
+  CreateFiles(Spec.OldCC, CC);
 
   std::map FileToReplacements;
   llvm::SmallString<128> InitialDirectory;
@@ -201,7 +202,7 @@
   Spec, FileToReplacements, InitialDirectory.str(), "LLVM");
 
   tooling::runToolOnCodeWithArgs(
-  Factory->create(), TestCC, {"-std=c++11", "-fparse-all-comments"},
+  Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"},
   TestCCName, "clang-move", std::make_shared(),
   FileToSourceText);
   formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
@@ -263,6 +264,79 @@
   EXPECT_EQ(0u, Results.size());
 }
 
+TEST(ClangMove, MoveAll) {
+  std::vector TestHeaders = {
+"class A {\npublic:\n  int f();\n};",
+// forward declaration.
+"class B;\nclass A {\npublic:\n  int f();\n};",
+// template forward declaration.
+"template  class B;\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nusing namespace a;\nclass A {\npublic:\n  int f();\n};",
+  };
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  Spec.Names.push_back("A");
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+EXPECT_EQ("", Results[Spec.OldHeader]);
+EXPECT_EQ("", Results[Spec.OldCC]);
+  }
+}
+
+TEST(ClangMove, MoveAllMultipleClasses) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  std::vector TestHeaders = {
+"class C;\nclass A {\npublic:\n  int f();\n};\nclass B {};",
+"class C;\nclass B;\nclass A {\npublic:\n  int f();\n};\nclass B {};",
+  };
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  Spec.Names = {std::string("A"), std::string("B")};
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+EXPECT_EQ("", Results[Spec.OldHeader]);
+EXPECT_EQ("", Results[Spec.OldCC]);
+  }
+}
+
+TEST(ClangMove, DontMoveAll) {
+  const char ExpectedHeader[] = "#ifndef NEW_FOO_H\n"
+"#define NEW_FOO_H\n"
+"class A {\npublic:\n  int f();\n};\n"
+"#endif // NEW_FOO_H\n";
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  std::vector TestHeaders = {
+"typedef int Int;\nclass A {\npublic:\n  int f();\n};",
+"using Int=int;\nclass A {\npublic:\n  int f();\n};",
+"class B {};\nclass A {\npublic:\n  int f();\n};",
+"void f() {};\nclass A {\npublic:\n  int f();\n};",
+"enum Color { RED };\nclass A {\npublic:\n  int f();\n};",

[PATCH] D26415: [XRay] Support AArch64 in Clang

2016-11-08 Thread Serge Rogatch via cfe-commits
rSerge created this revision.
rSerge added reviewers: dberris, rengolin.
rSerge added subscribers: iid_iunknown, cfe-commits.
Herald added a subscriber: aemerson.

This patch adds XRay support in Clang for AArch64 target.


https://reviews.llvm.org/D26415

Files:
  lib/Driver/Tools.cpp
  test/Driver/XRay/xray-instrument-cpu.c
  test/Driver/XRay/xray-instrument-os.c


Index: test/Driver/XRay/xray-instrument-os.c
===
--- test/Driver/XRay/xray-instrument-os.c
+++ test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
 // XFAIL: -linux-
-// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;
Index: test/Driver/XRay/xray-instrument-cpu.c
===
--- test/Driver/XRay/xray-instrument-cpu.c
+++ test/Driver/XRay/xray-instrument-cpu.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
 // REQUIRES: linux
 typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4902,7 +4902,8 @@
 const char *const XRayInstrumentOption = "-fxray-instrument";
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {
   // Supported.
 } else {
   D.Diag(diag::err_drv_clang_unsupported)


Index: test/Driver/XRay/xray-instrument-os.c
===
--- test/Driver/XRay/xray-instrument-os.c
+++ test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
 // XFAIL: -linux-
-// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;
Index: test/Driver/XRay/xray-instrument-cpu.c
===
--- test/Driver/XRay/xray-instrument-cpu.c
+++ test/Driver/XRay/xray-instrument-cpu.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
 // REQUIRES: linux
 typedef int a;
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4902,7 +4902,8 @@
 const char *const XRayInstrumentOption = "-fxray-instrument";
 if (Triple.getOS() == llvm::Triple::Linux &&
 (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::x86_64)) {
+ Triple.getArch() == llvm::Triple::x86_64 ||
+ Triple.getArch() == llvm::Triple::aarch64)) {
   // Supported.
 } else {
   D.Diag(diag::err_drv_clang_unsupported)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D26385#589589, @eugenis wrote:

> This is a good change, but I don't think it is the right fix for PR30940. 
> Instead of handling this in the NDK, we should change *::getIRStackGuard to 
> fallback to __stack_chk_guard when targeting an old version.


Right, this is only addressing part of the problem related to that issue. I can 
probably put together a follow up to address the rest of the bug, although I am 
not all that familiar with __stack_chk_guard, so testing might be a problem.


https://reviews.llvm.org/D26385



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


[PATCH] D26410: [CodeGen] Don't emit the same global block multiple times.

2016-11-08 Thread George Burgess IV via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rjmccall.
george.burgess.iv added a subscriber: cfe-commits.

https://reviews.llvm.org/D14274 makes our constexpr evaluator more aggressive 
with some variables marked `const`. This changes how we behave on code like the 
following:

  void foo() {
void (^const block_A)(void) = ^{ return; };
get_kernel_work_group_size(block_A);
get_kernel_work_group_size(block_A);
  }

The constexpr evaluator will now give us `^{ return; }` three times (one for 
each use of `block_A`) instead of once (in `block_A`'s assignment). CodeGen 
emits a block every time it gets handed a `BlockExpr`, so we end up emitting 
the code for `^{ return; }` three times in total. We can fix this by tracking 
which global `BlockExpr`s we've already generated code for.

This seems to not happen for local `BlockExpr`s, since the constexpr fails for 
`BlockExpr`s with captures (see `PointerExprEvaluator::VisitBlockExpr` in 
lib/AST/ExprConstant.cpp). That said, I'm happy to add this uniquing code for 
`BlockExpr`s with captures if anyone wants me to.


https://reviews.llvm.org/D26410

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/block-in-ctor-dtor.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -2,6 +2,8 @@
 
 typedef void (^bl_t)(local void *);
 
+// N.B. The check here only exists to set BL_GLOBAL
+// CHECK: @block_G = {{.*}}bitcast ([[BL_GLOBAL:[^@]+@__block_literal_global(\.[0-9]+)?]]
 const bl_t block_G = (bl_t) ^ (local void *a) {};
 
 kernel void device_side_enqueue(global int *a, global int *b, int i) {
@@ -84,27 +86,23 @@
  },
  c);
 
+  // The full type of these expressions are long (and repeated elsewhere), so we
+  // capture it as part of the regex for convenience and clarity.
+  // CHECK: store void ()* bitcast ([[BL_A:[^@]+@__block_literal_global.[0-9]+]] to void ()*), void ()** %block_A
   void (^const block_A)(void) = ^{
 return;
   };
+  // CHECK: store void (i8 addrspace(2)*)* bitcast ([[BL_B:[^@]+@__block_literal_global.[0-9]+]] to void (i8 addrspace(2)*)*), void (i8 addrspace(2)*)** %block_B
   void (^const block_B)(local void *) = ^(local void *a) {
 return;
   };
 
-  // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A
-  // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
-  // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]])
+  // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* bitcast ([[BL_A]] to i8*))
   unsigned size = get_kernel_work_group_size(block_A);
-  // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)** %block_B
-  // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8*
-  // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]])
+  // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* bitcast ([[BL_B]] to i8*))
   size = get_kernel_work_group_size(block_B);
-  // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A
-  // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
-  // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]])
+  // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* bitcast ([[BL_A]] to i8*))
   size = get_kernel_preferred_work_group_size_multiple(block_A);
-  // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)* addrspace(1)* @block_G
-  // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8*
-  // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]])
+  // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* bitcast ([[BL_GLOBAL]] to i8*))
   size = get_kernel_preferred_work_group_size_multiple(block_G);
 }
Index: test/CodeGenCXX/block-in-ctor-dtor.cpp
===
--- test/CodeGenCXX/block-in-ctor-dtor.cpp
+++ test/CodeGenCXX/block-in-ctor-dtor.cpp
@@ -42,7 +42,5 @@
 // CHECK-LABEL: define internal void @___ZN4ZoneD2Ev_block_invoke_
 // CHECK-LABEL: define internal void @___ZN1XC2Ev_block_invoke
 // CHECK-LABEL: define internal void @___ZN1XC2Ev_block_invoke_
-// CHECK-LABEL: define internal void @___ZN1XC1Ev_block_invoke
-// CHECK-LABEL: define internal void @___ZN1XC1Ev_block_invoke_
 // CHECK-LABEL: define internal void @___ZN1XD2Ev_block_invoke
 // CHECK-LABEL: define internal void @___ZN1XD2Ev_block_invoke_
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -457,6 +457,10 @@
   bool isTriviallyRecursive(const FunctionDecl *F);
   

[PATCH] D22296: CodeGen: New vtable group representation: struct of vtable arrays.

2016-11-08 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

Ping


https://reviews.llvm.org/D22296



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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-08 Thread Dave Lee via cfe-commits
kastiglione updated this revision to Diff 77232.
kastiglione added a comment.

Added test


https://reviews.llvm.org/D26406

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  test/Misc/warning-flags.c
  test/SemaObjC/check-dup-objc-decls-1.m


Index: test/SemaObjC/check-dup-objc-decls-1.m
===
--- test/SemaObjC/check-dup-objc-decls-1.m
+++ test/SemaObjC/check-dup-objc-decls-1.m
@@ -35,6 +35,12 @@
 @protocol PP @end  // expected-note {{previous definition is here}}
 @protocol PP @end  // expected-warning {{duplicate protocol definition of 
'PP'}}
 
+@protocol DP @end
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wduplicate-protocol"
+@protocol DP @end
+#pragma clang diagnostic pop
+
 @interface A(Cat) @end // expected-note {{previous definition is here}}
 @interface A(Cat) @end // expected-warning {{duplicate definition of 
category 'Cat' on interface 'A'}}
 
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -739,7 +739,8 @@
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 
is ignored">;
+def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 
is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;


Index: test/SemaObjC/check-dup-objc-decls-1.m
===
--- test/SemaObjC/check-dup-objc-decls-1.m
+++ test/SemaObjC/check-dup-objc-decls-1.m
@@ -35,6 +35,12 @@
 @protocol PP @end  // expected-note {{previous definition is here}}
 @protocol PP @end  // expected-warning {{duplicate protocol definition of 'PP'}}
 
+@protocol DP @end
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wduplicate-protocol"
+@protocol DP @end
+#pragma clang diagnostic pop
+
 @interface A(Cat) @end // expected-note {{previous definition is here}}
 @interface A(Cat) @end // expected-warning {{duplicate definition of category 'Cat' on interface 'A'}}
 
Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -739,7 +739,8 @@
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">;
+def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for 

[clang-tools-extra] r286281 - [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.

2016-11-08 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Nov  8 13:55:13 2016
New Revision: 286281

URL: http://llvm.org/viewvc/llvm-project?rev=286281=rev
Log:
[clang-move] Move all code from old.h/cc directly when moving all class 
declarations from old.h.

Summary: When moving all code to new.h/cc,  these code also will be formatted 
based on the given code style.

Reviewers: ioeric

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/clang-move/ClangMove.h
clang-tools-extra/trunk/test/clang-move/Inputs/test.h
clang-tools-extra/trunk/test/clang-move/move-class.cpp
clang-tools-extra/trunk/unittests/clang-move/ClangMoveTests.cpp

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=286281=286280=286281=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Tue Nov  8 13:55:13 2016
@@ -122,13 +122,13 @@ public:
   void InclusionDirective(clang::SourceLocation HashLoc,
   const clang::Token & /*IncludeTok*/,
   StringRef FileName, bool IsAngled,
-  clang::CharSourceRange /*FilenameRange*/,
+  clang::CharSourceRange FilenameRange,
   const clang::FileEntry * /*File*/,
   StringRef SearchPath, StringRef /*RelativePath*/,
   const clang::Module * /*Imported*/) override {
 if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc)))
   MoveTool->addIncludes(FileName, IsAngled, SearchPath,
-FileEntry->getName(), SM);
+FileEntry->getName(), FilenameRange, SM);
   }
 
 private:
@@ -321,20 +321,42 @@ void ClangMoveTool::registerMatchers(ast
 return;
   }
 
-  auto InOldHeader = isExpansionInFile(
-  MakeAbsolutePath(OriginalRunningDirectory, Spec.OldHeader));
-  auto InOldCC =
-  isExpansionInFile(MakeAbsolutePath(OriginalRunningDirectory, 
Spec.OldCC));
+  auto InOldHeader = isExpansionInFile(makeAbsolutePath(Spec.OldHeader));
+  auto InOldCC = isExpansionInFile(makeAbsolutePath(Spec.OldCC));
   auto InOldFiles = anyOf(InOldHeader, InOldCC);
   auto InMovedClass =
   hasOutermostEnclosingClass(cxxRecordDecl(*InMovedClassNames));
 
+  auto ForwardDecls =
+  cxxRecordDecl(unless(anyOf(isImplicit(), isDefinition(;
+
+  
//
+  // Matchers for old header
+  
//
+  // Match all top-level named declarations (e.g. function, variable, enum) in
+  // old header, exclude forward class declarations and namespace declarations.
+  //
+  // The old header which contains only one declaration being moved and forward
+  // declarations is considered to be moved totally.
+  auto AllDeclsInHeader = namedDecl(
+  unless(ForwardDecls), unless(namespaceDecl()),
+  unless(usingDirectiveDecl()), // using namespace decl.
+  unless(classTemplateDecl(has(ForwardDecls))), // template forward decl.
+  InOldHeader,
+  hasParent(decl(anyOf(namespaceDecl(), translationUnitDecl();
+  Finder->addMatcher(AllDeclsInHeader.bind("decls_in_header"), this);
+  // Match forward declarations in old header.
+  Finder->addMatcher(namedDecl(ForwardDecls, InOldHeader).bind("fwd_decl"),
+ this);
+
+  
//
+  // Matchers for old files, including old.h/old.cc
+  
//
   // Match moved class declarations.
   auto MovedClass = cxxRecordDecl(
   InOldFiles, *InMovedClassNames, isDefinition(),
   hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl(;
   Finder->addMatcher(MovedClass.bind("moved_class"), this);
-
   // Match moved class methods (static methods included) which are defined
   // outside moved class declaration.
   Finder->addMatcher(
@@ -343,6 +365,9 @@ void ClangMoveTool::registerMatchers(ast
   .bind("class_method"),
   this);
 
+  
//
+  // Matchers for old cc
+  
//
   // Match static member variable definition of the moved class.
   Finder->addMatcher(
   varDecl(InMovedClass, InOldCC, isDefinition(), isStaticDataMember())
@@ -374,16 +399,13 @@ void ClangMoveTool::registerMatchers(ast
  varDecl(IsOldCCStaticDefinition)))
  .bind("static_decls"),
   

[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 77228.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressed comments.


https://reviews.llvm.org/D25771

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- unittests/change-namespace/ChangeNamespaceTests.cpp
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -313,8 +313,8 @@
  "}\n"
  "namespace nb {\n"
  "using nc::SAME;\n"
- "using YO = nc::SAME;\n"
- "typedef nc::SAME IDENTICAL;\n"
+ "using YO = nd::SAME;\n"
+ "typedef nd::SAME IDENTICAL;\n"
  "void f(nd::SAME Same) {}\n"
  "} // namespace nb\n"
  "} // namespace na\n";
@@ -333,93 +333,14 @@
  "namespace x {\n"
  "namespace y {\n"
  "using ::na::nc::SAME;\n"
- "using YO = na::nc::SAME;\n"
- "typedef na::nc::SAME IDENTICAL;\n"
+ "using YO = na::nd::SAME;\n"
+ "typedef na::nd::SAME IDENTICAL;\n"
  "void f(na::nd::SAME Same) {}\n"
  "} // namespace y\n"
  "} // namespace x\n";
   EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
 }
 
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInFunction) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() {\n"
- "  using glob::Glob;\n"
- "  Glob g;\n"
- "}\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() {\n"
- "  using ::glob::Glob;\n"
- "  glob::Glob g;\n"
- "}\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingShadowDeclInGlobal) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is UsingShadowDecl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using glob::Glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
-TEST_F(ChangeNamespaceTest, UsingNamespace) {
-  std::string Code = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "namespace na {\n"
- "namespace nb {\n"
- "void f() { Glob g; }\n"
- "} // namespace nb\n"
- "} // namespace na\n";
-
-  // FIXME: don't add namespace qualifier when there is "using namespace" decl.
-  std::string Expected = "namespace glob {\n"
- "class Glob {};\n"
- "}\n"
- "using namespace glob;\n"
- "\n"
- "namespace x {\n"
- "namespace y {\n"
- "void f() { glob::Glob g; }\n"
- "} // namespace y\n"
- "} // namespace x\n";
-  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
-}
-
 TEST_F(ChangeNamespaceTest, TypeInNestedNameSpecifier) {
   std::string Code =
   "namespace na {\n"
@@ -625,6 +546,359 @@
   EXPECT_EQ(format(Expected), 

Re: r286243 - [clang-format] Remove (SourceManager, FileID) variants

2016-11-08 Thread Daniel Jasper via cfe-commits
Fixed in r286279.

On Tue, Nov 8, 2016 at 10:45 AM, Galina Kistanova 
wrote:

> Hello Daniel,
>
> This commit broke at least one of our builders:
> http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/234
>
> Please have a look at this?
>
> Thanks
>
> Galina
>
> On Tue, Nov 8, 2016 at 8:11 AM, Daniel Jasper via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: djasper
>> Date: Tue Nov  8 10:11:33 2016
>> New Revision: 286243
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=286243=rev
>> Log:
>> [clang-format] Remove (SourceManager, FileID) variants
>>
>> In Format, remove the reformat() and clean() functions taking a
>> SourceManager
>> and a FileID. Keep the versions taking StringRef Code.
>>
>> - there was duplicated functionality
>> - the FileID versions were harder to use
>> - the clean() version is dead code anyways
>>
>> Patch by Krasimir Georgiev. Thank you.
>>
>> Modified:
>> cfe/trunk/include/clang/Format/Format.h
>> cfe/trunk/lib/Format/Format.cpp
>> cfe/trunk/lib/Index/CommentToXML.cpp
>>
>> Modified: cfe/trunk/include/clang/Format/Format.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Format/Format.h?rev=286243=286242=286243=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Format/Format.h (original)
>> +++ cfe/trunk/include/clang/Format/Format.h Tue Nov  8 10:11:33 2016
>> @@ -794,7 +794,7 @@ llvm::Expected
>>  cleanupAroundReplacements(StringRef Code, const tooling::Replacements
>> ,
>>const FormatStyle );
>>
>> -/// \brief Reformats the given \p Ranges in the file \p ID.
>> +/// \brief Reformats the given \p Ranges in \p Code.
>>  ///
>>  /// Each range is extended on either end to its next bigger logic unit,
>> i.e.
>>  /// everything that might influence its formatting or might be
>> influenced by its
>> @@ -806,31 +806,15 @@ cleanupAroundReplacements(StringRef Code
>>  /// If ``IncompleteFormat`` is non-null, its value will be set to true
>> if any
>>  /// of the affected ranges were not formatted due to a non-recoverable
>> syntax
>>  /// error.
>> -tooling::Replacements reformat(const FormatStyle ,
>> -   SourceManager , FileID ID,
>> -   ArrayRef Ranges,
>> -   bool *IncompleteFormat = nullptr);
>> -
>> -/// \brief Reformats the given \p Ranges in \p Code.
>> -///
>> -/// Otherwise identical to the reformat() function using a file ID.
>>  tooling::Replacements reformat(const FormatStyle , StringRef Code,
>> ArrayRef Ranges,
>> StringRef FileName = "",
>> bool *IncompleteFormat = nullptr);
>>
>> -/// \brief Clean up any erroneous/redundant code in the given \p Ranges
>> in the
>> -/// file \p ID.
>> -///
>> -/// Returns the ``Replacements`` that clean up all \p Ranges in the file
>> \p ID.
>> -tooling::Replacements cleanup(const FormatStyle ,
>> -  SourceManager , FileID ID,
>> -  ArrayRef Ranges);
>> -
>>  /// \brief Clean up any erroneous/redundant code in the given \p Ranges
>> in \p
>>  /// Code.
>>  ///
>> -/// Otherwise identical to the cleanup() function using a file ID.
>> +/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
>>  tooling::Replacements cleanup(const FormatStyle , StringRef Code,
>>ArrayRef Ranges,
>>StringRef FileName = "");
>>
>> Modified: cfe/trunk/lib/Format/Format.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/For
>> mat.cpp?rev=286243=286242=286243=diff
>> 
>> ==
>> --- cfe/trunk/lib/Format/Format.cpp (original)
>> +++ cfe/trunk/lib/Format/Format.cpp Tue Nov  8 10:11:33 2016
>> @@ -1719,18 +1719,6 @@ cleanupAroundReplacements(StringRef Code
>>return processReplacements(Cleanup, Code, NewReplaces, Style);
>>  }
>>
>> -tooling::Replacements reformat(const FormatStyle , SourceManager
>> ,
>> -   FileID ID, ArrayRef
>> Ranges,
>> -   bool *IncompleteFormat) {
>> -  FormatStyle Expanded = expandPresets(Style);
>> -  if (Expanded.DisableFormat)
>> -return tooling::Replacements();
>> -
>> -  Environment Env(SM, ID, Ranges);
>> -  Formatter Format(Env, Expanded, IncompleteFormat);
>> -  return Format.process();
>> -}
>> -
>>  tooling::Replacements reformat(const FormatStyle , StringRef Code,
>> ArrayRef Ranges,
>> StringRef FileName, bool
>> *IncompleteFormat) {
>> @@ -1760,13 +1748,6 @@ tooling::Replacements reformat(const For
>>return Format.process();
>>  }
>>
>> -tooling::Replacements cleanup(const FormatStyle , SourceManager
>> ,
>> 

[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

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

> and generally frowned upon in many codebases (e.g. LLVM)

Should it still be a part of google/? The old check was enforcing a part of the 
Google C++ style guide, but the new one seems to be somewhat broader. Am I 
mistaken?


https://reviews.llvm.org/D23130



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


r286279 - Remove FormatContext from libClang as it is now unused.

2016-11-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  8 13:47:19 2016
New Revision: 286279

URL: http://llvm.org/viewvc/llvm-project?rev=286279=rev
Log:
Remove FormatContext from libClang as it is now unused.

Modified:
cfe/trunk/include/clang/Index/CommentToXML.h
cfe/trunk/lib/Index/CommentToXML.cpp

Modified: cfe/trunk/include/clang/Index/CommentToXML.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/CommentToXML.h?rev=286279=286278=286279=diff
==
--- cfe/trunk/include/clang/Index/CommentToXML.h (original)
+++ cfe/trunk/include/clang/Index/CommentToXML.h Tue Nov  8 13:47:19 2016
@@ -22,12 +22,7 @@ class HTMLTagComment;
 }
 
 namespace index {
-class SimpleFormatContext;
-
 class CommentToXMLConverter {
-  std::unique_ptr FormatContext;
-  unsigned FormatInMemoryUniqueId;
-
 public:
   CommentToXMLConverter();
   ~CommentToXMLConverter();

Modified: cfe/trunk/lib/Index/CommentToXML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=286279=286278=286279=diff
==
--- cfe/trunk/lib/Index/CommentToXML.cpp (original)
+++ cfe/trunk/lib/Index/CommentToXML.cpp Tue Nov  8 13:47:19 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 #include "clang/Index/CommentToXML.h"
-#include "SimpleFormatContext.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Comment.h"
@@ -531,12 +530,8 @@ public:
   CommentASTToXMLConverter(const FullComment *FC,
SmallVectorImpl ,
const CommandTraits ,
-   const SourceManager ,
-   SimpleFormatContext ,
-   unsigned FUID) :
-  FC(FC), Result(Str), Traits(Traits), SM(SM),
-  FormatRewriterContext(SFC),
-  FormatInMemoryUniqueId(FUID) { }
+   const SourceManager ) :
+  FC(FC), Result(Str), Traits(Traits), SM(SM) { }
 
   // Inline content.
   void visitTextComment(const TextComment *C);
@@ -574,8 +569,6 @@ private:
 
   const CommandTraits 
   const SourceManager 
-  SimpleFormatContext 
-  unsigned FormatInMemoryUniqueId;
 };
 
 void getSourceTextOfDeclaration(const DeclInfo *ThisDecl,
@@ -596,18 +589,13 @@ void CommentASTToXMLConverter::formatTex
   StringRef StringDecl(Declaration.c_str(), Declaration.size());
 
   // Formatter specific code.
-  // Form a unique in memory buffer name.
-  SmallString<128> Filename;
-  Filename += "xmldecl";
-  Filename += llvm::utostr(FormatInMemoryUniqueId);
-  Filename += ".xd";
   unsigned Offset = 0;
   unsigned Length = Declaration.size();
 
   bool IncompleteFormat = false;
   tooling::Replacements Replaces =
   reformat(format::getLLVMStyle(), StringDecl,
-   tooling::Range(Offset, Length), Filename, );
+   tooling::Range(Offset, Length), "xmldecl.xd", 
);
   auto FormattedStringDecl = applyAllReplacements(StringDecl, Replaces);
   if (static_cast(FormattedStringDecl)) {
 Declaration = *FormattedStringDecl;
@@ -1127,7 +1115,7 @@ void CommentASTToXMLConverter::appendToR
   Result << "]]>";
 }
 
-CommentToXMLConverter::CommentToXMLConverter() : FormatInMemoryUniqueId(0) {}
+CommentToXMLConverter::CommentToXMLConverter() {}
 CommentToXMLConverter::~CommentToXMLConverter() {}
 
 void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC,
@@ -1149,14 +1137,7 @@ void CommentToXMLConverter::convertHTMLT
 void CommentToXMLConverter::convertCommentToXML(const FullComment *FC,
 SmallVectorImpl ,
 const ASTContext ) {
-  if (!FormatContext || (FormatInMemoryUniqueId % 1000) == 0) {
-// Create a new format context, or re-create it after some number of
-// iterations, so the buffers don't grow too large.
-FormatContext.reset(new SimpleFormatContext(Context.getLangOpts()));
-  }
-
   CommentASTToXMLConverter Converter(FC, XML, 
Context.getCommentCommandTraits(),
- Context.getSourceManager(), 
*FormatContext,
- FormatInMemoryUniqueId++);
+ Context.getSourceManager());
   Converter.visit(FC);
 }


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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

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

> It is defines with a value of 0. This allows you to actually do something 
> better, IMO.

Can we stick with undefined? That's historically how things have been, and I'm 
sure there's code out there depending on that (I had actually written a test 
that would depend on this a few weeks ago).

If we do want to do this, we're going to have to redo the legacy headers as 
they current define this unconditionally (`-Wmacro-redefined`). I suppose we 
probably don't have to worry about people using a new clang with an old NDK, so 
we could just change that, but I don't really see an argument for setting it to 
zero.


https://reviews.llvm.org/D26385



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


Re: r285946 - Using release to free memory is at best confusing -- one would expect

2016-11-08 Thread David Blaikie via cfe-commits
Ah, I see - your follow up in 285950 mentions that this unique_ptr was
always null, so none of it really mattered/did anything.

On Tue, Nov 8, 2016 at 11:42 AM David Blaikie  wrote:

> On Thu, Nov 3, 2016 at 10:52 AM Chandler Carruth via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: chandlerc
> Date: Thu Nov  3 12:42:32 2016
> New Revision: 285946
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285946=rev
> Log:
> Using release to free memory is at best confusing -- one would expect
> that its result is in fact used. Instead, use reset.
>
>
> Perhaps I'm missing something/perhaps you could provide some more
> context/detail: release() wouldn't've free'd memory, it would've leaked it,
> right? (seems more than just confusing, but actually wrong - so I'm
> confused by your description)
>
>
>
> This was pointed out by PVS-Studio.
>
> Modified:
> cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
>
> Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285946=285945=285946=diff
>
> ==
> --- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original)
> +++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov  3
> 12:42:32 2016
> @@ -43,7 +43,7 @@ VerifyDiagnosticConsumer::~VerifyDiagnos
>assert(!CurrentPreprocessor && "CurrentPreprocessor should be
> invalid!");
>SrcManager = nullptr;
>CheckDiagnostics();
> -  Diags.takeClient().release();
> +  Diags.takeClient().reset();
>  }
>
>  #ifndef NDEBUG
>
>
> ___
> 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] D26373: [analyzer] Provide Contains() on ImmutableMap program state partial trait.

2016-11-08 Thread Dominic Chen via cfe-commits
ddcc added a comment.

Even though there isn't a performance difference, I think it is semantically 
clearer since it is explicit that the value is unneeded.

The interface of ProgramState provides a `contains()` function that calls into 
`Contains()` of the underlying partial traits as part of its implementation. 
That function is present for `ImmutableSet` and `ImmutableList`, so it is 
inconsistent that `ImmutableMap` doesn't have it. I've been working on a Z3 
constraint backend that uses this, though the implementation has been trickier 
than I expected.


https://reviews.llvm.org/D26373



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


Re: r285946 - Using release to free memory is at best confusing -- one would expect

2016-11-08 Thread David Blaikie via cfe-commits
On Thu, Nov 3, 2016 at 10:52 AM Chandler Carruth via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chandlerc
> Date: Thu Nov  3 12:42:32 2016
> New Revision: 285946
>
> URL: http://llvm.org/viewvc/llvm-project?rev=285946=rev
> Log:
> Using release to free memory is at best confusing -- one would expect
> that its result is in fact used. Instead, use reset.
>

Perhaps I'm missing something/perhaps you could provide some more
context/detail: release() wouldn't've free'd memory, it would've leaked it,
right? (seems more than just confusing, but actually wrong - so I'm
confused by your description)


>
> This was pointed out by PVS-Studio.
>
> Modified:
> cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
>
> Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285946=285945=285946=diff
>
> ==
> --- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original)
> +++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov  3
> 12:42:32 2016
> @@ -43,7 +43,7 @@ VerifyDiagnosticConsumer::~VerifyDiagnos
>assert(!CurrentPreprocessor && "CurrentPreprocessor should be
> invalid!");
>SrcManager = nullptr;
>CheckDiagnostics();
> -  Diags.takeClient().release();
> +  Diags.takeClient().reset();
>  }
>
>  #ifndef NDEBUG
>
>
> ___
> 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] D14274: Add alloc_size attribute to clang

2016-11-08 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 77222.
george.burgess.iv added a comment.

Rebased and made the `__builtin_object_size` code a tiny bit cleaner.

The blocks bugfix I mentioned will be up as a separate review in a few minutes. 
:)


https://reviews.llvm.org/D14274

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/alloc-size.c
  test/CodeGenCXX/alloc-size.cpp
  test/CodeGenCXX/global-init.cpp
  test/Sema/alloc-size.c
  test/SemaCXX/constant-expression-cxx11.cpp

Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -1156,7 +1156,7 @@
 constexpr int m2b = const_cast(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}}
 
 struct T { int n; };
-const T t = { 42 }; // expected-note {{declared here}}
+const T t = { 42 };
 
 constexpr int f(volatile int &) {
   return r; // expected-note {{read of volatile-qualified type 'volatile int'}}
@@ -1168,7 +1168,7 @@
   int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}}
   int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}}
   int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}}
-  int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}}
+  int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}}
 };
 
 }
Index: test/Sema/alloc-size.c
===
--- /dev/null
+++ test/Sema/alloc-size.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify
+
+void *fail1(int a) __attribute__((alloc_size)); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
+void *fail2(int a) __attribute__((alloc_size())); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
+
+void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}}
+
+void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+
+void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+
+int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}}
+
+int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to non-K functions}}
+
+void *fail11(void *a) __attribute__((alloc_size(1))); //expected-error{{'alloc_size' attribute argument may only refer to a function parameter of integer type}}
+
+void *fail12(int a) __attribute__((alloc_size("abc"))); //expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}}
+void *fail12(int a) __attribute__((alloc_size(1, "abc"))); //expected-error{{'alloc_size' attribute requires parameter 2 to be an integer constant}}
+void *fail13(int a) __attribute__((alloc_size(1U<<31))); //expected-error{{integer constant expression evaluates to value 2147483648 that cannot be represented in a 32-bit signed integer type}}
Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -18,9 +18,6 @@
 // CHECK: @__dso_handle = external global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
-// It's okay if we ever implement the IR-generation optimization to remove this.
-// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8], [7 x i8]* 
-
 // PR6205: The casts should not require global initializers
 // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
 // CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* getelementptr inbounds (%"struct.PR5974::C", %"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0)
Index: test/CodeGenCXX/alloc-size.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alloc-size.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -O0 %s -o - 2>&1 -std=c++11 | FileCheck %s
+
+namespace templates {
+void *my_malloc(int N) 

Re: r284272 - Implement no_sanitize_address for global vars

2016-11-08 Thread Aaron Ballman via cfe-commits
On Fri, Oct 14, 2016 at 3:55 PM, Douglas Katzman via cfe-commits
 wrote:
> Author: dougk
> Date: Fri Oct 14 14:55:09 2016
> New Revision: 284272
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev
> Log:
> Implement no_sanitize_address for global vars
>
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/AttributeList.h
> cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/test/CodeGen/asan-globals.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
> cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=284272=284271=284272=diff
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016
> @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl
>  def NoSanitize : InheritableAttr {
>let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
>let Args = [VariadicStringArgument<"Sanitizers">];
> -  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
> +  let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag,
> +"ExpectedFunctionMethodOrGlobalVar">;

The down-side to this change is that now every no_sanitize attribute
now appertains to a global variable, as far as its subjects go, but
really only the address sanitizer applies to global variables. I'm not
certain there's much to be done for it, but this divergence is
unfortunate. For instance, this means that misuse of no_sanitizer for
thread may tell the user the attribute appertains to global variables,
and when they fix the misuse on a global variable, they're told "just
kidding, this doesn't apply to global variables."

>let Documentation = [NoSanitizeDocs];
>let AdditionalMembers = [{
>  SanitizerMask getMask() const {
> @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr
> GCC<"no_sanitize_address">,
> GCC<"no_sanitize_thread">,
> GNU<"no_sanitize_memory">];
> -  let Subjects = SubjectList<[Function], ErrorDiag>;
> +  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
> +"ExpectedFunctionGlobalVarMethodOrProperty">;

This new diagnostic looks incorrect to me -- the subject list does not
list methods or properties, for instance.

>let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
> NoSanitizeMemoryDocs];
>let ASTNode = 0;
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14 14:55:09 
> 2016
> @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War
>"|functions, methods and blocks"
>"|functions, methods, and classes"
>"|functions, methods, and parameters"
> +  "|functions, methods, and global variables"
>"|classes"
>"|enums"
>"|variables"
>
> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?rev=284272=284271=284272=diff
> ==
> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016
> @@ -891,6 +891,7 @@ enum AttributeDeclKind {
>ExpectedFunctionMethodOrBlock,
>ExpectedFunctionMethodOrClass,
>ExpectedFunctionMethodOrParameter,
> +  ExpectedFunctionMethodOrGlobalVar,
>ExpectedClass,
>ExpectedEnum,
>ExpectedVariable,
>
> Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp?rev=284272=284271=284272=diff
> ==
> --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original)
> +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016
> @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS
>std::string QualName;
>llvm::raw_string_ostream OS(QualName);
>D.printQualifiedName(OS);
> -  reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(), IsDynInit);
> +
> +  bool IsBlacklisted = false;
> +  for (auto Attr : D.specific_attrs())

This should be const auto * and probably not use Attr (since that's a
type name).

> +if 

[PATCH] D26236: [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.

2016-11-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 77223.
hokein marked 2 inline comments as done.
hokein added a comment.

Update test to check old header.


https://reviews.llvm.org/D26236

Files:
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  test/clang-move/Inputs/test.h
  test/clang-move/move-class.cpp
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- unittests/clang-move/ClangMoveTests.cpp
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -173,24 +173,25 @@
  "} // namespace a\n";
 
 std::map
-runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec ) {
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec ,
+   const char *const Header = TestHeader,
+   const char *const CC = TestCC) {
   clang::RewriterTestContext Context;
 
   std::map FileToFileID;
   std::vector> FileToSourceText = {
-  {TestHeaderName, TestHeader}, {TestCCName, TestCC}};
+  {TestHeaderName, Header}, {TestCCName, CC}};
 
   auto CreateFiles = [, , ](
   llvm::StringRef Name, llvm::StringRef Code) {
 if (!Name.empty()) {
-  FileToSourceText.emplace_back(Name, Code);
   FileToFileID[Name] = Context.createInMemoryFile(Name, Code);
 }
   };
   CreateFiles(Spec.NewCC, "");
   CreateFiles(Spec.NewHeader, "");
-  CreateFiles(Spec.OldHeader, TestHeader);
-  CreateFiles(Spec.OldCC, TestCC);
+  CreateFiles(Spec.OldHeader, Header);
+  CreateFiles(Spec.OldCC, CC);
 
   std::map FileToReplacements;
   llvm::SmallString<128> InitialDirectory;
@@ -201,7 +202,7 @@
   Spec, FileToReplacements, InitialDirectory.str(), "LLVM");
 
   tooling::runToolOnCodeWithArgs(
-  Factory->create(), TestCC, {"-std=c++11", "-fparse-all-comments"},
+  Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"},
   TestCCName, "clang-move", std::make_shared(),
   FileToSourceText);
   formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
@@ -263,6 +264,79 @@
   EXPECT_EQ(0u, Results.size());
 }
 
+TEST(ClangMove, MoveAll) {
+  std::vector TestHeaders = {
+"class A {\npublic:\n  int f();\n};",
+// forward declaration.
+"class B;\nclass A {\npublic:\n  int f();\n};",
+// template forward declaration.
+"template  class B;\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nclass A {\npublic:\n  int f();\n};",
+"namespace a {}\nusing namespace a;\nclass A {\npublic:\n  int f();\n};",
+  };
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  Spec.Names.push_back("A");
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+EXPECT_EQ("", Results[Spec.OldHeader]);
+EXPECT_EQ("", Results[Spec.OldCC]);
+  }
+}
+
+TEST(ClangMove, MoveAllMultipleClasses) {
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  std::vector TestHeaders = {
+"class C;\nclass A {\npublic:\n  int f();\n};\nclass B {};",
+"class C;\nclass B;\nclass A {\npublic:\n  int f();\n};\nclass B {};",
+  };
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  Spec.Names = {std::string("A"), std::string("B")};
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+EXPECT_EQ("", Results[Spec.OldHeader]);
+EXPECT_EQ("", Results[Spec.OldCC]);
+  }
+}
+
+TEST(ClangMove, DontMoveAll) {
+  const char ExpectedHeader[] = "#ifndef NEW_FOO_H\n"
+"#define NEW_FOO_H\n"
+"class A {\npublic:\n  int f();\n};\n"
+"#endif // NEW_FOO_H\n";
+  const char Code[] = "#include \"foo.h\"\nint A::f() { return 0; }";
+  std::vector TestHeaders = {
+"typedef int Int;\nclass A {\npublic:\n  int f();\n};",
+"using Int=int;\nclass A {\npublic:\n  int f();\n};",
+"class B {};\nclass A {\npublic:\n  int f();\n};",
+"void f() {};\nclass A {\npublic:\n  int f();\n};",
+"enum Color { RED };\nclass A {\npublic:\n  int f();\n};",
+  };
+  move::ClangMoveTool::MoveDefinitionSpec Spec;
+  Spec.Names.push_back("A");
+  Spec.OldHeader = "foo.h";
+  Spec.OldCC = "foo.cc";
+  Spec.NewHeader = "new_foo.h";
+  Spec.NewCC = "new_foo.cc";
+  for (const auto& Header : TestHeaders) {
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(ExpectedHeader, 

[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CodeGenTypes.cpp:743
+auto NullPtr = CGM.getNullPtr(LLPT, T);
+return isa(NullPtr);
+  }

tony-tye wrote:
> Is this correct if the target does not represent a NULL pointer as the 
> address with value 0? Or should this be asking the target if this null 
> pointer is represented by an address value of 0?
Currently this is correct even if the target does not represent a null pointer 
as address with value 0. The purpose of this line is to check if NullPtr has 
zero value at compile time. In LLVM checking whether a pointer having zero 
value at compile time is by checking if it is ConstantPointerNull.

However, if in the future LLVM no longer assumes ConstantPointerNull having 
zero value, then this will become incorrect. To be future proof, I think I'd 
better add a member function isPtrZero to TargetCodeGenInfo and use it to check 
if a pointer has zero value.


https://reviews.llvm.org/D26196



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Evgeniy Stepanov via cfe-commits
eugenis added a comment.

This is a good change, but I don't think it is the right fix for PR30940. 
Instead of handling this in the NDK, we should change *::getIRStackGuard to 
fallback to __stack_chk_guard when targeting an old version.


https://reviews.llvm.org/D26385



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


Re: r284272 - Implement no_sanitize_address for global vars

2016-11-08 Thread Douglas Katzman via cfe-commits
oh, sorry for missing this email.
I'll say "no" - I was hoping you'd audit it!

jyknight looked at it and gave me the suggestion to fail the attribute
parsing if, in the non-deprecated syntax, _any_ of the no_sanitize
modifiers are inapplicable to global vars.

On Tue, Oct 25, 2016 at 7:19 PM, Kostya Serebryany  wrote:

> ping
>
> On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryany  wrote:
>
>> Did you code-review this?
>> (sorry if I missed it)
>>
>> On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: dougk
>>> Date: Fri Oct 14 14:55:09 2016
>>> New Revision: 284272
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev
>>> Log:
>>> Implement no_sanitize_address for global vars
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/Attr.td
>>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> cfe/trunk/include/clang/Sema/AttributeList.h
>>> cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
>>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>> cfe/trunk/test/CodeGen/asan-globals.cpp
>>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>>> cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/Attr.td?rev=284272=284271=284272=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>>> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016
>>> @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl
>>>  def NoSanitize : InheritableAttr {
>>>let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
>>>let Args = [VariadicStringArgument<"Sanitizers">];
>>> -  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
>>> +  let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar],
>>> ErrorDiag,
>>> +"ExpectedFunctionMethodOrGlobalVar">;
>>>let Documentation = [NoSanitizeDocs];
>>>let AdditionalMembers = [{
>>>  SanitizerMask getMask() const {
>>> @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr
>>> GCC<"no_sanitize_address">,
>>> GCC<"no_sanitize_thread">,
>>> GNU<"no_sanitize_memory">];
>>> -  let Subjects = SubjectList<[Function], ErrorDiag>;
>>> +  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
>>> +"ExpectedFunctionGlobalVarMethodOrProperty">;
>>>let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
>>> NoSanitizeMemoryDocs];
>>>let ASTNode = 0;
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14
>>> 14:55:09 2016
>>> @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War
>>>"|functions, methods and blocks"
>>>"|functions, methods, and classes"
>>>"|functions, methods, and parameters"
>>> +  "|functions, methods, and global variables"
>>>"|classes"
>>>"|enums"
>>>"|variables"
>>>
>>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Sema/AttributeList.h?rev=284272=284271=284272=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
>>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09
>>> 2016
>>> @@ -891,6 +891,7 @@ enum AttributeDeclKind {
>>>ExpectedFunctionMethodOrBlock,
>>>ExpectedFunctionMethodOrClass,
>>>ExpectedFunctionMethodOrParameter,
>>> +  ExpectedFunctionMethodOrGlobalVar,
>>>ExpectedClass,
>>>ExpectedEnum,
>>>ExpectedVariable,
>>>
>>> Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Sa
>>> nitizerMetadata.cpp?rev=284272=284271=284272=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016
>>> @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS
>>>std::string QualName;
>>>llvm::raw_string_ostream OS(QualName);
>>>D.printQualifiedName(OS);
>>> -  reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(),
>>> IsDynInit);
>>> +
>>> +  bool IsBlacklisted = false;
>>> +  for (auto Attr : D.specific_attrs())
>>> +if (Attr->getMask() & 

[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-08 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/google/GlobalNamesCheck.cpp:77
+}
+diag(
+D->getLocStart(),

Is this formatting that clang-format generates?



Comment at: test/clang-tidy/google-global-names.cpp:13-14
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'i' declared in the global 
namespace
+extern int ii = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'ii' declared in the global 
namespace
+

aaron.ballman wrote:
> bkramer wrote:
> > aaron.ballman wrote:
> > > This strikes me as being intentional enough to warrant not diagnosing 
> > > because of the `extern` keyword.
> > The only case I see where this pattern is valuable is interfacing with C 
> > code. Not sure yet if we want to allow that or enforce extern "C" instead. 
> > Ideas?
> > 
> > an extern global in the global namespace still feels like something we 
> > should warn on :|
> Yet externs in the global namespace do happen for valid reasons (such as not 
> breaking ABIs by putting the extern definition into a namespace or changing 
> the language linkage) -- I'm trying to think of ways we can allow the user to 
> silence this diagnostic in those cases. I feel like in cases where the user 
> writes "extern", they're explicitly specifying their intent and that doesn't 
> seem like a case to warn them about, in some regards. It would give us two 
> ways to silence the diagnostic (well, three, but two are morally close 
> enough):
> 
> 1) Put it into a namespace
> 2) Slap `extern` on it if it is global for C++ compatibility (such as ABIs)
> 3) Slap `extern "C"` on it if it global for C compatibility
> 
> I suppose we could require `extern "C++"` instead of `extern`, but I don't 
> think that's a particularly common use of the language linkage specifier?
I still think that a user explicitly writing 'extern' is expecting external 
linkage and all that goes along with it.



Comment at: test/clang-tidy/google-global-names.cpp:18
+extern "C" void g();
+extern "C" void h() {}
+

Can you also add a test:
```
extern "C++" void h2() {}
```
I believe this will diagnose, but whether it should diagnose or not, I'm less 
certain of.


https://reviews.llvm.org/D23130



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

2016-11-08 Thread Stephen Hines via cfe-commits
srhines added a comment.

In https://reviews.llvm.org/D26385#589534, @danalbert wrote:

> > This macro (along with ANDROID) should always be defined for Android 
> > targets.
>
> What if only `arm-linux-androideabi` (without a version) is specified? We 
> should be falling back to the old behavior (don't defined `__ANDROID_API__`) 
> when that happens since that's what every build system out there is going to 
> be relying on.


It is defines with a value of 0. This allows you to actually do something 
better, IMO. You can now handle old or new NDKs by seeing if this is defined to 
a special level, or 0 for no level, or not defined at all (old toolchain, build 
rules, etc.). Does that make sense?


https://reviews.llvm.org/D26385



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


[PATCH] D25771: [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.

2016-11-08 Thread Haojian Wu via cfe-commits
hokein added inline comments.



Comment at: change-namespace/ChangeNamespace.cpp:233
+ const DeclContext *DeclCtx, SourceLocation Loc) {
+  return SM.isBeforeInTranslationUnit(SM.getSpellingLoc(D->getLocation()),
+  SM.getSpellingLoc(Loc)) &&

I will create two variables for `SM.getSpellingLoc(D->getLocation())` and 
`SM.getSpellingLoc(Loc)` to avoid redundant function call.



Comment at: change-namespace/ChangeNamespace.cpp:569
+StringRef FromDeclNameRef = FromDeclName;
+if (FromDeclNameRef.consume_front(UsingNamespace->getNominatedNamespace()
+  ->getQualifiedNameAsString())) {

Shouldn't we check whether the using namespace decl is visible here? 


https://reviews.llvm.org/D25771



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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-08 Thread Dave Lee via cfe-commits
kastiglione added a comment.

@arphaman I wondered whether this called for a test. I'm happy to add one just 
like that.


https://reviews.llvm.org/D26406



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


[PATCH] D26385: Define __ANDROID_API__ for all Android builds.

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

> This macro (along with ANDROID) should always be defined for Android targets.

What if only `arm-linux-androideabi` (without a version) is specified? We 
should be falling back to the old behavior (don't defined `__ANDROID_API__`) 
when that happens since that's what every build system out there is going to be 
relying on.


https://reviews.llvm.org/D26385



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


[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread Tony Tye via cfe-commits
tony-tye added inline comments.



Comment at: lib/CodeGen/CodeGenTypes.cpp:743
+auto NullPtr = CGM.getNullPtr(LLPT, T);
+return isa(NullPtr);
+  }

Is this correct if the target does not represent a NULL pointer as the address 
with value 0? Or should this be asking the target if this null pointer is 
represented by an address value of 0?


https://reviews.llvm.org/D26196



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


[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-08 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

In https://reviews.llvm.org/D23130#588681, @alexfh wrote:

> Benjamin, what's the plan here?


I still think this check is useful, particularly for LLVM. I also don't think 
any of the existing review comments still apply or have ever applied in the 
first place, so I rebased this onto head, it's up for review again.


https://reviews.llvm.org/D23130



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


[PATCH] D23130: [Clang-tidy] Add a check for definitions in the global namespace.

2016-11-08 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 77216.
bkramer added a comment.
Herald added subscribers: modocache, mgorny.

Update to head


https://reviews.llvm.org/D23130

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/GlobalNamesCheck.cpp
  clang-tidy/google/GlobalNamesCheck.h
  clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-global-names-in-headers.rst
  docs/clang-tidy/checks/google-global-names.rst
  test/clang-tidy/google-global-names.cpp
  unittests/clang-tidy/GoogleModuleTest.cpp

Index: unittests/clang-tidy/GoogleModuleTest.cpp
===
--- unittests/clang-tidy/GoogleModuleTest.cpp
+++ unittests/clang-tidy/GoogleModuleTest.cpp
@@ -1,6 +1,6 @@
 #include "ClangTidyTest.h"
 #include "google/ExplicitConstructorCheck.h"
-#include "google/GlobalNamesInHeadersCheck.h"
+#include "google/GlobalNamesCheck.h"
 #include "gtest/gtest.h"
 
 using namespace clang::tidy::google;
@@ -56,7 +56,7 @@
   "A(Foo);"));
 }
 
-class GlobalNamesInHeadersCheckTest : public ::testing::Test {
+class GlobalNamesCheckTest : public ::testing::Test {
 protected:
   bool runCheckOnCode(const std::string , const std::string ) {
 static const char *const Header = "namespace std {\n"
@@ -69,7 +69,7 @@
 if (!StringRef(Filename).endswith(".cpp")) {
   Args.emplace_back("-xc++-header");
 }
-test::runCheckOnCode(
+test::runCheckOnCode(
 Header + Code, , Filename, Args);
 if (Errors.empty())
   return false;
@@ -81,7 +81,7 @@
   }
 };
 
-TEST_F(GlobalNamesInHeadersCheckTest, UsingDeclarations) {
+TEST_F(GlobalNamesCheckTest, UsingDeclarations) {
   EXPECT_TRUE(runCheckOnCode("using std::string;", "foo.h"));
   EXPECT_FALSE(runCheckOnCode("using std::string;", "foo.cpp"));
   EXPECT_FALSE(runCheckOnCode("namespace my_namespace {\n"
@@ -91,7 +91,7 @@
   EXPECT_FALSE(runCheckOnCode("SOME_MACRO(std::string);", "foo.h"));
 }
 
-TEST_F(GlobalNamesInHeadersCheckTest, UsingDirectives) {
+TEST_F(GlobalNamesCheckTest, UsingDirectives) {
   EXPECT_TRUE(runCheckOnCode("using namespace std;", "foo.h"));
   EXPECT_FALSE(runCheckOnCode("using namespace std;", "foo.cpp"));
   EXPECT_FALSE(runCheckOnCode("namespace my_namespace {\n"
@@ -101,7 +101,7 @@
   EXPECT_FALSE(runCheckOnCode("SOME_MACRO(namespace std);", "foo.h"));
 }
 
-TEST_F(GlobalNamesInHeadersCheckTest, RegressionAnonymousNamespace) {
+TEST_F(GlobalNamesCheckTest, RegressionAnonymousNamespace) {
   EXPECT_FALSE(runCheckOnCode("namespace {}", "foo.h"));
 }
 
Index: test/clang-tidy/google-global-names.cpp
===
--- /dev/null
+++ test/clang-tidy/google-global-names.cpp
@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s google-global-names %t
+
+void f();
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: 'f' declared in the global namespace
+void f() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: 'f' declared in the global namespace
+class F;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'F' declared in the global namespace
+class F {};
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'F' declared in the global namespace
+int i;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'i' declared in the global namespace
+extern int ii = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'ii' declared in the global namespace
+
+// No warnings below.
+extern "C" void g();
+extern "C" void h() {}
+
+#define VAR(v) v
+VAR(int m);
+
+extern "C" {
+void j() {}
+}
+
+struct Clike {
+  int i;
+};
+
+extern "C" int ik;
+extern "C" { int il; }
+
+void *operator new(__SIZE_TYPE__, int) { return 0; }
+void operator delete(void *, int) {}
+
+static void l() {}
+namespace {
+void m() {}
+}
+namespace x {
+void n() {}
+}
+
+int main() {}
Index: docs/clang-tidy/checks/google-global-names.rst
===
--- docs/clang-tidy/checks/google-global-names.rst
+++ docs/clang-tidy/checks/google-global-names.rst
@@ -1,10 +1,12 @@
-.. title:: clang-tidy - google-global-names-in-headers
+.. title:: clang-tidy - google-global-names
 
-google-global-names-in-headers
-==
+google-global-names
+===
 
-Flag global namespace pollution in header files. Right now it only triggers on
-``using`` declarations and directives.
+Flag global namespace pollution in header files.
+Right now it only triggers on using declarations and directives in header files
+and declarations and definitions of functions, classes and variables in the
+global namespace.
 
 The relevant style guide section is
 https://google.github.io/styleguide/cppguide.html#Namespaces.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 

Re: r286243 - [clang-format] Remove (SourceManager, FileID) variants

2016-11-08 Thread Galina Kistanova via cfe-commits
Hello Daniel,

This commit broke at least one of our builders:
http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/234

Please have a look at this?

Thanks

Galina

On Tue, Nov 8, 2016 at 8:11 AM, Daniel Jasper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: djasper
> Date: Tue Nov  8 10:11:33 2016
> New Revision: 286243
>
> URL: http://llvm.org/viewvc/llvm-project?rev=286243=rev
> Log:
> [clang-format] Remove (SourceManager, FileID) variants
>
> In Format, remove the reformat() and clean() functions taking a
> SourceManager
> and a FileID. Keep the versions taking StringRef Code.
>
> - there was duplicated functionality
> - the FileID versions were harder to use
> - the clean() version is dead code anyways
>
> Patch by Krasimir Georgiev. Thank you.
>
> Modified:
> cfe/trunk/include/clang/Format/Format.h
> cfe/trunk/lib/Format/Format.cpp
> cfe/trunk/lib/Index/CommentToXML.cpp
>
> Modified: cfe/trunk/include/clang/Format/Format.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Format/Format.h?rev=286243=286242=286243=diff
> 
> ==
> --- cfe/trunk/include/clang/Format/Format.h (original)
> +++ cfe/trunk/include/clang/Format/Format.h Tue Nov  8 10:11:33 2016
> @@ -794,7 +794,7 @@ llvm::Expected
>  cleanupAroundReplacements(StringRef Code, const tooling::Replacements
> ,
>const FormatStyle );
>
> -/// \brief Reformats the given \p Ranges in the file \p ID.
> +/// \brief Reformats the given \p Ranges in \p Code.
>  ///
>  /// Each range is extended on either end to its next bigger logic unit,
> i.e.
>  /// everything that might influence its formatting or might be influenced
> by its
> @@ -806,31 +806,15 @@ cleanupAroundReplacements(StringRef Code
>  /// If ``IncompleteFormat`` is non-null, its value will be set to true if
> any
>  /// of the affected ranges were not formatted due to a non-recoverable
> syntax
>  /// error.
> -tooling::Replacements reformat(const FormatStyle ,
> -   SourceManager , FileID ID,
> -   ArrayRef Ranges,
> -   bool *IncompleteFormat = nullptr);
> -
> -/// \brief Reformats the given \p Ranges in \p Code.
> -///
> -/// Otherwise identical to the reformat() function using a file ID.
>  tooling::Replacements reformat(const FormatStyle , StringRef Code,
> ArrayRef Ranges,
> StringRef FileName = "",
> bool *IncompleteFormat = nullptr);
>
> -/// \brief Clean up any erroneous/redundant code in the given \p Ranges
> in the
> -/// file \p ID.
> -///
> -/// Returns the ``Replacements`` that clean up all \p Ranges in the file
> \p ID.
> -tooling::Replacements cleanup(const FormatStyle ,
> -  SourceManager , FileID ID,
> -  ArrayRef Ranges);
> -
>  /// \brief Clean up any erroneous/redundant code in the given \p Ranges
> in \p
>  /// Code.
>  ///
> -/// Otherwise identical to the cleanup() function using a file ID.
> +/// Returns the ``Replacements`` that clean up all \p Ranges in \p Code.
>  tooling::Replacements cleanup(const FormatStyle , StringRef Code,
>ArrayRef Ranges,
>StringRef FileName = "");
>
> Modified: cfe/trunk/lib/Format/Format.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/
> Format.cpp?rev=286243=286242=286243=diff
> 
> ==
> --- cfe/trunk/lib/Format/Format.cpp (original)
> +++ cfe/trunk/lib/Format/Format.cpp Tue Nov  8 10:11:33 2016
> @@ -1719,18 +1719,6 @@ cleanupAroundReplacements(StringRef Code
>return processReplacements(Cleanup, Code, NewReplaces, Style);
>  }
>
> -tooling::Replacements reformat(const FormatStyle , SourceManager
> ,
> -   FileID ID, ArrayRef
> Ranges,
> -   bool *IncompleteFormat) {
> -  FormatStyle Expanded = expandPresets(Style);
> -  if (Expanded.DisableFormat)
> -return tooling::Replacements();
> -
> -  Environment Env(SM, ID, Ranges);
> -  Formatter Format(Env, Expanded, IncompleteFormat);
> -  return Format.process();
> -}
> -
>  tooling::Replacements reformat(const FormatStyle , StringRef Code,
> ArrayRef Ranges,
> StringRef FileName, bool
> *IncompleteFormat) {
> @@ -1760,13 +1748,6 @@ tooling::Replacements reformat(const For
>return Format.process();
>  }
>
> -tooling::Replacements cleanup(const FormatStyle , SourceManager ,
> -  FileID ID, ArrayRef
> Ranges) {
> -  Environment Env(SM, ID, Ranges);
> -  Cleaner Clean(Env, Style);
> -  return Clean.process();
> -}
> -
>  tooling::Replacements cleanup(const FormatStyle , StringRef Code,
> 

r286264 - Revert "Remove now unnecessary FormatRewriterContext."

2016-11-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  8 12:30:52 2016
New Revision: 286264

URL: http://llvm.org/viewvc/llvm-project?rev=286264=rev
Log:
Revert "Remove now unnecessary FormatRewriterContext."

This reverts commit r286262. I accidentally committed it without all of
the changes.

Modified:
cfe/trunk/lib/Index/CommentToXML.cpp

Modified: cfe/trunk/lib/Index/CommentToXML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=286264=286263=286264=diff
==
--- cfe/trunk/lib/Index/CommentToXML.cpp (original)
+++ cfe/trunk/lib/Index/CommentToXML.cpp Tue Nov  8 12:30:52 2016
@@ -535,6 +535,7 @@ public:
SimpleFormatContext ,
unsigned FUID) :
   FC(FC), Result(Str), Traits(Traits), SM(SM),
+  FormatRewriterContext(SFC),
   FormatInMemoryUniqueId(FUID) { }
 
   // Inline content.
@@ -573,6 +574,7 @@ private:
 
   const CommandTraits 
   const SourceManager 
+  SimpleFormatContext 
   unsigned FormatInMemoryUniqueId;
 };
 


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


[clang-tools-extra] r286257 - Remove mentions of clang-analyzer-alpha

2016-11-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Nov  8 12:12:56 2016
New Revision: 286257

URL: http://llvm.org/viewvc/llvm-project?rev=286257=rev
Log:
Remove mentions of clang-analyzer-alpha

Modified:
clang-tools-extra/trunk/docs/clang-tidy/index.rst
clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp

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=286257=286256=286257=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Tue Nov  8 12:12:56 2016
@@ -38,10 +38,10 @@ negative globs remove them. For example,
 
 .. code-block:: console
 
-  $ clang-tidy test.cpp -checks=-*,clang-analyzer-*,-clang-analyzer-alpha*
+  $ clang-tidy test.cpp -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*
 
 will disable all default checks (``-*``) and enable all ``clang-analyzer-*``
-checks except for ``clang-analyzer-alpha*`` ones.
+checks except for ``clang-analyzer-cplusplus*`` ones.
 
 The ``-list-checks`` option lists all the enabled checks. When used without
 ``-checks=``, it shows checks enabled by default. Use ``-checks=*`` to see all

Modified: clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp?rev=286257=286256=286257=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/static-analyzer.cpp Tue Nov  8 
12:12:56 2016
@@ -1,4 +1,4 @@
-// RUN: clang-tidy %s -checks='-*,clang-analyzer-*,-clang-analyzer-alpha*' -- 
| FileCheck %s
+// RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s
 extern void *malloc(unsigned long);
 extern void free(void *);
 


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


r286262 - Remove now unnecessary FormatRewriterContext.

2016-11-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  8 12:29:19 2016
New Revision: 286262

URL: http://llvm.org/viewvc/llvm-project?rev=286262=rev
Log:
Remove now unnecessary FormatRewriterContext.

Modified:
cfe/trunk/lib/Index/CommentToXML.cpp

Modified: cfe/trunk/lib/Index/CommentToXML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=286262=286261=286262=diff
==
--- cfe/trunk/lib/Index/CommentToXML.cpp (original)
+++ cfe/trunk/lib/Index/CommentToXML.cpp Tue Nov  8 12:29:19 2016
@@ -535,7 +535,6 @@ public:
SimpleFormatContext ,
unsigned FUID) :
   FC(FC), Result(Str), Traits(Traits), SM(SM),
-  FormatRewriterContext(SFC),
   FormatInMemoryUniqueId(FUID) { }
 
   // Inline content.
@@ -574,7 +573,6 @@ private:
 
   const CommandTraits 
   const SourceManager 
-  SimpleFormatContext 
   unsigned FormatInMemoryUniqueId;
 };
 


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


[PATCH] D26196: Add support for non-zero null pointers

2016-11-08 Thread Yaxun Liu via cfe-commits
yaxunl retitled this revision from "[WIP] Add support for non-zero null 
pointers" to "Add support for non-zero null pointers".
yaxunl updated this revision to Diff 77210.
yaxunl added a comment.

Fixed list initialization of large struct which are mostly initialized by 0 
through memset.
Added tests for casting literal 0 and non-literal integer to pointer.

There are many more places need to be changed. I am wondering if it makes sense 
to split this feature into multiple pieces, e.g. for C and OpenCL, C++, 
Objective-C, OpenMP, incrementally.


https://reviews.llvm.org/D26196

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,414 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -fno-common -emit-llvm -o - | FileCheck %s
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test default initialization of pointers.
+
+// CHECK: @p1 = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *p1;
+
+// CHECK: @p2 = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *p2;
+
+// CHECK: @p3 = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *p3;
+
+// CHECK: @p4 = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *p4;
+
+// CHECK: @p5 = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *p5;
+
+// Test default initialization of sturcture.
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+// CHECK: @S1 = local_unnamed_addr addrspace(1) global %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, align 4
+StructTy1 S1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// CHECK: @S2 = local_unnamed_addr addrspace(1) global %struct.StructTy2 zeroinitializer, align 4
+StructTy2 S2;
+
+// Test default initialization of array.
+// CHECK: @A1 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy1] [%struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }, %struct.StructTy1 { i8* addrspacecast (i8 addrspace(4)* null to i8*), i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), i8 addrspace(2)* null, i8 addrspace(1)* null, i8 addrspace(4)* null }], align 4
+StructTy1 A1[2];
+
+// CHECK: @A2 = local_unnamed_addr addrspace(1) global [2 x %struct.StructTy2] zeroinitializer, align 4
+StructTy2 A2[2];
+
+// Test comparison with 0.
+
+// CHECK-LABEL: 

[PATCH] D26304: [Power9] vector load/store with length - clang portion

2016-11-08 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

With the suggestions above, this LGTM.


https://reviews.llvm.org/D26304



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


[PATCH] D26308: [PowerPC] Add vector conversion builtins to altivec.h - clang portion

2016-11-08 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D26308



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


[PATCH] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-08 Thread Dave Lee via cfe-commits
kastiglione created this revision.
kastiglione added a reviewer: cfe-commits.

Expose a warning flag for `warn_duplicate_protocol_def`. This allows control
over the severity of duplicate protocol definitions.

For example `-Werror=duplicate-protocol` or
`#pragma clang diagnostic ignored "-Wduplicate-protocol"`.


https://reviews.llvm.org/D26406

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  test/Misc/warning-flags.c


Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -739,7 +739,8 @@
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 
is ignored">;
+def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 
is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;


Index: test/Misc/warning-flags.c
===
--- test/Misc/warning-flags.c
+++ test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (83):
+CHECK: Warnings without flags (82):
 CHECK-NEXT:   ext_excess_initializers
 CHECK-NEXT:   ext_excess_initializers_in_char_array_initializer
 CHECK-NEXT:   ext_expected_semi_decl_list
@@ -58,7 +58,6 @@
 CHECK-NEXT:   warn_drv_objc_gc_unsupported
 CHECK-NEXT:   warn_drv_pch_not_first_include
 CHECK-NEXT:   warn_dup_category_def
-CHECK-NEXT:   warn_duplicate_protocol_def
 CHECK-NEXT:   warn_enum_value_overflow
 CHECK-NEXT:   warn_expected_qualified_after_typename
 CHECK-NEXT:   warn_extraneous_char_constant
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -739,7 +739,8 @@
   "trying to recursively use %0 as superclass of %1">;
 def err_conflicting_aliasing_type : Error<"conflicting types for alias %0">;
 def warn_undef_interface : Warning<"cannot find interface declaration for %0">;
-def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">;
+def warn_duplicate_protocol_def : Warning<"duplicate protocol definition of %0 is ignored">,
+  InGroup>;
 def err_protocol_has_circular_dependency : Error<
   "protocol has circular dependency">;
 def err_undeclared_protocol : Error<"cannot find protocol declaration for %0">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D26163: [clang-format] Fix PR30527: Regression when clang-format insert spaces in [] when in template

2016-11-08 Thread Branko Kokanovic via cfe-commits
Friendly ping:)

On Mon, Oct 31, 2016 at 10:16 PM, Branko Kokanovic 
wrote:

> branko created this revision.
> branko added a reviewer: djasper.
> branko added a subscriber: cfe-commits.
> Herald added a subscriber: klimek.
>
> Actual regression was introduced in r272668. This revision fixes JS
> script, but also regress Cpp case. It manifests with spaces added when
> template is followed with array. Bug 30527 mentions case of array as a
> nested template type (foo). Fix is to detect such case and to
> prevent treating it as array initialization, but as a subscript case.
> However, before r272668, this case was treated simple because we were
> detecting it as a StartsObjCMethodExpr. Same was true for other similar
> case - array of templates (foo[]). This patch tries to address two
> problems: 1) fixing regression 2) making sure both cases (array as a nested
> type, array of templates) which were entering StartsObjCMethodExpr branch
> are handled now appropriately.
>
>
> https://reviews.llvm.org/D26163
>
> Files:
>   lib/Format/TokenAnnotator.cpp
>   unittests/Format/FormatTest.cpp
>
>
> Index: unittests/Format/FormatTest.cpp
> ===
> --- unittests/Format/FormatTest.cpp
> +++ unittests/Format/FormatTest.cpp
> @@ -11501,6 +11501,26 @@
>verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
>  }
>
> +TEST_F(FormatTest, ArrayOfTemplates) {
> +  EXPECT_EQ("auto a = new unique_ptr[10];",
> +format("auto a = new unique_ptr [ 10];"));
> +
> +  FormatStyle Spaces = getLLVMStyle();
> +  Spaces.SpacesInSquareBrackets = true;
> +  EXPECT_EQ("auto a = new unique_ptr[ 10 ];",
> +format("auto a = new unique_ptr [10];", Spaces));
> +}
> +
> +TEST_F(FormatTest, ArrayAsTemplateType) {
> +  EXPECT_EQ("auto a = unique_ptr;",
> +format("auto a = unique_ptr < Foo < Bar>[ 10]> ;"));
> +
> +  FormatStyle Spaces = getLLVMStyle();
> +  Spaces.SpacesInSquareBrackets = true;
> +  EXPECT_EQ("auto a = unique_ptr;",
> +format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
> +}
> +
>  // Since this test case uses UNIX-style file path. We disable it for MS
>  // compiler.
>  #if !defined(_MSC_VER) && !defined(__MINGW32__)
> Index: lib/Format/TokenAnnotator.cpp
> ===
> --- lib/Format/TokenAnnotator.cpp
> +++ lib/Format/TokenAnnotator.cpp
> @@ -305,7 +305,17 @@
>  FormatToken *Left = CurrentToken->Previous;
>  Left->ParentBracket = Contexts.back().ContextKind;
>  FormatToken *Parent = Left->getPreviousNonComment();
> -bool StartsObjCMethodExpr =
> +
> +// Cases where '>' is followed by '['.
> +// In C++, this can happen either in array of templates (foo[10])
> +// or when array is a nested template type
> (unique_ptr).
> +bool CppArrayTemplates =
> +Style.Language == FormatStyle::LK_Cpp && Parent &&
> +Parent->is(TT_TemplateCloser) &&
> +(Contexts.back().CanBeExpression || Contexts.back().IsExpression
> ||
> + Contexts.back().InTemplateArgument);
> +
> +bool StartsObjCMethodExpr = !CppArrayTemplates &&
>  Style.Language == FormatStyle::LK_Cpp &&
>  Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare)
> &&
>  CurrentToken->isNot(tok::l_brace) &&
> @@ -326,7 +336,7 @@
>   Parent->isOneOf(tok::l_brace, tok::comma)) {
>  Left->Type = TT_JsComputedPropertyName;
>} else if (Style.Language == FormatStyle::LK_Proto ||
> - (Parent &&
> + (!CppArrayTemplates && Parent &&
>Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser,
> tok::at,
>tok::comma, tok::l_paren, tok::l_square,
>tok::question, tok::colon,
> tok::kw_return,
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26375: [libc++] Compare to libc++ source directory for out-of-source check

2016-11-08 Thread Shoaib Meenai via cfe-commits
smeenai added a comment.

In https://reviews.llvm.org/D26375#588949, @beanz wrote:

> This patch doesn't make sense to me.
>
> In an in-tree build `CMAKE_SOURCE_DIR` would be the LLVM source directory 
> which shouldn't match your `CMAKE_BINARY_DIR`.
>
> In an out-of-tree build `CMAKE_SOURCE_DIR` would match the libcxx sure 
> directory, which shouldn't match `CMAKE_BINARY_DIR`.
>
> In an out-of-tree build `CMAKE_SOURCE_DIR` and `CMAKE_CURRENT_SOURCE_DIR`, 
> and for an in-tree build (where they would be different) there should be no 
> situation where the `CMAKE_CURRENT_SOURCE_DIR` could possibly be equal to the 
> current source directory unless the user does something *really* strange.
>
> By *really* strange I mean a workflow that involved checking out LLVM, and 
> libcxx, then configuring LLVM from inside the libcxx directory. If we're 
> looking to capture that kind of situation (configuring a build inside an 
> arbitrary directory in the source tree) our existing mechanisms are 
> insufficient in a great many ways, so I don't think we should go down that 
> path.
>
> If you think this patch is important can you please explain the specific 
> cases where this catches errors that the current code doesn't?


My reasoning was that conceptually, it makes sense for libc++ to be concerned 
about its own source tree as far as out-of-source builds go. When libc++ is 
build in-tree, LLVM's build system already takes care of ensuring that the 
build directory is not the LLVM source directory, so it's redundant for libc++ 
to do the same.

I don't feel strongly about this though, and from your comment it sounds like I 
may have just misunderstood the point of this check (i.e. the redundancy was in 
fact the intended effect), in which case I'm happy abandoning.


https://reviews.llvm.org/D26375



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


  1   2   >