[PATCH] D26218: [clang-tidy] Ignore notes along with a warning when processing NOLINT

2016-11-08 Thread Nikita Kakuev via cfe-commits
nkakuev added a comment.

@alexfh I'll fix it in a separate review.


https://reviews.llvm.org/D26218



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


[clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Nov  8 02:28:19 2016
New Revision: 286222

URL: http://llvm.org/viewvc/llvm-project?rev=286222&view=rev
Log:
[clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no 
need to disable them

Modified:
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp

Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=286222&r1=286221&r2=286222&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Tue Nov  8 
02:28:19 2016
@@ -49,10 +49,9 @@ Configuration files:
 
 )");
 
-const char DefaultChecks[] =  // Enable these checks:
+const char DefaultChecks[] =  // Enable these checks by default:
 "clang-diagnostic-*," //   * compiler diagnostics
-"clang-analyzer-*,"   //   * Static Analyzer checks
-"-clang-analyzer-alpha*"; //   * but not alpha checks: many false positives
+"clang-analyzer-*";   //   * Static Analyzer checks
 
 static cl::opt Checks("checks", cl::desc(R"(
 Comma-separated list of globs with optional '-'


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


[PATCH] D26021: [X86][AVX512][Clang] Add support for mask_{move|store|load}_s{s/d} and int2mask/mask2int intrinsics.

2016-11-08 Thread Ayman Musa via cfe-commits
aymanmus updated the summary for this revision.
aymanmus updated this revision to Diff 77158.
aymanmus added a comment.

Fix spaces and indentations.


https://reviews.llvm.org/D26021

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -516,6 +516,18 @@
   return (__m256i)__builtin_shufflevector(__A, __A , 0, 1, 2, 3);
 }
 
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_int2mask(int __a)
+{
+  return (__mmask16)__a;
+}
+
+static __inline__ int __DEFAULT_FN_ATTRS
+_mm512_mask2int(__mmask16 __a)
+{
+  return (int)__a;
+}
+
 /* Bitwise operators */
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_and_epi32(__m512i __a, __m512i __b)
@@ -9107,35 +9119,96 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
-  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
-   (__v4sf) __W,
-   (__mmask8) __U);
+  __m128 res = __A; 
+  res[0] = (__U & 1) ? __B[0] : __W[0];
+  return res; 
 }
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
 {
-  return (__m128) __builtin_ia32_movss_mask ((__v4sf) __A, (__v4sf) __B,
-   (__v4sf)
-   _mm_setzero_si128(),
-   (__mmask8) __U);
+  __m128 res = __A; 
+  res[0] = (__U & 1) ? __B[0] : 0; 
+  return res; 
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_mask_move_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B)
 {
-  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
-   (__v2df) __W,
-   (__mmask8) __U);
+  __m128d res = __A; 
+  res[0] = (__U & 1) ? __B[0] : __W[0];
+  return res; 
 }
 
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
 {
-  return (__m128d) __builtin_ia32_movsd_mask ((__v2df) __A, (__v2df) __B,
-   (__v2df)
-   _mm_setzero_pd (),
-   (__mmask8) __U);
+  __m128d res = __A; 
+  res[0] = (__U & 1) ? __B[0] : 0; 
+  return res; 
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __A)
+{
+  __builtin_ia32_storess128_mask ((__v16sf *)__W, 
+(__v16sf) _mm512_castps128_ps512(__A),
+(__mmask16) __U & (__mmask16)1);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm_mask_store_sd (double * __W, __mmask8 __U, __m128d __A)
+{
+  __builtin_ia32_storesd128_mask ((__v8df *)__W, 
+(__v8df) _mm512_castpd128_pd512(__A),
+(__mmask8) __U & 1);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_load_ss (__m128 __W, __mmask8 __U, const float* __A)
+{
+  __m128 src = (__v4sf) __builtin_shufflevector((__v4sf) __W,
+(__v4sf) {0.0, 0.0, 0.0, 0.0},
+0, 4, 4, 4);
+
+  return (__m128) __builtin_shufflevector(
+   __builtin_ia32_loadss128_mask ((__v16sf *) __A,
+  (__v16sf) _mm512_castps128_ps512(src),
+  (__mmask16) __U & 1),
+   _mm512_undefined_ps(), 0, 1, 2, 3);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_load_ss (__mmask8 __U, const float* __A)
+{
+  return (__m128) __builtin_shufflevector(
+   __builtin_ia32_loadss128_mask ((__v16sf *) __A,
+  (__v16sf) _mm512_setzero_ps(),
+  (__mmask16) __U & 1),
+   _mm512_undefined_ps(), 0, 1, 2, 3);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_mask_load_sd (__m128d __W, __mmask8 __U, const double* __A)
+{
+  __m128d src = (__v2df) __builtin_shufflevector((__v2df) __W,
+ (__v2df) {0.0, 0.0}, 0, 2);
+
+  return (__m128d) __builtin_shufflevector(
+__builtin_ia32_loadsd128_mask ((__v8df *) __A,
+  (__v8df) _mm512_castpd128_pd512(src),
+  (__mmask8) __U & 1),
+_mm512_undefined_pd(), 0, 1);
+}
+
+static __inline__ __m128d __DEFAULT_FN_ATTRS
+_mm_maskz_load_sd (__mmask8 __U, const double* __A)
+{
+  return (__m128d) __builtin_shufflevector(
+__builtin_ia32_loadsd128_mask ((__v8df *) __A,
+  (__v8df) _mm512_setzero_pd(),
+  (__mmask8) __U & 1),
+_mm512_undefined_pd(), 0, 1);
 }
 
 #define _mm512_shuffle_epi32(A, I) __extension__ ({ \
Index: lib/CodeGen/CGBuiltin.cp

Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-08 Thread Malcolm Parsons via cfe-commits
On 8 November 2016 at 08:28, Alexander Kornienko via cfe-commits
 wrote:
> [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no 
> need to disable them

Oh, I was using clang-analyzer-alpha.cplusplus.VirtualCall.

Should clang-tidy have an option to enable experimental checks?

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


[PATCH] D25659: [clang-tidy] Avoid running aliased checks twice

2016-11-08 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D25659#588663, @alexfh wrote:

> In https://reviews.llvm.org/D25659#588658, @alexfh wrote:
>
> > I think, silently choosing one of the checks may be confusing and 
> > counter-intuitive. Should we just warn in case we see the same check 
> > enabled by multiple aliases?
>
>
> And by "aliases" I mean different names under which the check is registered. 
> I'm not sure I see the benefit of introducing a separate concept and a 
> separate API for registering checks under multiple names. This introduces 
> another sort of dynamic binding, which we have to have good reasons for.


Is using `typeid()` on the constructed checks OK?


https://reviews.llvm.org/D25659



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


r286224 - Test commit of vbyakovl.

2016-11-08 Thread Vladimir Yakovlev via cfe-commits
Author: vbyakovl
Date: Tue Nov  8 04:32:10 2016
New Revision: 286224

URL: http://llvm.org/viewvc/llvm-project?rev=286224&view=rev
Log:
Test commit of vbyakovl.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=286224&r1=286223&r2=286224&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Nov  8 04:32:10 2016
@@ -1128,7 +1128,7 @@ TypeResult Sema::actOnObjCTypeArgsAndPro
   ActualTypeArgInfos.clear();
   break;
 }
-
+
 assert(TypeArgInfo && "No type source info?");
 ActualTypeArgInfos.push_back(TypeArgInfo);
   }
@@ -1145,7 +1145,7 @@ TypeResult Sema::actOnObjCTypeArgsAndPro
 
   if (Result == T)
 return BaseType;
-
+
   // Create source information for this type.
   TypeSourceInfo *ResultTInfo = Context.CreateTypeSourceInfo(Result);
   TypeLoc ResultTL = ResultTInfo->getTypeLoc();


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


[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-11-08 Thread Pavel Labath via cfe-commits
labath added a comment.

If noone objects, I am going to commit this tomorrow.


https://reviews.llvm.org/D25948



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


[PATCH] D26021: [X86][AVX512][Clang] Add support for mask_{move|store|load}_s{s/d} and int2mask/mask2int intrinsics.

2016-11-08 Thread Igor Breger via cfe-commits
igorb accepted this revision.
igorb added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lib/Headers/avx512fintrin.h:9123
+  __m128 res=__A; 
+  res[0] = (__U&1)? __B[0]:__W[0];
+  return res; 

.



Comment at: lib/Headers/avx512fintrin.h:9155
+  __builtin_ia32_storess128_mask ((__v16sf *)__W, 
+(__v16sf) _mm512_castps128_ps512(__A),
+(__mmask16) __U & (__mmask16)1);

.


https://reviews.llvm.org/D26021



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


[PATCH] D25074: [clang-tidy] Improve rename_check.py

2016-11-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.



Comment at: clang-tidy/rename_check.py:89
 
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', 
'_')
-  header_guard_new = module.upper() + '_' + 
check_name_new.upper().replace('-', '_')
+  header_guard_old = args.module.upper() + '_' + \
+  args.old_check_name.upper().replace('-', '_')

alexfh wrote:
> Does PEP8 have any preferences with regard to using a terminating backslash 
> over enclosing an expression that needs to be wrapped in parentheses? If no, 
> I'd better use parentheses.
Hm, apparently it [[ 
https://www.python.org/dev/peps/pep-0008/#maximum-line-length | does ]].

> The preferred way of wrapping long lines is by using Python's implied line 
> continuation inside parentheses, brackets and braces. Long lines can be 
> broken over multiple lines by wrapping expressions in parentheses. These 
> should be used in preference to using a backslash for line continuation.

Didn't know it, though. Thank you for pointing it out!


https://reviews.llvm.org/D25074



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


[PATCH] D25074: [clang-tidy] Improve rename_check.py

2016-11-08 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 77168.
omtcyfz added a comment.

Addressing comments Alex made about line breaks.


https://reviews.llvm.org/D25074

Files:
  clang-tidy/rename_check.py

Index: clang-tidy/rename_check.py
===
--- clang-tidy/rename_check.py
+++ clang-tidy/rename_check.py
@@ -10,9 +10,9 @@
 #======#
 
 import os
-import re
-import sys
 import glob
+import argparse
+
 
 def replaceInFile(fileName, sFrom, sTo):
   if sFrom == sTo:
@@ -29,64 +29,79 @@
   with open(fileName, "w") as f:
 f.write(txt)
 
+
 def generateCommentLineHeader(filename):
   return ''.join(['//===--- ',
   os.path.basename(filename),
   ' - clang-tidy ',
   '-' * max(0, 42 - len(os.path.basename(filename))),
   '*- C++ -*-===//'])
 
+
 def generateCommentLineSource(filename):
   return ''.join(['//===--- ',
   os.path.basename(filename),
   ' - clang-tidy',
   '-' * max(0, 52 - len(os.path.basename(filename))),
   '-===//'])
 
+
 def fileRename(fileName, sFrom, sTo):
   if sFrom not in fileName:
 return fileName
   newFileName = fileName.replace(sFrom, sTo)
   print("Rename '%s' -> '%s'" % (fileName, newFileName))
   os.rename(fileName, newFileName)
   return newFileName
 
+
 def getListOfFiles(clang_tidy_path):
-  files =  glob.glob(os.path.join(clang_tidy_path,'*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '*'))
   for dirname in files:
 if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname,'*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'test', 'clang-tidy', '*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'docs', 'clang-tidy', 'checks', '*'))
+  files += glob.glob(os.path.join(dirname, '*'))
+  files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
+  'clang-tidy', '*'))
+  files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
+  'clang-tidy', 'checks', '*'))
   return [filename for filename in files if os.path.isfile(filename)]
 
+
 def main():
-  if len(sys.argv) != 4:
-print('Usage: rename_check.py   \n')
-print('   example: rename_check.py misc awesome-functions new-awesome-function')
-return
+  parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
+  parser.add_argument('module', type=str,
+  help='Module where the renamed check is defined')
+  parser.add_argument('old_check_name', type=str,
+  help='Old check name.')
+  parser.add_argument('new_check_name', type=str,
+  help='New check name.')
+  args = parser.parse_args()
 
-  module = sys.argv[1].lower()
-  check_name = sys.argv[2]
+  args.module = args.module.lower()
   check_name_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name.split('-'))) + 'Check'
