r265915 - [Clang][AVX512][BuiltIn] Adding avx512 ( vperm{i|t}2var, vpermil{var}{ps|pd}{256|512} ) builtin to clang.

2016-04-11 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 11 02:15:34 2016
New Revision: 265915

URL: http://llvm.org/viewvc/llvm-project?rev=265915&view=rev
Log:
[Clang][AVX512][BuiltIn] Adding avx512 ( vperm{i|t}2var, 
vpermil{var}{ps|pd}{256|512} ) builtin to clang.

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


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=265915&r1=265914&r2=265915&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 11 02:15:34 2016
@@ -1848,6 +1848,26 @@ TARGET_BUILTIN(__builtin_ia32_vcvttss2si
 TARGET_BUILTIN(__builtin_ia32_vcvttss2si64, "LLiV4fIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvttss2usi32, "UiV4fIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvttss2usi64, "ULLiV4fIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermi2vard512_mask, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermi2varpd512_mask, 
"V8dV8dV8LLiV8dUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermi2varps512_mask, 
"V16fV16fV16iV16fUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermi2varq512_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilpd512_mask, "V8dV8dIiV8dUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilps512_mask, 
"V16fV16fIiV16fUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilvarpd512_mask, 
"V8dV8dV8LLiV8dUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilvarps512_mask, 
"V16fV16fV16iV16fUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermt2vard512_maskz, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varpd512_maskz, 
"V8dV8LLiV8dV8dUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varps512_maskz, 
"V16fV16iV16fV16fUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermt2varq512_maskz, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vpermilpd_mask, "V2dV2dIiV2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilpd256_mask, "V4dV4dIiV4dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilps_mask, "V4fV4fIiV4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilps256_mask, "V8fV8fIiV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilvarpd_mask, 
"V2dV2dV2LLiV2dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilvarpd256_mask, 
"V4dV4dV4LLiV4dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilvarps_mask, 
"V4fV4fV4iV4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vpermilvarps256_mask, 
"V8fV8fV8iV8fUc","","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=265915&r1=265914&r2=265915&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Apr 11 02:15:34 2016
@@ -3985,6 +3985,16 @@ _mm512_mask_unpackhi_pd (__m512d __W, __
 #define _mm_cvt_roundsd_si64( __A, __R) __extension__ ({ \
 __builtin_ia32_vcvtsd2si64 ((__v2df)( __A),( __R));\
 })
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask2_permutex2var_epi32 (__m512i __A, __m512i __I,
+ __mmask16 __U, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_vpermi2vard512_mask ((__v16si) __A,
+   (__v16si) __I
+   /* idx */ ,
+   (__v16si) __B,
+   (__mmask16) __U);
+}
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_maskz_unpackhi_pd (__mmask8 __U, __m512d __A, __m512d __B)
@@ -4233,6 +4243,181 @@ _mm_cvttss_u64 (__m128 __A)
   _MM_FROUND_CUR_DIRECTION);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask2_permutex2var_pd (__m512d __A, __m512i __I, __mmask8 __U,
+__m512d __B)
+{
+  return (__m512d) __builtin_ia32_vpermi2varpd512_mask ((__v8df) __A,
+  (__v8di) __I
+  /* idx */ ,
+  (__v8df) __B,
+  (__mmask8) __U);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_mask2_permutex2var_ps (__m512 __A, __m512i __I, __mmask16 __U,
+__m512 __B)
+{
+  return (__m512) __builtin_ia32_vpermi2varps512_mask ((__v16sf) __A,
+   (__v16si) __I
+   /* idx */ ,
+   (__v16sf) __B,
+   (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask2_permutex2var_epi64 (__m512i __A, __m512i __I,
+ __mmask8 __U, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_vpermi2varq512_mask 

Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-11 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Sorry, I was out for couple days.

It seems that there are no real objections so I'm committing this patch and I'm 
going to keep working on this topic to support target attribute with dynamic 
dispatching on x86 so if you think that something is missing, please let me 
know. Thank you for the review!



Comment at: include/clang/Basic/AttrDocs.td:2371
@@ +2370,3 @@
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];

echristo wrote:
> probinson wrote:
> > echristo wrote:
> > > probinson wrote:
> > > > joerg wrote:
> > > > > probinson wrote:
> > > > > > echristo wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > echristo wrote:
> > > > > > > > > Probably better to say linux fwiw and not ELF.
> > > > > > > > The validation code in Sema is checking for an ELF target.  If 
> > > > > > > > the restriction is more precise than that, then we should make 
> > > > > > > > a TargetInfo callback.  Do the BSDs and other ELF targets not 
> > > > > > > > use binutils/glibc?
> > > > > > > We should make a TargetInfo callback. BSDs and other ELF targets 
> > > > > > > aren't guaranteed to use binutils/glibc (some of them have even 
> > > > > > > switched to llvm already) - and I don't know what the state of 
> > > > > > > ifunc support on those architectures is.
> > > > > > Hear hear. PS4 is ELF but we don't use glibc.
> > > > > The attribute is not Linux specific, so ELF is a reasonable first 
> > > > > approximation. Most BSDs have some ifunc support at least. I'm not in 
> > > > > favor of doing any checks beyond ELF -- even on Linux the 
> > > > > availability of working ifunc support depends on other factors like 
> > > > > whether the binary is dynamically linked.
> > > > What's the failure mode if the target doesn't actually support it?
> > > The failure mode is an unknown relocation if your linker doesn't support 
> > > it. If your linker supports it but your libc doesn't that'll be an 
> > > unknown dynamic relocation at program start up.
> > > 
> > > In retrospect I think we can leave it just as an ELF check here and go. 
> > > There are similar features in Mach-O that we might want this to use at 
> > > some point as well so we can leave it as general as possible and rely on 
> > > downstream tools to provide more errors?
> > > 
> > > I honestly don't have a strong opinion here given the current vaguely 
> > > broad platform support and future possibilities.
> > Yeah, we can live with that.
> Cool. So in summary: "Ignore this entire thread" :)
I think check for ELF only is a reasonable first approximation when attribute 
can be used.


http://reviews.llvm.org/D15524



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


Re: [PATCH] D18943: clang-format: [JS] do not insert semicolons after wrapped annotations.

2016-04-11 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.
Closed by commit rL265916: clang-format: [JS] do not insert semicolons after 
wrapped annotations. (authored by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D18943?vs=53190&id=53199#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18943

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -715,6 +715,13 @@
 return;
 
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
+// If the token before the previous one is an '@', the previous token is an
+// annotation and can precede another identifier/value.
+const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+if (PrePrevious->is(tok::at))
+  return;
+  }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)
 addUnwrappedLine();
   bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -686,6 +686,8 @@
   verifyFormat("x instanceof String", "x\n"
   "instanceof\n"
   "String");
+  verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
+  "  bar) {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -715,6 +715,13 @@
 return;
 
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
+// If the token before the previous one is an '@', the previous token is an
+// annotation and can precede another identifier/value.
+const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+if (PrePrevious->is(tok::at))
+  return;
+  }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)
 addUnwrappedLine();
   bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -686,6 +686,8 @@
   verifyFormat("x instanceof String", "x\n"
   "instanceof\n"
   "String");
+  verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
+  "  bar) {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

2016-04-11 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

I think merge them into one file is a good idea.
And the layout by sepc order is OK, is will makes the review easy.


http://reviews.llvm.org/D18369



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


r265917 - [GCC] Attribute ifunc support in clang

2016-04-11 Thread Dmitry Polukhin via cfe-commits
Author: dpolukhin
Date: Mon Apr 11 02:48:59 2016
New Revision: 265917

URL: http://llvm.org/viewvc/llvm-project?rev=265917&view=rev
Log:
[GCC] Attribute ifunc support in clang

This patch add support for GCC attribute((ifunc("resolver"))) for
targets that use ELF as object file format. In general ifunc is a
special kind of function alias with type @gnu_indirect_function. LLVM
patch http://reviews.llvm.org/D15525

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

Added:
cfe/trunk/test/CodeGen/ifunc.c   (with props)
cfe/trunk/test/Sema/attr-ifunc.c   (with props)
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-alias-elf.c

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=265917&r1=265916&r2=265917&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Apr 11 02:48:59 2016
@@ -567,6 +567,13 @@ public:
 return NextInContextAndBits.getInt() & ModulePrivateFlag;
   }
 
+  /// Return true if this declaration has an attribute which acts as
+  /// definition of the entity, such as 'alias' or 'ifunc'.
+  bool hasDefiningAttr() const;
+
+  /// Return this declaration's defining attribute if it has one.
+  const Attr *getDefiningAttr() const;
+
 protected:
   /// \brief Specify whether this declaration was marked as being private
   /// to the module in which it was defined.

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=265917&r1=265916&r2=265917&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Apr 11 02:48:59 2016
@@ -855,6 +855,13 @@ def IBOutletCollection : InheritableAttr
   let Documentation = [Undocumented];
 }
 
+def IFunc : Attr {
+  let Spellings = [GCC<"ifunc">];
+  let Args = [StringArgument<"Resolver">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [IFuncDocs];
+}
+
 def Restrict : InheritableAttr {
   let Spellings = [Declspec<"restrict">, GCC<"malloc">];
   let Subjects = SubjectList<[Function]>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=265917&r1=265916&r2=265917&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Mon Apr 11 02:48:59 2016
@@ -2358,3 +2358,16 @@ to replace the deprecated name with a ne
 string argument which is the message to display when emitting the warning.
   }];
 }
+
+def IFuncDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((ifunc("resolver")))`` is used to mark that the address of a 
declaration should be resolved at runtime by calling a resolver function.
+
+The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should take no arguments and return a 
pointer.
+
+The ``ifunc`` attribute may only be used on a function declaration.  A 
function declaration with an ``ifunc`` attribute is considered to be a 
definition of the declared entity.  The entity must not have weak linkage; for 
example, in C++, it cannot be applied to a declaration if a definition at that 
location would be considered inline.
+
+Not all targets support this attribute.  ELF targets support this attribute 
when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF 
targets currently do not support this attribute.
+  }];
+}

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=265917&r1=265916&r2=265917&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Apr 11 02:48:59 
2016
@@ -2464,17 +2464,21 @@ def err_attribute_weakref_without_alias
 def err_alias_not_supported_on_darwin : Error <
   "only weak aliases are supported on darwin">;
 def err_alias_to_undefined : Error<
-  "alias must point to a defined variable or function">;
+ 

Re: [PATCH] D15524: [GCC] Attribute ifunc support in clang

2016-04-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265917: [GCC] Attribute ifunc support in clang (authored by 
dpolukhin).

Changed prior to commit:
  http://reviews.llvm.org/D15524?vs=52906&id=53200#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15524

Files:
  cfe/trunk/include/clang/AST/DeclBase.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.h
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGen/ifunc.c
  cfe/trunk/test/Sema/attr-alias-elf.c
  cfe/trunk/test/Sema/attr-ifunc.c

Index: cfe/trunk/include/clang/AST/DeclBase.h
===
--- cfe/trunk/include/clang/AST/DeclBase.h
+++ cfe/trunk/include/clang/AST/DeclBase.h
@@ -567,6 +567,13 @@
 return NextInContextAndBits.getInt() & ModulePrivateFlag;
   }
 
+  /// Return true if this declaration has an attribute which acts as
+  /// definition of the entity, such as 'alias' or 'ifunc'.
+  bool hasDefiningAttr() const;
+
+  /// Return this declaration's defining attribute if it has one.
+  const Attr *getDefiningAttr() const;
+
 protected:
   /// \brief Specify whether this declaration was marked as being private
   /// to the module in which it was defined.
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2464,17 +2464,21 @@
 def err_alias_not_supported_on_darwin : Error <
   "only weak aliases are supported on darwin">;
 def err_alias_to_undefined : Error<
-  "alias must point to a defined variable or function">;
+  "%select{alias|ifunc}0 must point to a defined %select{variable or |}1function">;
 def warn_alias_to_weak_alias : Warning<
-  "alias will always resolve to %0 even if weak definition of alias %1 is overridden">,
+  "%select{alias|ifunc}2 will always resolve to %0 even if weak definition of %1 is overridden">,
   InGroup;
 def warn_alias_with_section : Warning<
-  "alias will not be in section '%0' but in the same section as the aliasee">,
+  "%select{alias|ifunc}1 will not be in section '%0' but in the same section as the %select{aliasee|resolver}2">,
   InGroup;
 def err_duplicate_mangled_name : Error<
   "definition with same mangled name as another definition">;
 def err_cyclic_alias : Error<
-  "alias definition is part of a cycle">;
+  "%select{alias|ifunc}0 definition is part of a cycle">;
+def err_ifunc_resolver_return : Error<
+  "ifunc resolver function must return a pointer">;
+def err_ifunc_resolver_params : Error<
+  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type : Warning<
   "%0 attribute only applies to %select{functions|unions|"
   "variables and functions|functions and methods|parameters|"
@@ -4196,7 +4200,7 @@
 def err_alias_after_tentative :
   Error<"alias definition of %0 after tentative definition">;
 def err_alias_is_definition :
-  Error<"definition %0 cannot also be an alias">;
+  Error<"definition %0 cannot also be an %select{alias|ifunc}1">;
 def err_definition_of_implicitly_declared_member : Error<
   "definition of implicitly declared %select{default constructor|copy "
   "constructor|move constructor|copy assignment operator|move assignment "
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2358,3 +2358,16 @@
 string argument which is the message to display when emitting the warning.
   }];
 }
+
+def IFuncDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+``__attribute__((ifunc("resolver")))`` is used to mark that the address of a declaration should be resolved at runtime by calling a resolver function.
+
+The symbol name of the resolver function is given in quotes.  A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``.  The resolver function should take no arguments and return a pointer.
+
+The ``ifunc`` attribute may only be used on a function declaration.  A function declaration with an ``ifunc`` attribute is considered to be a definition of the declared entity.  The entity must not have weak linkage; for example, in C++, it cannot be applied to a declaration if a definition at that location would be considered inline.
+
+Not all targets support this attribute.  ELF targets support this attribute when using binutils v2.20.1 or higher and glibc v2.11.1 or higher.  Non-ELF targets currently do not support this attribute.
+  }];
+}
Index: cfe/trunk/inclu

[PATCH] D18950: clang-format: [JS] Test for parameter annotations.

2016-04-11 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Just to ensure no regressions, this already works fine.

http://reviews.llvm.org/D18950

Files:
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -936,6 +936,9 @@
"return 'y';\n"
"  }\n"
"}");
+  verifyFormat("class C {\n"
+   "  private x(@A x: string) {}\n"
+   "}");
   verifyFormat("class X {}\n"
"class Y {}");
 }


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -936,6 +936,9 @@
"return 'y';\n"
"  }\n"
"}");
+  verifyFormat("class C {\n"
+   "  private x(@A x: string) {}\n"
+   "}");
   verifyFormat("class X {}\n"
"class Y {}");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-11 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 53202.
ioeric added a comment.

