Re: [PATCH] D17437: [OpenCL] Add Sema checks for types

2016-02-22 Thread Xiuli PAN via cfe-commits
pxli168 retitled this revision from "[OpenCL] Add Sema checks for image and 
pipe" to "[OpenCL] Add Sema checks for types".
pxli168 updated the summary for this revision.
pxli168 updated this revision to Diff 48654.
pxli168 marked an inline comment as done.
pxli168 added a comment.

Refine comments and diag.


http://reviews.llvm.org/D17437

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGenOpenCL/opencl_types.cl
  test/SemaOpenCL/invalid-image.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -6,3 +6,6 @@
 }
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' 
declaration specifier}}
 }
+void test4() {
+  pipe int p; // expected-error {{type 'pipe' can only be used as a function 
parameter}}
+}
Index: test/SemaOpenCL/invalid-image.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-image.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify %s
+
+void test1(image1d_t *i){} // expected-error {{pointer to type 'image1d_t' is 
invalid in OpenCL}}
+
+void test2() {
+  image1d_t i; // expected-error {{type 'image1d_t' can only be used as a 
function parameter}}
+}
Index: test/CodeGenOpenCL/opencl_types.cl
===
--- test/CodeGenOpenCL/opencl_types.cl
+++ test/CodeGenOpenCL/opencl_types.cl
@@ -36,5 +36,5 @@
 // CHECK: call {{.*}}void @fnc4smp(i32
 }
 
-void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t 
*d) {}
-// CHECK-LABEL: 
@{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}}
+void __attribute__((overloadable)) bad1(image1d_t b, image2d_t c, image2d_t d) 
{}
+// CHECK-LABEL: 
@{{_Z4bad111ocl_image1d11ocl_image2dS0_|"\\01\?bad1@@\$\$J0YAXPAUocl_image1d@@PAUocl_image2d@@1@Z"}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5710,6 +5710,17 @@
   QualType R = TInfo->getType();
   DeclarationName Name = GetNameForDeclarator(D).getName();
 
+  // OpenCL v2.0 s6.9.b - Image type can only be used as a function argument.
+  // OpenCL v2.0 s6.13.16.1 - Pipe type can only be used as a function
+  // argument.
+  if (getLangOpts().OpenCL && (R->isImageType() || R->isPipeType())) {
+Diag(D.getIdentifierLoc(),
+ diag::err_opencl_type_can_only_be_used_as_function_parameter)
+<< R;
+D.setInvalidType();
+return nullptr;
+  }
+
   DeclSpec::SCS SCSpec = D.getDeclSpec().getStorageClassSpec();
   StorageClass SC = StorageClassSpecToVarDeclStorageClass(D.getDeclSpec());
 
@@ -10737,7 +10748,17 @@
   Diag(NameLoc, diag::err_arg_with_address_space);
   New->setInvalidDecl();
 }
-  }   
+  }
+
+  // OpenCL v2.0 s6.9b - Pointer to image/sampler cannot be used.
+  // OpenCL v2.0 s6.13.16.1 - Pointer to pipe cannot be used.
+  if (getLangOpts().OpenCL && T->isPointerType()) {
+const QualType PTy = T->getPointeeType();
+if (PTy->isImageType() || PTy->isSamplerT() || PTy->isPipeType()) {
+  Diag(NameLoc, diag::err_opencl_pointer_to_type) << PTy;
+  New->setInvalidDecl();
+}
+  }
 
   return New;
 }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7703,6 +7703,10 @@
   "array of block type is invalid in OpenCL">;
 def err_opencl_ternary_with_block : Error<
   "block type cannot be used as expression in ternary expression in OpenCL">;
+def err_opencl_pointer_to_type : Error<
+  "pointer to type %0 is invalid in OpenCL">;
+def err_opencl_type_can_only_be_used_as_function_parameter : Error <
+  "type %0 can only be used as a function parameter in OpenCL">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -6,3 +6,6 @@
 }
 void test3(int pipe p){// expected-error {{cannot combine with previous 'int' declaration specifier}}
 }
+void test4() {
+  pipe int p; // expected-error {{type 'pipe' can only be used as a function parameter}}
+}
Index: test/SemaOpenCL/invalid-image.cl
===
--- /dev/null
+++ test/SemaOpenCL/invalid-image.cl
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -verify %s
+
+void test1(image1d_t *i){} // expected-error {{pointer to type 'image1d_t' is invalid in OpenCL}}
+
+void test2() {
+  image1d_t i; // expected-error {{type 'image1d_t' can 

Re: [PATCH] D17437: [OpenCL] Add Sema checks for types

2016-02-22 Thread Xiuli PAN via cfe-commits
pxli168 added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:5725
@@ +5724,3 @@
+  // Pipes can only be passed as arguments to a function.
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200 &&
+  R->isPipeType()) {

Anastasia wrote:
> Remove 'getLangOpts().OpenCLVersion >= 200'. Parser will only allow pipe for 
> CL2.0. Ideally we don't need to check getLangOpts().OpenCL either, but might 
> be good to leave it for documentation purposes.
> 
> However could we merge with the previous:
>   if (getLangOpts().OpenCL) {
>if (...) ... // image type
>if (...) ... // pipe type
>   }
Ok, it should be more clear.


Comment at: lib/Sema/SemaDecl.cpp:10768
@@ -10746,1 +10767,3 @@
 
+  // OpenCL v2.0 s6.9b2 - An image type cannot be used to declare a variable, a
+  // structure or union field, an array of images, a pointer to an image, or 
the

Anastasia wrote:
> Here you only check the pointer and not the other bits. So please modify the 
> comment according to what the code does.
> 
> Does the same restriction apply to other OpenCL types i.e. sampler, event, 
> queue, etc? 
Good suggestion. I will have a look and try to add them.


Comment at: test/CodeGenOpenCL/opencl_types.cl:39
@@ -38,3 @@
-
-void __attribute__((overloadable)) bad1(image1d_t *b, image2d_t *c, image2d_t 
*d) {}
-// CHECK-LABEL: 
@{{_Z4bad1P11ocl_image1dP11ocl_image2dS2_|"\\01\?bad1@@\$\$J0YAXPE?APAUocl_image1d@@PE?APAUocl_image2d@@1@Z"}}

Anastasia wrote:
> Could you please not remove this mangling test as it's not being tested 
> elsewhere.
> 
> You can remove * from parameters though!
OK, I will try to make this mangle right for different target.


Comment at: test/SemaOpenCL/invalid-pipes-cl2.0.cl:9
@@ -8,1 +8,3 @@
 }
+void test4() {
+  pipe int p; // expected-error {{pipe can only be used as a function 
parameter}}

yaxunl wrote:
> Do we have a test for diagnosing pipe type for OCL < 2.0 ?
We have one called test/SemaOpenCL/pipes-1.2-negative.cl


http://reviews.llvm.org/D17437



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


r261516 - [CLANG] [AVX512] [BUILTIN] Adding prol{d|q|w}{128|256|512} builtin to clang .

2016-02-22 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Feb 22 03:05:41 2016
New Revision: 261516

URL: http://llvm.org/viewvc/llvm-project?rev=261516&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding prol{d|q|w}{128|256|512} builtin to clang .

Differential Revision: http://reviews.llvm.org/D16985

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-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=261516&r1=261515&r2=261516&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Feb 22 03:05:41 2016
@@ -1608,6 +1608,12 @@ TARGET_BUILTIN(__builtin_ia32_pmovzxwd12
 TARGET_BUILTIN(__builtin_ia32_pmovzxwd256_mask, "V8iV8sV8iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovzxwq128_mask, 
"V2LLiV8sV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pmovzxwq256_mask, 
"V4LLiV8sV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_prold512_mask, "V16iV16iIiV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_prolq512_mask, 
"V8LLiV8LLiIiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_prold128_mask, "V4iV4iIiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_prold256_mask, "V8iV8iIiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_prolq128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_prolq256_mask, 
"V4LLiV4LLiIiV4LLiUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=261516&r1=261515&r2=261516&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Feb 22 03:05:41 2016
@@ -3330,6 +3330,41 @@ _mm512_maskz_cvtepu16_epi64 (__mmask8 __
  (__v8di)(__m512i)(b), (p), \
  (__mmask8)(m)); })
 
+#define _mm512_rol_epi32(a, b) __extension__ ({ \
+  (__m512i) __builtin_ia32_prold512_mask ((__v16si) (a), (b),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16) -1); })
+
+#define _mm512_mask_rol_epi32(W, U, a, b) __extension__ ({ \
+  (__m512i) __builtin_ia32_prold512_mask ((__v16si) (a), (b),\
+  (__v16si) (W),\
+  (__mmask16) (U)); })
+
+#define _mm512_maskz_rol_epi32(U, a, b) __extension__ ({ \
+  (__m512i) __builtin_ia32_prold512_mask ((__v16si) (a), (b),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16) (U)); })
+
+#define _mm512_rol_epi64(a, b) __extension__ ({ \
+  (__m512i) __builtin_ia32_prolq512_mask ((__v8di) (a), (b),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8) -1); })
+
+#define _mm512_mask_rol_epi64(W, U, a, b) __extension__ ({ \
+  (__m512i) __builtin_ia32_prolq512_mask ((__v8di) (a), (b),\
+  (__v8di) (W),\
+  (__mmask8) (U)); })
+
+#define _mm512_maskz_rol_epi64(U, a, b) __extension__ ({ \
+  (__m512i) __builtin_ia32_prolq512_mask ((__v8di) (a), (b),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8) (U)); })
+
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif // __AVX512FINTRIN_H

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=261516&r1=261515&r2=261516&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Mon Feb 22 03:05:41 2016
@@ -31,6 +31,11 @@
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("avx512vl")))
 #define __DEFAULT_FN_ATTRS_BOTH __attribute__((__always_inline__, __nodebug__, 
__target__("avx512vl, avx512bw")))
 
+static  __inline __v2di __DEFAULT_FN_ATTRS
+_mm_setzero_di(void) {
+  return (__v2di){ 0, 0};
+}
+
 /* Integer compare */
 
 static __inline__ __mmask8 __DEFAULT_FN_ATTRS_BOTH
@@ -4942,6 +4947,74 @@ _mm256_maskz_cvtepu16_epi64 (__mmask8 __
 }
 
 
+#define _mm_rol_epi32(a, b) __extension__ ({\

r261518 - [CLANG] [AVX512] [BUILTIN] Adding prol{d|q|w}{128|256|512} builtin to clang .

2016-02-22 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Feb 22 03:42:57 2016
New Revision: 261518

URL: http://llvm.org/viewvc/llvm-project?rev=261518&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding prol{d|q|w}{128|256|512} builtin to clang .

Fixing problem with the lib/include/avx512vlintrin.h file. 
Adding one more _ to the prefix of _extension__ -> __extension__.

Differential Revision: http://reviews.llvm.org/D16985

Modified:
cfe/trunk/lib/Headers/avx512vlintrin.h

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=261518&r1=261517&r2=261518&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Mon Feb 22 03:42:57 2016
@@ -4981,7 +4981,7 @@ _mm256_maskz_cvtepu16_epi64 (__mmask8 __
  _mm256_setzero_si256 (),\
  (__mmask8) (u)); })
 
-#define _mm_rol_epi64(a, b) _extension__ ({\
+#define _mm_rol_epi64(a, b) __extension__ ({\
(__m128i)__builtin_ia32_prolq128_mask((__v2di) (a), (b),\
  (__v2di)\
  _mm_setzero_di (),\


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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 48657.
hokein marked an inline comment as done.
hokein added a comment.

- Address review comments.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  test/clang-tidy/Inputs/compilation-database/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,6 @@
+// REQUIRES: shell
+// RUN: sed 's|test_dir|%S|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %s -header-filter=.* | FileCheck %s -implicit-check-not="{{warning:}}"
+
+#include "./Inputs/compilation-database/header.h"
+// CHECK: warning: use nullptr [modernize-use-nullptr]
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "test_dir",
+  "command": "clang++ -o test.o clang-tidy-run-with-database.cpp",
+  "file": "test_dir/clang-tidy-run-with-database.cpp"
+}
+]
Index: test/clang-tidy/Inputs/compilation-database/header.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/header.h
@@ -0,0 +1,3 @@
+#define NULL 0
+
+int *a = NULL;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -57,8 +57,17 @@
 Error = DiagnosticsEngine::Error
   };
 
-  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError);
-
+  ClangTidyError(StringRef CheckName, Level DiagLevel, bool IsWarningAsError,
+ const std::string &BuildDirectory);
+
+  // A build directory of the source file containing the error.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // It can be empty in some cases, e.g. the source file does not exist.
+  std::string BuildDirectory;
   std::string CheckName;
   ClangTidyMessage Message;
   tooling::Replacements Fix;
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -116,9 +116,10 @@
 
 ClangTidyError::ClangTidyError(StringRef CheckName,
ClangTidyError::Level DiagLevel,
-   bool IsWarningAsError)
-: CheckName(CheckName), DiagLevel(DiagLevel),
-  IsWarningAsError(IsWarningAsError) {}
+   bool IsWarningAsError,
+   const std::string &BuildDirectory)
+: BuildDirectory(std::move(BuildDirectory)), CheckName(CheckName),
+  DiagLevel(DiagLevel), IsWarningAsError(IsWarningAsError) {}
 
 // Returns true if GlobList starts with the negative indicator ('-'), removes it
 // from the GlobList.
@@ -335,7 +336,17 @@
 bool IsWarningAsError =
 DiagLevel == DiagnosticsEngine::Warning &&
 Context.getWarningAsErrorFilter().contains(CheckName);
-Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError));
+
+std::string BuildDirectory;
+if (Info.hasSourceManager()) {
+  auto WorkingDir = Info.getSourceManager()
+.getFileManager().getVirtualFileSystem()
+->getCurrentWorkingDirectory();
+  if (WorkingDir)
+BuildDirectory = WorkingDir.get();
+}
+Errors.push_back(
+ClangTidyError(CheckName, Level, IsWarningAsError, BuildDirectory));
   }
 
   // FIXME: Provide correct LangOptions for each file.
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -109,6 +109,13 @@
 
   void reportDiagnostic(const ClangTidyError &Error) {
 const ClangTidyMessage &Message = Error.Message;
+// By default, the working directory of file system is the current
+// clang-tidy running directory.
+//
+// Change the directory to the one used during the analysis.
+if (!Error.BuildDirectory.empty())
+  Files.getVirtualFileSystem()->setCurrentWorkingDirectory(
+  Error.BuildDirectory);
 SourceLocation Loc = getLocation(Message.FilePath, Message.FileOffset);
 // Contains a pair for each attempted fix: location and whethe

Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein marked 4 inline comments as done.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:120
@@ +119,3 @@
+   bool IsWarningAsError,
+   const std::string &BuildDirectory)
+: BuildDirectory(std::move(BuildDirectory)), CheckName(CheckName),

We might not use `StringRef` here since 
`SourceManager.getFileManager().getVirtualFileSystem().getCurrentWorkingDirectory()`
 returns `std::string`.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.h:66
@@ +65,3 @@
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.

However, I see the `compile_commands.json` is hardcoded in source. 
http://clang.llvm.org/doxygen/JSONCompilationDatabase_8cpp_source.html#l00111


http://reviews.llvm.org/D17335



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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-22 Thread Michael Matz via cfe-commits
Hi,

On Fri, 19 Feb 2016, Richard Smith wrote:

> >> > The trivially copyable is gone again.  Why is it not necessary?
> >>
> >> The C++ ABI doesn't defer to the C psABI for types that aren't
> >> trivially-copyable. See
> >> http://mentorembedded.github.io/cxx-abi/abi.html#normal-call
> >
> > Hmm, yes, but we don't want to define something for only C and C++, but
> > language independend (so far as possible).  And given only the above
> > language I think this type:
> >
> > struct S {
> >   S() {something();}
> > };
> >
> > would be an empty type, and that's not what we want.
> 
> Yes it is. Did you mean to give S a copy constructor, copy assignment
> operator, or destructor instead?

Er, yes, I did mean to :-)


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


Re: r261506 - Fix PR24473 : Teach clang to remember to substitute into member variable templates referred to within dependent qualified ids.

2016-02-22 Thread Faisal Vali via cfe-commits
On Sun, Feb 21, 2016 at 11:45 PM, Richard Smith  wrote:
> On 21 Feb 2016 8:21 p.m., "Faisal Vali"  wrote:
>>
>> On Sun, Feb 21, 2016 at 10:06 PM, Richard Smith 
>> wrote:
>> > On 21 Feb 2016 6:29 p.m., "Faisal Vali via cfe-commits"
>> >  wrote:
>> >>
>> >> Author: faisalv
>> >> Date: Sun Feb 21 20:24:29 2016
>> >> New Revision: 261506
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=261506&view=rev
>> >> Log:
>> >> Fix PR24473 : Teach clang to remember to substitute into member
>> >> variable
>> >> templates referred to within dependent qualified ids.
>> >>
>> >> In passing also fix a semi-related bug that allows access to variable
>> >> templates through member access notation.
>> >>
>> >>
>> >> Modified:
>> >> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> >> cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
>> >>
>> >> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
>> >> URL:
>> >>
>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=261506&r1=261505&r2=261506&view=diff
>> >>
>> >>
>> >> ==
>> >> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
>> >> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sun Feb 21 20:24:29 2016
>> >> @@ -902,6 +902,32 @@ static bool IsInFnTryBlockHandler(const
>> >>return false;
>> >>  }
>> >>
>> >> +static VarDecl *
>> >> +getVarTemplateSpecialization(Sema &S, VarTemplateDecl *VarTempl,
>> >> +  const TemplateArgumentListInfo *TemplateArgs,
>> >> +  const DeclarationNameInfo &MemberNameInfo,
>> >> +  SourceLocation TemplateKWLoc) {
>> >> +
>> >> +  if (!TemplateArgs) {
>> >> +S.Diag(MemberNameInfo.getBeginLoc(), diag::err_template_decl_ref)
>> >> +<< /*Variable template*/ 1 << MemberNameInfo.getName()
>> >> +<< MemberNameInfo.getSourceRange();
>> >> +
>> >> +S.Diag(VarTempl->getLocation(), diag::note_template_decl_here);
>> >> +
>> >> +return nullptr;
>> >> +  }
>> >> +  DeclResult VDecl = S.CheckVarTemplateId(
>> >> +  VarTempl, TemplateKWLoc, MemberNameInfo.getLoc(),
>> >> *TemplateArgs);
>> >> +  if (VDecl.isInvalid())
>> >> +return nullptr;
>> >> +  VarDecl *Var = cast(VDecl.get());
>> >> +  if (!Var->getTemplateSpecializationKind())
>> >> +Var->setTemplateSpecializationKind(TSK_ImplicitInstantiation,
>> >> +   MemberNameInfo.getLoc());
>> >> +  return Var;
>> >> +}
>> >> +
>> >>  ExprResult
>> >>  Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
>> >> SourceLocation OpLoc, bool IsArrow,
>> >> @@ -1069,9 +1095,20 @@ Sema::BuildMemberReferenceExpr(Expr *Bas
>> >>// Handle the implicit-member-access case.
>> >>if (!BaseExpr) {
>> >>  // If this is not an instance member, convert to a non-member
>> >> access.
>> >> -if (!MemberDecl->isCXXInstanceMember())
>> >> +if (!MemberDecl->isCXXInstanceMember()) {
>> >> +  // If this is a variable template, get the instantiated variable
>> >> +  // declaration corresponding to the supplied template arguments
>> >> +  // (while emitting diagnostics as necessary) that will be
>> >> referenced
>> >> +  // by this expression.
>> >> +  if (isa(MemberDecl)) {
>> >> +MemberDecl = getVarTemplateSpecialization(
>> >> +*this, cast(MemberDecl), TemplateArgs,
>> >> +R.getLookupNameInfo(), TemplateKWLoc);
>> >> +if (!MemberDecl)
>> >> +  return ExprError();
>> >> +  }
>> >>return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(),
>> >> MemberDecl);
>> >
>> > Does this properly preserve the template argument list as written?
>> >
>>
>> Shouldn't it? Since it passes on the passed in template argument list
>> (that I'm assuming is preserved) to CheckVarTemplateId?
>
> None of the three arguments passed to BuildDeclarationNameExpr references
> the template argument list as written. Passing it to CheckVarTemplateId is
> insufficient -- that can't preserve the template arguments from each use,
> because it produces the same result for all uses.
>

I see what you mean.  I'll pass the TemplateArgs through to
BuildDeclRefExpr so it is preserved within that node.  Does it make
sense to squirrel the FoundDecl (the template)  within  the
DeclRefExpr node too?



>> Perhaps you have an example in mind?
>>
>> Thanks!
>>
>> >> -
>> >> +}
>> >>  SourceLocation Loc = R.getNameLoc();
>> >>  if (SS.getRange().isValid())
>> >>Loc = SS.getRange().getBegin();
>> >> @@ -1127,6 +1164,15 @@ Sema::BuildMemberReferenceExpr(Expr *Bas
>> >> TemplateKWLoc, Enum, FoundDecl,
>> >> MemberNameInfo,
>> >> Enum->getType(), VK_RValue, OK_Ordinary);
>> >>}
>> >> +  if (VarTemplateDecl *VarTempl =
>> >> dyn_cast(MemberDecl))
>> >> {
>> >> +if (VarDecl *Var = getVarTemplateSpecialization(
>>

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-22 Thread Michael Matz via cfe-commits
Hi,

On Sat, 20 Feb 2016, Richard Smith wrote:

> > An empty type is a type where it and all of its subobjects 
> > (recursively) are of class, structure, union, or array type.
> >
> > doesn't cover "trivially-copyable".
> 
> That's correct. Whether a type is trivially copyable is unrelated to 
> whether it is empty.

I would still feel more comfortable to include the restriction to 
trivially copyable types, not in the part of definition of empty type, of 
course, but as part of the restrictions of when a type can be passed in no 
registers.  Basically to clarify the intent in the psABI if there's any 
doubt.  I.e. like so:

---
An empty type is a type where it and all of its subobjects (recursively)
are of class, structure, union, or array type.  No memory slot nor 
register should be used to pass or return an object of empty type that's 
trivially copyable.
---

(With possibly a self-sufficient definition of trivially copyable, that's 
language agnostic)


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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:120
@@ +119,3 @@
+   bool IsWarningAsError,
+   const std::string &BuildDirectory)
+: BuildDirectory(std::move(BuildDirectory)), CheckName(CheckName),

hokein wrote:
> We might not use `StringRef` here since 
> `SourceManager.getFileManager().getVirtualFileSystem().getCurrentWorkingDirectory()`
>  returns `std::string`.
As discussed offline, it makes sense to avoid calling 
`SourceManager.getFileManager().getVirtualFileSystem().getCurrentWorkingDirectory()`
 for each error, since it already has a cost of at least a string 
allocation/copy, but might also be an actual I/O operation. We can assume the 
working directory doesn't change while parsing a file, so we can cache it in 
the `ClangTidyContext` together with the current file name. Once we do this, we 
can get a `StringRef` to the working directory stored in `ClangTidyContext` and 
pass it here (but still store a `std::string` to avoid dependencies on a 
lifetime of an external string).


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.h:66
@@ +65,3 @@
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.

hokein wrote:
> However, I see the `compile_commands.json` is hardcoded in source. 
> http://clang.llvm.org/doxygen/JSONCompilationDatabase_8cpp_source.html#l00111
Yes, but this is just one implementation of a compilation database. There are 
other implementations as well.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.h:66
@@ +65,3 @@
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.

alexfh wrote:
> hokein wrote:
> > However, I see the `compile_commands.json` is hardcoded in source. 
> > http://clang.llvm.org/doxygen/JSONCompilationDatabase_8cpp_source.html#l00111
> Yes, but this is just one implementation of a compilation database. There are 
> other implementations as well.
nit: "the compilation database"


http://reviews.llvm.org/D17335



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


r261522 - Make Sema::CheckFormatString a static function inside SemaChecking.cpp

2016-02-22 Thread Andy Gibbs via cfe-commits
Author: andyg
Date: Mon Feb 22 07:00:43 2016
New Revision: 261522

URL: http://llvm.org/viewvc/llvm-project?rev=261522&view=rev
Log:
Make Sema::CheckFormatString a static function inside SemaChecking.cpp

No functionality change.  Change at the request of Richard Trieu, see
http://reviews.llvm.org/D15636#357858.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=261522&r1=261521&r2=261522&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb 22 07:00:43 2016
@@ -9111,13 +9111,6 @@ public:
   };
   static FormatStringType GetFormatStringType(const FormatAttr *Format);
 
-  void CheckFormatString(const StringLiteral *FExpr, const Expr 
*OrigFormatExpr,
- ArrayRef Args, bool HasVAListArg,
- unsigned format_idx, unsigned firstDataArg,
- FormatStringType Type, bool inFunctionCall,
- VariadicCallType CallType,
- llvm::SmallBitVector &CheckedVarArgs);
-  
   bool FormatStringHasSArg(const StringLiteral *FExpr);
   
   static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=261522&r1=261521&r2=261522&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Feb 22 07:00:43 2016
@@ -3265,6 +3265,16 @@ enum StringLiteralCheckType {
 };
 } // end anonymous namespace
 
+static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
+  const Expr *OrigFormatExpr,
+  ArrayRef Args,
+  bool HasVAListArg, unsigned format_idx,
+  unsigned firstDataArg,
+  Sema::FormatStringType Type,
+  bool inFunctionCall,
+  Sema::VariadicCallType CallType,
+  llvm::SmallBitVector &CheckedVarArgs);
+
 // Determine if an expression is a string literal or constant string.
 // If this function returns false on the arguments to a function expecting a
 // format string, we will usually need to emit a warning.
@@ -3437,8 +3447,9 @@ checkFormatStringExpr(Sema &S, const Exp
   StrE = cast(E);
 
 if (StrE) {
-  S.CheckFormatString(StrE, E, Args, HasVAListArg, format_idx, 
firstDataArg,
-  Type, InFunctionCall, CallType, CheckedVarArgs);
+  CheckFormatString(S, StrE, E, Args, HasVAListArg, format_idx,
+firstDataArg, Type, InFunctionCall, CallType,
+CheckedVarArgs);
   return SLCT_CheckedLiteral;
 }
 
@@ -4906,27 +4917,30 @@ bool CheckScanfHandler::HandleScanfSpeci
   return true;
 }
 