-  check_name_new = sys.argv[3]
-  check_name_new_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name_new.split('-'))) + 'Check'
+ args.old_check_name.split('-'))) + 'Check'
+  check_name_new_camel = (''.join(map(lambda elem: elem.capitalize(),
+  args.new_check_name.split('-'))) +
+  'Check')
 
-  clang_tidy_path = os.path.dirname(sys.argv[0])
+  clang_tidy_path = os.path.dirname(__file__)
 
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', '_')
-  header_guard_new = module.upper() + '_' + check_name_new.upper().replace('-', '_')
+  header_guard_old = (args.module.upper() + '_' +
+  args.old_check_name.upper().replace('-', '_'))
+  header_guard_new = (args.module.upper() + '_' +
+  args.new_check_name.upper().replace('-', '_'))
 
   for filename in getListOfFiles(clang_tidy_path):
 originalName = filename
-filename = fileRename(filename, check_name, check_name_new)
+filename = fileRename(filename, args.old_check_name,
+  args.new_check_name)
 filename = fileRename(filename, check_name_camel, check_name_new_camel)
-replaceInFile(filename, generateCommentLineHeader(originalName), generateCommentLineHeader(filename))
-replaceInFile(filename, generateCommentLineSource(originalName), generateCommentLineSource(filename))
+replaceInFile(filename, generateCommentLineHeader(originalName),
+  generateCommentLineHeader(filename))
+replaceInFile(filename, generateCommentLineSource(originalName),
+  generateCommentLineSource(filename))
 replaceInFile(filename, header_guard_old, header_guard_new)
-replaceInFile(filename, check_name, check_name_new)
+replaceInFile(filename

[PATCH] D25074: [clang-tidy] Improve rename_check.py

2016-11-08 Thread Kirill Bobyrev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286228: [clang-tidy] Improve rename_check.py. (authored by 
omtcyfz).

Changed prior to commit:
  https://reviews.llvm.org/D25074?vs=77168&id=77169#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25074

Files:
  clang-tools-extra/trunk/clang-tidy/rename_check.py

Index: clang-tools-extra/trunk/clang-tidy/rename_check.py
===
--- clang-tools-extra/trunk/clang-tidy/rename_check.py
+++ clang-tools-extra/trunk/clang-tidy/rename_check.py
@@ -10,9 +10,9 @@
 #======#
 
 import os
-import re
-import sys
 import glob
+import argparse
+
 
 def replaceInFile(fileName, sFrom, sTo):
   if sFrom == sTo:
@@ -29,64 +29,79 @@
   with open(fileName, "w") as f:
 f.write(txt)
 
+
 def generateCommentLineHeader(filename):
   return ''.join(['//===--- ',
   os.path.basename(filename),
   ' - clang-tidy ',
   '-' * max(0, 42 - len(os.path.basename(filename))),
   '*- C++ -*-===//'])
 
+
 def generateCommentLineSource(filename):
   return ''.join(['//===--- ',
   os.path.basename(filename),
   ' - clang-tidy',
   '-' * max(0, 52 - len(os.path.basename(filename))),
   '-===//'])
 
+
 def fileRename(fileName, sFrom, sTo):
   if sFrom not in fileName:
 return fileName
   newFileName = fileName.replace(sFrom, sTo)
   print("Rename '%s' -> '%s'" % (fileName, newFileName))
   os.rename(fileName, newFileName)
   return newFileName
 
+
 def getListOfFiles(clang_tidy_path):
-  files =  glob.glob(os.path.join(clang_tidy_path,'*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '*'))
   for dirname in files:
 if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname,'*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'test', 'clang-tidy', '*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'docs', 'clang-tidy', 'checks', '*'))
+  files += glob.glob(os.path.join(dirname, '*'))
+  files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
+  'clang-tidy', '*'))
+  files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
+  'clang-tidy', 'checks', '*'))
   return [filename for filename in files if os.path.isfile(filename)]
 
+
 def main():
-  if len(sys.argv) != 4:
-print('Usage: rename_check.py   \n')
-print('   example: rename_check.py misc awesome-functions new-awesome-function')
-return
+  parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
+  parser.add_argument('module', type=str,
+  help='Module where the renamed check is defined')
+  parser.add_argument('old_check_name', type=str,
+  help='Old check name.')
+  parser.add_argument('new_check_name', type=str,
+  help='New check name.')
+  args = parser.parse_args()
 
-  module = sys.argv[1].lower()
-  check_name = sys.argv[2]
+  args.module = args.module.lower()
   check_name_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name.split('-'))) + 'Check'
-  check_name_new = sys.argv[3]
-  check_name_new_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name_new.split('-'))) + 'Check'
-
-  clang_tidy_path = os.path.dirname(sys.argv[0])
-
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', '_')
-  header_guard_new = module.upper() + '_' + check_name_new.upper().replace('-', '_')
+ args.old_check_name.split('-'))) + 'Check'
+  check_name_new_camel = (''.join(map(lambda elem: elem.capitalize(),
+  args.new_check_name.split('-'))) +
+  'Check')
+
+  clang_tidy_path = os.path.dirname(__file__)
+
+  header_guard_old = (args.module.upper() + '_' +
+  args.old_check_name.upper().replace('-', '_'))
+  header_guard_new = (args.module.upper() + '_' +
+  args.new_check_name.upper().replace('-', '_'))
 
   for filename in getListOfFiles(clang_tidy_path):
 originalName = filename
-filename = fileRename(filename, check_name, check_name_new)
+filename = fileRename(filename, args.old_check_name,
+  args.new_check_name)
 filename = fileRename(filename, check_name_camel, check_name_new_camel)
