Re: [PATCH] D18648: make __builtin_isfinite more efficient (PR27145)

2016-04-07 Thread Chandler Carruth via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM, nice!


http://reviews.llvm.org/D18648



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


Re: [PATCH] D18617: Call TargetMachine::addEarlyAsPossiblePasses from BackendUtil.

2016-04-07 Thread Chandler Carruth via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Minor tweak, but with that LGTM once the LLVM side is in place.



Comment at: lib/CodeGen/BackendUtil.cpp:347
@@ +346,3 @@
+PassManagerBuilder::EP_EarlyAsPossible,
+[this](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
+  TM->addEarlyAsPossiblePasses(PM);

Why capture this? Capturing TM would seem narrower. If you don't want a narrow 
capture, I'd just use [&]...


http://reviews.llvm.org/D18617



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

2016-04-07 Thread Kim Gräsman via cfe-commits
kimgr added a subscriber: kimgr.
kimgr added a comment.

A test case would be nice here. You can repro on all systems by passing 
`-fdelayed-template-parsing` explicitly.


http://reviews.llvm.org/D18852



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

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

Please add a test file with -fms-compatibility or -fdelayed-template-parsing.


http://reviews.llvm.org/D18852



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


Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

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

A couple of nits.



Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:64
@@ -62,5 +63,3 @@
 unsigned RHSWidth = getMaxCalculationWidth(Context, Bop->getRHS());
-if (Bop->getOpcode() == BO_Mul)
-  return LHSWidth + RHSWidth;
-if (Bop->getOpcode() == BO_Add)
-  return std::max(LHSWidth, RHSWidth) + 1;
+if (Bop->getOpcode() == BO_Mul) return LHSWidth + RHSWidth;
+if (Bop->getOpcode() == BO_Add) return std::max(LHSWidth, RHSWidth) + 1;

If clang-format did this, it used an incorrect style. In LLVM style it should 
put `return` on the next line. It should do the right thing, if you run it with 
`-style=file` and your clang-tools-extra working copy is checked out inside the 
cfe working copy (the important part here is that there's clang's or llvm's 
.clang-format file in a parent directory of the files you're running 
clang-format on).


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:95
@@ -96,40 +94,3 @@
 
-static llvm::SmallDenseMap createRelativeIntSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::UShort] = 2;
-  Result[BuiltinType::Short] = 2;
-  Result[BuiltinType::UInt] = 3;
-  Result[BuiltinType::Int] = 3;
-  Result[BuiltinType::ULong] = 4;
-  Result[BuiltinType::Long] = 4;
-  Result[BuiltinType::ULongLong] = 5;
-  Result[BuiltinType::LongLong] = 5;
-  Result[BuiltinType::UInt128] = 6;
-  Result[BuiltinType::Int128] = 6;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::Char16] = 2;
-  Result[BuiltinType::Char32] = 3;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesWMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::WChar_U] = 2;
-  Result[BuiltinType::WChar_S] = 2;
-  return Result;
+static int RelativeIntSizes(BuiltinType::Kind kind) {
+  switch (kind) {

s/RelativeIntSizes/relativeIntSize/ (singular, first character should be 
lower-case).


Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:223
@@ -201,4 +222,3 @@
 
-} // namespace misc
-} // namespace tidy
-} // namespace clang
+}  // namespace misc
+}  // namespace tidy

Two spaces before comments are common for Google style, so your clang-format 
most certainly uses a wrong style.


http://reviews.llvm.org/D18783



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


Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

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

Wait, it looks like you've updated the patch from an incorrect branch: I see 
only clang-tidy/misc/MisplacedWideningCastCheck.cpp file here.


http://reviews.llvm.org/D18783



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


Re: [PATCH] D18761: [mips] Enable IAS by default for 32-bit MIPS targets (O32).

2016-04-07 Thread Vasileios Kalintiris via cfe-commits
vkalintiris accepted this revision.
vkalintiris added a comment.
This revision is now accepted and ready to land.

LGTM.


http://reviews.llvm.org/D18761



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


r265654 - Move class into an anonymous namespace. NFC.

2016-04-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr  7 05:14:54 2016
New Revision: 265654

URL: http://llvm.org/viewvc/llvm-project?rev=265654&view=rev
Log:
Move class into an anonymous namespace. NFC.

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=265654&r1=265653&r2=265654&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Apr  7 05:14:54 2016
@@ -6657,6 +6657,7 @@ Address HexagonABIInfo::EmitVAArg(CodeGe
 // Lanai ABI Implementation
 
//===--===//
 
+namespace {
 class LanaiABIInfo : public DefaultABIInfo {
 public:
   LanaiABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
@@ -6681,6 +6682,7 @@ public:
 
   ABIArgInfo classifyArgumentType(QualType RetTy, CCState &State) const;
 };
+} // end anonymous namespace
 
 bool LanaiABIInfo::shouldUseInReg(QualType Ty, CCState &State) const {
   unsigned Size = getContext().getTypeSize(Ty);


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


[clang-tools-extra] r265655 - [docs] Update version (http://llvm.org/PR27253)

2016-04-07 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Apr  7 05:17:23 2016
New Revision: 265655

URL: http://llvm.org/viewvc/llvm-project?rev=265655&view=rev
Log:
[docs] Update version (http://llvm.org/PR27253)

Modified:
clang-tools-extra/trunk/docs/conf.py

Modified: clang-tools-extra/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/conf.py?rev=265655&r1=265654&r2=265655&view=diff
==
--- clang-tools-extra/trunk/docs/conf.py (original)
+++ clang-tools-extra/trunk/docs/conf.py Thu Apr  7 05:17:23 2016
@@ -49,9 +49,9 @@ copyright = u'2007-%d, The Clang Team' %
 # built documents.
 #
 # The short X.Y version.
-version = '3.8'
+version = '3.9'
 # The full version, including alpha/beta/rc tags.
-release = '3.8'
+release = '3.9'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


Re: r265640 - Basic: thread CodeGenOptions into TargetInfo

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

On 07/04/16 07:41, Saleem Abdulrasool via cfe-commits wrote:

Author: compnerd
Date: Thu Apr  7 00:41:11 2016
New Revision: 265640

URL: http://llvm.org/viewvc/llvm-project?rev=265640&view=rev
Log:
Basic: thread CodeGenOptions into TargetInfo

This threads CodeGenOptions into the TargetInfo hierarchy.  This is motivated by
ARM which can change some target information based on the EABI selected
(-meabi).  Similar options exist for other platforms (e.g. MIPS) and thus is
generally useful.  NFC.

Modified:
 cfe/trunk/include/clang/Basic/TargetInfo.h
 cfe/trunk/lib/Basic/Targets.cpp
 cfe/trunk/lib/Frontend/ASTUnit.cpp
 cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
 cfe/trunk/lib/Frontend/CompilerInstance.cpp
 cfe/trunk/unittests/Basic/CMakeLists.txt
 cfe/trunk/unittests/Lex/CMakeLists.txt

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=265640&r1=265639&r2=265640&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Apr  7 00:41:11 2016
@@ -21,6 +21,7 @@
  #include "clang/Basic/TargetCXXABI.h"
  #include "clang/Basic/TargetOptions.h"
  #include "clang/Basic/VersionTuple.h"
+#include "clang/Frontend/CodeGenOptions.h"
It seems this introduces a layering issue and breaks even more our 
selfhost modules builds: 
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/14262

Maybe outlining the ctor will fix the issue.

  #include "llvm/ADT/APInt.h"
  #include "llvm/ADT/IntrusiveRefCntPtr.h"
  #include "llvm/ADT/SmallSet.h"
@@ -107,7 +108,8 @@ public:
/// what the backend expects.
static TargetInfo *
CreateTargetInfo(DiagnosticsEngine &Diags,
-   const std::shared_ptr &Opts);
+   const std::shared_ptr &Opts,
+   const CodeGenOptions &CGOpts = CodeGenOptions());
  
virtual ~TargetInfo();
  


Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=265640&r1=265639&r2=265640&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Thu Apr  7 00:41:11 2016
@@ -20,6 +20,7 @@
  #include "clang/Basic/TargetBuiltins.h"
  #include "clang/Basic/TargetOptions.h"
  #include "clang/Basic/Version.h"
+#include "clang/Frontend/CodeGenOptions.h"
  #include "llvm/ADT/APFloat.h"
  #include "llvm/ADT/STLExtras.h"
  #include "llvm/ADT/StringExtras.h"
@@ -76,7 +77,8 @@ protected:
virtual void getOSDefines(const LangOptions &Opts, const llvm::Triple 
&Triple,
  MacroBuilder &Builder) const=0;
  public:
-  OSTargetInfo(const llvm::Triple &Triple) : TgtInfo(Triple) {}
+  OSTargetInfo(const llvm::Triple &Triple, const CodeGenOptions &CGOpts)
+  : TgtInfo(Triple, CGOpts) {}
void getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const override {
  TgtInfo::getTargetDefines(Opts, Builder);
@@ -101,8 +103,8 @@ protected:
}
  
  public:

-  CloudABITargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {}
+  CloudABITargetInfo(const llvm::Triple &Triple, const CodeGenOptions &CGOpts)
+  : OSTargetInfo(Triple, CGOpts) {}
  };
  
  static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,

@@ -220,7 +222,8 @@ protected:
}
  
  public:

-  DarwinTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) {
+  DarwinTargetInfo(const llvm::Triple &Triple, const CodeGenOptions &CGOpts)
+  : OSTargetInfo(Triple, CGOpts) {
  // By default, no TLS, and we whitelist permitted architecture/OS
  // combinations.
  this->TLSSupported = false;
@@ -287,8 +290,9 @@ protected:
  DefineStd(Builder, "unix", Opts);
}
  public:
-  DragonFlyBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {
+  DragonFlyBSDTargetInfo(const llvm::Triple &Triple,
+ const CodeGenOptions &CGOpts)
+  : OSTargetInfo(Triple, CGOpts) {
  switch (Triple.getArch()) {
  default:
  case llvm::Triple::x86:
@@ -329,7 +333,8 @@ protected:
  Builder.defineMacro("__STDC_MB_MIGHT_NEQ_WC__", "1");
}
  public:
-  FreeBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo(Triple) 
{
+  FreeBSDTargetInfo(const llvm::Triple &Triple, const CodeGenOptions &CGOpts)
+  : OSTargetInfo(Triple, CGOpts) {
  switch (Triple.getArch()) {
  default:
  case llvm::Triple::x86:
@@ -368,8 +373,8 @@ protected:
Builder.defineMacro("_GNU_SOURCE");
}
  public:
-  KFreeBSDTargetInfo(const llvm::Triple &Triple)
-  : OSTargetInfo(Triple) {}
+  KFreeBSDTargetInfo(const llvm::Triple &Triple, const CodeGenOptions &CGOpts)
+  : OSTargetInfo(Triple, 

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

2016-04-07 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin updated this revision to Diff 52906.
DmitryPolukhin added a comment.

- rebase after committing llvm patch


http://reviews.llvm.org/D15524

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

Index: test/Sema/attr-ifunc.c
===
--- /dev/null
+++ test/Sema/attr-ifunc.c
@@ -0,0 +1,43 @@
+// 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
+
+#if defined(_WIN32)
+void foo() {}
+void bar() __attribute__((ifunc("foo")));
+//expected-warning@-1 {{'ifunc' attribute ignored}}
+
+#else
+#if defined(CHECK_ALIASES)
+void* f1_ifunc();
+void f1() __attribute__((ifunc("f1_ifunc")));
+//expected-error@-1 {{ifunc must point to a defined function}}
+
+void* f2_a() __attribute__((ifunc("f2_b")));
+//expected-error@-1 {{ifunc definition is part of a cycle}}
+void* f2_b() __attribute__((ifunc("f2_a")));
+//expected-error@-1 {{ifunc definition is part of a cycle}}
+
+void* f3_a() __attribute__((ifunc("f3_b")));
+//expected-warning@-1 {{ifunc will always resolve to f3_c even if weak definition of f3_b is overridden}}
+void* f3_b() __attribute__((weak, alias("f3_c")));
+void* f3_c() { return 0; }
+
+void f4_ifunc() {}
+void f4() __attribute__((ifunc("f4_ifunc")));
+//expected-error@-1 {{ifunc resolver function must return a pointer}}
+
+void* f5_ifunc(int i) { return 0; }
+void f5() __attribute__((ifunc("f5_ifunc")));
+//expected-error@-1 {{ifunc resolver function must have no parameters}}
+
+#else
+void f1a() __asm("f1");
+void f1a() {}
+//expected-note@-1 {{previous definition is here}}
+void f1() __attribute__((ifunc("f1_ifunc")));
+//expected-error@-1 {{definition with same mangled name as another definition}}
+void* f1_ifunc() { return 0; }
+
+#endif
+#endif
Index: test/Sema/attr-alias-elf.c
===
--- test/Sema/attr-alias-elf.c
+++ test/Sema/attr-alias-elf.c
@@ -55,7 +55,7 @@
 
 void test2_bar() {}
 void test2_foo() __attribute__((weak, alias("test2_bar")));
-void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of alias test2_foo is overridden}}
+void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of test2_foo is overridden}}
 
 void test3_bar() { }
 void test3_foo() __attribute__((section("test"))); // expected-warning {{alias will not be in section 'test' but in the same section as the aliasee}}
Index: test/CodeGen/ifunc.c
===
--- /dev/null
+++ test/CodeGen/ifunc.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -O2 -emit-llvm -o - %s | FileCheck %s
+
+int foo(int) __attribute__ ((ifunc("foo_ifunc")));
+
+static int f1(int i) {
+  return i + 1;
+}
+
+static int f2(int i) {
+  return i + 2;
+}
+
+typedef int (*foo_t)(int);
+
+int global;
+
+static foo_t foo_ifunc() {
+  return global ? f1 : f2;
+}
+
+int bar() {
+  return foo(1);
+}
+
+extern void goo(void);
+
+void bar2(void) {
+  goo();
+}
+
+extern void goo(void) __attribute__ ((ifunc("goo_ifunc")));
+
+void* goo_ifunc(void) {
+  return 0;
+}
+// CHECK: @foo = ifunc i32 (i32), bitcast (i32 (i32)* ()* @foo_ifunc to i32 (i32)*)
+// CHECK: @goo = ifunc void (), bitcast (i8* ()* @goo_ifunc to void ()*)
+
+// CHECK: call i32 @foo(i32
+// CHECK: call void @goo()
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1548,6 +1548,28 @@
  Attr.getAttributeSpellingListIndex()));
 }
 
+static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+return;
+
+  // Aliases should be on declarations, not definitions.
+  const auto *FD = cast(D);
+  if (FD->isThisDeclarationADefinition()) {
+S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 1;
+return;
+  }
+  // FIXME: it should be handled as a target specific attribute.
+  if (S.Context.getTargetInfo().getTriple().getObjectFormat() !=
+  llvm::Triple::ELF) {
+S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+return;
+  }
+
+  D->addAttr(::new (S.Context) IFuncAttr(Attr.getRange

r265668 - [OPENMP 4.0] Parsing/sema analysis for 'simdlen' clause in 'declare simd'

2016-04-07 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Apr  7 07:45:37 2016
New Revision: 265668

URL: http://llvm.org/viewvc/llvm-project?rev=265668&view=rev
Log:
[OPENMP 4.0] Parsing/sema analysis for 'simdlen' clause in 'declare simd'
construct.

OpenMP 4.0 defines '#pragma omp declare simd' construct that may have
associated 'simdlen' clause with constant positive expression as an
argument:
simdlen()
Patch adds parsin and semantic analysis for simdlen clause.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/OpenMP/declare_simd_ast_print.c
cfe/trunk/test/OpenMP/declare_simd_ast_print.cpp
cfe/trunk/test/OpenMP/declare_simd_messages.cpp
cfe/trunk/test/OpenMP/dump.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=265668&r1=265667&r2=265668&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Apr  7 07:45:37 2016
@@ -2265,13 +2265,22 @@ def OMPDeclareSimdDecl : Attr {
   let SemaHandler = 0;
   let HasCustomParsing = 1;
   let Documentation = [OMPDeclareSimdDocs];
-  let Args = [EnumArgument<"BranchState", "BranchStateTy",
-   ["", "inbranch", "notinbranch"],
-   ["BS_Undefined", "BS_Inbranch", "BS_Notinbranch"]>];
+  let Args = [
+EnumArgument<"BranchState", "BranchStateTy",
+ [ "", "inbranch", "notinbranch" ],
+ [ "BS_Undefined", "BS_Inbranch", "BS_Notinbranch" ]>,
+ExprArgument<"Simdlen">
+  ];
   let AdditionalMembers = [{
 void printPrettyPragma(raw_ostream & OS, const PrintingPolicy &Policy)
 const {
-  OS << ' ' << ConvertBranchStateTyToStr(getBranchState());
+  if (getBranchState() != BS_Undefined)
+OS << ConvertBranchStateTyToStr(getBranchState()) << " ";
+  if (auto *E = getSimdlen()) {
+OS << "simdlen(";
+E->printPretty(OS, nullptr, Policy);
+OS << ") ";
+  }
 }
   }];
 }

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=265668&r1=265667&r2=265668&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Apr  7 07:45:37 2016
@@ -2456,6 +2456,10 @@ private:
 
   
//======//
   // OpenMP: Directives and clauses.
+  /// Parse clauses for '#pragma omp declare simd'.
+  DeclGroupPtrTy ParseOMPDeclareSimdClauses(DeclGroupPtrTy Ptr,
+CachedTokens &Toks,
+SourceLocation Loc);
   /// \brief Parses declarative OpenMP directives.
   DeclGroupPtrTy ParseOpenMPDeclarativeDirectiveWithExtDecl(
   AccessSpecifier &AS, ParsedAttributesWithRange &Attrs,
@@ -2520,6 +2524,10 @@ private:
   OpenMPClauseKind Kind);
 
 public:
+  /// Parses simple expression in parens for single-expression clauses of 
OpenMP
+  /// constructs.
+  /// \param LLoc Returned location of left paren.
+  ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc);
   bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
   bool AllowDestructorName,
   bool AllowConstructorName,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=265668&r1=265667&r2=265668&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr  7 07:45:37 2016
@@ -8107,7 +8107,7 @@ public:
   DeclGroupPtrTy
   ActOnOpenMPDeclareSimdDirective(DeclGroupPtrTy DG,
   OMPDeclareSimdDeclAttr::BranchStateTy BS,
-  SourceRange SR);
+  Expr *Simdlen, SourceRange SR);
 
   OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind,
  Expr *Expr,

Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=265668&r1=265667&r2=265668&view=diff
==
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Thu Apr  7 07:45:37 2016
@@ -332,32 +332,134 @@ Parser::ParseOpenMPDeclareReductionDirec
 /// Parses clauses

Re: [PATCH] D18829: [clang-tidy] Fix FP with readability-redundant-string-init for default arguments

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

Awesome! Thanks for the fix!


http://reviews.llvm.org/D18829



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