-void Sema::CheckFormatString(const StringLiteral *FExpr,
- const Expr *OrigFormatExpr,
- ArrayRef Args,
- bool HasVAListArg, unsigned format_idx,
- unsigned firstDataArg, FormatStringType Type,
- bool inFunctionCall, VariadicCallType CallType,
- llvm::SmallBitVector &CheckedVarArgs) {
+static void CheckFormatString(Sema &S, const StringLiteral *FExpr,
+  const Expr *OrigFormatExpr,
+  ArrayRef Args,
+  bool HasVAListArg, unsigned format_idx,
+  unsigned firstDataArg,
+  Sema::FormatStringType Type,
+  bool inFunctionCall,
+  Sema::VariadicCallType CallType,
+  llvm::SmallBitVector &CheckedVarArgs) {
   // CHECK: is the format string a wide literal?
   if (!FExpr->isAscii() && !FExpr->isUTF8()) {
 CheckFormatHandler::EmitFormatDiagnostic(
-  *this, inFunctionCall, Args[format_idx],
-  PDiag(diag::warn_format_string_is_wide_literal), FExpr->getLocStart(),
+  S, inFunctionCall, Args[format_idx],
+  S.PDiag(diag::warn_format_string_is_wide_literal), FExpr->getLocStart(),
   /*IsStringLocation*/true, OrigFormatExpr->getSourceRange());
 return;
   }
-  
+
   // Str - The format string.  NOTE: this is NOT null-terminated!
   StringRef StrRef = FExpr->getString();
   const char *Str = StrRef.data();
   // Account for cases where the string literal is truncated in a declaration.
-  const ConstantArrayType *T = 
Context.getAsConstantArrayType(FExpr->getType());
+

Re: r261506 - Fix PR24473 : Teach clang to remember to substitute into member variable templates referred to within dependent qualified ids.

2016-02-22 Thread Faisal Vali via cfe-commits
On Mon, Feb 22, 2016 at 6:46 AM, Faisal Vali  wrote:
> On Sun, Feb 21, 2016 at 11:45 PM, Richard Smith  wrote:
>> On 21 Feb 2016 8:21 p.m., "Faisal Vali"  wrote:
>>>
>>> On Sun, Feb 21, 2016 at 10:06 PM, Richard Smith 
>>> wrote:
>>> > On 21 Feb 2016 6:29 p.m., "Faisal Vali via cfe-commits"
>>> >  wrote:
>>> >>
>>> >> Author: faisalv
>>> >> Date: Sun Feb 21 20:24:29 2016
>>> >> New Revision: 261506
>>> >>
>>> >> URL: http://llvm.org/viewvc/llvm-project?rev=261506&view=rev
>>> >> Log:
>>> >> Fix PR24473 : Teach clang to remember to substitute into member
>>> >> variable
>>> >> templates referred to within dependent qualified ids.
>>> >>
>>> >> In passing also fix a semi-related bug that allows access to variable
>>> >> templates through member access notation.
>>> >>
>>> >>
>>> >> Modified:
>>> >> cfe/trunk/lib/Sema/SemaExprMember.cpp
>>> >> cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
>>> >>
>>> >> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
>>> >> URL:
>>> >>
>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=261506&r1=261505&r2=261506&view=diff
>>> >>
>>> >>
>>> >> ==
>>> >> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
>>> >> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Sun Feb 21 20:24:29 2016
>>> >> @@ -902,6 +902,32 @@ static bool IsInFnTryBlockHandler(const
>>> >>return false;
>>> >>  }
>>> >>
>>> >> +static VarDecl *
>>> >> +getVarTemplateSpecialization(Sema &S, VarTemplateDecl *VarTempl,
>>> >> +  const TemplateArgumentListInfo *TemplateArgs,
>>> >> +  const DeclarationNameInfo &MemberNameInfo,
>>> >> +  SourceLocation TemplateKWLoc) {
>>> >> +
>>> >> +  if (!TemplateArgs) {
>>> >> +S.Diag(MemberNameInfo.getBeginLoc(), diag::err_template_decl_ref)
>>> >> +<< /*Variable template*/ 1 << MemberNameInfo.getName()
>>> >> +<< MemberNameInfo.getSourceRange();
>>> >> +
>>> >> +S.Diag(VarTempl->getLocation(), diag::note_template_decl_here);
>>> >> +
>>> >> +return nullptr;
>>> >> +  }
>>> >> +  DeclResult VDecl = S.CheckVarTemplateId(
>>> >> +  VarTempl, TemplateKWLoc, MemberNameInfo.getLoc(),
>>> >> *TemplateArgs);
>>> >> +  if (VDecl.isInvalid())
>>> >> +return nullptr;
>>> >> +  VarDecl *Var = cast(VDecl.get());
>>> >> +  if (!Var->getTemplateSpecializationKind())
>>> >> +Var->setTemplateSpecializationKind(TSK_ImplicitInstantiation,
>>> >> +   MemberNameInfo.getLoc());
>>> >> +  return Var;
>>> >> +}
>>> >> +
>>> >>  ExprResult
>>> >>  Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
>>> >> SourceLocation OpLoc, bool IsArrow,
>>> >> @@ -1069,9 +1095,20 @@ Sema::BuildMemberReferenceExpr(Expr *Bas
>>> >>// Handle the implicit-member-access case.
>>> >>if (!BaseExpr) {
>>> >>  // If this is not an instance member, convert to a non-member
>>> >> access.
>>> >> -if (!MemberDecl->isCXXInstanceMember())
>>> >> +if (!MemberDecl->isCXXInstanceMember()) {
>>> >> +  // If this is a variable template, get the instantiated variable
>>> >> +  // declaration corresponding to the supplied template arguments
>>> >> +  // (while emitting diagnostics as necessary) that will be
>>> >> referenced
>>> >> +  // by this expression.
>>> >> +  if (isa(MemberDecl)) {
>>> >> +MemberDecl = getVarTemplateSpecialization(
>>> >> +*this, cast(MemberDecl), TemplateArgs,
>>> >> +R.getLookupNameInfo(), TemplateKWLoc);
>>> >> +if (!MemberDecl)
>>> >> +  return ExprError();
>>> >> +  }
>>> >>return BuildDeclarationNameExpr(SS, R.getLookupNameInfo(),
>>> >> MemberDecl);
>>> >
>>> > Does this properly preserve the template argument list as written?
>>> >
>>>
>>> Shouldn't it? Since it passes on the passed in template argument list
>>> (that I'm assuming is preserved) to CheckVarTemplateId?
>>
>> None of the three arguments passed to BuildDeclarationNameExpr references
>> the template argument list as written. Passing it to CheckVarTemplateId is
>> insufficient -- that can't preserve the template arguments from each use,
>> because it produces the same result for all uses.
>>
>
> I see what you mean.  I'll pass the TemplateArgs through to
> BuildDeclRefExpr so it is preserved within that node.  Does it make
> sense to squirrel the FoundDecl (the template)  within  the
> DeclRefExpr node too?
>

FYI, I think we should, since the FoundDecl could be a using member
declaration for a base class' variable template. (Not sure why this
wasn't being preserved for the non-variable template case either?)

>
>
>>> Perhaps you have an example in mind?
>>>
>>> Thanks!
>>>
>>> >> -
>>> >> +}
>>> >>  SourceLocation Loc = R.getNameLoc();
>>> >>  if (SS.getRange().isValid())
>>> >>Loc = SS.getRange().getBegin();
>>

r261523 - Use an anonymous hyperlink reference to eliminate Sphinx warnings.

2016-02-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb 22 07:09:36 2016
New Revision: 261523

URL: http://llvm.org/viewvc/llvm-project?rev=261523&view=rev
Log:
Use an anonymous hyperlink reference to eliminate Sphinx warnings.

Modified:
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=261523&r1=261522&r2=261523&view=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Mon Feb 22 07:09:36 2016
@@ -244,7 +244,7 @@ Coverage counters
 =
 
 This experimental feature is inspired by
-`AFL `_'s coverage
+`AFL `__'s coverage
 instrumentation. With additional compile-time and run-time flags you can get
 more sensitive coverage information.  In addition to boolean values assigned to
 every basic block (edge) the instrumentation will collect imprecise counters.
@@ -301,7 +301,7 @@ With an additional ``...=trace-pc,indire
 These callbacks are not implemented in the Sanitizer run-time and should be 
defined
 by the user. So, these flags do not require the other sanitizer to be used.
 This mechanism is used for fuzzing the Linux kernel 
(https://github.com/google/syzkaller)
-and can be used with `AFL `_.
+and can be used with `AFL `__.
 
 Tracing data flow
 =


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


Re: [PATCH] D16139: [MIPS] initFeatureMap() to handle empty string argument

2016-02-22 Thread Bhushan Attarde via cfe-commits
bhushan added a comment.

> I'm guessing it's something to do with the 'Features[CPU] = true' line.


Yes.
`Features[CPU] = true` enables a feature given by CPU string. (This gets 
translated into "+CPU").
When CPU string is empty, this gets translated into "+" (i.e. with empty 
feature name).

This results into a warning `'+' is not a recognized feature for this target 
(ignoring feature)`.


Repository:
  rL LLVM

http://reviews.llvm.org/D16139



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


Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2016-02-22 Thread Andy Gibbs via cfe-commits
AndyG marked 7 inline comments as done.
AndyG added a comment.

I've removed CheckFormatString from Sema.h and make it a static function inside 
SemaChecking.cpp in r261522.  I'll submit a new diff here with the remaining 
requested changes for this patch when I have a moment.


http://reviews.llvm.org/D15636



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


Re: r261461 - Lex: Never overflow the file in HeaderMap::lookupFilename()

2016-02-22 Thread Rafael Espíndola via cfe-commits
On 20 February 2016 at 19:14, Duncan P. N. Exon Smith via cfe-commits
 wrote:
> Author: dexonsmith
> Date: Sat Feb 20 18:14:36 2016
> New Revision: 261461
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261461&view=rev
> Log:
> Lex: Never overflow the file in HeaderMap::lookupFilename()
>
> If a header map file is corrupt, the strings in the string table may not
> be null-terminated.  The logic here previously relied on `MemoryBuffer`
> always being null-terminated, but this isn't actually guaranteed by the
> class AFAICT.

Depends on the constructor used. Note the RequiresNullTerminator
parameter. It exists because it apparently makes clang parsing faster
by allowing it to not check for the size all the time.

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


Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS

2016-02-22 Thread Craig, Ben via cfe-commits

On 2/19/2016 3:32 PM, Joerg Sonnenberger via cfe-commits wrote:

On Fri, Feb 19, 2016 at 06:14:18PM +, Ben Craig via cfe-commits wrote:

Instead of checking _LIBCPP_LOCALE__L_EXTENSIONS all over, instead
check it once, and define the various *_l symbols once.

If you want to rename using macros, please use the argument form. I find
that to provide better self-documentation.

Joerg

Would the following form address your concerns?
#define __libcxx_sscanf_l(...) sscanf_l(__VA_ARGS__)

I think that getting more elaborate than that general form would be more 
effort and more buggy without significant customer benefit.



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


--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux 
Foundation Collaborative Project

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


Re: [PATCH] D17488: Extend UnnecessaryCopyInitialization check to trigger on non-const copies that can be safely converted to const references.

2016-02-22 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.cpp:69
@@ +68,3 @@
+   : "the variable '%0' is copy-constructed from a const reference 
"
+ "but "
+ "is only used as const reference; consider making it a const "

nit: Clang-format doesn't reflow string literals 
 One way to fix this is to merge all the lines of this string literal and 
clang-format again.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.h:19
@@ -18,3 +18,3 @@
 
-// A check that detects const local variable declarations that are copy
+// A check that detects local variable declarations that are copy
 // initialized with the const reference of a function call or the const

Maybe just "The check detects local variable declarations "?

Also, should the .rst file be updated as well?


Comment at: clang-tidy/utils/DeclRefExprUtils.h:21
@@ +20,3 @@
+/// \brief Returns true if all DeclRefExpr to the variable within Stmt do not
+/// modify it.
+/// Returns true if only const methods or operators are called on the variable

nit: There should be an empty line after the brief summary, IIRC. (But you can 
look at the doxygen output and see how this looks like.)


Comment at: clang-tidy/utils/FixItHintUtils.cpp:23
@@ +22,3 @@
+  if (!Token.is(tok::unknown))
+AmpLocation = Token.getLocation().getLocWithOffset(Token.getLength());
+  return FixItHint::CreateInsertion(AmpLocation, "&");

`Lexer::getLocForEndOfToken` seems to be more suitable for this purpose.


Comment at: clang-tidy/utils/FixItHintUtils.h:21
@@ +20,3 @@
+/// \brief Creates fix to make VarDecl a reference by adding '&'.
+FixItHint createReferenceFix(const VarDecl &Var, ASTContext &Context);
+

Since this is now a library, we should make names clear and unambiguous. I'd 
pull a part of the name's meaning to the namespace and expand the name with the 
needed details. Maybe something like this:

  namespace clang {
  namespace tidy {
  namespace utils {
  namespace create_fixit {
  
  FixItHint changeVarDeclToReference(...);
  FixItHint changeVarDeclToConst(...);


Repository:
  rL LLVM

http://reviews.llvm.org/D17488



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


Re: [PATCH] D17446: ASTMatchers: add new statement/decl matchers

2016-02-22 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1000
@@ +999,3 @@
+
+
+/// \brief Matches implicit initializers of init list expressions.

Can remove the extra newline.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1005
@@ +1004,3 @@
+/// \code
+///   point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; }
+/// \endcode

I don't think this code is valid because of the }; and the missing semicolon at 
the end.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1019
@@ +1018,3 @@
+/// parenListExpr()
+///   matches "*this"
+const internal::VariadicDynCastAllOfMatcher parenListExpr;

It may be good to have an example of how this differs from ParenExpr with a 
list. e.g., I don't think this will match: `int a = 0, b = 1; int i = (a, b);`, 
will it? Either way, it would be good to have as an example (and possibly test 
case).


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1646
@@ +1645,3 @@
+///
+/// Example matches a ?: b
+/// \code

Comment doesn't match code, should either match a ?: b or change the code to 
use b instead of c.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1648
@@ +1647,3 @@
+/// \code
+///   (a ?: c) + 42
+/// \endcode

Missing semicolon?


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1654
@@ +1653,3 @@
+
+/// \brief Matches opaque value expressions.
+///

This is still a bit too brief, because opaque value expressions aren't very 
commonly used, it's hard to understand what it will actually match. If you can 
expand the description a bit as to what an opaque value expression actually is, 
that would be great.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1658
@@ +1657,3 @@
+/// \code
+///   (a ?: c) + 42
+/// \endcode

Missing semicolon?


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1820
@@ -1729,1 +1819,3 @@
 
+/// \brief Matches predefined identifier expressions [C99 6.4.2.2]
+///

Missing a period at the end of the sentence.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1822
@@ +1821,3 @@
+///
+/// Example: Matches __func__)
+/// \code

Spurious ), I hope. ;-)


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1830
@@ +1829,3 @@
+
+/// \brief Matches C99 designated initializer expressions [C99 6.7.8]
+///

Missing period.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1846
@@ +1845,3 @@
+///   point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; };
+///   point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; }
+/// \endcode

Neither of these look to be valid code. Both seem to have extra };, and the 
last one is missing a semicolon.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:3506
@@ +3505,3 @@
+  internal::Matcher, InnerMatcher) {
+  const Expr* const SubExpression =
+  internal::GetSourceExpressionMatcher::get(Node);

Is this formatting that clang-format produced? The * looks to be in the wrong 
place.


http://reviews.llvm.org/D17446



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


Re: [PATCH][modules][PR26237]

2016-02-22 Thread Vassil Vassilev via cfe-commits

ping...
On 30/01/16 21:13, Vassil Vassilev wrote:

On 30/01/16 18:36, David Blaikie wrote:



On Sat, Jan 30, 2016 at 9:00 AM, Vassil Vassilev 
 wrote:


AFAICT the making a test case independent on STL is the hard
part. I think it will be always failing due to the relocation of
the memory region of the underlying SmallVector.


Sorry, I think I didn't explain myself well. What I mean is - due to 
the instability of test cases for UB (especially library UB), we 
don't usually commit test cases for them - we just fix them without 
tests. About the only time I think committing a test is helpful for 
UB (especially library UB) is if we have a reliable way to test/catch 
the UB (eg: the sanitizers or a checking STL that fails fast on 
validation violations). So, while it would be good to 
provide/demonstrate your test case, I would not commit the test case 
unless it's a minimal reproduction in the presence of one of those 
tools (sanitizers or checking STL) - and would just commit the fix 
without a test case, usually.


(I'm not actually reviewing this patch - I don't know much about the 
modules code, but just providing a bit of context and first-pass-review)

Got it. Thanks!
--Vassil



On 30/01/16 17:37, David Blaikie wrote:


Yeah, it's good to have a reproduction, but I wouldn't actually
commit one - unless you have a checked stl to test against that
always fails on possibly-invalidating sequences of operations,
then you'd have a fairly simple reproduction

On Jan 30, 2016 8:23 AM, "Vassil Vassilev"
mailto:v.g.vassi...@gmail.com>> wrote:

Sorry.

Our module builds choke on merging several modules,
containing declarations from STL (we are using libc++, no
modulemaps).

When writing a new module containing the definition of a STL
reverse_iterator, it collects all its template
specializations. Some of the specializations need to be
deserialized from a third module. This triggers an iterator
invalidation bug because of the deserialization happening
when iterating the specializations container itself. This
happens only when the container's capacity is exceeded and
the relocation invalidates the iterators and at best causes
a crash (see valgrind reports in the bug report).
Unfortunately I haven't been able to make the reproducer
independent on STL.

--Vassil

On 30/01/16 17:08, David Blaikie wrote:


It might be handy to give an overview of the issue in the
review (& certainly in the commit) message rather than only
citing the bug number

On Jan 30, 2016 6:49 AM, "Vassil Vassilev via cfe-commits"
 wrote:

Attaching a fix to
https://llvm.org/bugs/show_bug.cgi?id=26237

Please review.

Many thanks!
--Vassil

___
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


r261528 - clang-format: [JS] treat forwardDeclare as an import/export statement.

2016-02-22 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb 22 09:06:53 2016
New Revision: 261528

URL: http://llvm.org/viewvc/llvm-project?rev=261528&view=rev
Log:
clang-format: [JS] treat forwardDeclare as an import/export statement.

Patch by Martin Probst. Thank you.

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=261528&r1=261527&r2=261528&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Feb 22 09:06:53 2016
@@ -786,7 +786,8 @@ private:
Tok.Next->Next && (Tok.Next->Next->TokenText == "module" ||
   Tok.Next->Next->TokenText == "provide" ||
   Tok.Next->Next->TokenText == "require" ||
-  Tok.Next->Next->TokenText == "setTestOnly") &&
+  Tok.Next->Next->TokenText == "setTestOnly" ||
+  Tok.Next->Next->TokenText == "forwardDeclare") &&
Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
   }
 

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=261528&r1=261527&r2=261528&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Feb 22 09:06:53 2016
@@ -277,6 +277,8 @@ TEST_F(FormatTestJS, GoogModules) {
getGoogleJSStyleWithColumns(40));
   verifyFormat("goog.setTestOnly('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
+  verifyFormat("goog.forwardDeclare('this.is.really.absurdly.long');",
+   getGoogleJSStyleWithColumns(40));
 
   // These should be wrapped normally.
   verifyFormat(


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


Re: [PATCH] D17439: clang-format: [JS] treat forwardDeclare as an import/export statement.

2016-02-22 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

LG. Submitted as r261528.


http://reviews.llvm.org/D17439



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


Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-02-22 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:41
@@ +40,3 @@
+   Function->parameters().begin();
+  if (Index >= Function->getNumParams()) {
+return;

Please add a comment about when this happens (template parameter packs? C-style 
variadic functions?).


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:46
@@ +45,3 @@
+  Param->getType().getCanonicalType().isConstQualified();
+  // Do not trigger on non-const value parameters when:
+  // 1. they are in a constructor definition since they can likely trigger

Please add an empty line before the comment.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:48
@@ +47,3 @@
+  // 1. they are in a constructor definition since they can likely trigger
+  // misc-move-constructor-init which will suggest to move the argument.
+  // 2. they are not only used as const.

nit: Add three spaces before the first word for better alignment.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:58
@@ +57,3 @@
+  "copied for each invocation; consider "
+  "making this a reference"
+: "the parameter '%0' is copied for each "

s/making this a reference/making it a reference/?


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:62
@@ +61,3 @@
+  "consider making it a const reference")
+  << Param->getName();
+  // Do not propose fixes in macros since we cannot place them correctly.

What if parameter doesn't have a name? Should we print an index ("parameter #n 
is copied ...").


Comment at: docs/clang-tidy/checks/performance-unnecessary-value-param.rst:6
@@ +5,3 @@
+
+Flags value parameter declarations of expensive to copy types that are copied
+for each invocation but it would suffice to pass them by const reference.

Add an example?


Comment at: docs/clang-tidy/checks/performance-unnecessary-value-param.rst:16
@@ +15,3 @@
+
+1. the parameter is const qualified.
+2. the parameter is not const, but only const methods or operators are invoked

nit: a `;` seems to be more suitable as a trailing punctuation here.


Repository:
  rL LLVM

http://reviews.llvm.org/D17491



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


Re: [PATCH] D17440: clang-format: [JS] do not wrap ES6 imports/exports.

2016-02-22 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I am missing a decent explanation here. In contrast to C++ #includes as well as 
goog.require, etc. The import/export statements actually provide syntactic 
structure and can name multiple entities. Why would it be a good idea to always 
write them into a single line?



Comment at: unittests/Format/FormatTestJS.cpp:867
@@ -869,11 +866,3 @@
"} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/module.js';");
-  verifyFormat("import {\n"
-   "  X,\n"
-   "  Y,\n"
-   "} from 'some/long/module.js';",
-   getGoogleJSStyleWithColumns(20));
+  verifyFormat("import {X, Y,} from 'some/module.js';");
   verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");

Really?


http://reviews.llvm.org/D17440



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


Re: [PATCH] D17447: Add check for CERT ENV33-C

2016-02-22 Thread Aaron Ballman via cfe-commits
aaron.ballman updated this revision to Diff 48674.
aaron.ballman added a comment.

Updated based on review feedback.


http://reviews.llvm.org/D17447

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/CommandProcessorCheck.cpp
  clang-tidy/cert/CommandProcessorCheck.h
  docs/clang-tidy/checks/cert-env33-c.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-env33-c.c

Index: test/clang-tidy/cert-env33-c.c
===
--- test/clang-tidy/cert-env33-c.c
+++ test/clang-tidy/cert-env33-c.c
@@ -0,0 +1,20 @@
+// RUN: %check_clang_tidy %s cert-env33-c %t
+
+typedef struct FILE {} FILE;
+
+extern int system(const char *);
+extern FILE *popen(const char *, const char *);
+extern FILE *_popen(const char *, const char *);
+
+void f(void) {
+  // It is permissible to check for the presence of a command processor.
+  system(0);
+
+  system("test");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'system' uses a command processor [cert-env33-c]
+
+  popen("test", "test");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'popen' uses a command processor
+  _popen("test", "test");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling '_popen' uses a command processor
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -8,6 +8,7 @@
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl59-cpp (redirects to google-build-namespaces) 
+   cert-env33-c
cert-err52-cpp
cert-err58-cpp
cert-err60-cpp
Index: docs/clang-tidy/checks/cert-env33-c.rst
===
--- docs/clang-tidy/checks/cert-env33-c.rst
+++ docs/clang-tidy/checks/cert-env33-c.rst
@@ -0,0 +1,13 @@
+.. title:: clang-tidy - cert-env33-c
+
+cert-env33-c
+
+
+This check flags calls to ``system()``, ``popen()``, and ``_popen()``, which
+execute a command processor. It does not flag calls to ``system()`` with a null
+pointer argument, as such a call checks for the presence of a command processor
+but does not actually attempt to execute a command.
+
+This check corresponds to the CERT C Coding Standard rule
+`ENV33-C. Do not call system()
+`_.
Index: clang-tidy/cert/CommandProcessorCheck.h
===
--- clang-tidy/cert/CommandProcessorCheck.h
+++ clang-tidy/cert/CommandProcessorCheck.h
@@ -0,0 +1,38 @@
+//===--- CommandInterpreterCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_COMMAND_PROCESSOR_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_COMMAND_PROCESSOR_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+/// Execution of a command processor can lead to security vulnerabilities,
+/// and is generally not required. Instead, prefer to launch executables
+/// directly via mechanisms that give you more control over what executable is
+/// actually launched.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-env33-c.html
+class CommandProcessorCheck : public ClangTidyCheck {
+public:
+  CommandProcessorCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_COMMAND_PROCESSOR_CHECK_H
Index: clang-tidy/cert/CommandProcessorCheck.cpp
===
--- clang-tidy/cert/CommandProcessorCheck.cpp
+++ clang-tidy/cert/CommandProcessorCheck.cpp
@@ -0,0 +1,45 @@
+//===--- Env33CCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CommandProcessorCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void CommandProcessorCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatch

Re: [PATCH] D17447: Add check for CERT ENV33-C

2016-02-22 Thread Aaron Ballman via cfe-commits
aaron.ballman marked 4 inline comments as done.
aaron.ballman added a comment.

http://reviews.llvm.org/D17447



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


Re: [PATCH] D17146: [libcxx] locale portability refactor

2016-02-22 Thread Ben Craig via cfe-commits
bcraig abandoned this revision.
bcraig added a comment.

Breaking this up into smaller chunks.


http://reviews.llvm.org/D17146



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


Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2016-02-22 Thread Andy Gibbs via cfe-commits
AndyG marked 11 inline comments as done.
AndyG added a comment.

Revised patch coming shortly...



Comment at: lib/Sema/SemaChecking.cpp:3603
@@ -3554,3 +3602,3 @@
 
-  void DoneProcessing();
+  void DoneProcessing(signed &FirstUncoveredArg);
 

rtrieu wrote:
> Don't change the call signature here, leave it as a zero argument call.  Have 
> another function return the first uncovered argument.
DoneProcessing is that function!  To move the logic into another function would 
leave nothing behind :o)

Passing UncoveredArgHandler& into CheckFormatHandler allows this to be worked 
around.


Comment at: lib/Sema/SemaChecking.cpp:3840-3892
@@ -3796,5 +3839,55 @@
+
+void UncoveredArgHandler::Update(signed NewFirstUncoveredArg,
+ const Expr *StrExpr) {
+  // Don't update if a previous string covers all arguments.
+  if (FirstUncoveredArg == AllCovered)
+return;
+
+  switch (NewFirstUncoveredArg) {
+case Unknown:
+  // The string was not fully analysed.  Do nothing.
+  break;
+
+case UncoveredArgHandler::AllCovered:
+  // A string has been found with all arguments covered, so clear out
+  // the diagnostics.
+  FirstUncoveredArg = AllCovered;
+  DiagnosticExprs.clear();
+  break;
+
+default:
+  // UncoveredArgHandler tracks the highest uncovered argument index
+  // and with it all the strings that match this index.
+  if (NewFirstUncoveredArg == FirstUncoveredArg)
+DiagnosticExprs.push_back(StrExpr);
+  else if (NewFirstUncoveredArg > FirstUncoveredArg) {
+DiagnosticExprs.clear();
+DiagnosticExprs.push_back(StrExpr);
+FirstUncoveredArg = NewFirstUncoveredArg;
   }
-}
+  break;
   }
 }
 
+void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall,
+   const Expr *ArgExpr) {
+  assert(FirstUncoveredArg >= 0 && DiagnosticExprs.size() > 0 &&
+ "Invalid state");
+
+  if (!ArgExpr)
+return;
+
+  SourceLocation Loc = ArgExpr->getLocStart();
+
+  if (S.getSourceManager().isInSystemMacro(Loc))
+return;
+
+  PartialDiagnostic PDiag = S.PDiag(diag::warn_printf_data_arg_not_used);
+  for (unsigned i = 1; i < DiagnosticExprs.size(); ++i)
+PDiag << DiagnosticExprs[i]->getSourceRange();
+
+  CheckFormatHandler::EmitFormatDiagnostic(
+  S, IsFunctionCall, DiagnosticExprs[0],
+  PDiag, Loc, /*IsStringLocation*/false,
+  DiagnosticExprs[0]->getSourceRange());
+}

rtrieu wrote:
> Move these two functions up to where the class is defined.
UncoveredArgHandler::Update has been moved up, but 
UncoveredArgHandler::Diagnose has been left since it has a dependency on 
CheckFormatHandler.


Comment at: lib/Sema/SemaChecking.cpp:3886-3887
@@ +3885,4 @@
+  PartialDiagnostic PDiag = S.PDiag(diag::warn_printf_data_arg_not_used);
+  for (unsigned i = 1; i < DiagnosticExprs.size(); ++i)
+PDiag << DiagnosticExprs[i]->getSourceRange();
+

rtrieu wrote:
> Use a range-based for-loop here.
Except that it is iterating from the second item in the list.  I don't think 
there is an easier way to do it.


http://reviews.llvm.org/D15636



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


Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2016-02-22 Thread Andy Gibbs via cfe-commits
AndyG updated this revision to Diff 48678.
AndyG marked 2 inline comments as done.
AndyG added a comment.

Patch additionally re-based off r261522.


http://reviews.llvm.org/D15636

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/format-strings-scanf.c
  test/Sema/format-strings.c

Index: test/Sema/format-strings.c
===
--- test/Sema/format-strings.c
+++ test/Sema/format-strings.c
@@ -46,6 +46,9 @@
 
   vscanf(s, ap); // expected-warning {{format string is not a string literal}}
 
+  const char *const fmt = "%d"; // FIXME -- defined here
+  printf(fmt, 1, 2); // expected-warning{{data argument not used}}
+
   // rdar://6079877
   printf("abc"
  "%*d", 1, 1); // no-warning
@@ -86,6 +89,19 @@
   printf(i == 0 ? (i == 1 ? "yes" : "no") : "dont know"); // no-warning
   printf(i == 0 ? (i == 1 ? s : "no") : "dont know"); // expected-warning{{format string is not a string literal}}
   printf("yes" ?: "no %d", 1); // expected-warning{{data argument not used by format string}}
+  printf(0 ? "yes %s" : "no %d", 1); // no-warning
+  printf(0 ? "yes %d" : "no %s", 1); // expected-warning{{format specifies type 'char *'}}
+
+  printf(0 ? "yes" : "no %d", 1); // no-warning
+  printf(0 ? "yes %d" : "no", 1); // expected-warning{{data argument not used by format string}}
+  printf(1 ? "yes" : "no %d", 1); // expected-warning{{data argument not used by format string}}
+  printf(1 ? "yes %d" : "no", 1); // no-warning
+  printf(i ? "yes" : "no %d", 1); // no-warning
+  printf(i ? "yes %s" : "no %d", 1); // expected-warning{{format specifies type 'char *'}}
+  printf(i ? "yes" : "no %d", 1, 2); // expected-warning{{data argument not used by format string}}
+
+  printf(i ? "%*s" : "-", i, s); // no-warning
+  printf(i ? "yes" : 0 ? "no %*d" : "dont know %d", 1, 2); // expected-warning{{data argument not used by format string}}
 }
 
 void check_writeback_specifier()
@@ -519,7 +535,7 @@
 
   // Make sure that the "format string is defined here" note is not emitted
   // when the original string is within the argument expression.
-  printf(1 ? "yes %d" : "no %d"); // expected-warning 2{{more '%' conversions than data arguments}}
+  printf(1 ? "yes %d" : "no %d"); // expected-warning{{more '%' conversions than data arguments}}
 
   const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
   printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
Index: test/Sema/format-strings-scanf.c
===
--- test/Sema/format-strings-scanf.c
+++ test/Sema/format-strings-scanf.c
@@ -18,7 +18,7 @@
 int vsscanf(const char * restrict, const char * restrict, va_list);
 
 void test(const char *s, int *i) {
-  scanf(s, i); // expected-warning{{ormat string is not a string literal}}
+  scanf(s, i); // expected-warning{{format string is not a string literal}}
   scanf("%0d", i); // expected-warning{{zero field width in scanf format string is unused}}
   scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
   scanf("%d%[asdfasdfd", i, s); // expected-warning{{no closing ']' for '%[' in scanf format string}}
@@ -171,3 +171,15 @@
   scanf("%d", (ip_t)0); // No warning.
   scanf("%d", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}
 }
+
+void check_conditional_literal(char *s, int *i) {
+  scanf(0 ? "%s" : "%d", i); // no warning
+  scanf(1 ? "%s" : "%d", i); // expected-warning{{format specifies type 'char *'}}
+  scanf(0 ? "%d %d" : "%d", i); // no warning
+  scanf(1 ? "%d %d" : "%d", i); // expected-warning{{more '%' conversions than data arguments}}
+  scanf(0 ? "%d %d" : "%d", i, s); // expected-warning{{data argument not used}}
+  scanf(1 ? "%d %s" : "%d", i, s); // no warning
+  scanf(i ? "%d %s" : "%d", i, s); // no warning
+  scanf(i ? "%d" : "%d", i, s); // expected-warning{{data argument not used}}
+  scanf(i ? "%s" : "%d", s); // expected-warning{{format specifies type 'int *'}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -3258,6 +3258,50 @@
 }
 
 namespace {
+class UncoveredArgHandler {
+  enum { Unknown = -1, AllCovered = -2 };
+  signed FirstUncoveredArg;
+  SmallVector DiagnosticExprs;
+
+public:
+  UncoveredArgHandler() : FirstUncoveredArg(Unknown) { }
+
+  bool hasUncoveredArg() const {
+return (FirstUncoveredArg >= 0);
+  }
+
+  unsigned getUncoveredArg() const {
+assert(hasUncoveredArg() && "no uncovered argument");
+return FirstUncoveredArg;
+  }
+
+  void Update(signed NewFirstUncoveredArg, const Expr *StrExpr) {
+// Don't update if a previous string covers all arguments.
+if (FirstUncoveredArg == AllCovered)
+  return;
+
+if (NewFirstUncoveredArg < 0) {
+  // A string 

Re: [PATCH] D17416: [libcxx] Reorganize locale extension fallbacks. NFCI

2016-02-22 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

This looks fine to me; but I want to hear from @danalbert.


http://reviews.llvm.org/D17416



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


Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS

2016-02-22 Thread Joerg Sonnenberger via cfe-commits
On Mon, Feb 22, 2016 at 08:25:56AM -0600, Craig, Ben via cfe-commits wrote:
> On 2/19/2016 3:32 PM, Joerg Sonnenberger via cfe-commits wrote:
> >On Fri, Feb 19, 2016 at 06:14:18PM +, Ben Craig via cfe-commits wrote:
> >>Instead of checking _LIBCPP_LOCALE__L_EXTENSIONS all over, instead
> >>check it once, and define the various *_l symbols once.
> >If you want to rename using macros, please use the argument form. I find
> >that to provide better self-documentation.
> >
> >Joerg
> Would the following form address your concerns?
> #define __libcxx_sscanf_l(...) sscanf_l(__VA_ARGS__)
> 
> I think that getting more elaborate than that general form would be more
> effort and more buggy without significant customer benefit.

For variadic functions, the above is fine. I don't think it is more
complicated for the fixed argument-number versions.

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


Re: [PATCH] D17437: [OpenCL] Add Sema checks for types

2016-02-22 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

do we need to add a test that pointer to sampler is invalid?


http://reviews.llvm.org/D17437



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


Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS

2016-02-22 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Actually, the prefix we use in the rest of libc++ for private functions is 
`__libcpp_`  Take a look in type_traits for a bunch of examples.

In general, I'm liking the way this is going. I suspect I will have more 
comments later today.


http://reviews.llvm.org/D17456



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


Re: [PATCH] D17507: The controlling expression for _Generic is unevaluated

2016-02-22 Thread Aaron Ballman via cfe-commits
On Mon, Feb 22, 2016 at 10:52 AM, Aaron Ballman  wrote:
> aaron.ballman created this revision.
> aaron.ballman added a reviewer: rsmith.
> aaron.ballman added a subscriber: cfe-commits.
>
> In r252104, I fixed a _Generic bug so that the controlling expression has its 
> type decayed and qualifiers stripped. However, this caused a diagnostic 
> regression because the controlling expression is not evaluated, and my fix 
> triggered diagnostics (like null pointer dereferences) that it should not 
> have. This patch fixes the regression by putting the evaluation of the 
> controlling expression into an unevaluated context before decaying and 
> stripping qualifiers.

I should point out that this addresses PR26398
(https://llvm.org/bugs/show_bug.cgi?id=26398).

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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 48682.
hokein marked an inline comment as done.
hokein added a comment.

- Don't save BuildDirectory for every error in each check.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/compilation-database/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,6 @@
+// REQUIRES: shell
+// RUN: sed 's|test_dir|%S|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %s -header-filter=.* | FileCheck %s -implicit-check-not="{{warning:}}"
+
+#include "./Inputs/compilation-database/header.h"
+// CHECK: warning: use nullptr [modernize-use-nullptr]
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "test_dir",
+  "command": "clang++ -o test.o clang-tidy-run-with-database.cpp",
+  "file": "test_dir/clang-tidy-run-with-database.cpp"
+}
+]
Index: test/clang-tidy/Inputs/compilation-database/header.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/header.h
@@ -0,0 +1,3 @@
+#define NULL 0
+
+int *a = NULL;
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -357,7 +357,8 @@
   unsigned WErrorCount = 0;
 
   // -fix-errors implies -fix.
-  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
+  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount,
+   Stats.BuildDirectory);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -101,6 +101,14 @@
   unsigned ErrorsIgnoredNOLINT;
   unsigned ErrorsIgnoredNonUserCode;
   unsigned ErrorsIgnoredLineFilter;
+  // A build directory of the source file containing the error.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // It can be empty in some cases, e.g. the source file does not exist.
+  std::string BuildDirectory;
 
   unsigned errorsIgnored() const {
 return ErrorsIgnoredNOLINT + ErrorsIgnoredCheckFilter +
@@ -185,6 +193,8 @@
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
 
+  void setBuildDirectoryForStats(StringRef BuildDirectory);
+
   /// \brief Returns all collected errors.
   const std::vector &getErrors() const { return Errors; }
 
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -229,6 +229,10 @@
   OptionsProvider->getOptions(File));
 }
 
+void ClangTidyContext::setBuildDirectoryForStats(StringRef BuildDirectory) {
+  Stats.BuildDirectory = BuildDirectory;
+}
+
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }
 
 GlobList &ClangTidyContext::getChecksFilter() {
@@ -335,6 +339,15 @@
 bool IsWarningAsError =
 DiagLevel == DiagnosticsEngine::Warning &&
 Context.getWarningAsErrorFilter().contains(CheckName);
+
+std::string BuildDirectory;
+if (Info.hasSourceManager()) {
+  auto WorkingDir = Info.getSourceManager()
+.getFileManager().getVirtualFileSystem()
+->getCurrentWorkingDirectory();
+  if (WorkingDir)
+BuildDirectory = WorkingDir.get();
+}
 Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError));
   }
 
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -223,7 +223,8 @@
 /// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
 /// Errors containing fixes are automatically applied.
 void handleErrors(const std::vector &Errors, bool Fix,
-  unsigned &WarningsAsErrorsCount);
+  unsigned &WarningsAsErrorsCount,
+  StringRef Buil

Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 48683.
hokein added a comment.

Some cleanup.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/compilation-database/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,6 @@
+// REQUIRES: shell
+// RUN: sed 's|test_dir|%S|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %s -header-filter=.* | FileCheck %s -implicit-check-not="{{warning:}}"
+
+#include "./Inputs/compilation-database/header.h"
+// CHECK: warning: use nullptr [modernize-use-nullptr]
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "test_dir",
+  "command": "clang++ -o test.o clang-tidy-run-with-database.cpp",
+  "file": "test_dir/clang-tidy-run-with-database.cpp"
+}
+]
Index: test/clang-tidy/Inputs/compilation-database/header.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/header.h
@@ -0,0 +1,3 @@
+#define NULL 0
+
+int *a = NULL;
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -357,7 +357,8 @@
   unsigned WErrorCount = 0;
 
   // -fix-errors implies -fix.