-replaceInFile(filename, generateCommentLineHeader(originalName), generateCommentLineHeader(filename))
-replaceInFile(filename, generateCommentLineSource(originalName), generateCommentLineSource(filename))
+replaceInFile(filename, generateCommentLineHeader(originalName),
+  generateCommentLineHeader(filename))
+replaceInFile(filename,

r286229 - [X86][AVX512][Clang] Add support for mask_{move|store|load}_s{s/d} and int2mask/mask2int intrinsics.

2016-11-08 Thread Ayman Musa via cfe-commits
Author: aymanmus
Date: Tue Nov  8 06:00:30 2016
New Revision: 286229

URL: http://llvm.org/viewvc/llvm-project?rev=286229&view=rev
Log:
[X86][AVX512][Clang] Add support for mask_{move|store|load}_s{s/d} and 
int2mask/mask2int intrinsics.

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=286229&r1=286228&r2=286229&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Nov  8 06:00:30 2016
@@ -1448,8 +1448,10 @@ TARGET_BUILTIN(__builtin_ia32_fixupimmps
 TARGET_BUILTIN(__builtin_ia32_fixupimmps256_mask, 
"V8fV8fV8fV8iIiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_fixupimmps256_maskz, 
"V8fV8fV8fV8iIiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadapd128_mask, "V2dV2d*V2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_loadsd128_mask, "V8dV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_loadapd256_mask, "V4dV4d*V4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadaps128_mask, "V4fV4f*V4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_loadss128_mask, "V16fV16f*V16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_loadaps256_mask, "V8fV8f*V8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi128_mask, 
"V2LLiV2LLi*V2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi256_mask, 
"V4LLiV4LLi*V4LLiUc","","avx512vl")
@@ -1466,8 +1468,10 @@ TARGET_BUILTIN(__builtin_ia32_storedquhi
 TARGET_BUILTIN(__builtin_ia32_storedquqi128_mask, 
"vV16c*V16cUs","","avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_storedquqi256_mask, 
"vV32c*V32cUi","","avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_storeapd128_mask, "vV2d*V2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_storesd128_mask, "vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeapd256_mask, "vV4d*V4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_storeaps128_mask, "vV4f*V4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_storess128_mask, "vV16f*V16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeaps256_mask, "vV8f*V8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_storedqudi128_mask, 
"vV2LLi*V2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_storedqudi256_mask, 
"vV4LLi*V4LLiUc","","avx512vl")
@@ -1790,8 +1794,6 @@ TARGET_BUILTIN(__builtin_ia32_expandload
 TARGET_BUILTIN(__builtin_ia32_expandsf512_mask, "V16fV16fV16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_expandsi512_mask, "V16iV16iV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtps2pd512_mask, "V8dV8fV8dUcIi","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_movss_mask, "V4fV4fV4fV4fUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_movsd_mask, "V2dV2dV2dV2dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, 
"vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, 
"vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, 
"vV16f*V16fUs","","avx512f")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=286229&r1=286228&r2=286229&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Nov  8 06:00:30 2016
@@ -7386,6 +7386,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_storeups512_mask:
 return EmitX86MaskedStore(*this, Ops, 1);
 
+  case X86::BI__builtin_ia32_storess128_mask:
+  case X86::BI__builtin_ia32_storesd128_mask: {
+return EmitX86MaskedStore(*this, Ops, 16);
+  }
   case X86::BI__builtin_ia32_movdqa32store128_mask:
   case X86::BI__builtin_ia32_movdqa64store128_mask:
   case X86::BI__builtin_ia32_storeaps128_mask:
@@ -7422,6 +7426,10 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_loaddqudi512_mask:
 return EmitX86MaskedLoad(*this, Ops, 1);
 
+  case X86::BI__builtin_ia32_loadss128_mask:
+  case X86::BI__builtin_ia32_loadsd128_mask:
+return EmitX86MaskedLoad(*this, Ops, 16);
+
   case X86::BI__builtin_ia32_loadaps128_mask:
   case X86::BI__builtin_ia32_loadaps256_mask:
   case X86::BI__builtin_ia32_loadaps512_mask:

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=286229&r1=286228&r2=286229&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Nov  8 06:00:30 2016
@@ -516,6 +516,18

[PATCH] D26021: [X86][AVX512][Clang] Add support for mask_{move|store|load}_s{s/d} and int2mask/mask2int intrinsics.

2016-11-08 Thread Ayman Musa via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286229: [X86][AVX512][Clang] Add support for 
mask_{move|store|load}_s{s/d} and… (authored by aymanmus).

Changed prior to commit:
  https://reviews.llvm.org/D26021?vs=77158&id=77170#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26021

Files:
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/avx512fintrin.h
  cfe/trunk/test/CodeGen/avx512f-builtins.c

Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -1448,8 +1448,10 @@
 TARGET_BUILTIN(__builtin_ia32_fixupimmps256_mask, "V8fV8fV8fV8iIiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_fixupimmps256_maskz, "V8fV8fV8fV8iIiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadapd128_mask, "V2dV2d*V2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_loadsd128_mask, "V8dV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_loadapd256_mask, "V4dV4d*V4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadaps128_mask, "V4fV4f*V4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_loadss128_mask, "V16fV16f*V16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_loadaps256_mask, "V8fV8f*V8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi128_mask, "V2LLiV2LLi*V2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi256_mask, "V4LLiV4LLi*V4LLiUc","","avx512vl")
@@ -1466,8 +1468,10 @@
 TARGET_BUILTIN(__builtin_ia32_storedquqi128_mask, "vV16c*V16cUs","","avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_storedquqi256_mask, "vV32c*V32cUi","","avx512vl,avx512bw")
 TARGET_BUILTIN(__builtin_ia32_storeapd128_mask, "vV2d*V2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_storesd128_mask, "vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeapd256_mask, "vV4d*V4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_storeaps128_mask, "vV4f*V4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_storess128_mask, "vV16f*V16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeaps256_mask, "vV8f*V8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_storedqudi128_mask, "vV2LLi*V2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_storedqudi256_mask, "vV4LLi*V4LLiUc","","avx512vl")
@@ -1790,8 +1794,6 @@
 TARGET_BUILTIN(__builtin_ia32_expandsf512_mask, "V16fV16fV16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_expandsi512_mask, "V16iV16iV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_cvtps2pd512_mask, "V8dV8fV8dUcIi","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_movss_mask, "V4fV4fV4fV4fUc","","avx512f")
-TARGET_BUILTIN(__builtin_ia32_movsd_mask, "V2dV2dV2dV2dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, "vV8d*V8dUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, "vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, "vV16f*V16fUs","","avx512f")
Index: cfe/trunk/test/CodeGen/avx512f-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512f-builtins.c
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512f -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512f -O2 -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=O2
 
 #include 
 
@@ -7995,34 +7996,143 @@
   return _mm512_setzero_pd();
 }
 
+__mmask16 test_mm512_int2mask(int __a)
+{
+  // O2-LABEL: test_mm512_int2mask
+  // O2: trunc i32 %__a to i16
+  return _mm512_int2mask(__a);
+}
+
+int test_mm512_mask2int(__mmask16 __a)
+{
+  // O2-LABEL: test_mm512_mask2int
+  // O2: zext i16 %__a to i32
+  return _mm512_mask2int(__a);
+}
+
 __m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
-  // CHECK-LABEL: @test_mm_mask_move_ss
-  // CHECK: @llvm.x86.avx512.mask.move.ss
+  // O2-LABEL: @test_mm_mask_move_ss
+  // O2: %[[M:.*]] = and i8 %__U, 1
+  // O2: %[[M2:.*]] = icmp ne i8 %[[M]], 0
+  // O2: %[[ELM1:.*]] = extractelement <4 x float> %__B, i32 0
+  // O2: %[[ELM2:.*]] = extractelement <4 x float> %__W, i32 0
+  // O2: %[[SEL:.*]] = select i1 %[[M2]], float %[[ELM1]], float %[[ELM2]]
+  // O2: %[[RES:.*]] = insertelement <4 x float> %__A, float %[[SEL]], i32 0
+  // O2: ret <4 x float> %[[RES]]
   return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
 }
 
 __m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
 {
-  // CHECK-LABEL: @test_mm_maskz_move_ss
-  // CHECK: @llvm.x86.avx512.mask.move.ss
+  // O2-LABEL: @test_mm_maskz_move_ss
+  // O2: %[[M:.*]] = and i8 %__U, 1
+  // O2: %[[M2:.*]] = icmp ne i8 %[[M]], 0
+  // O2: %[[ELM1:.*]] = extractelement <4 x float> %__B, i32 0
+  // O2: %[[SEL:.*]] = select i1 %[[M2]], flo

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

2016-11-08 Thread Nemanja Ivanovic via cfe-commits
nemanjai added inline comments.



Comment at: include/clang/Basic/BuiltinsPPC.def:304
 
+BUILTIN(__builtin_vsx_lxvl, "V4ivC*Ui", "")
+BUILTIN(__builtin_vsx_lxvll, "V4ivC*Ui", "")

Also, in addition to guarding for 64-bit, these should be defined to take the 
length parameter as a 64-bit integer.


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] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-11-08 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

@mclow.lists, @EricWF, ok to commit the patch?

Thanks,
Sebastian


https://reviews.llvm.org/D24991



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-08 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D26157#589033, @pekka.jaaskelainen wrote:

> The uses for the OpenCL logical address spaces that I know of are:
>
> 1. to differentiate local kernel arguments as their memory allocation is 
> different (per WG if parallel WGs)
> 2. alias analysis: as OpenCL address spaces are per definition disjoint (no 
> overlap), it can be utilized to prove that pointers to different address 
> spaces are not accessing the same areas, which helps e.g. vectorization and 
> other optimizations that require code motion/parallelization
> 3. clGetKernelArgInfo() implementation
>
>   The kernel arg MD is good enough for 1) and 3) and helps in 2). Actually 
> having the address spaces in the pointers would be much better, but is harder 
> to maintain.


I think 2) should be done through address space of IR since the MD is only 
available for kernel functions. For amdgpu targets this is not an issue since 
they preserve the OpenCL address spaces.

> Yes. Maybe I should just add to the docs about the MD in my patch? I think 
> this patch should go in regardless of a possible heavier work related to the 
> logical address spaces as the current MD is clearly broken.

Agree.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


r286205 - [PowerPC] Implement remaining vector comparison builtins.

2016-11-08 Thread Tony Jiang via cfe-commits
Author: jtony
Date: Mon Nov  7 22:15:45 2016
New Revision: 286205

URL: http://llvm.org/viewvc/llvm-project?rev=286205&view=rev
Log:
[PowerPC] Implement remaining vector comparison builtins.

vector bool char vec_cmpeq (vector bool char, vector bool char);
vector bool int vec_cmpeq (vector bool int, vector bool int);
vector bool long long vec_cmpeq (vector bool long long, vector bool long lon
vector bool short vec_cmpeq (vector bool short, vector bool short);

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=286205&r1=286204&r2=286205&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Mon Nov  7 22:15:45 2016
@@ -1564,6 +1564,12 @@ vec_cmpeq(vector unsigned char __a, vect
   (vector char)__b);
 }
 
+static __inline__ vector bool char __ATTRS_o_ai
+vec_cmpeq(vector bool char __a, vector bool char __b) {
+  return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
+  (vector char)__b);
+}
+
 static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
vector short __b) {
   return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
@@ -1575,6 +1581,12 @@ vec_cmpeq(vector unsigned short __a, vec
(vector short)__b);
 }
 
+static __inline__ vector bool short __ATTRS_o_ai
+vec_cmpeq(vector bool short __a, vector bool short __b) {
+  return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
+   (vector short)__b);
+}
+
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
  vector int __b) {
   return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
@@ -1586,6 +1598,12 @@ vec_cmpeq(vector unsigned int __a, vecto
  (vector int)__b);
 }
 