- Fixed a potential bug in checkEmptyNamespace.


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/FixTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11274,6 +11274,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/FixTest.cpp
===
--- /dev/null
+++ unittests/Format/FixTest.cpp
@@ -0,0 +1,85 @@
+//===- unittest/Format/FixTest.cpp - Code fixing unit tests ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class FixTest : public ::testing::Test {
+protected:
+  std::string fix(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::fix(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(FixTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(FixTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\nnamespace C {\n"
+ "namespace D int i; }\n\n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = fix(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(FixTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Set the changed range to be the second "\n".
+  std::vector Ranges(1, tooling::Range(14, 0));
+  std::string Result = fix(Code, Ranges);
+  

Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-11 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: lib/Format/Format.cpp:1597
@@ +1596,3 @@
+ SmallVector(Ranges.begin(), 
Ranges.end())),
+UnwrappedLines(1),
+Encoding(encoding::detectEncoding(SourceMgr.getBufferData(ID))),

djasper wrote:
> Why are you doing this?
I am not quite sure here actually. This was copied from Formatter. And since 
`consumeUnwrappedLine` requires at lease one element in `UnwrappedLines`, I 
figured this is necessary initialization?


Comment at: lib/Format/Format.cpp:1818
@@ +1817,3 @@
+
+// Merge multiple continuous token deletions into one big deletion.
+unsigned Idx = 0;

djasper wrote:
> Can you explain why you are doing this?
I want to reduce the number of replacements so that when we do `reformat`  on 
the fixed code, there could be fewer changed code ranges considering that the 
current implementation of `computeAffectedLines` is not that efficient when we 
have many ranges.


Comment at: lib/Format/Format.cpp:2286
@@ +2285,3 @@
+const FormatStyle &, StringRef, std::vector, StringRef)>
+ReplacementsProcessFunctionType;
+

djasper wrote:
> Don't define a typedef for something that is only used once. Also, this is an 
> internal function, how about writing this as:
> 
>   template 
>   static tooling::Replacements
>   processReplacements(StringRef Code, const tooling::Replacements &Replaces, 
> T ProcessFunc,
>   const FormatStyle &Style) {
> 
>   }
> 
> No need to spell out the function type (I think).
Wow, this is really helpful! Thanks!


Comment at: lib/Format/Format.cpp:1590
@@ +1589,3 @@
+
+class CodeProcesser : public UnwrappedLineConsumer {
+public:

I'm not quite sure if the name is accurate. Do you have a better name?


http://reviews.llvm.org/D18551



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


Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-11 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 53203.
hokein added a comment.

Use one vector storing checks details instead of three.


http://reviews.llvm.org/D18694

Files:
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/Inputs/explain-config/.clang-tidy
  test/clang-tidy/explain-checks.cpp

Index: test/clang-tidy/explain-checks.cpp
===
--- /dev/null
+++ test/clang-tidy/explain-checks.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE1 %s
+// RUN: clang-tidy -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE2 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE3 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,-modernize-use-nullptr'}" %S/Inputs/explain-config/a.cc -explain-config | FileCheck --check-prefix=CHECK-MESSAGE4 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-*'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE5 %s
+// RUN: clang-tidy -explain-config %S/Inputs/explain-config/a.cc | grep "'modernize-use-nullptr' is enabled in the %S/Inputs/explain-config/.clang-tidy."
+
+// CHECK-MESSAGE1: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE2: 'modernize-use-nullptr' is enabled in the command-line option '-config'.
+// CHECK-MESSAGE3: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE4: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE5: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
Index: test/clang-tidy/Inputs/explain-config/.clang-tidy
===
--- /dev/null
+++ test/clang-tidy/Inputs/explain-config/.clang-tidy
@@ -0,0 +1 @@
+Checks: '-*,modernize-use-nullptr'
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -128,6 +128,12 @@
 )"),
 cl::init(false), cl::cat(ClangTidyCategory));
 
+static cl::opt ExplainConfig("explain-config", cl::desc(R"(
+for each enabled check explains, where it is enabled, i.e. in clang-tidy binary,
+command line or a specific configuration file.
+)"),
+   cl::init(false), cl::cat(ClangTidyCategory));
+
 static cl::opt Config("config", cl::desc(R"(
 Specifies a configuration in YAML/JSON format:
   -config="{Checks: '*',
@@ -179,6 +185,12 @@
 namespace clang {
 namespace tidy {
 
+static const char* CheckSourceTypeDefaultBinary = "clang-tidy binary";
+static const char* CheckSourceTypeCheckCommandLineOption =
+"command-line option '-checks'";
+static const char* CheckSourceTypeConfigCommandLineOption =
+"command-line option '-config'";
+
 static void printStats(const ClangTidyStats &Stats) {
   if (Stats.errorsIgnored()) {
 llvm::errs() << "Suppressed " << Stats.errorsIgnored() << " warnings (";
@@ -256,6 +268,8 @@
 
   ClangTidyOptions DefaultOptions;
   DefaultOptions.Checks = DefaultChecks;
+  DefaultOptions.CheckSources.emplace_back(DefaultChecks,
+   CheckSourceTypeDefaultBinary);
   DefaultOptions.WarningsAsErrors = "";
   DefaultOptions.HeaderFilterRegex = HeaderFilter;
   DefaultOptions.SystemHeaders = SystemHeaders;
@@ -266,8 +280,11 @@
 DefaultOptions.User = llvm::sys::Process::GetEnv("USERNAME");
 
   ClangTidyOptions OverrideOptions;
-  if (Checks.getNumOccurrences() > 0)
+  if (Checks.getNumOccurrences() > 0) {
 OverrideOptions.Checks = Checks;
+OverrideOptions.CheckSources.emplace_back(
+Checks, CheckSourceTypeCheckCommandLineOption);
+  }
   if (WarningsAsErrors.getNumOccurrences() > 0)
 OverrideOptions.WarningsAsErrors = WarningsAsErrors;
   if (HeaderFilter.getNumOccurrences() > 0)
@@ -280,6 +297,10 @@
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
 parseConfiguration(Config)) {
+  if (ParsedConfig->Checks) {
+ParsedConfig->CheckSources.emplace_back(
+*ParsedConfig->Checks, CheckSourceTypeConfigCommandLineOption);
+  }
   return llvm::make_unique(
   GlobalOptions, ClangTidyOptions::getDefaults()
  .mergeWith(DefaultOptions)
@@ -311,6 +332,20 @@
   ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FileName);
   std::vector EnabledChecks = getCheckNames(EffectiveOptions);
 
+  if (ExplainConfig) {
+for (const std::string &Check : EnabledChecks) {
+  for (auto It = EffectiveOptions.CheckSources.rbegin();
+   It != EffectiveOptions

Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

2016-04-11 Thread Haojian Wu via cfe-commits
hokein marked 5 inline comments as done.
hokein added a comment.

http://reviews.llvm.org/D18694



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


r265918 - Remove redundant conditions of the form (A || (!A && B)) -> (A || B)

2016-04-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 11 03:26:13 2016
New Revision: 265918

URL: http://llvm.org/viewvc/llvm-project?rev=265918&view=rev
Log:
Remove redundant conditions of the form (A || (!A && B)) -> (A || B)

Found by cppcheck! PR27286 PR27287 PR27288 PR27289

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=265918&r1=265917&r2=265918&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Apr 11 03:26:13 2016
@@ -2994,7 +2994,7 @@ LValue CodeGenFunction::EmitOMPArraySect
   else
 ResultExprTy = BaseTy->getPointeeType();
   llvm::Value *Idx = nullptr;
-  if (IsLowerBound || (!IsLowerBound && E->getColonLoc().isInvalid())) {
+  if (IsLowerBound || E->getColonLoc().isInvalid()) {
 // Requesting lower bound or upper bound, but without provided length and
 // without ':' symbol for the default length -> length = 1.
 // Idx = LowerBound ?: 0;

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=265918&r1=265917&r2=265918&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Mon Apr 11 03:26:13 2016
@@ -1596,8 +1596,7 @@ OMPClause *Parser::ParseOpenMPVarListCla
(Kind != OMPC_map)) ||
   ((Kind == OMPC_reduction) && !InvalidReductionId) ||
   ((Kind == OMPC_map) && (MapType != OMPC_MAP_unknown) &&
-   (!MapTypeModifierSpecified ||
-(MapTypeModifierSpecified && MapTypeModifier == OMPC_MAP_always))) ||
+   (!MapTypeModifierSpecified || MapTypeModifier == OMPC_MAP_always)) ||
   ((Kind == OMPC_depend) && DepKind != OMPC_DEPEND_unknown);
   const bool MayHaveTail = (Kind == OMPC_linear || Kind == OMPC_aligned);
   while (IsComma || (Tok.isNot(tok::r_paren) && Tok.isNot(tok::colon) &&

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=265918&r1=265917&r2=265918&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Apr 11 03:26:13 2016
@@ -1828,8 +1828,7 @@ bool Sema::IsIntegralPromotion(Expr *Fro
 (FromType->isSignedIntegerType() ||
  // We can promote any unsigned integer type whose size is
  // less than int to an int.
- (!FromType->isSignedIntegerType() &&
-  Context.getTypeSize(FromType) < Context.getTypeSize(ToType {
+ Context.getTypeSize(FromType) < Context.getTypeSize(ToType))) {
   return To->getKind() == BuiltinType::Int;
 }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp?rev=265918&r1=265917&r2=265918&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp Mon Apr 
11 03:26:13 2016
@@ -582,8 +582,7 @@ void IvarInvalidationCheckerImpl::Method
 // If InvalidationMethod is present, we are processing the message send and
 // should ensure we are invalidating with the appropriate method,
 // otherwise, we are processing setting to 'nil'.
-if (!InvalidationMethod ||
-(InvalidationMethod && I->second.hasMethod(InvalidationMethod)))
+if (!InvalidationMethod || I->second.hasMethod(InvalidationMethod))
   IVars.erase(I);
   }
 }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=265918&r1=265917&r2=265918&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Mon Apr 11 03:26:13 2016
@@ -1130,11 +1130,10 @@ void invalidateRegionsWorker::VisitClust
 // Check offset is not symbolic and within array's boundaries.
 // Handles arrays of 0 elements and of 0-sized elements as well.
 if (!ROffset ||
-(ROffset &&
- ((*ROffset >= LowerOffset && *ROffset < UpperOffset) ||
-  (UpperOverflow &&
-   (*ROffset >= LowerOffset || *ROffset < UpperOffset)) ||
-  (LowerOffset == UpperOffset && *ROffset == Lower

Re: [PATCH] D18950: clang-format: [JS] Test for parameter annotations.

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

LG.


http://reviews.llvm.org/D18950



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


Re: [PATCH] D18950: clang-format: [JS] Test for parameter annotations.

2016-04-11 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265922: clang-format: [JS] Test for parameter annotations. 
(authored by mprobst).

Changed prior to commit:
  http://reviews.llvm.org/D18950?vs=53201&id=53205#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18950

Files:
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -936,6 +936,9 @@
"return 'y';\n"
"  }\n"
"}");
+  verifyFormat("class C {\n"
+   "  private x(@A x: string) {}\n"
+   "}");
   verifyFormat("class X {}\n"
"class Y {}");
 }


Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -936,6 +936,9 @@
"return 'y';\n"
"  }\n"
"}");
+  verifyFormat("class C {\n"
+   "  private x(@A x: string) {}\n"
+   "}");
   verifyFormat("class X {}\n"
"class Y {}");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r265926 - Don't clutter the test directory with temporary IR files.

2016-04-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 11 05:16:37 2016
New Revision: 265926

URL: http://llvm.org/viewvc/llvm-project?rev=265926&view=rev
Log:
Don't clutter the test directory with temporary IR files.

-emit-llvm emits a file, -emit-llvm-only doesn't.

Modified:
cfe/trunk/test/Sema/attr-ifunc.c

Modified: cfe/trunk/test/Sema/attr-ifunc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ifunc.c?rev=265926&r1=265925&r2=265926&view=diff
==
--- cfe/trunk/test/Sema/attr-ifunc.c (original)
+++ cfe/trunk/test/Sema/attr-ifunc.c Mon Apr 11 05:16:37 2016
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm 
-DCHECK_ALIASES %s
-// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
-DCHECK_ALIASES %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only 
%s
 
 #if defined(_WIN32)
 void foo() {}


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


r265928 - [Clang][AVX512][BuiltIn] Adding avx512 ( ptest{n}m{b|w}{128|256|512} ) builtin to clang

2016-04-11 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 11 05:22:07 2016
New Revision: 265928

URL: http://llvm.org/viewvc/llvm-project?rev=265928&view=rev
Log:
[Clang][AVX512][BuiltIn] Adding avx512 ( ptest{n}m{b|w}{128|256|512} ) builtin 
to clang 

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-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=265928&r1=265927&r2=265928&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 11 05:22:07 2016
@@ -1868,6 +1868,28 @@ TARGET_BUILTIN(__builtin_ia32_vpermilvar
 TARGET_BUILTIN(__builtin_ia32_vpermilvarpd256_mask, 
"V4dV4dV4LLiV4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermilvarps_mask, 
"V4fV4fV4iV4fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpermilvarps256_mask, 
"V8fV8fV8iV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmb512, "ULLiV64cV64cULLi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_ptestmw512, "UiV32sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_ptestnmb512, "ULLiV64cV64cULLi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_ptestnmw512, "UiV32sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_ptestmb128, 
"UsV16cV16cUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmb256, 
"UiV32cV32cUi","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmw128, "UcV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmw256, 
"UsV16sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmb128, 
"UsV16cV16cUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmb256, 
"UiV32cV32cUi","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmw128, "UcV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmw256, 
"UsV16sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmd128, "UcV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmd256, "UcV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmq128, "UcV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestmq256, "UcV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmd128, "UcV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmd256, "UcV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmq128, "UcV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmq256, "UcV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_ptestnmd512, "UsV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_ptestnmq512, "UcV8LLiV8LLiUc","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=265928&r1=265927&r2=265928&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Mon Apr 11 05:22:07 2016
@@ -1997,6 +1997,67 @@ _mm512_mask_storeu_epi8 (void *__P, __mm
  (__mmask64) __U);
 }
 
+static __inline__ __mmask64 __DEFAULT_FN_ATTRS
+_mm512_test_epi8_mask (__m512i __A, __m512i __B)
+{
+  return (__mmask64) __builtin_ia32_ptestmb512 ((__v64qi) __A,
+(__v64qi) __B,
+(__mmask64) -1);
+}
+
+static __inline__ __mmask64 __DEFAULT_FN_ATTRS
+_mm512_mask_test_epi8_mask (__mmask64 __U, __m512i __A, __m512i __B)
+{
+  return (__mmask64) __builtin_ia32_ptestmb512 ((__v64qi) __A,
+(__v64qi) __B, __U);
+}
+
+static __inline__ __mmask32 __DEFAULT_FN_ATTRS
+_mm512_test_epi16_mask (__m512i __A, __m512i __B)
+{
+  return (__mmask32) __builtin_ia32_ptestmw512 ((__v32hi) __A,
+(__v32hi) __B,
+(__mmask32) -1);
+}
+
+static __inline__ __mmask32 __DEFAULT_FN_ATTRS
+_mm512_mask_test_epi16_mask (__mmask32 __U, __m512i __A, __m512i __B)
+{
+  return (__mmask32) __builtin_ia32_ptestmw512 ((__v32hi) __A,
+(__v32hi) __B, __U);
+}
+
+static __inline__ __mmask64 __DEFAULT_FN_ATTRS
+_mm512_testn_epi8_mask (__m512i __A, __m512i __B)
+{
+  return (__mmask64) __builtin_ia32_ptestnmb512 ((__v64qi) __A,
+ (__v64qi) __B,
+ (__mmask64) -1);
+}
+
+static __inline__ __mmask64 __DEFAULT_FN_ATTRS
+_mm512_mask_testn_epi8_mask (__mmask64 __U, __m512i __A, __m512i __B)
+{
+  return (__mmask64) __builtin_ia32_ptestnmb512 ((__v64qi) __A,
+ (__v64qi) __B, __U

Re: [PATCH] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

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

I've just realized that the approach is artificially limited to just keeping 
track of the origin of the `Checks` option, while it could be easily extended 
to track the origin of all configuration items. What if instead of 
`std::vector CheckSources;` we introduce 
`std::vector> Sources;`? Then we could 
be able to find where a certain check option or an extra argument was 
introduced, for example. WDYT?



Comment at: clang-tidy/tool/ClangTidyMain.cpp:188
@@ -181,1 +187,3 @@
 
+static const char* CheckSourceTypeDefaultBinary = "clang-tidy binary";
+static const char* CheckSourceTypeCheckCommandLineOption =

One problem with this way of defining string constants is that they are not 
constants. `CheckSourceTypeDefaultBinary = "oops";` will work just fine. 
Instead, I prefer to use `constexpr char XXX[] = "...";` construct.


http://reviews.llvm.org/D18694



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


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-11 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Format/Format.h:800
@@ -793,1 +799,3 @@
 
+/// \brief Fix any erroneous/redundant code in the given \p Ranges in \p Code.
+///

Same as above, "fix" is probably not the right word. "cleanup" seems somewhat 
better. Here and everywhere else in this patch :-/.


Comment at: lib/Format/Format.cpp:1446
@@ -1445,3 +1445,3 @@
 
-class Formatter : public UnwrappedLineConsumer {
+class RangeManager {
 public:

Maybe call this AffectedRangeManager? That is the class's very specific purpose.


Comment at: lib/Format/Format.cpp:1590
@@ +1589,3 @@
+
+class CodeProcesser : public UnwrappedLineConsumer {
+public:

ioeric wrote:
> I'm not quite sure if the name is accurate. Do you have a better name?
I think the difficulty of finding a name somewhat stems from the fact that it 
does multiple things at once. I think the main purpose is to encapsulate the 
"flattening" of the different #if/#else branches in successive runs.

Manuel, do you have an idea for a good name here?


Comment at: lib/Format/Format.cpp:1607
@@ -1462,2 +1606,3 @@
 
-  tooling::Replacements format(bool *IncompleteFormat) {
+  tooling::Replacements format(bool *IncompleteFormat);
+

It feels like these two functions increase the coupling between Formatter/Fixer 
and CodeProcesser and aren't really necessary. Can you just inline them at the 
locations where they are called?


Comment at: lib/Format/Format.cpp:1669
@@ +1668,3 @@
+
+  friend class Formatter;
+  friend class Fixer;

Lets not have this access. Provide getters.


Comment at: lib/Format/Format.cpp:1908
@@ +1907,3 @@
+  int checkEmptyNamespace(unsigned CurrentLine) {
+if (AnnotatedLines[CurrentLine]->NamespaceEmptynessChecked)
+  return -1;

I see why you are doing it this way, but let me propose something else:

How about iterating over all of the lines for each thing to cleanup 
(namespaces, ctor-intializers, etc.). I don't think it makes a significant 
difference in the runtime. Then you can just skip all the lines that you have 
already looked at (i.e. the returned int).

Among other things, you can probably remove the duplication of the 
AnnotatedLines[CurrentLine]->startsWith(..) and maybe even the 
AnnotatedLine::Deleted field.


Comment at: lib/Format/FormatToken.h:283
@@ +282,3 @@
+  // \brief Fixer will set this to true if the token is going to be deleted.
+  bool Deleted = false;
+

Do you need this? Wouldn't it be enough to add them to the set of deleted 
tokens and mark them as Finalized?


http://reviews.llvm.org/D18551



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


r265934 - [clang-format] Walk backwards from end() instead of forwards from rend().

2016-04-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Apr 11 07:19:19 2016
New Revision: 265934

URL: http://llvm.org/viewvc/llvm-project?rev=265934&view=rev
Log:
[clang-format] Walk backwards from end() instead of forwards from rend().

This should've been forwards from rbegin(), reverse iterators are just
too confusing to be used by mere mortals. Fixes out-of-bounds walks over
the list.

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=265934&r1=265933&r2=265934&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Apr 11 07:19:19 2016
@@ -718,7 +718,7 @@ void UnwrappedLineParser::readTokenWithJ
   if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
 // If the token before the previous one is an '@', the previous token is an
 // annotation and can precede another identifier/value.
-const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+const FormatToken *PrePrevious = std::prev(Line->Tokens.end(), 2)->Tok;
 if (PrePrevious->is(tok::at))
   return;
   }


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


r265935 - [Clang][AVX512][BuiltIn] Adding avx512 ( punpck{h|l}{dq|qdq}{128|256|512}, rndscale{ss|sd}, {scalef{ss|sd|pd512|ps512} ) builtin to clang

2016-04-11 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 11 07:32:31 2016
New Revision: 265935

URL: http://llvm.org/viewvc/llvm-project?rev=265935&view=rev
Log:
[Clang][AVX512][BuiltIn] Adding avx512 ( 
punpck{h|l}{dq|qdq}{128|256|512},rndscale{ss|sd}, {scalef{ss|sd|pd512|ps512} ) 
builtin to clang

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


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=265935&r1=265934&r2=265935&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 11 07:32:31 2016
@@ -1890,6 +1890,24 @@ TARGET_BUILTIN(__builtin_ia32_ptestnmq12
 TARGET_BUILTIN(__builtin_ia32_ptestnmq256, "UcV4LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_ptestnmd512, "UsV16iV16iUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_ptestnmq512, "UcV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_punpckhdq512_mask, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_punpckhqdq512_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_punpckldq512_mask, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_punpcklqdq512_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_punpckhdq128_mask, 
"V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpckhdq256_mask, 
"V8iV8iV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpckhqdq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpckhqdq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpckldq128_mask, 
"V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpckldq256_mask, 
"V8iV8iV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpcklqdq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_punpcklqdq256_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_rndscalesd_round_mask, 
"V2dV2dV2dV2dUcIiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_rndscaless_round_mask, 
"V4fV4fV4fV4fUcIiIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_scalefpd512_mask, 
"V8dV8dV8dV8dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_scalefps512_mask, 
"V16fV16fV16fV16fUsIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_scalefsd_round_mask, 
"V2dV2dV2dV2dUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_scalefss_round_mask, 
"V4fV4fV4fV4fUcIi","","avx512f")
 
 #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=265935&r1=265934&r2=265935&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Apr 11 07:32:31 2016
@@ -3995,6 +3995,15 @@ _mm512_mask2_permutex2var_epi32 (__m512i
(__v16si) __B,
(__mmask16) __U);
 }
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_unpackhi_epi32 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_punpckhdq512_mask ((__v16si) __A,
+ (__v16si) __B,
+ (__v16si)
+ _mm512_setzero_si512 (),
+ (__mmask16) -1);
+}
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 _mm512_maskz_unpackhi_pd (__mmask8 __U, __m512d __A, __m512d __B)
@@ -4449,6 +4458,422 @@ _mm512_mask_testn_epi64_mask (__mmask8 _
 }
 
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_unpackhi_epi32 (__m512i __W, __mmask16 __U, __m512i __A,
+  __m512i __B)
+{
+  return (__m512i) __builtin_ia32_punpckhdq512_mask ((__v16si) __A,
+ (__v16si) __B,
+ (__v16si) __W,
+ (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_unpackhi_epi32 (__mmask16 __U, __m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_punpckhdq512_mask ((__v16si) __A,
+ (__v16si) __B,
+ (__v16si)
+ _mm512_setzero_si512 (),
+ (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_unpackhi_epi64 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_punpckhqdq512_mask ((__v8di) __A,
+  (__v8di) __B,
+  (__v8di)
+  _mm512_setzero_si512 (),
+  (__mmask8) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_unpackhi_epi64 (__m512i __W, __mmask8 __U, __m512i __A, __m512i 
__B)
+{
+  return (__m512i)

r265922 - clang-format: [JS] Test for parameter annotations.

2016-04-11 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Apr 11 04:17:57 2016
New Revision: 265922

URL: http://llvm.org/viewvc/llvm-project?rev=265922&view=rev
Log:
clang-format: [JS] Test for parameter annotations.

Summary: Just to ensure no regressions, this already works fine.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

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

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=265922&r1=265921&r2=265922&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Apr 11 04:17:57 2016
@@ -936,6 +936,9 @@ TEST_F(FormatTestJS, MetadataAnnotations
"return 'y';\n"
"  }\n"
"}");
+  verifyFormat("class C {\n"
+   "  private x(@A x: string) {}\n"
+   "}");
   verifyFormat("class X {}\n"
"class Y {}");
 }


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


[PATCH] D18957: clang-rename: add missing newline at the end of 'found name:'

2016-04-11 Thread Miklos Vajna via cfe-commits
vmiklos created this revision.
vmiklos added a reviewer: klimek.
vmiklos added a subscriber: cfe-commits.

This makes it easier for external tools to parse lines starting with 
clang-rename, as 'renamed at:' lines already end with a newline.

http://reviews.llvm.org/D18957

Files:
  clang-rename/tool/ClangRename.cpp

Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -108,7 +108,7 @@
 exit(1);
 
   if (PrintName)
-errs() << "clang-rename: found name: " << PrevName;
+errs() << "clang-rename: found name: " << PrevName << "\n";
 
   // Perform the renaming.
   rename::RenamingAction RenameAction(NewName, PrevName, USRs,


Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -108,7 +108,7 @@
 exit(1);
 
   if (PrintName)
-errs() << "clang-rename: found name: " << PrevName;
+errs() << "clang-rename: found name: " << PrevName << "\n";
 
   // Perform the renaming.
   rename::RenamingAction RenameAction(NewName, PrevName, USRs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r265916 - clang-format: [JS] do not insert semicolons after wrapped annotations.

2016-04-11 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Apr 11 02:35:57 2016
New Revision: 265916

URL: http://llvm.org/viewvc/llvm-project?rev=265916&view=rev
Log:
clang-format: [JS] do not insert semicolons after wrapped annotations.

Reviewers: djasper

Subscribers: klimek

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

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=265916&r1=265915&r2=265916&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Apr 11 02:35:57 2016
@@ -715,6 +715,13 @@ void UnwrappedLineParser::readTokenWithJ
 return;
 
   bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+  if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
+// If the token before the previous one is an '@', the previous token is an
+// annotation and can precede another identifier/value.
+const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+if (PrePrevious->is(tok::at))
+  return;
+  }
   if (Next->is(tok::exclaim) && PreviousMustBeValue)
 addUnwrappedLine();
   bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=265916&r1=265915&r2=265916&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Apr 11 02:35:57 2016
@@ -686,6 +686,8 @@ TEST_F(FormatTestJS, AutomaticSemicolonI
   verifyFormat("x instanceof String", "x\n"
   "instanceof\n"
   "String");
+  verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
+  "  bar) {}");
 }
 
 TEST_F(FormatTestJS, ClosureStyleCasts) {


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


[PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki created this revision.
pilki added a reviewer: alexfh.
pilki added a subscriber: cfe-commits.

Checks if constructors and assignment operators that are marked '= default' are 
actually deleted by the compiler.

http://reviews.llvm.org/D18961

Files:
   clang-tidy/readability/CMakeLists.txt
   clang-tidy/readability/DeletedDefaultCheck.cpp
   clang-tidy/readability/DeletedDefaultCheck.h
   clang-tidy/readability/ReadabilityTidyModule.cpp
   docs/clang-tidy/checks/list.rst
   docs/clang-tidy/checks/readability-deleted-default.rst
   test/clang-tidy/readability-deleted-default.cpp

Index:  test/clang-tidy/readability-deleted-default.cpp
===
---  test/clang-tidy/readability-deleted-default.cpp
+++  test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,103 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault&& Other) = delete;
+  NoDefault(const NoDefault& Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: this default constructor is marked '= default' but is actually implicitly deleted
+  MissingEverything(MissingEverything&& Other) = default;
+  // CHECK-MESSAGES: warning: this move constructor is marked '= default' but is actually implicitly deleted
+  MissingEverything(const MissingEverything& Other) = default;
+  // CHECK-MESSAGES: warning: this copy constructor is marked '= default' but is actually implicitly deleted
+  MissingEverything& operator=(MissingEverything&& Other) = default;
+  // CHECK-MESSAGES: warning: this move assignment operator is marked '= default' but is actually implicitly deleted
+  MissingEverything& operator=(const MissingEverything& Other) = default;
+  // CHECK-MESSAGES: warning: this copy assignment operator is marked '= default' but is actually implicitly deleted
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable&& Other) = default;
+  NotAssignable(const NotAssignable& Other) = default;
+  NotAssignable& operator=(NotAssignable&& Other) = default;
+  // CHECK-MESSAGES: warning: this move assignment operator is marked '= default' but is actually implicitly deleted
+  NotAssignable& operator=(const NotAssignable& Other) = default;
+  // CHECK-MESSAGES: warning: this copy assignment operator is marked '= default' but is actually implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable&& Other) = default;
+  Movable(const Movable& Other) = delete;
+  Movable& operator=(Movable&& Other) = default;
+  Movable& operator=(const Movable& Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable&& Other) = default;
+  NotCopyable(const NotCopyable& Other) = default;
+  // CHECK-MESSAGES: warning: this copy constructor is marked '= default' but is actually implicitly deleted
+  NotCopyable& operator=(NotCopyable&& Other) = default;
+  NotCopyable& operator=(const NotCopyable& Other) = default;
+  // CHECK-MESSAGES: warning: this copy assignment operator is marked '= default' but is actually implicitly deleted
+private:
+  Movable M;
+};
+
+template 
+class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated&& Other) = default;
+  Templated(const Templated& Other) = default;
+  Templated& operator=(Templated&& Other) = default;
+  Templated& operator=(const Templated& Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated&& Other) = default;
+InnerTemplated(const InnerTemplated& Other) = default;
+InnerTemplated& operator=(InnerTemplated&& Other) = default;
+InnerTemplated& operator=(const InnerTemplated& Other) = default;
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically have warnings, but currently doesn't.
+InnerNotTemplated() = default;
+InnerNotTemplated(InnerNotTemplated&& Other) = default;
+InnerNotTemplated(const InnerNotTemplated& Other) = default;
+InnerNotTemplated& operator=(InnerNotTemplated&& Other) = default;
+InnerNotTemplated& operator=(const InnerNotTemplated& Other) = default;
+  private:
+int I;
+  };
+
+private:
+  const T TVar{};
+};
+
+void Foo() {
+ Templated V1;
+ Templated::InnerTemplated V2;
+ Templated::InnerNotTemplated V3;
+}
Index:  docs/clang-tidy/checks/readability-deleted-default.rst
===
---  docs/clang-tidy/checks/readability-deleted-default.rst
+++  docs/clang-tidy/checks/readability-deleted-default.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - readability-deleted-default
+
+readability-deleted-default
+===

[PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-04-11 Thread Andrew V. Tischenko via cfe-commits
avt77 created this revision.
avt77 added a reviewer: rnk.
avt77 added a subscriber: cfe-commits.
avt77 changed the visibility of this Differential Revision from "Public (No 
Login Required)" to "All Users".

If we have some function with dllimport attribute and then we have the function 
definition in the same module but without dllimport attribute we should add 
dllexport attribute to this function definition. The same should be done for 
variables. Example:

struct __declspec(dllimport) C3 {
   ~C3();
};

C3::~C3() {;} // we should export this definition

http://reviews.llvm.org/D18953

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CodeGen/dllimport.c
  test/CodeGenCXX/dllimport-members.cpp
  test/CodeGenCXX/dllimport.cpp
  test/Sema/dllimport.c
  test/SemaCXX/dllimport.cpp

Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5504,9 +5504,13 @@
 
 static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl,
NamedDecl *NewDecl,
-   bool IsSpecialization) {
-  if (TemplateDecl *OldTD = dyn_cast(OldDecl))
+   bool IsSpecialization,
+   bool IsDefinition = false) {
+  if (TemplateDecl *OldTD = dyn_cast(OldDecl)) {
 OldDecl = OldTD->getTemplatedDecl();
+if (!IsSpecialization)
+  IsDefinition = false;
+  }
   if (TemplateDecl *NewTD = dyn_cast(NewDecl))
 NewDecl = NewTD->getTemplatedDecl();
 
@@ -5563,29 +5567,49 @@
   // A redeclaration is not allowed to drop a dllimport attribute, the only
   // exceptions being inline function definitions, local extern declarations,
   // and qualified friend declarations.
-  // NB: MSVC converts such a declaration to dllexport.
+  // NB: MSVC converts such a declaration to dllexport that's why we do it also.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  if (const auto *VD = dyn_cast(NewDecl))
+  bool isMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+  if (const auto *VD = dyn_cast(NewDecl)) {
 // Ignore static data because out-of-line definitions are diagnosed
 // separately.
 IsStaticDataMember = VD->isStaticDataMember();
+IsDefinition =
+  !VD->isThisDeclarationADefinition(S.Context) == VarDecl::DeclarationOnly;
+  }
   else if (const auto *FD = dyn_cast(NewDecl)) {
 IsInline = FD->isInlined();
 IsQualifiedFriend = FD->getQualifier() &&
 FD->getFriendObjectKind() == Decl::FOK_Declared;
   }
 
   if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
   !NewDecl->isLocalExternDecl() && !IsQualifiedFriend) {
-S.Diag(NewDecl->getLocation(),
-   diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
-  << NewDecl << OldImportAttr;
-S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
-S.Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
-OldDecl->dropAttr();
-NewDecl->dropAttr();
-  } else if (IsInline && OldImportAttr &&
- !S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+if (isMicrosoft && IsDefinition) {
+  S.Diag(NewDecl->getLocation(),
+ diag::warn_redeclaration_without_import_attribute) << NewDecl;
+  S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
+  S.Diag(OldImportAttr->getLocation(),
+ diag::note_previous_attribute_replaced);
+  // Replace DLLImportAttr with DLLExportAttr
+  OldDecl->dropAttr();
+  NewDecl->dropAttr();
+  OldDecl->addAttr(::new (S.Context) DLLExportAttr(
+  OldImportAttr->getRange(), S.Context,
+  OldImportAttr->getSpellingListIndex()));
+  NewDecl->addAttr(::new (S.Context) DLLExportAttr(
+  NewImportAttr->getRange(), S.Context,
+  NewImportAttr->getSpellingListIndex()));
+} else {
+  S.Diag(NewDecl->getLocation(),
+ diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
+  << NewDecl << OldImportAttr;
+  S.Diag(OldDecl->getLocation(), diag::note_previous_declaration);
+  S.Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
+  OldDecl->dropAttr();
+  NewDecl->dropAttr();
+}
+  } else if (IsInline && OldImportAttr && !isMicrosoft) {
 // In MinGW, seeing a function declared inline drops the dllimport attribute.
 OldDecl->dropAttr();
 NewDecl->dropAttr();
@@ -6369,7 +6393,8 @@
   if (D.isRedeclaration() && !Previous.empty()) {
 checkDLLAttributeRedeclaration(
 *this, dyn_cast(Previous.getRepresentativeDecl()), NewVD,
-IsExplicitSpecialization);
+IsExplicitSpecialization,
+D.isFunctionDefinition());
   }
 
   if (NewTemplate) {
@@ -8368,7 +8393,8 @@
   if (D.isRedeclaration() && !Prev

[PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread silviu.bara...@arm.com via cfe-commits
sbaranga created this revision.
sbaranga added a reviewer: t.p.northover.
sbaranga added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

According to the ACLE spec, "__ARM_FEATURE_FMA is defined to 1 if
the hardware floating-point architecture supports fused floating-point
multiply-accumulate".

This changes clang's behaviour from emitting this macro for v7-A and v7-R
cores to only emitting it when the target has VFPv4 (and therefore support
for the floating point multiply-accumulate instruction).

Fixes PR27216

http://reviews.llvm.org/D18963

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-neon-fma.c
  test/Preprocessor/arm-acle-6.5.c
  test/Sema/arm_vfma.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4927,7 +4927,8 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM") &&
+(FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
Index: test/CodeGen/arm-neon-fma.c
===
--- test/CodeGen/arm-neon-fma.c
+++ test/CodeGen/arm-neon-fma.c
@@ -3,6 +3,7 @@
 // RUN:   -target-cpu cortex-a8 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
+// RUN:   -target-feature +vfp4 \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
 
 #include 
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=neon-vfpv4 -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7r-eabi -mfpu=neon-vfpv4 -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-FMA
 // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv8-eabi -mfpu=neon-vfpv4 -x c -E -dM %s -o - | 
FileCheck %s -check-prefix CHECK-FMA
 
 // CHECK-FMA: __ARM_FEATURE_FMA 1
 
Index: test/Sema/arm_vfma.c
===
--- test/Sema/arm_vfma.c
+++ test/Sema/arm_vfma.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 
 
 // expected-no-diagnostics


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4927,7 +4927,8 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM") &&
+(FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
Index: test/CodeGen/arm-neon-fma.c
===
--- test/CodeGen/arm-neon-fma.c
+++ test/CodeGen/arm-neon-fma.c
@@ -3,6 +3,7 @@
 // RUN:   -target-cpu cortex-a8 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
+// RUN:   -target-feature +vfp4 \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
 
 #include 
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=neon-vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN:

Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread Renato Golin via cfe-commits
rengolin added a reviewer: rengolin.


Comment at: lib/Basic/Targets.cpp:4931
@@ -4931,1 +4930,3 @@
+if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM") &&
+(FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");

I think just two checks are necessary, here:

(FPU & VFPV4FPU) || (ArchVersion > 7)

and make sure that the right FPU flag is set from the right cores, plus "+vfp4".


Comment at: test/CodeGen/arm-neon-fma.c:6
@@ -5,2 +5,3 @@
 // RUN:   -ffreestanding \
+// RUN:   -target-feature +vfp4 \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s

why not change the cpu to a core that has vfp4?

I know the test is about FMA, not the CPU, but this is a combination that will 
never occur in the wild...


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 

It's possible that v7 Apple cores always have FMA? I'd make sure of that before 
forcing the flag here. We don't want to disable it inadvertently.

@t.p.northover, can you confirm Apple's support for VFP4?


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

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


Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:157
@@ +156,3 @@
+// Convenience utility to get a RecordDecl from a QualType.
+const RecordDecl *getRecordDecl(const QualType &Type) {
+  if (const auto *RT = Type.getCanonicalType()->getAs())

`getCanonicalRecordDecl()` instead? (Otherwise, this suggests the function 
could be replaced with `Type->getCXXRecordDecl()` at the call site, but that's 
not quite right because this function canonicalizes the type first.)


Comment at: clang-tidy/utils/Matchers.h:31
@@ +30,3 @@
+
+AST_MATCHER(CXXConstructorDecl, isUserProvided) {
+  return Node.isUserProvided();

This should go into clang\include\clang\ASTMatchers\ASTMatchers.h instead. When 
added there, it should get doxygen comments, appropriate test cases in 
clang\unittests\ASTMatchers\ASTMatchersTest.cpp, and then you should regenerate 
the online documentation by running clang\docs\tools\dump_ast_matchers.py.


Comment at: clang-tidy/utils/Matchers.h:35
@@ +34,3 @@
+
+AST_MATCHER(CXXConstructorDecl, isDelegatingConstructor) {
+  return Node.isDelegatingConstructor();

Same for this one.


http://reviews.llvm.org/D18584



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:26
@@ +25,3 @@
+void DeletedDefaultCheck::registerMatchers(MatchFinder *Finder) {
+  const auto NotTemplate = unless(hasAncestor(
+  cxxRecordDecl(::clang::ast_matchers::isTemplateInstantiation(;

`unless(isInTemplateInstantiation())` is the canonical way to do this.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:30
@@ +29,3 @@
+  // We should actually use isExplicitlyDefaulted, but it does not exist.
+  Finder->addMatcher(
+  cxxConstructorDecl(isDefaultConstructor(), isExplicitlyDefaulted(),

I think, we need at most two matchers here: one for constructors and one for 
assignment operators. We could also cram these into a single matcher. I also 
suggest to combine the `diag()` calls to a single one using `%N` or 
`%select{}N` format to parametrize the message. Something along the lines of:

  Finder->addMatcher(cxxMethodDecl(isDefaulted(), isDeleted(), 
unless(isImplicit()), unless(isInTemplateInstantiation()),
  anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator(), 
cxxConstructorDecl().bind("ctor"))).bind("method"));

  ...
  const auto *Method = Result.Nodes.getNodeAs("method");
  assert(Method != nullptr);
  diag(Method->getLocStart(),
 "this %select{method|constructor}0 is marked '= default' but is 
actually "
 "implicitly deleted, probably because an instance variable or a base "
 "class is not copyable nor movable; this definition should either be 
removed "
 "or explicitly marked as '= delete'") << 
(Result.Nodes.getNodeAs("ctor") ? 1 : 0);

If you think that adding "copy", "move" or "default" makes the message any 
better, this could also be accommodated in this approach.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:31
@@ +30,3 @@
+  Finder->addMatcher(
+  cxxConstructorDecl(isDefaultConstructor(), isExplicitlyDefaulted(),
+ isDeleted(), NotTemplate)

Alternatively, you can use `isDefaulted(), unless(isImplicit())`.


Comment at:  test/clang-tidy/readability-deleted-default.cpp:13
@@ +12,3 @@
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: this default constructor is marked '= default' 
but is actually implicitly deleted
+  MissingEverything(MissingEverything&& Other) = default;

Please specify the message completely once.


http://reviews.llvm.org/D18961



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


Re: r259734 - Fix predefine for __NSConstantString struct type

2016-04-11 Thread Ben Langmuir via cfe-commits

> On Apr 3, 2016, at 10:57 AM, Yaron Keren  wrote:
> 
> I look at many AST dumps for small reduced code so it's mostly weird to see 
> this in the AST (and takes a bit of screen real estate) as it's not something 
> that originated in the code. 
> By now I'm used to ignoring it but would expect NSConstantString would baffle 
> new clang programmers. It would be nice if we won't see it...
> How is NSConstantString used outside ObjectiveC ?

A builtin that uses this type is exposed as the CFSTR() macro in CoreFoundation 
on Darwin platforms - this is a C framework that needs to be usable from C, 
Objective C and C++.

Sorry for the slow reply!

> 
> 
> 
> 
> 2016-04-03 20:39 GMT+03:00 Ben Langmuir  >:
> This type and the builtin it supports needs to work in C/C++ as well, not 
> just Objective-C.   Are you running into a problem here, or is it just 
> “weird” to see it in the AST?
> 
>> On Apr 3, 2016, at 5:21 AM, Yaron Keren > > wrote:
>> 
>> +1, if possible. There is a if (getLangOpts().ObjC1) block just before this.
>> 
>> 2016-04-03 14:21 GMT+03:00 Vassil Vassilev via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>>:
>> On 04/02/16 01:55, Ben Langmuir via cfe-commits wrote:
>> Author: benlangmuir
>> Date: Wed Feb  3 18:55:24 2016
>> New Revision: 259734
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=259734&view=rev 
>> 
>> Log:
>> Fix predefine for __NSConstantString struct type
>> 
>> Per review feedback the name was wrong and it can be used outside
>> Objective-C.
>> 
>> Unfortunately, making the internal struct visible broke some ASTMatchers
>> tests that assumed that the first record decl would be from user code,
>> rather than a builtin type.  I'm worried that this will also affect
>> users' code.  So this patch adds a typedef to wrap the internal struct
>> and only makes the typedef visible to namelookup.  This is sufficient to
>> allow the ASTReader to merge the decls we need without making the struct
>> itself visible.
>> 
>> rdar://problem/24425801 <>
>> 
>> Modified:
>>  cfe/trunk/include/clang/AST/ASTContext.h
>>  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>  cfe/trunk/lib/AST/ASTContext.cpp
>>  cfe/trunk/lib/Sema/Sema.cpp
>>  cfe/trunk/lib/Serialization/ASTReader.cpp
>>  cfe/trunk/lib/Serialization/ASTWriter.cpp
>>  cfe/trunk/test/CodeGenObjC/2010-02-01-utf16-with-null.m
>>  cfe/trunk/test/CodeGenObjC/arc-no-arc-exceptions.m
>>  cfe/trunk/test/CodeGenObjC/tentative-cfconstantstring.m
>>  cfe/trunk/test/Modules/Inputs/builtin.h
>>  cfe/trunk/test/Modules/builtins.m
>> 
>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=259734&r1=259733&r2=259734&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Feb  3 18:55:24 2016
>> @@ -253,8 +253,9 @@ class ASTContext : public RefCountedBase
>> mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
>>   QualType ObjCConstantStringType;
>> -  mutable RecordDecl *CFConstantStringTypeDecl;
>> -
>> +  mutable RecordDecl *CFConstantStringTagDecl;
>> +  mutable TypedefDecl *CFConstantStringTypeDecl;
>> +
>> mutable QualType ObjCSuperType;
>> QualType ObjCNSStringType;
>> @@ -1381,11 +1382,12 @@ public:
>> /// if it hasn't yet been built.
>> QualType getRawCFConstantStringType() const {
>>   if (CFConstantStringTypeDecl)
>> -  return getTagDeclType(CFConstantStringTypeDecl);
>> +  return getTypedefType(CFConstantStringTypeDecl);
>>   return QualType();
>> }
>> void setCFConstantStringType(QualType T);
>> -  TagDecl *getCFConstantStringDecl() const;
>> +  TypedefDecl *getCFConstantStringDecl() const;
>> +  RecordDecl *getCFConstantStringTagDecl() const;
>>   // This setter/getter represents the ObjC type for an NSConstantString.
>> void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl);
>> 
>> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=259734&r1=259733&r2=259734&view=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Feb  3 18:55:24 
>> 2016
>> @@ -988,15 +988,18 @@ namespace clang {
>> /// \brief The internal '__make_integer_

Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread silviu.bara...@arm.com via cfe-commits
sbaranga added inline comments.


Comment at: lib/Basic/Targets.cpp:4931
@@ -4931,1 +4930,3 @@
+if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM") &&
+(FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");

rengolin wrote:
> I think just two checks are necessary, here:
> 
> (FPU & VFPV4FPU) || (ArchVersion > 7)
> 
> and make sure that the right FPU flag is set from the right cores, plus 
> "+vfp4".
Yes, that should be sufficient.


Comment at: test/CodeGen/arm-neon-fma.c:6
@@ -5,2 +5,3 @@
 // RUN:   -ffreestanding \
+// RUN:   -target-feature +vfp4 \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s

rengolin wrote:
> why not change the cpu to a core that has vfp4?
> 
> I know the test is about FMA, not the CPU, but this is a combination that 
> will never occur in the wild...
Sure, good point.


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 

rengolin wrote:
> It's possible that v7 Apple cores always have FMA? I'd make sure of that 
> before forcing the flag here. We don't want to disable it inadvertently.
> 
> @t.p.northover, can you confirm Apple's support for VFP4?
If they do support it and don't have the vfp4 feature, then before this patch 
clang/llvm wouldn't have emitted a fma/vfma instruction anyway in any 
circumstances (because the backend will not generate it). The backend would 
instead legalize it with fmaf() libcalls - but that's not the correct behaviour 
according to the spec.


http://reviews.llvm.org/D18963



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


Re: [PATCH] D15032: [clang-tidy] new checker cppcoreguidelines-pro-lifetime

2016-04-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Thank you for working on this! A few initial nits (I don't have the chance to 
complete the review yet, but wanted to get you some early feedback).



Comment at: clang-tidy/cppcoreguidelines/ProLifetimeCheck.cpp:34-35
@@ +33,4 @@
+
+  Finder->addMatcher(functionDecl().bind("fun"), this);
+  Finder->addMatcher(varDecl(hasGlobalStorage()).bind("globalVar"), this);
+}

These can be combined into a single matcher using anyOf() (should be slightly 
more efficient than registering two separate matchers).


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeCheck.h:18
@@ +17,3 @@
+
+/// FIXME: Write a short description.
+///

Should write that short description. :-)


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:94-97
@@ +93,6 @@
+  Pointer(const FieldDecl *FD) : FD(FD) { assert(FD); }
+  Pointer(Pointer &&) = default;
+  Pointer &operator=(Pointer &&) = default;
+  Pointer(const Pointer &) = default;
+  Pointer &operator=(const Pointer &) = default;
+

I don't believe there's a need to explicitly default these (here and 
elsewhere), so they should just be removed.


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:99-101
@@ +98,5 @@
+
+  bool operator==(const Pointer &o) const { return VD == o.VD && FD == o.FD; }
+  bool operator!=(const Pointer &o) const { return !(*this == o); }
+  bool operator<(const Pointer &o) const {
+if (VD != o.VD)

Should be `O` instead of `o` per our usual conventions, here and elsewhere.


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:103-104
@@ +102,4 @@
+if (VD != o.VD)
+  return VD < o.VD;
+return FD < o.FD;
+  }

I would feel more comfortable using `std::les<>` for this to avoid comparisons 
between unrelated pointers not having a total ordering.


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:121
@@ +120,3 @@
+  /// Returns true if this pointer is a member variable of the class of the
+  /// current method
+  bool isMemberVariable() const { return FD; }

Comments should be properly punctuated (here and elsewhere).


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:153
@@ +152,3 @@
+
+  // static bool is(const ValueDecl *VD) { return get(VD).hasValue(); }
+

Should remove this instead of leaving it commented out.


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:178
@@ +177,3 @@
+class Owner {
+  enum SpecialType { VARDECL = 0, NULLPTR = 1, STATIC = 2, TEMPORARY = 3 };
+

Don't use all caps for enumerators (that's generally reserved for just macros 
by our conventions), here and elsewhere.


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:229
@@ +228,3 @@
+  return Pointer::get(VD.getPointer());
+return Optional();
+  }

I think this should return None instead.


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:548-549
@@ +547,4 @@
+  /// IgnoreParenImpCasts - Ignore parentheses and implicit casts.  Strip off
+  /// any ParenExpr
+  /// or ImplicitCastExprs, returning their operand.
+  /// Does not ignore MaterializeTemporaryExpr as Expr::IgnoreParenImpCasts

Reformat the comment to fit a bit better?


Comment at: clang-tidy/cppcoreguidelines/ProLifetimeVisitor.cpp:552
@@ +551,3 @@
+  /// would.
+  const Expr *IgnoreParenImpCasts(const Expr *E) {
+while (true) {

Method can be `const` qualified.


http://reviews.llvm.org/D15032



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


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

The patch itself looks good to me but the main question do we want to support 
VLA in C++ in GNU extension mode.


http://reviews.llvm.org/D18823



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


Re: r265201 - [Objective-C] Introduce objc_runtime_visible attribute.

2016-04-11 Thread Aaron Ballman via cfe-commits
On Fri, Apr 1, 2016 at 7:23 PM, Douglas Gregor via cfe-commits
 wrote:
> Author: dgregor
> Date: Fri Apr  1 18:23:52 2016
> New Revision: 265201

Sorry about the long delay before getting you this feedback (been a
bit hectic around here). One request: can you add some Sema tests that
the attribute properly diagnoses? Tests for the wrong attribute
subject, attribute with arguments, etc all fail would be appreciated
(so we don't accidentally regress its behavior in the future).

Thanks!

~Aaron

>
> URL: http://llvm.org/viewvc/llvm-project?rev=265201&view=rev
> Log:
> [Objective-C] Introduce objc_runtime_visible attribute.
>
> The objc_runtime_visible attribute deals with an odd corner case where
> a particular Objective-C class is known to the Objective-C runtime
> (and, therefore, accessible by name) but its symbol has been hidden
> for some reason. For such classes, teach CodeGen to use
> objc_lookUpClass to retrieve the Class object, rather than referencing
> the class symbol directly.
>
> Classes annotated with objc_runtime_visible have two major limitations
> that fall out from places where Objective-C metadata needs to refer to
> the class (or metaclass) symbol directly:
>
> * One cannot implement a subclass of an objc_runtime_visible class.
> * One cannot implement a category on an objc_runtime_visible class.
>
> Implements rdar://problem/25494092.
>
> Added:
> cfe/trunk/test/CodeGenObjC/attr-objc-runtime-visible.m
> cfe/trunk/test/SemaObjC/attr-objc-runtime-visible.m
> Modified:
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>
> Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=265201&r1=265200&r2=265201&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Apr  1 18:23:52 2016
> @@ -1241,6 +1241,12 @@ def ObjCRuntimeName : Attr {
>let Documentation = [ObjCRuntimeNameDocs];
>  }
>
> +def ObjCRuntimeVisible : Attr {
> +  let Spellings = [GNU<"objc_runtime_visible">];
> +  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
> +  let Documentation = [ObjCRuntimeVisibleDocs];
> +}
> +
>  def ObjCBoxable : Attr {
>let Spellings = [GNU<"objc_boxable">];
>let Subjects = SubjectList<[Record], ErrorDiag, "ExpectedStructOrUnion">;
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=265201&r1=265200&r2=265201&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri Apr  1 18:23:52 2016
> @@ -612,6 +612,13 @@ can only be placed before an @protocol o
>  }];
>  }
>
> +def ObjCRuntimeVisibleDocs : Documentation {
> +let Category = DocCatFunction;
> +let Content = [{
> +This attribute specifies that the Objective-C class to which it applies is 
> visible to the Objective-C runtime but not to the linker. Classes annotated 
> with this attribute cannot be subclassed and cannot have categories defined 
> for them.
> +}];
> +}
> +
>  def ObjCBoxableDocs : Documentation {
>  let Category = DocCatFunction;
>  let Content = [{
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=265201&r1=265200&r2=265201&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr  1 18:23:52 
> 2016
> @@ -715,6 +715,12 @@ def err_objc_root_class_subclass : Error
>  def warn_objc_root_class_missing : Warning<
>"class %0 defined without specifying a base class">,
>InGroup;
> +def err_objc_runtime_visible_category : Error<
> +  "cannot implement a category for class %0 that is only visible via the "
> +  "Objective-C runtime">;
> +def err_objc_runtime_visible_subclass : Error<
> +  "cannot implement subclass %0 of a superclass %1 that is only visible via 
> the "
> +  "Objective-C runtime">;
>  def note_objc_needs_superclass : Note<
>"add a super class to fix this problem">;
>  def warn_dup_category_def : Warning<
>
> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=265201&r1=265200&r2=265201&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Aaron Ballman via cfe-commits
aaron.ballman added reviewers: rsmith, doug.gregor.
aaron.ballman added a comment.

Adding a few more reviewers.

Is there a major use case driving this patch, or is this just for GCC 
compatibility? Personally, I would prefer to avoid adding VLA support to C++ 
unless there's a good motivating use case, but would like to hear what Richard 
or Doug think on the subject.


http://reviews.llvm.org/D18823



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


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added inline comments.


Comment at: llvm/tools/clang/test/SemaCXX/c99-variable-length-array.cpp:1
@@ -1,1 +1,2 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wvla-extension %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -DCPP98 -verify -Wvla-extension %s
+// RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -DGNU98 -verify -Wvla-extension 
%s

rengolin wrote:
> are we not supporting this in c99 anymore?
No, it is C++ test due to file extension .cpp. So C99 mode shouldn't be 
affected as far as I understand (i.e. the test was never run in C99). Mode by 
default is gnu++98 where this patch enable VLA so some warnings/errors from 
this test are gone (-Wvla-extension).


http://reviews.llvm.org/D18823



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


Re: r259734 - Fix predefine for __NSConstantString struct type

2016-04-11 Thread Yaron Keren via cfe-commits
If used only for Darwin, could this depend
on Target.getTriple().isOSDarwin() ?


2016-04-11 17:18 GMT+03:00 Ben Langmuir :

>
> On Apr 3, 2016, at 10:57 AM, Yaron Keren  wrote:
>
> I look at many AST dumps for small reduced code so it's mostly weird to
> see this in the AST (and takes a bit of screen real estate) as it's not
> something that originated in the code.
> By now I'm used to ignoring it but would expect NSConstantString would
> baffle new clang programmers. It would be nice if we won't see it...
> How is NSConstantString used outside ObjectiveC ?
>
>
> A builtin that uses this type is exposed as the CFSTR() macro in
> CoreFoundation on Darwin platforms - this is a C framework that needs to be
> usable from C, Objective C and C++.
>
> Sorry for the slow reply!
>
>
>
>
>
> 2016-04-03 20:39 GMT+03:00 Ben Langmuir :
>
>> This type and the builtin it supports needs to work in C/C++ as well, not
>> just Objective-C.   Are you running into a problem here, or is it just
>> “weird” to see it in the AST?
>>
>> On Apr 3, 2016, at 5:21 AM, Yaron Keren  wrote:
>>
>> +1, if possible. There is a if (getLangOpts().ObjC1) block just before
>> this.
>>
>> 2016-04-03 14:21 GMT+03:00 Vassil Vassilev via cfe-commits <
>> cfe-commits@lists.llvm.org>:
>>
>>> On 04/02/16 01:55, Ben Langmuir via cfe-commits wrote:
>>>
 Author: benlangmuir
 Date: Wed Feb  3 18:55:24 2016
 New Revision: 259734

 URL: http://llvm.org/viewvc/llvm-project?rev=259734&view=rev
 Log:
 Fix predefine for __NSConstantString struct type

 Per review feedback the name was wrong and it can be used outside
 Objective-C.

 Unfortunately, making the internal struct visible broke some ASTMatchers
 tests that assumed that the first record decl would be from user code,
 rather than a builtin type.  I'm worried that this will also affect
 users' code.  So this patch adds a typedef to wrap the internal struct
 and only makes the typedef visible to namelookup.  This is sufficient to
 allow the ASTReader to merge the decls we need without making the struct
 itself visible.

 rdar://problem/24425801

 Modified:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenObjC/2010-02-01-utf16-with-null.m
  cfe/trunk/test/CodeGenObjC/arc-no-arc-exceptions.m
  cfe/trunk/test/CodeGenObjC/tentative-cfconstantstring.m
  cfe/trunk/test/Modules/Inputs/builtin.h
  cfe/trunk/test/Modules/builtins.m

 Modified: cfe/trunk/include/clang/AST/ASTContext.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=259734&r1=259733&r2=259734&view=diff

 ==
 --- cfe/trunk/include/clang/AST/ASTContext.h (original)
 +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Feb  3 18:55:24 2016
 @@ -253,8 +253,9 @@ class ASTContext : public RefCountedBase
 mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
   QualType ObjCConstantStringType;
 -  mutable RecordDecl *CFConstantStringTypeDecl;
 -
 +  mutable RecordDecl *CFConstantStringTagDecl;
 +  mutable TypedefDecl *CFConstantStringTypeDecl;
 +
 mutable QualType ObjCSuperType;
 QualType ObjCNSStringType;
 @@ -1381,11 +1382,12 @@ public:
 /// if it hasn't yet been built.
 QualType getRawCFConstantStringType() const {
   if (CFConstantStringTypeDecl)
 -  return getTagDeclType(CFConstantStringTypeDecl);
 +  return getTypedefType(CFConstantStringTypeDecl);
   return QualType();
 }
 void setCFConstantStringType(QualType T);
 -  TagDecl *getCFConstantStringDecl() const;
 +  TypedefDecl *getCFConstantStringDecl() const;
 +  RecordDecl *getCFConstantStringTagDecl() const;
   // This setter/getter represents the ObjC type for an
 NSConstantString.
 void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl);

 Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=259734&r1=259733&r2=259734&view=diff

 ==
 --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
 +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Feb  3
 18:55:24 2016
 @@ -988,15 +988,18 @@ namespace clang {
 /// \brief The internal '__make_integer_seq' template.
 PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 13,
   -  /// \brief The internal '__NS

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Renato Golin via cfe-commits
rengolin added a subscriber: rengolin.
rengolin added a comment.

En passant comment: I really wish we wouldn't.

The C++ standard had some very careful considerations on VLAs and decided *not* 
to support. It wasn't for lack of interest, it was a well informed decision.



Comment at: llvm/tools/clang/test/SemaCXX/c99-variable-length-array.cpp:1
@@ -1,1 +1,2 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wvla-extension %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -DCPP98 -verify -Wvla-extension %s
+// RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -DGNU98 -verify -Wvla-extension 
%s

are we not supporting this in c99 anymore?


Comment at: llvm/tools/clang/test/SemaCXX/vla.cpp:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++98 -verify %s
 

doesn't this remove the test for support for it in c99?


http://reviews.llvm.org/D18823



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:82
@@ +81,3 @@
+  }
+  if (const auto* copy_assignment =
+  Result.Nodes.getNodeAs("copy-assignment")) {

nit: CopyAssignment


http://reviews.llvm.org/D18961



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


Re: r259734 - Fix predefine for __NSConstantString struct type

2016-04-11 Thread Ben Langmuir via cfe-commits
Sorry, I didn't mean to imply it’s *only* usable on Darwin.  CoreFoundation (or 
at least a large subset of it) supports other platforms.  And in general, these 
builtins are exposed in all languages and for all platforms, and have been 
“forever” so there could be other users of this functionality that I’m not 
aware of.

Ben

> On Apr 11, 2016, at 7:58 AM, Yaron Keren  wrote:
> 
> If used only for Darwin, could this depend on Target.getTriple().isOSDarwin() 
> ?
> 
> 
> 2016-04-11 17:18 GMT+03:00 Ben Langmuir  >:
> 
>> On Apr 3, 2016, at 10:57 AM, Yaron Keren > > wrote:
>> 
>> I look at many AST dumps for small reduced code so it's mostly weird to see 
>> this in the AST (and takes a bit of screen real estate) as it's not 
>> something that originated in the code. 
>> By now I'm used to ignoring it but would expect NSConstantString would 
>> baffle new clang programmers. It would be nice if we won't see it...
>> How is NSConstantString used outside ObjectiveC ?
> 
> A builtin that uses this type is exposed as the CFSTR() macro in 
> CoreFoundation on Darwin platforms - this is a C framework that needs to be 
> usable from C, Objective C and C++.
> 
> Sorry for the slow reply!
> 
>> 
>> 
>> 
>> 
>> 2016-04-03 20:39 GMT+03:00 Ben Langmuir > >:
>> This type and the builtin it supports needs to work in C/C++ as well, not 
>> just Objective-C.   Are you running into a problem here, or is it just 
>> “weird” to see it in the AST?
>> 
>>> On Apr 3, 2016, at 5:21 AM, Yaron Keren >> > wrote:
>>> 
>>> +1, if possible. There is a if (getLangOpts().ObjC1) block just before this.
>>> 
>>> 2016-04-03 14:21 GMT+03:00 Vassil Vassilev via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>>:
>>> On 04/02/16 01:55, Ben Langmuir via cfe-commits wrote:
>>> Author: benlangmuir
>>> Date: Wed Feb  3 18:55:24 2016
>>> New Revision: 259734
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=259734&view=rev 
>>> 
>>> Log:
>>> Fix predefine for __NSConstantString struct type
>>> 
>>> Per review feedback the name was wrong and it can be used outside
>>> Objective-C.
>>> 
>>> Unfortunately, making the internal struct visible broke some ASTMatchers
>>> tests that assumed that the first record decl would be from user code,
>>> rather than a builtin type.  I'm worried that this will also affect
>>> users' code.  So this patch adds a typedef to wrap the internal struct
>>> and only makes the typedef visible to namelookup.  This is sufficient to
>>> allow the ASTReader to merge the decls we need without making the struct
>>> itself visible.
>>> 
>>> rdar://problem/24425801 <>
>>> 
>>> Modified:
>>>  cfe/trunk/include/clang/AST/ASTContext.h
>>>  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>>  cfe/trunk/lib/AST/ASTContext.cpp
>>>  cfe/trunk/lib/Sema/Sema.cpp
>>>  cfe/trunk/lib/Serialization/ASTReader.cpp
>>>  cfe/trunk/lib/Serialization/ASTWriter.cpp
>>>  cfe/trunk/test/CodeGenObjC/2010-02-01-utf16-with-null.m
>>>  cfe/trunk/test/CodeGenObjC/arc-no-arc-exceptions.m
>>>  cfe/trunk/test/CodeGenObjC/tentative-cfconstantstring.m
>>>  cfe/trunk/test/Modules/Inputs/builtin.h
>>>  cfe/trunk/test/Modules/builtins.m
>>> 
>>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=259734&r1=259733&r2=259734&view=diff
>>>  
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>>> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Feb  3 18:55:24 2016
>>> @@ -253,8 +253,9 @@ class ASTContext : public RefCountedBase
>>> mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
>>>   QualType ObjCConstantStringType;
>>> -  mutable RecordDecl *CFConstantStringTypeDecl;
>>> -
>>> +  mutable RecordDecl *CFConstantStringTagDecl;
>>> +  mutable TypedefDecl *CFConstantStringTypeDecl;
>>> +
>>> mutable QualType ObjCSuperType;
>>> QualType ObjCNSStringType;
>>> @@ -1381,11 +1382,12 @@ public:
>>> /// if it hasn't yet been built.
>>> QualType getRawCFConstantStringType() const {
>>>   if (CFConstantStringTypeDecl)
>>> -  return getTagDeclType(CFConstantStringTypeDecl);
>>> +  return getTypedefType(CFConstantStringTypeDecl);
>>>   return QualType();
>>> }
>>> void setCFConstantStringType(QualType T);
>>> -  TagDecl *getCFConstantStringDecl() const;
>>> +  TypedefDecl *getCFConstantStringDecl() const;
>>> +  RecordDecl *getCFConstantStringTagDecl() const;
>>>   // This setter/getter represents the ObjC type for an 
>>> NSConstantString.
>>> void setObjCConstantStringInterface(ObjCInterface

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Hal Finkel via cfe-commits
hfinkel added a subscriber: hfinkel.
hfinkel added a comment.

In http://reviews.llvm.org/D18823#397071, @rengolin wrote:

> En passant comment: I really wish we wouldn't.
>
> The C++ standard had some very careful considerations on VLAs and decided 
> *not* to support. It wasn't for lack of interest, it was a well informed 
> decision.


The decision might have been well informed, but it was really a lack of 
consensus. There was (and still is) a large fraction of the committee in favor 
of VLAs (or ARBs as they called them). There is also a large fraction of the 
committee opposed to them, or willing to accept them, but only if we could also 
add a library type with a better interface. There is a concern, which is not 
completely unreasonable, that if we make a point of adding this feature to the 
C++ standard, without adding a library container type, it will make people more 
likely to use "raw" arrays and pointers instead of using higher-level 
containers and iterators. It turns out, however, that it is not clear how such 
a library container could be implemented in practice.

However, as an implementation extension, this concern is not relevant. I'm in 
favor of this; I have uses who use this feature in GCC. It is certainly true 
that most HPC users are using these on PODs, but the fact that you cannot apply 
them to other types creates a problem with generic programming that people have 
run into.


http://reviews.llvm.org/D18823



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


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Renato Golin via cfe-commits
rengolin added a comment.

In http://reviews.llvm.org/D18823#397112, @hfinkel wrote:

> However, as an implementation extension, this concern is not relevant. I'm in 
> favor of this; I have uses who use this feature in GCC. It is certainly true 
> that most HPC users are using these on PODs, but the fact that you cannot 
> apply them to other types creates a problem with generic programming that 
> people have run into.


Sounds odd to argue in favour of generic programming and not in favour of using 
generic standard containers.

I can easily accept the legacy argument, but creating new code with contentious 
features seems totally backwards to me.


http://reviews.llvm.org/D18823



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


r265952 - [CLANG] [AVX512] [BUILTIN] Adding PSRA{Q|D|QI|DI}{128|256|512} builtin

2016-04-11 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 11 10:46:39 2016
New Revision: 265952

URL: http://llvm.org/viewvc/llvm-project?rev=265952&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding PSRA{Q|D|QI|DI}{128|256|512} builtin

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


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=265952&r1=265951&r2=265952&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 11 10:46:39 2016
@@ -1908,6 +1908,16 @@ TARGET_BUILTIN(__builtin_ia32_scalefpd51
 TARGET_BUILTIN(__builtin_ia32_scalefps512_mask, 
"V16fV16fV16fV16fUsIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_scalefsd_round_mask, 
"V2dV2dV2dV2dUcIi","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_scalefss_round_mask, 
"V4fV4fV4fV4fUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psradi512_mask, "V16iV16iiV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psraqi512_mask, 
"V8LLiV8LLiiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrad128_mask, "V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrad256_mask, "V8iV8iV4iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psradi128_mask, "V4iV4iIiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psradi256_mask, "V8iV8iIiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psraq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psraq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psraqi128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psraqi256_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=265952&r1=265951&r2=265952&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Apr 11 10:46:39 2016
@@ -4874,6 +4874,49 @@ __builtin_ia32_scalefss_round_mask ((__v
  _MM_FROUND_CUR_DIRECTION);\
 })
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_srai_epi32 (__m512i __A, unsigned int __B)
+{
+  return (__m512i) __builtin_ia32_psradi512_mask ((__v16si) __A, __B,
+  (__v16si)
+  _mm512_setzero_si512 (),
+  (__mmask16) -1);
+}
+
+#define _mm512_mask_srai_epi32( __W, __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psradi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)( __W),\
+  (__mmask16)( __U));\
+})
+
+#define _mm512_maskz_srai_epi32( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psradi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16)( __U));\
+})
+
+#define _mm512_srai_epi64( __A, __B) __extension__ ({ \
+__builtin_ia32_psraqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8) -1);\
+})
+
+#define _mm512_mask_srai_epi64( __W, __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psraqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)( __W),\
+  (__mmask8)( __U));\
+})
+
+#define _mm512_maskz_srai_epi64( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psraqi512_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=265952&r1=265951&r2=265952&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Mon Apr 11 10:46:39 2016
@@ -7241,6 +7241,172 @@ _mm256_maskz_unpacklo_epi64 (__mmask8 __
   (__mmask8) __U);
 }
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_sra_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
+__m128i __B)
+{
+  return (__m128i) __builtin_ia32_psrad128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_sra_epi32 (__mmask8 __U, __m128i __A, __m128i __B)
+{
+  return (__m128i) __builtin_ia32_psrad128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si)
+ _mm_se

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

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

In http://reviews.llvm.org/D18823#397122, @rengolin wrote:

> In http://reviews.llvm.org/D18823#397112, @hfinkel wrote:
>
> > However, as an implementation extension, this concern is not relevant. I'm 
> > in favor of this; I have uses who use this feature in GCC. It is certainly 
> > true that most HPC users are using these on PODs, but the fact that you 
> > cannot apply them to other types creates a problem with generic programming 
> > that people have run into.
>
>
> Sounds odd to argue in favour of generic programming and not in favour of 
> using generic standard containers.
>
> I can easily accept the legacy argument, but creating new code with 
> contentious features seems totally backwards to me.


It comes up in cases where you're writing templates that are normally used with 
PODs and the relevant types, but don't want them to completely fail when used 
with other types (class for extended precision floats, or those doing forward 
automated differentiation, etc.).

Using VLAs in C++, as a general statement, is one of the most common language 
extensions I see used. It is used in new code regularly, and is often critical 
for performance (i.e. to avoid calls to the memory allocator). Using them on 
on-PODs is certainly less common, but still comes up.


http://reviews.llvm.org/D18823



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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread silviu.bara...@arm.com via cfe-commits
sbaranga updated this revision to Diff 53254.
sbaranga added a comment.

Apply review comments from Renato:

- simplify condition for enabling __ARM_FEATURE_FMA
- use cortex-a7 instead of cortex-a8 for testing since this is a real use case.


http://reviews.llvm.org/D18963

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/arm-neon-fma.c
  test/Preprocessor/arm-acle-6.5.c
  test/Sema/arm_vfma.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4927,7 +4927,7 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
Index: test/CodeGen/arm-neon-fma.c
===
--- test/CodeGen/arm-neon-fma.c
+++ test/CodeGen/arm-neon-fma.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \
 // RUN:   -target-abi aapcs \
-// RUN:   -target-cpu cortex-a8 \
+// RUN:   -target-cpu cortex-a7 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7r-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
 // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
-// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-FMA
+// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s 
-check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv8-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck 
%s -check-prefix CHECK-FMA
 
 // CHECK-FMA: __ARM_FEATURE_FMA 1
 
Index: test/Sema/arm_vfma.c
===
--- test/Sema/arm_vfma.c
+++ test/Sema/arm_vfma.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 
 
 // expected-no-diagnostics


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4927,7 +4927,7 @@
 Builder.defineMacro("__ARM_FP16_ARGS", "1");
 
 // ACLE 6.5.3 Fused multiply-accumulate (FMA)
-if (ArchVersion >= 7 && (CPUProfile != "M" || CPUAttr == "7EM"))
+if (ArchVersion >= 7 && (FPU & VFP4FPU))
   Builder.defineMacro("__ARM_FEATURE_FMA", "1");
 
 // Subtarget options.
Index: test/CodeGen/arm-neon-fma.c
===
--- test/CodeGen/arm-neon-fma.c
+++ test/CodeGen/arm-neon-fma.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \
 // RUN:   -target-abi aapcs \
-// RUN:   -target-cpu cortex-a8 \
+// RUN:   -target-cpu cortex-a7 \
 // RUN:   -mfloat-abi hard \
 // RUN:   -ffreestanding \
 // RUN:   -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
Index: test/Preprocessor/arm-acle-6.5.c
===
--- test/Preprocessor/arm-acle-6.5.c
+++ test/Preprocessor/arm-acle-6.5.c
@@ -49,10 +49,13 @@
 
 // CHECK-NO-FMA-NOT: __ARM_FEATURE_FMA
 
-// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
-// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7a-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7a-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
+// RUN: %clang -target armv7r-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-NO-FMA
+// RUN: %clang -target armv7r-eabi -mfpu=vfpv4 -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
 // RUN: %clang -target armv7em-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-FMA
-// RUN: %clang -target armv8-eabi -x c -E -dM %s -o - | FileCheck %s -check-

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki added inline comments.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:30
@@ +29,3 @@
+  // We should actually use isExplicitlyDefaulted, but it does not exist.
+  Finder->addMatcher(
+  cxxConstructorDecl(isDefaultConstructor(), isExplicitlyDefaulted(),

alexfh wrote:
> I think, we need at most two matchers here: one for constructors and one for 
> assignment operators. We could also cram these into a single matcher. I also 
> suggest to combine the `diag()` calls to a single one using `%N` or 
> `%select{}N` format to parametrize the message. Something along the lines of:
> 
>   Finder->addMatcher(cxxMethodDecl(isDefaulted(), isDeleted(), 
> unless(isImplicit()), unless(isInTemplateInstantiation()),
>   anyOf(isCopyAssignmentOperator(), isMoveAssignmentOperator(), 
> cxxConstructorDecl().bind("ctor"))).bind("method"));
> 
>   ...
>   const auto *Method = Result.Nodes.getNodeAs("method");
>   assert(Method != nullptr);
>   diag(Method->getLocStart(),
>  "this %select{method|constructor}0 is marked '= default' but is 
> actually "
>  "implicitly deleted, probably because an instance variable or a base 
> "
>  "class is not copyable nor movable; this definition should either be 
> removed "
>  "or explicitly marked as '= delete'") << 
> (Result.Nodes.getNodeAs("ctor") ? 1 : 0);
> 
> If you think that adding "copy", "move" or "default" makes the message any 
> better, this could also be accommodated in this approach.
I reduced to two matchers and used a common template for the error message. 
Tell me if it's ok.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:31
@@ +30,3 @@
+  Finder->addMatcher(
+  cxxConstructorDecl(isDefaultConstructor(), isExplicitlyDefaulted(),
+ isDeleted(), NotTemplate)

alexfh wrote:
> Alternatively, you can use `isDefaulted(), unless(isImplicit())`.
What is the advantage? Not writing my own matcher?


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki marked an inline comment as done.
pilki added a comment.

http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread David Blaikie via cfe-commits
I'd consider just making this a compiler warning, perhaps?

On Mon, Apr 11, 2016 at 5:52 AM, Alex Pilkiewicz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> pilki created this revision.
> pilki added a reviewer: alexfh.
> pilki added a subscriber: cfe-commits.
>
> Checks if constructors and assignment operators that are marked '=
> default' are actually deleted by the compiler.
>
> http://reviews.llvm.org/D18961
>
> Files:
>clang-tidy/readability/CMakeLists.txt
>clang-tidy/readability/DeletedDefaultCheck.cpp
>clang-tidy/readability/DeletedDefaultCheck.h
>clang-tidy/readability/ReadabilityTidyModule.cpp
>docs/clang-tidy/checks/list.rst
>docs/clang-tidy/checks/readability-deleted-default.rst
>test/clang-tidy/readability-deleted-default.cpp
>
>
> ___
> 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] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread Renato Golin via cfe-commits
rengolin accepted this revision.
rengolin added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-11 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:59
@@ +58,3 @@
+  while (!RawLexer.LexFromRawLexer(Tok)) {
+if (Tok.is(tok::semi) || Tok.is(tok::l_brace))
+  break;

Parsing C++ is hard.
Stopping at the first `{` means you will have a false negative here:

```
template  struct S{};
S inline foo() { return {}; }

```
I think we should just continue until we find the 'inline' keyword. We already 
know it is there from the matching.

We could also limit the search until functionDecl->getLocation(). We don't have 
to look until LocEnd() because we won't find it after the function name.


Comment at: clang-tidy/readability/RedundantInlineCheck.cpp:105
@@ +104,3 @@
+  // each FunctionDecl.
+  SmallVector Tokens = ParseTokens(FileRange, Result);
+  for (Token Tok : Tokens) {

Maybe ParseTokens should just return the specific token we are looking for.


Comment at: docs/clang-tidy/checks/readability-redundant-inline.rst:12
@@ +11,3 @@
+inline int f() {
+ return 0;
+   }

bad alignment


http://reviews.llvm.org/D18914



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki updated this revision to Diff 53257.
pilki marked 3 inline comments as done.

http://reviews.llvm.org/D18961

Files:
   clang-tidy/readability/CMakeLists.txt
   clang-tidy/readability/DeletedDefaultCheck.cpp
   clang-tidy/readability/DeletedDefaultCheck.h
   clang-tidy/readability/ReadabilityTidyModule.cpp
   docs/clang-tidy/checks/list.rst
   docs/clang-tidy/checks/readability-deleted-default.rst
   test/clang-tidy/readability-deleted-default.cpp

Index:  test/clang-tidy/readability-deleted-default.cpp
===
---  test/clang-tidy/readability-deleted-default.cpp
+++  test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,104 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault &&Other) = delete;
+  NoDefault(const NoDefault &Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: this default constructor is marked '= default' but is actually implicitly deleted, probably because an instance variable or a base class is lacking a default constructor. You should either remove this definition or explicitly mark it as '= delete' [readability-deleted-default]
+  MissingEverything(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: this move constructor is marked '= default' but is actually implicitly deleted, probably because an instance variable or a base class is not copyable nor movable. You should either remove this definition or explicitly mark it as '= delete' [readability-deleted-default]
+  MissingEverything(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: this copy constructor is marked '= default' but is actually implicitly deleted, probably because an instance variable or a base class is not copyable. You should either remove this definition or explicitly mark it as '= delete' [readability-deleted-default]
+  MissingEverything &operator=(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: this move assignment operator is marked '= default' but is actually implicitly deleted, probably because a base class or an instance variable is not assignable, e.g. because the latter is marked as const. You should either remove this definition or explicitly mark it as '= delete' [readability-deleted-default]
+  MissingEverything &operator=(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: this copy assignment operator is marked '= default' but is actually implicitly deleted, probably because a base class or an instance variable is not assignable, e.g. because the latter is marked as const. You should either remove this definition or explicitly mark it as '= delete' [readability-deleted-default]
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable &&Other) = default;
+  NotAssignable(const NotAssignable &Other) = default;
+  NotAssignable &operator=(NotAssignable &&Other) = default;
+  // CHECK-MESSAGES: warning: this move assignment operator is marked '= default' but is actually implicitly deleted
+  NotAssignable &operator=(const NotAssignable &Other) = default;
+  // CHECK-MESSAGES: warning: this copy assignment operator is marked '= default' but is actually implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable &&Other) = default;
+  Movable(const Movable &Other) = delete;
+  Movable &operator=(Movable &&Other) = default;
+  Movable &operator=(const Movable &Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable &&Other) = default;
+  NotCopyable(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: this copy constructor is marked '= default' but is actually implicitly deleted
+  NotCopyable &operator=(NotCopyable &&Other) = default;
+  NotCopyable &operator=(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: this copy assignment operator is marked '= default' but is actually implicitly deleted
+private:
+  Movable M;
+};
+
+template  class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated &&Other) = default;
+  Templated(const Templated &Other) = default;
+  Templated &operator=(Templated &&Other) = default;
+  Templated &operator=(const Templated &Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated &&Other) = default;
+InnerTemplated(const InnerTemplated &Other) = default;
+InnerTemplated &operator=(InnerTemplated &&Other) = default;
+InnerTemplated &operator=(const InnerTemplated &Other) = default;
+
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically h

Re: [PATCH] D18300: [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer

2016-04-11 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

Missed this patch somehow: it was in a wrong part of my dashboard =\

LG. Thanks for the fix.



Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:94
@@ +93,3 @@
+  bool Bool{false};
+  // CHECK-FIXES: bool Bool{false};
+};

aaron.ballman wrote:
> flx wrote:
> > aaron.ballman wrote:
> > > Why is this checking a fix? I thought that point was that this should not 
> > > generate any diagnostic (and hence, no fix is required)?
> > If I understood Alex correctly, CHECK-FIXES is needed to check for the 
> > absence of a change made by ClangTidy. But I agree it seems unlikely to 
> > have a change without a warning message which will trigger a test failure 
> > at any rate.
> @alexfh, what are your thoughts on this? It seems like we should be able to 
> test negative fixes, like with CHECK-NOT, except CHECK-FIXES-NOT or some such?
I usually ask people to add CHECK-FIXES in case when there is a warning that 
could change some code, but shouldn't. When there's no warning that is likely 
to touch some code, there's no need for a CHECK-FIXES to verify this.


Repository:
  rL LLVM

http://reviews.llvm.org/D18300



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


Re: r259734 - Fix predefine for __NSConstantString struct type

2016-04-11 Thread Vassil Vassilev via cfe-commits

On 11/04/16 16:18, Ben Langmuir wrote:


On Apr 3, 2016, at 10:57 AM, Yaron Keren > wrote:


I look at many AST dumps for small reduced code so it's mostly weird 
to see this in the AST (and takes a bit of screen real estate) as 
it's not something that originated in the code.
By now I'm used to ignoring it but would expect NSConstantString 
would baffle new clang programmers. It would be nice if we won't see 
it...

How is NSConstantString used outside ObjectiveC ?


A builtin that uses this type is exposed as the CFSTR() macro in 
CoreFoundation on Darwin platforms - this is a C framework that needs 
to be usable from C, Objective C and C++.
Ah, thanks for explaining. The name is a bit misleading and I thought 
this was just a objc builtin.




Sorry for the slow reply!






2016-04-03 20:39 GMT+03:00 Ben Langmuir >:


This type and the builtin it supports needs to work in C/C++ as
well, not just Objective-C.   Are you running into a problem
here, or is it just “weird” to see it in the AST?


On Apr 3, 2016, at 5:21 AM, Yaron Keren mailto:yaron.ke...@gmail.com>> wrote:

+1, if possible. There is a if (getLangOpts().ObjC1) block just
before this.

2016-04-03 14:21 GMT+03:00 Vassil Vassilev via cfe-commits
mailto:cfe-commits@lists.llvm.org>>:

On 04/02/16 01:55, Ben Langmuir via cfe-commits wrote:

Author: benlangmuir
Date: Wed Feb  3 18:55:24 2016
New Revision: 259734

URL: http://llvm.org/viewvc/llvm-project?rev=259734&view=rev
Log:
Fix predefine for __NSConstantString struct type

Per review feedback the name was wrong and it can be
used outside
Objective-C.

Unfortunately, making the internal struct visible broke
some ASTMatchers
tests that assumed that the first record decl would be
from user code,
rather than a builtin type. I'm worried that this will
also affect
users' code.  So this patch adds a typedef to wrap the
internal struct
and only makes the typedef visible to namelookup.  This
is sufficient to
allow the ASTReader to merge the decls we need without
making the struct
itself visible.

rdar://problem/24425801

Modified:
 cfe/trunk/include/clang/AST/ASTContext.h
 cfe/trunk/include/clang/Serialization/ASTBitCodes.h
 cfe/trunk/lib/AST/ASTContext.cpp
 cfe/trunk/lib/Sema/Sema.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/CodeGenObjC/2010-02-01-utf16-with-null.m
 cfe/trunk/test/CodeGenObjC/arc-no-arc-exceptions.m
 cfe/trunk/test/CodeGenObjC/tentative-cfconstantstring.m
 cfe/trunk/test/Modules/Inputs/builtin.h
 cfe/trunk/test/Modules/builtins.m

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=259734&r1=259733&r2=259734&view=diff

==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Feb  3
18:55:24 2016
@@ -253,8 +253,9 @@ class ASTContext : public RefCountedBase
mutable IdentifierInfo *MakeIntegerSeqName = nullptr;
  QualType ObjCConstantStringType;
-  mutable RecordDecl *CFConstantStringTypeDecl;
-
+  mutable RecordDecl *CFConstantStringTagDecl;
+  mutable TypedefDecl *CFConstantStringTypeDecl;
+
mutable QualType ObjCSuperType;
QualType ObjCNSStringType;
@@ -1381,11 +1382,12 @@ public:
/// if it hasn't yet been built.
QualType getRawCFConstantStringType() const {
  if (CFConstantStringTypeDecl)
-  return getTagDeclType(CFConstantStringTypeDecl);
+  return getTypedefType(CFConstantStringTypeDecl);
  return QualType();
}
void setCFConstantStringType(QualType T);
-  TagDecl *getCFConstantStringDecl() const;
+  TypedefDecl *getCFConstantStringDecl() const;
+  RecordDecl *getCFConstantStringTagDecl() const;
  // This setter/getter represents the ObjC type for
an NSConstantString.
void
setObjCConstantStringInterface(ObjCInterfaceDecl *Decl);

Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL:

http://llvm.org/

Re: [PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope

2016-04-11 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 53261.
mgehre added a comment.

Remove unused CFGBuilder::prependLifetimeEndsWithTerminator


http://reviews.llvm.org/D15031

Files:
  include/clang/Analysis/AnalysisContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/lifetime-cfg-output.cpp

Index: test/Analysis/lifetime-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/lifetime-cfg-output.cpp
@@ -0,0 +1,735 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+extern bool UV;
+class A {
+public:
+// CHECK:   [B2 (ENTRY)]
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1: true
+// CHECK-NEXT:2: UV
+// CHECK-NEXT:3: [B1.2] = [B1.1]
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+A() { 
+UV = true;
+}
+// CHECK:   [B3 (ENTRY)]
+// CHECK-NEXT:Succs (1): B2
+// CHECK:   [B1]
+// CHECK-NEXT:1: 0
+// CHECK-NEXT:2: this
+// CHECK-NEXT:3: [B1.2]->p
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, LValueToRValue, int *)
+// CHECK-NEXT:5: *[B1.4]
+// CHECK-NEXT:6: [B1.5] = [B1.1]
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B2]
+// CHECK-NEXT:1: this
+// CHECK-NEXT:2: [B2.1]->p
+// CHECK-NEXT:3: [B2.2] (ImplicitCastExpr, LValueToRValue, int *)
+// CHECK-NEXT:4: [B2.3] (ImplicitCastExpr, PointerToBoolean, _Bool)
+// CHECK-NEXT:T: if [B2.4]
+// CHECK-NEXT:Preds (1): B3
+// CHECK-NEXT:Succs (2): B1 B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (2): B1 B2
+~A() {
+if(p)
+*p = 0;
+}
+// CHECK:   [B2 (ENTRY)]
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1: 1
+// CHECK-NEXT:2: return [B1.1];
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+operator int() const { return 1; }
+int* p;
+};
+
+// CHECK:   [B2 (ENTRY)]
+// CHECK-NEXT:Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:2: A a;
+// CHECK-NEXT:3: a
+// CHECK-NEXT:4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:5: const A &b = a;
+// CHECK-NEXT:6: A() (CXXConstructExpr, class A)
+// CHECK-NEXT:7: [B1.6] (BindTemporary)
+// CHECK-NEXT:8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
+// CHECK-NEXT:9: [B1.8]
+// CHECK-NEXT:   10: const A &c = A();
+// CHECK-NEXT:   11: [B1.10] (Lifetime ends)
+// CHECK-NEXT:   12: [B1.2] (Lifetime ends)
+// CHECK-NEXT:   13: [B1.5] (Lifetime ends)
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B0 (EXIT)]
+// CHECK-NEXT:Preds (1): B1
+void test_const_ref() {
+  A a;
+  const A& b = a;
+  const A& c = A();
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:2: A a[2];
+// CHECK-NEXT:3:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:4: A b[0];
+// lifetime of a ends when its destructors are run
+// CHECK-NEXT:5: [B1.2] (Lifetime ends)
+// lifetime of b ends when its storage duration ends
+// CHECK-NEXT:6: [B1.4] (Lifetime ends)
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:2: A a;
+// CHECK-NEXT:3:  (CXXConstructExpr, class A)
+// CHECK-NEXT:4: A c;
+// CHECK-NEXT:5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:6: A d;
+// CHECK-NEXT:7: [B1.6] (Lifetime ends)
+// CHECK-NEXT:8: [B1.4] (Lifetime ends)
+// CHECK-NEXT:9:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   10: A b;
+// CHECK-NEXT:   11: [B1.10] (Lifetime ends)
+// CHECK-NEXT:   12: [B1.2] (Lifetime ends)
+// CHECK-NEXT:Preds (1): B2
+// CHECK-NEXT:Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_scope() {
+  A a;
+  { A c;
+A d;
+  }
+  A b;
+}
+
+// CHECK:  [B4 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B3
+// CHECK:   [B1]
+// CHECK-NEXT:1:  (CXXConstructExpr, class A)
+// CHECK-NE

[PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-11 Thread Taewook Oh via cfe-commits
twoh created this revision.
twoh added reviewers: rsmith, aaron.ballman.
twoh added a subscriber: cfe-commits.

Add functions declared in ctype.h to builtin function database. All functions 
are annotated with nothrow and const attribute, which enables better 
optimization. 

http://reviews.llvm.org/D18970

Files:
  include/clang/Basic/Builtins.def

Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -773,6 +773,22 @@
 LIBBUILTIN(vscanf, "icC*Ra",  "fS:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
+// C99 ctype.h
+LIBBUILTIN(isalnum, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isalpha, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isblank, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(iscntrl, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isdigit, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isgraph, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(islower, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isprint, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(ispunct, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isspace, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isupper, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isxdigit, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(tolower, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(toupper, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.


Index: include/clang/Basic/Builtins.def
===
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -773,6 +773,22 @@
 LIBBUILTIN(vscanf, "icC*Ra",  "fS:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
+// C99 ctype.h
+LIBBUILTIN(isalnum, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isalpha, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isblank, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(iscntrl, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isdigit, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isgraph, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(islower, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isprint, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(ispunct, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isspace, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isupper, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isxdigit, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(tolower, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(toupper, "ii", "fnc", "ctype.h", ALL_LANGUAGES)
+
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

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

In http://reviews.llvm.org/D18961#397163, @dblaikie wrote:

> I'd consider just making this a compiler warning, perhaps?


I agree that it might be a good idea. However, it doesn't hurt to have this in 
clang-tidy (at least as a prototype - to figure out details and see how it 
works on real code) until we have it in Clang. Also, making it a Clang 
diagnostic might be more difficult, especially without a prior experience.


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki added a comment.

In http://reviews.llvm.org/D18961#397163, @dblaikie wrote:

> I'd consider just making this a compiler warning, perhaps?


I honestly don't feel competent right now to write compiler warnings: 
clang-tidy has a nice, well defined interface. A compiler warning would force 
me to dig in the internals of clang. But if you feel strongly about it and give 
me a couple of pointers (like a diff that adds a similar warning, and maybe a 
pointer to the general area in the code where I would add it), I can maybe give 
it a try in the next few days/weeks.


http://reviews.llvm.org/D18961



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


Re: r265934 - [clang-format] Walk backwards from end() instead of forwards from rend().

2016-04-11 Thread David Blaikie via cfe-commits
On Mon, Apr 11, 2016 at 5:19 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Mon Apr 11 07:19:19 2016
> New Revision: 265934
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265934&view=rev
> Log:
> [clang-format] Walk backwards from end() instead of forwards from rend().
>
> This should've been forwards from rbegin(), reverse iterators are just
> too confusing to be used by mere mortals. Fixes out-of-bounds walks over
> the list.
>

Was/is the 2 correct then? (if it was next(rbegin, 2) that'd be equivalent
to prev(end, 3), yes?)


>
> Modified:
> cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>
> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=265934&r1=265933&r2=265934&view=diff
>
> ==
> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Apr 11 07:19:19 2016
> @@ -718,7 +718,7 @@ void UnwrappedLineParser::readTokenWithJ
>if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
>  // If the token before the previous one is an '@', the previous token
> is an
>  // annotation and can precede another identifier/value.
> -const FormatToken *PrePrevious = std::next(Line->Tokens.rend(),
> 2)->Tok;
> +const FormatToken *PrePrevious = std::prev(Line->Tokens.end(),
> 2)->Tok;
>  if (PrePrevious->is(tok::at))
>return;
>}
>
>
> ___
> 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] D18567: Block: Fix a crash when we have type attributes or qualifiers with omitted return type.

2016-04-11 Thread Manman Ren via cfe-commits
manmanren added a comment.

Ping :]


http://reviews.llvm.org/D18567



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

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

Thank you for addressing the comments!



Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:27
@@ +26,3 @@
+  const auto NotTemplate = unless(hasAncestor(
+  cxxRecordDecl(::clang::ast_matchers::isTemplateInstantiation(;
+

What about this comment?


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:32
@@ +31,3 @@
+  .bind("constructor"),
+  this);
+  Finder->addMatcher(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),

Yes, using standard tools instead of introducing a new one.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:44
@@ +43,3 @@
+  "this %0 is marked '= default' but is actually implicitly deleted, "
+  "probably because %1. You should either remove this definition or "
+  "explicitly mark it as '= delete'";

A few suggestions to improve the wording:
  * remove "this"
  * replace the period in the end of the first sentence with a semicolon and 
use a lower-case letter to start the second part.
  * "You should do X" doesn't sound right in warning messages. I'd use a softer 
option, for example in passive voice: "this definition should either be removed 
or explicitly marked as '= delete'"


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:49
@@ +48,3 @@
+if (Constructor->isDefaultConstructor()) {
+  diag(Constructor->getLocStart(), Message)
+  << "default constructor"

If the check() method issues a diagnostic in any case, I'd prefer a slightly 
different pattern to reduce code duplication a bit more:

  auto Diag = diag(Constructor->getLocStart(), ".");
  if (x) {
Diag << "qqq" << "eee";
  }
  ...


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:70
@@ +69,3 @@
+  Result.Nodes.getNodeAs("assignment")) {
+const StringRef Explanation = "a base class or an instance variable is not 
"
+  "assignable, e.g. because the latter is "

nit: No need for this variable.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:72
@@ +71,3 @@
+  "assignable, e.g. because the latter is "
+  "marked as const";
+diag(Assignment->getLocStart(), Message)

"marked 'const'" sounds better to me than "marked as const".


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18849: [modules] Avoid module relocation error when building modules from VFS

2016-04-11 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!


http://reviews.llvm.org/D18849



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


Re: r265934 - [clang-format] Walk backwards from end() instead of forwards from rend().

2016-04-11 Thread Benjamin Kramer via cfe-commits
On Mon, Apr 11, 2016 at 6:48 PM, David Blaikie  wrote:
>
>
> On Mon, Apr 11, 2016 at 5:19 AM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> Author: d0k
>> Date: Mon Apr 11 07:19:19 2016
>> New Revision: 265934
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=265934&view=rev
>> Log:
>> [clang-format] Walk backwards from end() instead of forwards from rend().
>>
>> This should've been forwards from rbegin(), reverse iterators are just
>> too confusing to be used by mere mortals. Fixes out-of-bounds walks over
>> the list.
>
>
> Was/is the 2 correct then? (if it was next(rbegin, 2) that'd be equivalent
> to prev(end, 3), yes?)

I think it is from looking at the test case, looping in martin to see
whether I'm right :)

>>
>>
>> Modified:
>> cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>>
>> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=265934&r1=265933&r2=265934&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Mon Apr 11 07:19:19 2016
>> @@ -718,7 +718,7 @@ void UnwrappedLineParser::readTokenWithJ
>>if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
>>  // If the token before the previous one is an '@', the previous token
>> is an
>>  // annotation and can precede another identifier/value.
>> -const FormatToken *PrePrevious = std::next(Line->Tokens.rend(),
>> 2)->Tok;
>> +const FormatToken *PrePrevious = std::prev(Line->Tokens.end(),
>> 2)->Tok;
>>  if (PrePrevious->is(tok::at))
>>return;
>>}
>>
>>
>> ___
>> 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] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

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

- Addressed comments.


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.h
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11274,6 +11274,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,85 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\nnamespace C {\n"
+ "namespace D int i; }\n\n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Set the changed range to be the second "\n".
+  std::vector Ranges(1, tooling::Range(14, 0));
+  st

r265963 - Update getting started docs

2016-04-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Apr 11 12:02:34 2016
New Revision: 265963

URL: http://llvm.org/viewvc/llvm-project?rev=265963&view=rev
Log:
Update getting started docs

compiler-rt is optional. We often get email from users with compiler-rt
build errors who don't actually need compiler-rt. Marking it optional
should help them avoid those potential problems.

While I'm here, update a reference to the build directory and remove an
obsolete reference to llvm-gcc. Nobody today is under the impression
that Clang depends on GCC.

Modified:
cfe/trunk/www/get_started.html

Modified: cfe/trunk/www/get_started.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_started.html?rev=265963&r1=265962&r2=265963&view=diff
==
--- cfe/trunk/www/get_started.html (original)
+++ cfe/trunk/www/get_started.html Mon Apr 11 12:02:34 2016
@@ -68,7 +68,7 @@ follows:
 cd ../../../..
   
   
-  Checkout Compiler-RT:
+  Checkout Compiler-RT (optional):
   
 cd llvm/projects
 svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk
@@ -109,7 +109,7 @@ follows:
   scenarios, you can use the -DGCC_INSTALL_PREFIX cmake option
   to tell Clang where the gcc containing the desired libstdc++ is 
installed.
   
-  Try it out (assuming you add llvm/Debug+Asserts/bin to your path):
+  Try it out (assuming you add llvm/build/bin to your path):
   
 clang --help
 clang file.c -fsyntax-only (check for correctness)
@@ -120,10 +120,10 @@ follows:
   
 
 
-Note that the C front-end uses LLVM, but does not depend on llvm-gcc. If you
-encounter problems with building Clang, make sure you have the latest SVN
-version of LLVM. LLVM contains support libraries for Clang that will be updated
-as well as development on Clang progresses.
+If you encounter problems while building Clang, make sure that your LLVM
+checkout is at the same revision as your Clang checkout. LLVM's interfaces
+change over time, and mismatched revisions are not expected to work
+together.
   
 Simultaneously Building Clang and LLVM:
 


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


r265964 - [Clang][AVX512][BuiltIn] Adding avx512 ( psll{d|q}512, psllv{16si|8di}, psra{d|q}512, psrav{16si|8di}, pternlog{d|q}{128|256|512} ) builtin to clang

2016-04-11 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Mon Apr 11 12:04:21 2016
New Revision: 265964

URL: http://llvm.org/viewvc/llvm-project?rev=265964&view=rev
Log:
[Clang][AVX512][BuiltIn] Adding avx512 ( 
psll{d|q}512,psllv{16si|8di},psra{d|q}512,psrav{16si|8di},pternlog{d|q}{128|256|512}
 ) builtin to clang

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


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=265964&r1=265963&r2=265964&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon Apr 11 12:04:21 2016
@@ -1918,6 +1918,30 @@ TARGET_BUILTIN(__builtin_ia32_psraq128_m
 TARGET_BUILTIN(__builtin_ia32_psraq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psraqi128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psraqi256_mask, 
"V4LLiV4LLiIiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pslld512_mask, "V16iV16iV4iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psllq512_mask, 
"V8LLiV8LLiV2LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psllv16si_mask, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psllv8di_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrad512_mask, "V16iV16iV4iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psraq512_mask, 
"V8LLiV8LLiV2LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrav16si_mask, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrav8di_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrld512_mask, "V16iV16iV4iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrlq512_mask, 
"V8LLiV8LLiV2LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrlv16si_mask, 
"V16iV16iV16iV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrlv8di_mask, 
"V8LLiV8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pternlogd512_mask, 
"V16iV16iV16iV16iIiUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pternlogd512_maskz, 
"V16iV16iV16iV16iIiUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pternlogq512_mask, 
"V8LLiV8LLiV8LLiV8LLiIiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pternlogq512_maskz, 
"V8LLiV8LLiV8LLiV8LLiIiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pternlogd128_mask, 
"V4iV4iV4iV4iIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogd128_maskz, 
"V4iV4iV4iV4iIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogd256_mask, 
"V8iV8iV8iV8iIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogd256_maskz, 
"V8iV8iV8iV8iIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogq128_mask, 
"V2LLiV2LLiV2LLiV2LLiIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogq128_maskz, 
"V2LLiV2LLiV2LLiV2LLiIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogq256_mask, 
"V4LLiV4LLiV4LLiV4LLiIiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pternlogq256_maskz, 
"V4LLiV4LLiV4LLiV4LLiIiUc","","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=265964&r1=265963&r2=265964&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Mon Apr 11 12:04:21 2016
@@ -4005,6 +4005,396 @@ _mm512_unpackhi_epi32 (__m512i __A, __m5
  (__mmask16) -1);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_sll_epi32 (__m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_pslld512_mask ((__v16si) __A,
+ (__v4si) __B,
+ (__v16si)
+ _mm512_setzero_si512 (),
+ (__mmask16) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_sll_epi32 (__m512i __W, __mmask16 __U, __m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_pslld512_mask ((__v16si) __A,
+ (__v4si) __B,
+ (__v16si) __W,
+ (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_sll_epi32 (__mmask16 __U, __m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_pslld512_mask ((__v16si) __A,
+ (__v4si) __B,
+ (__v16si)
+ _mm512_setzero_si512 (),
+ (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_sll_epi64 (__m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_psllq512_mask ((__v8di) __A,
+ (__v2di) __B,
+ (__v8di)
+   

Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-04-11 Thread Reid Kleckner via cfe-commits
rnk added a comment.

Richard, do you think we should be handling this by rewriting the AST-level 
attribute in Sema or by changing our interpretation of things in CodeGen? We're 
already creating a bunch of implicit attributes to implement class-level 
import/export.



Comment at: lib/Sema/SemaDecl.cpp:5572
@@ -5567,2 +5571,3 @@
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;
-  if (const auto *VD = dyn_cast(NewDecl))
+  bool isMicrosoft = S.Context.getTargetInfo().getCXXABI().isMicrosoft();
+  if (const auto *VD = dyn_cast(NewDecl)) {

To be consistent, this should be `IsMicrosoft`.


http://reviews.llvm.org/D18953



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


Re: [PATCH] D18551: Added Fixer implementation and fix() interface in clang-format for removing redundant code.

2016-04-11 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 53274.
ioeric added a comment.

- removed unused fields in AnnotatedLine.


http://reviews.llvm.org/D18551

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/CleanupTest.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11274,6 +11274,35 @@
   Code, formatReplacements(Code, Replaces, Style)));
 }
 
+TEST_F(ReplacementTest, FixOnlyAffectedCodeAfterReplacements) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "  int x;\n"
+ "} // namespace B\n"
+ "} // namespace A\n"
+ "\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { int y; } }\n"
+ "int x= 0;"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "int x= 0;"
+ "}";
+  FileID ID = Context.createInMemoryFile("fix.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 3), 6, ""));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 9, 34), 6, ""));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  auto FinalReplaces = formatReplacements(
+  Code, cleanupAroundReplacements(Code, Replaces, Style), Style);
+  EXPECT_EQ(Expected, applyAllReplacements(Code, FinalReplaces));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CleanupTest.cpp
===
--- /dev/null
+++ unittests/Format/CleanupTest.cpp
@@ -0,0 +1,85 @@
+//===- unittest/Format/CleanupTest.cpp - Code cleanup unit tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/Format/Format.h"
+
+#include "clang/Tooling/Core/Replacement.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+namespace {
+
+class CleanupTest : public ::testing::Test {
+protected:
+  std::string cleanup(llvm::StringRef Code,
+  const std::vector &Ranges,
+  const FormatStyle &Style = getLLVMStyle()) {
+tooling::Replacements Replaces = format::cleanup(Style, Code, Ranges);
+
+std::string Result = applyAllReplacements(Code, Replaces);
+EXPECT_NE("", Result);
+return Result;
+  }
+};
+
+TEST_F(CleanupTest, DeleteEmptyNamespaces) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n"
+ "} // namespace B\n"
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D { int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "\n\nnamespace C {\n"
+ "namespace D { int i; }\n\n"
+ "}";
+  std::vector Ranges;
+  Ranges.push_back(tooling::Range(28, 0));
+  Ranges.push_back(tooling::Range(91, 6));
+  Ranges.push_back(tooling::Range(132, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, NamespaceWithSyntaxError) {
+  std::string Code = "namespace A {\n"
+ "namespace B {\n" // missing r_brace
+ "} // namespace A\n\n"
+ "namespace C {\n"
+ "namespace D int i; }\n"
+ "inline namespace E { namespace { } }\n"
+ "}";
+  std::string Expected = "namespace A {\n"
+ "\n\nnamespace C {\n"
+ "namespace D int i; }\n\n"
+ "}";
+  std::vector Ranges(1, tooling::Range(0, Code.size()));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST_F(CleanupTest, EmptyNamespaceNotAffected) {
+  std::string Code = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Even though the namespaces are empty, but the inner most empty namespace
+  // block is not affected by the changed ranges.
+  std::string Expected = "namespace A {\n\n"
+ "namespace {\n\n}}";
+  // Set the changed range to be the second "\n".
+  std::vector Ranges(1, tooling::Range(14, 0));
+  std::string Result = cleanup(Code, Ranges);
+  EXPECT_

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread David Blaikie via cfe-commits
I don't feel sufficiently strongly to insist - clang-tidy's mostly outside
my wheelhouse anyway.

As for how to go about it - my rough approach would be to write a small
test case that calls an implicitly-deleted-but-explicitly-defaulted move
op, run it, check the diagnostic text, find that in DiagnosticSemaKinds,
find where the diagnostic identifier is used in the code, set a breakpoint,
break there - then trace back to when/where it got marked as deleted (find
the member function of the AST node in question that is used to mark it as
deleted - break in there, with the condition that 'this ==' the specific
instance you're looking at, etc). Then see if, at the point at which the
thing is marked as deleted, you can check that it's not dependent (not a
template, etc) and emit the appropriate warning.

- Dave

On Mon, Apr 11, 2016 at 9:44 AM, Alex Pilkiewicz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> pilki added a comment.
>
> In http://reviews.llvm.org/D18961#397163, @dblaikie wrote:
>
> > I'd consider just making this a compiler warning, perhaps?
>
>
> I honestly don't feel competent right now to write compiler warnings:
> clang-tidy has a nice, well defined interface. A compiler warning would
> force me to dig in the internals of clang. But if you feel strongly about
> it and give me a couple of pointers (like a diff that adds a similar
> warning, and maybe a pointer to the general area in the code where I would
> add it), I can maybe give it a try in the next few days/weeks.
>
>
> http://reviews.llvm.org/D18961
>
>
>
> ___
> 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] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Please mention this check in docs/ReleaseNotes.rst (in alphabetical order).


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread Tim Northover via cfe-commits
t.p.northover added inline comments.


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 

v7s is Swift, which has FMA. v7 for us is Cortex-A9, which I think also has FMA 
(not that it matters much these days).


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18474: [OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets

2016-04-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked an inline comment as done.
carlo.bertolli added a comment.

Alexey

Thanks for the review. I addressed your comment in a new version of the 
revision.
Samuel already reviewed the patch, as you can see in the message exchange. I am 
very happy to apply any design change you can think of.

- Carlo


Repository:
  rL LLVM

http://reviews.llvm.org/D18474



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


Re: [PATCH] D18474: [OPENMP] Enable correct generation of runtime call when target directive is separated from teams directive by multiple curly brackets

2016-04-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 53283.
carlo.bertolli added a comment.

[OPENMP] Remove template for intervening statement and only allow CompoundStmt.


Repository:
  rL LLVM

http://reviews.llvm.org/D18474

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

Index: test/OpenMP/teams_codegen.cpp
===
--- test/OpenMP/teams_codegen.cpp
+++ test/OpenMP/teams_codegen.cpp
@@ -29,6 +29,16 @@
 ++comp;
   }
 
+  // CK1: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 1, i8** 
%{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* 
{{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  {{{
+#pragma omp teams
+{
+  ++comp;
+}
+  }}}
+  
   // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** 
%{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* 
{{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 0)
   // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
 
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4257,6 +4257,20 @@
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief look inside a Body stmt for a LF statement discarding any
+/// intervening CompoundStmt's
+template 
+const static LF *hasEnclosingOpenMPDirective(const Stmt *Body) {
+  const CompoundStmt *S = nullptr;
+  // keep iterating until we find an LF or not a CompoundStmt or a nullptr
+  while ((S = dyn_cast_or_null(Body)) &&
+ (!dyn_cast_or_null(Body)))
+  Body = S->body_front();
+
+  return (Body) ? dyn_cast_or_null(Body) :
+  nullptr;
+}
+
 /// \brief Emit the num_teams clause of an enclosed teams directive at the
 /// target region scope. If there is no teams directive associated with the
 /// target directive, or if there is no num_teams clause associated with the
@@ -4287,7 +4301,8 @@
 
   // FIXME: Accommodate other combined directives with teams when they become
   // available.
-  if (auto *TeamsDir = dyn_cast(CS.getCapturedStmt())) {
+  if (auto *TeamsDir = hasEnclosingOpenMPDirective(
+  CS.getCapturedStmt())) {
 if (auto *NTE = TeamsDir->getSingleClause()) {
   CGOpenMPInnerExprInfo CGInfo(CGF, CS);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
@@ -4335,7 +4350,8 @@
 
   // FIXME: Accommodate other combined directives with teams when they become
   // available.
-  if (auto *TeamsDir = dyn_cast(CS.getCapturedStmt())) {
+  if (auto *TeamsDir = hasEnclosingOpenMPDirective(
+  CS.getCapturedStmt())) {
 if (auto *TLE = TeamsDir->getSingleClause()) {
   CGOpenMPInnerExprInfo CGInfo(CGF, CS);
   CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);


Index: test/OpenMP/teams_codegen.cpp
===
--- test/OpenMP/teams_codegen.cpp
+++ test/OpenMP/teams_codegen.cpp
@@ -29,6 +29,16 @@
 ++comp;
   }
 
+  // CK1: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 1, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 0, i32 0)
+  // CK1: call void @{{.+}}(i{{64|32}} %{{.+}})
+  #pragma omp target
+  {{{
+#pragma omp teams
+{
+  ++comp;
+}
+  }}}
+  
   // CK1-DAG: call i32 @__tgt_target_teams(i32 -1, i8* @{{[^,]+}}, i32 2, i8** %{{[^,]+}}, i8** %{{[^,]+}}, i{{64|32}}* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32* {{.+}}@{{[^,]+}}, i32 0, i32 0), i32 [[NT:%[^,]+]], i32 0)
   // CK1-DAG: [[NT]] = load i32, i32* [[NTA:%[^,]+]],
 
Index: lib/CodeGen/CGOpenMPRuntime.cpp
===
--- lib/CodeGen/CGOpenMPRuntime.cpp
+++ lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4257,6 +4257,20 @@
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief look inside a Body stmt for a LF statement discarding any
+/// intervening CompoundStmt's
+template 
+const static LF *hasEnclosingOpenMPDirective(const Stmt *Body) {
+  const CompoundStmt *S = nullptr;
+  // keep iterating until we find an LF or not a CompoundStmt or a nullptr
+  while ((S = dyn_cast_or_null(Body)) &&
+ (!dyn_cast_or_null(Body)))
+  Body = S->body_front();
+
+  return (Body) ? dyn_cast_or_null(Body) :
+  nullptr;
+}
+
 /// \brief Emit the num_teams clause of an enclosed teams directive at the
 /// target region scope. If there is no teams directive associated with the
 /// target directive, or if there is no num_teams clause associated with the
@@ -4287,7 +4301,8 @@
 
   // FIXME: Accommodate other combined directives with teams when they become
   // available.
-  if (auto *TeamsDir = dyn_cast(CS.getCapturedStmt())) {
+  if (auto *TeamsDir = hasEnclosingO

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki updated this revision to Diff 53289.
pilki marked 5 inline comments as done.

http://reviews.llvm.org/D18961

Files:
   clang-tidy/readability/CMakeLists.txt
   clang-tidy/readability/DeletedDefaultCheck.cpp
   clang-tidy/readability/DeletedDefaultCheck.h
   clang-tidy/readability/ReadabilityTidyModule.cpp
   docs/ReleaseNotes.rst
   docs/clang-tidy/checks/list.rst
   docs/clang-tidy/checks/readability-deleted-default.rst
   test/clang-tidy/readability-deleted-default.cpp

Index:  test/clang-tidy/readability-deleted-default.cpp
===
---  test/clang-tidy/readability-deleted-default.cpp
+++  test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,127 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault &&Other) = delete;
+  NoDefault(const NoDefault &Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: default constructor is marked '= default' but is actually implicitly deleted, probably because an instance variable or a base class is lacking a default constructor; this definition should either be removed or explicitly marked as '= delete' [readability-deleted-default]
+  MissingEverything(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move constructor is marked '= default' but is actually implicitly deleted, probably because an instance variable or a base class is not copyable nor movable; this definition should either be removed or explicitly marked as '= delete' [readability-deleted-default]
+  MissingEverything(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is marked '= default' but is actually implicitly deleted, probably because an instance variable or a base class is not copyable; this definition should either be removed or explicitly marked as '= delete' [readability-deleted-default]
+  MissingEverything &operator=(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is marked '= default' but is actually implicitly deleted, probably because a base class or an instance variable is not assignable, e.g. because the latter is marked 'const'; this definition should either be removed or explicitly marked as '= delete' [readability-deleted-default]
+  MissingEverything &operator=(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is marked '= default' but is actually implicitly deleted, probably because a base class or an instance variable is not assignable, e.g. because the latter is marked 'const'; this definition should either be removed or explicitly marked as '= delete' [readability-deleted-default]
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable &&Other) = default;
+  NotAssignable(const NotAssignable &Other) = default;
+  NotAssignable &operator=(NotAssignable &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is marked '= default' but is actually implicitly deleted
+  NotAssignable &operator=(const NotAssignable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is marked '= default' but is actually implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable &&Other) = default;
+  Movable(const Movable &Other) = delete;
+  Movable &operator=(Movable &&Other) = default;
+  Movable &operator=(const Movable &Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable &&Other) = default;
+  NotCopyable(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is marked '= default' but is actually implicitly deleted
+  NotCopyable &operator=(NotCopyable &&Other) = default;
+  NotCopyable &operator=(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is marked '= default' but is actually implicitly deleted
+private:
+  Movable M;
+};
+
+template  class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated &&Other) = default;
+  Templated(const Templated &Other) = default;
+  Templated &operator=(Templated &&Other) = default;
+  Templated &operator=(const Templated &Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated &&Other) = default;
+InnerTemplated(const InnerTemplated &Other) = default;
+InnerTemplated &operator=(InnerTemplated &&Other) = default;
+InnerTemplated &operator=(const InnerTemplated &Other) = default;
+
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically have warnings, but currently

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-11 Thread Alex Pilkiewicz via cfe-commits
pilki added a comment.

I hope I answered all comments (sorry if I missed some, I'm not yet used to 
this UI).

I have an open question about isInTemplateInstantiation, and added a test 
(since I missed templated function)



Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:27
@@ +26,3 @@
+  const auto NotTemplate = unless(hasAncestor(
+  cxxRecordDecl(::clang::ast_matchers::isTemplateInstantiation(;
+

alexfh wrote:
> What about this comment?
isInTemplateInstantiation() is a matcher on Stmt only (when hasAncestor is a 
polymorphic matcher). When using it, it does not compile. So I copied the body 
here. I don't know how bad that is.


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18953: [ms][dll] #26935 Defining a dllimport function should cause it to be exported

2016-04-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:5570
@@ -5565,3 +5569,3 @@
   // and qualified friend declarations.
-  // NB: MSVC converts such a declaration to dllexport.
+  // NB: MSVC converts such a declaration to dllexport that's why we do it 
also.
   bool IsInline = false, IsStaticDataMember = false, IsQualifiedFriend = false;

Just describe this as the semantics of this situation rather than suggesting 
this is some MSVC oddity we're emulating. "In such a case, the declaration is 
treated as if it were marked dllexport." or similar.

It also seems bizarre for this behavior to apply for local extern declarations 
and qualified friend declarations. Does the "dllimport gets turned into 
dllexport" behavior actually only apply to the definition case? And does the 
definition need to be inline?


Comment at: lib/Sema/SemaDecl.cpp:5595
@@ +5594,3 @@
+  // Replace DLLImportAttr with DLLExportAttr
+  OldDecl->dropAttr();
+  NewDecl->dropAttr();

Don't change attributes on a prior declaration; AST nodes should generally be 
immutable once created (this would lose source fidelity, and break under 
PCH/modules). Instead, make sure that anyone who looks at this gets the 
attribute from the appropriate (most recent) declaration and only change the 
attributes there.


Comment at: lib/Sema/SemaDecl.cpp:5596
@@ +5595,3 @@
+  OldDecl->dropAttr();
+  NewDecl->dropAttr();
+  OldDecl->addAttr(::new (S.Context) DLLExportAttr(

Is this really valid and treated as `__dllexport` if the new declaration 
explicitly specifies `__dllimport` (rather than inheriting it)?


Comment at: lib/Sema/SemaDecl.cpp:5600-5602
@@ +5599,5 @@
+  OldImportAttr->getSpellingListIndex()));
+  NewDecl->addAttr(::new (S.Context) DLLExportAttr(
+  NewImportAttr->getRange(), S.Context,
+  NewImportAttr->getSpellingListIndex()));
+} else {

The new attribute should be marked implicit.


http://reviews.llvm.org/D18953



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


r265977 - Emit the module hash by default with -flto=thin.

2016-04-11 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Mon Apr 11 13:45:20 2016
New Revision: 265977

URL: http://llvm.org/viewvc/llvm-project?rev=265977&view=rev
Log:
Emit the module hash by default with -flto=thin.

Reviewers: tejohnson

Subscribers: joker.eph, cfe-commits

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

From: Mehdi Amini 

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=265977&r1=265976&r2=265977&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Apr 11 13:45:20 2016
@@ -668,7 +668,8 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 
   case Backend_EmitBC:
 getPerModulePasses()->add(createBitcodeWriterPass(
-*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex));
+*OS, CodeGenOpts.EmitLLVMUseLists, CodeGenOpts.EmitSummaryIndex,
+CodeGenOpts.EmitSummaryIndex));
 break;
 
   case Backend_EmitLL:


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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 

t.p.northover wrote:
> v7s is Swift, which has FMA. v7 for us is Cortex-A9, which I think also has 
> FMA (not that it matters much these days).
v7 is Cortex-A8, and neither A8 nor A9 have FMA in VFP, only NEON.

Does Swift have FMA in VFP? or just NEON?


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18963: PR27216: Only define __ARM_FEATURE_FMA when the target has VFPv4

2016-04-11 Thread Tim Northover via cfe-commits
t.p.northover added inline comments.


Comment at: test/Sema/arm_vfma.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple thumbv7s-apple-ios7.0 -target-feature +neon 
-target-feature +vfp4 -fsyntax-only -verify %s
 #include 

rengolin wrote:
> t.p.northover wrote:
> > v7s is Swift, which has FMA. v7 for us is Cortex-A9, which I think also has 
> > FMA (not that it matters much these days).
> v7 is Cortex-A8, and neither A8 nor A9 have FMA in VFP, only NEON.
> 
> Does Swift have FMA in VFP? or just NEON?
Sorry, it appears virtually every part of my statement was wrong then. v7 
really does seem to be Cortex-A8 even for us, and Swift doesn't have scalar 
VFMA.


http://reviews.llvm.org/D18963



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


Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-11 Thread Joerg Sonnenberger via cfe-commits
joerg added a subscriber: joerg.
joerg added a comment.

ctype.h functions are only pure, not const?


http://reviews.llvm.org/D18970



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


r265982 - Lit C++11 Compatibility Patch #6

2016-04-11 Thread Charles Li via cfe-commits
Author: lcharles
Date: Mon Apr 11 14:30:25 2016
New Revision: 265982

URL: http://llvm.org/viewvc/llvm-project?rev=265982&view=rev
Log:
Lit C++11 Compatibility Patch #6

Updated the expected diagnostics of 17 OpenMP tests.
The changes to each test are identical.

Modified:
cfe/trunk/test/OpenMP/for_collapse_messages.cpp
cfe/trunk/test/OpenMP/for_ordered_clause.cpp
cfe/trunk/test/OpenMP/for_simd_collapse_messages.cpp
cfe/trunk/test/OpenMP/for_simd_safelen_messages.cpp
cfe/trunk/test/OpenMP/for_simd_simdlen_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_collapse_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_ordered_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_collapse_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_safelen_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_simdlen_messages.cpp
cfe/trunk/test/OpenMP/simd_collapse_messages.cpp
cfe/trunk/test/OpenMP/simd_safelen_messages.cpp
cfe/trunk/test/OpenMP/simd_simdlen_messages.cpp
cfe/trunk/test/OpenMP/taskloop_collapse_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_collapse_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_safelen_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_simdlen_messages.cpp

Modified: cfe/trunk/test/OpenMP/for_collapse_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_collapse_messages.cpp?rev=265982&r1=265981&r2=265982&view=diff
==
--- cfe/trunk/test/OpenMP/for_collapse_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/for_collapse_messages.cpp Mon Apr 11 14:30:25 2016
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -29,14 +34,21 @@ T tmain(T argc, S **argv) { //expected-n
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as 
specified in 'collapse' clause}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // 
expected-error 2 {{expected 2 for loops after '#pragma omp for', but found only 
1}}
-  // expected-error@+3 2 {{directive '#pragma omp for' cannot contain more 
than one 'collapse' clause}}
-  // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
-  // expected-error@+1 2 {{expression is not an integral constant expression}}
+  // expected-error@+6 2 {{directive '#pragma omp for' cannot contain more 
than one 'collapse' clause}}
+  // expected-error@+5 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+  // expected-error@+4 2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+  // expected-note@+2 2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
   #pragma omp for collapse (foobool(argc)), collapse (true), collapse (-5)
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for collapse (S) // expected-error {{'S' does not refer to a 
value}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  // expected-error@+1 2 {{expression is not an integral constant expression}}
+#if __cplusplus <= 199711L
+  // expected-error@+4 2 {{expression is not an integral constant expression}}
+#else
+  // expected-error@+2 2 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#endif
   #pragma omp for collapse (argv[1]=2) // expected-error {{expected ')'}} 
expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for collapse (1)
@@ -59,16 +71,27 @@ int main(int argc, char **argv) {
   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // 
expected-error {{expected 4 for loops after '#pragma omp for', but found only 
1}}
   #pragma omp for collapse (2+2)) // expected-warning {{extra tokens at the 
end of '#pragma omp for' are ignored}}  expected-note {{as specified in 
'collapse' clause}}
   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // 
expected-error {{expected 4 for loops after '#pragma omp for', but found only 
1}}
-  #pragma omp for collapse (foobool(1) > 0 ? 1 : 2) // expected-error 
{{expression is not an integral constant expression}}
-  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
-  // expected-error@+3 {{expression is not an integral constant expression}}
+  // expected-error@+4 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+  // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
+  #pragma omp for coll

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Richard Smith via cfe-commits
rsmith added a comment.

@vbyakovl The description of this patch is very misleading. What I believe this 
does is to allow VLAs with non-trivially-destructed element types. Can you fix 
the description (and make sure the fixed version ends up in the commit message 
if this is approved)?
@rjmccall Do you recall why we disallow this?


http://reviews.llvm.org/D18823



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


Re: [PATCH] D18849: [modules] Avoid module relocation error when building modules from VFS

2016-04-11 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

This doesn't appear to be a safe change.  We can't assume that `RootName` 
wouldn't ever be legitimately found somewhere in a path (even without a VFS) 
and changing the path prefix could give a completely different location.  I 
would also be concerned about the performance impact of performing two lookups, 
since finding a module for a header is not always a cheap operation.

I'm not sure off hand how else to fix this.


http://reviews.llvm.org/D18849



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


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

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

It requires careful IRGen support which at one point did not exist.  When I 
implemented VLAs of __strong/__weak references for ARC, I deliberately tried to 
make sure that the infrastructure would also work for the C++ cases, but I 
didn't have time to go actually test any of it.  It looks like the support was 
nearly sufficient.


http://reviews.llvm.org/D18823



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


[PATCH] D18991: [ASTMatchers]: fix crash in hasReturnValue

2016-04-11 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: klimek, alexfh.
mgehre added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

The crash was reproduced by the included test case. It was initially
found through a crash of clang-tidy's misc-misplaced-widening-cast
check.

http://reviews.llvm.org/D18991

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5500,6 +5500,7 @@
   StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
   EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
   EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+  EXPECT_FALSE(matches("void F() { return; }", RetVal));
 }
 
 } // end namespace ast_matchers
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5015,6 +5015,8 @@
 ///   matching 'a + b'
 AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
   InnerMatcher) {
+  if (!Node.getRetValue())
+return false;
   return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
 }
 


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -5500,6 +5500,7 @@
   StatementMatcher RetVal = returnStmt(hasReturnValue(binaryOperator()));
   EXPECT_TRUE(matches("int F() { int a, b; return a + b; }", RetVal));
   EXPECT_FALSE(matches("int F() { int a; return a; }", RetVal));
+  EXPECT_FALSE(matches("void F() { return; }", RetVal));
 }
 
 } // end namespace ast_matchers
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5015,6 +5015,8 @@
 ///   matching 'a + b'
 AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher, 
   InnerMatcher) {
+  if (!Node.getRetValue())
+return false;
   return InnerMatcher.matches(*Node.getRetValue(), Finder, Builder);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-11 Thread Taewook Oh via cfe-commits
twoh added a comment.

@joerg My bad. They surely read from globals. I'll fix the diff. Thanks for the 
catch!


http://reviews.llvm.org/D18970



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


Re: [PATCH] RHEL: Look in more places to find g++ headers and runtime

2016-04-11 Thread Michael Lampe via cfe-commits

New patch attached.

-Michael

Rafael EspĂ­ndola wrote:

LGTM with a comment saying why it is needed.

Cheers,
Rafael


On 22 March 2016 at 23:02, Michael Lampe via cfe-commits
 wrote:

Some distros with ten years of support ship an old gcc but later offer more
recent versions for installation in parallel. These versions are typically
not only needed for the compilation of llvm/clang, but also to properly use
the clang binary that comes out.

Clang already searches /usr at runtime for the most recent installation of
gcc. This patch appends paths for add-on installations of gcc in RHEL.


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





Index: clang/lib/Driver/ToolChains.cpp
===
--- clang/lib/Driver/ToolChains.cpp	(revision 265970)
+++ clang/lib/Driver/ToolChains.cpp	(working copy)
@@ -1370,9 +1370,17 @@
 // Then look for gcc installed alongside clang.
 Prefixes.push_back(D.InstalledDir + "/..");
 
-// And finally in /usr.
-if (D.SysRoot.empty())
+// Then look for distribution supplied gcc installations.
+if (D.SysRoot.empty()) {
+  // Look for RHEL devtoolsets.
+  Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-2/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-1.1/root/usr");
+  Prefixes.push_back("/opt/rh/devtoolset-1.0/root/usr");
+  // And finally in /usr.
   Prefixes.push_back("/usr");
+}
   }
 
   // Loop over the various components which exist and select the best GCC
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r265991 - Adjust tests to have consistent integer sizes.

2016-04-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Mon Apr 11 15:37:04 2016
New Revision: 265991

URL: http://llvm.org/viewvc/llvm-project?rev=265991&view=rev
Log:
Adjust tests to have consistent integer sizes.

Add a triple to the run lines so that integers will the same sizes across runs.
Also add a compile time check to ensure the assumptions about sizes are met.

Modified:
cfe/trunk/test/Sema/integer-overflow.c
cfe/trunk/test/SemaCXX/integer-overflow.cpp

Modified: cfe/trunk/test/Sema/integer-overflow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/integer-overflow.c?rev=265991&r1=265990&r2=265991&view=diff
==
--- cfe/trunk/test/Sema/integer-overflow.c (original)
+++ cfe/trunk/test/Sema/integer-overflow.c Mon Apr 11 15:37:04 2016
@@ -1,6 +1,11 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -triple x86_64-pc-linux-gnu
 typedef unsigned long long uint64_t;
-typedef unsigned long long uint32_t;
+typedef unsigned int uint32_t;
+
+// Check integer sizes.
+int array64[sizeof(uint64_t) == 8 ? 1 : -1];
+int array32[sizeof(uint32_t) == 4 ? 1 : -1];
+int arrayint[sizeof(int) < sizeof(uint64_t) ? 1 : -1];
 
 uint64_t f0(uint64_t);
 uint64_t f1(uint64_t, uint32_t);

Modified: cfe/trunk/test/SemaCXX/integer-overflow.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/integer-overflow.cpp?rev=265991&r1=265990&r2=265991&view=diff
==
--- cfe/trunk/test/SemaCXX/integer-overflow.cpp (original)
+++ cfe/trunk/test/SemaCXX/integer-overflow.cpp Mon Apr 11 15:37:04 2016
@@ -1,6 +1,11 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98 -triple 
x86_64-pc-linux-gnu
 typedef unsigned long long uint64_t;
-typedef unsigned long long uint32_t;
+typedef unsigned int uint32_t;
+
+// Check integer sizes.
+int array64[sizeof(uint64_t) == 8 ? 1 : -1];
+int array32[sizeof(uint32_t) == 4 ? 1 : -1];
+int arrayint[sizeof(int) < sizeof(uint64_t) ? 1 : -1];
 
 uint64_t f0(uint64_t);
 uint64_t f1(uint64_t, uint32_t);


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


Re: [PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-11 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 53315.
mgehre added a comment.

Update for review comments; simplified lexing, added proposed test case


http://reviews.llvm.org/D18914

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantInlineCheck.cpp
  clang-tidy/readability/RedundantInlineCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-inline.rst
  test/clang-tidy/readability-redundant-inline.cpp

Index: test/clang-tidy/readability-redundant-inline.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-inline.cpp
@@ -0,0 +1,72 @@
+// RUN: %check_clang_tidy %s readability-redundant-inline %t
+
+struct S {
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  int f1()
+return 0;
+  }
+  inline int f2(); // OK
+
+  inline constexpr int f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'inline' is redundant because 'constexpr' implies 'inline' [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  constexpr int f3()
+return 0;
+  }
+  static inline constexpr int f4() {
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'inline' is redundant because 'constexpr' implies 'inline'
+// CHECK-FIXES: {{^}}  static constexpr int f4()
+return 0;
+  }
+
+  static inline int f5();
+
+  static inline int f6() {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  static int f6()
+return 0;
+  }
+
+  inline friend int f7() {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'inline' is redundant because function body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  friend int f7()
+  return 0;
+  }
+
+  inline friend int f8(); // OK
+
+  template struct T{};
+  struct T inline f9() { return {}; }
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  struct T f9() { return {}; }
+};
+
+class S2 {
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  int f1()
+return 0;
+  }
+};
+
+inline int S::f2() { // OK
+  return 0;
+}
+
+inline int S::f5() { // OK
+  return 0;
+}
+
+inline int f3() { // OK
+  return 0;
+}
+
+inline constexpr int f4() {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 'inline' is redundant because 'constexpr' implies 'inline'
+// CHECK-FIXES: {{^}}constexpr int f4()
+  return 1;
+}
+
+constexpr int f5() { // OK
+  return 1;
+}
Index: docs/clang-tidy/checks/readability-redundant-inline.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-inline.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - readability-redundant-inline
+
+readability-redundant-inline
+
+
+This check flags redundant ``inline`` specifiers.
+It flags ``inline`` on member functions defined inside a class definition like
+.. code-block:: c++
+
+  struct S {
+inline int f() {
+  return 0;
+}
+  };
+
+and ``inline`` specifiers on functions that are also declared ``constexpr``.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
readability-inconsistent-declaration-parameter-name
readability-named-parameter
readability-redundant-control-flow
+   readability-redundant-inline
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -160,6 +160,12 @@
   Looks for procedures (functions returning no value) with ``return`` statements
   at the end of the function.  Such `return` statements are redundant.
 
+- New `readability-redundant-inline
+  `_ check
+
+  Looks for redundant ``inline`` specifiers which are implied by defining a body within a class definition
+  or by ``constexpr``.
+
 - New `readability-redundant-string-init
   `_ check
 
Index: clang-tidy/readability/RedundantInlineCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantInlineCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantInlineCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Comp

r265994 - libclang: fix two memory leaks (PR26292)

2016-04-11 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Apr 11 15:53:59 2016
New Revision: 265994

URL: http://llvm.org/viewvc/llvm-project?rev=265994&view=rev
Log:
libclang: fix two memory leaks (PR26292)

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=265994&r1=265993&r2=265994&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Apr 11 15:53:59 2016
@@ -3571,12 +3571,13 @@ static const ExprEvalResult* evaluateExp
   rettype = callExpr->getCallReturnType(ctx);
 
   if (rettype->isVectorType() || callExpr->getNumArgs() > 1) {
+clang_EvalResult_dispose((CXEvalResult *)result);
 return nullptr;
   }
   if (rettype->isIntegralType(ctx) || rettype->isRealFloatingType()) {
 if(callExpr->getNumArgs() == 1 &&
-  !callExpr->getArg(0)->getType()->isIntegralType(ctx)){
-
+  !callExpr->getArg(0)->getType()->isIntegralType(ctx)) {
+  clang_EvalResult_dispose((CXEvalResult *)result);
   return nullptr;
 }
   } else if(rettype.getAsString() == "CFStringRef") {


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


Re: [PATCH] D18849: [modules] Avoid module relocation error when building modules from VFS

2016-04-11 Thread Richard Smith via cfe-commits
rsmith added a comment.

Can you find who's poisoning the `FileManager`'s idea of the name of the file 
with a full path to the VFS overlay and fix that?



Comment at: lib/Lex/HeaderSearch.cpp:1163
@@ +1162,3 @@
+SmallString<256> RootName = StringRef(Root->getName());
+path::remove_dots(RootName, true/*remove_dot_dot*/);
+auto Pos = FileName.find(RootName);

remove_dot_dot=true is not a correct transformation to do to a path and can 
result in the wrong file being found.


http://reviews.llvm.org/D18849



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


Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-04-11 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 53316.
jbcoe added a comment.
This revision is now accepted and ready to land.

Remove `isDeleted` as it needs to be added for non-member functions.

I will add `isDeleted` as an isolated follow up patch.


http://reviews.llvm.org/D15469

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  test/Index/availability.cpp
  test/Index/file-refs.cpp
  test/Index/get-cursor.cpp
  test/Index/index-file.cpp
  test/Index/load-classes.cpp
  test/Index/print-type.cpp
  test/Index/recursive-cxx-member-calls.cpp
  test/Parser/skip-function-bodies.mm
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -2,7 +2,12 @@
 clang_CXCursorSet_insert
 clang_CXIndex_getGlobalOptions
 clang_CXIndex_setGlobalOptions
+clang_CXXConstructor_isConvertingConstructor
+clang_CXXConstructor_isCopyConstructor
+clang_CXXConstructor_isDefaultConstructor
+clang_CXXConstructor_isMoveConstructor
 clang_CXXField_isMutable
+clang_CXXMethod_isDefaulted
 clang_CXXMethod_isConst
 clang_CXXMethod_isPureVirtual
 clang_CXXMethod_isStatic
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7387,6 +7387,48 @@
 //===--===//
 
 extern "C" {
+
+unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Constructor && Constructor->isDefaultConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Constructor && Constructor->isCopyConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Constructor && Constructor->isMoveConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  // Passing 'false' excludes constructors marked 'explicit'.
+  return (Constructor && Constructor->isConvertingConstructor(false)) ? 1 : 0;
+}
+
 unsigned clang_CXXField_isMutable(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
@@ -7417,6 +7459,16 @@
   return (Method && (Method->getTypeQualifiers() & Qualifiers::Const)) ? 1 : 0;
 }
 
+unsigned clang_CXXMethod_isDefaulted(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXMethodDecl *Method =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Method && Method->isDefaulted()) ? 1 : 0;
+}
+
 unsigned clang_CXXMethod_isStatic(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -772,9 +772,20 @@
 
 clang_disposeString(DeprecatedMessage);
 clang_disposeString(UnavailableMessage);
-
+
+if (clang_CXXConstructor_isDefaultConstructor(Cursor))
+  printf(" (default constructor)");
+
+if (clang_CXXConstructor_isMoveConstructor(Cursor))
+  printf(" (move constructor)");
+if (clang_CXXConstructor_isCopyConstructor(Cursor))
+  printf(" (copy constructor)");
+if (clang_CXXConstructor_isConvertingConstructor(Cursor))
+  printf(" (converting constructor)");
 if (clang_CXXField_isMutable(Cursor))
   printf(" (mutable)");
+if (clang_CXXMethod_isDefaulted(Cursor))
+  printf(" (defaulted)");
 if (clang_CXXMethod_isStatic(Cursor))
   printf(" (static)");
 if (clang_CXXMethod_isVirtual(Cursor))
Index: test/Parser/skip-function-bodies.mm
===
--- test/Parser/skip-function-bodies.mm
+++ test/Parser/skip-function-bodies.mm
@@ -30,7 +30,7 @@
 // CHECK: skip-function-bodies.mm:3:7: ClassDecl=A:3:7 (Definition) Extent=[3:1 - 14:2]
 // CHECK: skip-function-bodies.mm:4:9: ClassDecl=

Re: [PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-11 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 53317.
mgehre added a comment.

Removed debug output


http://reviews.llvm.org/D18914

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantInlineCheck.cpp
  clang-tidy/readability/RedundantInlineCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-redundant-inline.rst
  test/clang-tidy/readability-redundant-inline.cpp

Index: test/clang-tidy/readability-redundant-inline.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-inline.cpp
@@ -0,0 +1,72 @@
+// RUN: %check_clang_tidy %s readability-redundant-inline %t
+
+struct S {
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  int f1()
+return 0;
+  }
+  inline int f2(); // OK
+
+  inline constexpr int f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'inline' is redundant because 'constexpr' implies 'inline' [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  constexpr int f3()
+return 0;
+  }
+  static inline constexpr int f4() {
+// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'inline' is redundant because 'constexpr' implies 'inline'
+// CHECK-FIXES: {{^}}  static constexpr int f4()
+return 0;
+  }
+
+  static inline int f5();
+
+  static inline int f6() {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  static int f6()
+return 0;
+  }
+
+  inline friend int f7() {
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'inline' is redundant because function body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  friend int f7()
+  return 0;
+  }
+
+  inline friend int f8(); // OK
+
+  template struct T{};
+  struct T inline f9() { return {}; }
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  struct T f9() { return {}; }
+};
+
+class S2 {
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because method body is defined inside class
+// CHECK-FIXES: {{^}}  int f1()
+return 0;
+  }
+};
+
+inline int S::f2() { // OK
+  return 0;
+}
+
+inline int S::f5() { // OK
+  return 0;
+}
+
+inline int f3() { // OK
+  return 0;
+}
+
+inline constexpr int f4() {
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 'inline' is redundant because 'constexpr' implies 'inline'
+// CHECK-FIXES: {{^}}constexpr int f4()
+  return 1;
+}
+
+constexpr int f5() { // OK
+  return 1;
+}
Index: docs/clang-tidy/checks/readability-redundant-inline.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-inline.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - readability-redundant-inline
+
+readability-redundant-inline
+
+
+This check flags redundant ``inline`` specifiers.
+It flags ``inline`` on member functions defined inside a class definition like
+.. code-block:: c++
+
+  struct S {
+inline int f() {
+  return 0;
+}
+  };
+
+and ``inline`` specifiers on functions that are also declared ``constexpr``.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
readability-inconsistent-declaration-parameter-name
readability-named-parameter
readability-redundant-control-flow
+   readability-redundant-inline
readability-redundant-smartptr-get
readability-redundant-string-cstr
readability-redundant-string-init
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -160,6 +160,12 @@
   Looks for procedures (functions returning no value) with ``return`` statements
   at the end of the function.  Such `return` statements are redundant.
 
+- New `readability-redundant-inline
+  `_ check
+
+  Looks for redundant ``inline`` specifiers which are implied by defining a body within a class definition
+  or by ``constexpr``.
+
 - New `readability-redundant-string-init
   `_ check
 
Index: clang-tidy/readability/RedundantInlineCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantInlineCheck.h
@@ -0,0 +1,35 @@
+//===--- RedundantInlineCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distribute

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-11 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: llvm/tools/clang/lib/Sema/SemaType.cpp:2158-2159
@@ -2157,3 +2157,4 @@
   if (!getLangOpts().C99) {
-if (T->isVariableArrayType()) {
+if (T->isVariableArrayType() &&
+!(getLangOpts().CPlusPlus && getLangOpts().GNUMode)) {
   // Prohibit the use of non-POD types in VLAs.

This isn't right; this is *not* a GNU C++ extension. GCC rejects it with 
-pedantic-errors in GNU and non-GNU mode, and accepts it by default in GNU and 
non-GNU mode.

What you need to do is to delete the check for a POD element type below, since 
that is the new feature you're adding support for.

Then please revert all of your test changes other than the new file.


http://reviews.llvm.org/D18823



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


Re: [PATCH] D18914: [clang-tidy] new readability-redundant-inline

2016-04-11 Thread Richard Smith via cfe-commits
rsmith added a subscriber: rsmith.


Comment at: test/clang-tidy/readability-redundant-inline.cpp:5
@@ +4,3 @@
+  inline int f1() {
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'inline' is redundant because 
method body is defined inside class [readability-redundant-inline]
+// CHECK-FIXES: {{^}}  int f1()

The `inline` keyword here is not actually redundant to Clang -- we generate an 
LLVM `inlinehint` if `inline` is specified here and not otherwise.


http://reviews.llvm.org/D18914



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


Re: [PATCH] D18991: [ASTMatchers]: fix crash in hasReturnValue

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

LG.

This should also fix http://llvm.org/PR27298


http://reviews.llvm.org/D18991



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


Re: [PATCH] D18991: [ASTMatchers]: fix crash in hasReturnValue

2016-04-11 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:5018
@@ -5017,1 +5017,3 @@
   InnerMatcher) {
+  if (!Node.getRetValue())
+return false;

nit: might be a bit clearer, if you reverse the condition:

  if (const auto *RetValue = Node.getRetValue())
return InnerMatcher.matches(*RetValue, Finder, Builder);
  return false;


http://reviews.llvm.org/D18991



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


Re: [PATCH] D17993: [CodeGen] Apply 'nonnull' to 'this' pointer arguments.

2016-04-11 Thread Geoff Berry via cfe-commits
gberry added a subscriber: gberry.
gberry added a comment.

Not to hijack this review, but would it not make sense to do something similar 
with the 'this' pointer and the 'dereferenceable' attribute?  Granted, figuring 
out the size to use is trickier, but I believe this would enable LICM e.g. to 
hoist member variable loads out of loops in more cases.


http://reviews.llvm.org/D17993



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


[PATCH] D18993: [clang-tidy] fix readability-avoid-const-params-in-decls creating invalid code in fix-its

2016-04-11 Thread Matthias Gehre via cfe-commits
mgehre created this revision.
mgehre added reviewers: fowles, hokein, sbenza, alexfh.
mgehre added a subscriber: cfe-commits.

The Fix-Its for the added test cases were before:
-void F11(const unsigned int /*version*/);
+void F11(unsigned int int /*version*/);

-void F12(const bool b = true);
+void F12(_Bool true);

http://reviews.llvm.org/D18993

Files:
  clang-tidy/readability/AvoidConstParamsInDecls.cpp
  test/clang-tidy/readability-avoid-const-params-in-decls.cpp

Index: test/clang-tidy/readability-avoid-const-params-in-decls.cpp
===
--- test/clang-tidy/readability-avoid-const-params-in-decls.cpp
+++ test/clang-tidy/readability-avoid-const-params-in-decls.cpp
@@ -10,7 +10,7 @@
 
 void F2(const int *const i);
 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
-// CHECK-FIXES: void F2(const int * i);
+// CHECK-FIXES: void F2(const int *i);
 
 void F3(int const i);
 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
@@ -26,7 +26,7 @@
 
 void F6(const int *const);
 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
-// BUG(b/27584482): void F6(const int *);  should be produced
+// CHECK-FIXES: void F6(const int *);
 
 void F7(int, const int);
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: parameter 2 is const-qualified
@@ -43,8 +43,15 @@
 
 void F10(const int *const *const long_name);
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'long_name'
-// CHECK-FIXES: void F10(const int *const * long_name);
+// CHECK-FIXES: void F10(const int *const *long_name);
 
+void F11(const unsigned int /*v*/);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 1
+// CHECK-FIXES: void F11(unsigned int /*v*/);
+
+void F12(const bool b = true);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b'
+// CHECK-FIXES: void F12(bool b = true);
 
 struct Foo {
   Foo(const int i);
Index: clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -28,7 +28,6 @@
 
 } // namespace
 
-
 void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
   const auto ConstParamDecl =
   parmVarDecl(hasType(qualType(isConstQualified(.bind("param");
@@ -38,16 +37,41 @@
  this);
 }
 
+// Re-lex the tokens to get precise location of last 'const'
+static Token ConstTok(CharSourceRange Range,
+  const MatchFinder::MatchResult &Result) {
+  const SourceManager &Sources = *Result.SourceManager;
+  std::pair LocInfo =
+  Sources.getDecomposedLoc(Range.getBegin());
+  StringRef File = Sources.getBufferData(LocInfo.first);
+  const char *TokenBegin = File.data() + LocInfo.second;
+  Lexer RawLexer(Sources.getLocForStartOfFile(LocInfo.first),
+ Result.Context->getLangOpts(), File.begin(), TokenBegin,
+ File.end());
+  Token Tok;
+  Token ConstTok;
+  while (!RawLexer.LexFromRawLexer(Tok)) {
+if (Sources.isBeforeInTranslationUnit(Range.getEnd(), Tok.getLocation()))
+  break;
+if (Tok.is(tok::raw_identifier)) {
+  IdentifierInfo &Info = Result.Context->Idents.get(StringRef(
+  Sources.getCharacterData(Tok.getLocation()), Tok.getLength()));
+  Tok.setIdentifierInfo(&Info);
+  Tok.setKind(Info.getTokenID());
+}
+if (Tok.is(tok::kw_const))
+  ConstTok = Tok;
+  }
+  return ConstTok;
+}
+
 void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
   const auto *Func = Result.Nodes.getNodeAs("func");
   const auto *Param = Result.Nodes.getNodeAs("param");
 
-  QualType Type = Param->getType();
-  if (!Type.isLocalConstQualified())
+  if (!Param->getType().isLocalConstQualified())
 return;
 
-  Type.removeLocalConst();
-
   auto Diag = diag(Param->getLocStart(),
"parameter %0 is const-qualified in the function "
"declaration; const-qualification of parameters only has an "
@@ -62,8 +86,17 @@
   } else {
 Diag << Param;
   }
-  Diag << FixItHint::CreateReplacement(getTypeRange(*Param),
-   Type.getAsString());
+
+  CharSourceRange FileRange = Lexer::makeFileCharRange(
+  CharSourceRange::getTokenRange(getTypeRange(*Param)),
+  *Result.SourceManager, Result.Context->getLangOpts());
+
+  if (!FileRange.isValid())
+return;
+
+  Token Tok = ConstTok(FileRange, Result);
+  Diag << FixItHint::CreateRemoval(
+  CharSourceRange::getTokenRange(Tok.getLocation(), Tok.getLocation()));
 }
 
 } // namespace readability
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17180: Fix failing python bindings test

2016-04-11 Thread Jonathan B Coe via cfe-commits
jbcoe abandoned this revision.
jbcoe added a comment.

Fixed in http://reviews.llvm.org/D17278


Repository:
  rL LLVM

http://reviews.llvm.org/D17180



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


Re: [PATCH] D18993: [clang-tidy] fix readability-avoid-const-params-in-decls creating invalid code in fix-its

2016-04-11 Thread Matt Kulukundis via cfe-commits
fowles accepted this revision.
fowles added a comment.
This revision is now accepted and ready to land.

Thanks for doing this!  I tried a bunch of variants and just couldn't figure it 
out.


http://reviews.llvm.org/D18993



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


  1   2   >