-  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
+  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount,
+   Stats.BuildDirectory);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -101,6 +101,14 @@
   unsigned ErrorsIgnoredNOLINT;
   unsigned ErrorsIgnoredNonUserCode;
   unsigned ErrorsIgnoredLineFilter;
+  // A build directory of the source file containing the error.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // It can be empty in some cases, e.g. the source file does not exist.
+  std::string BuildDirectory;
 
   unsigned errorsIgnored() const {
 return ErrorsIgnoredNOLINT + ErrorsIgnoredCheckFilter +
@@ -185,6 +193,8 @@
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
 
+  void setBuildDirectoryForStats(StringRef BuildDirectory);
+
   /// \brief Returns all collected errors.
   const std::vector &getErrors() const { return Errors; }
 
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -229,6 +229,10 @@
   OptionsProvider->getOptions(File));
 }
 
+void ClangTidyContext::setBuildDirectoryForStats(StringRef BuildDirectory) {
+  Stats.BuildDirectory = BuildDirectory;
+}
+
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }
 
 GlobList &ClangTidyContext::getChecksFilter() {
@@ -335,6 +339,7 @@
 bool IsWarningAsError =
 DiagLevel == DiagnosticsEngine::Warning &&
 Context.getWarningAsErrorFilter().contains(CheckName);
+
 Errors.push_back(ClangTidyError(CheckName, Level, IsWarningAsError));
   }
 
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -223,7 +223,8 @@
 /// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
 /// Errors containing fixes are automatically applied.
 void handleErrors(const std::vector &Errors, bool Fix,
-  unsigned &WarningsAsErrorsCount);
+  unsigned &WarningsAsErrorsCount,
+  StringRef BuildDirectory);
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -95,14 +95,20 @@
 
 class ErrorReporter {
 public:
-  ErrorReporter(bool ApplyFixes)
+  ErrorReporter(bool ApplyFixes, StringRef BuildD

[PATCH] D17507: The controlling expression for _Generic is unevaluated

2016-02-22 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a subscriber: cfe-commits.

In r252104, I fixed a _Generic bug so that the controlling expression has its 
type decayed and qualifiers stripped. However, this caused a diagnostic 
regression because the controlling expression is not evaluated, and my fix 
triggered diagnostics (like null pointer dereferences) that it should not have. 
This patch fixes the regression by putting the evaluation of the controlling 
expression into an unevaluated context before decaying and stripping qualifiers.

Assuming this patch is acceptable, I think it should go into 3.8 as well.

http://reviews.llvm.org/D17507

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/generic-selection.c

Index: test/Sema/generic-selection.c
===
--- test/Sema/generic-selection.c
+++ test/Sema/generic-selection.c
@@ -31,4 +31,8 @@
 
   const int i = 12;
   int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1];
+
+  // This is expected to not trigger any diagnostics because the controlling
+  // expression is not evaluated.
+  (void)_Generic(*(int *)0, int: 1);
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1373,10 +1373,13 @@
 
   // Decay and strip qualifiers for the controlling expression type, and handle
   // placeholder type replacement. See committee discussion from WG14 DR423.
-  ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
-  if (R.isInvalid())
-return ExprError();
-  ControllingExpr = R.get();
+  {
+EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated);
+ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
+if (R.isInvalid())
+  return ExprError();
+ControllingExpr = R.get();
+  }
 
   // The controlling expression is an unevaluated operand, so side effects are
   // likely unintended.


Index: test/Sema/generic-selection.c
===
--- test/Sema/generic-selection.c
+++ test/Sema/generic-selection.c
@@ -31,4 +31,8 @@
 
   const int i = 12;
   int a9[_Generic(i, int: 1, default: 2) == 1 ? 1 : -1];
+
+  // This is expected to not trigger any diagnostics because the controlling
+  // expression is not evaluated.
+  (void)_Generic(*(int *)0, int: 1);
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1373,10 +1373,13 @@
 
   // Decay and strip qualifiers for the controlling expression type, and handle
   // placeholder type replacement. See committee discussion from WG14 DR423.
-  ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
-  if (R.isInvalid())
-return ExprError();
-  ControllingExpr = R.get();
+  {
+EnterExpressionEvaluationContext Unevaluated(*this, Sema::Unevaluated);
+ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
+if (R.isInvalid())
+  return ExprError();
+ControllingExpr = R.get();
+  }
 
   // The controlling expression is an unevaluated operand, so side effects are
   // likely unintended.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 48684.
hokein added a comment.

Remove an extra blank line.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/compilation-database/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,6 @@
+// REQUIRES: shell
+// RUN: sed 's|test_dir|%S|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %s -header-filter=.* | FileCheck %s -implicit-check-not="{{warning:}}"
+
+#include "./Inputs/compilation-database/header.h"
+// CHECK: warning: use nullptr [modernize-use-nullptr]
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "test_dir",
+  "command": "clang++ -o test.o clang-tidy-run-with-database.cpp",
+  "file": "test_dir/clang-tidy-run-with-database.cpp"
+}
+]
Index: test/clang-tidy/Inputs/compilation-database/header.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/header.h
@@ -0,0 +1,3 @@
+#define NULL 0
+
+int *a = NULL;
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -357,7 +357,8 @@
   unsigned WErrorCount = 0;
 
   // -fix-errors implies -fix.
-  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
+  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount,
+   Stats.BuildDirectory);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -101,6 +101,14 @@
   unsigned ErrorsIgnoredNOLINT;
   unsigned ErrorsIgnoredNonUserCode;
   unsigned ErrorsIgnoredLineFilter;
+  // A build directory of the source file containing the error.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // It can be empty in some cases, e.g. the source file does not exist.
+  std::string BuildDirectory;
 
   unsigned errorsIgnored() const {
 return ErrorsIgnoredNOLINT + ErrorsIgnoredCheckFilter +
@@ -185,6 +193,8 @@
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
 
+  void setBuildDirectoryForStats(StringRef BuildDirectory);
+
   /// \brief Returns all collected errors.
   const std::vector &getErrors() const { return Errors; }
 
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -229,6 +229,10 @@
   OptionsProvider->getOptions(File));
 }
 
+void ClangTidyContext::setBuildDirectoryForStats(StringRef BuildDirectory) {
+  Stats.BuildDirectory = BuildDirectory;
+}
+
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }
 
 GlobList &ClangTidyContext::getChecksFilter() {
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -223,7 +223,8 @@
 /// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
 /// Errors containing fixes are automatically applied.
 void handleErrors(const std::vector &Errors, bool Fix,
-  unsigned &WarningsAsErrorsCount);
+  unsigned &WarningsAsErrorsCount,
+  StringRef BuildDirectory);
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -95,14 +95,20 @@
 
 class ErrorReporter {
 public:
-  ErrorReporter(bool ApplyFixes)
+  ErrorReporter(bool ApplyFixes, StringRef BuildDirectory)
   : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new DiagnosticIDs), &*DiagOpts,

Re: [PATCH] D17163: [ASTMatchers] Add matcher hasAnyName.

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

Looks good. Thanks!

(I suppose, Manuel has no substantial comments on this, since he has already 
seen the patch).


http://reviews.llvm.org/D17163



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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for this check! Mostly looks good, but there are a number of style 
nits.

The most important question to this check is that the standard doesn't 
guarantee that the C++ headers declare all the same functions **in the global 
namespace** (at least, this is how I understand the section of the standard you 
quoted). This means that the check in its current form can break the code that 
uses library symbols from the global namespace. The check could add `std::` 
wherever it's needed (though it may be not completely trivial) to mitigate the 
risk. It's not what needs to be addressed in the first iteration, but it's 
definitely worth a look at in order to make the check actually useful. It also 
could be a separate check or a separate mode (configurable via parameters) of 
this check, while someone could have reasons to do the migration in two stages 
(add `std::` qualifiers and then switch to new headers).



Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:15
@@ +14,3 @@
+
+#include 
+#include 

Is this header used?


Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:36
@@ +35,3 @@
+private:
+  std::map CStyledHeaderToCxx;
+