+static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
+ vector bool int __b) {
+  return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
+ (vector int)__b);
+}
+
 #ifdef __POWER8_VECTOR__
 static __inline__ vector bool long long __ATTRS_o_ai
 vec_cmpeq(vector signed long long __a, vector signed long long __b) {
@@ -1597,6 +1615,13 @@ vec_cmpeq(vector unsigned long long __a,
   return (vector bool long long)__builtin_altivec_vcmpequd(
   (vector long long)__a, (vector long long)__b);
 }
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector bool long long __a, vector bool long long __b) {
+  return (vector bool long long)__builtin_altivec_vcmpequd(
+  (vector long long)__a, (vector long long)__b);
+}
+
 #endif
 
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2298,14 +2323,15 @@ vec_first_match_or_eos_index(vector sign
  result if either is zero.
   */
   vector bool char __tmp1 = vec_cmpeq(__a, __b);
-  vector bool char __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
-vec_cmpeq(__tmp1, __b);
+  vector bool char __tmp2 = __tmp1 |
+vec_cmpeq((vector signed char)__tmp1, __a) |
+vec_cmpeq((vector signed char)__tmp1, __b);
 
   vector unsigned long long __res =
 #ifdef __LITTLE_ENDIAN__
-vec_cnttz((vector unsigned long long)__tmp2);
+  vec_cnttz((vector unsigned long long)__tmp2);
 #else
-vec_cntlz((vector unsigned long long)__tmp2);
+  vec_cntlz((vector unsigned long long)__tmp2);
 #endif
   if (__res[0] == 64) {
 return (__res[1] + 64) >> 3;
@@ -2317,14 +2343,15 @@ static __inline__ unsigned __ATTRS_o_ai
 vec_first_match_or_eos_index(vector unsigned char __a,
  vector unsigned char __b) {
   vector bool char __tmp1 = vec_cmpeq(__a, __b);
-  vector bool char __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
-vec_cmpeq(__tmp1, __b);
+  vector bool char __tmp2 = __tmp1 |
+vec_cmpeq((vector unsigned char)__tmp1, __a) |
+vec_cmpeq((vector unsigned char)__tmp1, __b);
 
   vector unsigned long long __res =
 #ifdef __LITTLE_ENDIAN__
-vec_cnttz((vector unsigned long long)__tmp2);
+  vec_cnttz((vector unsigned long long)__tmp2);
 #else
-vec_cntlz((vector unsigned long long)__tmp2);
+  vec_cntlz((vector unsigned long long)__tmp2);
 #endif
   if (__res[0] == 64) {
 return (__res[1] + 64) >> 3;
@@ -2335,14 +2362,15 @@ vec_first_match_or_eos_

[PATCH] D26271: [PPC} add extract significand/ extract exponent/test data class for vector float and vector double -- clang portion

2016-11-08 Thread Tony Jiang via cfe-commits
jtony added a comment.

A very small nit,  the bracket does not match in the title, do you mean [PPC] 
instead of [PPC}?


Repository:
  rL LLVM

https://reviews.llvm.org/D26271



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


[PATCH] D26271: [PPC} add extract significand/ extract exponent/test data class for vector float and vector double -- 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/D26271



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


[PATCH] D26282: [PowerPC] Implement plain VSX load/store builtins.

2016-11-08 Thread Tony Jiang via cfe-commits
jtony updated this revision to Diff 77190.
jtony added a comment.

Add -U99 option to git diff to show context for this patch.


https://reviews.llvm.org/D26282

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-quadword.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -21,6 +21,7 @@
 vector signed long long vsll = { 255LL, -937LL };
 vector unsigned long long vull = { 1447LL, 2894LL };
 double d = 23.4;
+signed long long sll = 618LL;
 float af[4] = {23.4f, 56.7f, 89.0f, 12.3f};
 double ad[2] = {23.4, 56.7};
 signed char asc[16] = { -8,  9, -10, 11, -12, 13, -14, 15,
@@ -31,8 +32,8 @@
 unsigned short aus[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 signed int asi[4] = { -1, 2, -3, 4 };
 unsigned int aui[4] = { 0, 1, 2, 3 };
-signed long asl[2] = { -1L, 2L };
-unsigned long aul[2] = { 1L, 2L };
+signed long long asll[2] = { -1L, 2L };
+unsigned long long aull[2] = { 1L, 2L };
 
 vector float res_vf;
 vector double res_vd;
@@ -1248,4 +1249,28 @@
   res_vull = vec_sro(vull, vuc);
 // CHECK: @llvm.ppc.altivec.vsro
 // CHECK-LE: @llvm.ppc.altivec.vsro
+
+res_vsll = vec_xl(sll, asll);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+
+res_vull = vec_xl(sll, aull);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+
+res_vd = vec_xl(sll, ad);
+// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+
+vec_xst(vsll, sll, asll);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+
+vec_xst(vull, sll, aull);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+
+vec_xst(vd, sll, ad);
+// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
 }
Index: test/CodeGen/builtins-ppc-quadword.c
===
--- test/CodeGen/builtins-ppc-quadword.c
+++ test/CodeGen/builtins-ppc-quadword.c
@@ -15,6 +15,12 @@
 // CHECK-PPC: error: __int128 is not supported on this target
 vector unsigned __int128 vulll = { 1 };
 
+signed long long param_sll;
+// CHECK-PPC: error: __int128 is not supported on this target
+signed __int128 param_lll;
+// CHECK-PPC: error: __int128 is not supported on this target
+unsigned __int128 param_ulll;
+
 // CHECK-PPC: error: __int128 is not supported on this target
 vector signed __int128 res_vlll;
 // CHECK-PPC: error: __int128 is not supported on this target
@@ -165,4 +171,26 @@
 // CHECK-LE: xor <16 x i8>
 // CHECK-LE: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> {{%.+}}, <4 x i32> {{%.+}}, <16 x i8> {{%.+}})
 // CHECK_PPC: error: call to 'vec_revb' is ambiguous
+
+  /* vec_xl */
+  res_vlll = vec_xl(param_sll, ¶m_lll);
+  // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xl' is ambiguous
+
+  res_vulll = vec_xl(param_sll, ¶m_ulll);
+  // CHECK: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <1 x i128>, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xl' is ambiguous
+
+  /* vec_xst */
+   vec_xst(vlll, param_sll, ¶m_lll);
+  // CHECK: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xst' is ambiguous
+
+   vec_xst(vulll, param_sll, ¶m_ulll);
+  // CHECK: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-LE: store <1 x i128> %{{[0-9]+}}, <1 x i128>* %{{[0-9]+}}, align 16
+  // CHECK-PPC: error: call to 'vec_xst' is ambiguous
 }
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -45,6 +45,7 @@
 int param_i;
 unsigned int param_ui;
 float param_f;
+signed long long param_sll;
 
 int res_sc;
 int res_uc;
@@ -9224,3 +9225,69 @@
 // CHECK-LE: xor <16 x i8>
 // CHECK-LE: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> {{%.+}}, <4 x i32> {{%.+}}, <16 x i8> {{%.+}})
 }
+
+/* -- vec_xl  */
+void test9() {
+  // CHECK-LABEL: define void @test9
+  // CHECK-LE-LABEL: define void @test9
+  res_vsc = vec_xl(param_sll, ¶m_sc);
+  // CHECK: load <16 x i8>, <16 x i8>* %{{[0-9]+}}, align 16
+  // CHECK-LE: load <16 x i8>, <

[PATCH] D25764: Add end location of loop to loop metadata.

2016-11-08 Thread Florian Hahn via cfe-commits
fhahn added a comment.

Ping. It would be great if somebody could have a look at this patch. The  
companion LLVM patch https://reviews.llvm.org/D25763 
(https://reviews.llvm.org/D25763) has been accepted already.


https://reviews.llvm.org/D25764



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


[PATCH] D26160: [PowerPC] Implement remaining vector comparison builtins

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


https://reviews.llvm.org/D26160



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


[clang-tools-extra] r286228 - [clang-tidy] Improve rename_check.py.

2016-11-08 Thread Kirill Bobyrev via cfe-commits
Author: omtcyfz
Date: Tue Nov  8 05:43:50 2016
New Revision: 286228

URL: http://llvm.org/viewvc/llvm-project?rev=286228&view=rev
Log:
[clang-tidy] Improve rename_check.py.

-Start using argparse instead of mimicking CLI parsing.
-PEPify the code.
-Decrease the number of imports by slightly cleaning up the script.

Reviewers: alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/rename_check.py

Modified: clang-tools-extra/trunk/clang-tidy/rename_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/rename_check.py?rev=286228&r1=286227&r2=286228&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/rename_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/rename_check.py Tue Nov  8 05:43:50 2016
@@ -10,9 +10,9 @@
 
#======#
 
 import os
-import re
-import sys
 import glob
+import argparse
+
 
 def replaceInFile(fileName, sFrom, sTo):
   if sFrom == sTo:
@@ -29,6 +29,7 @@ def replaceInFile(fileName, sFrom, sTo):
   with open(fileName, "w") as f:
 f.write(txt)
 
+
 def generateCommentLineHeader(filename):
   return ''.join(['//===--- ',
   os.path.basename(filename),
@@ -36,6 +37,7 @@ def generateCommentLineHeader(filename):
   '-' * max(0, 42 - len(os.path.basename(filename))),
   '*- C++ -*-===//'])
 
+
 def generateCommentLineSource(filename):
   return ''.join(['//===--- ',
   os.path.basename(filename),
@@ -43,6 +45,7 @@ def generateCommentLineSource(filename):
   '-' * max(0, 52 - len(os.path.basename(filename))),
   '-===//'])
 
+
 def fileRename(fileName, sFrom, sTo):
   if sFrom not in fileName:
 return fileName
@@ -51,42 +54,54 @@ def fileRename(fileName, sFrom, sTo):
   os.rename(fileName, newFileName)
   return newFileName
 
+
 def getListOfFiles(clang_tidy_path):
-  files =  glob.glob(os.path.join(clang_tidy_path,'*'))
+  files = glob.glob(os.path.join(clang_tidy_path, '*'))
   for dirname in files:
 if os.path.isdir(dirname):
-  files += glob.glob(os.path.join(dirname,'*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'test', 'clang-tidy', 
'*'))
-  files += glob.glob(os.path.join(clang_tidy_path,'..', 'docs', 'clang-tidy', 
'checks', '*'))
+  files += glob.glob(os.path.join(dirname, '*'))
+  files += glob.glob(os.path.join(clang_tidy_path, '..', 'test',
+  'clang-tidy', '*'))
+  files += glob.glob(os.path.join(clang_tidy_path, '..', 'docs',
+  'clang-tidy', 'checks', '*'))
   return [filename for filename in files if os.path.isfile(filename)]
 
+
 def main():
-  if len(sys.argv) != 4:
-print('Usage: rename_check.py   
\n')
-print('   example: rename_check.py misc awesome-functions 
new-awesome-function')
-return
+  parser = argparse.ArgumentParser(description='Rename clang-tidy check.')
+  parser.add_argument('module', type=str,
+  help='Module where the renamed check is defined')
+  parser.add_argument('old_check_name', type=str,
+  help='Old check name.')
+  parser.add_argument('new_check_name', type=str,
+  help='New check name.')
+  args = parser.parse_args()
 
-  module = sys.argv[1].lower()
-  check_name = sys.argv[2]
+  args.module = args.module.lower()
   check_name_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name.split('-'))) + 'Check'
-  check_name_new = sys.argv[3]
-  check_name_new_camel = ''.join(map(lambda elem: elem.capitalize(),
- check_name_new.split('-'))) + 'Check'
-
-  clang_tidy_path = os.path.dirname(sys.argv[0])
-
-  header_guard_old = module.upper() + '_' + check_name.upper().replace('-', 
'_')
-  header_guard_new = module.upper() + '_' + 
check_name_new.upper().replace('-', '_')
+ args.old_check_name.split('-'))) + 'Check'
+  check_name_new_camel = (''.join(map(lambda elem: elem.capitalize(),
+  args.new_check_name.split('-'))) +
+  'Check')
+
+  clang_tidy_path = os.path.dirname(__file__)
+
+  header_guard_old = (args.module.upper() + '_' +
+  args.old_check_name.upper().replace('-', '_'))
+  header_guard_new = (args.module.upper() + '_' +
+  args.new_check_name.upper().replace('-', '_'))
 
   for filename in getListOfFiles(clang_tidy_path):
 originalName = filename
-filename = fileRename(filename, check_name, check_name_new)
+filename = fileRename(filename, args.old_check_name,
+  args.new_check_name)
 filename = fileRename(filename, check_name_camel, check_name_new_camel)
-replaceInFile(filename, generateComment

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-08 Thread Alpha Abdoulaye via cfe-commits
Alpha added inline comments.



Comment at: include/clang/Tooling/Core/Diagnostic.h:35
+  DiagnosticMessage(llvm::StringRef Message, const SourceManager &Sources,
+SourceLocation Loc);
+  std::string Message;

alexfh wrote:
> What are the constraints on the location? Should it be a file location or 
> macro locations are fine too? Please add a (doxygen-style) comment.
Indeed, this should be a file location.



Comment at: include/clang/Tooling/Core/Diagnostic.h:68-71
+  /// A freeform chunk of text to describe the context of the replacements.
+  /// Will be printed, for example, when detecting conflicts during replacement
+  /// deduplication.
+  std::string Context;

alexfh wrote:
> That's too vague. Are you intending to use it only for reporting problems 
> with replacement deduplication? Should it be in this structure at all?
This was actually left to keep compatibility with `TranslationUnitReplacements` 
which was used for the export.
But it seems that even for that structure, there is in all likelihood no 
reference to any use of the `Context` field, except in test cases and in the 
Yaml IO mapping, where it is marked as an optional entry.
Should it be discarded instead (here, and thus also in 
`TranslationUnitReplacements`)?



Comment at: tools/extra/clang-tidy/ClangTidy.cpp:578
 raw_ostream &OS) {
-  TranslationUnitReplacements TUR;
-  for (const ClangTidyError &Error : Errors) {
-for (const auto &FileAndFixes : Error.Fix)
-  TUR.Replacements.insert(TUR.Replacements.end(),
-  FileAndFixes.second.begin(),
-  FileAndFixes.second.end());
-  }
-
+  TranslationUnitDiagnostics TUD;
+  TUD.Diagnostics.insert(TUD.Diagnostics.end(), Errors.begin(), Errors.end());

alexfh wrote:
> This function neither fills `TUD.MainSourceFile` nor `TUD.Context` (which I'm 
> not sure even belongs to this structure).
Done for  `MainSourceFile` which was surprisingly never exported with the fixes.
For  `Context`, see above comment about the 'TranslationUnitDiagnostics' 
structure.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-08 Thread Alpha Abdoulaye via cfe-commits
Alpha updated this revision to Diff 77196.
Alpha added a comment.

Export effectively MainSourceFile.
Change CheckName field.
Add doxygen-style comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/DiagnosticsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp

Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,45 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager &Sources,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   Diagnostic::Level DiagLevel)
+: DiagnosticName(DiagnosticName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   DiagnosticMessage &Message,
+   llvm::StringMap &Fix,
+   SmallVector &Notes,
+   Level DiagLevel)
+: DiagnosticName(DiagnosticName), Message(Message), Fix(Fix), Notes(Notes),
+  DiagLevel(DiagLevel) {}
+
+} // end namespace tooling
+} // end namespace clang
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -4,6 +4,7 @@
   Lookup.cpp
   Replacement.cpp
   QualTypeNames.cpp
+  Diagnostic.cpp
 
   LINK_LIBS
   clangAST
Index: include/clang/Tooling/DiagnosticsYaml.h
===
--- include/clang/Tooling/DiagnosticsYaml.h
+++ include/clang/Tooling/DiagnosticsYaml.h
@@ -0,0 +1,90 @@
+//===-- DiagnosticsYaml.h -- Serialiazation for Diagnosticss ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file defines the structure of a YAML document for serializing
+/// diagnostics.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+#define LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(clang::tooling::Diagnostic)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  /// \brief Helper to (de)serialize a Diagnostic since we don't have direct
+  /// access to its data members.
+  class NormalizedDiagnostic {
+  public:
+NormalizedDiagnostic(const IO &)
+: DiagnosticName(""), Message(), Fix(), Notes(), DiagLevel() {}
+
+NormalizedDiagnostic(const IO &, const clang::tooling::Diagnostic &D)
+: DiagnosticName(D.DiagnosticName), Message(Message), Fix(D.Fix),
+  Notes(D.Notes), DiagLevel(D.DiagLevel) {}
+
+clang::tooling::Diagnostic denormalize(const IO &) {
+  return clang::tooling::Diagnostic(DiagnosticName, Message, Fix, Notes,
+DiagLevel);
+}
+
+std::string DiagnosticName;
+clang::tooling::DiagnosticMessage Message;
+llvm::StringMap Fix;
+SmallVector Notes;
+clang::tooling::Diagnostic::Level Di

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

2016-11-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Nov  8 10:11:33 2016
New Revision: 286243

URL: http://llvm.org/viewvc/llvm-project?rev=286243&view=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&r1=286242&r2=286243&view=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 
&Replaces,
   const FormatStyle &Style);
 
-/// \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 &Style,
-   SourceManager &SourceMgr, 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 &Style, 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 &Style,
-  SourceManager &SourceMgr, 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 &Style, 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&r1=286242&r2=286243&view=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 &Style, SourceManager &SM,
-   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 &Style, 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 &Style, SourceManager &SM,
-  FileID ID, ArrayRef Ranges) {
-  Environment Env(SM, ID, Ranges);
-  Cleaner Clean(Env, Style);
-  return Clean.process();
-}
-
 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
   ArrayRef Ranges,
   StringRef FileName) {

Modified: cfe/trunk/lib/Index/CommentToXML.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/CommentToXML.cpp?rev=286243&r1=286242&r2=286243&view=diff
==
--- cfe/trunk/lib/Index/CommentToXML.cpp (original

[PATCH] D25985: [analyzer] Export coverage information from the analyzer.

2016-11-08 Thread Gábor Horváth via cfe-commits
xazax.hun updated the summary for this revision.
xazax.hun updated this revision to Diff 77199.
xazax.hun added a comment.

- Added a python script to merge gcov files.
- Fixed an error
- Multifile test is not added yet, will do so in the next update.


https://reviews.llvm.org/D25985

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/record-coverage.cpp
  test/Analysis/record-coverage.cpp.expected
  utils/analyzer/MergeCoverage.py

Index: utils/analyzer/MergeCoverage.py
===
--- /dev/null
+++ utils/analyzer/MergeCoverage.py
@@ -0,0 +1,127 @@
+'''
+   Script to merge gcov files produced by the static analyzer.
+   So coverage information of header files from multiple translation units are
+   merged together. The output can be pocessed by gcovr format like:
+gcovr -g outputdir --html --html-details -r sourceroot -o example.html
+   The expected layout of input (the input should be the gcovdir):
+gcovdir/TranslationUnit1/file1.gcov
+gcovdir/TranslationUnit1/subdir/file2.gcov
+...
+gcovdir/TranslationUnit1/fileN.gcov
+...
+gcovdir/TranslationUnitK/fileM.gcov
+   The output:
+outputdir/file1.gcov
+outputdir/subdir/file2.gcov
+...
+outputdir/fileM.gcov
+'''
+
+import argparse
+import os
+import sys
+import shutil
+
+def is_num(val):
+'''Check if val can be converted to int.'''
+try:
+int(val)
+return True
+except ValueError:
+return False
+
+
+def is_valid(line):
+'''Check whether a list is a valid gcov line after join on colon.'''
+if len(line) == 4:
+return line[2].lower() in {"graph", "data", "runs", "programs",
+"source"}
+else:
+return len(line) == 3
+
+
+def merge_gcov(from_gcov, to_gcov):
+'''Merge to existing gcov file, modify the second one.'''
+with open(from_gcov) as from_file, open(to_gcov) as to_file:
+from_lines = from_file.readlines()
+to_lines = to_file.readlines()
+
+if len(from_lines) != len(to_lines):
+print("Fatal error: failed to match gcov files,"
+" different line count: (%s, %s)" %
+(from_gcov, to_gcov))
+sys.exit(1)
+
+for i in range(len(from_lines)):
+from_split = from_lines[i].split(":")
+to_split = to_lines[i].split(":")
+
+if not is_valid(from_split) or not is_valid(to_split):
+print("Fatal error: invalid gcov format (%s, %s)" %
+(from_gcov, to_gcov))
+print("%s, %s" % (from_split, to_split))
+sys.exit(1)
+
+for j in range(2):
+if from_split[j+1] != to_split[j+1]:
+print("Fatal error: failed to match gcov files: (%s, %s)" %
+(from_gcov, to_gcov))
+print("%s != %s" % (from_split[j+1], to_split[j+1]))
+sys.exit(1)
+
+if to_split[0] == '#':
+to_split[0] = from_split[0]
+elif to_split[0] == '-':
+assert from_split[0] == '-'
+elif is_num(to_split[0]):
+assert is_num(from_split[0]) or from_split[0] == '#'
+if is_num(from_split[0]):
+to_split[0] = str(int(to_split[0]) + int(from_split[0]))
+
+to_lines[i] = ":".join(to_split)
+
+with open(to_gcov, 'w') as to_file:
+to_file.writelines(to_lines)
+
+
+def process_tu(tu_path, output):
+'''Process a directory containing files originated from checking a tu.'''
+for root, _, files in os.walk(tu_path):
+for gcovfile in files:
+_, ext = os.path.splitext(gcovfile)
+if ext != ".gcov":
+continue
+gcov_in_path = os.path.join(root, gcovfile)
+gcov_out_path = os.path.join(
+output, os.path.relpath(gcov_in_path, tu_path))
+if os.path.exists(gcov_out_path):
+merge_gcov(gcov_in_path, gcov_out_path)
+else:
+# No merging needed.
+shutil.copyfile(gcov_in_path, gcov_out_path)
+
+
+def main():
+'''Parsing arguments, process each tu dir.'''
+parser = argparse.ArgumentParser(description="Merge gcov files from "
+"different translation units")
+parser.add_argument("--input", "-i", help="Directory containing the input"
+" gcov files", required=True)
+parser.add_argument("--output", "-o", help="Output directory for gcov"
+" files. Warning! Output tree will be cleared!", required=True)
+args = parser.parse_args()
+
+if os.path.exists(args.output):
+shutil

[PATCH] D25659: [clang-tidy] Avoid running aliased checks twice

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

In https://reviews.llvm.org/D25659#589081, @malcolm.parsons wrote:

> In https://reviews.llvm.org/D25659#588663, @alexfh wrote:
>
> > In https://reviews.llvm.org/D25659#588658, @alexfh wrote:
> >
> > > I think, silently choosing one of the checks may be confusing and 
> > > counter-intuitive. Should we just warn in case we see the same check 
> > > enabled by multiple aliases?
> >
> >
> > And by "aliases" I mean different names under which the check is 
> > registered. I'm not sure I see the benefit of introducing a separate 
> > concept and a separate API for registering checks under multiple names. 
> > This introduces another sort of dynamic binding, which we have to have good 
> > reasons for.
>
>
> Is using `typeid()` on the constructed checks OK?


I don't think rtti is allowed in LLVM. But we can find a solution, I believe. 
The important thing is to decide what behavior is desired.


https://reviews.llvm.org/D25659



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


Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-08 Thread Alexander Kornienko via cfe-commits
I'd instead ask Static Analyzer folks if they can graduate this check. What
is your experience with it? Do you feel it's good enough for mainstream?

On Nov 8, 2016 2:11 AM, "Malcolm Parsons"  wrote:

> On 8 November 2016 at 08:28, Alexander Kornienko via cfe-commits
>  wrote:
> > [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's
> no need to disable them
>
> Oh, I was using clang-analyzer-alpha.cplusplus.VirtualCall.
>
> Should clang-tidy have an option to enable experimental checks?
>
> --
> Malcolm Parsons
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

2016-11-08 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 77201.
arphaman added a comment.

The updated patch preserves the old behaviour in `-Wshadow-all`


Repository:
  rL LLVM

https://reviews.llvm.org/D26278

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp

Index: test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow %s -D AVOID
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow-all %s
+
+void foo(int param) { // expected-note 1+ {{previous declaration is here}}
+  int var = 0; // expected-note 1+ {{previous declaration is here}}
+
+  // Warn for lambdas with a default capture specifier.
+  {
+auto f1 = [=] { int var = 1; };  // expected-warning {{declaration shadows a local variable}}
+auto f2 = [&] { int var = 2; };  // expected-warning {{declaration shadows a local variable}}
+auto f3 = [=] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [&] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn normally inside of lambdas.
+  auto l1 = [] { // expected-note {{previous declaration is here}}
+  int x = 1; // expected-note {{previous declaration is here}}
+  { int x = 2; } // expected-warning {{declaration shadows a local variable}}
+  };
+  auto l2 = [] (int x) { // expected-note {{previous declaration is here}}
+{ int x = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Avoid warnings for variables that aren't explicitly captured.
+  {
+#ifdef AVOID
+auto f1 = [] { int var = 1; }; // no warning
+auto f2 = [] (int param) { ; }; // no warning
+auto f3 = [param] () { int var = 1; }; // no warning
+auto f4 = [var] (int param) { ; }; // no warning
+#else
+auto f1 = [] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f2 = [] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f3 = [param] () { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [var] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  };
+
+  // Warn for variables that are explicitly captured.
+  {
+auto f1 = [var] () { // expected-note {{variable 'var' is explicitly captured here}}
+  int var = 1; // expected-warning {{declaration shadows a local variable}}
+};
+auto f2 = [param]   // expected-note {{variable 'param' is explicitly captured here}}
+ (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn for variables defined in the capture list.
+  auto l3 = [z = var] { // expected-note {{previous declaration is here}}
+#ifdef AVOID
+int var = 1; // no warning
+#else
+int var = 1; // expected-warning {{declaration shadows a local variable}}
+#endif
+{ int z = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+#ifdef AVOID
+  auto l4 = [var = param] (int param) { ; }; // no warning
+#else
+  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+
+  // Make sure that inner lambdas work as well.
+  auto l5 = [var, l1] { // expected-note {{variable 'l1' is explicitly captured here}}
+auto l1 = [] { // expected-warning {{declaration shadows a local variable}}
+#ifdef AVOID
+  int var = 1; // no warning
+#else
+  int var = 1; // expected-warning {{declaration shadows a local variable}}
+#endif
+};
+#ifdef AVOID
+auto f1 = [] { int var = 1; }; // no warning
+#else
+auto f1 = [] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+auto f2 = [=] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f3 = [var] // expected-note {{variable 'var' is explicitly captured here}}
+  { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Generic lambda arguments should work.
+#ifdef AVOID
+  auto g1 = [](auto param) { ; }; // no warning
+#else
+  auto g1 = [](auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  auto g2 = [param] // expected-note {{variable 'param' is explicitly captured here}}
+   (auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6582,6 +6582,17 @@
   return OldDC->isFileContext() ? SDK_Global : SDK_Local;
 }
 
+/// Return the location of the capture if the given lambda captures the given
+/// variable \p VD, or an invalid source location otherwise.
+static SourceL

[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-11-08 Thread Simon Dardis via cfe-commits
sdardis added a comment.

Ping.


https://reviews.llvm.org/D25866



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


[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

2016-11-08 Thread Reid Kleckner via cfe-commits
rnk added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:361
+def warn_decl_shadow_all :
+  Warning<"declaration shadows a %select{"
+  "local variable|"

Use the .Text accessor like we do here to avoid repeating the text:
```
def warn_objc_pointer_masking : Warning<
  "bitmasking for introspection of Objective-C object pointers is strongly "
  "discouraged">,
  InGroup;
def warn_objc_pointer_masking_performSelector : 
Warning,
```



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:366
+  "field of %2}1">,
+  InGroup, DefaultIgnore;
 def warn_ctor_parm_shadows_field:

Richard seemed to feel it was important to have a 
-Wshadow-field-in-constructor, so we should probably add a 
-Wshadow-uncaptured-local and put that in -Wshadow-all.


Repository:
  rL LLVM

https://reviews.llvm.org/D26278



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


[PATCH] D26118: [clang-tidy] Change readability-redundant-member-init to get base type from constructor

2016-11-08 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: clang-tidy/readability/RedundantMemberInitCheck.cpp:57
"initializer for base class %0 is redundant")
-  << Init->getTypeSourceInfo()->getType()
+  << Construct->getType()
   << FixItHint::CreateRemoval(Init->getSourceRange());

malcolm.parsons wrote:
> aaron.ballman wrote:
> > malcolm.parsons wrote:
> > > aaron.ballman wrote:
> > > > Why is it more correct to use the CXXConstructExpr type information 
> > > > rather than the CXXCtorInitializer?
> > > Something to do with templates and namespaces.
> > > 
> > > In the bug report, `CXXCtorInitializer` had type `std::__1::bitset<128>` 
> > > and `CXXConstructExpr` had type `std::bitset`.
> > > 
> > > I don't know why.
> > I believe it's because `__1` is an inline namespace, and the printing 
> > policy matters. IIRC, there's the `SuppressUnwrittenScope` policy data 
> > member, that if you set it to true, it won't print the inline or anonymous 
> > namespace when printing types.
> > 
> > We should understand why there's a difference before applying this change. 
> > I think using the CXXCtorInitializer's type is more correct than using the 
> > CXXConstructExpr's type (due to implicit type conversions). Given that the 
> > printing policy controls whether inline namespaces are printed, I would 
> > have expected these both to print without the inline namespace (the type 
> > changed, but not the printing policy) -- the fact that the behavior differs 
> > makes me worried there's a bug somewhere else and this fix is masking it.
> The difference isn't just the scope; `MAX_SUBTARGET_FEATURES` became `128` 
> too.
> 
> Looking at `Sema::BuildMemInitializer()` didn't help me.
The lookup of the base type has a Path with sugared type, but the Decl found 
has a canonical type.


https://reviews.llvm.org/D26118



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


[PATCH] D25659: [clang-tidy] Avoid running aliased checks twice

2016-11-08 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D25659#588658, @alexfh wrote:

> I think, silently choosing one of the checks may be confusing and 
> counter-intuitive. Should we just warn in case we see the same check enabled 
> by multiple aliases?


A warning is useful if the checks have different settings, e.g. 
google-readability-braces-around-statements and 
readability-braces-around-statements.

But a warning is just noise for other aliases, e.g. cert-dcl54-cpp and 
misc-new-delete-overloads.


https://reviews.llvm.org/D25659



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


[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

2016-11-08 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 77205.
arphaman marked 2 inline comments as done.
arphaman added a comment.

The updated patch introduces a new warning group named 
`-Wshadow-uncaptured-local` that was suggested by Reid.


Repository:
  rL LLVM

https://reviews.llvm.org/D26278

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp

Index: test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow -D AVOID %s
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow -Wshadow-uncaptured-local %s
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow-all %s
+
+void foo(int param) { // expected-note 1+ {{previous declaration is here}}
+  int var = 0; // expected-note 1+ {{previous declaration is here}}
+
+  // Warn for lambdas with a default capture specifier.
+  {
+auto f1 = [=] { int var = 1; };  // expected-warning {{declaration shadows a local variable}}
+auto f2 = [&] { int var = 2; };  // expected-warning {{declaration shadows a local variable}}
+auto f3 = [=] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [&] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn normally inside of lambdas.
+  auto l1 = [] { // expected-note {{previous declaration is here}}
+  int x = 1; // expected-note {{previous declaration is here}}
+  { int x = 2; } // expected-warning {{declaration shadows a local variable}}
+  };
+  auto l2 = [] (int x) { // expected-note {{previous declaration is here}}
+{ int x = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Avoid warnings for variables that aren't explicitly captured.
+  {
+#ifdef AVOID
+auto f1 = [] { int var = 1; }; // no warning
+auto f2 = [] (int param) { ; }; // no warning
+auto f3 = [param] () { int var = 1; }; // no warning
+auto f4 = [var] (int param) { ; }; // no warning
+#else
+auto f1 = [] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f2 = [] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f3 = [param] () { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [var] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  };
+
+  // Warn for variables that are explicitly captured.
+  {
+auto f1 = [var] () { // expected-note {{variable 'var' is explicitly captured here}}
+  int var = 1; // expected-warning {{declaration shadows a local variable}}
+};
+auto f2 = [param]   // expected-note {{variable 'param' is explicitly captured here}}
+ (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn for variables defined in the capture list.
+  auto l3 = [z = var] { // expected-note {{previous declaration is here}}
+#ifdef AVOID
+int var = 1; // no warning
+#else
+int var = 1; // expected-warning {{declaration shadows a local variable}}
+#endif
+{ int z = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+#ifdef AVOID
+  auto l4 = [var = param] (int param) { ; }; // no warning
+#else
+  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+
+  // Make sure that inner lambdas work as well.
+  auto l5 = [var, l1] { // expected-note {{variable 'l1' is explicitly captured here}}
+auto l1 = [] { // expected-warning {{declaration shadows a local variable}}
+#ifdef AVOID
+  int var = 1; // no warning
+#else
+  int var = 1; // expected-warning {{declaration shadows a local variable}}
+#endif
+};
+#ifdef AVOID
+auto f1 = [] { int var = 1; }; // no warning
+#else
+auto f1 = [] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+auto f2 = [=] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f3 = [var] // expected-note {{variable 'var' is explicitly captured here}}
+  { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Generic lambda arguments should work.
+#ifdef AVOID
+  auto g1 = [](auto param) { ; }; // no warning
+#else
+  auto g1 = [](auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
+#endif
+  auto g2 = [param] // expected-note {{variable 'param' is explicitly captured here}}
+   (auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6582,6 +6582,17

[PATCH] D25948: [VFS] Replace TimeValue usage with std::chrono

2016-11-08 Thread Ben Langmuir via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

LGTM, sorry for the delay.


https://reviews.llvm.org/D25948



___
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
hokein updated this revision to Diff 77208.
hokein marked 2 inline comments as done.
hokein added a comment.

Fix remaining comments.


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 &Spec) {
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec,
+   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 = [&FileToSourceText, &Context, &FileToFileID](
   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,72 @@
   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]);
+  }
+}
+
+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]);
+  }
+}
+
+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, Results[Spec.NewHeader]);
+  }
+}
+
 } // namespace
 } // namespce move
 } // namespace clang
Index: test/clang-move/move-class.cpp
===
--- test/clang-move/move-class.cpp
+++ test/clang-move/move-class.c

Re: [clang-tools-extra] r286222 - [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them

2016-11-08 Thread Malcolm Parsons via cfe-commits
On 8 November 2016 at 16:59, Alexander Kornienko  wrote:
> On Nov 8, 2016 2:11 AM, "Malcolm Parsons"  wrote:
>> Oh, I was using clang-analyzer-alpha.cplusplus.VirtualCall.
>>
>> Should clang-tidy have an option to enable experimental checks?
>
> I'd instead ask Static Analyzer folks if they can graduate this check. What
> is your experience with it? Do you feel it's good enough for mainstream?

It found lots of places where delegating constructors, final classes
or final virtual methods would be useful.
I agreed with its analysis.

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


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

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



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

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.


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] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-08 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

Your code comment seem to describe the issue quite well. Even though I am still 
inclined towards keeping the address spaces as long as possible and only 
converting into physical memory segments on the backend really. I believe there 
are a couple of flatten memory architectures that do that and it seems to work 
fine. But on the other hand it seems that there are other implementations that 
took the path of flattening directly in Clang and therefore are facing the 
issue you are solving now.

I will try to send some draft on OpenCL documentation in Clang hopefully the 
following weeks. Perhaps it will help us to converge to the common flow at some 
point.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26282: [PowerPC] Implement plain VSX load/store builtins.

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


https://reviews.llvm.org/D26282



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


[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

2016-11-08 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D26278



___
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 Eric Liu via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with a few nits.




Comment at: clang-move/ClangMove.cpp:539
+  const FileEntry *FE = SM.getFileManager().getFile(
+  MakeAbsolutePath(OriginalRunningDirectory, OldFile));
+  if (!FE) {

I'd probably pull this out as an inline function to save some typing.

```
inline std::string ClangMoveTool::MakeAbsolute(Path) {
return MakeAbsolutePath(OriginalRunningDirectory, OldFile));
}
```





Comment at: unittests/clang-move/ClangMoveTests.cpp:286
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(Header, Results[Spec.NewHeader]);
+  }

Please also check old header is removed or empty.



Comment at: unittests/clang-move/ClangMoveTests.cpp:329
+auto Results = runClangMoveOnCode(Spec, Header.c_str(), Code);
+EXPECT_EQ(ExpectedHeader, Results[Spec.NewHeader]);
+  }

Please also check old headers.


https://reviews.llvm.org/D26236



___
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


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[10]>;",
> +format("auto a = unique_ptr < Foo < Bar>[ 10]> ;"));
> +
> +  FormatStyle Spaces = getLLVMStyle();
> +  Spaces.SpacesInSquareBrackets = true;
> +  EXPECT_EQ("auto a = unique_ptr[ 10 ]>;",
> +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] 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


[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] 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] 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: 

[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&view=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&r1=286256&r2=286257&view=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&r1=286256&r2=286257&view=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&view=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&r1=286261&r2=286262&view=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 &SFC,
unsigned FUID) :
   FC(FC), Result(Str), Traits(Traits), SM(SM),
-  FormatRewriterContext(SFC),
   FormatInMemoryUniqueId(FUID) { }
 
   // Inline content.
@@ -574,7 +573,6 @@ private:
 
   const CommandTraits &Traits;
   const SourceManager &SM;
-  SimpleFormatContext &FormatRewriterContext;
   unsigned FormatInMemoryUniqueId;
 };
 


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


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&view=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&r1=286263&r2=286264&view=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 &SFC,
unsigned FUID) :
   FC(FC), Result(Str), Traits(Traits), SM(SM),
+  FormatRewriterContext(SFC),
   FormatInMemoryUniqueId(FUID) { }
 
   // Inline content.
@@ -573,6 +574,7 @@ private:
 
   const CommandTraits &Traits;
   const SourceManager &SM;
+  SimpleFormatContext &FormatRewriterContext;
   unsigned FormatInMemoryUniqueId;
 };
 


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


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&view=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&r1=286242&r2=286243&view=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
> &Replaces,
>const FormatStyle &Style);
>
> -/// \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 &Style,
> -   SourceManager &SourceMgr, 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 &Style, 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 &Style,
> -  SourceManager &SourceMgr, 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 &Style, 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&r1=286242&r2=286243&view=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 &Style, SourceManager
> &SM,
> -   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 &Style, 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 &Style, SourceManager &SM,
> -  FileID ID, ArrayRef
> Ranges) {
> -  Environment Env(SM, ID, Ranges);
> -  Cleaner Clean(Env, Style);

[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 &Code, const std::string &Filename) {
 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, &Errors, 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

[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] 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] D26406: Add -Wduplicate-protocol for existing diagnostic

2016-11-08 Thread Alex Lorenz via cfe-commits
arphaman added a comment.

I'm not sure that it's required, but shouldn't we have also have a test that 
checks for the usage of this flag as well? Adding a test case with `#pragma 
clang diagnostic ignored "-Wduplicate-protocol"` and some code to a file like 
"test/SemaObjC/check-dup-objc-decls-1.m" should be sufficient.


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] 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] 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] 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] 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


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&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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() & Sani

[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


[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] 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 &Spec) {
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec,
+   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 = [&FileToSourceText, &Context, &FileToFileID](
   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, Results[Spec.NewHeader]);
+// The expected old header should not contain class A

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&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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).

> + 

[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 &&r) {
   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&R-style 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 

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&view=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&r1=285945&r2=285946&view=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
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&view=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&r1=285945&r2=285946&view=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] 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


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&view=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&r1=286278&r2=286279&view=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&r1=286278&r2=286279&view=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 &Str,
const CommandTraits &Traits,
-   const SourceManager &SM,
-   SimpleFormatContext &SFC,
-   unsigned FUID) :
-  FC(FC), Result(Str), Traits(Traits), SM(SM),
-  FormatRewriterContext(SFC),
-  FormatInMemoryUniqueId(FUID) { }
+   const SourceManager &SM) :
+  FC(FC), Result(Str), Traits(Traits), SM(SM) { }
 
   // Inline content.
   void visitTextComment(const TextComment *C);
@@ -574,8 +569,6 @@ private:
 
   const CommandTraits &Traits;
   const SourceManager &SM;
-  SimpleFormatContext &FormatRewriterContext;
-  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, &IncompleteFormat);
+   tooling::Range(Offset, Length), "xmldecl.xd", 
&IncompleteFormat);
   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 &XML,
 const ASTContext &Context) {
-  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] 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


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&view=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&r1=286242&r2=286243&view=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
>> &Replaces,
>>const FormatStyle &Style);
>>
>> -/// \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 &Style,
>> -   SourceManager &SourceMgr, 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 &Style, 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 &Style,
>> -  SourceManager &SourceMgr, 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 &Style, 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&r1=286242&r2=286243&view=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 &Style, SourceManager
>> &SM,
>> -   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 &Style, StringRef Code,
>> ArrayRef Ranges,
>> StringRef FileName, bool
>> *IncompleteFormat) {
>> @@ -1760,13 +1748,6 @@ tooling::Replacements reformat(const For
>>return Format.process();
>>  }
>

[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), runChangeNamespaceOn

[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&view=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&r1=286280&r2=286281&view=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] 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 %0">;
___
cfe-commits mai

[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] 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);
   bool