Re: [PATCH] D18833: [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

2016-04-07 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Formatting is broken. `clang-format -style=file`, please.


http://reviews.llvm.org/D18833



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


Re: [PATCH] D18793: fix for 19986, extra spacing around c++14 lambda capture with initializer

2016-04-07 Thread Jacek Sieka via cfe-commits
arnetheduck planned changes to this revision.
arnetheduck added a comment.

Thanks for the comments - I'll see when I have time to get back to this as the 
current patch happens to take care of my (rather limited) use case..



Comment at: lib/Format/UnwrappedLineParser.cpp:1086
@@ +1085,3 @@
+  int parens = 0;
+  while (!eof()) {
+if (FormatTok->isOneOf(tok::l_paren, tok::l_square)) {

djasper wrote:
> We need to be much more error resilient here as people will frequently call 
> clang-format with mismatched parentheses and such. I am actually quite 
> skeptical about having yet another instance of parentheses counting. Maybe 
> just call parseParens() instead?
makes sense.


Comment at: lib/Format/UnwrappedLineParser.cpp:1094
@@ +1093,3 @@
+} else if (!FormatTok->isOneOf(tok::identifier, tok::coloncolon)) {
+  return false;
+}

djasper wrote:
> This seems wrong. Even in the case of the bug you say you are fixing, the 
> "23" is neither an identifier nor a coloncolon..
Ah, right... I've run it against our code base at work where it happened to be 
enough.. , but since full expressions can be used nowadays, I guess it's a lot 
more than just these to that *can* appear.


http://reviews.llvm.org/D18793



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


Re: [PATCH] D18810: [Clang-tidy] Fix readability-static-definition-in-anonymous-namespace warnings; other minor fixes.

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

Please regenerate the patch with the full context.



Comment at: clang-tidy/ClangTidy.cpp:39
@@ -38,1 +38,3 @@
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"

Did you make these changes automatically or use IWYU or a similar tool?


Comment at: clang-tidy/ClangTidy.cpp:58
@@ -56,2 +57,3 @@
 
-static const StringRef StaticAnalyzerChecks[] = {
+const char *AnalyzerCheckNamePrefix = "clang-analyzer-";
+

Please also make it `const char *const` or even better `const char X[] = `.


Comment at: clang-tidy/misc/DanglingHandleCheck.cpp:32
@@ -27,3 +31,3 @@
   std::vector Result;
-  for (StringRef &Class : Classes) {
+  for (auto &Class : Classes) {
 Class = Class.trim();

I'd prefer this to remain `StringRef &`. The type name is short and it's good 
to be able to see that it's not `std::string &`, for example.


Repository:
  rL LLVM

http://reviews.llvm.org/D18810



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


Re: [PATCH] D18510: [cxx1z-constexpr-lambda] Make conversion function constexpr

2016-04-07 Thread Faisal Vali via cfe-commits
faisalv added a comment.

*ping*


http://reviews.llvm.org/D18510



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


Re: [PATCH] D18495: Check default arguments of template template parameters for compatibility.

2016-04-07 Thread Faisal Vali via cfe-commits
faisalv added a comment.

*ping*


http://reviews.llvm.org/D18495



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


[clang-tools-extra] r265671 - [clang-tidy] Fix FP with readability-redundant-string-init for default arguments

2016-04-07 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr  7 09:18:53 2016
New Revision: 265671

URL: http://llvm.org/viewvc/llvm-project?rev=265671&view=rev
Log:
[clang-tidy] Fix FP with readability-redundant-string-init for default arguments

Summary:
Clang-tidy is reporting a warning of redundant string initialisation
on a string parameter initialized with empty string.

See bug: 27087

The reported example is:
```
#include 
void fn(std::string a = "");
```

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp?rev=265671&r1=265670&r2=265671&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringInitCheck.cpp 
Thu Apr  7 09:18:53 2016
@@ -61,7 +61,8 @@ void RedundantStringInitCheck::registerM
 hasInitializer(
 expr(anyOf(EmptyStringCtorExpr,
EmptyStringCtorExprWithTemporaries))
-.bind("expr"
+.bind("expr"))),
+unless(parmVarDecl()))
   .bind("decl"),
   this);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp?rev=265671&r1=265670&r2=265671&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-init.cpp 
Thu Apr  7 09:18:53 2016
@@ -131,3 +131,10 @@ void k() {
 
   std::string d = "u", e = "u", f = "u";
 }
+
+// These cases should not generate warnings.
+extern void Param1(std::string param = "");
+extern void Param2(const std::string& param = "");
+void Param3(std::string param = "") {}
+void Param4(STRING param = "") {}
+


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


[libcxx] r265672 - Fix bug #27260 - add missing swap(reference, reference) to vector.

2016-04-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr  7 09:20:31 2016
New Revision: 265672

URL: http://llvm.org/viewvc/llvm-project?rev=265672&view=rev
Log:
Fix bug #27260 - add missing swap(reference, reference) to vector.

Added:

libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
Modified:
libcxx/trunk/include/vector

Modified: libcxx/trunk/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=265672&r1=265671&r2=265672&view=diff
==
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Thu Apr  7 09:20:31 2016
@@ -2363,6 +2363,7 @@ public:
 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || 
 __is_nothrow_swappable::value);
 #endif
+static void swap(reference __x, reference __y) _NOEXCEPT { 
_VSTD::swap(__x, __y); }
 
 void resize(size_type __sz, value_type __x = false);
 void flip() _NOEXCEPT;

Added: 
libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp?rev=265672&view=auto
==
--- 
libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp 
(added)
+++ 
libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp 
Thu Apr  7 09:20:31 2016
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// vector
+
+// static void swap(reference x, reference y) noexcept;
+
+#include 
+#include 
+
+int main()
+{
+bool a[] = {false, true, false, true};
+bool* an = a + sizeof(a)/sizeof(a[0]);
+
+   std::vector v(a, an);
+   std::vector::reference r1 = v[0];
+   std::vector::reference r2 = v[3];
+   assert(!r1);
+   assert( r2);
+   v.swap(r1, r2);
+   assert( r1);
+   assert(!r2);
+}
\ No newline at end of file


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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

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

Richard, Reid and David,

Friendly ping, please take a look to this patch. If there are no more 
comments/suggestion, I think it is better to commit this patch iterate on GCC 
abi_tag support based on users' feedback.


http://reviews.llvm.org/D18035



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52915.
etienneb added a comment.

add unittests.


http://reviews.llvm.org/D18852

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  test/clang-tidy/performance-unnecessary-value-param-delayed.cpp

Index: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
@@ -0,0 +1,171 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- -fdelayed-template-parsing
+
+struct ExpensiveToCopyType {
+  const ExpensiveToCopyType & constReference() const {
+return *this;
+  }
+  void nonConstMethod();
+  virtual ~ExpensiveToCopyType();
+};
+
+void mutate(ExpensiveToCopyType &);
+void mutate(ExpensiveToCopyType *);
+void useAsConstReference(const ExpensiveToCopyType &);
+void useByValue(ExpensiveToCopyType);
+
+// This class simulates std::pair<>. It is trivially copy constructible
+// and trivially destructible, but not trivially copy assignable.
+class SomewhatTrivial {
+ public:
+  SomewhatTrivial();
+  SomewhatTrivial(const SomewhatTrivial&) = default;
+  ~SomewhatTrivial() = default;
+  SomewhatTrivial& operator=(const SomewhatTrivial&);
+};
+
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'Obj' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj) {
+}
+
+void positiveExpensiveValue(ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveValue(ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: the parameter 'Obj' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj) {
+  Obj.constReference();
+  useAsConstReference(Obj);
+  auto Copy = Obj;
+  useByValue(Obj);
+}
+
+void positiveWithComment(const ExpensiveToCopyType /* important */ S);
+// CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S);
+void positiveWithComment(const ExpensiveToCopyType /* important */ S) {
+  // CHECK-MESSAGES: [[@LINE-1]]:68: warning: the const qualified
+  // CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S) {
+}
+
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+  // CHECK-FIXES: void positiveUnnamedParam(const ExpensiveToCopyType&) {
+}
+
+void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToCopyType& ConstRef, ExpensiveToCopyType Copy);
+// CHECK-FIXES: void positiveAndNegative(const ExpensiveToCopyType& ConstCopy, const ExpensiveToCopyType& ConstRef, const ExpensiveToCopyType& Copy);
+void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToCopyType& ConstRef, ExpensiveToCopyType Copy) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-MESSAGES: [[@LINE-2]]:120: warning: the parameter 'Copy'
+  // CHECK-FIXES: void positiveAndNegative(const ExpensiveToCopyType& ConstCopy, const ExpensiveToCopyType& ConstRef, const ExpensiveToCopyType& Copy) {
+}
+
+struct PositiveConstValueConstructor {
+  PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+};
+
+template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
+  // CHECK-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
+}
+
+void instantiated() {
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), ExpensiveToCopyType());
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), 5);
+}
+
+template  void negativeTemplateType(const T V) {
+}
+
+void negativeArray(const ExpensiveToCopyType[]) {
+}
+
+void negativePointer(ExpensiveToCopyType* Obj) {
+}
+
+void negativeConstPointer(const ExpensiveToCopyType* Obj) {
+}
+
+void negativeConstReference(const ExpensiveToCopyType& Obj) {
+}
+
+void negativeReference(ExpensiveToCopyType& Obj) {
+}
+
+void negativeUniversalReference(ExpensiveToCopyType&& Obj) {
+}
+
+void negativeSomewhatTrivialConstValue(const SomewhatTrivial Somewhat) {
+}
+
+void negativeSomewhatTrivialValue(SomewhatTrivial Somewhat) {
+}
+
+void negativeConstBuiltIn(const int I) {
+}
+
+void negativeValueB

[libcxx] r265674 - Added a noexcept test

2016-04-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr  7 09:24:16 2016
New Revision: 265674

URL: http://llvm.org/viewvc/llvm-project?rev=265674&view=rev
Log:
Added a noexcept test

Modified:

libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp?rev=265674&r1=265673&r2=265674&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp 
Thu Apr  7 09:24:16 2016
@@ -17,12 +17,18 @@
 
 int main()
 {
+
 bool a[] = {false, true, false, true};
 bool* an = a + sizeof(a)/sizeof(a[0]);
 
std::vector v(a, an);
std::vector::reference r1 = v[0];
std::vector::reference r2 = v[3];
+
+#if __has_feature(cxx_noexcept)
+static_assert((noexcept(v.swap(r1,r2))), "");
+#endif
+
assert(!r1);
assert( r2);
v.swap(r1, r2);


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


r265675 - make __builtin_isfinite more efficient (PR27145)

2016-04-07 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Thu Apr  7 09:29:05 2016
New Revision: 265675

URL: http://llvm.org/viewvc/llvm-project?rev=265675&view=rev
Log:
make __builtin_isfinite more efficient (PR27145)

isinf (is infinite) and isfinite should be implemented with the same function
except we change the comparison operator.

See PR27145 for more details:
https://llvm.org/bugs/show_bug.cgi?id=27145

Ref: forked off of the discussion in D18513.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=265675&r1=265674&r2=265675&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Apr  7 09:29:05 2016
@@ -786,13 +786,19 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
-  case Builtin::BI__builtin_isinf: {
-// isinf(x) --> fabs(x) == infinity
+  case Builtin::BI__builtin_isinf:
+  case Builtin::BI__builtin_isfinite: {
+// isinf(x)--> fabs(x) == infinity
+// isfinite(x) --> fabs(x) != infinity
+// x != NaN via the ordered compare in either case.
 Value *V = EmitScalarExpr(E->getArg(0));
-V = EmitFAbs(*this, V);
-
-V = Builder.CreateFCmpOEQ(V, 
ConstantFP::getInfinity(V->getType()),"isinf");
-return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
+Value *Fabs = EmitFAbs(*this, V);
+Constant *Infinity = ConstantFP::getInfinity(V->getType());
+CmpInst::Predicate Pred = (BuiltinID == Builtin::BI__builtin_isinf)
+  ? CmpInst::FCMP_OEQ
+  : CmpInst::FCMP_ONE;
+Value *FCmp = Builder.CreateFCmp(Pred, Fabs, Infinity, "cmpinf");
+return RValue::get(Builder.CreateZExt(FCmp, ConvertType(E->getType(;
   }
 
   case Builtin::BI__builtin_isinf_sign: {
@@ -830,19 +836,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
-  case Builtin::BI__builtin_isfinite: {
-// isfinite(x) --> x == x && fabs(x) != infinity;
-Value *V = EmitScalarExpr(E->getArg(0));
-Value *Eq = Builder.CreateFCmpOEQ(V, V, "iseq");
-
-Value *Abs = EmitFAbs(*this, V);
-Value *IsNotInf =
-  Builder.CreateFCmpUNE(Abs, 
ConstantFP::getInfinity(V->getType()),"isinf");
-
-V = Builder.CreateAnd(Eq, IsNotInf, "and");
-return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
-  }
-
   case Builtin::BI__builtin_fpclassify: {
 Value *V = EmitScalarExpr(E->getArg(5));
 llvm::Type *Ty = ConvertType(E->getArg(5)->getType());

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=265675&r1=265674&r2=265675&view=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Thu Apr  7 09:29:05 2016
@@ -217,10 +217,8 @@ void test_float_builtins(float F, double
   // CHECK:  select i1 %[[ISINF]], i32 %[[SIGN]], i32 0
 
   res = __builtin_isfinite(F);
-  // CHECK: fcmp oeq float 
   // CHECK: call float @llvm.fabs.f32(float
-  // CHECK: fcmp une float {{.*}}, 0x7FF0
-  // CHECK: and i1 
+  // CHECK: fcmp one float {{.*}}, 0x7FF0
 
   res = __builtin_isnormal(F);
   // CHECK: fcmp oeq float


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


Re: [PATCH] D18648: make __builtin_isfinite more efficient (PR27145)

2016-04-07 Thread Sanjay Patel via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265675: make __builtin_isfinite more efficient (PR27145) 
(authored by spatel).

Changed prior to commit:
  http://reviews.llvm.org/D18648?vs=52214&id=52917#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18648

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins.c

Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -786,13 +786,19 @@
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
-  case Builtin::BI__builtin_isinf: {
-// isinf(x) --> fabs(x) == infinity
+  case Builtin::BI__builtin_isinf:
+  case Builtin::BI__builtin_isfinite: {
+// isinf(x)--> fabs(x) == infinity
+// isfinite(x) --> fabs(x) != infinity
+// x != NaN via the ordered compare in either case.
 Value *V = EmitScalarExpr(E->getArg(0));
-V = EmitFAbs(*this, V);
-
-V = Builder.CreateFCmpOEQ(V, 
ConstantFP::getInfinity(V->getType()),"isinf");
-return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
+Value *Fabs = EmitFAbs(*this, V);
+Constant *Infinity = ConstantFP::getInfinity(V->getType());
+CmpInst::Predicate Pred = (BuiltinID == Builtin::BI__builtin_isinf)
+  ? CmpInst::FCMP_OEQ
+  : CmpInst::FCMP_ONE;
+Value *FCmp = Builder.CreateFCmp(Pred, Fabs, Infinity, "cmpinf");
+return RValue::get(Builder.CreateZExt(FCmp, ConvertType(E->getType(;
   }
 
   case Builtin::BI__builtin_isinf_sign: {
@@ -830,19 +836,6 @@
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
-  case Builtin::BI__builtin_isfinite: {
-// isfinite(x) --> x == x && fabs(x) != infinity;
-Value *V = EmitScalarExpr(E->getArg(0));
-Value *Eq = Builder.CreateFCmpOEQ(V, V, "iseq");
-
-Value *Abs = EmitFAbs(*this, V);
-Value *IsNotInf =
-  Builder.CreateFCmpUNE(Abs, 
ConstantFP::getInfinity(V->getType()),"isinf");
-
-V = Builder.CreateAnd(Eq, IsNotInf, "and");
-return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
-  }
-
   case Builtin::BI__builtin_fpclassify: {
 Value *V = EmitScalarExpr(E->getArg(5));
 llvm::Type *Ty = ConvertType(E->getArg(5)->getType());
Index: cfe/trunk/test/CodeGen/builtins.c
===
--- cfe/trunk/test/CodeGen/builtins.c
+++ cfe/trunk/test/CodeGen/builtins.c
@@ -217,10 +217,8 @@
   // CHECK:  select i1 %[[ISINF]], i32 %[[SIGN]], i32 0
 
   res = __builtin_isfinite(F);
-  // CHECK: fcmp oeq float 
   // CHECK: call float @llvm.fabs.f32(float
-  // CHECK: fcmp une float {{.*}}, 0x7FF0
-  // CHECK: and i1 
+  // CHECK: fcmp one float {{.*}}, 0x7FF0
 
   res = __builtin_isnormal(F);
   // CHECK: fcmp oeq float


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -786,13 +786,19 @@
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
-  case Builtin::BI__builtin_isinf: {
-// isinf(x) --> fabs(x) == infinity
+  case Builtin::BI__builtin_isinf:
+  case Builtin::BI__builtin_isfinite: {
+// isinf(x)--> fabs(x) == infinity
+// isfinite(x) --> fabs(x) != infinity
+// x != NaN via the ordered compare in either case.
 Value *V = EmitScalarExpr(E->getArg(0));
-V = EmitFAbs(*this, V);
-
-V = Builder.CreateFCmpOEQ(V, ConstantFP::getInfinity(V->getType()),"isinf");
-return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
+Value *Fabs = EmitFAbs(*this, V);
+Constant *Infinity = ConstantFP::getInfinity(V->getType());
+CmpInst::Predicate Pred = (BuiltinID == Builtin::BI__builtin_isinf)
+  ? CmpInst::FCMP_OEQ
+  : CmpInst::FCMP_ONE;
+Value *FCmp = Builder.CreateFCmp(Pred, Fabs, Infinity, "cmpinf");
+return RValue::get(Builder.CreateZExt(FCmp, ConvertType(E->getType(;
   }
 
   case Builtin::BI__builtin_isinf_sign: {
@@ -830,19 +836,6 @@
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
-  case Builtin::BI__builtin_isfinite: {
-// isfinite(x) --> x == x && fabs(x) != infinity;
-Value *V = EmitScalarExpr(E->getArg(0));
-Value *Eq = Builder.CreateFCmpOEQ(V, V, "iseq");
-
-Value *Abs = EmitFAbs(*this, V);
-Value *IsNotInf =
-  Builder.CreateFCmpUNE(Abs, ConstantFP::getInfinity(V->getType()),"isinf");
-
-V = Builder.CreateAnd(Eq, IsNotInf, "and");
-return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
-  }
-
   case Builtin::BI__builtin_fpclassify: {
 Value *V = EmitScalarExpr(E->getArg(5));
 llvm::Ty

Re: [PATCH] D18833: [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52919.
etienneb added a comment.

alexfh comments.


http://reviews.llvm.org/D18833

Files:
  clang-tidy/misc/MisplacedWideningCastCheck.cpp

Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp
===
--- clang-tidy/misc/MisplacedWideningCastCheck.cpp
+++ clang-tidy/misc/MisplacedWideningCastCheck.cpp
@@ -10,7 +10,6 @@
 #include "MisplacedWideningCastCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/DenseMap.h"
 
 using namespace clang::ast_matchers;
 
@@ -29,18 +28,19 @@
 }
 
 void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
-  auto Calc = expr(anyOf(binaryOperator(anyOf(
- hasOperatorName("+"), hasOperatorName("-"),
- hasOperatorName("*"), hasOperatorName("<<"))),
- unaryOperator(hasOperatorName("~"))),
-   hasType(isInteger()))
-  .bind("Calc");
+  const auto Calc =
+  expr(anyOf(binaryOperator(
+ anyOf(hasOperatorName("+"), hasOperatorName("-"),
+   hasOperatorName("*"), hasOperatorName("<<"))),
+ unaryOperator(hasOperatorName("~"))),
+   hasType(isInteger()))
+  .bind("Calc");
 
-  auto ExplicitCast =
+  const auto ExplicitCast =
   explicitCastExpr(hasDestinationType(isInteger()), has(Calc));
-  auto ImplicitCast =
+  const auto ImplicitCast =
   implicitCastExpr(hasImplicitDestinationType(isInteger()), has(Calc));
-  auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
+  const auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
 
   Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
   Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
@@ -50,11 +50,12 @@
   binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!="),
hasOperatorName("<"), hasOperatorName("<="),
hasOperatorName(">"), hasOperatorName(">=")),
- anyOf(hasLHS(Cast), hasRHS(Cast))),
+ hasEitherOperand(Cast)),
   this);
 }
 
-static unsigned getMaxCalculationWidth(ASTContext &Context, const Expr *E) {
+static unsigned getMaxCalculationWidth(const ASTContext &Context,
+   const Expr *E) {
   E = E->IgnoreParenImpCasts();
 
   if (const auto *Bop = dyn_cast(E)) {
@@ -94,64 +95,89 @@
   return Context.getIntWidth(E->getType());
 }
 
-static llvm::SmallDenseMap createRelativeIntSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::UShort] = 2;
-  Result[BuiltinType::Short] = 2;
-  Result[BuiltinType::UInt] = 3;
-  Result[BuiltinType::Int] = 3;
-  Result[BuiltinType::ULong] = 4;
-  Result[BuiltinType::Long] = 4;
-  Result[BuiltinType::ULongLong] = 5;
-  Result[BuiltinType::LongLong] = 5;
-  Result[BuiltinType::UInt128] = 6;
-  Result[BuiltinType::Int128] = 6;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::Char16] = 2;
-  Result[BuiltinType::Char32] = 3;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesWMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::WChar_U] = 2;
-  Result[BuiltinType::WChar_S] = 2;
-  return Result;
+static int RelativeIntSizes(BuiltinType::Kind kind) {
+  switch (kind) {
+  case BuiltinType::UChar:
+return 1;
+  case BuiltinType::SChar:
+return 1;
+  case BuiltinType::Char_U:
+return 1;
+  case BuiltinType::Char_S:
+return 1;
+  case BuiltinType::UShort:
+return 2;
+  case BuiltinType::Short:
+return 2;
+  case BuiltinType::UInt:
+return 3;
+  case BuiltinType::Int:
+return 3;
+  case BuiltinType::ULong:
+return 4;
+  case BuiltinType::Long:
+return 4;
+  case BuiltinType::ULongLong:
+return 5;
+  case BuiltinType::LongLong:
+return 5;
+  case BuiltinType::UInt128:
+return 6;
+  case BuiltinType::Int128:
+return 6;
+  default:
+return 0;
+  }
 }
 
-static bool isFirstWider(BuiltinType::Kind First, BuiltinType::Kind Second) {
-  static const llvm::SmallDenseMap RelativeIntSizes(
-  createRelativeIntSizesMap());
-  static const llvm::SmallDenseMap RelativeCharSizes(
-  createRelativeCharSizesMap());
-  static const llvm::SmallDenseMap RelativeCharSizesW(
-  createRelativeCharSizesWMap());
+static int RelativeCharSizes(BuiltinType::Kind

Re: [PATCH] D18833: [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

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

LG


http://reviews.llvm.org/D18833



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

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

LG


http://reviews.llvm.org/D18852



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


Re: [PATCH] D18833: [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52921.
etienneb added a comment.

nits, lower case names.


http://reviews.llvm.org/D18833

Files:
  clang-tidy/misc/MisplacedWideningCastCheck.cpp

Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp
===
--- clang-tidy/misc/MisplacedWideningCastCheck.cpp
+++ clang-tidy/misc/MisplacedWideningCastCheck.cpp
@@ -10,7 +10,6 @@
 #include "MisplacedWideningCastCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/DenseMap.h"
 
 using namespace clang::ast_matchers;
 
@@ -29,18 +28,19 @@
 }
 
 void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
-  auto Calc = expr(anyOf(binaryOperator(anyOf(
- hasOperatorName("+"), hasOperatorName("-"),
- hasOperatorName("*"), hasOperatorName("<<"))),
- unaryOperator(hasOperatorName("~"))),
-   hasType(isInteger()))
-  .bind("Calc");
+  const auto Calc =
+  expr(anyOf(binaryOperator(
+ anyOf(hasOperatorName("+"), hasOperatorName("-"),
+   hasOperatorName("*"), hasOperatorName("<<"))),
+ unaryOperator(hasOperatorName("~"))),
+   hasType(isInteger()))
+  .bind("Calc");
 
-  auto ExplicitCast =
+  const auto ExplicitCast =
   explicitCastExpr(hasDestinationType(isInteger()), has(Calc));
-  auto ImplicitCast =
+  const auto ImplicitCast =
   implicitCastExpr(hasImplicitDestinationType(isInteger()), has(Calc));
-  auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
+  const auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
 
   Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
   Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
@@ -50,11 +50,12 @@
   binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!="),
hasOperatorName("<"), hasOperatorName("<="),
hasOperatorName(">"), hasOperatorName(">=")),
- anyOf(hasLHS(Cast), hasRHS(Cast))),
+ hasEitherOperand(Cast)),
   this);
 }
 
-static unsigned getMaxCalculationWidth(ASTContext &Context, const Expr *E) {
+static unsigned getMaxCalculationWidth(const ASTContext &Context,
+   const Expr *E) {
   E = E->IgnoreParenImpCasts();
 
   if (const auto *Bop = dyn_cast(E)) {
@@ -94,64 +95,89 @@
   return Context.getIntWidth(E->getType());
 }
 
-static llvm::SmallDenseMap createRelativeIntSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::UShort] = 2;
-  Result[BuiltinType::Short] = 2;
-  Result[BuiltinType::UInt] = 3;
-  Result[BuiltinType::Int] = 3;
-  Result[BuiltinType::ULong] = 4;
-  Result[BuiltinType::Long] = 4;
-  Result[BuiltinType::ULongLong] = 5;
-  Result[BuiltinType::LongLong] = 5;
-  Result[BuiltinType::UInt128] = 6;
-  Result[BuiltinType::Int128] = 6;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::Char16] = 2;
-  Result[BuiltinType::Char32] = 3;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesWMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::WChar_U] = 2;
-  Result[BuiltinType::WChar_S] = 2;
-  return Result;
+static int relativeIntSizes(BuiltinType::Kind kind) {
+  switch (kind) {
+  case BuiltinType::UChar:
+return 1;
+  case BuiltinType::SChar:
+return 1;
+  case BuiltinType::Char_U:
+return 1;
+  case BuiltinType::Char_S:
+return 1;
+  case BuiltinType::UShort:
+return 2;
+  case BuiltinType::Short:
+return 2;
+  case BuiltinType::UInt:
+return 3;
+  case BuiltinType::Int:
+return 3;
+  case BuiltinType::ULong:
+return 4;
+  case BuiltinType::Long:
+return 4;
+  case BuiltinType::ULongLong:
+return 5;
+  case BuiltinType::LongLong:
+return 5;
+  case BuiltinType::UInt128:
+return 6;
+  case BuiltinType::Int128:
+return 6;
+  default:
+return 0;
+  }
 }
 
-static bool isFirstWider(BuiltinType::Kind First, BuiltinType::Kind Second) {
-  static const llvm::SmallDenseMap RelativeIntSizes(
-  createRelativeIntSizesMap());
-  static const llvm::SmallDenseMap RelativeCharSizes(
-  createRelativeCharSizesMap());
-  static const llvm::SmallDenseMap RelativeCharSizesW(
-  createRelativeCharSizesWMap());
+static int relativeCharSizes(BuiltinTyp

Re: [PATCH] D18833: [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

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

Missed a couple of nits.



Comment at: clang-tidy/misc/MisplacedWideningCastCheck.cpp:98
@@ -96,40 +97,3 @@
 
-static llvm::SmallDenseMap createRelativeIntSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::UShort] = 2;
-  Result[BuiltinType::Short] = 2;
-  Result[BuiltinType::UInt] = 3;
-  Result[BuiltinType::Int] = 3;
-  Result[BuiltinType::ULong] = 4;
-  Result[BuiltinType::Long] = 4;
-  Result[BuiltinType::ULongLong] = 5;
-  Result[BuiltinType::LongLong] = 5;
-  Result[BuiltinType::UInt128] = 6;
-  Result[BuiltinType::Int128] = 6;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::Char16] = 2;
-  Result[BuiltinType::Char32] = 3;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesWMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::WChar_U] = 2;
-  Result[BuiltinType::WChar_S] = 2;
-  return Result;
+static int RelativeIntSizes(BuiltinType::Kind kind) {
+  switch (kind) {

s/RelativeIntSizes/relativeIntSize/
s/kind/Kind/


http://reviews.llvm.org/D18833



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


r265677 - Fixing duplicate declaration "_mm256 _mm_set_epi32" in revision 262177

2016-04-07 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Thu Apr  7 09:44:08 2016
New Revision: 265677

URL: http://llvm.org/viewvc/llvm-project?rev=265677&view=rev
Log:
Fixing duplicate declaration "_mm256 _mm_set_epi32" in revision 262177

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


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

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=265677&r1=265676&r2=265677&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Thu Apr  7 09:44:08 2016
@@ -5548,14 +5548,6 @@ _mm256_maskz_sllv_epi32 (__mmask8 __U, _
  (__mmask8) __U);
 }
 
-#define _mm256_maskz_sllv_epi32( __U, __X, __Y) __extension__ ({ \
-__builtin_ia32_psllv8si_mask ((__v8si)( __X),\
- (__v8si)( __Y),\
- (__v8si)\
- _mm256_setzero_si256 (),\
- (__mmask8)( __U));\
-})
-
 
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS


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


Re: [PATCH] D18833: [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52924.
etienneb marked an inline comment as done.
etienneb added a comment.

fix nits.


http://reviews.llvm.org/D18833

Files:
  clang-tidy/misc/MisplacedWideningCastCheck.cpp

Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp
===
--- clang-tidy/misc/MisplacedWideningCastCheck.cpp
+++ clang-tidy/misc/MisplacedWideningCastCheck.cpp
@@ -10,7 +10,6 @@
 #include "MisplacedWideningCastCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/DenseMap.h"
 
 using namespace clang::ast_matchers;
 
@@ -29,18 +28,19 @@
 }
 
 void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
-  auto Calc = expr(anyOf(binaryOperator(anyOf(
- hasOperatorName("+"), hasOperatorName("-"),
- hasOperatorName("*"), hasOperatorName("<<"))),
- unaryOperator(hasOperatorName("~"))),
-   hasType(isInteger()))
-  .bind("Calc");
+  const auto Calc =
+  expr(anyOf(binaryOperator(
+ anyOf(hasOperatorName("+"), hasOperatorName("-"),
+   hasOperatorName("*"), hasOperatorName("<<"))),
+ unaryOperator(hasOperatorName("~"))),
+   hasType(isInteger()))
+  .bind("Calc");
 
-  auto ExplicitCast =
+  const auto ExplicitCast =
   explicitCastExpr(hasDestinationType(isInteger()), has(Calc));
-  auto ImplicitCast =
+  const auto ImplicitCast =
   implicitCastExpr(hasImplicitDestinationType(isInteger()), has(Calc));
-  auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
+  const auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
 
   Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
   Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
@@ -50,11 +50,12 @@
   binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!="),
hasOperatorName("<"), hasOperatorName("<="),
hasOperatorName(">"), hasOperatorName(">=")),
- anyOf(hasLHS(Cast), hasRHS(Cast))),
+ hasEitherOperand(Cast)),
   this);
 }
 
-static unsigned getMaxCalculationWidth(ASTContext &Context, const Expr *E) {
+static unsigned getMaxCalculationWidth(const ASTContext &Context,
+   const Expr *E) {
   E = E->IgnoreParenImpCasts();
 
   if (const auto *Bop = dyn_cast(E)) {
@@ -94,64 +95,89 @@
   return Context.getIntWidth(E->getType());
 }
 
-static llvm::SmallDenseMap createRelativeIntSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::UShort] = 2;
-  Result[BuiltinType::Short] = 2;
-  Result[BuiltinType::UInt] = 3;
-  Result[BuiltinType::Int] = 3;
-  Result[BuiltinType::ULong] = 4;
-  Result[BuiltinType::Long] = 4;
-  Result[BuiltinType::ULongLong] = 5;
-  Result[BuiltinType::LongLong] = 5;
-  Result[BuiltinType::UInt128] = 6;
-  Result[BuiltinType::Int128] = 6;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::Char16] = 2;
-  Result[BuiltinType::Char32] = 3;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesWMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::WChar_U] = 2;
-  Result[BuiltinType::WChar_S] = 2;
-  return Result;
+static int relativeIntSizes(BuiltinType::Kind Kind) {
+  switch (Kind) {
+  case BuiltinType::UChar:
+return 1;
+  case BuiltinType::SChar:
+return 1;
+  case BuiltinType::Char_U:
+return 1;
+  case BuiltinType::Char_S:
+return 1;
+  case BuiltinType::UShort:
+return 2;
+  case BuiltinType::Short:
+return 2;
+  case BuiltinType::UInt:
+return 3;
+  case BuiltinType::Int:
+return 3;
+  case BuiltinType::ULong:
+return 4;
+  case BuiltinType::Long:
+return 4;
+  case BuiltinType::ULongLong:
+return 5;
+  case BuiltinType::LongLong:
+return 5;
+  case BuiltinType::UInt128:
+return 6;
+  case BuiltinType::Int128:
+return 6;
+  default:
+return 0;
+  }
 }
 
-static bool isFirstWider(BuiltinType::Kind First, BuiltinType::Kind Second) {
-  static const llvm::SmallDenseMap RelativeIntSizes(
-  createRelativeIntSizesMap());
-  static const llvm::SmallDenseMap RelativeCharSizes(
-  createRelativeCharSizesMap());
-  static const llvm::SmallDenseMap RelativeCharSizesW(
-  createRelativeCharSizesWMap());
+static int

[clang-tools-extra] r265679 - [clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr  7 09:52:52 2016
New Revision: 265679

URL: http://llvm.org/viewvc/llvm-project?rev=265679&view=rev
Log:
[clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

Summary:
In Release mode, the check was infinite looping over chromium code base.

It seems there is something strange with the creation of the Maps.
I believe the compiler is making some assumption with the implicit conversion 
from enum <-> int.

By moving the map to a standard switch/cases, we no longer allocate memory and 
we can keep the same behavior. For a small amount of elements, this is fine.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp?rev=265679&r1=265678&r2=265679&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp Thu 
Apr  7 09:52:52 2016
@@ -10,7 +10,6 @@
 #include "MisplacedWideningCastCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "llvm/ADT/DenseMap.h"
 
 using namespace clang::ast_matchers;
 
@@ -29,18 +28,19 @@ void MisplacedWideningCastCheck::storeOp
 }
 
 void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) {
-  auto Calc = expr(anyOf(binaryOperator(anyOf(
- hasOperatorName("+"), hasOperatorName("-"),
- hasOperatorName("*"), hasOperatorName("<<"))),
- unaryOperator(hasOperatorName("~"))),
-   hasType(isInteger()))
-  .bind("Calc");
+  const auto Calc =
+  expr(anyOf(binaryOperator(
+ anyOf(hasOperatorName("+"), hasOperatorName("-"),
+   hasOperatorName("*"), hasOperatorName("<<"))),
+ unaryOperator(hasOperatorName("~"))),
+   hasType(isInteger()))
+  .bind("Calc");
 
-  auto ExplicitCast =
+  const auto ExplicitCast =
   explicitCastExpr(hasDestinationType(isInteger()), has(Calc));
-  auto ImplicitCast =
+  const auto ImplicitCast =
   implicitCastExpr(hasImplicitDestinationType(isInteger()), has(Calc));
-  auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
+  const auto Cast = expr(anyOf(ExplicitCast, ImplicitCast)).bind("Cast");
 
   Finder->addMatcher(varDecl(hasInitializer(Cast)), this);
   Finder->addMatcher(returnStmt(hasReturnValue(Cast)), this);
@@ -50,11 +50,12 @@ void MisplacedWideningCastCheck::registe
   binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!="),
hasOperatorName("<"), hasOperatorName("<="),
hasOperatorName(">"), hasOperatorName(">=")),
- anyOf(hasLHS(Cast), hasRHS(Cast))),
+ hasEitherOperand(Cast)),
   this);
 }
 
-static unsigned getMaxCalculationWidth(ASTContext &Context, const Expr *E) {
+static unsigned getMaxCalculationWidth(const ASTContext &Context,
+   const Expr *E) {
   E = E->IgnoreParenImpCasts();
 
   if (const auto *Bop = dyn_cast(E)) {
@@ -94,64 +95,89 @@ static unsigned getMaxCalculationWidth(A
   return Context.getIntWidth(E->getType());
 }
 
-static llvm::SmallDenseMap createRelativeIntSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::UShort] = 2;
-  Result[BuiltinType::Short] = 2;
-  Result[BuiltinType::UInt] = 3;
-  Result[BuiltinType::Int] = 3;
-  Result[BuiltinType::ULong] = 4;
-  Result[BuiltinType::Long] = 4;
-  Result[BuiltinType::ULongLong] = 5;
-  Result[BuiltinType::LongLong] = 5;
-  Result[BuiltinType::UInt128] = 6;
-  Result[BuiltinType::Int128] = 6;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::Char16] = 2;
-  Result[BuiltinType::Char32] = 3;
-  return Result;
-}
-
-static llvm::SmallDenseMap createRelativeCharSizesWMap() {
-  llvm::SmallDenseMap Result;
-  Result[BuiltinType::UChar] = 1;
-  Result[BuiltinType::SChar] = 1;
-  Result[BuiltinType::Char_U] = 1;
-  Result[BuiltinType::Char_S] = 1;
-  Result[BuiltinType::WChar_U] = 2;
-  Result[BuiltinType::WChar_S] = 2;
-  return Result;
+static int relativeIntSizes(BuiltinType::Kind Kind) {
+  switch (Kind) {
+  case BuiltinType::UChar:
+return 1

[clang-tools-extra] r265680 - [clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a DiagnosticBuilder

2016-04-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Apr  7 09:55:25 2016
New Revision: 265680

URL: http://llvm.org/viewvc/llvm-project?rev=265680&view=rev
Log:
[clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a 
DiagnosticBuilder

Going through a string removes some of the smarts of the diagnosic printer
and makes the code more complicated. This change has some cosmetic impact
on the output but that's mostly minor.

Modified:
clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp
clang-tools-extra/trunk/clang-tidy/performance/ImplicitCastInLoopCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
clang-tools-extra/trunk/test/clang-tidy/performance-faster-string-find.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp?rev=265680&r1=265679&r2=265680&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp Thu Apr  7 
09:55:25 2016
@@ -115,8 +115,8 @@ void NonConstReferences::check(const Mat
 << Parameter->getFunctionScopeIndex();
   } else {
 diag(Parameter->getLocation(),
- "non-const reference parameter '%0', make it const or use a pointer")
-<< Parameter->getName();
+ "non-const reference parameter %0, make it const or use a pointer")
+<< Parameter;
   }
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=265680&r1=265679&r2=265680&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Thu 
Apr  7 09:55:25 2016
@@ -118,11 +118,10 @@ void DefinitionsInHeadersCheck::check(co
 }
 
 diag(FD->getLocation(),
- "function '%0' defined in a header file; "
+ "function %0 defined in a header file; "
  "function definitions in header files can lead to ODR violations")
-<< FD->getNameInfo().getName().getAsString()
-<< FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
-  "inline ");
+<< FD << FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
+"inline ");
   } else if (const auto *VD = dyn_cast(ND)) {
 // Static data members of a class template are allowed.
 if (VD->getDeclContext()->isDependentContext() && VD->isStaticDataMember())
@@ -134,9 +133,9 @@ void DefinitionsInHeadersCheck::check(co
   return;
 
 diag(VD->getLocation(),
- "variable '%0' defined in a header file; "
+ "variable %0 defined in a header file; "
  "variable definitions in header files can lead to ODR violations")
-<< VD->getName();
+<< VD;
   }
 }
 

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp?rev=265680&r1=265679&r2=265680&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp 
Thu Apr  7 09:55:25 2016
@@ -139,12 +139,12 @@ void ForwardDeclarationNamespaceCheck::o
 if (!CurDecl->hasDefinition() &&
 !haveSameNamespaceOrTranslationUnit(CurDecl, Decl)) {
   diag(CurDecl->getLocation(),
-   "declaration '%0' is never referenced, but a declaration with "
+   "declaration %0 is never referenced, but a declaration with "
"the same name found in another namespace '%1'")
-  << CurDecl->getName() << getNameOfNamespace(Decl);
-  diag(Decl->getLocation(), "a declaration of '%0' is found here",
+  << CurDecl << getNameOfNamespace(Decl);
+  diag(Decl->getLocation()

[clang-tools-extra] r265681 - [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr  7 09:58:13 2016
New Revision: 265681

URL: http://llvm.org/viewvc/llvm-project?rev=265681&view=rev
Log:
[clang-tidy] fix a crash with -fdelayed-template-parsing in 
UnnecessaryValueParamCheck.

Summary:
This is the same kind of bug than [[ http://reviews.llvm.org/D18238 | D18238 ]].

Fix crashes caused by deferencing null pointer when declarations parsing may be 
delayed.
The body of the declarations may be null.

The crashes were observed with a Windows build of clang-tidy and the following 
command-line.
```
command-line switches: -fms-compatibility-version=19 -fms-compatibility
```

Reviewers: alexfh

Subscribers: kimgr, LegalizeAdulthood, cfe-commits

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

Added:

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=265681&r1=265680&r2=265681&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Thu Apr  7 09:58:13 2016
@@ -51,6 +51,10 @@ void UnnecessaryValueParamCheck::check(c
   bool IsConstQualified =
   Param->getType().getCanonicalType().isConstQualified();
 
+  // Skip declarations delayed by late template parsing without a body.
+  if (!Function->getBody())
+return;
+
   // Do not trigger on non-const value parameters when:
   // 1. they are in a constructor definition since they can likely trigger
   //misc-move-constructor-init which will suggest to move the argument.

Added: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp?rev=265681&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-delayed.cpp
 Thu Apr  7 09:58:13 2016
@@ -0,0 +1,171 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- 
-fdelayed-template-parsing
+
+struct ExpensiveToCopyType {
+  const ExpensiveToCopyType & constReference() const {
+return *this;
+  }
+  void nonConstMethod();
+  virtual ~ExpensiveToCopyType();
+};
+
+void mutate(ExpensiveToCopyType &);
+void mutate(ExpensiveToCopyType *);
+void useAsConstReference(const ExpensiveToCopyType &);
+void useByValue(ExpensiveToCopyType);
+
+// This class simulates std::pair<>. It is trivially copy constructible
+// and trivially destructible, but not trivially copy assignable.
+class SomewhatTrivial {
+ public:
+  SomewhatTrivial();
+  SomewhatTrivial(const SomewhatTrivial&) = default;
+  ~SomewhatTrivial() = default;
+  SomewhatTrivial& operator=(const SomewhatTrivial&);
+};
+
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& 
Obj);
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 
'Obj' is copied for each invocation; consider making it a reference 
[performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& 
Obj) {
+}
+
+void positiveExpensiveValue(ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveValue(ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: the parameter 'Obj' is copied 
for each invocation but only used as a const reference; consider making it a 
const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj) {
+  Obj.constReference();
+  useAsConstReference(Obj);
+  auto Copy = Obj;
+  useByValue(Obj);
+}
+
+void positiveWithComment(const ExpensiveToCopyType /* important */ S);
+// CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* 
important */ S);
+void positiveWithComment(const ExpensiveToCopyType /* important */ S) {
+  // CHECK-MESSAGES: [[@LINE-1]]:68: warning: the const qualified
+  // CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* 
important */ S) {
+}
+
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+  // CHECK-FIXES: void positiveUnnamedParam(const ExpensiveToCopyTyp

Re: [clang-tools-extra] r265680 - [clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a DiagnosticBuilder

2016-04-07 Thread Alexander Kornienko via cfe-commits
Thanks!

On Thu, Apr 7, 2016 at 4:55 PM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Thu Apr  7 09:55:25 2016
> New Revision: 265680
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265680&view=rev
> Log:
> [clang-tidy] Remove unnecessary getName() on Decls and Types feeding into
> a DiagnosticBuilder
>
> Going through a string removes some of the smarts of the diagnosic printer
> and makes the code more complicated. This change has some cosmetic impact
> on the output but that's mostly minor.
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
>
> clang-tools-extra/trunk/clang-tidy/misc/MacroRepeatedSideEffectsCheck.cpp
> clang-tools-extra/trunk/clang-tidy/misc/NonCopyableObjects.cpp
> clang-tools-extra/trunk/clang-tidy/misc/UnusedAliasDeclsCheck.cpp
> clang-tools-extra/trunk/clang-tidy/misc/UnusedParametersCheck.cpp
>
> clang-tools-extra/trunk/clang-tidy/performance/FasterStringFindCheck.cpp
>
> clang-tools-extra/trunk/clang-tidy/performance/ImplicitCastInLoopCheck.cpp
> clang-tools-extra/trunk/clang-tidy/readability/FunctionSizeCheck.cpp
> clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
>
> clang-tools-extra/trunk/test/clang-tidy/performance-faster-string-find.cpp
>
> Modified: clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp?rev=265680&r1=265679&r2=265680&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp Thu
> Apr  7 09:55:25 2016
> @@ -115,8 +115,8 @@ void NonConstReferences::check(const Mat
>  << Parameter->getFunctionScopeIndex();
>} else {
>  diag(Parameter->getLocation(),
> - "non-const reference parameter '%0', make it const or use a
> pointer")
> -<< Parameter->getName();
> + "non-const reference parameter %0, make it const or use a
> pointer")
> +<< Parameter;
>}
>  }
>
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=265680&r1=265679&r2=265680&view=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> Thu Apr  7 09:55:25 2016
> @@ -118,11 +118,10 @@ void DefinitionsInHeadersCheck::check(co
>  }
>
>  diag(FD->getLocation(),
> - "function '%0' defined in a header file; "
> + "function %0 defined in a header file; "
>   "function definitions in header files can lead to ODR
> violations")
> -<< FD->getNameInfo().getName().getAsString()
> -<< FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
> -  "inline ");
> +<< FD <<
> FixItHint::CreateInsertion(FD->getSourceRange().getBegin(),
> +"inline ");
>} else if (const auto *VD = dyn_cast(ND)) {
>  // Static data members of a class template are allowed.
>  if (VD->getDeclContext()->isDependentContext() &&
> VD->isStaticDataMember())
> @@ -134,9 +133,9 @@ void DefinitionsInHeadersCheck::check(co
>return;
>
>  diag(VD->getLocation(),
> - "variable '%0' defined in a header file; "
> + "variable %0 defined in a header file; "
>   "variable definitions in header files can lead to ODR
> violations")
> -<< VD->getName();
> +<< VD;
>}
>  }
>
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp?rev=265680&r1=265679&r2=265680&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
> (original)
> +++
> clang-tools-extra/trunk/clang-tidy/misc/ForwardDeclarationNamespaceCheck.cpp
> Thu Apr  7 09:55:25 2016
> @@ -139,12 +139,12 @@ void ForwardDeclarationNamespaceCheck::o
>  if (!CurDecl->hasDefinition() &&
>  !haveSameNamespaceOrTranslationUnit(CurDecl, Decl)) {
>diag(CurDecl->getLocation(),
> -   "declaration '%0' is never referenced, but a declaration
> with "
> +   "declaration %0 is never referenced, but a declaration
> with 

Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52926.
etienneb marked 2 inline comments as done.
etienneb added a comment.

Revert last diff (invalid patchset).


http://reviews.llvm.org/D18783

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp

Index: test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s misc-string-literal-with-embedded-nul %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template 
+struct basic_string {
+  typedef basic_string _Type;
+  basic_string();
+  basic_string(const C *p, const A &a = A());
+
+  _Type& operator+=(const C* s);
+  _Type& operator=(const C* s);
+};
+
+typedef basic_string, std::allocator> string;
+typedef basic_string, std::allocator> wstring;
+}
+
+bool operator==(const std::string&, const char*);
+bool operator==(const char*, const std::string&);
+
+
+const char Valid[] = "This is valid \x12.";
+const char Strange[] = "This is strange \0x12 and must be fixed";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: suspicious embedded NUL character [misc-string-literal-with-embedded-nul]
+
+const char textA[] = "\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious embedded NUL character
+const wchar_t textW[] = L"\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: suspicious embedded NUL character
+
+const char A[] = "\0";
+const char B[] = "\0x";
+const char C[] = "\0x1";
+const char D[] = "\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+const wchar_t E[] = L"\0";
+const wchar_t F[] = L"\0x";
+const wchar_t G[] = L"\0x1";
+const wchar_t H[] = L"\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious embedded NUL character
+
+const char I[] = "\000\000\000\000";
+const char J[] = "\0\0\0\0\0\0";
+const char K[] = "";
+
+const char L[] = "\0x12" "\0x12" "\0x12" "\0x12";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+void TestA() {
+  std::string str1 = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str2 = "\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str3("\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+  std::string str4{"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+
+  std::string str;
+  str += "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: truncated string literal
+  str = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: truncated string literal
+
+  if (str == "abc\0def") return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: truncated string literal
+  if ("abc\0def" == str) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: truncated string literal
+}
+
+void TestW() {
+  std::wstring str1 = L"abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str2 = L"\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str3(L"\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+  std::wstring str4{L"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+}
Index: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
@@ -0,0 +1,37 @@
+.. title:: clang-tidy - misc-string-literal-with-embedded-nul
+
+misc-string-literal-with-embedded-nul
+=
+
+Find occurences of string literal with embedded NUL character and validate
+their usage.
+
+
+Invalid escaping
+
+
+Special characters can be escaped within a string literal by using their
+hexadecimal encoding like ``\x42``. A common mistake is to escape them
+like this ``\0x42`` where the ``\0`` stands for the NUL character.
+
+.. code:: c++
+
+  const char* Example[] = "Invalid character: \0x12 should be \x12";
+  const char* Bytes[] = "\x03\0x02\0x01\0x00\0xFF\0xFF\0xFF";
+
+
+Truncated literal
+^
+
+String-like classes can manipulate strings with embedded NUL as they are
+keeping track of the bytes and the length. This is not the case for an
+``char*`` (NUL-terminated) string.
+
+A common mistake is to pass a string-literal (NUL-terminated) to a string
+constructor. The bytes after the fir

Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52927.
etienneb added a comment.

nit


http://reviews.llvm.org/D18783

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp

Index: test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s misc-string-literal-with-embedded-nul %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template 
+struct basic_string {
+  typedef basic_string _Type;
+  basic_string();
+  basic_string(const C *p, const A &a = A());
+
+  _Type& operator+=(const C* s);
+  _Type& operator=(const C* s);
+};
+
+typedef basic_string, std::allocator> string;
+typedef basic_string, std::allocator> wstring;
+}
+
+bool operator==(const std::string&, const char*);
+bool operator==(const char*, const std::string&);
+
+
+const char Valid[] = "This is valid \x12.";
+const char Strange[] = "This is strange \0x12 and must be fixed";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: suspicious embedded NUL character [misc-string-literal-with-embedded-nul]
+
+const char textA[] = "\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious embedded NUL character
+const wchar_t textW[] = L"\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: suspicious embedded NUL character
+
+const char A[] = "\0";
+const char B[] = "\0x";
+const char C[] = "\0x1";
+const char D[] = "\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+const wchar_t E[] = L"\0";
+const wchar_t F[] = L"\0x";
+const wchar_t G[] = L"\0x1";
+const wchar_t H[] = L"\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious embedded NUL character
+
+const char I[] = "\000\000\000\000";
+const char J[] = "\0\0\0\0\0\0";
+const char K[] = "";
+
+const char L[] = "\0x12" "\0x12" "\0x12" "\0x12";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+void TestA() {
+  std::string str1 = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str2 = "\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str3("\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+  std::string str4{"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+
+  std::string str;
+  str += "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: truncated string literal
+  str = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: truncated string literal
+
+  if (str == "abc\0def") return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: truncated string literal
+  if ("abc\0def" == str) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: truncated string literal
+}
+
+void TestW() {
+  std::wstring str1 = L"abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str2 = L"\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str3(L"\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+  std::wstring str4{L"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+}
Index: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
@@ -0,0 +1,37 @@
+.. title:: clang-tidy - misc-string-literal-with-embedded-nul
+
+misc-string-literal-with-embedded-nul
+=
+
+Find occurences of string literal with embedded NUL character and validate
+their usage.
+
+
+Invalid escaping
+
+
+Special characters can be escaped within a string literal by using their
+hexadecimal encoding like ``\x42``. A common mistake is to escape them
+like this ``\0x42`` where the ``\0`` stands for the NUL character.
+
+.. code:: c++
+
+  const char* Example[] = "Invalid character: \0x12 should be \x12";
+  const char* Bytes[] = "\x03\0x02\0x01\0x00\0xFF\0xFF\0xFF";
+
+
+Truncated literal
+^
+
+String-like classes can manipulate strings with embedded NUL as they are
+keeping track of the bytes and the length. This is not the case for an
+``char*`` (NUL-terminated) string.
+
+A common mistake is to pass a string-literal (NUL-terminated) to a string
+constructor. The bytes after the first NUL character are truncated.
+
+.. code:: c++
+
+  std::string str("abc\0

Re: [PATCH] D18703: [clang-tidy] Add new checker for comparison with runtime string functions.

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


Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:73
@@ +72,3 @@
+  functionDecl(
+  hasAnyName("__builtin_memcmp",
+ "__builtin_strcasecmp",

I'd  initialize the list as a comma/semicolon-separated list in a single string.


Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:119
@@ +118,3 @@
+  // Add the list of user-defined string compare-like functions.
+  for (const auto &FunctionName : StringCompareLikeFunctions) {
+IsStringCompareFunction =

The loop is not needed. I guess, you just can use the proper hasAnyName 
overload.


Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:218
@@ +217,3 @@
+ "function '%0' is compared using logical not operator")
+<< Decl->getName()
+<< FixItHint::CreateRemoval(

getName() is not needed.


Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:230
@@ +229,3 @@
+
+  if (Result.Nodes.getNodeAs("invalid-conversion") != nullptr) {
+diag(Call->getLocStart(),

` != nullptr` is not commonly used in clang/clang-tidy code.


http://reviews.llvm.org/D18703



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


Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

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


Comment at: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst:6
@@ +5,3 @@
+
+Find occurences of string literal with embedded NUL character and validate
+their usage.

Please use third-person form (Finds, validates, etc.).


Comment at: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst:27
@@ +26,3 @@
+String-like classes can manipulate strings with embedded NUL as they are
+keeping track of the bytes and the length. This is not the case for an
+``char*`` (NUL-terminated) string.

s/an/a/


Comment at: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst:30
@@ +29,3 @@
+
+A common mistake is to pass a string-literal (NUL-terminated) to a string
+constructor. The bytes after the first NUL character are truncated.

There doesn't seem to be anything bad with `NUL-terminated`. Did you mean `with 
embedded NUL character`?


http://reviews.llvm.org/D18783



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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

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

Actually, did you think about adding this as a clang diagnostic?

Richard, what do you think about complaining in Clang about `int i = true;` 
kind of code?



Comment at: clang-tidy/modernize/BoolToIntegerConversionCheck.cpp:49
@@ +48,3 @@
+diag(BoolLiteral->getLocation(), "implicitly converting bool literal to "
+ "%0. Use integer literal instead")
+<< Type

s/. Use/; use/

Same below.


Comment at: docs/ReleaseNotes.rst:119
@@ +118,3 @@
+
+  Replaces implicit cast from bool literals to integers with int literals.
+

The phrase is technically incorrect. The check does not replace `implicit cast 
from bool literals`. It replaces bool literals (which are being implicitly cast 
to integers) with integer literals.


Comment at: docs/clang-tidy/checks/modernize-bool-to-integer-conversion.rst:9
@@ +8,3 @@
+.. code-block:: C++
+  int a = false;
+  vector v(true); // Makes vector of one element

There should be an empty line after `.. code-block ...`.


http://reviews.llvm.org/D18821



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


Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52930.
etienneb marked 3 inline comments as done.
etienneb added a comment.

fix doc.


http://reviews.llvm.org/D18783

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp

Index: test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s misc-string-literal-with-embedded-nul %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template 
+struct basic_string {
+  typedef basic_string _Type;
+  basic_string();
+  basic_string(const C *p, const A &a = A());
+
+  _Type& operator+=(const C* s);
+  _Type& operator=(const C* s);
+};
+
+typedef basic_string, std::allocator> string;
+typedef basic_string, std::allocator> wstring;
+}
+
+bool operator==(const std::string&, const char*);
+bool operator==(const char*, const std::string&);
+
+
+const char Valid[] = "This is valid \x12.";
+const char Strange[] = "This is strange \0x12 and must be fixed";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: suspicious embedded NUL character [misc-string-literal-with-embedded-nul]
+
+const char textA[] = "\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious embedded NUL character
+const wchar_t textW[] = L"\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: suspicious embedded NUL character
+
+const char A[] = "\0";
+const char B[] = "\0x";
+const char C[] = "\0x1";
+const char D[] = "\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+const wchar_t E[] = L"\0";
+const wchar_t F[] = L"\0x";
+const wchar_t G[] = L"\0x1";
+const wchar_t H[] = L"\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious embedded NUL character
+
+const char I[] = "\000\000\000\000";
+const char J[] = "\0\0\0\0\0\0";
+const char K[] = "";
+
+const char L[] = "\0x12" "\0x12" "\0x12" "\0x12";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+void TestA() {
+  std::string str1 = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str2 = "\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str3("\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+  std::string str4{"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+
+  std::string str;
+  str += "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: truncated string literal
+  str = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: truncated string literal
+
+  if (str == "abc\0def") return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: truncated string literal
+  if ("abc\0def" == str) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: truncated string literal
+}
+
+void TestW() {
+  std::wstring str1 = L"abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str2 = L"\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str3(L"\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+  std::wstring str4{L"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+}
Index: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - misc-string-literal-with-embedded-nul
+
+misc-string-literal-with-embedded-nul
+=
+
+Finds occurences of string literal with embedded NUL character and validates
+their usage.
+
+
+Invalid escaping
+
+
+Special characters can be escaped within a string literal by using their
+hexadecimal encoding like ``\x42``. A common mistake is to escape them
+like this ``\0x42`` where the ``\0`` stands for the NUL character.
+
+.. code:: c++
+
+  const char* Example[] = "Invalid character: \0x12 should be \x12";
+  const char* Bytes[] = "\x03\0x02\0x01\0x00\0xFF\0xFF\0xFF";
+
+
+Truncated literal
+^
+
+String-like classes can manipulate strings with embedded NUL as they are
+keeping track of the bytes and the length. This is not the case for a
+``char*`` (NUL-terminated) string.
+
+A common mistake is to pass a string-literal with embedded NUL to a string
+constructor expecting a NUL-terminated string. The bytes after

Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

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

LG with one nit.



Comment at: clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp:70
@@ +69,3 @@
+diag(SL->getLocStart(), "suspicious embedded NUL character");
+break;
+  }

nit: Should this be `return` instead?


http://reviews.llvm.org/D18783



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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

2016-04-07 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D18821#394486, @alexfh wrote:

> Actually, did you think about adding this as a clang diagnostic?
>
> Richard, what do you think about complaining in Clang about `int i = true;` 
> kind of code?


Glad to hear that :)


http://reviews.llvm.org/D18821



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


Re: [PATCH] D18766: [clang-tidy] Add check misc-multiple-statement-macro

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

LG with a nit.



Comment at: clang-tidy/misc/MultipleStatementMacroCheck.cpp:99
@@ +98,3 @@
+
+  diag(InnerRanges.back().first, "multiple statement macro spans unbraced "
+ "conditional and the following statement");

If I saw this message from a tool, I wouldn't get what it means right away. Can 
you come up with an easier to read alternative? I can only suggest `multiple 
statement macro used without braces`, but maybe a more self-documenting message 
comes to your mind.


Comment at: docs/clang-tidy/checks/misc-multiple-statement-macro.rst:16
@@ +15,2 @@
+INCREMENT_TWO(a, b);
+

While I see your point, this doesn't seem worse to me:

if (do_increment)
  INCREMENT_TWO(a, b); // `(b)++;` will always be executed.

Up to you though.


http://reviews.llvm.org/D18766



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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

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


Comment at: clang-tidy/modernize/BoolToIntegerConversionCheck.cpp:47
@@ +46,3 @@
+  const auto Type = Cast->getType().getLocalUnqualifiedType();
+  if (isPreprocessorIndependent(BoolLiteral, Result)) {
+diag(BoolLiteral->getLocation(), "implicitly converting bool literal to "

I'd prefer an alternative with less code duplication:

  auto Diag = diag("implicitly converting bool literal to %0%select{|inside a 
macro}1; use ...") << Type;
  if ()
Diag << 1 << FixItHint::...;
  else
Diag << 0;


http://reviews.llvm.org/D18821



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


Re: [PATCH] D18617: Call TargetMachine::addEarlyAsPossiblePasses from BackendUtil.

2016-04-07 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/CodeGen/BackendUtil.cpp:347
@@ +346,3 @@
+PassManagerBuilder::EP_EarlyAsPossible,
+[this](const PassManagerBuilder &, legacy::PassManagerBase &PM) {
+  TM->addEarlyAsPossiblePasses(PM);

chandlerc wrote:
> Why capture this? Capturing TM would seem narrower. If you don't want a 
> narrow capture, I'd just use [&]...
TM is a member variable; you can't explicitly capture member variables?  
https://godbolt.org/g/T4kl3G

I can change it to [&] if you like that better.


http://reviews.llvm.org/D18617



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


Re: [PATCH] D18797: [Clang-tidy] Mention readability-static-definition-in-anonymous-namespace in release notes

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

LG


Repository:
  rL LLVM

http://reviews.llvm.org/D18797



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


Re: [PATCH] D18783: [clang-tidy] add new checker for string literal with NUL character.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 52935.
etienneb added a comment.

nit


http://reviews.llvm.org/D18783

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
  clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
  test/clang-tidy/misc-string-literal-with-embedded-nul.cpp

Index: test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
@@ -0,0 +1,85 @@
+// RUN: %check_clang_tidy %s misc-string-literal-with-embedded-nul %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template 
+struct basic_string {
+  typedef basic_string _Type;
+  basic_string();
+  basic_string(const C *p, const A &a = A());
+
+  _Type& operator+=(const C* s);
+  _Type& operator=(const C* s);
+};
+
+typedef basic_string, std::allocator> string;
+typedef basic_string, std::allocator> wstring;
+}
+
+bool operator==(const std::string&, const char*);
+bool operator==(const char*, const std::string&);
+
+
+const char Valid[] = "This is valid \x12.";
+const char Strange[] = "This is strange \0x12 and must be fixed";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: suspicious embedded NUL character [misc-string-literal-with-embedded-nul]
+
+const char textA[] = "\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: suspicious embedded NUL character
+const wchar_t textW[] = L"\0x01\0x02\0x03\0x04";
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: suspicious embedded NUL character
+
+const char A[] = "\0";
+const char B[] = "\0x";
+const char C[] = "\0x1";
+const char D[] = "\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+const wchar_t E[] = L"\0";
+const wchar_t F[] = L"\0x";
+const wchar_t G[] = L"\0x1";
+const wchar_t H[] = L"\0x11";
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious embedded NUL character
+
+const char I[] = "\000\000\000\000";
+const char J[] = "\0\0\0\0\0\0";
+const char K[] = "";
+
+const char L[] = "\0x12" "\0x12" "\0x12" "\0x12";
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: suspicious embedded NUL character
+
+void TestA() {
+  std::string str1 = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str2 = "\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: truncated string literal
+  std::string str3("\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+  std::string str4{"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: truncated string literal
+
+  std::string str;
+  str += "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: truncated string literal
+  str = "abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: truncated string literal
+
+  if (str == "abc\0def") return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: truncated string literal
+  if ("abc\0def" == str) return;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: truncated string literal
+}
+
+void TestW() {
+  std::wstring str1 = L"abc\0def";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str2 = L"\0";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: truncated string literal
+  std::wstring str3(L"\0");
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+  std::wstring str4{L"\x00\x01\x02\x03"};
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: truncated string literal
+}
Index: docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - misc-string-literal-with-embedded-nul
+
+misc-string-literal-with-embedded-nul
+=
+
+Finds occurences of string literal with embedded NUL character and validates
+their usage.
+
+
+Invalid escaping
+
+
+Special characters can be escaped within a string literal by using their
+hexadecimal encoding like ``\x42``. A common mistake is to escape them
+like this ``\0x42`` where the ``\0`` stands for the NUL character.
+
+.. code:: c++
+
+  const char* Example[] = "Invalid character: \0x12 should be \x12";
+  const char* Bytes[] = "\x03\0x02\0x01\0x00\0xFF\0xFF\0xFF";
+
+
+Truncated literal
+^
+
+String-like classes can manipulate strings with embedded NUL as they are
+keeping track of the bytes and the length. This is not the case for a
+``char*`` (NUL-terminated) string.
+
+A common mistake is to pass a string-literal with embedded NUL to a string
+constructor expecting a NUL-terminated string. The bytes after the first NUL
+character are truncated.
+
+.. c

[clang-tools-extra] r265691 - [clang-tidy] add new checker for string literal with NUL character.

2016-04-07 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr  7 11:16:36 2016
New Revision: 265691

URL: http://llvm.org/viewvc/llvm-project?rev=265691&view=rev
Log:
[clang-tidy] add new checker for string literal with NUL character.

Summary:
This patch adds the support for detecting suspicious string
literals and their //incorrect// usage.

The following example shows a incorrect character escaping leading 
to an embedded NUL character. 
```
  std::string str = "\0x42";   // Should be "\x42".
```

The patch also add detection of truncated literal when a literal
is passed to a string constructor.

Reviewers: hokein, alexfh

Subscribers: LegalizeAdulthood, bcraig, Eugene.Zelenko, bkramer, cfe-commits

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

Added:

clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-string-literal-with-embedded-nul.rst

clang-tools-extra/trunk/test/clang-tidy/misc-string-literal-with-embedded-nul.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=265691&r1=265690&r2=265691&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Apr  7 11:16:36 
2016
@@ -23,6 +23,7 @@ add_clang_library(clangTidyMiscModule
   SizeofContainerCheck.cpp
   StaticAssertCheck.cpp
   StringIntegerAssignmentCheck.cpp
+  StringLiteralWithEmbeddedNulCheck.cpp
   SuspiciousMissingCommaCheck.cpp
   SuspiciousSemicolonCheck.cpp
   SwappedArgumentsCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=265691&r1=265690&r2=265691&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Thu Apr  7 
11:16:36 2016
@@ -31,6 +31,7 @@
 #include "SizeofContainerCheck.h"
 #include "StaticAssertCheck.h"
 #include "StringIntegerAssignmentCheck.h"
+#include "StringLiteralWithEmbeddedNulCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
 #include "SuspiciousSemicolonCheck.h"
 #include "SwappedArgumentsCheck.h"
@@ -89,6 +90,8 @@ public:
 "misc-static-assert");
 CheckFactories.registerCheck(
 "misc-string-integer-assignment");
+CheckFactories.registerCheck(
+"misc-string-literal-with-embedded-nul");
 CheckFactories.registerCheck(
 "misc-suspicious-missing-comma");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp?rev=265691&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp 
(added)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/StringLiteralWithEmbeddedNulCheck.cpp 
Thu Apr  7 11:16:36 2016
@@ -0,0 +1,83 @@
+//===--- StringLiteralWithEmbeddedNulCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "StringLiteralWithEmbeddedNulCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+AST_MATCHER(StringLiteral, containsNul) {
+  for (size_t i = 0; i < Node.getLength(); ++i)
+if (Node.getCodeUnit(i) == '\0')
+  return true;
+  return false;
+}
+
+void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
+  // Match a string that contains embedded NUL character. Extra-checks are
+  // applied in |check| to find incorectly escaped characters.
+  Finder->addMatcher(stringLiteral(containsNul()).bind("strlit"), this);
+
+  // The remaining checks only apply to C++.
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  const auto StrLitWithNul =
+  ignoringParenImpCasts(stringLiteral(containsNul()).bind("truncated"));
+
+  // Match string constructor.
+  const auto StringConstructorExpr = expr(anyOf(
+ 

Re: [PATCH] D11958: Add a -gmodules option to the clang driver.

2016-04-07 Thread Adrian Prantl via cfe-commits
aprantl accepted this revision.
aprantl added a reviewer: aprantl.
aprantl added a comment.
This revision is now accepted and ready to land.

This landed a long time ago as r246192.


Repository:
  rL LLVM

http://reviews.llvm.org/D11958



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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

2016-04-07 Thread Sean McBride via cfe-commits
On Thu, 7 Apr 2016 15:48:56 +, Alexander Kornienko via cfe-commits said:

>Actually, did you think about adding this as a clang diagnostic?
>
>Richard, what do you think about complaining in Clang about `int i =
>true;` kind of code?

If you don't mind a lurker interjecting... :)  I think that'd be great.  I work 
with an old C++ codebase that started before C++ had 'bool', and so it used 
'int' instead.  A warning for 'int i = true' would help to convert all those 
old 'ints' to 'bools'.

Cheers,

Sean


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


Re: [PATCH] D18797: [Clang-tidy] Mention readability-static-definition-in-anonymous-namespace in release notes

2016-04-07 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265698: Mention 
readability-static-definition-in-anonymous-namespace in release notes. 
(authored by eugenezelenko).

Changed prior to commit:
  http://reviews.llvm.org/D18797?vs=52712&id=52939#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18797

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

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -159,13 +159,18 @@
 
   Finds unnecessary string initializations.
 
+- New `readability-static-definition-in-anonymous-namespace
+  
`_
 check
+
+  Finds static function and variable definitions in anonymous namespace.
+
 Fixed bugs:
 
 - Crash when running on compile database with relative source files paths.
 
 - Crash when running with the `-fdelayed-template-parsing` flag.
 
-- The ``modernize-use-override`` check: incorrect fix-its placement around
+- The `modernize-use-override` check: incorrect fix-its placement around
   ``__declspec`` and other attributes.
 
 Clang-tidy changes from 3.7 to 3.8


Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -159,13 +159,18 @@
 
   Finds unnecessary string initializations.
 
+- New `readability-static-definition-in-anonymous-namespace
+  `_ check
+
+  Finds static function and variable definitions in anonymous namespace.
+
 Fixed bugs:
 
 - Crash when running on compile database with relative source files paths.
 
 - Crash when running with the `-fdelayed-template-parsing` flag.
 
-- The ``modernize-use-override`` check: incorrect fix-its placement around
+- The `modernize-use-override` check: incorrect fix-its placement around
   ``__declspec`` and other attributes.
 
 Clang-tidy changes from 3.7 to 3.8
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r265698 - Mention readability-static-definition-in-anonymous-namespace in release notes.

2016-04-07 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Apr  7 12:28:35 2016
New Revision: 265698

URL: http://llvm.org/viewvc/llvm-project?rev=265698&view=rev
Log:
Mention readability-static-definition-in-anonymous-namespace in release notes.

Consistency in using ` and ``.

Differential revision: http://reviews.llvm.org/D18797

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

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=265698&r1=265697&r2=265698&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Apr  7 12:28:35 2016
@@ -159,13 +159,18 @@ identified.  The improvements since the
 
   Finds unnecessary string initializations.
 
+- New `readability-static-definition-in-anonymous-namespace
+  
`_
 check
+
+  Finds static function and variable definitions in anonymous namespace.
+
 Fixed bugs:
 
 - Crash when running on compile database with relative source files paths.
 
 - Crash when running with the `-fdelayed-template-parsing` flag.
 
-- The ``modernize-use-override`` check: incorrect fix-its placement around
+- The `modernize-use-override` check: incorrect fix-its placement around
   ``__declspec`` and other attributes.
 
 Clang-tidy changes from 3.7 to 3.8


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


Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-04-07 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In http://reviews.llvm.org/D17821#393496, @bader wrote:

> In http://reviews.llvm.org/D17821#393387, @Anastasia wrote:
>
> > Regarding, extending this approach for OpenCL pipe types too. I was 
> > thinking we could change current implementation to have ReadPipeType and 
> > WritePipeType. They can both be derived from PipeType that we already have 
> > now (we can make it an abstract class to avoid its instantiation?).
> >
> > Similarly to images, since read and write pipes will be mapped to different 
> > Clang types, we won't need any extra semantical checking but just need to 
> > add extra code in CodeGen of pipe type and builtins to accept two separate 
> > types for read only and write only cases.
> >
> > Would this make sense?
>
>
> Sure. Do you want me to add it here or it's okay if we fix pipes in a 
> separate patch?


Yes, I think it's better to go in a separate commit, not to complicate this one 
too much. Also since there are not many comment here, I think we should try to 
commit it ASAP otherwise rebasing would be an issue.


http://reviews.llvm.org/D17821



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


Re: [PATCH] D17482: [clang-tidy] Allow tests to verify changes made to header files

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

Let's try to turn this to a productive lane. I'm not against adding this 
functionality, if it's actually useful, but as is the patch doesn't meet the 
bar. Right now, there are a few action items.

First, could you split the refactorings and send me as a separate patch? They 
have little to do with the added functionality, so I prefer to review them 
separately.

Second, please move the header to a subdirectory of test/clang-tidy/Inputs/ 
(http://reviews.llvm.org/D17482#inline-156627).

Third (possibly, after the refactoring patch goes in, to reduce unneeded work), 
please address this comment: http://reviews.llvm.org/D17482#inline-149906.


http://reviews.llvm.org/D17482



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


r265700 - Minor Wdocumentation fix. NFCI.

2016-04-07 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Apr  7 12:38:24 2016
New Revision: 265700

URL: http://llvm.org/viewvc/llvm-project?rev=265700&view=rev
Log:
Minor Wdocumentation fix. NFCI.

Modified:
cfe/trunk/include/clang/Parse/Parser.h

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=265700&r1=265699&r2=265700&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Apr  7 12:38:24 2016
@@ -2526,7 +2526,7 @@ private:
 public:
   /// Parses simple expression in parens for single-expression clauses of 
OpenMP
   /// constructs.
-  /// \param LLoc Returned location of left paren.
+  /// \param RLoc Returned location of right paren.
   ExprResult ParseOpenMPParensExpr(StringRef ClauseName, SourceLocation &RLoc);
   bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext,
   bool AllowDestructorName,


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


Re: [PATCH] D17412: PR19957: [OpenCL] incorrectly accepts implicit address space conversion with ternary operator

2016-04-07 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In http://reviews.llvm.org/D17412#391351, @Matt wrote:

> In http://reviews.llvm.org/D17412#391322, @Anastasia wrote:
>
> > Cool, thanks! I think we should commit this ASAP.
> >
> > @Xiuli/@Matt, do you have any more comments here?
>
>
> Hi! I think that "Matt" for this one would be @arsenm :-)


Oh, sure. Thanks for pointing this out!!!

@arsenm, if you don't have any objections, could we commit this?


http://reviews.llvm.org/D17412



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


Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

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


Comment at: clang-tidy/misc/AssignOperatorCheck.cpp:63
@@ +62,3 @@
+
+  Finder->addMatcher(returnStmt(IsBadReturnStatement, 
hasAncestor(IsGoodAssign))
+ .bind("returnStmt"),

baloghadamsoftware wrote:
> sbenza wrote:
> > baloghadamsoftware wrote:
> > > sbenza wrote:
> > > > I dislike these uses of hasAnscestor. They are kind of slow.
> > > > But more importantly, they break with nested functions/types.
> > > > This particular example is not checking that the return statement is 
> > > > from the assignment operator, only that it is within it. For example, 
> > > > it would match a lambda.
> > > > I think this would trip the check:
> > > > 
> > > > F& operator=(const F& o) {
> > > >   std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; 
> > > > });
> > > >   return *this;
> > > > }
> > > I can change it to hasDescendant if it is faster, but it does not solve 
> > > the lambda problem. No solution for that comes to my mind with the 
> > > existing matchers. Maybe a new matcher hasDescendantStatement could help 
> > > which only traverses statements down the AST. Is this the right way to go?
> > hasDescendant has the same problem has hasAnscestor.
> > I think the best is to write a matcher like:
> > 
> > AST_MATCHER_P(ReturnStmt, forFunction, internal::Matcher, 
> > InnerMatcher) {
> >   ...
> > }
> > 
> > In there we can find the right FunctionDecl that encloses the return 
> > statement and apply the matcher.
> > This matcher seems like a good candidate to add to ASTMatchers.h
> Maybe I am wrong, but your proposal also seems a bottom-up matcher which is 
> slow. That is the reason I proposed a top-down matcher, e.g. 
> hasDescendantStatement or something like this which is top-down and only 
> traverses statements so it does not search in a lambda which is a declaration.
hasAnscestor is slow because it is way too general. There are tons of virtual 
function calls, cache lookups, memory allocations, etc. And the search will not 
stop until it find a match or runs out of anscestors. This means it will go all 
the way to the translationUnitDecl before it figures out that there are no 
matches.
Every parent will be run through the matcher.

What I propose is a simple matcher that:
 1. Finds the enclosing FunctionDecl for a statement.
 2. Runs the matcher on it, if there is an enclosing function.

(1) can be done without any virtual function call and with no/minimal memory 
allocations.
(2) will be done only once on the found node.



http://reviews.llvm.org/D18265



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


r265702 - Basic: move CodeGenOptions from Frontend

2016-04-07 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Apr  7 12:49:44 2016
New Revision: 265702

URL: http://llvm.org/viewvc/llvm-project?rev=265702&view=rev
Log:
Basic: move CodeGenOptions from Frontend

This is a mechanical move of CodeGenOptions from libFrontend to libBasic.  This
fixes the layering violation introduced earlier by threading CodeGenOptions into
TargetInfo.  It should also fix the modules based self-hosting builds.  NFC.

Added:
cfe/trunk/include/clang/Basic/CodeGenOptions.def
  - copied, changed from r265700, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Basic/CodeGenOptions.h
  - copied, changed from r265700, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Basic/CodeGenOptions.cpp
  - copied, changed from r265700, cfe/trunk/lib/Frontend/CodeGenOptions.cpp
Removed:
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/lib/Frontend/CodeGenOptions.cpp
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Frontend/CompilerInvocation.h
cfe/trunk/include/clang/module.modulemap
cfe/trunk/lib/Basic/CMakeLists.txt
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.h
cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
cfe/trunk/lib/CodeGen/CoverageMappingGen.h
cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/unittests/Basic/CMakeLists.txt
cfe/trunk/unittests/Lex/CMakeLists.txt

Copied: cfe/trunk/include/clang/Basic/CodeGenOptions.def (from r265700, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.def)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?p2=cfe/trunk/include/clang/Basic/CodeGenOptions.def&p1=cfe/trunk/include/clang/Frontend/CodeGenOptions.def&r1=265700&r2=265702&rev=265702&view=diff
==
(empty)

Copied: cfe/trunk/include/clang/Basic/CodeGenOptions.h (from r265700, 
cfe/trunk/include/clang/Frontend/CodeGenOptions.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?p2=cfe/trunk/include/clang/Basic/CodeGenOptions.h&p1=cfe/trunk/include/clang/Frontend/CodeGenOptions.h&r1=265700&r2=265702&rev=265702&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Thu Apr  7 12:49:44 2016
@@ -11,13 +11,14 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
-#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
+#ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H
+#define LLVM_CLANG_BASIC_CODEGENOPTIONS_H
 
 #include "clang/Basic/DebugInfoOptions.h"
 #include "clang/Basic/Sanitizers.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Target/TargetOptions.h"
+
 #include 
 #include 
 #include 
@@ -31,12 +32,12 @@ class CodeGenOptionsBase {
 public:
 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
-#include "clang/Frontend/CodeGenOptions.def"
+#include "clang/Basic/CodeGenOptions.def"
 
 protected:
 #define CODEGENOPT(Name, Bits, Default)
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
-#include "clang/Frontend/CodeGenOptions.def"
+#include "clang/Basic/CodeGenOptions.def"
 };
 
 /// CodeGenOptions - Track various options which control how the code
@@ -211,7 +212,7 @@ public:
 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
   Type get##Name() const { return static_cast(Name); } \
   void set##Name(Type Value) { Name = static_cast(Value); }
-#include "clang/Frontend/CodeGenOptions.def"
+#include "clang/Basic/CodeGenOptions.def"
 
   CodeGenOptions();
 

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=265702&r1=265701&r2=265702&view=diff
==

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

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


Comment at: clang-tidy/ClangTidyOptions.cpp:269
@@ +268,3 @@
+  ->CheckSources[ClangTidyOptions::ConfigCommandlineOptionOrFile]
+  .push_back(ClangTidyOptions::StringPair(*ParsedOptions->Checks,
+  ConfigFile.c_str()));

Can we use `.emplace_back` here?


Comment at: clang-tidy/ClangTidyOptions.h:91
@@ +90,3 @@
+  // The priority from low to high:
+  //   DefaultBinary > ConfigCommandlineOptionOrFile > ChecksCommandlineOption
+  enum CheckSourceType {

If it's from low to high, I'd use `<` instead of `>` to avoid confusion ;)


Comment at: clang-tidy/ClangTidyOptions.h:99
@@ +98,3 @@
+
+  // \brief Stores each check filter and its source for every check source 
type.
+  // clang-tidy has 3 types of check sources:

1. Use `///` for doxygen comments.
2. Insert an empty comment line after this line to mark the end of the `\brief` 
block.
3. Mark the list items with `*`.


Comment at: clang-tidy/ClangTidyOptions.h:104
@@ +103,3 @@
+  //'-checks' commandline option
+  std::vector CheckSources[CheckSourceTypeEnd];
+

Can we store a single vector of string pairs instead of three different 
vectors? The second item of the pair already says enough about the source. And 
this being an array doesn't seem to be useful.


Comment at: clang-tidy/tool/ClangTidyMain.cpp:281
@@ +280,3 @@
+.push_back(ClangTidyOptions::StringPair(
+Checks, "command-line option '-checks'"));
+  }

Please pull this string literal to a constant: it's used more than once in the 
code. Maybe also pull the "clang-tidy binary" string too, for consistency.


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] D18694: [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.

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


Comment at: clang-tidy/tool/ClangTidyMain.cpp:281
@@ +280,3 @@
+.push_back(ClangTidyOptions::StringPair(
+Checks, "command-line option '-checks'"));
+  }

alexfh wrote:
> Please pull this string literal to a constant: it's used more than once in 
> the code. Maybe also pull the "clang-tidy binary" string too, for consistency.
Err, the strings are actually different, but I'd still make all three of them 
constants.


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] D18191: [clang-tidy] Add check for function parameters that are const& to builtin types

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


Comment at: docs/clang-tidy/checks/misc-const-ref-builtin.rst:28
@@ +27,2 @@
+
+The instantiation of g will not be flagged.

nit: enclose `g` with double backquotes, please. Same with other inline code 
snippets (`int`, `double`, etc.)


http://reviews.llvm.org/D18191



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

2016-04-07 Thread Kim Gräsman via cfe-commits
kimgr added a comment.

The RUN line looks weird to me, but I'm no lit expert...



Comment at: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- 
-fdelayed-template-parsing
+

Are the double `--` necessary?


http://reviews.llvm.org/D18852



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

2016-04-07 Thread Etienne Bergeron via cfe-commits
etienneb marked an inline comment as done.


Comment at: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- 
-fdelayed-template-parsing
+

kimgr wrote:
> Are the double `--` necessary?
Yes, this is fine. See other *delayed.cpp test.

Example:

// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
-fdelayed-template-parsing



http://reviews.llvm.org/D18852



___
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-07 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A couple of nits.



Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:181
@@ +180,3 @@
+  Init->isMemberInitializer()
+  ? static_cast(Init->getMember())
+  : static_cast(

If you're doing this to disambiguate the ternary operator, you can skip the 
second cast.


Comment at: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp:285
@@ +284,3 @@
+union NegativeUnionInClass {
+  NegativeUnionInClass() {} // No message as a union can only initialize one 
member
+  int X = 0;

nit: Trailing period is missing.

Same below.


http://reviews.llvm.org/D18584



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


[libcxx] r265706 - Recommit r263036 with additional inlining, so that it will continue to work with existing system dylibs. Implements LWG#2583

2016-04-07 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Apr  7 13:13:41 2016
New Revision: 265706

URL: http://llvm.org/viewvc/llvm-project?rev=265706&view=rev
Log:
Recommit r263036 with additional inlining, so that it will continue to work 
with existing system dylibs. Implements LWG#2583

Modified:
libcxx/trunk/include/string
libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=265706&r1=265705&r2=265706&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Thu Apr  7 13:13:41 2016
@@ -98,8 +98,10 @@ public:
 basic_string(const basic_string& str);
 basic_string(basic_string&& str)
 noexcept(is_nothrow_move_constructible::value);
-basic_string(const basic_string& str, size_type pos, size_type n = npos,
+basic_string(const basic_string& str, size_type pos,
  const allocator_type& a = allocator_type());
+basic_string(const basic_string& str, size_type pos, size_type n,
+ const Allocator& a = Allocator()); 
 basic_string(const value_type* s, const allocator_type& a = 
allocator_type());
 basic_string(const value_type* s, size_type n, const allocator_type& a = 
allocator_type());
 basic_string(size_type n, value_type c, const allocator_type& a = 
allocator_type());
@@ -1397,7 +1399,10 @@ public:
 basic_string(size_type __n, value_type __c);
 _LIBCPP_INLINE_VISIBILITY
 basic_string(size_type __n, value_type __c, const allocator_type& __a);
-basic_string(const basic_string& __str, size_type __pos, size_type __n = 
npos,
+basic_string(const basic_string& __str, size_type __pos, size_type __n,
+ const allocator_type& __a = allocator_type());
+_LIBCPP_INLINE_VISIBILITY
+basic_string(const basic_string& __str, size_type __pos,
  const allocator_type& __a = allocator_type());
 template
 _LIBCPP_INLINE_VISIBILITY
@@ -2220,6 +2225,21 @@ basic_string<_CharT, _Traits, _Allocator
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
 #endif
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& 
__str, size_type __pos,
+const allocator_type& 
__a)
+: __r_(__a)
+{
+size_type __str_sz = __str.size();
+if (__pos > __str_sz)
+this->__throw_out_of_range();
+__init(__str.data() + __pos, __str_sz - __pos);
+#if _LIBCPP_DEBUG_LEVEL >= 2
+__get_db()->__insert_c(this);
+#endif
 }
 
 template 

Modified: libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp?rev=265706&r1=265705&r2=265706&view=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp Thu 
Apr  7 13:13:41 2016
@@ -11,14 +11,21 @@
 // 
 
 // basic_string(const basic_string& str,
-//  size_type pos, size_type n = npos,
+//  size_type pos, size_type n,
+//  const Allocator& a = Allocator());
+//
+// basic_string(const basic_string& str,
+//  size_type pos,
 //  const Allocator& a = Allocator());
 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 #include "min_allocator.h"
 
@@ -91,6 +98,20 @@ test(S str, unsigned pos, unsigned n, co
 }
 }
 
+#if TEST_STD_VER >= 11
+void test2583()
+{   // LWG #2583
+typedef std::basic_string, 
test_allocator > StringA;
+std::vector>> vs;
+StringA s{"1234"};
+vs.emplace_back(s, 2);
+
+try { vs.emplace_back(s, 5); }
+catch (const std::out_of_range&) { return; }
+assert(false);
+}
+#endif
+
 int main()
 {
 {
@@ -131,7 +152,7 @@ int main()
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A(7)), 50, 10, A(8));
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A(7)), 50, 100, A(8));
 }
-#if __cplusplus >= 201103L
+#if TEST_STD_VER >= 11
 {
 typedef min_allocator A;
 typedef std::basic_string, A> S;
@@ -170,5 +191,7 @@ int main()
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A()), 50, 10, A());
 
test(S("1234567890123456789012345678901234567890123456789012345678901234567890",
 A()), 50, 100, A());
 }
+
+test2583();
 #endif
 }


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


Re: [PATCH] D18649: [clang-tidy] cppcoreguidelines-interfaces-global-init

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


Comment at: test/clang-tidy/cppcoreguidelines-interfaces-global-init.cpp:7
@@ +6,3 @@
+
+extern int ExternGlobal;
+static int GlobalScopeBadInit1 = ExternGlobal;

What happens if you add:

  extern int ExternGlobal;
  extern int ExternGlobal;
  int ExternGlobal = 123;

?


http://reviews.llvm.org/D18649



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


Re: [PATCH] D18745: [clang-tidy] Adds modernize-use-bool-literals check.

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


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.cpp:39
@@ +38,3 @@
+
+  return LiteralSource.size() >= 1 && isDigit(LiteralSource.front());
+}

Use `!x.empty()` instead of `x.size() >= 1`.


Comment at: clang-tidy/modernize/UseBoolLiteralsCheck.h:19
@@ +18,3 @@
+
+/// Finds integer literals, which are implicitly cast to bool.
+///

What about the ones explicitly cast to `bool`? Do we want to warn on them?


Comment at: test/clang-tidy/modernize-use-bool-literals.cpp:18
@@ +17,3 @@
+bool MacroIntToTrue = TRUE_MACRO; // Not ok, but can't replace
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: implicitly converting integer 
literal to bool inside macro, use bool literal instead 
[modernize-use-bool-literals]
+

Please add CHECK-FIXES to ensure that both the definition of the macro and the 
code using it are not changed.


http://reviews.llvm.org/D18745



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


Re: [PATCH] D18852: [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

2016-04-07 Thread Kim Gräsman via cfe-commits
kimgr added inline comments.


Comment at: test/clang-tidy/performance-unnecessary-value-param-delayed.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -- 
-fdelayed-template-parsing
+

etienneb wrote:
> kimgr wrote:
> > Are the double `--` necessary?
> Yes, this is fine. See other *delayed.cpp test.
> 
> Example:
> 
> // RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
> -fdelayed-template-parsing
> 
Oh, I see now that it's a peculiarity of `check_clang_tidy.py`. Sorry for the 
noise!


http://reviews.llvm.org/D18852



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


Re: [PATCH] D16183: Added CheckName field to YAML report

2016-04-07 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

The main concern here is that the clang-apply-replacements tool should be able 
to read this format. See the 
clang/tools/extra/clang-tidy/tool/run-clang-tidy.py script for an example of 
its usage.


http://reviews.llvm.org/D16183



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


Re: [PATCH] D17821: [OpenCL] Complete image types support

2016-04-07 Thread Alexey Bader via cfe-commits
bader added a comment.

In http://reviews.llvm.org/D17821#394620, @Anastasia wrote:

> Yes, I think it's better to go in a separate commit, not to complicate this 
> one too much. Also since there are not many comment here, I think we should 
> try to commit it ASAP otherwise rebasing would be an issue.


I can commit it tomorrow if there are no other comments.


http://reviews.llvm.org/D17821



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


Re: [PATCH] D18810: [Clang-tidy] Fix readability-static-definition-in-anonymous-namespace warnings; other minor fixes.

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

Actually, removal of `static` is not the right thing for LLVM:

> Because of this, we have a simple guideline: make anonymous namespaces as 
> small as possible, and only use them for class declarations.


http://llvm.org/docs/CodingStandards.html#anonymous-namespaces


Repository:
  rL LLVM

http://reviews.llvm.org/D18810



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

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

Richard, is there anything else that blocks this patch?



Comment at: lib/Sema/SemaDecl.cpp:6372
@@ +6371,3 @@
+  if (isa(OldDC)) {
+if (isa(ShadowedDecl))
+  return SDK_Field;

How about `return isa(ShadowedDecl) ? SDK_Field : SDK_StaticMember;`?


Comment at: lib/Sema/SemaDecl.cpp:6376
@@ +6375,3 @@
+  return SDK_StaticMember;
+  } else if (OldDC->isFileContext()) {
+return SDK_Global;

No `else` after `return`, please.


http://reviews.llvm.org/D18271



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


Re: [PATCH] D17362: [Sema] PR23090 Crash when return type or parameter types for extern "C" functions don't have external linkage

2016-04-07 Thread Richard Smith via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

Why do you think this is ill-formed? Using a type with internal linkage as the 
type of an extern "C" function is explicitly permitted by the C++ standard. 
[basic.link]p8 says:

"A type without linkage shall not be used as the type of a variable or function 
with external linkage unless the entity has C language linkage [...]."


http://reviews.llvm.org/D17362



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


Re: [PATCH] D17451: PR26448: [Sema] Fix determined type of ternary operator acting on two xvalue class types

2016-04-07 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


http://reviews.llvm.org/D17451



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


r265711 - NFC: simplify code in BuildInstanceMessage.

2016-04-07 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Apr  7 14:30:20 2016
New Revision: 265711

URL: http://llvm.org/viewvc/llvm-project?rev=265711&view=rev
Log:
NFC: simplify code in BuildInstanceMessage.

Instead of searching the global pool multiple times: in
LookupFactoryMethodInGlobalPool, LookupInstanceMethodInGlobalPool,
CollectMultipleMethodsInGlobalPool, and AreMultipleMethodsInGlobalPool,
we now collect the method candidates in CollectMultipleMethodsInGlobalPool
only, and other functions will use the collected method set.

This commit adds parameter "Methods" to AreMultipleMethodsInGlobalPool,
and SelectBestMethod. It also changes the implementation of
CollectMultipleMethodsInGlobalPool to collect the desired kind first, if none is
found, to collect the other kind. This avoids the need to call both
LookupFactoryMethodInGlobalPool and LookupInstanceMethodInGlobalPool.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=265711&r1=265710&r2=265711&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr  7 14:30:20 2016
@@ -3155,25 +3155,31 @@ private:
 
 public:
   /// \brief - Returns instance or factory methods in global method pool for
-  /// given selector. If no such method or only one method found, function 
returns
-  /// false; otherwise, it returns true
-  bool CollectMultipleMethodsInGlobalPool(Selector Sel,
-  SmallVectorImpl& 
Methods,
-  bool instance);
+  /// given selector. It checks the desired kind first, if none is found, and
+  /// parameter checkTheOther is set, it then checks the other kind. If no such
+  /// method or only one method is found, function returns false; otherwise, it
+  /// returns true.
+  bool
+  CollectMultipleMethodsInGlobalPool(Selector Sel,
+ SmallVectorImpl& Methods,
+ bool InstanceFirst, bool CheckTheOther);
 
-  bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod,
-  SourceRange R,
-  bool receiverIdOrClass);
+  bool
+  AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod,
+ SourceRange R, bool receiverIdOrClass,
+ SmallVectorImpl& Methods);
   
-  void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl 
&Methods,
-  Selector Sel, SourceRange R,
-  bool receiverIdOrClass);
+  void
+  DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl &Methods,
+ Selector Sel, SourceRange R,
+ bool receiverIdOrClass);
 
 private:
   /// \brief - Returns a selector which best matches given argument list or
   /// nullptr if none could be found
   ObjCMethodDecl *SelectBestMethod(Selector Sel, MultiExprArg Args,
-   bool IsInstance);
+   bool IsInstance,
+   SmallVectorImpl& Methods);
 
 
   /// \brief Record the typo correction failure and return an empty correction.

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=265711&r1=265710&r2=265711&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr  7 14:30:20 2016
@@ -3281,25 +3281,57 @@ static bool isAcceptableMethodMismatch(O
   return (chosen->getReturnType()->isIntegerType());
 }
 
+/// We first select the type of the method: Instance or Factory, then collect
+/// all methods with that type.
 bool Sema::CollectMultipleMethodsInGlobalPool(
-Selector Sel, SmallVectorImpl &Methods, bool instance) {
+Selector Sel, SmallVectorImpl &Methods,
+bool InstanceFirst, bool CheckTheOther) {
   if (ExternalSource)
 ReadMethodPool(Sel);
 
   GlobalMethodPool::iterator Pos = MethodPool.find(Sel);
   if (Pos == MethodPool.end())
 return false;
+
   // Gather the non-hidden methods.
-  ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
+  ObjCMethodList &MethList = InstanceFirst ? Pos->second.first :
+ Pos->second.second;
   for (ObjCMethodList *M = &MethList; M; M = M->getNext())
 if (M->getMethod() && !M->getMethod()->isHidden())
   Methods.push_back(M->getMethod());
+
+  // Return if we find any method with the desired kin

r265712 - [ObjC kindof] Use type bound to filter out the candidate methods.

2016-04-07 Thread Manman Ren via cfe-commits
Author: mren
Date: Thu Apr  7 14:32:24 2016
New Revision: 265712

URL: http://llvm.org/viewvc/llvm-project?rev=265712&view=rev
Log:
[ObjC kindof] Use type bound to filter out the candidate methods.

rdar://21306753

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/kindof.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=265712&r1=265711&r2=265712&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr  7 14:32:24 2016
@@ -3162,7 +3162,8 @@ public:
   bool
   CollectMultipleMethodsInGlobalPool(Selector Sel,
  SmallVectorImpl& Methods,
- bool InstanceFirst, bool CheckTheOther);
+ bool InstanceFirst, bool CheckTheOther,
+ const ObjCObjectType *TypeBound = 
nullptr);
 
   bool
   AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=265712&r1=265711&r2=265712&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr  7 14:32:24 2016
@@ -3281,11 +3281,45 @@ static bool isAcceptableMethodMismatch(O
   return (chosen->getReturnType()->isIntegerType());
 }
 
+/// Return true if the given method is wthin the type bound.
+static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method,
+ const ObjCObjectType *TypeBound) {
+  if (!TypeBound)
+return true;
+
+  if (TypeBound->isObjCId())
+// FIXME: should we handle the case of bounding to id differently?
+return true;
+
+  auto *BoundInterface = TypeBound->getInterface();
+  assert(BoundInterface && "unexpected object type!");
+
+  // Check if the Method belongs to a protocol. We should allow any method
+  // defined in any protocol, because any subclass could adopt the protocol.
+  auto *MethodProtocol = dyn_cast(Method->getDeclContext());
+  if (MethodProtocol) {
+return true;
+  }
+
+  // If the Method belongs to a class, check if it belongs to the class
+  // hierarchy of the class bound.
+  if (ObjCInterfaceDecl *MethodInterface = Method->getClassInterface()) {
+// We allow methods declared within classes that are part of the hierarchy
+// of the class bound (superclass of, subclass of, or the same as the class
+// bound).
+return MethodInterface == BoundInterface ||
+   MethodInterface->isSuperClassOf(BoundInterface) ||
+   BoundInterface->isSuperClassOf(MethodInterface);
+  }
+  llvm_unreachable("unknow method context");
+}
+
 /// We first select the type of the method: Instance or Factory, then collect
 /// all methods with that type.
 bool Sema::CollectMultipleMethodsInGlobalPool(
 Selector Sel, SmallVectorImpl &Methods,
-bool InstanceFirst, bool CheckTheOther) {
+bool InstanceFirst, bool CheckTheOther,
+const ObjCObjectType *TypeBound) {
   if (ExternalSource)
 ReadMethodPool(Sel);
 
@@ -3297,8 +3331,10 @@ bool Sema::CollectMultipleMethodsInGloba
   ObjCMethodList &MethList = InstanceFirst ? Pos->second.first :
  Pos->second.second;
   for (ObjCMethodList *M = &MethList; M; M = M->getNext())
-if (M->getMethod() && !M->getMethod()->isHidden())
-  Methods.push_back(M->getMethod());
+if (M->getMethod() && !M->getMethod()->isHidden()) {
+  if (FilterMethodsByTypeBound(M->getMethod(), TypeBound))
+Methods.push_back(M->getMethod());
+}
 
   // Return if we find any method with the desired kind.
   if (!Methods.empty())
@@ -3311,8 +3347,10 @@ bool Sema::CollectMultipleMethodsInGloba
   ObjCMethodList &MethList2 = InstanceFirst ? Pos->second.second :
   Pos->second.first;
   for (ObjCMethodList *M = &MethList2; M; M = M->getNext())
-if (M->getMethod() && !M->getMethod()->isHidden())
-  Methods.push_back(M->getMethod());
+if (M->getMethod() && !M->getMethod()->isHidden()) {
+  if (FilterMethodsByTypeBound(M->getMethod(), TypeBound))
+Methods.push_back(M->getMethod());
+}
 
   return Methods.size() > 1;
 }

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=265712&r1=265711&r2=265712&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Apr  7 14:32:24 2016
@@ -2618,16 +2618,15 @@ ExprResult Sema::BuildInstanceMessage(Ex
  

Re: [PATCH] D18843: Always have clang pass -pie-level and -pic-level values to the code generator

2016-04-07 Thread Sriraman Tallam via cfe-commits
tmsriram updated this revision to Diff 52945.
tmsriram added a comment.

Cleanup the code to use a local variable to store *Res.getLangOpts()


http://reviews.llvm.org/D18843

Files:
  lib/Frontend/CompilerInvocation.cpp

Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2110,6 +2110,7 @@
   InputArgList Args =
   Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
   MissingArgCount, IncludedFlagsBitmask);
+  LangOptions &LangOpts = *Res.getLangOpts();
 
   // Check for missing argument error.
   if (MissingArgCount) {
@@ -2128,7 +2129,7 @@
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags);
-  ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+  ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
@@ -2141,22 +2142,26 @@
 // PassManager in BackendUtil.cpp. They need to be initializd no matter
 // what the input type is.
 if (Args.hasArg(OPT_fobjc_arc))
-  Res.getLangOpts()->ObjCAutoRefCount = 1;
+  LangOpts.ObjCAutoRefCount = 1;
+// PIClevel and PIELevel are needed during code generation and this should 
be
+// set regardless of the input type.
+LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
-Diags, Res.getLangOpts()->Sanitize);
+Diags, LangOpts.Sanitize);
   } else {
 // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
-ParseLangArgs(*Res.getLangOpts(), Args, DashX, Res.getTargetOpts(), Diags);
+ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags);
 if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
-  Res.getLangOpts()->ObjCExceptions = 1;
+  LangOpts.ObjCExceptions = 1;
   }
 
   // FIXME: Override value name discarding when asan or msan is used because 
the
   // backend passes depend on the name of the alloca in order to print out
   // names.
   Res.getCodeGenOpts().DiscardValueNames &=
-  !Res.getLangOpts()->Sanitize.has(SanitizerKind::Address) &&
-  !Res.getLangOpts()->Sanitize.has(SanitizerKind::Memory);
+  !LangOpts.Sanitize.has(SanitizerKind::Address) &&
+  !LangOpts.Sanitize.has(SanitizerKind::Memory);
 
   // FIXME: ParsePreprocessorArgs uses the FileManager to read the contents of
   // PCH file and find the original header name. Remove the need to do that in


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2110,6 +2110,7 @@
   InputArgList Args =
   Opts->ParseArgs(llvm::makeArrayRef(ArgBegin, ArgEnd), MissingArgIndex,
   MissingArgCount, IncludedFlagsBitmask);
+  LangOptions &LangOpts = *Res.getLangOpts();
 
   // Check for missing argument error.
   if (MissingArgCount) {
@@ -2128,7 +2129,7 @@
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags);
-  ParseCommentArgs(Res.getLangOpts()->CommentOpts, Args);
+  ParseCommentArgs(LangOpts.CommentOpts, Args);
   ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
   // FIXME: We shouldn't have to pass the DashX option around here
   InputKind DashX = ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags);
@@ -2141,22 +2142,26 @@
 // PassManager in BackendUtil.cpp. They need to be initializd no matter
 // what the input type is.
 if (Args.hasArg(OPT_fobjc_arc))
-  Res.getLangOpts()->ObjCAutoRefCount = 1;
+  LangOpts.ObjCAutoRefCount = 1;
+// PIClevel and PIELevel are needed during code generation and this should be
+// set regardless of the input type.
+LangOpts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
+LangOpts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
-Diags, Res.getLangOpts()->Sanitize);
+Diags, LangOpts.Sanitize);
   } else {
 // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
-ParseLangArgs(*Res.getLangOpts(), Args, DashX, Res.getTargetOpts(), Diags);
+ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(), Diags);
 

[libclc] r265713 - [AMDGPU] Implement get_local_size for amdgcn--amdhsa triple

2016-04-07 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Thu Apr  7 14:54:19 2016
New Revision: 265713

URL: http://llvm.org/viewvc/llvm-project?rev=265713&view=rev
Log:
[AMDGPU] Implement get_local_size for amdgcn--amdhsa triple

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

Added:
libclc/trunk/amdgcn-amdhsa/
libclc/trunk/amdgcn-amdhsa/lib/
libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
libclc/trunk/amdgcn-amdhsa/lib/SOURCES
libclc/trunk/amdgcn-amdhsa/lib/workitem/
libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll
Modified:
libclc/trunk/.gitignore
libclc/trunk/configure.py

Modified: libclc/trunk/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.gitignore?rev=265713&r1=265712&r2=265713&view=diff
==
--- libclc/trunk/.gitignore (original)
+++ libclc/trunk/.gitignore Thu Apr  7 14:54:19 2016
@@ -1,5 +1,6 @@
 Makefile
 amdgcn--
+amdgcn--amdhsa
 build/*.pyc
 built_libs/
 generic--

Added: libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/OVERRIDES?rev=265713&view=auto
==
(empty)

Added: libclc/trunk/amdgcn-amdhsa/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/SOURCES?rev=265713&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/SOURCES (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/SOURCES Thu Apr  7 14:54:19 2016
@@ -0,0 +1 @@
+workitem/get_local_size.ll

Added: libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll?rev=265713&view=auto
==
--- libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll (added)
+++ libclc/trunk/amdgcn-amdhsa/lib/workitem/get_local_size.ll Thu Apr  7 
14:54:19 2016
@@ -0,0 +1,35 @@
+declare i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr() #0
+
+define i32 @get_local_size(i32 %dim) #1 {
+  %dispatch_ptr = call noalias nonnull dereferenceable(64) i8 addrspace(2)* 
@llvm.amdgcn.dispatch.ptr()
+  %dispatch_ptr_i32 = bitcast i8 addrspace(2)* %dispatch_ptr to i32 
addrspace(2)*
+  %xy_size_ptr = getelementptr inbounds i32, i32 addrspace(2)* 
%dispatch_ptr_i32, i64 1
+  %xy_size = load i32, i32 addrspace(2)* %xy_size_ptr, align 4, 
!invariant.load !0
+  switch i32 %dim, label %default [
+i32 0, label %x_dim
+i32 1, label %y_dim
+i32 2, label %z_dim
+  ]
+
+x_dim:
+  %x_size = and i32 %xy_size, 65535
+  ret i32 %x_size
+
+y_dim:
+  %y_size = lshr i32 %xy_size, 16
+  ret i32 %y_size
+
+z_dim:
+  %z_size_ptr = getelementptr inbounds i32, i32 addrspace(2)* 
%dispatch_ptr_i32, i64 2
+  %z_size = load i32, i32 addrspace(2)* %z_size_ptr, align 4, !invariant.load 
!0, !range !1
+  ret i32 %z_size
+
+default:
+  ret i32 1
+}
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { alwaysinline norecurse nounwind readonly }
+
+!0 = !{}
+!1 = !{ i32 0, i32 257 }

Modified: libclc/trunk/configure.py
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/configure.py?rev=265713&r1=265712&r2=265713&view=diff
==
--- libclc/trunk/configure.py (original)
+++ libclc/trunk/configure.py Thu Apr  7 14:54:19 2016
@@ -102,6 +102,9 @@ available_targets = {
   'amdgcn--': { 'devices' :
 [{'gpu' : 'tahiti', 'aliases' : ['pitcairn', 'verde', 'oland', 
'hainan', 'bonaire', 'kabini', 'kaveri', 
'hawaii','mullins','tonga','carrizo','iceland','fiji','stoney'],
  'defines' : {}} ]},
+  'amdgcn--amdhsa': { 'devices' :
+  [{'gpu' : '', 'aliases' : ['bonaire', 'hawaii', 
'kabini', 'kaveri', 'mullins', 'carrizo', 'stoney', 'fiji', 'iceland', 'tonga'],
+   'defines' : {}} ]},
   'nvptx--'   : { 'devices' : [{'gpu' : '', 'aliases' : [],
 'defines' : {'all' : ['cl_khr_fp64']}}]},
   'nvptx64--' : { 'devices' : [{'gpu' : '', 'aliases' : [],
@@ -112,7 +115,7 @@ available_targets = {
 'defines' : {'all' : 
['cl_khr_fp64']}}]},
 }
 
-default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--', 
'amdgcn--']
+default_targets = ['nvptx--nvidiacl', 'nvptx64--nvidiacl', 'r600--', 
'amdgcn--', 'amdgcn--amdhsa']
 
 targets = args
 if not targets:


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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

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

We had a conversation about this change around the office the other week, and 
people were concerned about false negatives like the trim_in_place one. 
Basically, I don't have time to discover all the ways you can modify your 
parameters:

  struct B {
A a;
B(A a) : a(a) { // modifies parameter, not member
  a.a = 42;
  modify_in_place(&a);
  a.setMember(3);
}
  };

These kinds of bugs are uncommon, but the existing -Wshadow protects users 
against this today. I think it'll be OK if we give these users an extra 
-Wshadow-constructor preserves the more strict behavior.


http://reviews.llvm.org/D18271



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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

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


Comment at: lib/Sema/SemaDecl.cpp:1615
@@ -1614,2 +1614,3 @@
 IdResolver.RemoveDecl(D);
+ShadowingDecls.erase(D);
   }

This'd be a good place to produce a -Wshadow-constructor or similar warning if 
D is still in the map.


Comment at: lib/Sema/SemaDecl.cpp:6483
@@ +6482,3 @@
+  const NamedDecl *D = DRE->getDecl();
+  auto I = ShadowingDecls.find(D);
+  if (I == ShadowingDecls.end())

Maybe map to the canonical decl before using the `Decl*` as a key? (This 
doesn't matter for now, but we'll likely want to extend this to other kinds of 
shadowing in the future.)


Comment at: lib/Sema/SemaDecl.cpp:6489-6490
@@ +6488,4 @@
+  ShadowedDeclKind Kind = computeShadowedDeclKind(ShadowedDecl, OldDC);
+  Diag(Loc, diag::warn_modifying_shadowing_decl) << D << Kind << OldDC;
+  Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
+

Could be useful to also note the location of the shadowing decl.


http://reviews.llvm.org/D18271



___
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-07 Thread Michael Miller via cfe-commits
michael_miller updated this revision to Diff 52950.
michael_miller marked 15 inline comments as done.
michael_miller added a comment.

Removed a superfluous cast and added periods to some comments.


http://reviews.llvm.org/D18584

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tidy/utils/Matchers.h
  clang-tidy/utils/TypeTraits.cpp
  clang-tidy/utils/TypeTraits.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
  test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -4,13 +4,13 @@
   int F;
   // CHECK-FIXES: int F{};
   PositiveFieldBeforeConstructor() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: F
   // CHECK-FIXES: PositiveFieldBeforeConstructor() {}
 };
 
 struct PositiveFieldAfterConstructor {
   PositiveFieldAfterConstructor() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F, G
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: F, G
   // CHECK-FIXES: PositiveFieldAfterConstructor() {}
   int F;
   // CHECK-FIXES: int F{};
@@ -26,12 +26,12 @@
 };
 
 PositiveSeparateDefinition::PositiveSeparateDefinition() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
 // CHECK-FIXES: PositiveSeparateDefinition::PositiveSeparateDefinition() {}
 
 struct PositiveMixedFieldOrder {
   PositiveMixedFieldOrder() : J(0) {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: I, K
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: I, K
   // CHECK-FIXES: PositiveMixedFieldOrder() : J(0) {}
   int I;
   // CHECK-FIXES: int I{};
@@ -43,7 +43,7 @@
 template 
 struct Template {
   Template() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these built-in/pointer fields: F
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: F
   int F;
   // CHECK-FIXES: int F{};
   T T1;
@@ -67,7 +67,6 @@
 };
 NegativeFieldInitializedInDefinition::NegativeFieldInitializedInDefinition() : F() {}
 
-
 struct NegativeInClassInitialized {
   int F = 0;
 
@@ -87,25 +86,248 @@
 };
 
 #define UNINITIALIZED_FIELD_IN_MACRO_BODY(FIELD) \
-  struct UninitializedField##FIELD {		 \
-UninitializedField##FIELD() {}		 \
-int FIELD;	 \
-  };		 \
+  struct UninitializedField##FIELD { \
+UninitializedField##FIELD() {}   \
+int FIELD;   \
+  }; \
 // Ensure FIELD is not initialized since fixes inside of macros are disabled.
 // CHECK-FIXES: int FIELD;
 
 UNINITIALIZED_FIELD_IN_MACRO_BODY(F);
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: F
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
 UNINITIALIZED_FIELD_IN_MACRO_BODY(G);
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these built-in/pointer fields: G
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: G
 
 #define UNINITIALIZED_FIELD_IN_MACRO_ARGUMENT(ARGUMENT) \
-  ARGUMENT		\
+  ARGUMENT
 
 UNINITIALIZED_FIELD_IN_MACRO_ARGUMENT(struct UninitializedFieldInMacroArg {
   UninitializedFieldInMacroArg() {}
   int Field;
 });
-// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: constructor does not initialize these built-in/pointer fields: Field
+// CHECK-MESSAGES: :[[@LINE-3]]:3: warning: constructor does not initialize these fields: Field
 // Ensure FIELD is not initialized since fixes inside of macros are disabled.
 // CHECK-FIXES: int Field;
+
+struct NegativeAggregateType {
+  int X;
+  int Y;
+  int Z;
+};
+
+struct PositiveTrivialType {
+  PositiveTrivialType() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields: F
+
+  NegativeAggregateType F;
+  // CHECK-FIXES: NegativeAggregateType F{};
+};
+
+struct NegativeNonTrivialType {
+  PositiveTrivialType F;
+};
+
+static void PositiveUninitializedTrivialType() {
+  NegativeAggregateType X;
+  // CHECK-MESSAGES: :[[@LIN

r265718 - [modules] Allow differences in flags that only affect preprocessor predefines

2016-04-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr  7 15:47:37 2016
New Revision: 265718

URL: http://llvm.org/viewvc/llvm-project?rev=265718&view=rev
Log:
[modules] Allow differences in flags that only affect preprocessor predefines
(and __has_feature checks) between explicitly-specified module files and the
current compilation.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/explicit-build-flags.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=265718&r1=265717&r2=265718&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Apr  7 15:47:37 2016
@@ -24,11 +24,15 @@
 //
 // VALUE_LANGOPT: for options that describe a value rather than a flag.
 //
-// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT: combinations of the above.
+// BENIGN_ENUM_LANGOPT, COMPATIBLE_ENUM_LANGOPT,
+// BENIGN_VALUE_LANGOPT, COMPATIBLE_VALUE_LANGOPT: combinations of the above.
 //
 // FIXME: Clients should be able to more easily select whether they want
 // different levels of compatibility versus how to handle different kinds
 // of option.
+//
+// The Description field should be a noun phrase, for instance "frobbing all
+// widgets" or "C's implicit blintz feature".
 
//===--===//
 
 #ifndef LANGOPT
@@ -65,6 +69,16 @@
  LANGOPT(Name, Bits, Default, Description)
 #endif
 
+#ifndef COMPATIBLE_VALUE_LANGOPT
+#  define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
+ VALUE_LANGOPT(Name, Bits, Default, Description)
+#endif
+
+#ifndef BENIGN_VALUE_LANGOPT
+#  define BENIGN_VALUE_LANGOPT(Name, Bits, Default, Description) \
+ COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description)
+#endif
+
 // FIXME: A lot of the BENIGN_ options should be COMPATIBLE_ instead.
 LANGOPT(C99   , 1, 0, "C99")
 LANGOPT(C11   , 1, 0, "C11")
@@ -124,32 +138,32 @@ LANGOPT(Coroutines, 1, 0, "C++ c
 BENIGN_LANGOPT(ThreadsafeStatics , 1, 1, "thread-safe static initializers")
 LANGOPT(POSIXThreads  , 1, 0, "POSIX thread support")
 LANGOPT(Blocks, 1, 0, "blocks extension to C")
-BENIGN_LANGOPT(EmitAllDecls  , 1, 0, "support for emitting all 
declarations")
-LANGOPT(MathErrno , 1, 1, "errno support for math functions")
-BENIGN_LANGOPT(HeinousExtensions , 1, 0, "Extensions that we really don't like 
and may be ripped out at any time")
+BENIGN_LANGOPT(EmitAllDecls  , 1, 0, "emitting all declarations")
+LANGOPT(MathErrno , 1, 1, "errno in math functions")
+BENIGN_LANGOPT(HeinousExtensions , 1, 0, "extensions that we really don't like 
and may be ripped out at any time")
 LANGOPT(Modules   , 1, 0, "modules extension to C")
 BENIGN_LANGOPT(CompilingModule, 1, 0, "compiling a module interface")
 COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module 
uses")
-LANGOPT(ModulesSearchAll  , 1, 1, "search even non-imported modules to find 
unresolved references")
-COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "require declaration of module 
uses and all headers to be in modules")
-BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically import modules as 
needed when performing error recovery")
-BENIGN_LANGOPT(ImplicitModules, 1, 1, "build modules that are not specified 
via -fmodule-file")
+BENIGN_LANGOPT(ModulesSearchAll  , 1, 1, "searching even non-imported modules 
to find unresolved references")
+COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of 
module uses and all headers to be in modules")
+BENIGN_LANGOPT(ModulesErrorRecovery, 1, 1, "automatically importing modules as 
needed when performing error recovery")
+BENIGN_LANGOPT(ImplicitModules, 1, 1, "building modules that are not specified 
via -fmodule-file")
 COMPATIBLE_LANGOPT(ModulesLocalVisibility, 1, 0, "local submodule visibility")
 COMPATIBLE_LANGOPT(Optimize  , 1, 0, "__OPTIMIZE__ predefined macro")
 COMPATIBLE_LANGOPT(OptimizeSize  , 1, 0, "__OPTIMIZE_SIZE__ predefined 
macro")
-LANGOPT(Static, 1, 0, "__STATIC__ predefined macro (as opposed to 
__DYNAMIC__)")
+COMPATIBLE_LANGOPT(Static, 1, 0, "__STATIC__ predefined macro (as 
opposed to __DYNAMIC__)")
 VALUE_LANGOPT(PackStruct  , 32, 0,
   "default struct packing maximum alignment")
 VALUE_LANGOPT(MaxTypeAlign  , 32, 0,
   "default maximum alignment for types")
-VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level")
-VALUE_LANGOPT(PIELevel, 2, 0, "__PIE__ level")
-LANGOPT(GNUInline , 1, 0, "GNU inline semantics")
+COMPATIBLE_VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level")
+COMPATIBLE_VALUE_LANGOPT(PIELevel, 2, 0, "__PIE__ level")
+COMPATIBLE_LANGOPT(GNUInline  

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

2016-04-07 Thread Matthias Gehre via cfe-commits
mgehre added a comment.

By the way, is there a tool to generate parts of the test based on clang 
output, i.e.
something that will prefix the output of clang with "CHECK: " and "CHECK-NEXT:" 
so I can copy-and-paste
it into my test file?


http://reviews.llvm.org/D15031



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


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

2016-04-07 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.

This all seems reasonable to me, one inline rewording comment, and check with 
rjmccall before committing.

Thanks!



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.
+  }];

Probably better to say linux fwiw and not ELF.


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] D16797: Update clang support on recent Haiku

2016-04-07 Thread Jérôme Duval via cfe-commits
korli removed rL LLVM as the repository for this revision.
korli updated this revision to Diff 52953.
korli added a comment.

Thanks for the review, and sorry for the late reply.

This updated diff takes rsmith's comments into account, adding a test 
test/Driver/haiku.c, a case for CST_Libcxx where applicable. This applies 
directly against today's trunk and clang builds then successfully.


http://reviews.llvm.org/D16797

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Frontend/InitHeaderSearch.cpp
  test/Driver/haiku.c

Index: test/Driver/haiku.c
===
--- /dev/null
+++ test/Driver/haiku.c
@@ -0,0 +1,12 @@
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86_64 -input-file %t.log %s
+
+// CHECK-X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64-unknown-haiku"
+// CHECK-X86_64: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
+
+// RUN: %clang -no-canonical-prefixes -target i586-pc-haiku %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-X86 -input-file %t.log %s
+
+// CHECK-X86: clang{{.*}}" "-cc1" "-triple" "i586-pc-haiku"
+// CHECK-X86: gcc{{.*}}" "-o" "a.out" "{{.*}}.o"
+
Index: lib/Frontend/InitHeaderSearch.cpp
===
--- lib/Frontend/InitHeaderSearch.cpp
+++ lib/Frontend/InitHeaderSearch.cpp
@@ -267,38 +267,39 @@
   }
 
   case llvm::Triple::Haiku:
-AddPath("/boot/common/include", System, false);
-AddPath("/boot/develop/headers/os", System, false);
-AddPath("/boot/develop/headers/os/app", System, false);
-AddPath("/boot/develop/headers/os/arch", System, false);
-AddPath("/boot/develop/headers/os/device", System, false);
-AddPath("/boot/develop/headers/os/drivers", System, false);
-AddPath("/boot/develop/headers/os/game", System, false);
-AddPath("/boot/develop/headers/os/interface", System, false);
-AddPath("/boot/develop/headers/os/kernel", System, false);
-AddPath("/boot/develop/headers/os/locale", System, false);
-AddPath("/boot/develop/headers/os/mail", System, false);
-AddPath("/boot/develop/headers/os/media", System, false);
-AddPath("/boot/develop/headers/os/midi", System, false);
-AddPath("/boot/develop/headers/os/midi2", System, false);
-AddPath("/boot/develop/headers/os/net", System, false);
-AddPath("/boot/develop/headers/os/storage", System, false);
-AddPath("/boot/develop/headers/os/support", System, false);
-AddPath("/boot/develop/headers/os/translation", System, false);
-AddPath("/boot/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/develop/headers/cpp", System, false);
-AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false);
-AddPath("/boot/develop/headers/3rdparty", System, false);
-AddPath("/boot/develop/headers/bsd", System, false);
-AddPath("/boot/develop/headers/glibc", System, false);
-AddPath("/boot/develop/headers/posix", System, false);
-AddPath("/boot/develop/headers",  System, false);
+AddPath("/boot/system/non-packaged/develop/headers", System, false);
+AddPath("/boot/system/develop/headers/os", System, false);
+AddPath("/boot/system/develop/headers/os/app", System, false);
+AddPath("/boot/system/develop/headers/os/arch", System, false);
+AddPath("/boot/system/develop/headers/os/device", System, false);
+AddPath("/boot/system/develop/headers/os/drivers", System, false);
+AddPath("/boot/system/develop/headers/os/game", System, false);
+AddPath("/boot/system/develop/headers/os/interface", System, false);
+AddPath("/boot/system/develop/headers/os/kernel", System, false);
+AddPath("/boot/system/develop/headers/os/locale", System, false);
+AddPath("/boot/system/develop/headers/os/mail", System, false);
+AddPath("/boot/system/develop/headers/os/media", System, false);
+AddPath("/boot/system/develop/headers/os/midi", System, false);
+AddPath("/boot/system/develop/headers/os/midi2", System, false);
+AddPath("/boot/system/develop/headers/os/net", System, false);
+AddPath("/boot/system/develop/headers/os/opengl", System, false);
+AddPath("/boot/system/develop/headers/os/storage", System, false);
+AddPath("/boot/system/develop/headers/os/support", System, false);
+AddPath("/boot/system/develop/headers/os/translation", System, false);
+AddPath("/boot/system/develop/headers/os/a

[PATCH] D18868: [Sema] PR27155: Fix a template argument deduction bug with base classes

2016-04-07 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
erik.pilkington added a subscriber: cfe-commits.

Previously, clang would incorrectly reject the following:

```
  struct S {};
  template struct D : T {};
  template void Foo(D);
  int fn() {
D, 0> v;
Foo(v);
  }
```

The problem is that clang initially tries to apply D for T in Foo, 
storing the result (in Deduced). Then clang tries to match 0 for 1 in Foo, 
would fail, and begin to consider the base classes of v (per temp.deduct.call 
p4.3), without resetting the original faulty assumption. This patch simply 
saves the deduced arguments before attempting the faulty deduction, then 
restores them once the faulty deduction fails.

Note: This section of code still has a somewhat related latent bug where 
ambiguous base class deductions are left undiagnosed, for example:

```
  int fn2() {
D, 1>, 0> v;
Foo(v); // error, is T deduced to be S or D?
  }
```

Which is outlawed by temp.deduct.call p5. I have another patch that fixes this, 
which I'll submit once(/if) this goes through.

http://reviews.llvm.org/D18868

Files:
  lib/Sema/SemaTemplateDeduction.cpp
  test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp

Index: test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
===
--- test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
+++ test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
@@ -146,3 +146,17 @@
   }
 
 }
+
+namespace PR27155 {
+
+struct B {};
+
+template struct D : T {};
+template void Foo(D);
+
+int fn() {
+  D, 0> f;
+  Foo(f);
+}
+
+}
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1421,21 +1421,29 @@
   const TemplateSpecializationType *SpecParam
 = cast(Param);
 
+  SmallVector DeducedOrig(Deduced.begin(),
+  Deduced.end());
+
   // Try to deduce template arguments from the template-id.
   Sema::TemplateDeductionResult Result
 = DeduceTemplateArguments(S, TemplateParams, SpecParam, Arg,
   Info, Deduced);
 
   if (Result && (TDF & TDF_DerivedClass)) {
-// C++ [temp.deduct.call]p3b3:
-//   If P is a class, and P has the form template-id, then A can be a
-//   derived class of the deduced A. Likewise, if P is a pointer to a
-//   class of the form template-id, A can be a pointer to a derived
-//   class pointed to by the deduced A.
+// C++14 [temp.deduct.call] p4b3:
+//   If P is a class and P has the form simple-template-id, then the
+//   transformed A can be a derived class of the deduced A. Likewise if
+//   P is a pointer to a class of the form simple-template-id, the
+//   transformed A can be a pointer to a derived class pointed to by 
the
+//   deduced A.
 //
-// More importantly:
 //   These alternatives are considered only if type deduction would
-//   otherwise fail.
+//   otherwise fail. If they yield more than one possible deduced A, 
the
+//   type deduction fails.
+
+// Reset the incorrectly deduced argument from above.
+Deduced = DeducedOrig;
+
 if (const RecordType *RecordT = Arg->getAs()) {
   // We cannot inspect base classes as part of deduction when the type
   // is incomplete, so either instantiate any templates necessary to
@@ -1450,8 +1458,6 @@
   SmallVector ToVisit;
   ToVisit.push_back(RecordT);
   bool Successful = false;
-  SmallVector DeducedOrig(Deduced.begin(),
-  Deduced.end());
   while (!ToVisit.empty()) {
 // Retrieve the next class in the inheritance hierarchy.
 const RecordType *NextT = ToVisit.pop_back_val();


Index: test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
===
--- test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
+++ test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
@@ -146,3 +146,17 @@
   }
 
 }
+
+namespace PR27155 {
+
+struct B {};
+
+template struct D : T {};
+template void Foo(D);
+
+int fn() {
+  D, 0> f;
+  Foo(f);
+}
+
+}
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1421,21 +1421,29 @@
   const TemplateSpecializationType *SpecParam
 = cast(Param);
 
+  SmallVector DeducedOrig(Deduced.begin(),
+  Deduced.end());
+
   // Try to deduce template arguments fr

r265728 - Replace Sema-level implementation of -fassume-sane-operator-new with a

2016-04-07 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr  7 16:46:12 2016
New Revision: 265728

URL: http://llvm.org/viewvc/llvm-project?rev=265728&view=rev
Log:
Replace Sema-level implementation of -fassume-sane-operator-new with a
CodeGen-level implementation. Instead of adding an attribute to clang's
FunctionDecl, add the IR attribute directly. This means a module built with
this flag is now compatible with code built without it and vice versa.

This change also results in the 'noalias' attribute no longer being added to
calls to operator new in the IR; it's now only added to the declaration. It
also fixes a bug where we failed to add the attribute to the 'nothrow' versions
(because we didn't implicitly declare them, there was no good time to inject a
fake attribute).

Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.def
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenCXX/align-avx-complete-objects.cpp
cfe/trunk/test/CodeGenCXX/arm.cpp
cfe/trunk/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
cfe/trunk/test/CodeGenCXX/cxx11-initializer-array-new.cpp
cfe/trunk/test/CodeGenCXX/delete-two-arg.cpp
cfe/trunk/test/CodeGenCXX/exceptions.cpp
cfe/trunk/test/CodeGenCXX/goto.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
cfe/trunk/test/CodeGenCXX/mips-size_t-ptrdiff_t.cpp
cfe/trunk/test/CodeGenCXX/multi-dim-operator-new.cpp
cfe/trunk/test/CodeGenCXX/new-alias.cpp
cfe/trunk/test/CodeGenCXX/new-array-init.cpp
cfe/trunk/test/CodeGenCXX/new-overflow.cpp
cfe/trunk/test/CodeGenCXX/new.cpp
cfe/trunk/test/CodeGenCXX/operator-new.cpp
cfe/trunk/test/CodeGenCXX/static-init.cpp
cfe/trunk/test/CodeGenObjCXX/arc-new-delete.mm
cfe/trunk/test/CodeGenObjCXX/copy.mm
cfe/trunk/test/Modules/explicit-build-flags.cpp

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=265728&r1=265727&r2=265728&view=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.def Thu Apr  7 16:46:12 2016
@@ -30,8 +30,9 @@ CODEGENOPT(Name, Bits, Default)
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
 CODEGENOPT(CompressDebugSections, 1, 0) ///< -Wa,-compress-debug-sections
-CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
+CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum 
for functions in GCNO files.
 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function 
names in GCDA files.

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=265728&r1=265727&r2=265728&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Apr  7 16:46:12 2016
@@ -189,7 +189,6 @@ LANGOPT(CUDAAllowVariadicFunctions, 1, 0
 LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "treating unattributed constexpr 
functions as __host__ __device__")
 LANGOPT(CUDADeviceFlushDenormalsToZero, 1, 0, "flushing denormals to zero")
 
-LANGOPT(AssumeSaneOperatorNew , 1, 1, "implicit __attribute__((malloc)) for 
C++'s new operators")
 LANGOPT(SizedDeallocation , 1, 0, "enable sized deallocation functions")
 LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
 BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=265728&r1=265727&r2=265728&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Apr  7 16:46:12 2016
@@ -4710,8 +4710,7 @@ public:
   void DeclareGlobalNewDelete();
   void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
QualType Param1,
-   QualType Param2 = QualType(),
-   bool addRestrictAttr = false);
+   QualType Param2 = QualType());
 
   bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,

Re: [PATCH] D18868: [Sema] PR27155: Fix a template argument deduction bug with base classes

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


Comment at: lib/Sema/SemaTemplateDeduction.cpp:1424-1426
@@ -1423,2 +1423,5 @@
 
+  SmallVector DeducedOrig(Deduced.begin(),
+  Deduced.end());
+
   // Try to deduce template arguments from the template-id.

Can you also make this saving (and restoring) of the old deduced arguments 
conditional on `TDF_DerivedClass` and the argument type being a class type? 
Maybe duplicate the `DeduceTemplateArguments` call and put one copy inside the 
`if (const RecordType *RecordT = ...` block and the other on the `else` path, 
instead of moving the copy earlier.


http://reviews.llvm.org/D18868



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


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

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

Update for review comments

- Change name from ObjLeavesScope to LifetimeEnds
- Make sure that trivially destructible objects end their lifetime after 
non-trivial destructible objects
- Add test
- Add analyzer option to enable LifetimeEnds CFG entries (disabled by default)

Note that AddImplicitDtors is mutally exclusive with AddLifetime (may be 
changed by a later patch)


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,673 @@
+// 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:Pred

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

2016-04-07 Thread John McCall via cfe-commits
rjmccall added inline comments.


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:
> 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?


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] D15524: [GCC] Attribute ifunc support in clang

2016-04-07 Thread Eric Christopher via cfe-commits
echristo added inline comments.


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.
+  }];

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.


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] D18868: [Sema] PR27155: Fix a template argument deduction bug with base classes

2016-04-07 Thread Erik Pilkington via cfe-commits
erik.pilkington updated this revision to Diff 52961.
erik.pilkington added a comment.

Invert some control flow for clarity, avoid unnecessary copy of deduced 
template arguments.


http://reviews.llvm.org/D18868

Files:
  lib/Sema/SemaTemplateDeduction.cpp
  test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp

Index: test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
===
--- test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
+++ test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp
@@ -146,3 +146,17 @@
   }
 
 }
+
+namespace PR27155 {
+
+struct B {};
+
+template struct D : T {};
+template void Foo(D);
+
+int fn() {
+  D, 0> f;
+  Foo(f);
+}
+
+}
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -1418,87 +1418,96 @@
 // TT
 // TT<>
 case Type::TemplateSpecialization: {
-  const TemplateSpecializationType *SpecParam
-= cast(Param);
-
-  // Try to deduce template arguments from the template-id.
-  Sema::TemplateDeductionResult Result
-= DeduceTemplateArguments(S, TemplateParams, SpecParam, Arg,
-  Info, Deduced);
-
-  if (Result && (TDF & TDF_DerivedClass)) {
-// C++ [temp.deduct.call]p3b3:
-//   If P is a class, and P has the form template-id, then A can be a
-//   derived class of the deduced A. Likewise, if P is a pointer to a
-//   class of the form template-id, A can be a pointer to a derived
-//   class pointed to by the deduced A.
-//
-// More importantly:
-//   These alternatives are considered only if type deduction would
-//   otherwise fail.
-if (const RecordType *RecordT = Arg->getAs()) {
-  // We cannot inspect base classes as part of deduction when the type
-  // is incomplete, so either instantiate any templates necessary to
-  // complete the type, or skip over it if it cannot be completed.
-  if (!S.isCompleteType(Info.getLocation(), Arg))
-return Result;
-
-  // Use data recursion to crawl through the list of base classes.
-  // Visited contains the set of nodes we have already visited, while
-  // ToVisit is our stack of records that we still need to visit.
-  llvm::SmallPtrSet Visited;
-  SmallVector ToVisit;
-  ToVisit.push_back(RecordT);
-  bool Successful = false;
-  SmallVector DeducedOrig(Deduced.begin(),
-  Deduced.end());
-  while (!ToVisit.empty()) {
-// Retrieve the next class in the inheritance hierarchy.
-const RecordType *NextT = ToVisit.pop_back_val();
-
-// If we have already seen this type, skip it.
-if (!Visited.insert(NextT).second)
-  continue;
-
-// If this is a base class, try to perform template argument
-// deduction from it.
-if (NextT != RecordT) {
-  TemplateDeductionInfo BaseInfo(Info.getLocation());
-  Sema::TemplateDeductionResult BaseResult
-= DeduceTemplateArguments(S, TemplateParams, SpecParam,
-  QualType(NextT, 0), BaseInfo,
-  Deduced);
-
-  // If template argument deduction for this base was successful,
-  // note that we had some success. Otherwise, ignore any deductions
-  // from this base class.
-  if (BaseResult == Sema::TDK_Success) {
-Successful = true;
-DeducedOrig.clear();
-DeducedOrig.append(Deduced.begin(), Deduced.end());
-Info.Param = BaseInfo.Param;
-Info.FirstArg = BaseInfo.FirstArg;
-Info.SecondArg = BaseInfo.SecondArg;
-  }
-  else
-Deduced = DeducedOrig;
-}
-
-// Visit base classes
-CXXRecordDecl *Next = cast(NextT->getDecl());
-for (const auto &Base : Next->bases()) {
-  assert(Base.getType()->isRecordType() &&
- "Base class that isn't a record?");
-  ToVisit.push_back(Base.getType()->getAs());
-}
-  }
+  const TemplateSpecializationType *SpecParam =
+  cast(Param);
+
+  if (!(TDF & TDF_DerivedClass))
+// Try to deduce template arguments from the template-id.
+return DeduceTemplateArguments(S, TemplateParams, SpecParam, Arg, Info,
+   Deduced);
+
+  SmallVector DeducedOrig(Deduced.begin(),
+  Deduced.end());
 
-  if (S

[PATCH] D18876: NFC: unify clang / LLVM atomic ordering

2016-04-07 Thread JF Bastien via cfe-commits
jfb created this revision.
jfb added reviewers: jyknight, reames.
jfb added a subscriber: cfe-commits.

Depends on http://reviews.llvm.org/D18875

This makes the C11 / C++11 *ABI* atomic ordering accessible from LLVM, as 
discussed in http://reviews.llvm.org/D18200#inline-151433

http://reviews.llvm.org/D18876

Files:
  include/clang/AST/Expr.h
  lib/CodeGen/CGAtomic.cpp
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1791,26 +1791,27 @@
 }
 
 static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op) {
-  if (Ordering < AtomicExpr::AO_ABI_memory_order_relaxed ||
-  Ordering > AtomicExpr::AO_ABI_memory_order_seq_cst)
+  if (Ordering < (int64_t)llvm::AtomicOrderingCABI::relaxed ||
+  Ordering > (int64_t)llvm::AtomicOrderingCABI::seq_cst)
 return false;
 
+  auto OrderingCABI = (llvm::AtomicOrderingCABI)Ordering;
   switch (Op) {
   case AtomicExpr::AO__c11_atomic_init:
 llvm_unreachable("There is no ordering argument for an init");
 
   case AtomicExpr::AO__c11_atomic_load:
   case AtomicExpr::AO__atomic_load_n:
   case AtomicExpr::AO__atomic_load:
-return Ordering != AtomicExpr::AO_ABI_memory_order_release &&
-   Ordering != AtomicExpr::AO_ABI_memory_order_acq_rel;
+return OrderingCABI != llvm::AtomicOrderingCABI::release &&
+   OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
 
   case AtomicExpr::AO__c11_atomic_store:
   case AtomicExpr::AO__atomic_store:
   case AtomicExpr::AO__atomic_store_n:
-return Ordering != AtomicExpr::AO_ABI_memory_order_consume &&
-   Ordering != AtomicExpr::AO_ABI_memory_order_acquire &&
-   Ordering != AtomicExpr::AO_ABI_memory_order_acq_rel;
+return OrderingCABI != llvm::AtomicOrderingCABI::consume &&
+   OrderingCABI != llvm::AtomicOrderingCABI::acquire &&
+   OrderingCABI != llvm::AtomicOrderingCABI::acq_rel;
 
   default:
 return true;
Index: lib/CodeGen/CGAtomic.cpp
===
--- lib/CodeGen/CGAtomic.cpp
+++ lib/CodeGen/CGAtomic.cpp
@@ -243,11 +243,6 @@
 /// Materialize an atomic r-value in atomic-layout memory.
 Address materializeRValue(RValue rvalue) const;
 
-/// \brief Translates LLVM atomic ordering to GNU atomic ordering for
-/// libcalls.
-static AtomicExpr::AtomicOrderingKind
-translateAtomicOrdering(const llvm::AtomicOrdering AO);
-
 /// \brief Creates temp alloca for intermediate operations on atomic value.
 Address CreateTempAlloca() const;
   private:
@@ -292,25 +287,6 @@
   };
 }
 
-AtomicExpr::AtomicOrderingKind
-AtomicInfo::translateAtomicOrdering(const llvm::AtomicOrdering AO) {
-  switch (AO) {
-  case llvm::AtomicOrdering::Unordered:
-  case llvm::AtomicOrdering::NotAtomic:
-  case llvm::AtomicOrdering::Monotonic:
-return AtomicExpr::AO_ABI_memory_order_relaxed;
-  case llvm::AtomicOrdering::Acquire:
-return AtomicExpr::AO_ABI_memory_order_acquire;
-  case llvm::AtomicOrdering::Release:
-return AtomicExpr::AO_ABI_memory_order_release;
-  case llvm::AtomicOrdering::AcquireRelease:
-return AtomicExpr::AO_ABI_memory_order_acq_rel;
-  case llvm::AtomicOrdering::SequentiallyConsistent:
-return AtomicExpr::AO_ABI_memory_order_seq_cst;
-  }
-  llvm_unreachable("Unhandled AtomicOrdering");
-}
-
 Address AtomicInfo::CreateTempAlloca() const {
   Address TempAlloca = CGF.CreateMemTemp(
   (LVal.isBitField() && ValueSizeInBits > AtomicSizeInBits) ? ValueTy
@@ -439,22 +415,22 @@
 default:
   FailureOrder = llvm::AtomicOrdering::Monotonic;
   break;
-case AtomicExpr::AO_ABI_memory_order_consume:
-case AtomicExpr::AO_ABI_memory_order_acquire:
+case (int)llvm::AtomicOrderingCABI::consume:
+case (int)llvm::AtomicOrderingCABI::acquire:
   FailureOrder = llvm::AtomicOrdering::Acquire;
   break;
-case AtomicExpr::AO_ABI_memory_order_seq_cst:
+case (int)llvm::AtomicOrderingCABI::seq_cst:
   FailureOrder = llvm::AtomicOrdering::SequentiallyConsistent;
   break;
 }
 if (isStrongerThan(FailureOrder, SuccessOrder)) {
   // Don't assert on undefined behavior "failure argument shall be no
   // stronger than the success argument".
   FailureOrder =
-llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrder);
+  llvm::AtomicCmpXchgInst::getStrongestFailureOrdering(SuccessOrder);
 }
-emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2, Size,
-  SuccessOrder, FailureOrder);
+emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2, Size, SuccessOrder,
+  FailureOrder);
 return;
   }
 
@@ -487,17 +463,17 @@
 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2,
   Size, SuccessOrder, llvm::AtomicOrdering::Acquire);
 CGF.Builder.CreateBr(ContBB)

Re: [PATCH] D18868: [Sema] PR27155: Fix a template argument deduction bug with base classes

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


Comment at: lib/Sema/SemaTemplateDeduction.cpp:1449-1451
@@ +1448,5 @@
+
+  const RecordType *RecordT = Arg->getAs();
+  if (!RecordT)
+return Result;
+

Can you move this up and merge it with the `TDF_DerivedClass` check to also 
skip the copy in the case where the argument is not of class type?


Comment at: lib/Sema/SemaTemplateDeduction.cpp:1453-1457
@@ +1452,7 @@
+
+  // We cannot inspect base classes as part of deduction when the type
+  // is incomplete, so either instantiate any templates necessary to
+  // complete the type, or skip over it if it cannot be completed.
+  if (!S.isCompleteType(Info.getLocation(), Arg))
+return Result;
+

... This too, if it's not too awkward.


http://reviews.llvm.org/D18868



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


[PATCH] D18879: Lit C++11 Compatibility Patch #6

2016-04-07 Thread Charles Li via cfe-commits
tigerleapgorge created this revision.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.

17 OpenMP tests have their expected diagnostics updated.
The changes to each file are identical.

http://reviews.llvm.org/D18879

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

Index: test/OpenMP/taskloop_simd_simdlen_messages.cpp
===
--- test/OpenMP/taskloop_simd_simdlen_messages.cpp
+++ test/OpenMP/taskloop_simd_simdlen_messages.cpp
@@ -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 @@
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp taskloop simd simdlen ((ST > 0) ? 1 + ST : 2)
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  // expected-error@+3 2 {{directive '#pragma omp taskloop simd' cannot contain more than one 'simdlen' clause}}
-  // expected-error@+2 2 {{argument to 'simdlen' 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 taskloop simd' cannot contain more than one 'simdlen' clause}}
+  // expected-error@+5 2 {{argument to 'simdlen' 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 taskloop simd simdlen (foobool(argc)), simdlen (true), simdlen (-5)
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp taskloop simd simdlen (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 taskloop simd simdlen (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 taskloop simd simdlen (4)
@@ -57,16 +69,27 @@
   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
   #pragma omp taskloop simd simdlen (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
-  #pragma omp taskloop simd simdlen (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 taskloop simd simdlen (foobool(1) > 0 ? 1 : 2)
+  for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
+  // expected-error@+6 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+  // expected-note@+4 {{non-constexpr function 'foobool' cannot be used in a constant expression}}
+#endif
   // expected-error@+2 2 {{directive '#pragma omp taskloop simd' cannot contain more than one 'simdlen' clause}}
   // expected-error@+1 2 {{argument to 'simdlen' clause must be a strictly positive integer value}}
   #pragma omp taskloop simd simdlen (foobool(argc)), simdlen (true), simdlen (-5) 
   for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4];
   #pragma omp taskloop simd simdlen (S1) // expected-error {{'S1' does not

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

2016-04-07 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.


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:
> 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.


http://reviews.llvm.org/D15524



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


[PATCH] D18882: [CUDA] Tweak math forward declares so we're compatible with libstdc++4.9.

2016-04-07 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added subscribers: tra, cfe-commits.

See comments in patch; we were assuming that some stdlib math functions
would be defined in namespace std, when in fact the spec says they
should be defined in the global namespace.  libstdc++4.9 became more
conforming and broke us.

This new implementation seems to cover the known knowns.

http://reviews.llvm.org/D18882

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

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -189,8 +189,21 @@
 // we have to include it and it will in turn include .hpp
 #include "sm_30_intrinsics.h"
 #include "sm_32_intrinsics.hpp"
+
 #undef __MATH_FUNCTIONS_HPP__
+
+// math_functions.hpp defines ::signbit as a __host__ __device__ function.  This
+// conflicts with libstdc++'s constexpr ::signbit, so we have to rename
+// math_function.hpp's ::signbit.  It's guarded by #undef signbit, but that's
+// conditional on __GNUC__.  :)
+#pragma push_macro("signbit")
+#pragma push_macro("__GNUC__")
+#undef __GNUC__
+#define signbit __ignored_cuda_signbit
 #include "math_functions.hpp"
+#pragma pop_macro("__GNUC__")
+#pragma pop_macro("signbit")
+
 #pragma pop_macro("__host__")
 
 #include "texture_indirect_functions.h"
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -37,153 +37,225 @@
 #define __DEVICE__ \
   static __inline__ __attribute__((always_inline)) __attribute__((device))
 
+__DEVICE__ double abs(double);
+__DEVICE__ float abs(float);
 __DEVICE__ int abs(int);
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
 __DEVICE__ double acos(double);
-__DEVICE__ float acosh(float);
+__DEVICE__ float acos(float);
 __DEVICE__ double acosh(double);
+__DEVICE__ float acosh(float);
 __DEVICE__ double asin(double);
-__DEVICE__ float asinh(float);
+__DEVICE__ float asin(float);
 __DEVICE__ double asinh(double);
-__DEVICE__ double atan(double);
+__DEVICE__ float asinh(float);
 __DEVICE__ double atan2(double, double);
-__DEVICE__ float atanh(float);
+__DEVICE__ float atan2(float, float);
+__DEVICE__ double atan(double);
+__DEVICE__ float atan(float);
 __DEVICE__ double atanh(double);
-__DEVICE__ float cbrt(float);
+__DEVICE__ float atanh(float);
 __DEVICE__ double cbrt(double);
+__DEVICE__ float cbrt(float);
 __DEVICE__ double ceil(double);
-__DEVICE__ float copysign(float, float);
+__DEVICE__ float ceil(float);
 __DEVICE__ double copysign(double, double);
+__DEVICE__ float copysign(float, float);
 __DEVICE__ double cos(double);
+__DEVICE__ float cos(float);
 __DEVICE__ double cosh(double);
-__DEVICE__ float erf(float);
-__DEVICE__ double erf(double);
-__DEVICE__ float erfc(float);
+__DEVICE__ float cosh(float);
 __DEVICE__ double erfc(double);
-__DEVICE__ double exp(double);
-__DEVICE__ float exp2(float);
+__DEVICE__ float erfc(float);
+__DEVICE__ double erf(double);
+__DEVICE__ float erf(float);
 __DEVICE__ double exp2(double);
-__DEVICE__ float expm1(float);
+__DEVICE__ float exp2(float);
+__DEVICE__ double exp(double);
+__DEVICE__ float exp(float);
 __DEVICE__ double expm1(double);
+__DEVICE__ float expm1(float);
 __DEVICE__ double fabs(double);
-__DEVICE__ float fdim(float, float);
+__DEVICE__ float fabs(float);
 __DEVICE__ double fdim(double, double);
+__DEVICE__ float fdim(float, float);
 __DEVICE__ double floor(double);
-__DEVICE__ float fma(float, float, float);
+__DEVICE__ float floor(float);
 __DEVICE__ double fma(double, double, double);
-__DEVICE__ float fmax(float, float);
+__DEVICE__ float fma(float, float, float);
 __DEVICE__ double fmax(double, double);
-__DEVICE__ float fmin(float, float);
+__DEVICE__ float fmax(float, float);
 __DEVICE__ double fmin(double, double);
+__DEVICE__ float fmin(float, float);
 __DEVICE__ double fmod(double, double);
+__DEVICE__ float fmod(float, float);
+__DEVICE__ int fpclassify(double);
+__DEVICE__ int fpclassify(float);
 __DEVICE__ double frexp(double, int *);
-__DEVICE__ float hypot(float, float);
+__DEVICE__ float frexp(float, int *);
 __DEVICE__ double hypot(double, double);
-__DEVICE__ int ilogb(float);
+__DEVICE__ float hypot(float, float);
 __DEVICE__ int ilogb(double);
+__DEVICE__ int ilogb(float);
+__DEVICE__ bool isfinite(double);
+__DEVICE__ bool isfinite(float);
+__DEVICE__ bool isgreater(double, double);
+__DEVICE__ bool isgreaterequal(double, double);
+__DEVICE__ bool isgreaterequal(float, float);
+__DEVICE__ bool isgreater(float, float);
+__DEVICE__ bool isinf(double);
+__DEVICE__ bool isinf(float);
+__DEVICE__ bool isless(

Re: [PATCH] D18882: [CUDA] Tweak math forward declares so we're compatible with libstdc++4.9.

2016-04-07 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265751: [CUDA] Tweak math forward declares so we're 
compatible with libstdc++4.9. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D18882?vs=52979&id=52980#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18882

Files:
  cfe/trunk/lib/Headers/__clang_cuda_cmath.h
  cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
  cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h
@@ -26,54 +26,39 @@
 #error "This file is for CUDA compilation only."
 #endif
 
-// CUDA allows using math functions form std:: on device side.  This
-// file provides __device__ overloads for math functions that map to
-// appropriate math functions provided by CUDA headers or to compiler
-// builtins if CUDA does not provide a suitable function.
+// CUDA lets us use various std math functions on the device side.  This file
+// works in concert with __clang_cuda_math_forward_declares.h to make this work.
+//
+// Specifically, the forward-declares header declares __device__ overloads for
+// these functions in the global namespace, then pulls them into namespace std
+// with 'using' statements.  Then this file implements those functions, after
+// the implementations have been pulled in.
+//
+// It's important that we declare the functions in the global namespace and pull
+// them into namespace std with using statements, as opposed to simply declaring
+// these functions in namespace std, because our device functions need to
+// overload the standard library functions, which may be declared in the global
+// namespace or in std, depending on the degree of conformance of the stdlib
+// implementation.  Declaring in the global namespace and pulling into namespace
+// std covers all of the known knowns.
 
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
 
-namespace std {
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
-using ::abs;
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
-using ::acos;
-using ::acosh;
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
-using ::asin;
-using ::asinh;
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }
-using ::atan;
 __DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); }
-using ::atan2;
-using ::atanh;
-using ::cbrt;
 __DEVICE__ float ceil(float __x) { return ::ceilf(__x); }
-using ::ceil;
-using ::copysign;
 __DEVICE__ float cos(float __x) { return ::cosf(__x); }
-using ::cos;
 __DEVICE__ float cosh(float __x) { return ::coshf(__x); }
-using ::cosh;
-using ::erf;
-using ::erfc;
 __DEVICE__ float exp(float __x) { return ::expf(__x); }
-using ::exp;
-using ::exp2;
-using ::expm1;
 __DEVICE__ float fabs(float __x) { return ::fabsf(__x); }
-using ::fabs;
-using ::fdim;
 __DEVICE__ float floor(float __x) { return ::floorf(__x); }
-using ::floor;
-using ::fma;
-using ::fmax;
-using ::fmin;
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
-using ::fmod;
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
@@ -85,9 +70,8 @@
 __DEVICE__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
-using ::frexp;
-using ::hypot;
-using ::ilogb;
+__DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
+__DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
 __DEVICE__ bool isfinite(double __x) { return ::__finite(__x); }
 __DEVICE__ bool isgreater(float __x, float __y) {
@@ -102,8 +86,6 @@
 __DEVICE__ bool isgreaterequal(double __x, double __y) {
   return __builtin_isgreaterequal(__x, __y);
 }
-__DEVICE__ bool isinf(float __x) { return ::__isinff(__x); }
-__DEVICE__ bool isinf(double __x) { return ::__isinf(__x); }
 __DEVICE__ bool isless(float __x, float __y) {
   return __builtin_isless(__x, __y);
 }
@@ -132,36 +114,18 @@
 __DEVICE__ bool isunordered(double __x, double __y) {
   return __builtin_isunordered(__x, __y);
 }
-using ::labs;
 __DEVICE__ float ldexp(float __arg, int __exp) {
   return ::ldexpf(__arg, __exp);
 }
-using ::ldexp;
-using ::lgamma;
-using ::llabs;
-using ::llrint;
 __DEVICE__ float log(float __x) { return ::logf(__x); }
-using ::log;
 __DEVICE__ float log10(float __x) { return ::log10f(__x); }
-using ::log10;
-using ::log1p;
-using ::log2;
-using ::logb;
-using ::lrint;
-using ::lround;
 __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr);

  1   2   >