There's a more effective container in LLVM: `llvm::StringMap`. If 
your code guarantees that only string literals be used to initialize this map, 
this can be a `llvm::StringMap`.


Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:54
@@ +53,3 @@
+: Check(Check), LangOpts(LangOpts) {
+  CStyledHeaderToCxx = {
+  {"assert.h", "cassert"},

It should be possible to initialize this in the constructor initializer list.


Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:77
@@ +76,3 @@
+
+  // Add C++ 11 headers
+  if (LangOpts.CPlusPlus11) {

nit: Please add a trailing period.


Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:94
@@ +93,3 @@
+StringRef SearchPath, StringRef RelativePath, const Module *Imported) {
+  if (CStyledHeaderToCxx.count(std::string(FileName)) != 0) {
+std::string Replacement =

1. s/`std::string(FileName)`/`FileName.str()`/
2. no need for this, if `llvm::StringMap` is used


Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:96
@@ +95,3 @@
+std::string Replacement =
+"<" + CStyledHeaderToCxx[std::string(FileName)] + ">";
+Check.diag(FilenameRange.getBegin(), "including deprecated C++ header")

`FileName.str()`


Comment at: docs/clang-tidy/checks/modernize-deprecated-headers.rst:8
@@ +7,3 @@
+
+  Annex D (normative)
+  Compatibility features [depr]

This quote from the standard is too long for my taste. A simple reference to 
the relevant section should be enough (`[depr.c.headers]`).


Comment at: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 
-isystem %S/Inputs/Headers
+

You seem to have forgotten to add these headers to `Inputs/Headers`. Or doesn't 
the check care about them actually being present?


Comment at: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp:25
@@ +24,3 @@
+
+// Headers deprecated since C++11; expect no diagnostics
+#include 

Trailing period.


Comment at: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp:32
@@ +31,3 @@
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 

Please also check diagnostic messages (`// CHECK-MESSAGES: ...`).


http://reviews.llvm.org/D17484



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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 48686.
hokein marked an inline comment as done.
hokein added a comment.

Address one comment.


http://reviews.llvm.org/D17335

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/compilation-database/header.h
  test/clang-tidy/Inputs/compilation-database/template.json
  test/clang-tidy/clang-tidy-run-with-database.cpp

Index: test/clang-tidy/clang-tidy-run-with-database.cpp
===
--- /dev/null
+++ test/clang-tidy/clang-tidy-run-with-database.cpp
@@ -0,0 +1,6 @@
+// REQUIRES: shell
+// RUN: sed 's|test_dir|%S|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %s -header-filter=.* | FileCheck %s -implicit-check-not="{{warning:}}"
+
+#include "./Inputs/compilation-database/header.h"
+// CHECK: warning: use nullptr [modernize-use-nullptr]
Index: test/clang-tidy/Inputs/compilation-database/template.json
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/template.json
@@ -0,0 +1,7 @@
+[
+{
+  "directory": "test_dir",
+  "command": "clang++ -o test.o clang-tidy-run-with-database.cpp",
+  "file": "test_dir/clang-tidy-run-with-database.cpp"
+}
+]
Index: test/clang-tidy/Inputs/compilation-database/header.h
===
--- /dev/null
+++ test/clang-tidy/Inputs/compilation-database/header.h
@@ -0,0 +1,3 @@
+#define NULL 0
+
+int *a = NULL;
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -357,7 +357,8 @@
   unsigned WErrorCount = 0;
 
   // -fix-errors implies -fix.
-  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount);
+  handleErrors(Errors, (FixErrors || Fix) && !DisableFixes, WErrorCount,
+   Stats.BuildDirectory);
 
   if (!ExportFixes.empty() && !Errors.empty()) {
 std::error_code EC;
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -101,6 +101,14 @@
   unsigned ErrorsIgnoredNOLINT;
   unsigned ErrorsIgnoredNonUserCode;
   unsigned ErrorsIgnoredLineFilter;
+  // A build directory of the source file containing the error.
+  //
+  // It's an absolute path which is `directory` field of the source file in
+  // compilation database. If users don't specify the compilation database
+  // directory, it is the current directory where clang-tidy runs.
+  //
+  // It can be empty in some cases, e.g. the source file does not exist.
+  std::string BuildDirectory;
 
   unsigned errorsIgnored() const {
 return ErrorsIgnoredNOLINT + ErrorsIgnoredCheckFilter +
@@ -185,6 +193,8 @@
   /// counters.
   const ClangTidyStats &getStats() const { return Stats; }
 
+  void setBuildDirectoryForStats(StringRef BuildDirectory);
+
   /// \brief Returns all collected errors.
   const std::vector &getErrors() const { return Errors; }
 
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -229,6 +229,10 @@
   OptionsProvider->getOptions(File));
 }
 
+void ClangTidyContext::setBuildDirectoryForStats(StringRef BuildDirectory) {
+  Stats.BuildDirectory = BuildDirectory;
+}
+
 void ClangTidyContext::setCheckProfileData(ProfileData *P) { Profile = P; }
 
 GlobList &ClangTidyContext::getChecksFilter() {
Index: clang-tidy/ClangTidy.h
===
--- clang-tidy/ClangTidy.h
+++ clang-tidy/ClangTidy.h
@@ -223,7 +223,8 @@
 /// \brief Displays the found \p Errors to the users. If \p Fix is true, \p
 /// Errors containing fixes are automatically applied.
 void handleErrors(const std::vector &Errors, bool Fix,
-  unsigned &WarningsAsErrorsCount);
+  unsigned &WarningsAsErrorsCount,
+  StringRef BuildDirectory);
 
 /// \brief Serializes replacements into YAML and writes them to the specified
 /// output stream.
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -95,14 +95,20 @@
 
 class ErrorReporter {
 public:
-  ErrorReporter(bool ApplyFixes)
+  ErrorReporter(bool ApplyFixes, StringRef BuildDirectory)
   : Files(FileSystemOptions()), DiagOpts(new DiagnosticOptions()),
 DiagPrinter(new TextDiagnosticPrinter(llvm::outs(), &*DiagOpts)),
 Diags(IntrusiveRefCntPtr(new Di

Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Haojian Wu via cfe-commits
hokein marked 2 inline comments as done.


Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:122
@@ -121,3 +121,3 @@
   IsWarningAsError(IsWarningAsError) {}
 
 // Returns true if GlobList starts with the negative indicator ('-'), removes 
it

Done. Now there is no need to add `BuildDirectory` in each `ClangTidyError`.


http://reviews.llvm.org/D17335



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


Re: [PATCH] D17447: Add check for CERT ENV33-C

2016-02-22 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks! I've commit in r261530.


http://reviews.llvm.org/D17447



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


[clang-tools-extra] r261530 - Add a new check, cert-env33-c, that diagnoses uses of system(), popen(), and _popen() to execute a command processor. This check corresponds to the CERT secure coding rul

2016-02-22 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Feb 22 10:01:06 2016
New Revision: 261530

URL: http://llvm.org/viewvc/llvm-project?rev=261530&view=rev
Log:
Add a new check, cert-env33-c, that diagnoses uses of system(), popen(), and 
_popen() to execute a command processor. This check corresponds to the CERT 
secure coding rule: 
https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=2130132

Added:
clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-env33-c.rst
clang-tools-extra/trunk/test/clang-tidy/cert-env33-c.c
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=261530&r1=261529&r2=261530&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Mon Feb 22 
10:01:06 2016
@@ -16,6 +16,7 @@
 #include "../misc/NonCopyableObjects.h"
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
+#include "CommandProcessorCheck.h"
 #include "FloatLoopCounter.h"
 #include "SetLongJmpCheck.h"
 #include "StaticObjectExceptionCheck.h"
@@ -54,6 +55,9 @@ public:
 // DCL
 CheckFactories.registerCheck(
 "cert-dcl03-c");
+// ENV
+CheckFactories.registerCheck(
+"cert-env33-c");
 // FLP
 CheckFactories.registerCheck(
 "cert-flp30-c");

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=261530&r1=261529&r2=261530&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Mon Feb 22 10:01:06 
2016
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCERTModule
   CERTTidyModule.cpp
+  CommandProcessorCheck.cpp
   FloatLoopCounter.cpp
   SetLongJmpCheck.cpp
   StaticObjectExceptionCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.cpp?rev=261530&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.cpp Mon Feb 
22 10:01:06 2016
@@ -0,0 +1,45 @@
+//===--- Env33CCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CommandProcessorCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cert {
+
+void CommandProcessorCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(anyOf(hasName("::system"), hasName("::popen"),
+hasName("::_popen")))
+ .bind("func")),
+  // Do not diagnose when the call expression passes a null pointer
+  // constant to system(); that only checks for the presence of a
+  // command processor, which is not a security risk by itself.
+  unless(callExpr(callee(functionDecl(hasName("::system"))),
+  argumentCountIs(1),
+  hasArgument(0, nullPointerConstant()
+  .bind("expr"),
+  this);
+}
+
+void CommandProcessorCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *Fn = Result.Nodes.getNodeAs("func");
+  const auto *E = Result.Nodes.getNodeAs("expr");
+
+  diag(E->getExprLoc(), "calling %0 uses a command processor") << Fn;
+}
+
+} // namespace cert
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.h?rev=261530&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/CommandProcessorCheck.h (added)
+++ clang-tools-extra/trun

Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17484#358617, @alexfh wrote:

> ... the check in its current form can break the code that uses library 
> symbols from the global namespace. ...


An action item for this is: document this possible issue and add a FIXME 
somewhere in the code to add `std::` qualifiers.


http://reviews.llvm.org/D17484



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


Re: [PATCH] D17456: [libcxx] Reorganize _LIBCPP_LOCALE__L_EXTENSIONS

2016-02-22 Thread Ben Craig via cfe-commits
bcraig updated the summary for this revision.
bcraig added a reviewer: joerg.
bcraig updated this revision to Diff 48687.
bcraig added a comment.

Changed libcxx prefix to libcpp.
Changed BSD forwarding macros to macro functions.


http://reviews.llvm.org/D17456

Files:
  include/__bsd_locale_defaults.h
  include/__bsd_locale_fallbacks.h
  include/locale
  src/locale.cpp

Index: src/locale.cpp
===
--- src/locale.cpp
+++ src/locale.cpp
@@ -1400,33 +1400,21 @@
 wchar_t
 ctype_byname::do_widen(char c) const
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-return btowc_l(c, __l);
-#else
-return __btowc_l(c, __l);
-#endif
+return __libcpp_btowc_l(c, __l);
 }
 
 const char*
 ctype_byname::do_widen(const char* low, const char* high, char_type* dest) const
 {
 for (; low != high; ++low, ++dest)
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-*dest = btowc_l(*low, __l);
-#else
-*dest = __btowc_l(*low, __l);
-#endif
+*dest = __libcpp_btowc_l(*low, __l);
 return low;
 }
 
 char
 ctype_byname::do_narrow(char_type c, char dfault) const
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-int r = wctob_l(c, __l);
-#else
-int r = __wctob_l(c, __l);
-#endif
+int r = __libcpp_wctob_l(c, __l);
 return r != static_cast(WEOF) ? static_cast(r) : dfault;
 }
 
@@ -1435,11 +1423,7 @@
 {
 for (; low != high; ++low, ++dest)
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-int r = wctob_l(*low, __l);
-#else
-int r = __wctob_l(*low, __l);
-#endif
+int r = __libcpp_wctob_l(*low, __l);
 *dest = r != static_cast(WEOF) ? static_cast(r) : dfault;
 }
 return low;
@@ -1549,22 +1533,14 @@
 {
 // save state in case it is needed to recover to_nxt on error
 mbstate_t save_state = st;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-size_t n = wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm),
-static_cast(to_end-to), &st, __l);
-#else
-size_t n = __wcsnrtombs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
-#endif
+size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast(fend-frm),
+ static_cast(to_end-to), &st, __l);
 if (n == size_t(-1))
 {
 // need to recover to_nxt
 for (to_nxt = to; frm != frm_nxt; ++frm)
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-n = wcrtomb_l(to_nxt, *frm, &save_state, __l);
-#else
-n = __wcrtomb_l(to_nxt, *frm, &save_state, __l);
-#endif
+n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l);
 if (n == size_t(-1))
 break;
 to_nxt += n;
@@ -1581,11 +1557,7 @@
 {
 // Try to write the terminating null
 extern_type tmp[MB_LEN_MAX];
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-n = wcrtomb_l(tmp, intern_type(), &st, __l);
-#else
-n = __wcrtomb_l(tmp, intern_type(), &st, __l);
-#endif
+n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l);
 if (n == size_t(-1))  // on error
 return error;
 if (n > static_cast(to_end-to_nxt))  // is there room?
@@ -1618,23 +1590,15 @@
 {
 // save state in case it is needed to recover to_nxt on error
 mbstate_t save_state = st;
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-size_t n = mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm),
-static_cast(to_end-to), &st, __l);
-#else
-size_t n = __mbsnrtowcs_l(to, &frm_nxt, fend-frm, to_end-to, &st, __l);
-#endif
+size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast(fend-frm),
+ static_cast(to_end-to), &st, __l);
 if (n == size_t(-1))
 {
 // need to recover to_nxt
 for (to_nxt = to; frm != frm_nxt; ++to_nxt)
 {
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-n = mbrtowc_l(to_nxt, frm, static_cast(fend-frm),
-  &save_state, __l);
-#else
-n = __mbrtowc_l(to_nxt, frm, fend-frm, &save_state, __l);
-#endif
+n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast(fend-frm),
+   &save_state, __l);
 switch (n)
 {
 case 0:
@@ -1662,11 +1626,7 @@
 if (fend != frm_end)  // set up next null terminated sequence
 {
 // Try to write the terminating null
-#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
-n = mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
-#else
-n = __mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
-#endif
+n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l);
 if (n != 0)  // on error
 return error;
 ++to_nxt;
@@ -1686,11 +1646,7 @@
 {
 to_nxt = to;
 extern_type tmp[MB_LEN_MAX];
-#ifdef _LIBCPP_L

Re: [PATCH] D17345: [OpenCL] Improve diagnostics of address spaces for variables inside function

2016-02-22 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Yes, that's right. In this commit I assume parser has already accepted the 
blocks.

We currently accept them if -fblocks is passed. I think we should also accept 
blocks by default with CL2.0. But I am thinking not to restrict passing 
-fblocks with earlier CL version. This way it's possible to enable them with 
earlier standards if whoever does it knows what it's needed for. We could give 
a warning in this case. What do you think?

However, I wouldn't block this patch on it, as I wouldn't commit them together 
anyways. But I am happy to prepare a separate patch.


http://reviews.llvm.org/D17345



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


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-22 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Yes, that's right. In this commit I assume parser has already accepted the 
blocks.

We currently accept them if -fblocks is passed. I think we should also accept 
blocks by default with CL2.0. But I am thinking not to restrict passing 
-fblocks with earlier CL version. This way it's possible to enable them with 
earlier standards if whoever does it knows what it's needed for. We could give 
a warning in this case. What do you think?

However, I wouldn't block this patch on it, as I wouldn't commit them together 
anyways. But I am happy to prepare a separate patch.


http://reviews.llvm.org/D16928



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


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-22 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked 5 inline comments as done.
carlo.bertolli added a comment.

Updating patch following comments.


Repository:
  rL LLVM

http://reviews.llvm.org/D17170



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


Re: [PATCH] D17335: [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.

2016-02-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17335#358613, @hokein wrote:

> - Don't save BuildDirectory for every error in each check.


I think, it's not going to work with multiple files. There's just one Stats 
instance.



Comment at: test/clang-tidy/clang-tidy-run-with-database.cpp:3
@@ +2,3 @@
+// RUN: sed 's|test_dir|%S|g' %S/Inputs/compilation-database/template.json > 
%T/compile_commands.json
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %s 
-header-filter=.* | FileCheck %s -implicit-check-not="{{warning:}}"
+

We need to test more stuff here, at least these come to mind:

1. -fix
2. multiple files in one clang-tidy invocation
3. files with the same name in different directories



http://reviews.llvm.org/D17335



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


Re: [PATCH] D17170: [OPENMP] Codegen for distribute directive

2016-02-22 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 48691.
carlo.bertolli added a comment.

Address latest comments.


Repository:
  rL LLVM

http://reviews.llvm.org/D17170

Files:
  include/clang/AST/StmtOpenMP.h
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/distribute_codegen.cpp

Index: test/OpenMP/distribute_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/distribute_codegen.cpp
@@ -0,0 +1,239 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64  --check-prefix HCHECK
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32  --check-prefix HCHECK
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 --check-prefix HCHECK
+
+// Test target codegen - host bc file has to be created first. (no significant differences with host version of target region)
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: %ident_t = type { i32, i32, i32, i32, i8* }
+// CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00"
+// CHECK-DAG: [[DEF_LOC_0:@.+]] = private unnamed_addr constant %ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) }
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}without_schedule_clause{{.*}}(float* {{.+}}, float* {{.+}}, float* {{.+}}, float* {{.+}})
+void without_schedule_clause(float *a, float *b, float *c, float *d) {
+  #pragma omp target
+  #pragma omp teams
+  #pragma omp distribute
+  for (int i = 33; i < 3200; i += 7) {
+a[i] = b[i] * c[i] * d[i];
+  }
+}
+
+// CHECK: define {{.*}}void @.omp_outlined.(i32* noalias [[GBL_TIDP:%.+]], i32* noalias [[BND_TID:%.+]], float** dereferenceable({{[0-9]+}}) [[APTR:%.+]], float** dereferenceable({{[0-9]+}}) [[BPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[CPTR:%.+]], float** dereferenceable({{[0-9]+}}) [[DPTR:%.+]])
+// CHECK:  [[TID_ADDR:%.+]] = alloca i32*
+// CHECK:  [[IV:%.+iv]] = alloca i32
+// CHECK:  [[LB:%.+lb]] = alloca i32
+// CHECK:  [[UB:%.+ub]] = alloca i32
+// CHECK:  [[ST:%.+stride]] = alloca i32
+// CHECK:  [[LAST:%.+last]] = alloca i32
+// CHECK-DAG:  store i32* [[GBL_TIDP]], i32** [[TID_ADDR]]
+// CHECK-DAG:  store i32 0, i32* [[LB]]
+// CHECK-DAG:  store i32 4571423, i32* [[UB]]
+// CHECK-DAG:  store i32 1, i32* [[ST]]
+// CHECK-DAG:  store i32 0, i32* [[LAST]]

r261533 - Add support for Android Vector calling convention for AArch64

2016-02-22 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Mon Feb 22 10:48:42 2016
New Revision: 261533

URL: http://llvm.org/viewvc/llvm-project?rev=261533&view=rev
Log:
Add support for Android Vector calling convention for AArch64

This modification applies the following Android commit when we have an
Android environment. This is the sole non-renderscript in the Android repo

commit 9212d4fb30a3ca2f4ee966dd2748c35573d9682c
Author: Tim Murray 
Date:   Fri Aug 15 16:00:15 2014 -0700

Update vector calling convention for AArch64.

bug 16846318

Change-Id: I3cfd167758b4bd634d8480ee6ba6bb55d61f82a7

Reviewers: srhines, jyknight

Subscribers: mcrosier, aemerson, rengolin, tberghammer, danalbert, srhines

Differential Revision: http://reviews.llvm.org/D17448

Modified:
cfe/trunk/lib/CodeGen/ABIInfo.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/arm64-abi-vector.c

Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=261533&r1=261532&r2=261533&view=diff
==
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Mon Feb 22 10:48:42 2016
@@ -85,6 +85,8 @@ namespace clang {
CodeGen::Address VAListAddr,
QualType Ty) const = 0;
 
+bool isAndroid() const;
+
 /// Emit the target dependent code to load a value of
 /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr.
 virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF,

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=261533&r1=261532&r2=261533&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Feb 22 10:48:42 2016
@@ -117,6 +117,8 @@ const TargetInfo &ABIInfo::getTarget() c
   return CGT.getTarget();
 }
 
+bool ABIInfo:: isAndroid() const { return getTarget().getTriple().isAndroid(); 
}
+
 bool ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
   return false;
 }
@@ -4319,6 +4321,11 @@ ABIArgInfo AArch64ABIInfo::classifyArgum
   // Handle illegal vector types here.
   if (isIllegalVectorType(Ty)) {
 uint64_t Size = getContext().getTypeSize(Ty);
+// Android promotes <2 x i8> to i16, not i32
+if(isAndroid() && (Size <= 16)) {
+  llvm::Type *ResType = llvm::Type::getInt16Ty(getVMContext());
+  return ABIArgInfo::getDirect(ResType);
+}
 if (Size <= 32) {
   llvm::Type *ResType = llvm::Type::getInt32Ty(getVMContext());
   return ABIArgInfo::getDirect(ResType);
@@ -4803,11 +4810,6 @@ public:
 }
   }
 
-  bool isAndroid() const {
-return (getTarget().getTriple().getEnvironment() ==
-llvm::Triple::Android);
-  }
-
   ABIKind getABIKind() const { return Kind; }
 
 private:

Modified: cfe/trunk/test/CodeGen/arm64-abi-vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-abi-vector.c?rev=261533&r1=261532&r2=261533&view=diff
==
--- cfe/trunk/test/CodeGen/arm64-abi-vector.c (original)
+++ cfe/trunk/test/CodeGen/arm64-abi-vector.c Mon Feb 22 10:48:42 2016
@@ -1,7 +1,9 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios7 -target-abi darwinpcs -emit-llvm 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-android -emit-llvm -o - %s | 
FileCheck -check-prefix=ANDROID %s
 
 #include 
 
+typedef __attribute__(( ext_vector_type(2) ))  char __char2;
 typedef __attribute__(( ext_vector_type(3) ))  char __char3;
 typedef __attribute__(( ext_vector_type(4) ))  char __char4;
 typedef __attribute__(( ext_vector_type(5) ))  char __char5;
@@ -13,6 +15,26 @@ typedef __attribute__(( ext_vector_type(
 typedef __attribute__(( ext_vector_type(5) ))  int __int5;
 typedef __attribute__(( ext_vector_type(3) ))  double __double3;
 
+// Passing legal vector types as varargs. Check that we've allocated the 
appropriate size
+double varargs_vec_2c(int fixed, ...) {
+// ANDROID: varargs_vec_2c
+// ANDROID: [[VAR:%.*]] = alloca <2 x i8>, align 2
+// ANDROID: [[AP_NEXT:%.*]] = getelementptr inbounds i8, i8* [[AP_CUR:%.*]], 
i64 8
+// ANDROID: bitcast i8* [[AP_CUR]] to <2 x i8>*
+  va_list ap;
+  double sum = fixed;
+  va_start(ap, fixed);
+  __char2 c3 = va_arg(ap, __char2);
+  sum = sum + c3.x + c3.y;
+  va_end(ap);
+  return sum;
+}
+
+double test_2c(__char2 *in) {
+// ANDROID: call double (i32, ...) @varargs_vec_2c(i32 3, i16 {{%.*}})
+  return varargs_vec_2c(3, *in);
+}
+
 double varargs_vec_3c(int fixed, ...) {
 // CHECK: varargs_vec_3c
 // CHECK: alloca <3 x i8>, align 4


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: [PATCH] D15636: Reduce false positives in printf/scanf format checker

2016-02-22 Thread Andy Gibbs via cfe-commits
AndyG added inline comments.


Comment at: lib/Sema/SemaChecking.cpp:3905
@@ -3822,14 +3904,3 @@
 CoveredArgs.flip();
-signed notCoveredArg = CoveredArgs.find_first();
-if (notCoveredArg >= 0) {
-  assert((unsigned)notCoveredArg < NumDataArgs);
-  if (const Expr *E = getDataArg((unsigned) notCoveredArg)) {
-SourceLocation Loc = E->getLocStart();
-if (!S.getSourceManager().isInSystemMacro(Loc)) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_printf_data_arg_not_used),
-   Loc, /*IsStringLocation*/false,
-   getFormatStringRange());
-}
-  }
-}
+UncoveredArg.Update(CoveredArgs.find_first(), FExpr);
   }

Rather than `FExpr`, I think this should be `OrigFormatExpr`?


http://reviews.llvm.org/D15636



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


Re: [PATCH] D16317: [Analyzer] Fix for PR23790: bind real value returned from strcmp when modelling strcmp.

2016-02-22 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks great, other than some non-standard indentation.



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1886
@@ +1885,3 @@
+  svalBuilder.evalBinOp(state, op, resultVal, zeroVal,
+  svalBuilder.getConditionType());
+DefinedSVal compareWithZeroVal = compareWithZero.castAs();

Non-standard indentation here.


http://reviews.llvm.org/D16317



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


r261535 - [MS ABI] Correctly handle dllimport'd explicit instantiation declaration w/ vbases

2016-02-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Feb 22 11:22:08 2016
New Revision: 261535

URL: http://llvm.org/viewvc/llvm-project?rev=261535&view=rev
Log:
[MS ABI] Correctly handle dllimport'd explicit instantiation declaration w/ 
vbases

We gave a VBTable dllimport storage class and external linkage while
also providing an initializer.  An initializer is only valid if the
VBTable has available_externally linkage.  Fix this by setting the
linkage to available_externally in situ while generating the
initializer.

This fixes PR26686.

Modified:
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/test/CodeGenCXX/PR26569.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=261535&r1=261534&r2=261535&view=diff
==
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Mon Feb 22 11:22:08 2016
@@ -2039,6 +2039,9 @@ void MicrosoftCXXABI::emitVBTableDefinit
 llvm::ArrayType::get(CGM.IntTy, Offsets.size());
   llvm::Constant *Init = llvm::ConstantArray::get(VBTableType, Offsets);
   GV->setInitializer(Init);
+
+  if (RD->hasAttr())
+GV->setLinkage(llvm::GlobalVariable::AvailableExternallyLinkage);
 }
 
 llvm::Value *MicrosoftCXXABI::performThisAdjustment(CodeGenFunction &CGF,

Modified: cfe/trunk/test/CodeGenCXX/PR26569.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR26569.cpp?rev=261535&r1=261534&r2=261535&view=diff
==
--- cfe/trunk/test/CodeGenCXX/PR26569.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR26569.cpp Mon Feb 22 11:22:08 2016
@@ -4,14 +4,17 @@ class A {
   virtual void m_fn1();
 };
 template 
-class B : A {};
+class B : virtual A {};
 
 extern template class __declspec(dllimport) B;
 class __declspec(dllexport) C : B {};
 
-// CHECK: @[[VTABLE_C:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4C@@6B@" to i8*), i8* bitcast 
(void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)]
-// CHECK: @[[VTABLE_B:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$B@H@@6B@" to i8*), i8* 
bitcast (void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], 
comdat($"\01??_S?$B@H@@6B@")
-// CHECK: @[[VTABLE_A:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4A@@6B@" to i8*), i8* bitcast 
(void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], comdat($"\01??_7A@@6B@")
-// CHECK: @"\01??_7C@@6B@" = dllexport unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_C]], i32 0, i32 1)
-// CHECK: @"\01??_S?$B@H@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_B]], i32 0, i32 1)
-// CHECK: @"\01??_7A@@6B@" = unnamed_addr alias i8*, getelementptr inbounds 
([2 x i8*], [2 x i8*]* @[[VTABLE_A]], i32 0, i32 1)
+// CHECK-DAG: @[[VTABLE_C:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4C@@6B@" to i8*), i8* bitcast 
(void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)]
+// CHECK-DAG: @[[VTABLE_B:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$B@H@@6B@" to i8*), i8* 
bitcast (void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], 
comdat($"\01??_S?$B@H@@6B@")
+// CHECK-DAG: @[[VTABLE_A:.*]] = private unnamed_addr constant [2 x i8*] [i8* 
bitcast (%rtti.CompleteObjectLocator* @"\01??_R4A@@6B@" to i8*), i8* bitcast 
(void (%class.A*)* @"\01?m_fn1@A@@EAEXXZ" to i8*)], comdat($"\01??_7A@@6B@")
+
+// CHECK-DAG: @"\01??_7C@@6B@" = dllexport unnamed_addr alias i8*, 
getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_C]], i32 0, i32 1)
+// CHECK-DAG: @"\01??_S?$B@H@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_B]], i32 0, i32 1)
+// CHECK-DAG: @"\01??_7A@@6B@" = unnamed_addr alias i8*, getelementptr 
inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_A]], i32 0, i32 1)
+
+// CHECK-DAG: @"\01??_8?$B@H@@7B@" = available_externally dllimport 
unnamed_addr constant [2 x i32] [i32 0, i32 4]


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


r261534 - Add a test for r261425.

2016-02-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Feb 22 11:22:01 2016
New Revision: 261534

URL: http://llvm.org/viewvc/llvm-project?rev=261534&view=rev
Log:
Add a test for r261425.

Added:
cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp

Added: cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp?rev=261534&view=auto
==
--- cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/exceptions-cxx-ehsc.cpp Mon Feb 22 11:22:01 2016
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -fexceptions 
-fcxx-exceptions -fexternc-nounwind | FileCheck %s
+
+namespace test1 {
+struct Cleanup { ~Cleanup(); };
+extern "C" void never_throws();
+void may_throw();
+
+void caller() {
+  Cleanup x;
+  never_throws();
+  may_throw();
+}
+}
+// CHECK-LABEL: define void @"\01?caller@test1@@YAXXZ"(
+// CHECK: call void @never_throws(
+// CHECK: invoke void @"\01?may_throw@test1@@YAXXZ"(


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


Re: [PATCH] D14203: [analyzer] Improve pointer arithmetic checker.

2016-02-22 Thread Devin Coughlin via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Other than a suggested diagnostic rewording to consider, looks good to me. 
Thanks Gábor!



Comment at: lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp:198
@@ +197,3 @@
+  new BuiltinBug(this, "Dangerous pointer arithmetic",
+ "Pointer arithmetic done on non-array variables means 
"
+ "reliance on memory layout, which is dangerous."));

Here is a suggestion to reword: "Pointer arithmetic on non-array variables 
relies on memory layout, which is dangerous."


http://reviews.llvm.org/D14203



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


[PATCH] D17515: AMDGPU: Add builtins for recently added intrinsics