[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] 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] 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&id=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 &Spec) {
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec &Spec,
+   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 = [&FileToSourceText, &Context, &FileToFileID](
   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("

[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] 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] 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] 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 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] 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 addr

Re: r284272 - Implement no_sanitize_address for global vars

2016-11-08 Thread Kostya Serebryany via cfe-commits
On Tue, Nov 8, 2016 at 11:27 AM, Douglas Katzman  wrote:

> oh, sorry for missing this email.
> I'll say "no" - I was hoping you'd audit it!
>

We do indeed have this practice for post-commit audit, but only for the
authors or active maintainers of the piece of code in question.
I afraid I do not fully understand the consequences of this patch -- they
may be non-trivial.
Please initiate a code review (even though the code is already committed).

--kcc


>
> 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&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=diff
 
 ==
 --- cfe/trunk/lib/CodeGe

Re: r284272 - Implement no_sanitize_address for global vars

2016-11-08 Thread Aaron Ballman via cfe-commits
On Tue, Nov 8, 2016 at 3:52 PM, Kostya Serebryany via cfe-commits
 wrote:
>
>
> On Tue, Nov 8, 2016 at 11:27 AM, Douglas Katzman  wrote:
>>
>> oh, sorry for missing this email.
>> I'll say "no" - I was hoping you'd audit it!
>
>
> We do indeed have this practice for post-commit audit, but only for the
> authors or active maintainers of the piece of code in question.
> I afraid I do not fully understand the consequences of this patch -- they
> may be non-trivial.
> Please initiate a code review (even though the code is already committed).

I concur; please add me as a reviewer.

~Aaron

>
> --kcc
>
>>
>>
>> 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
  wrote:
>
> Author: dougk
> Date: Fri Oct 14 14:55:09 2016
> New Revision: 284272
>
> URL: http://llvm.org/viewvc/llvm-project?rev=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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&r1=284271&r2=284272&view=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/viewv

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

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



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

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.


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 &In, int &Out) { 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 objec

[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] 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&id=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&view=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&r1=286294&r2=286295&view=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&view=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] 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] 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] 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] 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


  1   2   >