2016-02-22 Thread Matt Arsenault via cfe-commits
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: cfe-commits.

http://reviews.llvm.org/D17515

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/SemaOpenCL/builtins-amdgcn.cl

Index: test/SemaOpenCL/builtins-amdgcn.cl
===
--- /dev/null
+++ test/SemaOpenCL/builtins-amdgcn.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -fsyntax-only -verify %s
+
+void test_s_sleep(int x)
+{
+  __builtin_amdgcn_s_sleep(x); // expected-error {{argument to 
'__builtin_amdgcn_s_sleep' must be a constant integer}}
+}
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -3,6 +3,8 @@
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
+typedef unsigned long ulong;
+
 // CHECK-LABEL: @test_div_scale_f64
 // CHECK: call { double, i1 } @llvm.amdgcn.div.scale.f64(double %a, double %b, 
i1 true)
 // CHECK-DAG: [[FLAG:%.+]] = extractvalue { double, i1 } %{{.+}}, 1
@@ -169,6 +171,29 @@
   __builtin_amdgcn_s_barrier();
 }
 
+// CHECK-LABEL: @test_s_memtime
+// CHECK: call i64 @llvm.amdgcn.s.memtime()
+void test_s_memtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memtime();
+}
+
+// CHECK-LABEL: @test_s_memrealtime
+// CHECK: call i64 @llvm.amdgcn.s.memrealtime()
+void test_s_memrealtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memrealtime();
+}
+
+// CHECK-LABEL: @test_s_sleep
+// CHECK: call void @llvm.amdgcn.s.sleep(i32 1)
+// CHECK: call void @llvm.amdgcn.s.sleep(i32 15)
+void test_s_sleep()
+{
+  __builtin_amdgcn_s_sleep(1);
+  __builtin_amdgcn_s_sleep(15);
+}
+
 // CHECK-LABEL: @test_cubeid(
 // CHECK: call float @llvm.amdgcn.cubeid(float %a, float %b, float %c)
 void test_cubeid(global float* out, float a, float b, float c) {
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -40,8 +40,18 @@
 BUILTIN(__builtin_amdgcn_cubesc, "", "nc")
 BUILTIN(__builtin_amdgcn_cubetc, "", "nc")
 BUILTIN(__builtin_amdgcn_cubema, "", "nc")
+BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n")
+BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
 
+//===--===//
+// VI+ only builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n")
+
+//===--===//
 // Legacy names with amdgpu prefix
+//===--===//
+
 BUILTIN(__builtin_amdgpu_rsq, "dd", "nc")
 BUILTIN(__builtin_amdgpu_rsqf, "ff", "nc")
 BUILTIN(__builtin_amdgpu_ldexp, "ddi", "nc")


Index: test/SemaOpenCL/builtins-amdgcn.cl
===
--- /dev/null
+++ test/SemaOpenCL/builtins-amdgcn.cl
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -fsyntax-only -verify %s
+
+void test_s_sleep(int x)
+{
+  __builtin_amdgcn_s_sleep(x); // expected-error {{argument to '__builtin_amdgcn_s_sleep' must be a constant integer}}
+}
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -3,6 +3,8 @@
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
+typedef unsigned long ulong;
+
 // CHECK-LABEL: @test_div_scale_f64
 // CHECK: call { double, i1 } @llvm.amdgcn.div.scale.f64(double %a, double %b, i1 true)
 // CHECK-DAG: [[FLAG:%.+]] = extractvalue { double, i1 } %{{.+}}, 1
@@ -169,6 +171,29 @@
   __builtin_amdgcn_s_barrier();
 }
 
+// CHECK-LABEL: @test_s_memtime
+// CHECK: call i64 @llvm.amdgcn.s.memtime()
+void test_s_memtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memtime();
+}
+
+// CHECK-LABEL: @test_s_memrealtime
+// CHECK: call i64 @llvm.amdgcn.s.memrealtime()
+void test_s_memrealtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memrealtime();
+}
+
+// CHECK-LABEL: @test_s_sleep
+// CHECK: call void @llvm.amdgcn.s.sleep(i32 1)
+// CHECK: call void @llvm.amdgcn.s.sleep(i32 15)
+void test_s_sleep()
+{
+  __builtin_amdgcn_s_sleep(1);
+  __builtin_amdgcn_s_sleep(15);
+}
+
 // CHECK-LABEL: @test_cubeid(
 // CHECK: call float @llvm.amdgcn.cubeid(float %a, float %b, float %c)
 void test_cubeid(global float* out, float a, float b, float c) {
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -40,8 +40,18 @@
 BUILTIN(__builtin_amdgcn_cubesc, "", "nc")
 BUILTIN(__builtin_amdgcn

[PATCH] D17516: AMDGPU: Verify subtarget specific builtins

2016-02-22 Thread Matt Arsenault via cfe-commits
arsenm created this revision.
arsenm added reviewers: tstellarAMD, echristo.
arsenm added a subscriber: cfe-commits.

Cleanup setup of subtarget features.

http://reviews.llvm.org/D17516

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/Basic/Targets.cpp
  test/CodeGenOpenCL/builtins-amdgcn-error.cl
  test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/SemaOpenCL/builtins-amdgcn.cl

Index: test/SemaOpenCL/builtins-amdgcn.cl
===
--- test/SemaOpenCL/builtins-amdgcn.cl
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -fsyntax-only -verify %s
-
-void test_s_sleep(int x)
-{
-  __builtin_amdgcn_s_sleep(x); // expected-error {{argument to '__builtin_amdgcn_s_sleep' must be a constant integer}}
-}
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -178,13 +178,6 @@
   *out = __builtin_amdgcn_s_memtime();
 }
 
-// CHECK-LABEL: @test_s_memrealtime
-// CHECK: call i64 @llvm.amdgcn.s.memrealtime()
-void test_s_memrealtime(global ulong* out)
-{
-  *out = __builtin_amdgcn_s_memrealtime();
-}
-
 // CHECK-LABEL: @test_s_sleep
 // CHECK: call void @llvm.amdgcn.s.sleep(i32 1)
 // CHECK: call void @llvm.amdgcn.s.sleep(i32 15)
Index: test/CodeGenOpenCL/builtins-amdgcn-vi.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-vi.cl
@@ -0,0 +1,12 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu tonga -S -emit-llvm -o - %s | FileCheck %s
+
+typedef unsigned long ulong;
+
+
+// CHECK-LABEL: @test_s_memrealtime
+// CHECK: call i64 @llvm.amdgcn.s.memrealtime()
+void test_s_memrealtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memrealtime();
+}
Index: test/CodeGenOpenCL/builtins-amdgcn-error.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/builtins-amdgcn-error.cl
@@ -0,0 +1,18 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -target-cpu tahiti -verify -S -o - %s
+
+// FIXME: We only get one error if the functions are the other order in the
+// file.
+
+typedef unsigned long ulong;
+
+ulong test_s_memrealtime()
+{
+  return __builtin_amdgcn_s_memrealtime(); // expected-error {{'__builtin_amdgcn_s_memrealtime' needs target feature s-memrealtime}}
+}
+
+void test_s_sleep(int x)
+{
+  __builtin_amdgcn_s_sleep(x); // expected-error {{argument to '__builtin_amdgcn_s_sleep' must be a constant integer}}
+}
+
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1801,23 +1801,32 @@
   bool hasFMAF:1;
   bool hasLDEXPF:1;
 
+  bool hasSMemRealTime : 1;
+  bool Has16BitInsts : 1;
+
+  static bool isAMDGCN(const llvm::Triple &TT) {
+return TT.getArch() == llvm::Triple::amdgcn;
+  }
+
 public:
   AMDGPUTargetInfo(const llvm::Triple &Triple)
-: TargetInfo(Triple) {
+: TargetInfo(Triple) ,
+  GPU(isAMDGCN(Triple) ? GK_SOUTHERN_ISLANDS : GK_R600),
+  hasFP64(false),
+  hasFMAF(false),
+  hasLDEXPF(false),
+  hasSMemRealTime(false),
+  Has16BitInsts(false) {
 
 if (Triple.getArch() == llvm::Triple::amdgcn) {
   DataLayoutString = DataLayoutStringSI;
-  GPU = GK_SOUTHERN_ISLANDS;
   hasFP64 = true;
   hasFMAF = true;
   hasLDEXPF = true;
 } else {
   DataLayoutString = DataLayoutStringR600;
-  GPU = GK_R600;
-  hasFP64 = false;
-  hasFMAF = false;
-  hasLDEXPF = false;
 }
+
 AddrSpaceMap = &AMDGPUAddrSpaceMap;
 UseAddrSpaceMapMangling = true;
   }
@@ -1858,6 +1867,10 @@
 return false;
   }
 
+  bool initFeatureMap(llvm::StringMap &Features,
+  DiagnosticsEngine &Diags, StringRef CPU,
+  const std::vector &FeatureVec) const override;
+
   ArrayRef getTargetBuiltins() const override {
 return llvm::makeArrayRef(BuiltinInfo,
 clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin);
@@ -1929,39 +1942,45 @@
   .Case("carrizo",  GK_VOLCANIC_ISLANDS)
   .Default(GK_NONE);
 
-if (GPU == GK_NONE) {
+if (GPU == GK_NONE)
   return false;
-}
 
 // Set the correct data layout
-switch (GPU) {
-case GK_NONE:
-case GK_R600:
-case GK_R700:
-case GK_EVERGREEN:
-case GK_NORTHERN_ISLANDS:
-  DataLayoutString = DataLayoutStringR600;
-  hasFP64 = false;
-  hasFMAF = false;
-  hasLDEXPF = false;
-  break;
-case GK_R600_DOUBLE_OPS:
-case GK_R700_DOUBLE_OPS:
-case GK_EVERGREEN_DOUBLE_OPS:
-case GK_CAYMAN:
-  DataLayoutString = DataLayoutStringR600DoubleOps;
-  hasFP64 = true;
-  hasFMAF = true;
-  h

Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-22 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

In http://reviews.llvm.org/D17484#358617, @alexfh wrote:

> Thank you for this check! Mostly looks good, but there are a number of style 
> nits.
>
> The most important question to this check is that the standard doesn't 
> guarantee that the C++ headers declare all the same functions **in the global 
> namespace** (at least, this is how I understand the section of the standard 
> you quoted).


Oh crap, I totally forgot about this.  Yes, I believe the weasel wording in the 
standard is that an implementation may put the symbols in the global namespace 
as well as inside `std` when the C++ header is used, but is not required to put 
them in the global namespace.  They are required to put them in namespace `std` 
when the C++ header form is used.

So if you switch to C++ headers, you code may still compile, but it is 
implementation dependent.

If you use the C headers, you can't prefix symbols with `std` because they 
won't be there.

In other discussions of this topic, it was considered best to make both changes 
at the same time: switch to the C++ header and decorate the symbols with `std` 
prefix.

It would be reasonable for this check to insert a `using namespace std;` at the 
top of the translation unit after all the `#include` lines as a means of 
preserving meaning without trying to identify every symbol that needs `std` on 
it.


http://reviews.llvm.org/D17484



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


r261537 - Don't enable /GX by default

2016-02-22 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Feb 22 11:44:51 2016
New Revision: 261537

URL: http://llvm.org/viewvc/llvm-project?rev=261537&view=rev
Log:
Don't enable /GX by default

The /GX flag is disabled unless explicitly specified on the command
line.  This partially addresses PR26698.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261537&r1=261536&r2=261537&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Feb 22 11:44:51 2016
@@ -5813,8 +5813,10 @@ static EHFlags parseClangCLEHFlags(const
 }
   }
   // The /GX, /GX- flags are only processed if there are not /EH flags.
+  // The default is that /GX is not specified.
   if (EHArgs.empty() &&
-  Args.hasFlag(options::OPT__SLASH_GX, options::OPT__SLASH_GX_)) {
+  Args.hasFlag(options::OPT__SLASH_GX, options::OPT__SLASH_GX_,
+   /*default=*/false)) {
 EH.Synch = true;
 EH.NoUnwindC = true;
   }

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=261537&r1=261536&r2=261537&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Feb 22 11:44:51 2016
@@ -211,6 +211,9 @@
 // RUN: %clang_cl /FI asdf.h -### -- %s 2>&1 | FileCheck -check-prefix=FI_ %s
 // FI_: "-include" "asdf.h"
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NO-GX %s
+// NO-GX-NOT: "-fcxx-exceptions" "-fexceptions"
+
 // RUN: %clang_cl /c /GX -### -- %s 2>&1 | FileCheck -check-prefix=GX %s
 // GX: "-fcxx-exceptions" "-fexceptions"
 


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


Re: [PATCH] D17436: [OpenCL] Add Sema checks for OpenCL 2.0 block

2016-02-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:6714
@@ +6713,3 @@
+  if (LangOpts.OpenCLVersion >= 200 && T->isBlockPointerType()) {
+const BlockPointerType *BlkTy = T->getAs();
+const FunctionProtoType *FTy =

Yes, but you have to diagnose blocks correctly in all CL versions in which we 
accept blocks. When you come to this point here you should only care about 
checking whether blocks have variadic prototype or not. You should assume the 
parser did the right job to either accept or reject the block declaration 
earlier and also gave the right diagnostic.

It will be responsibility of a parser to correctly accept or reject blocks 
depending on a version. I will prepare a patch for it later on. Please see my 
related comment on the review: http://reviews.llvm.org/D16928 


Comment at: lib/Sema/SemaExpr.cpp:6509
@@ +6508,3 @@
+  return QualType();
+  }
+

What is the implication of that? Will we get errors in different order then?


http://reviews.llvm.org/D17436



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


r261545 - [analyzer] Detect duplicate [super dealloc] calls

2016-02-22 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Mon Feb 22 11:56:24 2016
New Revision: 261545

URL: http://llvm.org/viewvc/llvm-project?rev=261545&view=rev
Log:
[analyzer] Detect duplicate [super dealloc] calls

Add an alpha path checker that warns about duplicate calls to [super dealloc].
This will form the foundation of a checker that will detect uses of
'self' after calling [super dealloc].

Part of rdar://problem/6953275.

Based on a patch by David Kilzer!

Differential Revision: http://reviews.llvm.org/D5238

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=261545&r1=261544&r2=261545&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Feb 22 11:56:24 
2016
@@ -56,6 +56,7 @@ add_clang_library(clangStaticAnalyzerChe
   ObjCContainersChecker.cpp
   ObjCMissingSuperCallChecker.cpp
   ObjCSelfInitChecker.cpp
+  ObjCSuperDeallocChecker.cpp
   ObjCUnusedIVarsChecker.cpp
   PaddingChecker.cpp
   PointerArithChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=261545&r1=261544&r2=261545&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Mon Feb 22 11:56:24 2016
@@ -513,6 +513,10 @@ def ObjCDeallocChecker : Checker<"Deallo
   HelpText<"Warn about Objective-C classes that lack a correct implementation 
of -dealloc">,
   DescFile<"CheckObjCDealloc.cpp">;
 
+def ObjCSuperDeallocChecker : Checker<"SuperDealloc">,
+  HelpText<"Warn about improper use of '[super dealloc]' in Objective-C">,
+  DescFile<"ObjCSuperDeallocChecker.cpp">;
+
 def InstanceVariableInvalidation : Checker<"InstanceVariableInvalidation">,
   HelpText<"Check that the invalidatable instance variables are invalidated in 
the methods annotated with objc_instance_variable_invalidator">,
   DescFile<"IvarInvalidationChecker.cpp">;

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp?rev=261545&view=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp Mon Feb 
22 11:56:24 2016
@@ -0,0 +1,197 @@
+//===- ObjCSuperDeallocChecker.cpp - Check correct use of [super dealloc] 
-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines ObjCSuperDeallocChecker, a builtin check that warns when
+// [super dealloc] is called twice on the same instance in MRR mode.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ObjCSuperDeallocChecker
+: public Checker {
+
+  mutable IdentifierInfo *IIdealloc, *IINSObject;
+  mutable Selector SELdealloc;
+
+  std::unique_ptr DoubleSuperDeallocBugType;
+
+  void initIdentifierInfoAndSelectors(ASTContext &Ctx) const;
+
+  bool isSuperDeallocMessage(const ObjCMethodCall &M) const;
+
+public:
+  ObjCSuperDeallocChecker();
+  void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
+  void checkPreObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
+};
+
+} // End anonymous namespace.
+
+// Remember whether [super dealloc] has previously been called on the
+// a SymbolRef for the receiver.
+REGISTER_SET_WITH_PROGRAMSTATE(CalledSuperDealloc, SymbolRef)
+
+class SuperDeallocBRVisitor final
+: public BugReporterVisitorImpl {
+
+  SymbolRef ReceiverSymbol;
+  bool Satisfied;
+
+public:
+  SuperDeallocBRVisitor(SymbolRef ReceiverSymbol)
+  : ReceiverSymbol(ReceiverSymbol),
+Satisfied

Re: [PATCH] D5238: [analyzer] Detect duplicate [super dealloc] calls

2016-02-22 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261545: [analyzer] Detect duplicate [super dealloc] calls 
(authored by dcoughlin).

Changed prior to commit:
  http://reviews.llvm.org/D5238?vs=48447&id=48707#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D5238

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
  cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m

Index: cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
===
--- cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
+++ cfe/trunk/test/Analysis/DeallocUseAfterFreeErrors.m
@@ -0,0 +1,298 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s
+
+void clang_analyzer_warnIfReached();
+
+#define nil ((id)0)
+
+typedef unsigned long NSUInteger;
+@protocol NSObject
+- (instancetype)retain;
+- (oneway void)release;
+@end
+
+@interface NSObject  { }
+- (void)dealloc;
+- (instancetype)init;
+@end
+
+typedef struct objc_selector *SEL;
+
+//======
+//  
+//  Check that 'self' is not referenced after calling '[super dealloc]'.
+
+@interface SuperDeallocThenReleaseIvarClass : NSObject {
+  NSObject *_ivar;
+}
+@end
+
+@implementation SuperDeallocThenReleaseIvarClass
+- (instancetype)initWithIvar:(NSObject *)ivar {
+  self = [super init];
+  if (!self)
+return nil;
+  _ivar = [ivar retain];
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  [_ivar release];
+}
+@end
+
+@interface SuperDeallocThenAssignNilToIvarClass : NSObject {
+  NSObject *_delegate;
+}
+@end
+
+@implementation SuperDeallocThenAssignNilToIvarClass
+- (instancetype)initWithDelegate:(NSObject *)delegate {
+  self = [super init];
+  if (!self)
+return nil;
+  _delegate = delegate;
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  _delegate = nil;
+}
+@end
+
+@interface SuperDeallocThenReleasePropertyClass : NSObject { }
+@property (retain) NSObject *ivar;
+@end
+
+@implementation SuperDeallocThenReleasePropertyClass
+- (instancetype)initWithProperty:(NSObject *)ivar {
+  self = [super init];
+  if (!self)
+return nil;
+  self.ivar = ivar;
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  self.ivar = nil;
+}
+@end
+
+@interface SuperDeallocThenAssignNilToPropertyClass : NSObject { }
+@property (assign) NSObject *delegate;
+@end
+
+@implementation SuperDeallocThenAssignNilToPropertyClass
+- (instancetype)initWithDelegate:(NSObject *)delegate {
+  self = [super init];
+  if (!self)
+return nil;
+  self.delegate = delegate;
+  return self;
+}
+- (void)dealloc {
+  [super dealloc];
+  self.delegate = nil;
+}
+@end
+
+@interface SuperDeallocThenCallInstanceMethodClass : NSObject { }
+- (void)_invalidate;
+@end
+
+@implementation SuperDeallocThenCallInstanceMethodClass
+- (void)_invalidate {
+}
+- (void)dealloc {
+  [super dealloc];
+  [self _invalidate];
+}
+@end
+
+@interface SuperDeallocThenCallNonObjectiveCMethodClass : NSObject { }
+@end
+
+static void _invalidate(NSObject *object) {
+  (void)object;
+}
+
+@implementation SuperDeallocThenCallNonObjectiveCMethodClass
+- (void)dealloc {
+  [super dealloc];
+  _invalidate(self);
+}
+@end
+
+@interface TwoSuperDeallocCallsClass : NSObject {
+  NSObject *_ivar;
+}
+- (void)_invalidate;
+@end
+
+@implementation TwoSuperDeallocCallsClass
+- (void)_invalidate {
+}
+- (void)dealloc {
+  if (_ivar) {
+[_ivar release];
+[super dealloc];
+return;
+  }
+  [super dealloc];
+  [self _invalidate];
+}
+@end
+
+//======
+// Warn about calling [super dealloc] twice due to missing return statement.
+
+@interface MissingReturnCausesDoubleSuperDeallocClass : NSObject {
+  NSObject *_ivar;
+}
+@end
+
+@implementation MissingReturnCausesDoubleSuperDeallocClass
+- (void)dealloc {
+  if (_ivar) { // expected-note {{Taking true branch}}
+[_ivar release];
+[super dealloc]; // expected-note {{[super dealloc] called here}}
+// return;
+  }
+  [super dealloc]; // expected-warning{{[super dealloc] should not be called multiple times}}
+  // expected-note@-1{{[super dealloc] should not be called multiple times}}
+}
+@end
+
+//======
+// Warn about calling [super dealloc] twice in two different methods.
+
+@interface SuperDeallocInOtherMethodClass : NSObject {
+  NSObject *_ivar;
+}
+- (void)_cleanup;
+@end
+
+@implementation SuperDeallocInOtherMethodClass
+- (void)_cleanup {
+  [_ivar release];
+  [super dealloc]; // expected-note {{[super dealloc] called here}}
+}
+- (void)dealloc {
+  [self _cleanup]; // expected-note {{Calling '_cleanup'}}
+  //expected-note@-1 {{Retu

Re: [PATCH] D17437: [OpenCL] Add Sema checks for types

2016-02-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/invalid-image.cl:3
@@ +2,3 @@
+
+void test1(image1d_t *i){} // expected-error {{pointer to type 'image1d_t' is 
invalid in OpenCL}}
+

Could we add similar tests for other types too. I think we could put them in 
existing cl files.


http://reviews.llvm.org/D17437



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


Re: [PATCH] D17446: ASTMatchers: add new statement/decl matchers

2016-02-22 Thread Richard via cfe-commits
LegalizeAdulthood added a subscriber: LegalizeAdulthood.


Comment at: docs/LibASTMatchersReference.html:512
@@ +511,3 @@
+MatcherStmt>addrLabelExprMatcherAddrLabelExpr>...
+Matches address of 
label statements (GNU extension).
+

Can we put `gnu` in the name of matchers that only match GNU extensions?


Comment at: docs/LibASTMatchersReference.html:544
@@ +543,3 @@
+MatcherStmt>atomicExprMatcherAtomicExpr>...
+Matches atomic builtins.
+

Please provide an example here.


Comment at: docs/LibASTMatchersReference.html:549
@@ +548,3 @@
+MatcherStmt>binaryConditionalOperatorMatcherBinaryConditionalOperator>...
+Matches 
binary conditional operator expressions (GNU extension).
+

See above re: gnu specific extensions.  When I read the name of this matcher, I 
expected it to be matching `==`, `!=`, `<=`, etc.


Comment at: docs/LibASTMatchersReference.html:1120
@@ +1119,3 @@
+MatcherStmt>opaqueValueExprMatcherOpaqueValueExpr>...
+Matches opaque 
value expressions.
+

The docs say that OpaqueValueExpr doesn't correspond to concrete syntax, so why 
would we have a matcher for it?


Comment at: docs/LibASTMatchersReference.html:1140
@@ +1139,3 @@
+Given
+  template class X { void f() { X x(*this); } };
+parenListExpr()

Can we have a simpler example?  For instance, I can't see that `ParenListExpr` 
has anything to do with templates.


Comment at: docs/LibASTMatchersReference.html:1149
@@ +1148,3 @@
+
+Example: Matches __func__)
+  printf("%s", __func__);

Does it actually match the closing paren?


Comment at: docs/LibASTMatchersReference.html:1175
@@ +1174,3 @@
+MatcherStmt>stmtExprMatcherStmtExpr>...
+Matches GNU statement 
expression.
+

Ditto re: gnu extension


Comment at: docs/LibASTMatchersReference.html:1752
@@ +1751,3 @@
+MatcherCXXConstructExpr>requiresZeroInitialization
+Matches 
a constructor call expression which requires
+zero initialization.

Please provide an example.


http://reviews.llvm.org/D17446



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


Re: [PATCH] D17437: [OpenCL] Add Sema checks for types

2016-02-22 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: test/SemaOpenCL/invalid-image.cl:3
@@ +2,3 @@
+
+void test1(image1d_t *i){} // expected-error {{pointer to type 'image1d_t' is 
invalid in OpenCL}}
+

Anastasia wrote:
> Could we add similar tests for other types too. I think we could put them in 
> existing cl files.
At least sampler test could go into test/SemaOpenCL/sampler_t.cl


http://reviews.llvm.org/D17437



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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-22 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

Thank you for a review, Alex!

I'll clean up the parts you mentioned soon!

In http://reviews.llvm.org/D17484#358617, @alexfh wrote:

> The most important question to this check is that the standard doesn't 
> guarantee that the C++ headers declare all the same functions **in the global 
> namespace** (at least, this is how I understand the section of the standard 
> you quoted). This means that the check in its current form can break the code 
> that uses library symbols from the global namespace. The check could add 
> `std::` wherever it's needed (though it may be not completely trivial) to 
> mitigate the risk. It's not what needs to be addressed in the first 
> iteration, but it's definitely worth a look at in order to make the check 
> actually useful. It also could be a separate check or a separate mode 
> (configurable via parameters) of this check, while someone could have reasons 
> to do the migration in two stages (add `std::` qualifiers and then switch to 
> new headers).


Yes, you are correct: the check might cause some troubles in codebases, because 
it is not guaranteed that the functions from the C library headers will occur 
in the global namespace.

I was initially aware of that, but I thought it'd be better to add the initial 
check first and enhance it later. Appropriate FIXME seems great.

In http://reviews.llvm.org/D17484#358757, @LegalizeAdulthood wrote:

> It would be reasonable for this check to insert a `using namespace std;` at 
> the top of the translation unit after all the `#include` lines as a means of 
> preserving meaning without trying to identify every symbol that needs `std` 
> on it.


I'm not sure that's a good option. I would certainly argue about putting using 
namespaces like std anywhere during the vanilla check run. Simply because of 
the collisions caused by some libraries with the functions having analogies in 
STL.

However, I can see it as an option for the further variations of this check.

Say, let it have three options:

- Don't bother about namespaces: in case user already has `using namespace std` 
or doesn't care about implementation-dependend things. Seems like a reasonable 
scenario to me.
- Add `std::` prefix to all functions from these headers in the process of 
migration: generally it seems a bit better to me.
- Put `using namespace std;` somewhere (maybe even specify where: i.e. if user 
wants to put it right to the top of TU or in each source file where a C library 
is used. That's considerably good, too.

//just note for the future//
I also think there might be a good place in clang-tidy for an independent check 
responsible for namespace migrations. Say, user has been using only one library 
and now when he wants to add another one it would be good to put the 
appropriate namespace prefixes where appropriate.

Seems quite sophisticated ATM though.


http://reviews.llvm.org/D17484



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


r261548 - Add has_feature attribute_availability_with_strict.

2016-02-22 Thread Manman Ren via cfe-commits
Author: mren
Date: Mon Feb 22 12:24:30 2016
New Revision: 261548

URL: http://llvm.org/viewvc/llvm-project?rev=261548&view=rev
Log:
Add has_feature attribute_availability_with_strict.

rdar://23791325

Modified:
cfe/trunk/lib/Lex/PPMacroExpansion.cpp
cfe/trunk/test/Sema/attr-availability-macosx.c

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=261548&r1=261547&r2=261548&view=diff
==
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Feb 22 12:24:30 2016
@@ -1066,6 +1066,7 @@ static bool HasFeature(const Preprocesso
   .Case("attribute_availability_with_version_underscores", true)
   .Case("attribute_availability_tvos", true)
   .Case("attribute_availability_watchos", true)
+  .Case("attribute_availability_with_strict", true)
   .Case("attribute_cf_returns_not_retained", true)
   .Case("attribute_cf_returns_retained", true)
   .Case("attribute_cf_returns_on_parameters", true)

Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=261548&r1=261547&r2=261548&view=diff
==
--- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
+++ cfe/trunk/test/Sema/attr-availability-macosx.c Mon Feb 22 12:24:30 2016
@@ -1,5 +1,9 @@
 // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin9.0.0" -fsyntax-only -verify 
%s
 
+#if !__has_feature(attribute_availability_with_strict)
+#error "Missing __has_feature"
+#endif
+
 void f0(int) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.6)));
 void f1(int) __attribute__((availability(macosx,introduced=10.5)));
 void f2(int) 
__attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // 
expected-note {{'f2' has been explicitly marked deprecated here}}


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


Re: r261548 - Add has_feature attribute_availability_with_strict.

2016-02-22 Thread Aaron Ballman via cfe-commits
On Mon, Feb 22, 2016 at 1:24 PM, Manman Ren via cfe-commits
 wrote:
> Author: mren
> Date: Mon Feb 22 12:24:30 2016
> New Revision: 261548
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261548&view=rev
> Log:
> Add has_feature attribute_availability_with_strict.
>
> rdar://23791325

Please add more context to commit logs; radar reports in commit logs
don't help those of us who are not at Apple. Also, I don't recall
seeing this patch go through the review process, can you point me to
the thread?

>
> Modified:
> cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> cfe/trunk/test/Sema/attr-availability-macosx.c
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=261548&r1=261547&r2=261548&view=diff
> ==
> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Feb 22 12:24:30 2016
> @@ -1066,6 +1066,7 @@ static bool HasFeature(const Preprocesso
>.Case("attribute_availability_with_version_underscores", true)
>.Case("attribute_availability_tvos", true)
>.Case("attribute_availability_watchos", true)
> +  .Case("attribute_availability_with_strict", true)

I wonder if this would actually be better as an attribute feature
testing macro, instead of bolted on to __has_feature. It's strange to
have attribute feature testing capabilities and not use them. That
being said, I'm not opposed to this patch as-is because there are
other attribute_availability_* feature test.

Thanks!

~Aaron

>.Case("attribute_cf_returns_not_retained", true)
>.Case("attribute_cf_returns_retained", true)
>.Case("attribute_cf_returns_on_parameters", true)
>
> Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=261548&r1=261547&r2=261548&view=diff
> ==
> --- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
> +++ cfe/trunk/test/Sema/attr-availability-macosx.c Mon Feb 22 12:24:30 2016
> @@ -1,5 +1,9 @@
>  // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin9.0.0" -fsyntax-only 
> -verify %s
>
> +#if !__has_feature(attribute_availability_with_strict)
> +#error "Missing __has_feature"
> +#endif
> +
>  void f0(int) 
> __attribute__((availability(macosx,introduced=10.4,deprecated=10.6)));
>  void f1(int) __attribute__((availability(macosx,introduced=10.5)));
>  void f2(int) 
> __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // 
> expected-note {{'f2' has been explicitly marked deprecated here}}
>
>
> ___
> 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


Re: r261448 - Lex: Check buckets on header map construction

2016-02-22 Thread Adrian Prantl via cfe-commits

> On Feb 20, 2016, at 1:00 PM, Duncan P. N. Exon Smith via cfe-commits 
>  wrote:
> 
> Author: dexonsmith
> Date: Sat Feb 20 15:00:58 2016
> New Revision: 261448
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=261448&view=rev
> Log:
> Lex: Check buckets on header map construction
> 
> If the number of buckets is not a power of two, immediately recognize
> the header map as corrupt, rather than waiting for the first lookup.  I
> converted the later check to an assert.
> 
> Modified:
>cfe/trunk/lib/Lex/HeaderMap.cpp
>cfe/trunk/unittests/Lex/HeaderMapTest.cpp
> 
> Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=261448&r1=261447&r2=261448&view=diff
> ==
> --- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
> +++ cfe/trunk/lib/Lex/HeaderMap.cpp Sat Feb 20 15:00:58 2016
> @@ -19,6 +19,7 @@
> #include "llvm/Support/DataTypes.h"
> #include "llvm/Support/MathExtras.h"
> #include "llvm/Support/MemoryBuffer.h"
> +#include "llvm/Support/SwapByteOrder.h"
> #include 
> #include 
> using namespace clang;
> @@ -82,6 +83,15 @@ bool HeaderMapImpl::checkHeader(const ll
>   if (Header->Reserved != 0)
> return false;
> 
> +  // Check the number of buckets.
> +  auto NumBuckets = NeedsByteSwap
> +? llvm::sys::getSwappedBytes(Header->NumBuckets)
> +: Header->NumBuckets;
> +
> +  // If the number of buckets is not a power of two, the headermap is 
> corrupt.

Support/MathExtras.h defines isPowerOf2_32 which is IMHO more readable and also 
checks for 0 (which may or may not be what we want here).

-- adrian
> +  if (NumBuckets & (NumBuckets - 1))
> +return false;
> +
>   // Okay, everything looks good.
>   return true;
> }
> @@ -191,10 +201,8 @@ StringRef HeaderMapImpl::lookupFilename(
>   const HMapHeader &Hdr = getHeader();
>   unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
> 
> -  // If the number of buckets is not a power of two, the headermap is 
> corrupt.
> -  // Don't probe infinitely.
> -  if (NumBuckets & (NumBuckets-1))
> -return StringRef();
> +  // Don't probe infinitely.  This should be checked before constructing.
> +  assert(!(NumBuckets & (NumBuckets - 1)) && "Expected power of 2");
> 
>   // Linearly probe the hash table.
>   for (unsigned Bucket = HashHMapKey(Filename);; ++Bucket) {
> 
> Modified: cfe/trunk/unittests/Lex/HeaderMapTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderMapTest.cpp?rev=261448&r1=261447&r2=261448&view=diff
> ==
> --- cfe/trunk/unittests/Lex/HeaderMapTest.cpp (original)
> +++ cfe/trunk/unittests/Lex/HeaderMapTest.cpp Sat Feb 20 15:00:58 2016
> @@ -91,4 +91,13 @@ TEST(HeaderMapTest, checkHeaderValidButE
>   ASSERT_TRUE(NeedsSwap);
> }
> 
> +TEST(HeaderMapTest, checkHeader3Buckets) {
> +  MapFile<3, 1> File;
> +  ASSERT_EQ(3 * sizeof(HMapBucket), sizeof(File.Buckets));
> +
> +  File.init();
> +  bool NeedsSwap;
> +  ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
> +}
> +
> } // end namespace
> 
> 
> ___
> 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


r261551 - [VFS] Add support for handling path traversals

2016-02-22 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Feb 22 12:41:01 2016
New Revision: 261551

URL: http://llvm.org/viewvc/llvm-project?rev=261551&view=rev
Log:
[VFS] Add support for handling path traversals

Handle ".", ".." and "./" with trailing slashes while collecting files
to be dumped into the vfs overlay directory.

Include the support for symlinks into components. Given the path:

/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
component is a symlink, it's not safe to use `path::remove_dots` here,
and `realpath` is used to get the right answer. Since `realpath`
is expensive, we only do it at collecting time (which only happens
during the crash reproducer) and cache the base directory for fast lookups.

Overall, this makes the input to the VFS YAML file to be canonicalized
to never contain traversal components.

Differential Revision: http://reviews.llvm.org/D17104

rdar://problem/24499339

Added:
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=261551&r1=261550&r2=261551&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Feb 22 12:41:01 2016
@@ -111,6 +111,20 @@ bool FileSystem::exists(const Twine &Pat
   return Status && Status->exists();
 }
 
+#ifndef NDEBUG
+static bool isTraversalComponent(StringRef Component) {
+  return Component.equals("..") || Component.equals(".");
+}
+
+static bool pathHasTraversal(StringRef Path) {
+  using namespace llvm::sys;
+  for (StringRef Comp : llvm::make_range(path::begin(Path), path::end(Path)))
+if (isTraversalComponent(Comp))
+  return true;
+  return false;
+}
+#endif
+
 
//===---===/
 // RealFileSystem implementation
 
//===---===/
@@ -807,6 +821,9 @@ public:
 ///
 /// and inherit their attributes from the external contents.
 ///
+/// Virtual file paths and external files are expected to be canonicalized
+/// without "..", "." and "./" in their paths.
+///
 /// In both cases, the 'name' field may contain multiple path components (e.g.
 /// /path/to/file). However, any directory that contains more than one child
 /// must be uniquely represented by a directory entry.
@@ -1004,7 +1021,13 @@ class RedirectingFileSystemParser {
   if (Key == "name") {
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
-Name = Value;
+
+SmallString<256> Path(Value);
+// Guarantee that old YAML files containing paths with ".." and "." are
+// properly canonicalized before read into the VFS.
+Path = sys::path::remove_leading_dotslash(Path);
+sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+Name = Path.str();
   } else if (Key == "type") {
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
@@ -1048,7 +1071,12 @@ class RedirectingFileSystemParser {
 HasContents = true;
 if (!parseScalarString(I->getValue(), Value, Buffer))
   return nullptr;
-ExternalContentsPath = Value;
+SmallString<256> Path(Value);
+// Guarantee that old YAML files containing paths with ".." and "." are
+// properly canonicalized before read into the VFS.
+Path = sys::path::remove_leading_dotslash(Path);
+sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+ExternalContentsPath = Path.str();
   } else if (Key == "use-external-name") {
 bool Val;
 if (!parseScalarBool(I->getValue(), Val))
@@ -1238,6 +1266,12 @@ ErrorOr RedirectingFileSystem::
   if (std::error_code EC = makeAbsolute(Path))
 return EC;
 
+  // Canonicalize path by removing ".", "..", "./", etc components. This is
+  // a VFS request, do bot bother about symlinks in the path components
+  // but canonicalize in order to perform the correct entry search.
+  Path = sys::path::remove_leading_dotslash(Path);
+  sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
+
   if (Path.empty())
 return make_error_code(llvm::errc::invalid_argument);
 
@@ -1254,10 +1288,10 @@ ErrorOr RedirectingFileSystem::
 ErrorOr
 RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,
   sys::path::const_iterator End, Entry *From) {
-  if (Start->equals("."))
-++Start;
+  assert(!isTraversalComponent(*Start) &&
+ !isTraversalComponent(From->getName()) &&
+ "Paths should not contain traversal components");
 
-  // FIXME: handle ..
   if (CaseSensitive ? !Start->equals(Fr

r261552 - [VFS] Add 'overlay-relative' field to YAML files

2016-02-22 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Feb 22 12:41:09 2016
New Revision: 261552

URL: http://llvm.org/viewvc/llvm-project?rev=261552&view=rev
Log:
[VFS] Add 'overlay-relative' field to YAML files

The VFS overlay mapping between virtual paths and real paths is done through
the 'external-contents' entries in YAML files, which contains hardcoded paths
to the real files.

When a module compilation crashes, headers are dumped into .cache/vfs
directory and are mapped via the .cache/vfs/vfs.yaml. The script
generated for reproduction uses -ivfsoverlay pointing to file to gather the
mapping between virtual paths and files inside .cache/vfs. Currently, we
are only capable of reproducing such crashes in the same machine as they
happen, because of the hardcoded paths in 'external-contents'.

To be able to reproduce a crash in another machine, this patch introduces a new
option in the VFS yaml file called 'overlay-relative'. When it's equal to
'true' it means that the provided path to the YAML file through the
-ivfsoverlay option should also be used to prefix the final path for every
'external-contents'.

Example, given the invocation snippet "... -ivfsoverlay
.cache/vfs/vfs.yaml" and the following entry in the yaml file:

"overlay-relative": "true",
"roots": [
...
  "type": "directory",
  "name": "/usr/include",
  "contents": [
{
  "type": "file",
  "name": "stdio.h",
  "external-contents": "/usr/include/stdio.h"
},
...

Here, a file manager request for virtual "/usr/include/stdio.h", that will map
into real path "//.cache/vfs/usr/include/stdio.h.

This is a useful feature for debugging module crashes in machines other than
the one where the error happened.

Differential Revision: http://reviews.llvm.org/D17457

rdar://problem/24499339

Added:
cfe/trunk/test/Modules/crash-vfs-relative-overlay.m
  - copied, changed from r261551, 
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=261552&r1=261551&r2=261552&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Feb 22 12:41:09 2016
@@ -310,6 +310,7 @@ llvm::sys::fs::UniqueID getNextVirtualUn
 IntrusiveRefCntPtr
 getVFSFromYAML(std::unique_ptr Buffer,
llvm::SourceMgr::DiagHandlerTy DiagHandler,
+   StringRef YAMLFilePath,
void *DiagContext = nullptr,
IntrusiveRefCntPtr ExternalFS = 
getRealFileSystem());
 
@@ -323,6 +324,8 @@ struct YAMLVFSEntry {
 class YAMLVFSWriter {
   std::vector Mappings;
   Optional IsCaseSensitive;
+  Optional IsOverlayRelative;
+  std::string OverlayDir;
 
 public:
   YAMLVFSWriter() {}
@@ -330,6 +333,11 @@ public:
   void setCaseSensitivity(bool CaseSensitive) {
 IsCaseSensitive = CaseSensitive;
   }
+  void setOverlayDir(StringRef OverlayDirectory) {
+IsOverlayRelative = true;
+OverlayDir.assign(OverlayDirectory.str());
+  }
+
   void write(llvm::raw_ostream &OS);
 };
 

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=261552&r1=261551&r2=261552&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Feb 22 12:41:09 2016
@@ -790,6 +790,7 @@ public:
 /// All configuration options are optional.
 ///   'case-sensitive': 
 ///   'use-external-names': 
+///   'overlay-relative': 
 ///
 /// Virtual directories are represented as
 /// \verbatim
@@ -832,6 +833,10 @@ class RedirectingFileSystem : public vfs
   std::vector> Roots;
   /// \brief The file system to use for external references.
   IntrusiveRefCntPtr ExternalFS;
+  /// If IsRelativeOverlay is set, this represents the directory
+  /// path that should be prefixed to each 'external-contents' entry
+  /// when reading from YAML files.
+  std::string ExternalContentsPrefixDir;
 
   /// @name Configuration
   /// @{
@@ -841,6 +846,10 @@ class RedirectingFileSystem : public vfs
   /// Currently, case-insensitive matching only works correctly with ASCII.
   bool CaseSensitive;
 
+  /// IsRelativeOverlay marks whether a IsExternalContentsPrefixDir path must
+  /// be prefixed in every 'external-contents' when reading from YAML files.
+  bool IsRelativeOverlay = false;
+
   /// \brief Whether to use to use the value of 'external-contents' for the
   ///

Re: r261422 - Fix handling of vaargs on PPC32 when going from regsave to overflow.

2016-02-22 Thread Hans Wennborg via cfe-commits
On Sat, Feb 20, 2016 at 6:29 AM, Hal Finkel  wrote:
>
>
> - Original Message -
>> From: "Dimitry Andric via cfe-commits" 
>> To: "Hans Wennborg" 
>> Cc: "Roman Divacky" , "cfe-commits" 
>> 
>> Sent: Saturday, February 20, 2016 8:24:36 AM
>> Subject: Re: r261422 - Fix handling of vaargs on PPC32 when going from 
>> regsave to overflow.
>>
>> On 20 Feb 2016, at 09:31, Roman Divacky via cfe-commits
>>  wrote:
>> >
>> > Author: rdivacky
>> > Date: Sat Feb 20 02:31:24 2016
>> > New Revision: 261422
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=261422&view=rev
>> > Log:
>> > Fix handling of vaargs on PPC32 when going from regsave to
>> > overflow.
>> >
>> > It can happen that when we only have 1 more register left in the
>> > regsave
>> > area we need to store a value bigger than 1 register and therefore
>> > we
>> > go to the overflow area. In this case we have to leave the last
>> > slot
>> > in the regsave area unused and keep using overflow area. Do this
>> > by storing a limit value to the used register counter in the
>> > overflow block.
>> >
>> > Issue diagnosed by and solution tested by Mark Millard!
>>
>> Hans, this looks like a nice minor fix to have in 3.8.0.  Can we
>> merge it, please?
>
> Fine by me.

r261553.

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


Re: r261548 - Add has_feature attribute_availability_with_strict.

2016-02-22 Thread Manman Ren via cfe-commits

> On Feb 22, 2016, at 10:37 AM, Aaron Ballman via cfe-commits 
>  wrote:
> 
> On Mon, Feb 22, 2016 at 1:24 PM, Manman Ren via cfe-commits
> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: mren
>> Date: Mon Feb 22 12:24:30 2016
>> New Revision: 261548
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=261548&view=rev 
>> 
>> Log:
>> Add has_feature attribute_availability_with_strict.
>> 
>> rdar://23791325 
> 
> Please add more context to commit logs; radar reports in commit logs
> don't help those of us who are not at Apple. Also, I don't recall
> seeing this patch go through the review process, can you point me to
> the thread?

This is a follow-up to r261163 and r261512. The strict qualifier was added in 
these two revisions.
Sorry for not putting in the context in the commit message,

Manman

> 
>> 
>> Modified:
>>cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>>cfe/trunk/test/Sema/attr-availability-macosx.c
>> 
>> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=261548&r1=261547&r2=261548&view=diff
>> ==
>> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
>> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Feb 22 12:24:30 2016
>> @@ -1066,6 +1066,7 @@ static bool HasFeature(const Preprocesso
>>   .Case("attribute_availability_with_version_underscores", true)
>>   .Case("attribute_availability_tvos", true)
>>   .Case("attribute_availability_watchos", true)
>> +  .Case("attribute_availability_with_strict", true)
> 
> I wonder if this would actually be better as an attribute feature
> testing macro, instead of bolted on to __has_feature. It's strange to
> have attribute feature testing capabilities and not use them. That
> being said, I'm not opposed to this patch as-is because there are
> other attribute_availability_* feature test.
> 
> Thanks!
> 
> ~Aaron
> 
>>   .Case("attribute_cf_returns_not_retained", true)
>>   .Case("attribute_cf_returns_retained", true)
>>   .Case("attribute_cf_returns_on_parameters", true)
>> 
>> Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=261548&r1=261547&r2=261548&view=diff
>> ==
>> --- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
>> +++ cfe/trunk/test/Sema/attr-availability-macosx.c Mon Feb 22 12:24:30 2016
>> @@ -1,5 +1,9 @@
>> // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin9.0.0" -fsyntax-only 
>> -verify %s
>> 
>> +#if !__has_feature(attribute_availability_with_strict)
>> +#error "Missing __has_feature"
>> +#endif
>> +
>> void f0(int) 
>> __attribute__((availability(macosx,introduced=10.4,deprecated=10.6)));
>> void f1(int) __attribute__((availability(macosx,introduced=10.5)));
>> void f2(int) 
>> __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // 
>> expected-note {{'f2' has been explicitly marked deprecated here}}
>> 
>> 
>> ___
>> 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 
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261556 - [VFS] Fix call to getVFSFromYAML in unittests

2016-02-22 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Feb 22 13:02:27 2016
New Revision: 261556

URL: http://llvm.org/viewvc/llvm-project?rev=261556&view=rev
Log:
[VFS] Fix call to getVFSFromYAML in unittests

Follow up from r261552

Modified:
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=261556&r1=261555&r2=261556&view=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Mon Feb 22 13:02:27 2016
@@ -662,7 +662,7 @@ public:
   getFromYAMLRawString(StringRef Content,
IntrusiveRefCntPtr ExternalFS) {
 std::unique_ptr Buffer = MemoryBuffer::getMemBuffer(Content);
-return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, this,
+return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, "", this,
   ExternalFS);
   }
 


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


Re: r261548 - Add has_feature attribute_availability_with_strict.

2016-02-22 Thread Aaron Ballman via cfe-commits
On Mon, Feb 22, 2016 at 1:57 PM, Manman Ren  wrote:
>
> On Feb 22, 2016, at 10:37 AM, Aaron Ballman via cfe-commits
>  wrote:
>
> On Mon, Feb 22, 2016 at 1:24 PM, Manman Ren via cfe-commits
>  wrote:
>
> Author: mren
> Date: Mon Feb 22 12:24:30 2016
> New Revision: 261548
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261548&view=rev
> Log:
> Add has_feature attribute_availability_with_strict.
>
> rdar://23791325
>
>
> Please add more context to commit logs; radar reports in commit logs
> don't help those of us who are not at Apple. Also, I don't recall
> seeing this patch go through the review process, can you point me to
> the thread?
>
>
> This is a follow-up to r261163 and r261512. The strict qualifier was added
> in these two revisions.
> Sorry for not putting in the context in the commit message,

Thank you for the context. Since this is a user-facing change, it
probably should have had a separate review so we could discuss things
like __has_feature vs __has_attribute before the commit goes live.
That being said: patch LGTM. :-)

~Aaron

>
> Manman
>
>
>
> Modified:
>cfe/trunk/lib/Lex/PPMacroExpansion.cpp
>cfe/trunk/test/Sema/attr-availability-macosx.c
>
> Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=261548&r1=261547&r2=261548&view=diff
> ==
> --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
> +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Mon Feb 22 12:24:30 2016
> @@ -1066,6 +1066,7 @@ static bool HasFeature(const Preprocesso
>   .Case("attribute_availability_with_version_underscores", true)
>   .Case("attribute_availability_tvos", true)
>   .Case("attribute_availability_watchos", true)
> +  .Case("attribute_availability_with_strict", true)
>
>
> I wonder if this would actually be better as an attribute feature
> testing macro, instead of bolted on to __has_feature. It's strange to
> have attribute feature testing capabilities and not use them. That
> being said, I'm not opposed to this patch as-is because there are
> other attribute_availability_* feature test.
>
> Thanks!
>
> ~Aaron
>
>   .Case("attribute_cf_returns_not_retained", true)
>   .Case("attribute_cf_returns_retained", true)
>   .Case("attribute_cf_returns_on_parameters", true)
>
> Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=261548&r1=261547&r2=261548&view=diff
> ==
> --- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
> +++ cfe/trunk/test/Sema/attr-availability-macosx.c Mon Feb 22 12:24:30 2016
> @@ -1,5 +1,9 @@
> // RUN: %clang_cc1 "-triple" "x86_64-apple-darwin9.0.0" -fsyntax-only
> -verify %s
>
> +#if !__has_feature(attribute_availability_with_strict)
> +#error "Missing __has_feature"
> +#endif
> +
> void f0(int)
> __attribute__((availability(macosx,introduced=10.4,deprecated=10.6)));
> void f1(int) __attribute__((availability(macosx,introduced=10.5)));
> void f2(int)
> __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); //
> expected-note {{'f2' has been explicitly marked deprecated here}}
>
>
> ___
> 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
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-22 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 48711.
omtcyf0 marked 9 inline comments as done.
omtcyf0 added a comment.

Fixed all the issues @alexfh pointed to.


http://reviews.llvm.org/D17484

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-deprecated-headers.rst
  test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
@@ -0,0 +1,163 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+// CHECK-MESSAGES: :[[@LINE-27]]:10: warning: including deprecated C++ header [modernize-deprecated-headers]
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+// CHECK-FIXES: #include 
+
+#include "assert.h"
+#include "complex.h"
+#include "ctype.h"
+#include "errno.h"
+#include "fenv.h"
+#include "float.h"
+#include "inttypes.h"
+#include "iso646.h"
+#include "limits.h"
+#include "locale.h"
+#include "math.h"
+#in

Re: [PATCH] D17104: [VFS] Drop path traversal assertion

2016-02-22 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Committed r261551


http://reviews.llvm.org/D17104



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


Re: [PATCH] D17457: [VFS] Add 'overlay-relative' field to YAML files

2016-02-22 Thread Bruno Cardoso Lopes via cfe-commits
bruno closed this revision.
bruno added a comment.

Committed r261552 / r261556


http://reviews.llvm.org/D17457



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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-22 Thread Kirill Bobyrev via cfe-commits
omtcyf0 added a comment.

Marked the comments as *done*.



Comment at: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 
-isystem %S/Inputs/Headers
+

alexfh wrote:
> You seem to have forgotten to add these headers to `Inputs/Headers`. Or 
> doesn't the check care about them actually being present?
Correct. It doesn't care about them being present.


http://reviews.llvm.org/D17484



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


r261557 - [WebAssembly] Lower va_arg in clang.

2016-02-22 Thread Dan Gohman via cfe-commits
Author: djg
Date: Mon Feb 22 13:17:40 2016
New Revision: 261557

URL: http://llvm.org/viewvc/llvm-project?rev=261557&view=rev
Log:
[WebAssembly] Lower va_arg in clang.

This uses the general emitVoidPtrVAArg lowering logic for everything, since
this supports all types, and we don't have any special requirements.

Added:
cfe/trunk/test/CodeGen/wasm-varargs.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=261557&r1=261556&r2=261557&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Feb 22 13:17:40 2016
@@ -616,6 +616,9 @@ private:
 for (auto &Arg : FI.arguments())
   Arg.info = classifyArgumentType(Arg.type);
   }
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const override;
 };
 
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
@@ -667,6 +670,14 @@ ABIArgInfo WebAssemblyABIInfo::classifyR
   return DefaultABIInfo::classifyReturnType(RetTy);
 }
 
+Address WebAssemblyABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+  QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*Indirect=*/ false,
+  getContext().getTypeInfoInChars(Ty),
+  CharUnits::fromQuantity(4),
+  /*AllowHigherAlign=*/ true);
+}
+
 
//===--===//
 // le32/PNaCl bitcode ABI Implementation
 //

Added: cfe/trunk/test/CodeGen/wasm-varargs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/wasm-varargs.c?rev=261557&view=auto
==
--- cfe/trunk/test/CodeGen/wasm-varargs.c (added)
+++ cfe/trunk/test/CodeGen/wasm-varargs.c Mon Feb 22 13:17:40 2016
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | 
FileCheck %s
+
+#include 
+
+int test_i32(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  int v = va_arg(va, int);
+  va_end(va);
+
+  return v;
+}
+
+// CHECK-LABEL: define i32 @test_i32(i8*{{.*}} %fmt, ...) {{.*}} {
+// CHECK:   [[FMT_ADDR:%[^,=]+]] = alloca i8*, align 4
+// CHECK:   [[VA:%[^,=]+]] = alloca i8*, align 4
+// CHECK:   [[V:%[^,=]+]] = alloca i32, align 4
+// CHECK:   store i8* %fmt, i8** [[FMT_ADDR]], align 4
+// CHECK:   [[VA1:%[^,=]+]] = bitcast i8** [[VA]] to i8*
+// CHECK:   call void @llvm.va_start(i8* [[VA1]])
+// CHECK:   [[ARGP_CUR:%[^,=]+]] = load i8*, i8** [[VA]], align 4
+// CHECK:   [[ARGP_NEXT:%[^,=]+]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR]], i32 4
+// CHECK:   store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
+// CHECK:   [[R3:%[^,=]+]] = bitcast i8* [[ARGP_CUR]] to i32*
+// CHECK:   [[R4:%[^,=]+]] = load i32, i32* [[R3]], align 4
+// CHECK:   store i32 [[R4]], i32* [[V]], align 4
+// CHECK:   [[VA2:%[^,=]+]] = bitcast i8** [[VA]] to i8*
+// CHECK:   call void @llvm.va_end(i8* [[VA2]])
+// CHECK:   [[R5:%[^,=]+]] = load i32, i32* [[V]], align 4
+// CHECK:   ret i32 [[R5]]
+// CHECK: }
+
+long long test_i64(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  long long v = va_arg(va, long long);
+  va_end(va);
+
+  return v;
+}
+
+// CHECK-LABEL: define i64 @test_i64(i8*{{.*}} %fmt, ...) {{.*}} {
+// CHECK:   [[FMT_ADDR:%[^,=]+]] = alloca i8*, align 4
+// CHECK:   [[VA:%[^,=]+]] = alloca i8*, align 4
+// CHECK:   [[V:%[^,=]+]] = alloca i64, align 8
+// CHECK:   store i8* %fmt, i8** [[FMT_ADDR]], align 4
+// CHECK:   [[VA1:%[^,=]+]] = bitcast i8** [[VA]] to i8*
+// CHECK:   call void @llvm.va_start(i8* [[VA1]])
+// CHECK:   [[ARGP_CUR:%[^,=]+]] = load i8*, i8** [[VA]], align 4
+// CHECK:   [[R0:%[^,=]+]] = ptrtoint i8* [[ARGP_CUR]] to i32
+// CHECK:   [[R1:%[^,=]+]] = add i32 [[R0]], 7
+// CHECK:   [[R2:%[^,=]+]] = and i32 [[R1]], -8
+// CHECK:   [[ARGP_CUR_ALIGNED:%[^,=]+]] = inttoptr i32 [[R2]] to i8*
+// CHECK:   [[ARGP_NEXT:%[^,=]+]] = getelementptr inbounds i8, i8* 
[[ARGP_CUR_ALIGNED]], i32 8
+// CHECK:   store i8* [[ARGP_NEXT]], i8** [[VA]], align 4
+// CHECK:   [[R3:%[^,=]+]] = bitcast i8* [[ARGP_CUR_ALIGNED]] to i64*
+// CHECK:   [[R4:%[^,=]+]] = load i64, i64* [[R3]], align 8
+// CHECK:   store i64 [[R4]], i64* [[V]], align 8
+// CHECK:   [[VA2:%[^,=]+]] = bitcast i8** [[VA]] to i8*
+// CHECK:   call void @llvm.va_end(i8* [[VA2]])
+// CHECK:   [[R5:%[^,=]+]] = load i64, i64* [[V]], align 8
+// CHECK:   ret i64 [[R5]]
+// CHECK: }
+
+struct S {
+int x;
+int y;
+int z;
+};
+
+struct S test_struct(char *fmt, ...) {
+  va_list va;
+
+  va_start(va, fmt);
+  struct S v = va_arg(va, struct S);
+  va_end(va);
+
+  return v;
+}
+
+// CHECK: define void @test_struct([[STRUCT_S:%[^,=]+]]*{{.*}} noalias sret 
%agg.result

r261560 - [WebAssembly] Initial driver support for standard library paths.

2016-02-22 Thread Dan Gohman via cfe-commits
Author: djg
Date: Mon Feb 22 13:26:15 2016
New Revision: 261560

URL: http://llvm.org/viewvc/llvm-project?rev=261560&view=rev
Log:
[WebAssembly] Initial driver support for standard library paths.

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/wasm-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=261560&r1=261559&r2=261560&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Feb 22 13:26:15 2016
@@ -4468,6 +4468,11 @@ Tool *MyriadToolChain::buildLinker() con
 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
  const llvm::opt::ArgList &Args)
   : ToolChain(D, Triple, Args) {
+
+  assert(Triple.isArch32Bit() != Triple.isArch64Bit());
+  getFilePaths().push_back(
+  getDriver().SysRoot + "/lib" + (Triple.isArch32Bit() ? "32" : "64"));
+
   // Use LLD by default.
   DefaultLinker = "lld";
 }

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261560&r1=261559&r2=261560&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Feb 22 13:26:15 2016
@@ -6613,7 +6613,10 @@ void wasm::Linker::ConstructJob(Compilat
 const InputInfoList &Inputs,
 const ArgList &Args,
 const char *LinkingOutput) const {
-  const char *Linker = Args.MakeArgString(getToolChain().GetLinkerPath());
+
+  const ToolChain &ToolChain = getToolChain();
+  const Driver &D = ToolChain.getDriver();
+  const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
   ArgStringList CmdArgs;
   CmdArgs.push_back("-flavor");
   CmdArgs.push_back("ld");
@@ -6625,9 +6628,48 @@ void wasm::Linker::ConstructJob(Compilat
   if (areOptimizationsEnabled(Args))
 CmdArgs.push_back("--gc-sections");
 
-  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+  if (Args.hasArg(options::OPT_rdynamic))
+CmdArgs.push_back("-export-dynamic");
+  if (Args.hasArg(options::OPT_s))
+CmdArgs.push_back("--strip-all");
+  if (Args.hasArg(options::OPT_shared))
+CmdArgs.push_back("-shared");
+  if (Args.hasArg(options::OPT_static))
+CmdArgs.push_back("-Bstatic");
+
+  Args.AddAllArgs(CmdArgs, options::OPT_L);
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+if (Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("rcrt1.o")));
+else if (Args.hasArg(options::OPT_pie))
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
+else
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt1.o")));
+
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
+  }
+
+  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);
+
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+if (D.CCCIsCXX())
+  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (Args.hasArg(options::OPT_pthread))
+  CmdArgs.push_back("-lpthread");
+
+CmdArgs.push_back("-lc");
+CmdArgs.push_back("-lcompiler_rt");
+  }
+
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
+
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
+
   C.addCommand(llvm::make_unique(JA, *this, Linker, CmdArgs, Inputs));
 }
 

Modified: cfe/trunk/test/Driver/wasm-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/wasm-toolchain.c?rev=261560&r1=261559&r2=261560&view=diff
==
--- cfe/trunk/test/Driver/wasm-toolchain.c (original)
+++ cfe/trunk/test/Driver/wasm-toolchain.c Mon Feb 22 13:26:15 2016
@@ -25,20 +25,20 @@
 
 // A basic C link command-line.
 
-// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown %s 
2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown 
--sysroot=/foo %s 2>&1 | FileCheck -check-prefix=LINK %s
 // LINK: clang{{.*}}" "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
-// LINK: lld{{.*}}" "-flavor" "ld" "[[temp]]" "-o" "a.out"
+// LINK: lld{{.*}}" "-flavor" "ld" "-L/foo/lib32" "crt1.o" "crti.o" "[[temp]]" 
"-lc" "-lcompiler_rt" "crtn.o" "-o" "a.out"
 
 // A basic C link command-line with optimization. WebAssembly is somewhat
 // special in enabling --gc-sections by default.
 
-// RUN: %clang -### -O2 -no-canonical-prefixes -target wasm32-unknown-unknown 
%s 2>&1 | FileCheck -check-pr

Re: [PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

2016-02-22 Thread Rong Xu via cfe-commits
xur marked an inline comment as done.
xur added a comment.

I'll send a revised patch soon.



Comment at: lib/CodeGen/CodeGenModule.cpp:150
@@ -149,2 +149,3 @@
 
-  if (!CodeGenOpts.InstrProfileInput.empty()) {
+  if (!CodeGenOpts.hasProfileIRInstr() &&
+  !CodeGenOpts.InstrProfileInput.empty()) {

davidxl wrote:
> Better to use if (CodeGenOpts.hasProfileClangInstr() && ..)
OK. That would require to insert an extra cc1 option of 
-profile-instrument=clang for profile-use. And possibly some test case option 
changes too.


Comment at: lib/Driver/Tools.cpp:3201
@@ +3200,3 @@
+// Set the profile kind if it's not the default clang kind.
+static void setProfileKindFlag(ArgStringList &CmdArgs,
+   std::string ProfileName) {

davidxl wrote:
> I don't quite like this change in the driver. I think the right thing to do 
> is:
> 
> 1) for profile use case, there is no need to pass -fprofile-instrument=<...> 
> FE option from the driver
> 2) The profileInstrKind determination needs to happen in FE (not driver) by 
> peeking into the passed in profile data.
I'll split off the profile kind detection to a separated patch suggested by 
Sean.


Comment at: test/CodeGen/pgo-instrumentation.c:4
@@ +3,3 @@
+// Ensure Pass PGOInstrumentationGenPass is invoked.
+// RUN: %clang -O2 -c -Xclang -fprofile-instrument=llvm 
-fprofile-instr-generate %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s 
-check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN
+// CHECK-PGOGENPASS-INVOKED-INSTR-GEN: PGOInstrumentationGenPass

silvas wrote:
> Use `%clang_cc1` here and elsewhere.
Will do.


http://reviews.llvm.org/D15829



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


[PATCH] D17519: AMDGPU: Fix broken/confusing predefined macro

2016-02-22 Thread Matt Arsenault via cfe-commits
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: cfe-commits.

amdgcn should not be defining __R600__

http://reviews.llvm.org/D17519

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1824,3 +1824,17 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZVECTOR
 //
 // CHECK_SYSTEMZ_ZVECTOR: #define __VEC__ 10301
+
+// Begin amdgcn tests 
+//
+// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
+// RUN: -target amdgcn-unknown-unknown \
+// RUN:   | FileCheck %s -check-prefix=CHECK_AMDGCN
+// CHECK_AMDGCN: #define __AMDGCN__ 1
+
+// Begin r600 tests 
+//
+// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
+// RUN: -target r600-unknown-unknown \
+// RUN:   | FileCheck %s -check-prefix=CHECK_R600
+// CHECK_R600: #define __R600__ 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1878,7 +1878,11 @@
 
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
-Builder.defineMacro("__R600__");
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  Builder.defineMacro("__AMDGCN__");
+else
+  Builder.defineMacro("__R600__");
+
 if (hasFMAF)
   Builder.defineMacro("__HAS_FMAF__");
 if (hasLDEXPF)


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1824,3 +1824,17 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZVECTOR
 //
 // CHECK_SYSTEMZ_ZVECTOR: #define __VEC__ 10301
+
+// Begin amdgcn tests 
+//
+// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
+// RUN: -target amdgcn-unknown-unknown \
+// RUN:   | FileCheck %s -check-prefix=CHECK_AMDGCN
+// CHECK_AMDGCN: #define __AMDGCN__ 1
+
+// Begin r600 tests 
+//
+// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
+// RUN: -target r600-unknown-unknown \
+// RUN:   | FileCheck %s -check-prefix=CHECK_R600
+// CHECK_R600: #define __R600__ 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1878,7 +1878,11 @@
 
   void getTargetDefines(const LangOptions &Opts,
 MacroBuilder &Builder) const override {
-Builder.defineMacro("__R600__");
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  Builder.defineMacro("__AMDGCN__");
+else
+  Builder.defineMacro("__R600__");
+
 if (hasFMAF)
   Builder.defineMacro("__HAS_FMAF__");
 if (hasLDEXPF)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261563 - clang-format: [JS] Add @return to the supported JSDoc pragmas in Google

2016-02-22 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Feb 22 14:24:11 2016
New Revision: 261563

URL: http://llvm.org/viewvc/llvm-project?rev=261563&view=rev
Log:
clang-format: [JS] Add @return to the supported JSDoc pragmas in Google
style.

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=261563&r1=261562&r2=261563&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Feb 22 14:24:11 2016
@@ -587,7 +587,7 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
-GoogleStyle.CommentPragmas = "@(export|see|visibility) ";
+GoogleStyle.CommentPragmas = "@(export|return|see|visibility) ";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.SpacesInContainerLiterals = false;
   } else if (Language == FormatStyle::LK_Proto) {


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


[PATCH] D17520: AMDGPU: Fix inconsistent register name for flat_scratch

2016-02-22 Thread Matt Arsenault via cfe-commits
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: cfe-commits.

http://reviews.llvm.org/D17520

Files:
  lib/Basic/Targets.cpp
  test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl

Index: test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-LABEL: @use_flat_scratch_name
+kernel void use_flat_scratch_name()
+{
+// CHECK: tail call void asm sideeffect "s_mov_b64 flat_scratch, 0", 
"~{flat_scratch}"()
+  __asm__ volatile("s_mov_b64 flat_scratch, 0" : : : "flat_scratch");
+
+// CHECK: tail call void asm sideeffect "s_mov_b32 flat_scratch_lo, 0", 
"~{flat_scratch_lo}"()
+  __asm__ volatile("s_mov_b32 flat_scratch_lo, 0" : : : "flat_scratch_lo");
+
+// CHECK: tail call void asm sideeffect "s_mov_b32 flat_scratch_hi, 0", 
"~{flat_scratch_hi}"()
+  __asm__ volatile("s_mov_b32 flat_scratch_hi, 0" : : : "flat_scratch_hi");
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2047,8 +2047,8 @@
   "s104", "s105", "s106", "s107", "s108", "s109", "s110", "s111",
   "s112", "s113", "s114", "s115", "s116", "s117", "s118", "s119",
   "s120", "s121", "s122", "s123", "s124", "s125", "s126", "s127"
-  "exec", "vcc", "scc", "m0", "flat_scr", "exec_lo", "exec_hi",
-  "vcc_lo", "vcc_hi", "flat_scr_lo", "flat_scr_hi"
+  "exec", "vcc", "scc", "m0", "flat_scratch", "exec_lo", "exec_hi",
+  "vcc_lo", "vcc_hi", "flat_scratch_lo", "flat_scratch_hi"
 };
 
 ArrayRef AMDGPUTargetInfo::getGCCRegNames() const {


Index: test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @use_flat_scratch_name
+kernel void use_flat_scratch_name()
+{
+// CHECK: tail call void asm sideeffect "s_mov_b64 flat_scratch, 0", "~{flat_scratch}"()
+  __asm__ volatile("s_mov_b64 flat_scratch, 0" : : : "flat_scratch");
+
+// CHECK: tail call void asm sideeffect "s_mov_b32 flat_scratch_lo, 0", "~{flat_scratch_lo}"()
+  __asm__ volatile("s_mov_b32 flat_scratch_lo, 0" : : : "flat_scratch_lo");
+
+// CHECK: tail call void asm sideeffect "s_mov_b32 flat_scratch_hi, 0", "~{flat_scratch_hi}"()
+  __asm__ volatile("s_mov_b32 flat_scratch_hi, 0" : : : "flat_scratch_hi");
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2047,8 +2047,8 @@
   "s104", "s105", "s106", "s107", "s108", "s109", "s110", "s111",
   "s112", "s113", "s114", "s115", "s116", "s117", "s118", "s119",
   "s120", "s121", "s122", "s123", "s124", "s125", "s126", "s127"
-  "exec", "vcc", "scc", "m0", "flat_scr", "exec_lo", "exec_hi",
-  "vcc_lo", "vcc_hi", "flat_scr_lo", "flat_scr_hi"
+  "exec", "vcc", "scc", "m0", "flat_scratch", "exec_lo", "exec_hi",
+  "vcc_lo", "vcc_hi", "flat_scratch_lo", "flat_scratch_hi"
 };
 
 ArrayRef AMDGPUTargetInfo::getGCCRegNames() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [modules] PR24954

2016-02-22 Thread Vassil Vassilev via cfe-commits

On 02/02/16 02:52, Richard Smith via cfe-commits wrote:

On Thu, Jan 28, 2016 at 8:23 AM, Vassil Vassilev  wrote:

Would this patch be more reasonable? It follows what
RegisterTemplateSpecialization (introduced in r245779) does. AFAICT this
adds an update record far less often.

It's still adding redundant update records. We'll write the
appropriate update record as part of serializing the declaration
itself, so we only need to ensure that the declaration is emitted, not
actually emit an update record for it. Perhaps you could store a list
of such declarations on the ASTWriter, and call GetDeclRef on each of
them once we start emitting the AST file (or maybe just push them into
UpdatingVisibleDecls). Please also restrict this to the template
friend corner case.
The attached patch fixes the issues more or less in the direction you 
suggest. I am not sure if I expressed well enough the conditions of the 
template friend corner case. Could you have a look?



--Vassil

On 12/12/15 16:13, Vassil Vassilev wrote:

I couldn't find GetDecl routine in the ASTWriter. Could you elaborate?

Assuming you meant ASTWriter::GetDeclRef(D): It seems that the conditions
when calling GetDeclRef differ from the conditions of
AddedCXXTemplateSpecialization. Eg:

ASTWriter::AddedCXXTemplateSpecialization {
   assert(!WritingAST && "Already writing the AST!");
   ...
}
ASTWriter::GetDeclRef {
   assert(WritingAST && "Cannot request a declaration ID before AST
writing");
   ..
}

IIUC this particular instantiation happens *after* module B was built, thus
it needs to be retrospectively added to the serialized namespace. It looks
like even avoiding somehow the asserts of GetDeclRef it wouldn't help much.

Alternatively I could try to reduce the redundant update records by
narrowing down to instantiations coming in the context of friends.

--Vassil

On 12/12/15 01:07, Richard Smith wrote:

Instead of adding an update record directly in this case (which will emit
far more update records than necessary), how about just calling GetDecl(D)
from AddedCXXTemplateSpecialization to ensure that it gets emitted?

On Fri, Dec 4, 2015 at 7:46 AM, Vassil Vassilev  wrote:

Hi,
   Could you review my fix please.
Many thanks,
Vassil

On 08/10/15 15:53, Vassil Vassilev wrote:

Hi Richard,
   I started working on https://llvm.org/bugs/show_bug.cgi?id=24954

   IIUC r228485 introduces an abstraction to deal with
not-really-anonymous friend decls
(serialization::needsAnonymousDeclarationNumber in ASTCommon.cpp).

   A comment explicitly says:
   "// This doesn't apply to friend tag decls; Sema makes those available
to name
// lookup in the surrounding context."

   In the bug reproducer, the friend function (wrt __iom_t10) is forward
declared in the same namespace, where Sema makes the friend available for a
name lookup.

   It seems that the friend operator<< in __iom_t10 (sorry about the names
they come from libcxx) doesn't get registered in the ASTWriter's DeclIDs but
it gets registered in outer namespace's lookup table. Thus, assert is
triggered when finalizing module A, since it rebuilds the lookups of the
updated contexts.

   The issue only appears when building module A deserializes/uses module
B.

   Currently I was assume that something wrong happens in either
needsAnonymousDeclarationNumber or I hit a predicted issue
ASTWriterDecl.cpp:1602
 // FIXME: This is not correct; when we reach an imported declaration
we
 // won't emit its previous declaration.
 (void)Writer.GetDeclRef(D->getPreviousDecl());
 (void)Writer.GetDeclRef(MostRecent);

   The issue seems a fairly complex one and I am a bit stuck.

   Any hints are very very welcome ;)
Many thanks,
Vassil







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


From 4efa41e3cba19d3dc2ac76c60a135a01fbd13380 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Sun, 27 Sep 2015 21:12:39 +0200
Subject: [PATCH] [modules] Fix adding a templated friend functions to a
 namespace from another module.

When clang adds argument dependent lookup candidates, it can perform template
instantiations. For example, it can instantiate a templated friend function and
register it in the enclosing namespace's lookup table.

Fixes https://llvm.org/bugs/show_bug.cgi?id=24954
---
 lib/Serialization/ASTWriter.cpp  |  7 +--
 test/Modules/Inputs/PR24954/A.h  | 10 ++
 test/Modules/Inputs/PR24954/B.h  | 30 
 test/Modules/Inputs/PR24954/module.modulemap |  9 +
 test/Modules/pr24954.cpp |  7 +++
 5 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 test/Modules/Inputs/PR24954/A.h
 create mode 100644 test/Modules/Inputs/PR24954/B.h
 create mode 100644 test/Modules/Inputs/PR24954/module.modulemap
 create mode 100644 test/Modules/pr24954.cpp

diff --git a/lib/Serialization/

Re: [PATCH] D16993: Add documentation for bitreverse builtins

2016-02-22 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

ping


http://reviews.llvm.org/D16993



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


Re: [PATCH] D17516: AMDGPU: Verify subtarget specific builtins

2016-02-22 Thread Eric Christopher via cfe-commits
echristo added inline comments.


Comment at: lib/Basic/Targets.cpp:1829
@@ -1820,2 +1828,3 @@
 }
+
 AddrSpaceMap = &AMDGPUAddrSpaceMap;

Extra whitespace.


Comment at: lib/Basic/Targets.cpp:2059-2063
@@ +2058,7 @@
+
+  if (Has16BitInsts)
+Features["16-bit-insts"] = true;
+
+  if (hasSMemRealTime)
+Features["s-memrealtime"] = true;
+

This is typically more of the "move the cpu checks down here" area from what 
you'd have above. Also you're not calling the target independent version of 
initFeatureMap - is that done on purpose?


http://reviews.llvm.org/D17516



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


Re: [PATCH] D17163: [ASTMatchers] Add matcher hasAnyName.

2016-02-22 Thread Samuel Benzaquen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL261574: [ASTMatchers] Add matcher hasAnyName. (authored by 
sbenza).

Changed prior to commit:
  http://reviews.llvm.org/D17163?vs=47802&id=48720#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17163

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/docs/tools/dump_ast_matchers.py
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
  cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Index: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -14,6 +14,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ManagedStatic.h"
 
 namespace clang {
@@ -293,15 +294,26 @@
   return false;
 }
 
-HasNameMatcher::HasNameMatcher(std::string NameRef)
-: UseUnqualifiedMatch(NameRef.find("::") == NameRef.npos),
-  Name(std::move(NameRef)) {
-  assert(!Name.empty());
+Matcher hasAnyNameFunc(ArrayRef NameRefs) {
+  std::vector Names;
+  for (auto *Name : NameRefs)
+Names.emplace_back(*Name);
+  return internal::Matcher(
+  new internal::HasNameMatcher(std::move(Names)));
+}
+
+HasNameMatcher::HasNameMatcher(std::vector N)
+: UseUnqualifiedMatch(std::all_of(
+  N.begin(), N.end(),
+  [](StringRef Name) { return Name.find("::") == Name.npos; })),
+  Names(std::move(N)) {
+  for (StringRef Name : Names)
+assert(!Name.empty());
 }
 
 namespace {
 
-bool ConsumeNameSuffix(StringRef &FullName, StringRef Suffix) {
+bool consumeNameSuffix(StringRef &FullName, StringRef Suffix) {
   StringRef Name = FullName;
   if (!Name.endswith(Suffix))
 return false;
@@ -315,79 +327,127 @@
   return true;
 }
 
-bool ConsumeNodeName(StringRef &Name, const NamedDecl &Node) {
+StringRef getNodeName(const NamedDecl &Node, llvm::SmallString<128> &Scratch) {
   // Simple name.
   if (Node.getIdentifier())
-return ConsumeNameSuffix(Name, Node.getName());
+return Node.getName();
 
   if (Node.getDeclName()) {
 // Name needs to be constructed.
-llvm::SmallString<128> NodeName;
-llvm::raw_svector_ostream OS(NodeName);
+Scratch.clear();
+llvm::raw_svector_ostream OS(Scratch);
 Node.printName(OS);
-return ConsumeNameSuffix(Name, OS.str());
+return OS.str();
   }
 
-  return ConsumeNameSuffix(Name, "(anonymous)");
+  return "(anonymous)";
 }
 
+StringRef getNodeName(const RecordDecl &Node, llvm::SmallString<128> &Scratch) {
+  if (Node.getIdentifier()) {
+return Node.getName();
+  }
+  Scratch.clear();
+  return ("(anonymous " + Node.getKindName() + ")").toStringRef(Scratch);
+}
+
+StringRef getNodeName(const NamespaceDecl &Node,
+  llvm::SmallString<128> &Scratch) {
+  return Node.isAnonymousNamespace() ? "(anonymous namespace)" : Node.getName();
+}
+
+
+class PatternSet {
+public:
+  PatternSet(ArrayRef Names) {
+for (StringRef Name : Names)
+  Patterns.push_back({Name, Name.startswith("::")});
+  }
+
+  /// Consumes the name suffix from each pattern in the set and removes the ones
+  /// that didn't match.
+  /// Return true if there are still any patterns left.
+  bool consumeNameSuffix(StringRef NodeName, bool CanSkip) {
+for (size_t I = 0; I < Patterns.size();) {
+  if (internal::consumeNameSuffix(Patterns[I].Pattern, NodeName) ||
+  CanSkip) {
+++I;
+  } else {
+Patterns.erase(Patterns.begin() + I);
+  }
+}
+return !Patterns.empty();
+  }
+
+  /// Check if any of the patterns are a match.
+  /// A match will be a pattern that was fully consumed, that also matches the
+  /// 'fully qualified' requirement.
+  bool foundMatch(bool AllowFullyQualified) const {
+for (auto& P: Patterns)
+  if (P.Pattern.empty() && (AllowFullyQualified || !P.IsFullyQualified))
+return true;
+return false;
+  }
+
+private:
+  struct Pattern {
+StringRef Pattern;
+bool IsFullyQualified;
+  };
+  llvm::SmallVector Patterns;
+};
+
 }  // namespace
 
 bool HasNameMatcher::matchesNodeUnqualified(const NamedDecl &Node) const {
   assert(UseUnqualifiedMatch);
-  StringRef NodeName = Name;
-  return ConsumeNodeName(NodeName, Node) && NodeName.empty();
+  llvm::SmallString<128> Scratch;
+  StringRef NodeName = getNodeName(Node, Scratch);
+  return std::any_of(Names.begin(), Names.end(), [&](StringRef Name) {
+return consumeNameSuffix(Name, NodeName) && Name.empty();
+  });
 }
 
 bool HasNameMatcher::matchesNodeFullFast(const NamedDecl &Node) const {
+  PatternSet Patterns(Names);
+  llvm::SmallString<128>

r261574 - [ASTMatchers] Add matcher hasAnyName.

2016-02-22 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Mon Feb 22 15:13:02 2016
New Revision: 261574

URL: http://llvm.org/viewvc/llvm-project?rev=261574&view=rev
Log:
[ASTMatchers] Add matcher hasAnyName.

Summary: Add matcher hasAnyName as an optimization over anyOf(hasName(),...)

Reviewers: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D17163

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/docs/tools/dump_ast_matchers.py
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=261574&r1=261573&r2=261574&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb 22 15:13:02 2016
@@ -3102,6 +3102,16 @@ expr(nullPointerConstant())
 
 
 
+MatcherNamedDecl>>hasAnyNameStringRef, ..., 
StringRef
+Matches NamedDecl nodes 
that have any of the specified names.
+
+This matcher is only provided as a performance optimization of hasName.
+hasAnyName(a, b, c)
+ is equivalent but faster than
+anyOf(hasName(a), hasName(b), hasName(c))
+
+
+
 MatcherStmt>>isInTemplateInstantiation
 Matches 
statements inside of a template instantiation.
 

Modified: cfe/trunk/docs/tools/dump_ast_matchers.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_ast_matchers.py?rev=261574&r1=261573&r2=261574&view=diff
==
--- cfe/trunk/docs/tools/dump_ast_matchers.py (original)
+++ cfe/trunk/docs/tools/dump_ast_matchers.py Mon Feb 22 15:13:02 2016
@@ -264,6 +264,16 @@ def act_on_decl(declaration, comment, al
   add_matcher('*', name, 'Matcher<*>', comment)
   return
 
+# Parse Variadic functions.
+m = re.match(
+r"""^.*llvm::VariadicFunction\s*<\s*([^,]+),\s*([^,]+),\s*[^>]+>\s*
+  ([a-zA-Z]*)\s*=\s*{.*};$""",
+declaration, flags=re.X)
+if m:
+  result, arg, name = m.groups()[:3]
+  add_matcher(result, name, '%s, ..., %s' % (arg, arg), comment)
+  return
+
 # Parse Variadic operator matchers.
 m = re.match(
 r"""^.*VariadicOperatorMatcherFunc\s*<\s*([^,]+),\s*([^\s>]+)\s*>\s*

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=261574&r1=261573&r2=261574&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 22 15:13:02 2016
@@ -1844,11 +1844,24 @@ inline internal::Matcher sizeOfExp
 /// \code
 ///   namespace a { namespace b { class X; } }
 /// \endcode
-inline internal::Matcher hasName(std::string Name) {
-  return internal::Matcher(
-  new internal::HasNameMatcher(std::move(Name)));
+inline internal::Matcher hasName(const std::string &Name) {
+  return internal::Matcher(new internal::HasNameMatcher({Name}));
 }
 
+/// \brief Matches NamedDecl nodes that have any of the specified names.
+///
+/// This matcher is only provided as a performance optimization of hasName.
+/// \code
+/// hasAnyName(a, b, c)
+/// \endcode
+///  is equivalent to, but faster than
+/// \code
+/// anyOf(hasName(a), hasName(b), hasName(c))
+/// \endcode
+const llvm::VariadicFunction, StringRef,
+ internal::hasAnyNameFunc>
+hasAnyName = {};
+
 /// \brief Matches NamedDecl nodes whose fully qualified names contain
 /// a substring matched by the given RegExp.
 ///

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=261574&r1=261573&r2=261574&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Mon Feb 22 
15:13:02 2016
@@ -637,10 +637,10 @@ private:
 
 /// \brief Matches named declarations with a specific name.
 ///
-/// See \c hasName() in ASTMatchers.h for details.
+/// See \c hasName() and \c hasAnyName() in ASTMatchers.h for details.
 class HasNameMatcher : public SingleNodeMatcherInterface {
  public:
-  explicit HasNameMatcher(std::string Name);
+  explicit HasNameMatcher(std::vector Names);
 
   bool matchesNode(c

Re: r261574 - [ASTMatchers] Add matcher hasAnyName.

2016-02-22 Thread Aaron Ballman via cfe-commits
On Mon, Feb 22, 2016 at 4:13 PM, Samuel Benzaquen via cfe-commits
 wrote:
> Author: sbenza
> Date: Mon Feb 22 15:13:02 2016
> New Revision: 261574
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261574&view=rev
> Log:
> [ASTMatchers] Add matcher hasAnyName.
>
> Summary: Add matcher hasAnyName as an optimization over anyOf(hasName(),...)

Does this mean we can get a clang-tidy check to convert
anyOf(hasName(), ...) into hasAnyName()? ;-)

~Aaron

>
> Reviewers: alexfh
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D17163
>
> Modified:
> cfe/trunk/docs/LibASTMatchersReference.html
> cfe/trunk/docs/tools/dump_ast_matchers.py
> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>
> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=261574&r1=261573&r2=261574&view=diff
> ==
> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> +++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb 22 15:13:02 2016
> @@ -3102,6 +3102,16 @@ expr(nullPointerConstant())
>  
>
>
> +MatcherNamedDecl>>  class="name" onclick="toggle('hasAnyName0')"> name="hasAnyName0Anchor">hasAnyNameStringRef, ..., 
> StringRef
> +Matches NamedDecl 
> nodes that have any of the specified names.
> +
> +This matcher is only provided as a performance optimization of hasName.
> +hasAnyName(a, b, c)
> + is equivalent but faster than
> +anyOf(hasName(a), hasName(b), hasName(c))
> +
> +
> +
>  MatcherStmt>>  class="name" onclick="toggle('isInTemplateInstantiation0')"> name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation
>  Matches 
> statements inside of a template instantiation.
>
>
> Modified: cfe/trunk/docs/tools/dump_ast_matchers.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_ast_matchers.py?rev=261574&r1=261573&r2=261574&view=diff
> ==
> --- cfe/trunk/docs/tools/dump_ast_matchers.py (original)
> +++ cfe/trunk/docs/tools/dump_ast_matchers.py Mon Feb 22 15:13:02 2016
> @@ -264,6 +264,16 @@ def act_on_decl(declaration, comment, al
>add_matcher('*', name, 'Matcher<*>', comment)
>return
>
> +# Parse Variadic functions.
> +m = re.match(
> +r"""^.*llvm::VariadicFunction\s*<\s*([^,]+),\s*([^,]+),\s*[^>]+>\s*
> +  ([a-zA-Z]*)\s*=\s*{.*};$""",
> +declaration, flags=re.X)
> +if m:
> +  result, arg, name = m.groups()[:3]
> +  add_matcher(result, name, '%s, ..., %s' % (arg, arg), comment)
> +  return
> +
>  # Parse Variadic operator matchers.
>  m = re.match(
>  r"""^.*VariadicOperatorMatcherFunc\s*<\s*([^,]+),\s*([^\s>]+)\s*>\s*
>
> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=261574&r1=261573&r2=261574&view=diff
> ==
> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 22 15:13:02 2016
> @@ -1844,11 +1844,24 @@ inline internal::Matcher sizeOfExp
>  /// \code
>  ///   namespace a { namespace b { class X; } }
>  /// \endcode
> -inline internal::Matcher hasName(std::string Name) {
> -  return internal::Matcher(
> -  new internal::HasNameMatcher(std::move(Name)));
> +inline internal::Matcher hasName(const std::string &Name) {
> +  return internal::Matcher(new internal::HasNameMatcher({Name}));
>  }
>
> +/// \brief Matches NamedDecl nodes that have any of the specified names.
> +///
> +/// This matcher is only provided as a performance optimization of hasName.
> +/// \code
> +/// hasAnyName(a, b, c)
> +/// \endcode
> +///  is equivalent to, but faster than
> +/// \code
> +/// anyOf(hasName(a), hasName(b), hasName(c))
> +/// \endcode
> +const llvm::VariadicFunction, StringRef,
> + internal::hasAnyNameFunc>
> +hasAnyName = {};
> +
>  /// \brief Matches NamedDecl nodes whose fully qualified names contain
>  /// a substring matched by the given RegExp.
>  ///
>
> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=261574&r1=261573&r2=261574&view=diff
> 

Re: [PATCH] D16821: Add whole-program vtable optimization feature to Clang.

2016-02-22 Thread Peter Collingbourne via cfe-commits
pcc added inline comments.


Comment at: lib/CodeGen/CGVTables.cpp:904-919
@@ -900,5 +903,18 @@
+
+bool CodeGenModule::IsBitSetBlacklistedRecord(const CXXRecordDecl *RD) {
+  std::string TypeName = RD->getQualifiedNameAsString();
+  auto isInBlacklist = [&](const SanitizerBlacklist &BL) {
+if (RD->hasAttr() && BL.isBlacklistedType("attr:uuid"))
+  return true;
+
+return BL.isBlacklistedType(TypeName);
+  };
 
-  return getContext().getSanitizerBlacklist().isBlacklistedType(
-  RD->getQualifiedNameAsString());
+  return isInBlacklist(WholeProgramVTablesBlacklist) ||
+ ((LangOpts.Sanitize.has(SanitizerKind::CFIVCall) ||
+   LangOpts.Sanitize.has(SanitizerKind::CFINVCall) ||
+   LangOpts.Sanitize.has(SanitizerKind::CFIDerivedCast) ||
+   LangOpts.Sanitize.has(SanitizerKind::CFIUnrelatedCast)) &&
+  isInBlacklist(getContext().getSanitizerBlacklist()));
 }
 

rsmith wrote:
> It looks like putting a class in a sanitizer blacklist turns off the vptr 
> optimizations for the class and putting it in the vptr blacklist turns off 
> CFI checks for it. Can we avoid that, perhaps by using separate bitsets for 
> the vptr checks and CFI?
> It looks like putting a class in a sanitizer blacklist turns off the vptr 
> optimizations for the class and putting it in the vptr blacklist turns off 
> CFI checks for it

This is approximately what we want to do in any case. The blacklists identify 
classes defined outside of the linkage unit, and both CFI checks (modulo the 
cross-DSO feature) and devirtualization both rely on the classes being defined 
in the current linkage unit.

One can imagine adding classes to the blacklist that are somehow incompatible 
with CFI checks, but in general I'd expect that list to be pretty small 
(Chromium's list [1] currently has 18 entries, most of which are 
non-whole-program issues) so it probably isn't a huge loss for 
devirtualization, and we can always try to find some way to improve on that 
later.

Likewise, I think we could be a little smarter about using the correct 
blacklists in cross-DSO mode, but that can probably come later.

> Can we avoid that, perhaps by using separate bitsets for the vptr checks and 
> CFI?

I think we could probably share bitsets for both use cases and filter for 
devirt/CFI at call sites. I suspect it will be important for devirt and CFI to 
share bitsets, as I will want to eliminate CFI checks in devirtualized calls.

[1] 
https://code.google.com/p/chromium/codesearch#chromium/src/tools/cfi/blacklist.txt&q=cfi/blacklist&sq=package:chromium&type=cs&l=2


Comment at: lib/CodeGen/CodeGenModule.h:492
@@ -491,1 +491,3 @@
 
+  SanitizerBlacklist WholeProgramVTablesBlacklist;
+

rsmith wrote:
> Now might be a good time to rename the `SanitizerBlacklist` class to 
> something more general (but not as part of this commit).
Ack.


Comment at: lib/CodeGen/ItaniumCXXABI.cpp:1605
@@ -1604,5 +1604,3 @@
 
-  if (CGF.SanOpts.has(SanitizerKind::CFIVCall))
-CGF.EmitVTablePtrCheckForCall(MethodDecl, VTable,
-  CodeGenFunction::CFITCK_VCall, Loc);
+  CGF.EmitBitSetCodeForVCall(MethodDecl->getParent(), VTable, Loc);
 

rsmith wrote:
> You can be a lot more aggressive than this -- you can make an assumption 
> about the value of the vptr from within `EmitTypeCheck` in every case where 
> the vptr sanitizer would emit a dynamic type check. I'm not sure that doing 
> so will allow you to deduce a lot more vptrs, but it seems like it could help 
> in some cases.
Maybe, but that probably wouldn't help yet. The devirtualization optimization 
pass looks for a very specific IR pattern, and if we generate extra vtable 
loads for casts to assume against, we would need additional machinery to ensure 
the load from the cast is invariant with those from any calls (maybe Piotr's 
work would help here, not sure).

One thing that I'd like to do (and this would help CFI as well) is to 
specifically recognize cases like this:

```
struct B {
  virtual void vf();
};

struct D1 {
};

struct D2 : B {
  virtual void vf();
};

void f(D1 *d) {
  d->vf();
}
```

In this case I'd like to devirtualize the virtual call in `f()` to `B::vf()`. 
But because the implicit cast to `B` in `f()` removes the information that `d` 
cannot be of type `D2`, we cannot eliminate `D2::vf()` as a candidate target 
(see also `test/cfi/sibling.cpp` in the CFI test suite).

Although this could possibly be emitted and pattern matched at the IR level, it 
seems simpler (and would probably catch enough cases) to have Clang look 
through the implicit cast when IR gen'ing for the call.


http://reviews.llvm.org/D16821



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


Re: [PATCH] D16821: Add whole-program vtable optimization feature to Clang.

2016-02-22 Thread Pete Cooper via cfe-commits

> On Feb 22, 2016, at 1:30 PM, Peter Collingbourne  wrote:
> 
> One thing that I'd like to do (and this would help CFI as well) is to 
> specifically recognize cases like this:
> 
> ```
> struct B {
>  virtual void vf();
> };
> 
> struct D1 {
> };
I assume you meant D1 : B here?
> 
> struct D2 : B {
>  virtual void vf();
> };
> 
> void f(D1 *d) {
>  d->vf();
> }
> ```
> 
> In this case I'd like to devirtualize the virtual call in `f()` to `B::vf()`. 
> But because the implicit cast to `B` in `f()` removes the information that 
> `d` cannot be of type `D2`, we cannot eliminate `D2::vf()` as a candidate 
> target (see also `test/cfi/sibling.cpp` in the CFI test suite).
> 
> Although this could possibly be emitted and pattern matched at the IR level, 
> it seems simpler (and would probably catch enough cases) to have Clang look 
> through the implicit cast when IR gen'ing for the call.
So my devirtualizer dealt with this by marking each call site with the most 
specific class we know of in the hierarchy.  

In this case, then class hierarchy would contain the pairs: (B, B), (D1, B), 
(D2, B).

The call site in f() would be tagged with (D1, B) not (B, B).  Then, when we 
are in the pass, we look at the subclasses from (D1, B), see that there are 
none (or that none override vf), and devirtualize to B::vf().

If that isn’t possible in the current solution (I didn’t check), then it should 
be easy enough to add.  I certainly don’t think any of the current 
implementation would be hard to adapt to support this use case.

Cheers,
Pete



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


Re: r261574 - [ASTMatchers] Add matcher hasAnyName.

2016-02-22 Thread Samuel Benzaquen via cfe-commits
On Mon, Feb 22, 2016 at 4:19 PM, Aaron Ballman 
wrote:

> On Mon, Feb 22, 2016 at 4:13 PM, Samuel Benzaquen via cfe-commits
>  wrote:
> > Author: sbenza
> > Date: Mon Feb 22 15:13:02 2016
> > New Revision: 261574
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=261574&view=rev
> > Log:
> > [ASTMatchers] Add matcher hasAnyName.
> >
> > Summary: Add matcher hasAnyName as an optimization over
> anyOf(hasName(),...)
>
> Does this mean we can get a clang-tidy check to convert
> anyOf(hasName(), ...) into hasAnyName()? ;-)
>
> ~Aaron
>

I would be simple, but I don't think it the cost/benefit is there. =)
I changed all the checks manually in 5 minutes.
I'll be sending that change soon.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r261574 - [ASTMatchers] Add matcher hasAnyName.

2016-02-22 Thread Aaron Ballman via cfe-commits
On Mon, Feb 22, 2016 at 4:43 PM, Samuel Benzaquen  wrote:
>
> On Mon, Feb 22, 2016 at 4:19 PM, Aaron Ballman 
> wrote:
>>
>> On Mon, Feb 22, 2016 at 4:13 PM, Samuel Benzaquen via cfe-commits
>>  wrote:
>> > Author: sbenza
>> > Date: Mon Feb 22 15:13:02 2016
>> > New Revision: 261574
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=261574&view=rev
>> > Log:
>> > [ASTMatchers] Add matcher hasAnyName.
>> >
>> > Summary: Add matcher hasAnyName as an optimization over
>> > anyOf(hasName(),...)
>>
>> Does this mean we can get a clang-tidy check to convert
>> anyOf(hasName(), ...) into hasAnyName()? ;-)
>>
>> ~Aaron
>
>
> I would be simple, but I don't think it the cost/benefit is there. =)
> I changed all the checks manually in 5 minutes.
> I'll be sending that change soon.

Haha, I was joking about the new check, but am really glad to hear
we'll be using the new AST matcher right away. Thank you for working
on this!

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


[libcxx] r261581 - Fix __is_referenceable to work with vector types. Fixes PR#26654 and 26656. Thanks to Evgeniy for the reports, and to Eric for the suggestion on how to fix it.

2016-02-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Feb 22 16:13:03 2016
New Revision: 261581

URL: http://llvm.org/viewvc/llvm-project?rev=261581&view=rev
Log:
Fix __is_referenceable to work with vector types. Fixes PR#26654 and 26656. 
Thanks to Evgeniy for the reports, and to Eric for the suggestion on how to fix 
it.

Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp

Modified: libcxx/trunk/include/type_traits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=261581&r1=261580&r2=261581&view=diff
==
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Feb 22 16:13:03 2016
@@ -959,34 +959,15 @@ template  _LIBCPP_CONSTEXPR b
 
 
 // __is_referenceable  [defns.referenceable]
-template  struct __is_referenceable
-: public std::integral_constant::value || 
is_reference<_Tp>::value> {};
 
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-template 
-struct __is_referenceable<_Ret(_Args...)>   : public std::true_type {};
-
-template 
-struct __is_referenceable<_Ret(_Args..., ...)>  : public std::true_type {};
-#else
-template 
-struct __is_referenceable<_Ret()>   : public std::true_type {};
-template 
-struct __is_referenceable<_Ret(_A0)>: public std::true_type {};
-template 
-struct __is_referenceable<_Ret(_A0, _A1)>   : public std::true_type {};
-template 
-struct __is_referenceable<_Ret(_A0, _A1, _A2)>  : public std::true_type {};
-
-template 
-struct __is_referenceable<_Ret(...)>: public std::true_type {};
-template 
-struct __is_referenceable<_Ret(_A0, ...)>   : public std::true_type {};
-template 
-struct __is_referenceable<_Ret(_A0, _A1, ...)>  : public std::true_type {};
-template 
-struct __is_referenceable<_Ret(_A0, _A1, _A2, ...)> : public std::true_type {};
-#endif
+struct __is_referenceable_impl {
+template  static _Tp& __test(int);
+template  static __two __test(...);
+};
+
+template 
+struct __is_referenceable : std::integral_constant(0)), 
__two>::value> {};
 
 
 // add_const

Modified: libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp?rev=261581&r1=261580&r2=261581&view=diff
==
--- libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp Mon Feb 
22 16:13:03 2016
@@ -39,6 +39,11 @@ static_assert(( std::__is_referenceable<
 static_assert(( std::__is_referenceable::value), "");
 #endif
 
+static_assert(( std::__is_referenceable::value), "");
+static_assert(( std::__is_referenceable::value), "");
+static_assert(( std::__is_referenceable::value), "");
+static_assert(( std::__is_referenceable::value), "");
+
 // Functions without cv-qualifiers are referenceable 
 static_assert(( std::__is_referenceable::value), "");
 #if TEST_STD_VER >= 11


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


r261583 - Fix Visual Studio build after r261574

2016-02-22 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Feb 22 16:21:58 2016
New Revision: 261583

URL: http://llvm.org/viewvc/llvm-project?rev=261583&view=rev
Log:
Fix Visual Studio build after r261574

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=261583&r1=261582&r2=261583&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 22 16:21:58 2016
@@ -1845,7 +1845,9 @@ inline internal::Matcher sizeOfExp
 ///   namespace a { namespace b { class X; } }
 /// \endcode
 inline internal::Matcher hasName(const std::string &Name) {
-  return internal::Matcher(new internal::HasNameMatcher({Name}));
+  std::vector Names;
+  Names.push_back(Name);
+  return internal::Matcher(new internal::HasNameMatcher(Names));
 }
 
 /// \brief Matches NamedDecl nodes that have any of the specified names.

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=261583&r1=261582&r2=261583&view=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Mon Feb 22 16:21:58 2016
@@ -369,7 +369,7 @@ public:
   /// Return true if there are still any patterns left.
   bool consumeNameSuffix(StringRef NodeName, bool CanSkip) {
 for (size_t I = 0; I < Patterns.size();) {
-  if (internal::consumeNameSuffix(Patterns[I].Pattern, NodeName) ||
+  if (internal::consumeNameSuffix(Patterns[I].P, NodeName) ||
   CanSkip) {
 ++I;
   } else {
@@ -384,14 +384,14 @@ public:
   /// 'fully qualified' requirement.
   bool foundMatch(bool AllowFullyQualified) const {
 for (auto& P: Patterns)
-  if (P.Pattern.empty() && (AllowFullyQualified || !P.IsFullyQualified))
+  if (P.P.empty() && (AllowFullyQualified || !P.IsFullyQualified))
 return true;
 return false;
   }
 
 private:
   struct Pattern {
-StringRef Pattern;
+StringRef P;
 bool IsFullyQualified;
   };
   llvm::SmallVector Patterns;


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


Re: r261574 - [ASTMatchers] Add matcher hasAnyName.

2016-02-22 Thread Hans Wennborg via cfe-commits
On Mon, Feb 22, 2016 at 1:13 PM, Samuel Benzaquen via cfe-commits
 wrote:
> Author: sbenza
> Date: Mon Feb 22 15:13:02 2016
> New Revision: 261574
>
> URL: http://llvm.org/viewvc/llvm-project?rev=261574&view=rev
> Log:
> [ASTMatchers] Add matcher hasAnyName.
>
> Summary: Add matcher hasAnyName as an optimization over anyOf(hasName(),...)
>
> Reviewers: alexfh
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D17163

I've tried to fix the Visual Studio build in r261583. Please take a
look to make sure the fixes seem reasonable.


> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 22 15:13:02 2016
> @@ -1844,11 +1844,24 @@ inline internal::Matcher sizeOfExp
>  /// \code
>  ///   namespace a { namespace b { class X; } }
>  /// \endcode
> -inline internal::Matcher hasName(std::string Name) {
> -  return internal::Matcher(
> -  new internal::HasNameMatcher(std::move(Name)));
> +inline internal::Matcher hasName(const std::string &Name) {
> +  return internal::Matcher(new internal::HasNameMatcher({Name}));

That doesn't compile with Visual Studio 2013:

C:\b\build\slave\ClangToTWin\build\src\third_party\llvm\tools\clang\include\clang/ASTMatchers/ASTMatchers.h(1848)
: error C2440: 'initializing' : cannot convert from 'initializer-list'
to 'clang::ast_matchers::internal::HasNameMatcher'
Constructor for class
'clang::ast_matchers::internal::HasNameMatcher' is declared 'explicit'

> +private:
> +  struct Pattern {
> +StringRef Pattern;

C:\b\build\slave\ClangToTWin\build\src\third_party\llvm\tools\clang\lib\ASTMatchers\ASTMatchersInternal.cpp(394)
: error C2380: type(s) preceding 'Pattern' (constructor with return
type, or illegal redefinition of current class-name?)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >