[libcxx] r268009 - Fix PR21428 for long. Buffer was one byte too small in octal formatting case. Rename previously added test

2016-04-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Apr 29 02:23:20 2016
New Revision: 268009

URL: http://llvm.org/viewvc/llvm-project?rev=268009&view=rev
Log:
Fix PR21428 for long. Buffer was one byte too small in octal formatting case. 
Rename previously added test

Added:

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
Removed:

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
Modified:
libcxx/trunk/include/locale

Modified: libcxx/trunk/include/locale
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=268009&r1=268008&r2=268009&view=diff
==
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Fri Apr 29 02:23:20 2016
@@ -1375,7 +1375,7 @@ num_put<_CharT, _OutputIterator>::do_put
 this->__format_int(__fmt+1, __len, true, __iob.flags());
 const unsigned __nbuf = (numeric_limits::digits / 3)
   + ((numeric_limits::digits % 3) != 0)
-  + 1;
+  + 2;
 char __nar[__nbuf];
 int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, 
__fmt, __v);
 char* __ne = __nar + __nc;

Removed: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass?rev=268008&view=auto
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass
 (removed)
@@ -1,85 +0,0 @@
-//===--===//
-//
-// 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.
-//
-//===--===//
-
-// 
-
-// template  >
-//   class basic_ostream;
-
-// operator<<( int16_t val);
-// operator<<(uint16_t val);
-// operator<<( int32_t val);
-// operator<<(uint32_t val);
-// operator<<( int64_t val);
-// operator<<(uint64_t val);
-
-//  Testing to make sure that the max length values are correctly inserted
-
-#include 
-#include 
-#include 
-#include 
-
-template 
-void test_octal(const char *expected)
-{
-std::stringstream ss;
-ss << std::oct << static_cast(-1);
-
-assert(ss.str() == expected);
-}
-
-template 
-void test_dec(const char *expected)
-{
-std::stringstream ss;
-ss << std::dec << static_cast(-1);
-
-//  std::cout << ss.str() << " " << expected << std::endl;
-assert(ss.str() == expected);
-}
-
-template 
-void test_hex(const char *expected)
-{
-std::stringstream ss;
-ss << std::hex << static_cast(-1);
-
-std::string str = ss.str();
-for (size_t i = 0; i < str.size(); ++i )
-str[i] = std::toupper(str[i]);
-
-assert(str == expected);
-}
-
-int main(int argc, char* argv[])
-{
-test_octal("17");
-test_octal< int16_t>("17");
-test_octal(   "377");
-test_octal< int32_t>(   "377");
-test_octal("17");
-test_octal< int64_t>("17");
-
-test_dec(   "65535");
-test_dec< int16_t>(  "-1");
-test_dec(  "4294967295");
-test_dec< int32_t>(  "-1");
-test_dec("18446744073709551615");
-test_dec< int64_t>(  "-1");
-
-test_hex("");
-test_hex< int16_t>("");
-test_hex("");
-test_hex< int32_t>("");
-test_hex("");
-test_hex< int64_t>("");
-
-return 0;
-}

Added: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp?rev=268009&view=auto
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
 F

r268013 - [Clang][AVX512][Builtin] Adding intrinsics for compress instruction set

2016-04-29 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Fri Apr 29 03:52:02 2016
New Revision: 268013

URL: http://llvm.org/viewvc/llvm-project?rev=268013&view=rev
Log:
[Clang][AVX512][Builtin] Adding intrinsics for compress instruction set

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


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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268013&r1=268012&r2=268013&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Apr 29 03:52:02 2016
@@ -2218,6 +2218,10 @@ TARGET_BUILTIN(__builtin_ia32_dbpsadbw12
 TARGET_BUILTIN(__builtin_ia32_dbpsadbw256_mask, 
"V16sV32cV32cIiV16sUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_dbpsadbw512_mask, 
"V32sV64cV64cIiV32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psadbw512, "V8LLiV64cV64c","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_compressdf512_mask, "V8dV8dV8dUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_compressdi512_mask, 
"V8LLiV8LLiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_compresssf512_mask, 
"V16fV16fV16fUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_compresssi512_mask, 
"V16iV16iV16iUs","","avx512f")
 
 
 #undef BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268013&r1=268012&r2=268013&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Apr 29 03:52:02 2016
@@ -7561,6 +7561,74 @@ _mm512_stream_ps (float *__P, __m512 __A
   __builtin_ia32_movntps512 (__P, (__v16sf) __A);
 }
 
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_mask_compress_pd (__m512d __W, __mmask8 __U, __m512d __A)
+{
+  return (__m512d) __builtin_ia32_compressdf512_mask ((__v8df) __A,
+  (__v8df) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_maskz_compress_pd (__mmask8 __U, __m512d __A)
+{
+  return (__m512d) __builtin_ia32_compressdf512_mask ((__v8df) __A,
+  (__v8df)
+  _mm512_setzero_pd (),
+  (__mmask8) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_compress_epi64 (__m512i __W, __mmask8 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_compressdi512_mask ((__v8di) __A,
+  (__v8di) __W,
+  (__mmask8) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_compress_epi64 (__mmask8 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_compressdi512_mask ((__v8di) __A,
+  (__v8di)
+  _mm512_setzero_si512 (),
+  (__mmask8) __U);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_mask_compress_ps (__m512 __W, __mmask16 __U, __m512 __A)
+{
+  return (__m512) __builtin_ia32_compresssf512_mask ((__v16sf) __A,
+ (__v16sf) __W,
+ (__mmask16) __U);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_maskz_compress_ps (__mmask16 __U, __m512 __A)
+{
+  return (__m512) __builtin_ia32_compresssf512_mask ((__v16sf) __A,
+ (__v16sf)
+ _mm512_setzero_ps (),
+ (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_compress_epi32 (__m512i __W, __mmask16 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_compresssi512_mask ((__v16si) __A,
+  (__v16si) __W,
+  (__mmask16) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_compress_epi32 (__mmask16 __U, __m512i __A)
+{
+  return (__m512i) __builtin_ia32_compresssi512_mask ((__v16si) __A,
+  (__v16si)
+  _mm512_setzero_si512 (),
+  (__mmask16) __U);
+}
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif // __AVX512FINTRIN_H

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268013&r1=268012&r2=268013&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Fri Apr 29 03:52:02 2016
@@ -5238,3 +5238,50 @@ void test_mm512_stream_ps(float *__P, __
   _mm512_stream_ps(__P, __A); 
 }
 
+__m512d test_mm512_mask_compress_pd(__m512d __W, __mmask8 __U, __m512d __A) {
+  // CHECK-LABEL: @test_mm512_mask_compress_pd
+  // CHECK: @llvm.x86.avx512.mask.compress.pd.512
+  return _mm512_mask_compress_pd(__W, __U, __A); 
+}
+
+__m512d test_mm512_maskz_compress_pd(__mmask8 __U, __m512d __A

[clang-tools-extra] r268017 - [include-fixer] Add Yaml database integration.

2016-04-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Apr 29 04:23:38 2016
New Revision: 268017

URL: http://llvm.org/viewvc/llvm-project?rev=268017&view=rev
Log:
[include-fixer] Add Yaml database integration.

Reviewers: bkramer

Subscribers: cfe-commits, klimek, djasper

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

Added:
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
clang-tools-extra/trunk/test/include-fixer/Inputs/
clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
clang-tools-extra/trunk/test/include-fixer/yamldb.cpp
Modified:
clang-tools-extra/trunk/include-fixer/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/CMakeLists.txt?rev=268017&r1=268016&r2=268017&view=diff
==
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt Fri Apr 29 04:23:38 
2016
@@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
 add_clang_library(clangIncludeFixer
   IncludeFixer.cpp
   InMemoryXrefsDB.cpp
+  YamlXrefsDB.cpp
 
   LINK_LIBS
   clangAST
@@ -15,6 +16,7 @@ add_clang_library(clangIncludeFixer
   clangSema
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
 
 add_subdirectory(tool)

Added: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp?rev=268017&view=auto
==
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp (added)
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp Fri Apr 29 04:23:38 
2016
@@ -0,0 +1,64 @@
+//===-- YamlXrefsDB.cpp 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "YamlXrefsDB.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+#include 
+
+namespace clang {
+namespace include_fixer {
+
+YamlXrefsDB::YamlXrefsDB(llvm::StringRef FilePath) {
+  int ReadFD = 0;
+  if (llvm::sys::fs::openFileForRead(FilePath, ReadFD))
+return;
+  auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, FilePath, -1);
+  if (!Buffer)
+return;
+  Symbols = clang::find_all_symbols::ReadSymbolInfosFromYAML(
+  Buffer.get()->getBuffer());
+}
+
+std::vector YamlXrefsDB::search(llvm::StringRef Identifier) {
+  llvm::SmallVector Names;
+  std::vector Results;
+
+  // The identifier may be fully qualified, so split it and get all the context
+  // names.
+  Identifier.split(Names, "::");
+  for (const auto &Symbol : Symbols) {
+// Match the identifier name without qualifier.
+if (Symbol.Name == Names.back()) {
+  bool IsMatched = true;
+  auto SymbolContext = Symbol.Contexts.begin();
+  // Match the remaining context names.
+  for (auto IdentiferContext = Names.rbegin() + 1;
+   IdentiferContext != Names.rend() &&
+   SymbolContext != Symbol.Contexts.end();
+   ++IdentiferContext, ++SymbolContext) {
+if (SymbolContext->second != *IdentiferContext) {
+  IsMatched = false;
+  break;
+}
+  }
+
+  if (IsMatched) {
+Results.push_back("\"" + Symbol.FilePath + "\"");
+  }
+}
+  }
+  return Results;
+}
+
+} // namespace include_fixer
+} // namespace clang

Added: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h?rev=268017&view=auto
==
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h (added)
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h Fri Apr 29 04:23:38 2016
@@ -0,0 +1,35 @@
+//===-- YamlXrefsDB.h ---*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
+
+#include "XrefsDB.h"
+#include "find-all-symbols/SymbolInfo.h"
+#include 
+#include 
+
+namespace clang {
+namespace include_fixer {
+
+/// Yaml format database.
+class YamlXrefsDB : public XrefsDB {
+public:
+  YamlXrefsDB(llvm::StringRef FilePath);
+
+  st

Re: [PATCH] D19648: [include-fixer] Add Yaml database integration.

2016-04-29 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268017: [include-fixer] Add Yaml database integration. 
(authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19648?vs=55412&id=3#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19648

Files:
  clang-tools-extra/trunk/include-fixer/CMakeLists.txt
  clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
  clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
  clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
  clang-tools-extra/trunk/test/include-fixer/Inputs/fake_yaml_db.yaml
  clang-tools-extra/trunk/test/include-fixer/yamldb.cpp

Index: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
===
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
@@ -0,0 +1,64 @@
+//===-- YamlXrefsDB.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "YamlXrefsDB.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include 
+#include 
+
+namespace clang {
+namespace include_fixer {
+
+YamlXrefsDB::YamlXrefsDB(llvm::StringRef FilePath) {
+  int ReadFD = 0;
+  if (llvm::sys::fs::openFileForRead(FilePath, ReadFD))
+return;
+  auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, FilePath, -1);
+  if (!Buffer)
+return;
+  Symbols = clang::find_all_symbols::ReadSymbolInfosFromYAML(
+  Buffer.get()->getBuffer());
+}
+
+std::vector YamlXrefsDB::search(llvm::StringRef Identifier) {
+  llvm::SmallVector Names;
+  std::vector Results;
+
+  // The identifier may be fully qualified, so split it and get all the context
+  // names.
+  Identifier.split(Names, "::");
+  for (const auto &Symbol : Symbols) {
+// Match the identifier name without qualifier.
+if (Symbol.Name == Names.back()) {
+  bool IsMatched = true;
+  auto SymbolContext = Symbol.Contexts.begin();
+  // Match the remaining context names.
+  for (auto IdentiferContext = Names.rbegin() + 1;
+   IdentiferContext != Names.rend() &&
+   SymbolContext != Symbol.Contexts.end();
+   ++IdentiferContext, ++SymbolContext) {
+if (SymbolContext->second != *IdentiferContext) {
+  IsMatched = false;
+  break;
+}
+  }
+
+  if (IsMatched) {
+Results.push_back("\"" + Symbol.FilePath + "\"");
+  }
+}
+  }
+  return Results;
+}
+
+} // namespace include_fixer
+} // namespace clang
Index: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
===
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
@@ -9,24 +9,29 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "YamlXrefsDB.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
+
 using namespace clang;
 using namespace llvm;
 
 namespace {
 cl::OptionCategory IncludeFixerCategory("Tool options");
 
 enum DatabaseFormatTy {
   fixed, ///< Hard-coded mapping.
+  yaml,  ///< Yaml database created by find-all-symbols.
 };
 
 cl::opt DatabaseFormat(
 "db", cl::desc("Specify input format"),
-cl::values(clEnumVal(fixed, "Hard-coded mapping"), clEnumValEnd),
+cl::values(clEnumVal(fixed, "Hard-coded mapping"),
+   clEnumVal(yaml, "Yaml database created by find-all-symbols"),
+   clEnumValEnd),
 cl::init(fixed), cl::cat(IncludeFixerCategory));
 
 cl::opt Input("input",
@@ -67,6 +72,10 @@
 llvm::make_unique(std::move(XrefsMap));
 break;
   }
+  case yaml: {
+XrefsDB = llvm::make_unique(Input);
+break;
+  }
   }
 
   // Now run our tool.
Index: clang-tools-extra/trunk/include-fixer/CMakeLists.txt
===
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt
@@ -5,6 +5,7 @@
 add_clang_library(clangIncludeFixer
   IncludeFixer.cpp
   InMemoryXrefsDB.cpp
+  YamlXrefsDB.cpp
 
   LINK_LIBS
   clangAST
@@ -15,6 +16,7 @@
   clangSema
   clangTooling
   clangToolingCore
+  findAllSymbols
   )
 
 add_subdirectory(tool)
Index: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
===
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
+++ clang-tools-extra/trun

r268018 - Implementation of VlA of GNU C++ extension, by Vladimir Yakovlev.

2016-04-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr 29 04:39:50 2016
New Revision: 268018

URL: http://llvm.org/viewvc/llvm-project?rev=268018&view=rev
Log:
Implementation of VlA of GNU C++ extension, by Vladimir Yakovlev.

This enables GNU C++ extension "Variable length array" by default.
Differential Revision: http://reviews.llvm.org/D18823

Added:
cfe/trunk/test/CodeGenCXX/vla-consruct.cpp
cfe/trunk/test/SemaCXX/vla-consruct.cpp
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/c99-variable-length-array-cxx11.cpp
cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=268018&r1=268017&r2=268018&view=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Apr 29 04:39:50 2016
@@ -1915,7 +1915,7 @@ void CodeGenFunction::EnterDtorCleanups(
 /// \param zeroInitialize true if each element should be
 ///   zero-initialized before it is constructed
 void CodeGenFunction::EmitCXXAggrConstructorCall(
-const CXXConstructorDecl *ctor, const ConstantArrayType *arrayType,
+const CXXConstructorDecl *ctor, const ArrayType *arrayType,
 Address arrayBegin, const CXXConstructExpr *E, bool zeroInitialize) {
   QualType elementType;
   llvm::Value *numElements =

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=268018&r1=268017&r2=268018&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Fri Apr 29 04:39:50 2016
@@ -472,8 +472,8 @@ CodeGenFunction::EmitCXXConstructExpr(co
 }
   }
   
-  if (const ConstantArrayType *arrayType 
-= getContext().getAsConstantArrayType(E->getType())) {
+  if (const ArrayType *arrayType
+= getContext().getAsArrayType(E->getType())) {
 EmitCXXAggrConstructorCall(CD, arrayType, Dest.getAddress(), E);
   } else {
 CXXCtorType Type = Ctor_Complete;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=268018&r1=268017&r2=268018&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Apr 29 04:39:50 2016
@@ -1879,7 +1879,7 @@ public:
   const CXXConstructExpr *E);
 
   void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
-  const ConstantArrayType *ArrayTy,
+  const ArrayType *ArrayTy,
   Address ArrayPtr,
   const CXXConstructExpr *E,
   bool ZeroInitialization = false);

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=268018&r1=268017&r2=268018&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Apr 29 04:39:50 2016
@@ -2234,15 +2234,8 @@ QualType Sema::BuildArrayType(QualType T
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
   if (!getLangOpts().C99) {
 if (T->isVariableArrayType()) {
-  // Prohibit the use of non-POD types in VLAs.
-  QualType BaseT = Context.getBaseElementType(T);
-  if (!T->isDependentType() && isCompleteType(Loc, BaseT) &&
-  !BaseT.isPODType(Context) && !BaseT->isObjCLifetimeType()) {
-Diag(Loc, diag::err_vla_non_pod) << BaseT;
-return QualType();
-  }
   // Prohibit the use of VLAs during template argument deduction.
-  else if (isSFINAEContext()) {
+  if (isSFINAEContext()) {
 Diag(Loc, diag::err_vla_in_sfinae);
 return QualType();
   }

Added: cfe/trunk/test/CodeGenCXX/vla-consruct.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vla-consruct.cpp?rev=268018&view=auto
==
--- cfe/trunk/test/CodeGenCXX/vla-consruct.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/vla-consruct.cpp Fri Apr 29 04:39:50 2016
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions -O0 %s -emit-llvm -o - | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+
+static int N;
+struct S {
+  S()
+  __attribute__((nothrow)) { printf("%d: S()\n", ++N); }
+  ~S() __attribute__((nothrow)) { printf("%d: ~S()\n", N--); }
+  int n[17];
+};
+// C

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

2016-04-29 Thread Alexey Bataev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268018: Implementation of VlA of GNU C++ extension, by 
Vladimir Yakovlev. (authored by ABataev).

Changed prior to commit:
  http://reviews.llvm.org/D18823?vs=53658&id=4#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18823

Files:
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/lib/CodeGen/CGExprCXX.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGenCXX/vla-consruct.cpp
  cfe/trunk/test/SemaCXX/c99-variable-length-array-cxx11.cpp
  cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
  cfe/trunk/test/SemaCXX/vla-consruct.cpp

Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -2234,15 +2234,8 @@
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
   if (!getLangOpts().C99) {
 if (T->isVariableArrayType()) {
-  // Prohibit the use of non-POD types in VLAs.
-  QualType BaseT = Context.getBaseElementType(T);
-  if (!T->isDependentType() && isCompleteType(Loc, BaseT) &&
-  !BaseT.isPODType(Context) && !BaseT->isObjCLifetimeType()) {
-Diag(Loc, diag::err_vla_non_pod) << BaseT;
-return QualType();
-  }
   // Prohibit the use of VLAs during template argument deduction.
-  else if (isSFINAEContext()) {
+  if (isSFINAEContext()) {
 Diag(Loc, diag::err_vla_in_sfinae);
 return QualType();
   }
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -1879,7 +1879,7 @@
   const CXXConstructExpr *E);
 
   void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
-  const ConstantArrayType *ArrayTy,
+  const ArrayType *ArrayTy,
   Address ArrayPtr,
   const CXXConstructExpr *E,
   bool ZeroInitialization = false);
Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -1915,7 +1915,7 @@
 /// \param zeroInitialize true if each element should be
 ///   zero-initialized before it is constructed
 void CodeGenFunction::EmitCXXAggrConstructorCall(
-const CXXConstructorDecl *ctor, const ConstantArrayType *arrayType,
+const CXXConstructorDecl *ctor, const ArrayType *arrayType,
 Address arrayBegin, const CXXConstructExpr *E, bool zeroInitialize) {
   QualType elementType;
   llvm::Value *numElements =
Index: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp
@@ -472,8 +472,8 @@
 }
   }
   
-  if (const ConstantArrayType *arrayType 
-= getContext().getAsConstantArrayType(E->getType())) {
+  if (const ArrayType *arrayType
+= getContext().getAsArrayType(E->getType())) {
 EmitCXXAggrConstructorCall(CD, arrayType, Dest.getAddress(), E);
   } else {
 CXXCtorType Type = Ctor_Complete;
Index: cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
===
--- cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
+++ cfe/trunk/test/SemaCXX/c99-variable-length-array.cpp
@@ -16,8 +16,8 @@
 void vla(int N) {
   int array1[N]; // expected-warning{{variable length arrays are a C99 feature}}
   POD array2[N]; // expected-warning{{variable length arrays are a C99 feature}}
-  NonPOD array3[N]; // expected-error{{variable length array of non-POD element type 'NonPOD'}}
-  NonPOD2 array4[N][3]; // expected-error{{variable length array of non-POD element type 'NonPOD2'}}
+  NonPOD array3[N]; // expected-warning{{variable length arrays are a C99 feature}}
+  NonPOD2 array4[N][3]; // expected-warning{{variable length arrays are a C99 feature}}
 }
 
 /// Warn about VLAs in templates.
Index: cfe/trunk/test/SemaCXX/vla-consruct.cpp
===
--- cfe/trunk/test/SemaCXX/vla-consruct.cpp
+++ cfe/trunk/test/SemaCXX/vla-consruct.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -O0 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -pedantic-errors -DPE -O0 -verify %s
+
+# ifndef PE
+// expected-no-diagnostics
+# endif
+
+extern "C" int printf(const char*, ...);
+
+static int N;
+struct S {
+  S() __attribute__ ((nothrow))  { printf("%d: S()\n", ++N); }
+  ~S()  __attribute__ ((nothrow))  { printf("%d: ~S()\n", N--); }
+  int n[

[clang-tools-extra] r268019 - [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.

2016-04-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Apr 29 04:45:09 2016
New Revision: 268019

URL: http://llvm.org/viewvc/llvm-project?rev=268019&view=rev
Log:
[find-all-symbols] Save absolute file path instead of relative file path in 
SymbolInfo.

Reviewers: bkramer

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=268019&r1=268018&r2=268019&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp 
Fri Apr 29 04:45:09 2016
@@ -16,6 +16,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
@@ -47,19 +48,37 @@ bool SetCommonInfo(const MatchFinder::Ma
   SetContext(ND, Symbol);
 
   Symbol->Name = ND->getNameAsString();
-  SourceLocation Loc = 
Result.SourceManager->getExpansionLoc(ND->getLocation());
+
+  const SourceManager *SM = Result.SourceManager;
+  SourceLocation Loc = SM->getExpansionLoc(ND->getLocation());
   if (!Loc.isValid()) {
 llvm::errs() << "Declaration " << ND->getNameAsString() << "("
  << ND->getDeclKindName()
  << ") has invalid declaration location.";
 return false;
   }
-  std::string FilePath = Result.SourceManager->getFilename(Loc).str();
+
+  Symbol->LineNumber = SM->getExpansionLineNumber(Loc);
+
+  llvm::StringRef FilePath = SM->getFilename(Loc);
   if (FilePath.empty())
 return false;
 
-  Symbol->FilePath = FilePath;
-  Symbol->LineNumber = Result.SourceManager->getExpansionLineNumber(Loc);
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(FilePath)) {
+AbsolutePath = FilePath;
+  } else {
+auto WorkingDir = SM->getFileManager()
+  .getVirtualFileSystem()
+  ->getCurrentWorkingDirectory();
+if (!WorkingDir)
+  return false;
+AbsolutePath = *WorkingDir;
+llvm::sys::path::append(AbsolutePath, FilePath);
+  }
+
+  llvm::sys::path::remove_dots(AbsolutePath, true);
+  Symbol->FilePath = AbsolutePath.str();
   return true;
 }
 } // namespace


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


Re: [PATCH] D15654: A Python code model for C++ used to drive code generators

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

I'm abandoning this revision for lack of interest.


http://reviews.llvm.org/D15654



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


Re: [PATCH] D19665: [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

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

Don't change the AArch64 intrinsics and move the test to Sema.


http://reviews.llvm.org/D19665

Files:
  include/clang/Basic/arm_neon.td
  test/Sema/arm-no-fp16.c

Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -704,8 +704,10 @@
 

 // E.3.22 Converting vectors
 
-def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+  def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+}
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;
Index: test/Sema/arm-no-fp16.c
===
--- /dev/null
+++ test/Sema/arm-no-fp16.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon 
-target-feature -fp16 -fsyntax-only -verify
+
+#include 
+
+float16x4_t test_vcvt_f16_f32(float32x4_t a) {
+  return vcvt_f16_f32(a); // expected-warning{{implicit declaration of 
function 'vcvt_f16_f32'}}  expected-error{{returning 'int' from a function with 
incompatible result type 'float16x4_t'}}
+}
+
+float32x4_t test_vcvt_f32_f16(float16x4_t a) {
+  return vcvt_f32_f16(a); // expected-warning{{implicit declaration of 
function 'vcvt_f32_f16'}} expected-error{{returning 'int' from a function with 
incompatible result type 'float32x4_t'}}
+}


Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -704,8 +704,10 @@
 
 // E.3.22 Converting vectors
 
-def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+  def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+}
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;
Index: test/Sema/arm-no-fp16.c
===
--- /dev/null
+++ test/Sema/arm-no-fp16.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon -target-feature -fp16 -fsyntax-only -verify
+
+#include 
+
+float16x4_t test_vcvt_f16_f32(float32x4_t a) {
+  return vcvt_f16_f32(a); // expected-warning{{implicit declaration of function 'vcvt_f16_f32'}}  expected-error{{returning 'int' from a function with incompatible result type 'float16x4_t'}}
+}
+
+float32x4_t test_vcvt_f32_f16(float16x4_t a) {
+  return vcvt_f32_f16(a); // expected-warning{{implicit declaration of function 'vcvt_f32_f16'}} expected-error{{returning 'int' from a function with incompatible result type 'float32x4_t'}}
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19665: [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

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


Comment at: include/clang/Basic/arm_neon.td:710-711
@@ -709,2 +709,4 @@
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+}
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;

Thanks for catching this!


http://reviews.llvm.org/D19665



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


Re: [PATCH] D19647: [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.

2016-04-29 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268019: [find-all-symbols] Save absolute file path instead 
of relative file path in… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19647?vs=55398&id=6#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19647

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp

Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -16,6 +16,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
@@ -47,19 +48,37 @@
   SetContext(ND, Symbol);
 
   Symbol->Name = ND->getNameAsString();
-  SourceLocation Loc = 
Result.SourceManager->getExpansionLoc(ND->getLocation());
+
+  const SourceManager *SM = Result.SourceManager;
+  SourceLocation Loc = SM->getExpansionLoc(ND->getLocation());
   if (!Loc.isValid()) {
 llvm::errs() << "Declaration " << ND->getNameAsString() << "("
  << ND->getDeclKindName()
  << ") has invalid declaration location.";
 return false;
   }
-  std::string FilePath = Result.SourceManager->getFilename(Loc).str();
+
+  Symbol->LineNumber = SM->getExpansionLineNumber(Loc);
+
+  llvm::StringRef FilePath = SM->getFilename(Loc);
   if (FilePath.empty())
 return false;
 
-  Symbol->FilePath = FilePath;
-  Symbol->LineNumber = Result.SourceManager->getExpansionLineNumber(Loc);
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(FilePath)) {
+AbsolutePath = FilePath;
+  } else {
+auto WorkingDir = SM->getFileManager()
+  .getVirtualFileSystem()
+  ->getCurrentWorkingDirectory();
+if (!WorkingDir)
+  return false;
+AbsolutePath = *WorkingDir;
+llvm::sys::path::append(AbsolutePath, FilePath);
+  }
+
+  llvm::sys::path::remove_dots(AbsolutePath, true);
+  Symbol->FilePath = AbsolutePath.str();
   return true;
 }
 } // namespace


Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -16,6 +16,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::ast_matchers;
 
@@ -47,19 +48,37 @@
   SetContext(ND, Symbol);
 
   Symbol->Name = ND->getNameAsString();
-  SourceLocation Loc = Result.SourceManager->getExpansionLoc(ND->getLocation());
+
+  const SourceManager *SM = Result.SourceManager;
+  SourceLocation Loc = SM->getExpansionLoc(ND->getLocation());
   if (!Loc.isValid()) {
 llvm::errs() << "Declaration " << ND->getNameAsString() << "("
  << ND->getDeclKindName()
  << ") has invalid declaration location.";
 return false;
   }
-  std::string FilePath = Result.SourceManager->getFilename(Loc).str();
+
+  Symbol->LineNumber = SM->getExpansionLineNumber(Loc);
+
+  llvm::StringRef FilePath = SM->getFilename(Loc);
   if (FilePath.empty())
 return false;
 
-  Symbol->FilePath = FilePath;
-  Symbol->LineNumber = Result.SourceManager->getExpansionLineNumber(Loc);
+  llvm::SmallString<128> AbsolutePath;
+  if (llvm::sys::path::is_absolute(FilePath)) {
+AbsolutePath = FilePath;
+  } else {
+auto WorkingDir = SM->getFileManager()
+  .getVirtualFileSystem()
+  ->getCurrentWorkingDirectory();
+if (!WorkingDir)
+  return false;
+AbsolutePath = *WorkingDir;
+llvm::sys::path::append(AbsolutePath, FilePath);
+  }
+
+  llvm::sys::path::remove_dots(AbsolutePath, true);
+  Symbol->FilePath = AbsolutePath.str();
   return true;
 }
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r268020 - [OPENMP] Fix detection of explicit data-sharing attributes in templates.

2016-04-29 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr 29 04:56:11 2016
New Revision: 268020

URL: http://llvm.org/viewvc/llvm-project?rev=268020&view=rev
Log:
[OPENMP] Fix detection of explicit data-sharing attributes in templates.

Fixes a bug with analysis of data-sharing attributes in templates.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=268020&r1=268019&r2=268020&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Apr 29 04:56:11 2016
@@ -1416,6 +1416,9 @@ class DSAAttrChecker : public StmtVisito
 
 public:
   void VisitDeclRefExpr(DeclRefExpr *E) {
+if (E->isTypeDependent() || E->isValueDependent() ||
+E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
+  return;
 if (auto *VD = dyn_cast(E->getDecl())) {
   // Skip internally declared variables.
   if (VD->isLocalVarDecl() && !CS->capturesVariable(VD))
@@ -1464,6 +1467,9 @@ public:
 }
   }
   void VisitMemberExpr(MemberExpr *E) {
+if (E->isTypeDependent() || E->isValueDependent() ||
+E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
+  return;
 if (isa(E->getBase()->IgnoreParens())) {
   if (auto *FD = dyn_cast(E->getMemberDecl())) {
 auto DVar = Stack->getTopDSA(FD, false);

Modified: cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp?rev=268020&r1=268019&r2=268020&view=diff
==
--- cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp Fri Apr 29 04:56:11 
2016
@@ -7,6 +7,17 @@ bool foobool(int argc) {
   return argc;
 }
 
+template 
+struct S {
+  T b;
+  S(T a, T c) {
+#pragma omp task default(none) firstprivate(a, b)
+a = b = c; // expected-error {{variable 'c' must have explicitly specified 
data sharing attributes}}
+  }
+};
+
+S s(3, 4); // expected-note {{in instantiation of member function 
'S::S' requested here}}
+
 struct S1; // expected-note {{declared here}} expected-note{{forward 
declaration of 'S1'}}
 extern S1 a;
 class S2 {


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


Re: [PATCH] D18136: boost-use-to-string check

2016-04-29 Thread Piotr Padlewski via cfe-commits
Prazek marked 2 inline comments as done.


Comment at: clang-tidy/boost/UseToStringCheck.cpp:38
@@ +37,3 @@
+  argumentCountIs(1), unless(isInTemplateInstantiation()))
+  .bind("to_string"),
+  this);

alexfh wrote:
> clang-format?
nope, everything was formated


http://reviews.llvm.org/D18136



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


Re: [PATCH] D18274: [clang-tidy] Add boost module

2016-04-29 Thread Piotr Padlewski via cfe-commits
Prazek abandoned this revision.
Prazek added a comment.

Merged with boost-use-to-string


http://reviews.llvm.org/D18274



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


Re: [PATCH] D18136: boost-use-to-string check

2016-04-29 Thread Piotr Padlewski via cfe-commits
Prazek updated this revision to Diff 8.
Prazek marked an inline comment as done.
Prazek added a comment.

merged with boost module


http://reviews.llvm.org/D18136

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/boost/BoostTidyModule.cpp
  clang-tidy/boost/CMakeLists.txt
  clang-tidy/boost/UseToStringCheck.cpp
  clang-tidy/boost/UseToStringCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/boost-use-to-string.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/boost-use-to-string.cpp

Index: test/clang-tidy/boost-use-to-string.cpp
===
--- /dev/null
+++ test/clang-tidy/boost-use-to-string.cpp
@@ -0,0 +1,149 @@
+// RUN: %check_clang_tidy %s boost-use-to-string %t
+
+namespace std {
+
+template 
+class basic_string {};
+
+using string = basic_string;
+using wstring = basic_string;
+}
+
+namespace boost {
+template 
+T lexical_cast(const V &) {
+  return T();
+};
+}
+
+struct my_weird_type {};
+
+std::string fun(const std::string &) {}
+
+void test_to_string1() {
+
+  auto xa = boost::lexical_cast(5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::to_string instead of boost::lexical_cast [boost-use-to-string]
+  // CHECK-FIXES: auto xa = std::to_string(5);
+
+  auto z = boost::lexical_cast(42LL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::to_string {{..}}
+  // CHECK-FIXES: auto z = std::to_string(42LL);
+
+  // this should not trigger
+  fun(boost::lexical_cast(42.0));
+  auto non = boost::lexical_cast(42);
+  boost::lexical_cast("12");
+}
+
+void test_to_string2() {
+  int a;
+  long b;
+  long long c;
+  unsigned d;
+  unsigned long e;
+  unsigned long long f;
+  float g;
+  double h;
+  long double i;
+  bool j;
+
+  fun(boost::lexical_cast(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(a));
+  fun(boost::lexical_cast(b));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(b));
+  fun(boost::lexical_cast(c));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(c));
+  fun(boost::lexical_cast(d));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(d));
+  fun(boost::lexical_cast(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(e));
+  fun(boost::lexical_cast(f));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_string {{..}}
+  // CHECK-FIXES: fun(std::to_string(f));
+
+  // No change for floating numbers.
+  fun(boost::lexical_cast(g));
+  fun(boost::lexical_cast(h));
+  fun(boost::lexical_cast(i));
+  // And bool.
+  fun(boost::lexical_cast(j));
+}
+
+std::string fun(const std::wstring &) {}
+
+void test_to_wstring() {
+  int a;
+  long b;
+  long long c;
+  unsigned d;
+  unsigned long e;
+  unsigned long long f;
+  float g;
+  double h;
+  long double i;
+  bool j;
+
+  fun(boost::lexical_cast(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring instead of boost::lexical_cast [boost-use-to-string]
+  // CHECK-FIXES: fun(std::to_wstring(a));
+  fun(boost::lexical_cast(b));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(b));
+  fun(boost::lexical_cast(c));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(c));
+  fun(boost::lexical_cast(d));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(d));
+  fun(boost::lexical_cast(e));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(e));
+  fun(boost::lexical_cast(f));
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::to_wstring {{..}}
+  // CHECK-FIXES: fun(std::to_wstring(f));
+
+  // No change for floating numbers
+  fun(boost::lexical_cast(g));
+  fun(boost::lexical_cast(h));
+  fun(boost::lexical_cast(i));
+  // and bool.
+  fun(boost::lexical_cast(j));
+}
+
+const auto glob = boost::lexical_cast(42);
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use std::to_string{{..}}
+// CHECK-FIXES: const auto glob = std::to_string(42);
+
+template 
+void string_as_T(T t = T()) {
+  boost::lexical_cast(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use std::to_string{{..}}
+  // CHECK-FIXES: std::to_string(42);
+
+  boost::lexical_cast(42);
+  string_as_T(boost::lexical_cast(42));
+  auto p = boost::lexical_cast(42);
+  auto p2 = (T)boost::lexical_cast(42);
+  auto p3 = static_cast(boost::lexical_cast(42));
+}
+
+#define my_to_string boost::lexical_cast
+
+void no_fixup_inside_macro() {
+  my_to_string(12);
+  // CHECK-MESSAGES: :[[@LINE-1]

[PATCH] D19717: [find-all-symbols] Fix racy yaml file writing.

2016-04-29 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added a reviewer: hokein.
bkramer added a subscriber: cfe-commits.

If multiple find-all-symbols processes access the temporary directory
simultaneously with two files with the same name they would collide and
create a broken yaml file. Fix this by using the safe createUniqueFile
API from LLVM instead.

http://reviews.llvm.org/D19717

Files:
  include-fixer/find-all-symbols/SymbolInfo.cpp
  include-fixer/find-all-symbols/SymbolInfo.h
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -59,10 +59,13 @@
 
   void Write(const std::string &Dir) {
 for (const auto &Symbol : Symbols) {
-  SmallString<256> FilePath(Dir);
-  llvm::sys::path::append(
-  FilePath, llvm::sys::path::filename(Symbol.first) + ".yaml");
-  WriteSymboInfosToFile(FilePath, Symbol.second);
+  int FD;
+  SmallString<128> ResultPath;
+  llvm::sys::fs::createUniqueFile(
+  Dir + "/" + llvm::sys::path::filename(Symbol.first) + "-%%.yaml",
+  FD, ResultPath);
+  llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
+  WriteSymbolInfosToFile(OS, Symbol.second);
 }
   }
 
@@ -90,7 +93,13 @@
   UniqueSymbols.insert(Symbol);
   }
 
-  WriteSymboInfosToFile(OutputFile, UniqueSymbols);
+  llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+ << '\n';
+return false;
+  }
+  WriteSymbolInfosToFile(OS, UniqueSymbols);
   return true;
 }
 
Index: include-fixer/find-all-symbols/SymbolInfo.h
===
--- include-fixer/find-all-symbols/SymbolInfo.h
+++ include-fixer/find-all-symbols/SymbolInfo.h
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -87,9 +88,9 @@
   bool operator<(const SymbolInfo &Symbol) const;
 };
 
-/// \brief Write SymbolInfos to a single file (YAML format).
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols);
+/// \brief Write SymbolInfos to a stream (YAML format).
+bool WriteSymbolInfosToFile(llvm::raw_ostream &OS,
+const std::set &Symbols);
 
 /// \brief Read SymbolInfos from a YAML document.
 std::vector ReadSymbolInfosFromYAML(llvm::StringRef Yaml);
Index: include-fixer/find-all-symbols/SymbolInfo.cpp
===
--- include-fixer/find-all-symbols/SymbolInfo.cpp
+++ include-fixer/find-all-symbols/SymbolInfo.cpp
@@ -97,16 +97,11 @@
  std::tie(Symbol.Name, Symbol.FilePath, Symbol.LineNumber);
 }
 
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols) {
-  int FD = 0;
-  if (llvm::sys::fs::openFileForWrite(FilePath, FD, llvm::sys::fs::F_None))
-return false;
-  llvm::raw_fd_ostream OS(FD, true);
+bool WriteSymbolInfosToFile(llvm::raw_ostream &OS,
+const std::set &Symbols) {
   llvm::yaml::Output yout(OS);
   for (auto Symbol : Symbols)
 yout << Symbol;
-  OS.close();
   return true;
 }
 


Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -59,10 +59,13 @@
 
   void Write(const std::string &Dir) {
 for (const auto &Symbol : Symbols) {
-  SmallString<256> FilePath(Dir);
-  llvm::sys::path::append(
-  FilePath, llvm::sys::path::filename(Symbol.first) + ".yaml");
-  WriteSymboInfosToFile(FilePath, Symbol.second);
+  int FD;
+  SmallString<128> ResultPath;
+  llvm::sys::fs::createUniqueFile(
+  Dir + "/" + llvm::sys::path::filename(Symbol.first) + "-%%.yaml",
+  FD, ResultPath);
+  llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
+  WriteSymbolInfosToFile(OS, Symbol.second);
 }
   }
 
@@ -90,7 +93,13 @@
   UniqueSymbols.insert(Symbol);
   }
 
-  WriteSymboInfosToFile(OutputFile, UniqueSymbols);
+  llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+ << '\n';
+return false;
+  }
+  WriteSymbolInfosToFile(OS, UniqueSymbols);
   return true;
 }
 
Index: include-fixer/find-all-symbols/SymbolInfo.h
===
--- include-fixer/find-all-symbols/SymbolInfo.h
+++ include-fixer/find-all-symbols/SymbolInfo.

Re: [PATCH] D19622: [libc++] Implement the member functions of a local struct.

2016-04-29 Thread Sebastian Redl via cfe-commits



On 28.04.2016 04:25, Eric Fiselier via cfe-commits wrote:

EricWF closed this revision.
EricWF added a comment.

r267843. This warning seems a bit silly though.

And here I thought this warning was gone after VS 2008, given that its 
dedicated warning page was removed.


But it's apparently still in the list:
https://msdn.microsoft.com/en-us/library/mt656776.aspx

I rail against this warning here:
http://stackoverflow.com/questions/18979503/why-locally-defined-struct-in-function-need-assignment-operator-copy-construct/18979812#18979812

It's not just that the warning is silly, it's also a level 1 warning, 
which is extra-silly. (MSVC's silly warnings are usually level 4.)


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


Re: [PATCH] D19717: [find-all-symbols] Fix racy yaml file writing.

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

Thanks! LGTM with one nit.



Comment at: include-fixer/find-all-symbols/SymbolInfo.h:92
@@ +91,3 @@
+/// \brief Write SymbolInfos to a stream (YAML format).
+bool WriteSymbolInfosToFile(llvm::raw_ostream &OS,
+const std::set &Symbols);

It would be better to change the function name to WriteSymbolInfosToStream.


http://reviews.llvm.org/D19717



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


[clang-tools-extra] r268021 - [find-all-symbols] Fix racy yaml file writing.

2016-04-29 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Apr 29 05:16:28 2016
New Revision: 268021

URL: http://llvm.org/viewvc/llvm-project?rev=268021&view=rev
Log:
[find-all-symbols] Fix racy yaml file writing.

If multiple find-all-symbols processes access the temporary directory
simultaneously with two files with the same name they would collide and
create a broken yaml file. Fix this by using the safe createUniqueFile
API from LLVM instead.

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

Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp?rev=268021&r1=268020&r2=268021&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp Fri 
Apr 29 05:16:28 2016
@@ -97,16 +97,11 @@ bool SymbolInfo::operator<(const SymbolI
  std::tie(Symbol.Name, Symbol.FilePath, Symbol.LineNumber);
 }
 
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols) {
-  int FD = 0;
-  if (llvm::sys::fs::openFileForWrite(FilePath, FD, llvm::sys::fs::F_None))
-return false;
-  llvm::raw_fd_ostream OS(FD, true);
+bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
+  const std::set &Symbols) {
   llvm::yaml::Output yout(OS);
   for (auto Symbol : Symbols)
 yout << Symbol;
-  OS.close();
   return true;
 }
 

Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=268021&r1=268020&r2=268021&view=diff
==
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h 
(original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Fri Apr 
29 05:16:28 2016
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -87,9 +88,9 @@ struct SymbolInfo {
   bool operator<(const SymbolInfo &Symbol) const;
 };
 
-/// \brief Write SymbolInfos to a single file (YAML format).
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols);
+/// \brief Write SymbolInfos to a stream (YAML format).
+bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
+  const std::set &Symbols);
 
 /// \brief Read SymbolInfos from a YAML document.
 std::vector ReadSymbolInfosFromYAML(llvm::StringRef Yaml);

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp?rev=268021&r1=268020&r2=268021&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 Fri Apr 29 05:16:28 2016
@@ -59,10 +59,13 @@ public:
 
   void Write(const std::string &Dir) {
 for (const auto &Symbol : Symbols) {
-  SmallString<256> FilePath(Dir);
-  llvm::sys::path::append(
-  FilePath, llvm::sys::path::filename(Symbol.first) + ".yaml");
-  WriteSymboInfosToFile(FilePath, Symbol.second);
+  int FD;
+  SmallString<128> ResultPath;
+  llvm::sys::fs::createUniqueFile(
+  Dir + "/" + llvm::sys::path::filename(Symbol.first) + "-%%.yaml",
+  FD, ResultPath);
+  llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
+  WriteSymbolInfosToStream(OS, Symbol.second);
 }
   }
 
@@ -90,7 +93,13 @@ bool Merge(llvm::StringRef MergeDir, llv
   UniqueSymbols.insert(Symbol);
   }
 
-  WriteSymboInfosToFile(OutputFile, UniqueSymbols);
+  llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+ << '\n';
+return false;
+  }
+  WriteSymbolInfosToStream(OS, UniqueSymbols);
   return true;
 }
 


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


Re: [PATCH] D19717: [find-all-symbols] Fix racy yaml file writing.

2016-04-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268021: [find-all-symbols] Fix racy yaml file writing. 
(authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D19717?vs=9&id=55562#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19717

Files:
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -87,9 +88,9 @@
   bool operator<(const SymbolInfo &Symbol) const;
 };
 
-/// \brief Write SymbolInfos to a single file (YAML format).
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols);
+/// \brief Write SymbolInfos to a stream (YAML format).
+bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
+  const std::set &Symbols);
 
 /// \brief Read SymbolInfos from a YAML document.
 std::vector ReadSymbolInfosFromYAML(llvm::StringRef Yaml);
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
@@ -97,16 +97,11 @@
  std::tie(Symbol.Name, Symbol.FilePath, Symbol.LineNumber);
 }
 
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols) {
-  int FD = 0;
-  if (llvm::sys::fs::openFileForWrite(FilePath, FD, llvm::sys::fs::F_None))
-return false;
-  llvm::raw_fd_ostream OS(FD, true);
+bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
+  const std::set &Symbols) {
   llvm::yaml::Output yout(OS);
   for (auto Symbol : Symbols)
 yout << Symbol;
-  OS.close();
   return true;
 }
 
Index: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -59,10 +59,13 @@
 
   void Write(const std::string &Dir) {
 for (const auto &Symbol : Symbols) {
-  SmallString<256> FilePath(Dir);
-  llvm::sys::path::append(
-  FilePath, llvm::sys::path::filename(Symbol.first) + ".yaml");
-  WriteSymboInfosToFile(FilePath, Symbol.second);
+  int FD;
+  SmallString<128> ResultPath;
+  llvm::sys::fs::createUniqueFile(
+  Dir + "/" + llvm::sys::path::filename(Symbol.first) + "-%%.yaml",
+  FD, ResultPath);
+  llvm::raw_fd_ostream OS(FD, /*shouldClose=*/true);
+  WriteSymbolInfosToStream(OS, Symbol.second);
 }
   }
 
@@ -90,7 +93,13 @@
   UniqueSymbols.insert(Symbol);
   }
 
-  WriteSymboInfosToFile(OutputFile, UniqueSymbols);
+  llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+ << '\n';
+return false;
+  }
+  WriteSymbolInfosToStream(OS, UniqueSymbols);
   return true;
 }
 


Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
@@ -12,6 +12,7 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -87,9 +88,9 @@
   bool operator<(const SymbolInfo &Symbol) const;
 };
 
-/// \brief Write SymbolInfos to a single file (YAML format).
-bool WriteSymboInfosToFile(llvm::StringRef FilePath,
-   const std::set &Symbols);
+/// \brief Write SymbolInfos to a stream (YAML format).
+bool WriteSymbolInfosToStream(llvm::raw_ostream &OS,
+  const std::set &Symbols);
 
 /// \brief Read SymbolInfos from a YAML document.
 std::vector ReadSymbolInfosFromYAML(llvm::StringRef Yaml);
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolI

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 7.
rmaprath added a comment.

In http://reviews.llvm.org/D19412#416183, @EricWF wrote:

> OK. I *think* this is my last round of review comments except for one 
> specific issue. I'm still looking into the changes to the static mutex's and 
> condition_variables in `memory.cpp` and `algorithm.cpp`. In these cases I 
> don't want to go from compile-time initialization to run-time initialization. 
>  This could introduce the static initialization order fiasco.


So, as pointed out earlier by @bcraig, there won't be a runtime overhead for 
those compilers supporting `constexr`. For those that don't, this is still a 
trivial enough constructor call that is very likely to get optimized away. To 
elaborate, we can simplify this scenario to something like:

**thread.h**

  struct thread_t {
int state1;
int *state2;
bool state3;
  };
  
  #define THREAD_INITIALIZER  {0, 0, false}

**test.cpp**

  #include "thread.h"
  
  class Foo {
  private:
thread_t __t_;
  public:
Foo() {__t_ = (thread_t) THREAD_INITIALIZER;}
  };
  
  Foo f();
  
  int main() {
return 0;
  }

Compiling this with either `clang` or `gcc` in `-std=c++03` does **not** 
introduce an entry in the `.init_array` section. This can be observed with:

  > clang++ -std=c++03 -c test.cpp
  > objdump -j .init_array -dxs test.o

On the other hand, if you slightly change the constructor to take a parameter, 
or print something into `std::cout`, there will be an entry in the 
`.init_array`.

Moreover, even if some compiler naively emits a runtime initialization code for 
these constructors (`mutex` and `condition_variable`), I don't see how that can 
lead to problems related to static initialization order - all these 
constructors do is simply copy some memory, at worse, the compiler may emit a 
call to `memcpy` - but `memcpy` does not (AFAIK) depend on any other library 
state. In other words, these constructors don't require any other parts of the 
library having being initialized first.

I hope that clears it?

I have addressed the rest of you comments. Two minor nits:

- Can we keep `__libcpp_mutex_t` (used in `__threading_support`) and 
`__mutex_type` (used in `__mutex_base`) separate? I feel it's cleaner to make a 
distinction between the types of the threading API and the rest of the library. 
I don't have a strong opinion though, let me know if you'd like it changed 
still.
- I'd rather not move `__libcpp_recursive_mutex_init` back into 
`recursive_mutex.cpp`, as this would introduce pthread dependencies 
(`pthread_mutexattr_xxx`) back into the library sources. It's possible to 
workaround that by adding further `__libcpp_mutexattr_xxx` functions to the 
threading API, but those seem to be bit too pthread-specific. Again, no strong 
preference.

Thanks!

/ Asiri


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,13 +23,13 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
@@ -37,13 +37,13 @@
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
@@ -52,36 +52,14 @@
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
+int ec = __libcpp_recursive_mutex_init(&__m_);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthrea

[clang-tools-extra] r268022 - Make run-find-all-symbols executable.

2016-04-29 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Apr 29 05:33:11 2016
New Revision: 268022

URL: http://llvm.org/viewvc/llvm-project?rev=268022&view=rev
Log:
Make run-find-all-symbols executable.

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
   (contents, props changed)

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py?rev=268022&r1=268021&r2=268022&view=diff
==
(empty)

Propchange: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/run-find-all-symbols.py
--
svn:executable = *


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


r268028 - [clang][BuiltIn][AVX512]Adding intrinsics for cmp{ss|sd} instruction set.

2016-04-29 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Fri Apr 29 06:01:16 2016
New Revision: 268028

URL: http://llvm.org/viewvc/llvm-project?rev=268028&view=rev
Log:
[clang][BuiltIn][AVX512]Adding intrinsics for cmp{ss|sd} instruction set.

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


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

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268028&r1=268027&r2=268028&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Apr 29 06:01:16 2016
@@ -,7 +,8 @@ TARGET_BUILTIN(__builtin_ia32_compressdf
 TARGET_BUILTIN(__builtin_ia32_compressdi512_mask, 
"V8LLiV8LLiV8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compresssf512_mask, 
"V16fV16fV16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compresssi512_mask, 
"V16iV16iV16iUs","","avx512f")
-
+TARGET_BUILTIN(__builtin_ia32_cmpsd_mask, "UcV2dV2dIiUcIi","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_cmpss_mask, "UcV4fV4fIiUcIi","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268028&r1=268027&r2=268028&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Fri Apr 29 06:01:16 2016
@@ -7629,6 +7629,58 @@ _mm512_maskz_compress_epi32 (__mmask16 _
   (__mmask16) __U);
 }
 
+#define _mm_cmp_round_ss_mask( __X, __Y, __P, __R) __extension__ ({ \
+__builtin_ia32_cmpss_mask ((__v4sf)( __X),\
+ (__v4sf)( __Y), __P,\
+ (__mmask8) -1, __R);\
+})
+
+#define _mm_mask_cmp_round_ss_mask( __M, __X, __Y, __P, __R) __extension__ ({ \
+__builtin_ia32_cmpss_mask ((__v4sf)( __X),\
+ (__v4sf)( __Y), __P,\
+ (__mmask8)( __M), __R);\
+})
+
+#define _mm_cmp_ss_mask( __X, __Y, __P) __extension__ ({ \
+__builtin_ia32_cmpss_mask ((__v4sf)( __X),\
+ (__v4sf)( __Y),( __P),\
+ (__mmask8) -1,\
+ _MM_FROUND_CUR_DIRECTION);\
+})
+
+#define _mm_mask_cmp_ss_mask( __M, __X, __Y, __P) __extension__ ({ \
+__builtin_ia32_cmpss_mask ((__v4sf)( __X),\
+ (__v4sf)( __Y),( __P),\
+ (__mmask8)( __M),\
+ _MM_FROUND_CUR_DIRECTION);\
+})
+
+#define _mm_cmp_round_sd_mask( __X, __Y, __P,__R) __extension__ ({ \
+__builtin_ia32_cmpsd_mask ((__v2df)( __X),\
+ (__v2df)( __Y), __P,\
+ (__mmask8) -1, __R);\
+})
+
+#define _mm_mask_cmp_round_sd_mask( __M, __X, __Y, __P, __R) __extension__ ({ \
+__builtin_ia32_cmpsd_mask ((__v2df)( __X),\
+ (__v2df)( __Y), __P,\
+ (__mmask8)( __M), __R);\
+})
+
+#define _mm_cmp_sd_mask( __X, __Y, __P) __extension__ ({ \
+__builtin_ia32_cmpsd_mask ((__v2df)( __X),\
+ (__v2df)( __Y),( __P),\
+ (__mmask8) -1,\
+ _MM_FROUND_CUR_DIRECTION);\
+})
+
+#define _mm_mask_cmp_sd_mask( __M, __X, __Y, __P) __extension__ ({ \
+__builtin_ia32_cmpsd_mask ((__v2df)( __X),\
+ (__v2df)( __Y),( __P),\
+ (__mmask8)( __M),\
+ _MM_FROUND_CUR_DIRECTION);\
+})
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif // __AVX512FINTRIN_H

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268028&r1=268027&r2=268028&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Fri Apr 29 06:01:16 2016
@@ -5285,3 +5285,51 @@ __m512i test_mm512_maskz_compress_epi32(
   // CHECK: @llvm.x86.avx512.mask.compress.d.512
   return _mm512_maskz_compress_epi32(__U, __A); 
 }
+
+__mmask8 test_mm_cmp_round_ss_mask(__m128 __X, __m128 __Y) {
+  // CHECK-LABEL: @test_mm_cmp_round_ss_mask
+  // CHECK: @llvm.x86.avx512.mask.cmp
+  return _mm_cmp_round_ss_mask(__X, __Y, 5, _MM_FROUND_CUR_DIRECTION); 
+}
+
+__mmask8 test_mm_mask_cmp_round_ss_mask(__mmask8 __M, __m128 __X, __m128 __Y) {
+  // CHECK-LABEL: @test_mm_mask_cmp_round_ss_mask
+  // CHECK: @llvm.x86.avx512.mask.cmp
+  return _mm_mask_cmp_round_ss_mask(__M, __X, __Y, 5, 
_MM_FROUND_CUR_DIRECTION); 
+}
+
+__mmask8 test_mm_cmp_ss_mask(__m128 __X, __m128 __Y) {
+  // CHECK-LABEL: @test_mm_cmp_ss_mask
+  // CHECK: @llvm.x86.avx512.mask.cmp
+  return _mm_cmp_ss_mask(__X, __Y, 5); 
+}
+
+__mmask8 test_mm_mask_cmp_ss_mask(__mmask8 __M, __m128 __X, __m128 __Y) {
+  // CHECK-LABEL: @test_mm_mask_cmp_ss_mask
+  // CHECK: 

Re: [PATCH] D19156: [ms][dll] #27212: Generating of implicit special members should take into account MSVC compatibility version

2016-04-29 Thread Andrew V. Tischenko via cfe-commits
avt77 updated this revision to Diff 55567.
avt77 added a comment.

Now it's really a micro-patch: please review.


http://reviews.llvm.org/D19156

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/dllexport.cpp

Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -4774,7 +4774,6 @@
 
   // The class is either imported or exported.
   const bool ClassExported = ClassAttr->getKind() == attr::DLLExport;
-  const bool ClassImported = !ClassExported;
 
   TemplateSpecializationKind TSK = Class->getTemplateSpecializationKind();
 
@@ -4809,9 +4808,12 @@
 if (!Context.getTargetInfo().getCXXABI().isMicrosoft())
   continue;
 
-// MSVC versions before 2015 don't export the move assignment 
operators,
-// so don't attempt to import them if we have a definition.
-if (ClassImported && MD->isMoveAssignmentOperator() &&
+// MSVC versions before 2015 don't export the move assignment operators
+// and move constructor, so don't attempt to import/export them if
+// we have a definition.
+auto *CXXC = dyn_cast(MD);
+if ((MD->isMoveAssignmentOperator() ||
+ (CXXC && CXXC->isMoveConstructor())) &&
 !getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2015))
   continue;
   }
Index: test/CodeGenCXX/dllexport.cpp
===
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases 
-disable-llvm-optzns -o - %s -w | FileCheck --check-prefix=MSC 
--check-prefix=M32 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck 
--check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases 
-disable-llvm-optzns -o - %s -w -fms-compatibility-version=19.00 | FileCheck 
--check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 %s
+// RUN: %clang_cc1 -triple i686-windows-msvc   -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases 
-disable-llvm-optzns -o - %s -w -fms-compatibility-version=18.00 | FileCheck 
--check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 %s
+
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w 
-fms-compatibility-version=19.00 | FileCheck --check-prefix=MSC 
--check-prefix=M64 -check-prefix=MSVC2015 %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w 
-fms-compatibility-version=18.00 | FileCheck --check-prefix=MSC 
--check-prefix=M64 -check-prefix=MSVC2013 %s
+
 // RUN: %clang_cc1 -triple i686-windows-gnu-emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck 
--check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -triple x86_64-windows-gnu  -emit-llvm -std=c++1y 
-fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck 
--check-prefix=GNU --check-prefix=G64 %s
 
@@ -528,6 +532,8 @@
   SomeTemplate(T o = T()) : o(o) {}
   T o;
 };
+// MSVC2015-DAG: define weak_odr dllexport {{.+}} 
@"\01??4?$SomeTemplate@H@@Q{{.+}}@$$Q{{.+}}@@Z"
+// MSVC2013-DAG: define weak_odr dllexport {{.+}} 
@"\01??4?$SomeTemplate@H@@Q{{.+}}0@A{{.+}}0@@Z"
 struct __declspec(dllexport) InheritFromTemplate : SomeTemplate {};
 
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01??_F?$SomeTemplate@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
@@ -616,7 +622,8 @@
 
 struct __declspec(dllexport) Y {
   // Move assignment operator:
-  // M32-DAG: define weak_odr dllexport x86_thiscallcc 
dereferenceable({{[0-9]+}}) %struct.Y* @"\01??4Y@@QAEAAU0@$$QAU0@@Z"
+  // MSVC2015-DAG: define weak_odr dllexport {{.+}} 
@"\01??4Y@@Q{{.+}}@$$Q{{.+}}@@Z"
+  // MSVC2013-DAG: define weak_odr dllexport {{.+}} 
@"\01??4Y@@Q{{.+}}0@A{{.+}}0@@Z"
 
   int x;
 };
@@ -933,3 +940,15 @@
 USEMEMFUNC(ExplicitInstantiationDeclTemplateBase2, func)
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ"
 // G32-DAG: define weak_odr x86_thiscallcc void 
@_ZN38ExplicitInstantiationDeclTemplateBase2IiE4funcEv
+
+class __declspec(dllexport) ACE_Shared_Object {
+  public:
+virtual ~ACE_Shared_Object ();
+};
+
+class __declspec(dllexport) ACE_Service_Object: public ACE_Shared_Object {};
+
+// Implicit move constructor declaration.
+// MSVC2015-DAG: define weak_odr dllexport 
{{.+}}ACE_Service_Object@@Q{{.+}}@$$Q
+// The declarations should not be exported.
+// MSVC2013-NOT: define weak_odr dllexport 
{{.+}}ACE_Service_Object@@Q{{.+}}

r268029 - Recommit "[MS] Improved implementation of stack pragmas (vtordisp, *_seg)"

2016-04-29 Thread Denis Zobnin via cfe-commits
Author: dzobnin
Date: Fri Apr 29 06:27:00 2016
New Revision: 268029

URL: http://llvm.org/viewvc/llvm-project?rev=268029&view=rev
Log:
Recommit "[MS] Improved implementation of stack pragmas (vtordisp, *_seg)"

Slightly updated version, double-checked build and tests.
Improve implementation of MS pragmas that use stack + compatibility fixes.
This patch:
  1. Changes implementation of #pragma vtordisp to use PragmaStack class
 that other stack pragmas use;
  2. Fixes "#pragma vtordisp()" behavior - it shouldn't affect the stack;
  3. Supports "save-restore" of pragma stacks on enter / exit a C++ method
 body, as MSVC does.

TODO:
  1. Change implementation of #pragma pack to use the same approach;
  2. Introduce diagnostics on popping named stack slots, as MSVC does.

Reviewers:
  rnk, thakis

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/test/CodeGenCXX/sections.cpp
cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268029&r1=268028&r2=268029&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Apr 29 06:27:00 2016
@@ -327,40 +327,21 @@ public:
   LangOptions::PragmaMSPointersToMembersKind
   MSPointerToMemberRepresentationMethod;
 
-  enum PragmaVtorDispKind {
-PVDK_Push,  ///< #pragma vtordisp(push, mode)
-PVDK_Set,   ///< #pragma vtordisp(mode)
-PVDK_Pop,   ///< #pragma vtordisp(pop)
-PVDK_Reset  ///< #pragma vtordisp()
-  };
-
-  enum PragmaMsStackAction {
-PSK_Reset,// #pragma ()
-PSK_Set,  // #pragma ("name")
-PSK_Push, // #pragma (push[, id])
-PSK_Push_Set, // #pragma (push[, id], "name")
-PSK_Pop,  // #pragma (pop[, id])
-PSK_Pop_Set,  // #pragma (pop[, id], "name")
-  };
-
-  /// \brief Whether to insert vtordisps prior to virtual bases in the 
Microsoft
-  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
-  ///
-  /// 0: Suppress all vtordisps
-  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
-  ///structors
-  /// 2: Always insert vtordisps to support RTTI on partially constructed
-  ///objects
-  ///
-  /// The stack always has at least one element in it.
-  SmallVector VtorDispModeStack;
-
   /// Stack of active SEH __finally scopes.  Can be empty.
   SmallVector CurrentSEHFinally;
 
   /// \brief Source location for newly created implicit MSInheritanceAttrs
   SourceLocation ImplicitMSInheritanceAttrLoc;
 
+  enum PragmaMsStackAction {
+PSK_Reset = 0x0,// #pragma ()
+PSK_Set   = 0x1,// #pragma (value)
+PSK_Push  = 0x2,// #pragma (push[, id])
+PSK_Pop   = 0x4,// #pragma (pop[, id])
+PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
+PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
+  };
+
   template
   struct PragmaStack {
 struct Slot {
@@ -377,18 +358,66 @@ public:
  PragmaMsStackAction Action,
  llvm::StringRef StackSlotLabel,
  ValueType Value);
-explicit PragmaStack(const ValueType &Value)
-  : CurrentValue(Value) {}
+
+// MSVC seems to add artificial slots to #pragma stacks on entering a C++
+// method body to restore the stacks on exit, so it works like this:
+//
+//   struct S {
+// #pragma (push, InternalPragmaSlot, )
+// void Method {}
+// #pragma (pop, InternalPragmaSlot)
+//   };
+//
+// It works even with #pragma vtordisp, although MSVC doesn't support
+//   #pragma vtordisp(push [, id], n)
+// syntax.
+//
+// Push / pop a named sentinel slot.
+void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
+  assert((Action == PSK_Push || Action == PSK_Pop) &&
+ "Can only push / pop #pragma stack sentinels!");
+  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
+}
+
+// Constructors.
+explicit PragmaStack(const ValueType &Default)
+: DefaultValue(Default), CurrentValue(Default) {}
+
 SmallVector Stack;
+ValueType DefaultValue; // Value used for PSK_Reset action.
 ValueType CurrentValue;
 SourceLocation CurrentPragmaLocation;
   };
   // FIXME: We should serialize / deserialize these if they occur in a PCH (but
   // we shouldn't do so if they're in a module).
+
+  /// \brief Whether to insert vtordisps prior to virtual bases in the 
Microsoft
+  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
+  ///
+  /// 0: Suppress all vtordisps
+  /// 1

Re: [PATCH] D19361: [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)

2016-04-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268029: Recommit "[MS] Improved implementation of stack 
pragmas (vtordisp, *_seg)" (authored by dzobnin).

Changed prior to commit:
  http://reviews.llvm.org/D19361?vs=54484&id=55568#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19361

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaAttr.cpp
  cfe/trunk/test/CodeGenCXX/sections.cpp
  cfe/trunk/test/SemaCXX/pragma-vtordisp.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -327,40 +327,21 @@
   LangOptions::PragmaMSPointersToMembersKind
   MSPointerToMemberRepresentationMethod;
 
-  enum PragmaVtorDispKind {
-PVDK_Push,  ///< #pragma vtordisp(push, mode)
-PVDK_Set,   ///< #pragma vtordisp(mode)
-PVDK_Pop,   ///< #pragma vtordisp(pop)
-PVDK_Reset  ///< #pragma vtordisp()
-  };
-
-  enum PragmaMsStackAction {
-PSK_Reset,// #pragma ()
-PSK_Set,  // #pragma ("name")
-PSK_Push, // #pragma (push[, id])
-PSK_Push_Set, // #pragma (push[, id], "name")
-PSK_Pop,  // #pragma (pop[, id])
-PSK_Pop_Set,  // #pragma (pop[, id], "name")
-  };
-
-  /// \brief Whether to insert vtordisps prior to virtual bases in the Microsoft
-  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
-  ///
-  /// 0: Suppress all vtordisps
-  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
-  ///structors
-  /// 2: Always insert vtordisps to support RTTI on partially constructed
-  ///objects
-  ///
-  /// The stack always has at least one element in it.
-  SmallVector VtorDispModeStack;
-
   /// Stack of active SEH __finally scopes.  Can be empty.
   SmallVector CurrentSEHFinally;
 
   /// \brief Source location for newly created implicit MSInheritanceAttrs
   SourceLocation ImplicitMSInheritanceAttrLoc;
 
+  enum PragmaMsStackAction {
+PSK_Reset = 0x0,// #pragma ()
+PSK_Set   = 0x1,// #pragma (value)
+PSK_Push  = 0x2,// #pragma (push[, id])
+PSK_Pop   = 0x4,// #pragma (pop[, id])
+PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
+PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
+  };
+
   template
   struct PragmaStack {
 struct Slot {
@@ -377,18 +358,66 @@
  PragmaMsStackAction Action,
  llvm::StringRef StackSlotLabel,
  ValueType Value);
-explicit PragmaStack(const ValueType &Value)
-  : CurrentValue(Value) {}
+
+// MSVC seems to add artificial slots to #pragma stacks on entering a C++
+// method body to restore the stacks on exit, so it works like this:
+//
+//   struct S {
+// #pragma (push, InternalPragmaSlot, )
+// void Method {}
+// #pragma (pop, InternalPragmaSlot)
+//   };
+//
+// It works even with #pragma vtordisp, although MSVC doesn't support
+//   #pragma vtordisp(push [, id], n)
+// syntax.
+//
+// Push / pop a named sentinel slot.
+void SentinelAction(PragmaMsStackAction Action, StringRef Label) {
+  assert((Action == PSK_Push || Action == PSK_Pop) &&
+ "Can only push / pop #pragma stack sentinels!");
+  Act(CurrentPragmaLocation, Action, Label, CurrentValue);
+}
+
+// Constructors.
+explicit PragmaStack(const ValueType &Default)
+: DefaultValue(Default), CurrentValue(Default) {}
+
 SmallVector Stack;
+ValueType DefaultValue; // Value used for PSK_Reset action.
 ValueType CurrentValue;
 SourceLocation CurrentPragmaLocation;
   };
   // FIXME: We should serialize / deserialize these if they occur in a PCH (but
   // we shouldn't do so if they're in a module).
+
+  /// \brief Whether to insert vtordisps prior to virtual bases in the Microsoft
+  /// C++ ABI.  Possible values are 0, 1, and 2, which mean:
+  ///
+  /// 0: Suppress all vtordisps
+  /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial
+  ///structors
+  /// 2: Always insert vtordisps to support RTTI on partially constructed
+  ///objects
+  PragmaStack VtorDispStack;
   PragmaStack DataSegStack;
   PragmaStack BSSSegStack;
   PragmaStack ConstSegStack;
   PragmaStack CodeSegStack;
+  // TODO: Change implementation of #pragma pack to use PragmaStack<> approach.
+
+  // RAII object to push / pop sentinel slots for all MS #pragma stacks.
+  // Actions should be performed only if we enter / exit a C++ method body.
+  class PragmaStackSentinelRAII {
+  public:
+PragmaStackSentinelRAII(Sema &S, StringRef SlotLabel, bool ShouldAct);
+~PragmaStackSentinelRAII();
+
+  private:
+ 

Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-04-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55570.
rmaprath added a comment.

Re-sync with http://reviews.llvm.org/D19412.


http://reviews.llvm.org/D19415

Files:
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -192,7 +192,77 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(_LIBCPP_MUTEX_INITIALIZER)
+  #error "_LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(_LIBCPP_COND_INITIALIZER)
+  #error "_LIBCPP_COND_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* 
__m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+// Returns non-zero if the thread ids are equal, otherwise 0
+int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Returns non-zero if t1 < t2, otherwise 0
+int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__f)(void*), void* 
__arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit) (void*));
+
+void* __libcpp_tl_get(__libcpp_tl_key __key);
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
   #error "No thread API selected."
 #endif
 


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -192,7 +192,77 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(_LIBCPP_MUTEX_INITIALIZER)
+  #error "_LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(_LIBCPP_COND_INITIALIZER)
+  #error "_LIBCPP_COND_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+// Returns non-zero if the thread ids are equal, otherwise 0
+int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Returns non-zero if t1 < t2, otherwise 0
+int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__f)(void*), void* __arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit) (void*));
+
+void* __libcpp_tl_get(__libcpp_tl_key __key);
+
+void

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55569.
rmaprath added a comment.

Minor tweak: Got rid of the unnecessary template parameters on 
`__libcpp_thread_create` and `__libcpp_tl_create`.


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,89 +23,67 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
+int ec = __libcpp_recursive_mutex_init(&__m_);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __libcpp_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __libcpp_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +143,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__libcpp_thread_id_equal(id, __id_))
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +161,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +195,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static mutex mut;
+static condition_variable cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +225,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+unique_lock lk(mut);
 while (flag == 1)
-pthread_cond_wait(&cv, &mut);
+cv.wait(lk);
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(&flag, 1ul);
-pthread_mutex_unlock(&mut);
+lk.unlock();
 func(arg);
-pthread_mutex_lock(&mut);
+lk.lock();
   

Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55571.
rmaprath added a comment.

Missed one: s/_LIBCPP_COND_INITIALIZER/_LIBCPP_CONDVAR_INITIALIZER


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,89 +23,67 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
+int ec = __libcpp_recursive_mutex_init(&__m_);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __libcpp_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __libcpp_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +143,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__libcpp_thread_id_equal(id, __id_))
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +161,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +195,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static mutex mut;
+static condition_variable cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +225,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+unique_lock lk(mut);
 while (flag == 1)
-pthread_cond_wait(&cv, &mut);
+cv.wait(lk);
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(&flag, 1ul);
-pthread_mutex_unlock(&mut);
+lk.unlock();
 func(arg);
-pthread_mutex_lock(&mut);
+lk.lock();
 __libcpp_relaxed_store(&flag, ~0ul);
-

Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-04-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55573.
rmaprath added a comment.

Minor re-spin on http://reviews.llvm.org/D19412.


http://reviews.llvm.org/D19415

Files:
  include/__threading_support

Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -192,7 +192,77 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(_LIBCPP_MUTEX_INITIALIZER)
+  #error "_LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(_LIBCPP_CONDVAR_INITIALIZER)
+  #error "_LIBCPP_CONDVAR_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* 
__m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+// Returns non-zero if the thread ids are equal, otherwise 0
+int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Returns non-zero if t1 < t2, otherwise 0
+int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__f)(void*), void* 
__arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit) (void*));
+
+void* __libcpp_tl_get(__libcpp_tl_key __key);
+
+void __libcpp_tl_set(__libcpp_tl_key __key, void* __p);
+
+#else
   #error "No thread API selected."
 #endif
 


Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -192,7 +192,77 @@
 pthread_setspecific(__key, __p);
 }
 
-#else // !_LIBCPP_THREAD_API_PTHREAD
+#elif defined(_LIBCPP_THREAD_API_EXTERNAL)
+
+// Mutex
+#if !defined(_LIBCPP_MUTEX_INITIALIZER)
+  #error "_LIBCPP_MUTEX_INITIALIZER must be defined."
+#endif
+struct __libcpp_mutex_external;
+typedef __libcpp_mutex_external* __libcpp_mutex_t;
+
+int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
+
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
+
+// Condition variable
+#if !defined(_LIBCPP_CONDVAR_INITIALIZER)
+  #error "_LIBCPP_CONDVAR_INITIALIZER must be defined."
+#endif
+struct __libcpp_condvar_external;
+typedef __libcpp_condvar_external* __libcpp_condvar_t;
+
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
+
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
+
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts);
+
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
+
+// Thread id
+typedef unsigned long __libcpp_thread_id;
+
+// Returns non-zero if the thread ids are equal, otherwise 0
+int __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Returns non-zero if t1 < t2, otherwise 0
+int __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2);
+
+// Thread
+struct __libcpp_thread_external;
+typedef __libcpp_thread_external* __libcpp_thread_t;
+
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__f)(void*), void* __arg);
+
+__libcpp_thread_id __libcpp_thread_get_current_id();
+
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
+
+int __libcpp_thread_join(__libcpp_thread_t* __t);
+
+int __libcpp_thread_detach(__libcpp_thread_t* __t);
+
+void __libcpp_thread_yield();
+
+// Thread local storage
+typedef unsigned long __libcpp_tl_key;
+
+int __libcpp_tl_create(__libcpp_tl_key* __key, void (*__at_exit) (void*));
+
+void* __libcpp_tl_get(__libcpp_tl_key

[PATCH] D19720: [find-all-symbols] Parallelize the merge step.

2016-04-29 Thread Benjamin Kramer via cfe-commits
bkramer created this revision.
bkramer added reviewers: hokein, djasper.
bkramer added a subscriber: cfe-commits.

There is still more parallelism to get here because we synchonize on the
actual uniquing but just doing YAML parsing in parallel already gives a
significant speedup.

Merging all symbols in LLVM+clang+compiler-rt+lld+libc++, 48 cores.
before: 201.55s user 1.47s system 99% cpu 3:23.04 total
after:  279.13s user 7.53s system 929% cpu 30.838 total

http://reviews.llvm.org/D19720

Files:
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -74,23 +75,34 @@
 };
 
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
-  std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+for (const SymbolInfo &Symbol : Symbols)
+  UniqueSymbols.insert(Symbol);
+  };
+
   // Load all symbol files in MergeDir.
+  llvm::ThreadPool Pool;
+  std::error_code EC;
   for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
-}
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols =
-ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
-for (const auto &Symbol : Symbols)
-  UniqueSymbols.insert(Symbol);
+// Do the YAML file parsing in parallel.
+Pool.async(
+[&AddSymbols](std::string Path) {
+  auto Buffer = llvm::MemoryBuffer::getFile(Path);
+  if (!Buffer) {
+llvm::errs() << "Cann't open " << Path << "\n";
+return;
+  }
+  std::vector Symbols =
+  ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+  // FIXME: Merge without creating such a heavy contention point.
+  AddSymbols(Symbols);
+},
+Dir->path());
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);


Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -74,23 +75,34 @@
 };
 
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
-  std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+for (const SymbolInfo &Symbol : Symbols)
+  UniqueSymbols.insert(Symbol);
+  };
+
   // Load all symbol files in MergeDir.
+  llvm::ThreadPool Pool;
+  std::error_code EC;
   for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
-}
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols =
-ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
-for (const auto &Symbol : Symbols)
-  UniqueSymbols.insert(Symbol);
+// Do the YAML file parsing in parallel.
+Pool.async(
+[&AddSymbols](std::string Path) {
+  auto Buffer = llvm::MemoryBuffer::getFile(Path);
+  if (!Buffer) {
+llvm::errs() << "Cann't open " << Path << "\n";
+return;
+  }
+  std::vector Symbols =
+  ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+  // FIXME: Merge without creating such a heavy contention point.
+  AddSymbols(Symbols);
+},
+Dir->path());
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19720: [find-all-symbols] Parallelize the merge step.

2016-04-29 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 55577.
bkramer added a comment.

Drain the pool, fix typo.


http://reviews.llvm.org/D19720

Files:
  include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -76,26 +77,39 @@
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
   std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+for (const SymbolInfo &Symbol : Symbols)
+  UniqueSymbols.insert(Symbol);
+  };
+
   // Load all symbol files in MergeDir.
-  for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
-   Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
+  {
+llvm::ThreadPool Pool;
+for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
+ Dir != DirEnd && !EC; Dir.increment(EC)) {
+  // Parse YAML files in parallel.
+  Pool.async(
+  [&AddSymbols](std::string Path) {
+auto Buffer = llvm::MemoryBuffer::getFile(Path);
+if (!Buffer) {
+  llvm::errs() << "Can't open " << Path << "\n";
+  return;
+}
+std::vector Symbols =
+ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+// FIXME: Merge without creating such a heavy contention point.
+AddSymbols(Symbols);
+  },
+  Dir->path());
 }
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols =
-ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
-for (const auto &Symbol : Symbols)
-  UniqueSymbols.insert(Symbol);
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
   if (EC) {
-llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+llvm::errs() << "Can't open '" << OutputFile << "': " << EC.message()
  << '\n';
 return false;
   }


Index: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -76,26 +77,39 @@
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
   std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+for (const SymbolInfo &Symbol : Symbols)
+  UniqueSymbols.insert(Symbol);
+  };
+
   // Load all symbol files in MergeDir.
-  for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
-   Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
+  {
+llvm::ThreadPool Pool;
+for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
+ Dir != DirEnd && !EC; Dir.increment(EC)) {
+  // Parse YAML files in parallel.
+  Pool.async(
+  [&AddSymbols](std::string Path) {
+auto Buffer = llvm::MemoryBuffer::getFile(Path);
+if (!Buffer) {
+  llvm::errs() << "Can't open " << Path << "\n";
+  return;
+}
+std::vector Symbols =
+ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+// FIXME: Merge without creating such a heavy contention point.
+AddSymbols(Symbols);
+  },
+  Dir->path());
 }
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols =
-ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
-for (const auto &Symbol : Symbols)
-  UniqueSymbols.insert(Symbol);
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
   if (EC) {
-llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.messa

Re: [PATCH] D19720: [find-all-symbols] Parallelize the merge step.

2016-04-29 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp:107
@@ -94,3 +106,3 @@
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);

Don't we need to all 'Pool.wait()' to wait for all working threads complete?


http://reviews.llvm.org/D19720



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


Re: [PATCH] D19720: [find-all-symbols] Parallelize the merge step.

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

Just see you updated code. LGTM.


http://reviews.llvm.org/D19720



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


Re: [PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-04-29 Thread Andrey Turetskiy via cfe-commits
aturetsk updated this revision to Diff 55579.
aturetsk added a comment.

Add a missing option and a test.


http://reviews.llvm.org/D19658

Files:
  include/clang/Driver/Options.td
  test/Driver/x86-target-features.c

Index: test/Driver/x86-target-features.c
===
--- /dev/null
+++ test/Driver/x86-target-features.c
@@ -0,0 +1,51 @@
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mx87 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-x87 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -m80387 %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=X87 %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-80387 %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=NO-X87 %s
+// X87: "-target-feature" "+x87"
+// NO-X87: "-target-feature" "-x87"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmmx -m3dnow 
-m3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MMX %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-mmx -mno-3dnow 
-mno-3dnowa %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MMX %s
+// MMX: "-target-feature" "+mmx" "-target-feature" "+3dnow" "-target-feature" 
"+3dnowa"
+// NO-MMX: "-target-feature" "-mmx" "-target-feature" "-3dnow" 
"-target-feature" "-3dnowa"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msse -msse2 -msse3 
-mssse3 -msse4a -msse4.1 -msse4.2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=SSE %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sse -mno-sse2 
-mno-sse3 -mno-ssse3 -mno-sse4a -mno-sse4.1 -mno-sse4.2 %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=NO-SSE %s
+// SSE: "-target-feature" "+sse" "-target-feature" "+sse2" "-target-feature" 
"+sse3" "-target-feature" "+ssse3" "-target-feature" "+sse4a" "-target-feature" 
"+sse4.1" "-target-feature" "+sse4.2"
+// NO-SSE: "-target-feature" "-sse" "-target-feature" "-sse2" 
"-target-feature" "-sse3" "-target-feature" "-ssse3" "-target-feature" "-sse4a" 
"-target-feature" "-sse4.1" "-target-feature" "-sse4.2"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -msse4 -maes %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=SSE4-AES %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-sse4 -mno-aes 
%s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-SSE4-AES %s
+// SSE4-AES: "-target-feature" "+sse4.2" "-target-feature" "+aes"
+// NO-SSE4-AES: "-target-feature" "-sse4.1" "-target-feature" "-aes"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mavx -mavx2 
-mavx512f -mavx512cd -mavx512er -mavx512pf -mavx512dq -mavx512bw -mavx512vl 
-mavx512vbmi -mavx512ifma %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-avx -mno-avx2 
-mno-avx512f -mno-avx512cd -mno-avx512er -mno-avx512pf -mno-avx512dq 
-mno-avx512bw -mno-avx512vl -mno-avx512vbmi -mno-avx512ifma %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=NO-AVX %s
+// AVX: "-target-feature" "+avx" "-target-feature" "+avx2" "-target-feature" 
"+avx512f" "-target-feature" "+avx512cd" "-target-feature" "+avx512er" 
"-target-feature" "+avx512pf" "-target-feature" "+avx512dq" "-target-feature" 
"+avx512bw" "-target-feature" "+avx512vl" "-target-feature" "+avx512vbmi" 
"-target-feature" "+avx512ifma"
+// NO-AVX: "-target-feature" "-avx" "-target-feature" "-avx2" 
"-target-feature" "-avx512f" "-target-feature" "-avx512cd" "-target-feature" 
"-avx512er" "-target-feature" "-avx512pf" "-target-feature" "-avx512dq" 
"-target-feature" "-avx512bw" "-target-feature" "-avx512vl" "-target-feature" 
"-avx512vbmi" "-target-feature" "-avx512ifma"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mpclmul -mrdrnd 
-mfsgsbase -mbmi -mbmi2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BMI %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-pclmul 
-mno-rdrnd -mno-fsgsbase -mno-bmi -mno-bmi2 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-BMI %s
+// BMI: "-target-feature" "+pclmul" "-target-feature" "+rdrnd" 
"-target-feature" "+fsgsbase" "-target-feature" "+bmi" "-target-feature" "+bmi2"
+// NO-BMI: "-target-feature" "-pclmul" "-target-feature" "-rdrnd" 
"-target-feature" "-fsgsbase" "-target-feature" "-bmi" "-target-feature" "-bmi2"
+
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mlzcnt -mpopcnt 
-mtbm -mfma -mfma4 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=FMA %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-lzcnt 
-mno-popcnt -mno-tbm -mno-fma -mno-fma4 %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-FMA %s
+// FMA: "-target-feature" "+lzcnt" "-target-feature" "+popcnt" 
"-target-feature" "+tbm" "-target-feature" "+fma" "-target-feature" "+fma4"
+// NO-FMA: "-target-feature" "-lzcnt" "-target-feature" "-popcnt" 
"-target-feature" "-tbm" "-target-feature" "-fma" "-target

Re: [PATCH] D19658: [X86] Add -m[no-]x87 and -m[no-]80387 options to control FeatureX87

2016-04-29 Thread Andrey Turetskiy via cfe-commits
aturetsk added a comment.

Hi,
Thanks for the review.
All m_x86_Features_Group options are handled in function 
handleTargetFeaturesGroup from lib/Driver/Tools.cpp, so there is no additional 
code needed.
There was no test for this, so I added a new one trying to cover all options 
from m_x86_Features_Group.



Comment at: include/clang/Driver/Options.td:1406
@@ -1403,2 +1405,3 @@
 def mno_sha : Flag<["-"], "mno-sha">, Group;
+def mno_cx16 : Flag<["-"], "mno-cx16">, Group;
 def mno_fxsr : Flag<["-"], "mno-fxsr">, Group;

The test showed me that this flag is missing so I added it.


http://reviews.llvm.org/D19658



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


Re: [PATCH] D19361: [MS] Improved implementation of MS stack pragmas (vtordisp, *_seg)

2016-04-29 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla added a comment.

Reid, thanks for review! I've changed the patch according to your comments and 
also moved implementation of RAII object to SemaAttr.cpp file (implementation 
in header broke many buildbots).

Nico, I will look at serialization and try to implement the desired behavior, 
thank you!


Repository:
  rL LLVM

http://reviews.llvm.org/D19361



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


[PATCH] D19721: Fix crash in BuildCXXDefaultInitExpr.

2016-04-29 Thread Raphael Isemann via cfe-commits
teemperor created this revision.
teemperor added reviewers: cfe-commits, rnk.

  Fix crash in BuildCXXDefaultInitExpr when member of template class
  has same name as the class itself.

http://reviews.llvm.org/D19721

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp

Index: test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
===
--- /dev/null
+++ test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+struct A {};
+
+template 
+struct B {
+
+  // Don't crash here
+  A B{};
+};
+
+int main() {
+  B b;
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -11412,8 +11412,31 @@
 CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern();
 DeclContext::lookup_result Lookup =
 ClassPattern->lookup(Field->getDeclName());
-assert(Lookup.size() == 1);
-FieldDecl *Pattern = cast(Lookup[0]);
+
+FieldDecl *Pattern = nullptr;
+
+// It's possible that both the current CXXRecordDecl and
+// the wanted FieldDecl appear in Lookup, so we iterate
+// over it and check that there is exactly one FieldDecl
+// and an optional unused CXXRecordDecl.
+for (NamedDecl *PossibleDecl : Lookup) {
+  FieldDecl *PossibleFieldDecl = dyn_cast(PossibleDecl);
+
+  if (PossibleFieldDecl) {
+// Will fail if there is more than one FieldDecl in Lookup.
+assert(Pattern == nullptr);
+
+Pattern = PossibleFieldDecl;
+  } else {
+// Assert that the other declaration is the unused
+// parent CXXRecordDecl.
+assert(isa(PossibleDecl));
+  }
+}
+
+// Will fail if there is no FieldDecl in Lookup.
+assert(Pattern != nullptr);
+
 if (InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field)))
   return ExprError();


Index: test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
===
--- /dev/null
+++ test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+struct A {};
+
+template 
+struct B {
+
+  // Don't crash here
+  A B{};
+};
+
+int main() {
+  B b;
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -11412,8 +11412,31 @@
 CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern();
 DeclContext::lookup_result Lookup =
 ClassPattern->lookup(Field->getDeclName());
-assert(Lookup.size() == 1);
-FieldDecl *Pattern = cast(Lookup[0]);
+
+FieldDecl *Pattern = nullptr;
+
+// It's possible that both the current CXXRecordDecl and
+// the wanted FieldDecl appear in Lookup, so we iterate
+// over it and check that there is exactly one FieldDecl
+// and an optional unused CXXRecordDecl.
+for (NamedDecl *PossibleDecl : Lookup) {
+  FieldDecl *PossibleFieldDecl = dyn_cast(PossibleDecl);
+
+  if (PossibleFieldDecl) {
+// Will fail if there is more than one FieldDecl in Lookup.
+assert(Pattern == nullptr);
+
+Pattern = PossibleFieldDecl;
+  } else {
+// Assert that the other declaration is the unused
+// parent CXXRecordDecl.
+assert(isa(PossibleDecl));
+  }
+}
+
+// Will fail if there is no FieldDecl in Lookup.
+assert(Pattern != nullptr);
+
 if (InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field)))
   return ExprError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18700: [Inline asm][GCC compatibility] Handle %v-prefixed code in inline assembly

2016-04-29 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla updated this revision to Diff 55581.
d.zobnin.bugzilla added a comment.
Herald added a subscriber: joker.eph.

Updated the patch after r266292 commit: [ASTImporter] Implement some 
expression-related AST node import.


http://reviews.llvm.org/D18700

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/avx-v-modifier-inline-asm.cpp

Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -632,6 +632,14 @@
 
   CurPtr = NameEnd+1;
   continue;
+} else if (*Begin == 'v') {
+  // GCC accepts code staring with "%v", e. g. "%vpcmpestri" and transforms
+  // it into "vpcmpestri" instruction if target processor supports AVX and
+  // into "pcmpestri" otherwise.
+  if (SupportsAVX)
+CurStringPiece = "v" + CurStringPiece;
+  CurStringPiece += EscapedChar;
+  continue;
 }
 
 DiagOffs = CurPtr-StrStart-1;
@@ -682,13 +690,15 @@
 //===--===//
 
 GCCAsmStmt::GCCAsmStmt(const ASTContext &C, SourceLocation asmloc,
-   bool issimple, bool isvolatile, unsigned numoutputs,
-   unsigned numinputs, IdentifierInfo **names,
-   StringLiteral **constraints, Expr **exprs,
-   StringLiteral *asmstr, unsigned numclobbers,
-   StringLiteral **clobbers, SourceLocation rparenloc)
-  : AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
-numinputs, numclobbers), RParenLoc(rparenloc), AsmStr(asmstr) {
+   bool issimple, bool isvolatile, bool supportsavx,
+   unsigned numoutputs, unsigned numinputs,
+   IdentifierInfo **names, StringLiteral **constraints,
+   Expr **exprs, StringLiteral *asmstr,
+   unsigned numclobbers, StringLiteral **clobbers,
+   SourceLocation rparenloc)
+: AsmStmt(GCCAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
+  numinputs, numclobbers),
+  RParenLoc(rparenloc), AsmStr(asmstr), SupportsAVX(supportsavx) {
 
   unsigned NumExprs = NumOutputs + NumInputs;
 
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -4833,6 +4833,7 @@
 Importer.Import(S->getAsmLoc()),
 S->isSimple(),
 S->isVolatile(),
+S->getSupportsAVX(),
 S->getNumOutputs(),
 S->getNumInputs(),
 Names.data(),
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -138,6 +138,75 @@
   return false;
 }
 
+// Collect all target features specified for the current context by the "target"
+// attribute. Start from current DeclContext and iterate its parents until we
+// find a function context.
+static void CollectTargetFeatures(Sema &S,
+  std::vector &TargetFeatures,
+  StringRef &TargetCPU) {
+  DeclContext *DC = S.CurContext;
+
+  auto Collect = [&TargetFeatures, &TargetCPU](const FunctionDecl *FD) {
+if (!FD)
+  return;
+if (const auto *TA = FD->getAttr()) {
+  TargetAttr::ParsedTargetAttr ParsedAttr = TA->parse();
+  TargetFeatures.insert(TargetFeatures.begin(), ParsedAttr.first.begin(),
+ParsedAttr.first.end());
+  if (TargetCPU == "")
+TargetCPU = ParsedAttr.second;
+}
+  };
+
+  // Climb up the tree of nested DeclContext-s, collecting the target features.
+  while (true) {
+if (isa(DC) || isa(DC) || isa(DC)) {
+  DC = DC->getParent();
+} else if (const auto *MD = dyn_cast(DC)) {
+  // Check if it's a lambda and collect its target features.
+  if (MD->getOverloadedOperator() == OO_Call &&
+  cast(DC->getParent())->isLambda()) {
+Collect(MD);
+  }
+  DC = DC->getParent()->getParent();
+} else {
+  // It's the nearest function, collect its features and break.
+  Collect(dyn_cast(DC));
+  break;
+}
+  }
+}
+
+// Check whether a particular target feature is enabled in current context,
+// either by command-line options or by __attribute__((__target__("..."))),
+// applied to any surrounding lambda or function.
+static bool TargetFeatureEnabled(Sema &S, StringRef Feature) {
+  const TargetInfo &TI = S.Context.getTargetInfo();
+  llvm::StringMap FeatureMap;
+  StringRef TargetCPU;
+  std::vector TargetFeatures;
+
+  // Collect target features and CPU from surrounding declarations.
+  CollectTargetFeatures(S, TargetFeatures, TargetCPU);
+
+  // Don't forget to add command-line features and CPU (lowest priority).
+  TargetFeatures.insert(TargetFeatures.begin

Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-29 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 55588.
andreybokhanko added a comment.

Fixed a bug uncovered by David Majnemer's review; added tests he asked for.


http://reviews.llvm.org/D19654

Files:
  include/clang/AST/Type.h
  include/clang/Basic/AddressSpaces.h
  include/clang/Basic/Attr.td
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-ms-cxx11.cpp
  test/CodeGenCXX/mangle-ms-cxx14.cpp
  test/Sema/MicrosoftExtensions.c
  test/Sema/address_spaces.c
  test/Sema/invalid-assignment-constant-address-space.c
  test/SemaCXX/MicrosoftExtensions.cpp

Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -609,7 +609,6 @@
 case tok::kw___ptr64:
 case tok::kw___w64:
 case tok::kw___ptr32:
-case tok::kw___unaligned:
 case tok::kw___sptr:
 case tok::kw___uptr: {
   IdentifierInfo *AttrName = Tok.getIdentifierInfo();
@@ -3087,6 +3086,11 @@
   break;
 }
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
+
 case tok::kw___sptr:
 case tok::kw___uptr:
 case tok::kw___ptr64:
@@ -3097,7 +3101,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   ParseMicrosoftTypeAttributes(DS.getAttributes());
   continue;
 
@@ -4791,6 +4794,10 @@
   ParseOpenCLQualifiers(DS.getAttributes());
   break;
 
+case tok::kw___unaligned:
+  isInvalid = DS.SetTypeQual(DeclSpec::TQ_unaligned, Loc, PrevSpec, DiagID,
+ getLangOpts());
+  break;
 case tok::kw___uptr:
   // GNU libc headers in C mode use '__uptr' as an identifer which conflicts
   // with the MS modifier keyword.
@@ -4808,7 +4815,6 @@
 case tok::kw___fastcall:
 case tok::kw___thiscall:
 case tok::kw___vectorcall:
-case tok::kw___unaligned:
   if (AttrReqs & AR_DeclspecAttributesParsed) {
 ParseMicrosoftTypeAttributes(DS.getAttributes());
 continue;
@@ -5031,7 +5037,8 @@
 DS.getConstSpecLoc(),
 DS.getVolatileSpecLoc(),
 DS.getRestrictSpecLoc(),
-DS.getAtomicSpecLoc()),
+DS.getAtomicSpecLoc(),
+DS.getUnalignedSpecLoc()),
 DS.getAttributes(),
 SourceLocation());
 else
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -833,7 +833,7 @@
   // '(' abstract-declarator ')'
   if (Tok.isOneOf(tok::kw___attribute, tok::kw___declspec, tok::kw___cdecl,
   tok::kw___stdcall, tok::kw___fastcall, tok::kw___thiscall,
-  tok::kw___vectorcall, tok::kw___unaligned))
+  tok::kw___vectorcall))
 return TPResult::True; // attributes indicate declaration
   TPResult TPR = TryParseDeclarator(mayBeAbstract, mayHaveIdentifier);
   if (TPR != TPResult::Ambiguous)
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1446,6 +1446,9 @@
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
 }
 
 void MicrosoftCXXNameMangler::manglePointerCVQualifiers(Qualifiers Quals) {
@@ -1577,6 +1580,8 @@
 }
 break;
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';
   mangleQualifiers(Quals, false);
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -1592,6 +1592,12 @@
 AppendTypeQualList(OS, quals, Policy.LangOpts.C99);
 addSpace = true;
   }
+  if (hasUnaligned()) {
+if (addSpace)
+  OS << ' ';
+OS << "__unaligned";
+addSpace = true;
+  }
   if (unsigned addrspace = getAddressSpace()) {
 if (addSpace)
   OS << ' ';
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.c

Re: [PATCH] D19654: PR27132: Proper mangling for __unaligned qualifier (now with PR27367 fixed)

2016-04-29 Thread Andrey Bokhanko via cfe-commits
andreybokhanko marked 3 inline comments as done.
andreybokhanko added a comment.

David, thank you for the review!

In http://reviews.llvm.org/D19654#416408, @majnemer wrote:

> It would be good to have a test for the variable template case:
>
>   template 
>   T x;
>  
>   auto g() { return x; }
>
>
> should mangle to `??$x@PEFAH@@3PEFAHEFA`


It mangles exaclty to `??$x@PEFAH@@3PEFAHEFA` (in 64 bit mode). Test added.



Comment at: lib/AST/MicrosoftMangle.cpp:1446-1451
@@ -1445,5 +1445,8 @@
 Out << 'E';
 
   if (HasRestrict)
 Out << 'I';
+
+  if (!PointeeType.isNull() && PointeeType.getLocalQualifiers().hasUnaligned())
+Out << 'F';
 }

Good catch!

Indeed, __restrict and __unaligned are mangled in a different order. Fixed; 
test added.


Comment at: lib/AST/MicrosoftMangle.cpp:1583-1585
@@ -1579,3 +1582,5 @@
   case QMM_Result:
+// Presence of __unaligned qualifier shouldn't affect mangling here.
+Quals.removeUnaligned();
 if ((!IsPointer && Quals) || isa(T)) {
   Out << '?';

Done. Test added.


http://reviews.llvm.org/D19654



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


Re: [PATCH] D19720: [find-all-symbols] Parallelize the merge step.

2016-04-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268037: [find-all-symbols] Parallelize the merge step. 
(authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D19720?vs=55577&id=55589#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19720

Files:
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Index: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -76,26 +77,38 @@
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
   std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+UniqueSymbols.insert(Symbols.begin(), Symbols.end());
+  };
+
   // Load all symbol files in MergeDir.
-  for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
-   Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
+  {
+llvm::ThreadPool Pool;
+for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
+ Dir != DirEnd && !EC; Dir.increment(EC)) {
+  // Parse YAML files in parallel.
+  Pool.async(
+  [&AddSymbols](std::string Path) {
+auto Buffer = llvm::MemoryBuffer::getFile(Path);
+if (!Buffer) {
+  llvm::errs() << "Can't open " << Path << "\n";
+  return;
+}
+std::vector Symbols =
+ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+// FIXME: Merge without creating such a heavy contention point.
+AddSymbols(Symbols);
+  },
+  Dir->path());
 }
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols =
-ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
-for (const auto &Symbol : Symbols)
-  UniqueSymbols.insert(Symbol);
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
   if (EC) {
-llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+llvm::errs() << "Can't open '" << OutputFile << "': " << EC.message()
  << '\n';
 return false;
   }


Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -76,26 +77,38 @@
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
   std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+UniqueSymbols.insert(Symbols.begin(), Symbols.end());
+  };
+
   // Load all symbol files in MergeDir.
-  for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
-   Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
+  {
+llvm::ThreadPool Pool;
+for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
+ Dir != DirEnd && !EC; Dir.increment(EC)) {
+  // Parse YAML files in parallel.
+  Pool.async(
+  [&AddSymbols](std::string Path) {
+auto Buffer = llvm::MemoryBuffer::getFile(Path);
+if (!Buffer) {
+  llvm::errs() << "Can't open " << Path << "\n";
+  return;
+}
+std::vector Symbols =
+ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+// FIXME: Merge without creating such a heavy contention point.
+AddSymbols(Symbols);
+  },
+  Dir->path());
 }
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols 

[clang-tools-extra] r268037 - [find-all-symbols] Parallelize the merge step.

2016-04-29 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Apr 29 07:46:27 2016
New Revision: 268037

URL: http://llvm.org/viewvc/llvm-project?rev=268037&view=rev
Log:
[find-all-symbols] Parallelize the merge step.

There is still more parallelism to get here because we synchonize on the
actual uniquing but just doing YAML parsing in parallel already gives a
significant speedup.

Merging all symbols in LLVM+clang+compiler-rt+lld+libc++, 48 cores.
before: 201.55s user 1.47s system 99% cpu 3:23.04 total
after:  276.99s user 7.63s system 838% cpu 33.947 total

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

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp?rev=268037&r1=268036&r2=268037&view=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/tool/FindAllSymbolsMain.cpp
 Fri Apr 29 07:46:27 2016
@@ -14,8 +14,9 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Path.h"
-
+#include "llvm/Support/ThreadPool.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -76,26 +77,38 @@ private:
 bool Merge(llvm::StringRef MergeDir, llvm::StringRef OutputFile) {
   std::error_code EC;
   std::set UniqueSymbols;
+  std::mutex SymbolMutex;
+  auto AddSymbols = [&](ArrayRef Symbols) {
+// Synchronize set accesses.
+std::unique_lock LockGuard(SymbolMutex);
+UniqueSymbols.insert(Symbols.begin(), Symbols.end());
+  };
+
   // Load all symbol files in MergeDir.
-  for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
-   Dir != DirEnd && !EC; Dir.increment(EC)) {
-int ReadFD = 0;
-if (llvm::sys::fs::openFileForRead(Dir->path(), ReadFD)) {
-  llvm::errs() << "Cann't open " << Dir->path() << "\n";
-  continue;
+  {
+llvm::ThreadPool Pool;
+for (llvm::sys::fs::directory_iterator Dir(MergeDir, EC), DirEnd;
+ Dir != DirEnd && !EC; Dir.increment(EC)) {
+  // Parse YAML files in parallel.
+  Pool.async(
+  [&AddSymbols](std::string Path) {
+auto Buffer = llvm::MemoryBuffer::getFile(Path);
+if (!Buffer) {
+  llvm::errs() << "Can't open " << Path << "\n";
+  return;
+}
+std::vector Symbols =
+ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
+// FIXME: Merge without creating such a heavy contention point.
+AddSymbols(Symbols);
+  },
+  Dir->path());
 }
-auto Buffer = llvm::MemoryBuffer::getOpenFile(ReadFD, Dir->path(), -1);
-if (!Buffer)
-  continue;
-std::vector Symbols =
-ReadSymbolInfosFromYAML(Buffer.get()->getBuffer());
-for (const auto &Symbol : Symbols)
-  UniqueSymbols.insert(Symbol);
   }
 
   llvm::raw_fd_ostream OS(OutputFile, EC, llvm::sys::fs::F_None);
   if (EC) {
-llvm::errs() << "Cann't open '" << OutputFile << "': " << EC.message()
+llvm::errs() << "Can't open '" << OutputFile << "': " << EC.message()
  << '\n';
 return false;
   }


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


Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-29 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

This turns out to be a bit of a mess: Alias and NoDebug use the same diagnostic 
kind text, neither of which match the actual subject list. Alias doesn't 
appertain to an obj-c method or property. NoDebug doesn't appertain to an obj-c 
property. The diagnostic text for that diagnostic kind doesn't match the 
subject list it is describing in either case. And the diagnostic text talks 
about "global variables" when what it really means are "variables that have 
global *storage*" and so static storage duration is a bit more accurate than 
"global variable" which implies that the following should diagnose:

  void f() {
static int i __attribute__((nodebug));
  }

I have a WIP patch (http://reviews.llvm.org/D18768) that will hopefully make 
this situation better. Your current changes will add a bit of overhead to my 
refactoring, but it's a drop in the bucket compared to the other diagnostic 
wording changes, so I'm not overly concerned. I think the patch LGTM despite my 
comments.



Comment at: include/clang/Basic/Attr.td:977
@@ -976,1 +976,3 @@
+  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
+  "ExpectedFunctionGlobalVarMethodOrProperty">;
   let Documentation = [NoDebugDocs];

It's really strange that the diagnostic kind is 
`ExpectedFunctionGlobalVarMethodOrProperty` but the subject list does not have 
objective-c properties. It's even more strange that this diagnostic kind 
corresponds to the diagnostic text "functions and global variables" without 
mention of objective-c methods or properties. I see that the Alias attribute 
suffers from this same discombobulation.


Comment at: test/Sema/attr-nodebug.c:6
@@ -5,3 +5,3 @@
 void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies 
to variables with static storage duration and functions}}
+  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute 
only applies to functions and global variables}}
 }

Global variables is a misnomer though since this really applies to variables 
with static storage duration (including local variables).


http://reviews.llvm.org/D19689



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-04-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55593.
rmaprath added a comment.

Added missing `__confg` header include.


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,89 +23,67 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
+int ec = __libcpp_recursive_mutex_init(&__m_);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __libcpp_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __libcpp_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +143,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__libcpp_thread_id_equal(id, __id_))
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +161,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +195,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static mutex mut;
+static condition_variable cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +225,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+unique_lock lk(mut);
 while (flag == 1)
-pthread_cond_wait(&cv, &mut);
+cv.wait(lk);
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(&flag, 1ul);
-pthread_mutex_unlock(&mut);
+lk.unlock();
 func(arg);
-pthread_mutex_lock(&mut);
+lk.lock();
 __libcpp_relaxed_store(&flag, ~0ul);
-pthread_mutex_u

Re: [PATCH] D19322: Concepts: Create space for requires-clause in TemplateParameterList; NFC

2016-04-29 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:175
@@ -152,2 +174,3 @@
+  Expr *RequiresClause;
 
 public:

faisalv wrote:
> Yuk - this entire guy (FizedSizeTemplateParameterListStorage) seems quite 
> fragile (dependent on object layout) - are the gains (in the single use below 
> during auto-type deduction) in preformance really worth the introduction of 
> this fragility/ugliness? 
> Unless there is a clear win from this strategy, I think i'd favor (perhaps in 
> a later patch) - either just removing this structure and using TPL for the 
> use-case in auto-type below, or using placement new and creating the stack 
> TPL on a stack unsigned char array?
> Thoughts?
> 
I don't like the class here either; however, I would not like to introduce heap 
allocation just to remove it. placement-new is certainly part of the solution. 
I think that `TrailingObjects` should have an alias for a type that can be used 
as aligned storage (templated in the style of `totalSizeToAlloc`). I would like 
to keep that endeavour to a separate patch though.


http://reviews.llvm.org/D19322



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


Re: [PATCH] D19665: [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

2016-04-29 Thread Tim Northover via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a reviewer: t.p.northover.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks for updating the patch.

Tim.


http://reviews.llvm.org/D19665



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


Re: [PATCH] D19183: [clang-tidy] Add modernize-make-shared check

2016-04-29 Thread Piotr Padlewski via cfe-commits
Prazek added a subscriber: alexfh.
Prazek added a comment.

ping.
@alexfh are you planning to take a look?


http://reviews.llvm.org/D19183



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


r268047 - [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

2016-04-29 Thread Silviu Baranga via cfe-commits
Author: sbaranga
Date: Fri Apr 29 10:03:32 2016
New Revision: 268047

URL: http://llvm.org/viewvc/llvm-project?rev=268047&view=rev
Log:
[ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by 
testing __ARM_FP

Summary:
Conversions between float and half are only available when the
taraget has the half-precision extension. Guard these intrinsics
so that they don't cause crashes in the backend.

Fixes PR27550.

Reviewers: rengolin, t.p.northover

Subscribers: cfe-commits, aemerson, t.p.northover, rengolin

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

Added:
cfe/trunk/test/Sema/arm-no-fp16.c
Modified:
cfe/trunk/include/clang/Basic/arm_neon.td

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=268047&r1=268046&r2=268047&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Fri Apr 29 10:03:32 2016
@@ -704,8 +704,10 @@ def VGET_LOW  : NoTestOpInst<"vget_low",
 

 // E.3.22 Converting vectors
 
-def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
-def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+let ArchGuard = "(__ARM_FP & 2)" in {
+  def VCVT_F16_F32 : SInst<"vcvt_f16_f32", "md", "Hf">;
+  def VCVT_F32_F16 : SInst<"vcvt_f32_f16", "wd", "h">;
+}
 
 def VCVT_S32 : SInst<"vcvt_s32", "xd",  "fQf">;
 def VCVT_U32 : SInst<"vcvt_u32", "ud",  "fQf">;

Added: cfe/trunk/test/Sema/arm-no-fp16.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/arm-no-fp16.c?rev=268047&view=auto
==
--- cfe/trunk/test/Sema/arm-no-fp16.c (added)
+++ cfe/trunk/test/Sema/arm-no-fp16.c Fri Apr 29 10:03:32 2016
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple thumbv7-none-eabi %s -target-feature +neon 
-target-feature -fp16 -fsyntax-only -verify
+
+#include 
+
+float16x4_t test_vcvt_f16_f32(float32x4_t a) {
+  return vcvt_f16_f32(a); // expected-warning{{implicit declaration of 
function 'vcvt_f16_f32'}}  expected-error{{returning 'int' from a function with 
incompatible result type 'float16x4_t'}}
+}
+
+float32x4_t test_vcvt_f32_f16(float16x4_t a) {
+  return vcvt_f32_f16(a); // expected-warning{{implicit declaration of 
function 'vcvt_f32_f16'}} expected-error{{returning 'int' from a function with 
incompatible result type 'float32x4_t'}}
+}


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


Re: [PATCH] D19665: [ARM] Guard the declarations of f16 to f32 vcvt intrinsics in arm_neon.h by testing __ARM_FP

2016-04-29 Thread silviu.bara...@arm.com via cfe-commits
sbaranga added a comment.

Thanks, r268047!

Cheers,
Silviu


http://reviews.llvm.org/D19665



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


Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-04-29 Thread Yaxun Liu via cfe-commits
yaxunl updated this revision to Diff 55600.
yaxunl added a comment.

Add defining macro cl_khr_ for supported extensions or optional core features.

Enable supported extensions or optional core features only if it is available 
in the OpenCL version the program is compiled with.

Add spir triple to tests using extensions.

Generated  full diffs.


http://reviews.llvm.org/D19484

Files:
  include/clang/Basic/LangOptions.h
  include/clang/Basic/OpenCLExtensions.def
  include/clang/Basic/OpenCLOptions.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TargetOptions.h
  lib/Basic/Targets.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Parse/ParsePragma.cpp
  lib/Sema/Sema.cpp
  test/CodeGenOpenCL/builtins-r600.cl
  test/CodeGenOpenCL/fpmath.cl
  test/CodeGenOpenCL/half.cl
  test/Lexer/opencl-half-literal.cl
  test/Misc/languageOptsOpenCL.cl
  test/PCH/opencl-extensions.cl
  test/Parser/opencl-astype.cl
  test/Parser/opencl-atomics-cl20.cl
  test/Parser/opencl-pragma.cl
  test/Parser/opencl-storage-class.cl
  test/SemaOpenCL/extension-fp64-cl1.1.cl
  test/SemaOpenCL/extension-fp64.cl
  test/SemaOpenCL/extensions.cl
  test/SemaOpenCL/half.cl
  test/SemaOpenCL/invalid-kernel-parameters.cl
  test/SemaOpenCL/invalid-logical-ops-1.2.cl
  test/SemaOpenCL/optional-core-fp64-cl1.2.cl
  test/SemaOpenCL/optional-core-fp64-cl2.0.cl

Index: test/SemaOpenCL/optional-core-fp64-cl2.0.cl
===
--- test/SemaOpenCL/optional-core-fp64-cl2.0.cl
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
-// expected-no-diagnostics
-
-void f1(double da) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-void f2(void) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : disable
-
-void f3(void) {
-  double d;
-}
Index: test/SemaOpenCL/optional-core-fp64-cl1.2.cl
===
--- test/SemaOpenCL/optional-core-fp64-cl1.2.cl
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// expected-no-diagnostics
-
-void f1(double da) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
-
-void f2(void) {
-  double d;
-  (void) 1.0;
-}
-
-#pragma OPENCL EXTENSION cl_khr_fp64 : disable
-
-void f3(void) {
-  double d;
-}
Index: test/SemaOpenCL/invalid-logical-ops-1.2.cl
===
--- test/SemaOpenCL/invalid-logical-ops-1.2.cl
+++ test/SemaOpenCL/invalid-logical-ops-1.2.cl
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple x86_64-unknown-linux-gnu
 
-#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable // expected-warning{{unknown OpenCL extension 'cl_khr_fp64' - ignoring}}
+
 typedef __attribute__((ext_vector_type(4))) float float4;
 typedef __attribute__((ext_vector_type(4))) double double4;
 typedef __attribute__((ext_vector_type(4))) int int4;
Index: test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- test/SemaOpenCL/invalid-kernel-parameters.cl
+++ test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple spir-unknown-unknown
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
Index: test/SemaOpenCL/half.cl
===
--- test/SemaOpenCL/half.cl
+++ test/SemaOpenCL/half.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
Index: test/SemaOpenCL/extensions.cl
===
--- /dev/null
+++ test/SemaOpenCL/extensions.cl
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
+
+// Test with a target not supporting fp64.
+// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64
+
+void f1(double da) { // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  double d; // expected-error {{type 'double' requires cl_khr_fp64 extension}}
+  (void) 1.0; // expected-warning {{double precision constant requires cl_khr_fp64}}
+}
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#ifdef NOFP64
+// expected-warning@-2{{unknown OpenCL extension 'cl_khr_fp64' - ignoring}}
+#endif
+
+void f2(void) {
+  double d;
+#ifdef NOFP64
+// expected-error@-2{{use of type 'double' requires cl_khr_fp64 extension to 

Re: [PATCH] D19679: Method pool in modules: sync up out of date selectors before writing the module

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

Adrian,

Thanks for reviewing the patch!

Manman



Comment at: include/clang/Serialization/ASTReader.h:657
@@ +656,3 @@
+  /// Whether a selector is out of date. We mark a selector as out of date
+  // if we load another module after the method pool entry was pulled in.
+  llvm::DenseMap SelectorOutOfDate;

aprantl wrote:
> ///
Yes.


Comment at: test/Modules/method_pool_write.m:3
@@ +2,3 @@
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs %s -verify
+// expected-no-diagnostics
+

aprantl wrote:
> Is there anything meaningful that could be CHECKed in the output?
This commit makes sure that we don't emit an error message for not being able 
to find the method. That is why it checks for no diagnostics. Maybe I should 
use -fsyntax-only?


http://reviews.llvm.org/D19679



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


Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-29 Thread David Blaikie via cfe-commits
On Thu, Apr 28, 2016 at 4:46 PM, Robinson, Paul 
wrote:

> Generally tests test something other than "this program doesn't crash" -
> should it test that we apply the attribute correctly? (either via ast dump,
> or checking the resulting DWARF doesn't have debug info on the relevant
> entity)
>
> Or is this not actually a new/separate codepath? In which case do we
> really need the test?
>
>
>
> It's a –verify test which is about diagnostics, rather than not-crashing.
> It parallels line 3 of Sema/attr-nodebug.c, which verifies the attribute
> can be applied to a function.  Without this test, you could remove
> "ObjCMethod" from the Subjects line and no test would fail.  I put
> "ObjCMethod" on the Subjects line because the hand-coded condition used
> "isFunctionOrMethod" which permits Objective-C methods.  The new test
> passes with old and new compilers, demonstrating the NFC claim.
>

Ah, OK - thanks for the context :)


>
>
> Now, if we decide the 'nodebug' attribute should not apply to Objective-C,
> that's fine with me, in which case the new test should verify that a
> diagnostic *is* produced.
>
>
>
> I am admittedly clueless about Objective-C, are they handled differently
> from other functions by the time we get to CGDebugInfo?  If there's another
> path I should tweak, I'd like to know about it.
>
> Thanks,
>
> --paulr
>
>
>
> *From:* David Blaikie [mailto:dblai...@gmail.com]
> *Sent:* Thursday, April 28, 2016 4:26 PM
> *To:* reviews+d19689+public+514682b5314c5...@reviews.llvm.org; Robinson,
> Paul
> *Cc:* Aaron Ballman; cfe-commits
> *Subject:* Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]
>
>
>
> LGTM
>
>
>
> On Thu, Apr 28, 2016 at 2:10 PM, Paul Robinson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> probinson created this revision.
> probinson added a reviewer: aaron.ballman.
> probinson added a subscriber: cfe-commits.
>
> The 'nodebug' attribute had hand-coded constraints; replace those with a
> Subjects line in Attr.td.
> Also add a missing test to verify the attribute is okay on an Objective-C
> method.
>
> http://reviews.llvm.org/D19689
>
> Files:
>   include/clang/Basic/Attr.td
>   include/clang/Basic/DiagnosticSemaKinds.td
>   lib/Sema/SemaDeclAttr.cpp
>   test/Sema/attr-nodebug.c
>   test/SemaObjC/attr-nodebug.m
>
> Index: test/SemaObjC/attr-nodebug.m
> ===
> --- test/SemaObjC/attr-nodebug.m
> +++ test/SemaObjC/attr-nodebug.m
> @@ -0,0 +1,5 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +// expected-no-diagnostics
> +@interface NSObject
> +- (void)doSomething __attribute__((nodebug));
> +@end
>
>
>
> Generally tests test something other than "this program doesn't crash" -
> should it test that we apply the attribute correctly? (either via ast dump,
> or checking the resulting DWARF doesn't have debug info on the relevant
> entity)
>
> Or is this not actually a new/separate codepath? In which case do we
> really need the test?
>
>
>
> Index: test/Sema/attr-nodebug.c
> ===
> --- test/Sema/attr-nodebug.c
> +++ test/Sema/attr-nodebug.c
> @@ -3,7 +3,7 @@
>  int a __attribute__((nodebug));
>
>  void b() {
> -  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only
> applies to variables with static storage duration and functions}}
> +  int b __attribute__((nodebug)); // expected-warning {{'nodebug'
> attribute only applies to functions and global variables}}
>  }
>
>  void t1() __attribute__((nodebug));
> Index: lib/Sema/SemaDeclAttr.cpp
> ===
> --- lib/Sema/SemaDeclAttr.cpp
> +++ lib/Sema/SemaDeclAttr.cpp
> @@ -3572,18 +3572,6 @@
>  }
>
>  static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList
> &Attr) {
> -  if (const VarDecl *VD = dyn_cast(D)) {
> -if (!VD->hasGlobalStorage())
> -  S.Diag(Attr.getLoc(),
> - diag::warn_attribute_requires_functions_or_static_globals)
> -<< Attr.getName();
> -  } else if (!isFunctionOrMethod(D)) {
> -S.Diag(Attr.getLoc(),
> -   diag::warn_attribute_requires_functions_or_static_globals)
> -  << Attr.getName();
> -return;
> -  }
> -
>D->addAttr(::new (S.Context)
>   NoDebugAttr(Attr.getRange(), S.Context,
>   Attr.getAttributeSpellingListIndex()));
> Index: include/clang/Basic/DiagnosticSemaKinds.td
> ===
> --- include/clang/Basic/DiagnosticSemaKinds.td
> +++ include/clang/Basic/DiagnosticSemaKinds.td
> @@ -2504,9 +2504,6 @@
>  def warn_incomplete_encoded_type : Warning<
>"encoding of %0 type is incomplete because %1 component has unknown
> encoding">,
>InGroup>;
> -def warn_attribute_requires_functions_or_static_globals : Warning<
> -  "%0 only applies to variables with static storage duration and
> functions">,
> -  InGroup;
>  def warn_gnu_inline_attribute_req

Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-04-29 Thread David Blaikie via cfe-commits
As mentioned in the bug, I /think/ the right thing to do here is to change
the preferred location of the CXXMemberCallExpr so that we improve
diagnostics as well. Any place where the preferred location of an
expression and the debug location of an expression are differing I'd really
like a pretty deep discussion of why those two uses cases should differ.

Eg, where this location turns up in diagnostics:

blaikie@blaikie-linux:~/dev$ cat loc.cpp
struct foo {
  const foo *x() const;
  void y();
};

void f(const foo *g) {
  g->x()->y();
  g->x()->x()->y();
}
blaikie@blaikie-linux:~/dev$ clang++-tot loc.cpp -fsyntax-only
loc.cpp:7:3: error: member function 'y' not viable: 'this' argument
has type 'const foo', but function is not marked const
  g->x()->y();
  ^~
...
loc.cpp:8:3: error: member function 'y' not viable: 'this' argument
has type 'const foo', but function is not marked const
  g->x()->x()->y();
  ^~~
...

It seems like pointing to the 'y' in both these cases would be an
improvement? The source range highlighting the 'this' part of the
expression is certainly helpful, but could still be confusing if the
functions had more similar/the same name, etc.



On Thu, Apr 28, 2016 at 8:42 PM, Hal Finkel via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> hfinkel created this revision.
> hfinkel added reviewers: rsmith, aprantl, dexonsmith, dblaikie, echristo.
> hfinkel added a subscriber: cfe-commits.
> Herald added subscribers: joker.eph, mcrosier.
>
> We currently generate debug info for member calls in the context of the
> call expression. For member calls, this has an odd effect, which becomes
> especially obvious when generating source locations for optimizer-feedback
> remarks regarding inlining.
>
> Given this:
>
>   $ cat -n /tmp/i.cpp
>  1  void ext();
>  2
>  3  struct Bar {
>  4void bar() { ext(); }
>  5  };
>  6
>  7  struct Foo {
>  8Bar *b;
>  9
> 10Bar *foo() { return b; }
> 11  };
> 12
> 13  void test(Foo *f) {
> 14f->foo()->bar();
> 15  }
>
>   $ clang -g /tmp/i.cpp -S -emit-llvm -o -
>
>   define void @_Z4testP3Foo(%struct.Foo* %f) #0 !dbg !6 {
> ...
> %call = call %struct.Bar* @_ZN3Foo3fooEv(%struct.Foo* %0), !dbg !27
> call void @_ZN3Bar3barEv(%struct.Bar* %call), !dbg !28
> ...
>   !27 = !DILocation(line: 14, column: 3, scope: !6)
>   !28 = !DILocation(line: 14, column: 3, scope: !29)
>
> but we want instead for the calls to point to the callee expressions
> (foo() and bar() in this case). With this change, that's what happens.
>
> Fixes PR27567.
>
> http://reviews.llvm.org/D19708
>
> Files:
>   lib/CodeGen/CGExprCXX.cpp
>   test/CodeGenCXX/debug-info-member-call.cpp
>
> Index: test/CodeGenCXX/debug-info-member-call.cpp
> ===
> --- /dev/null
> +++ test/CodeGenCXX/debug-info-member-call.cpp
> @@ -0,0 +1,24 @@
> +// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm
> -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
> +void ext();
> +
> +struct Bar {
> +  void bar() { ext(); }
> +};
> +
> +struct Foo {
> +  Bar *b;
> +
> +  Bar *foo() { return b; }
> +};
> +
> +void test(Foo *f) {
> +  f->foo()->bar();
> +}
> +
> +// CHECK-LABEL: @_Z4testP3Foo
> +// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
> +// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
> +
> +// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
> +// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
> +
> Index: lib/CodeGen/CGExprCXX.cpp
> ===
> --- lib/CodeGen/CGExprCXX.cpp
> +++ lib/CodeGen/CGExprCXX.cpp
> @@ -107,6 +107,10 @@
>ReturnValueSlot
> ReturnValue) {
>const Expr *callee = CE->getCallee()->IgnoreParens();
>
> +  // The debug information for the call instruction should point to the
> callee
> +  // expression.
> +  ApplyDebugLocation DL(*this, callee);
> +
>if (isa(callee))
>  return EmitCXXMemberPointerCallExpr(CE, ReturnValue);
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r267904 - Debug info: Apply an artificial debug location to __cyg_profile_func.* calls.

2016-04-29 Thread David Blaikie via cfe-commits
On Thu, Apr 28, 2016 at 4:42 PM, Adrian Prantl  wrote:

>
> On Apr 28, 2016, at 4:31 PM, David Blaikie  wrote:
>
>
>
> On Thu, Apr 28, 2016 at 1:11 PM, Adrian Prantl  wrote:
>
>>
>> On Apr 28, 2016, at 12:53 PM, David Blaikie  wrote:
>>
>>
>>
>> On Thu, Apr 28, 2016 at 12:50 PM, Adrian Prantl 
>> wrote:
>>
>>>
>>> On Apr 28, 2016, at 12:34 PM, David Blaikie  wrote:
>>>
>>> Should these have no/artificial location? It seems like perhaps they
>>> should have the same location as the scope they're for? (well, the
>>> beginning or end of that scope, respectively, etc)
>>>
>>>
>>> While there is usually a single source location for the beginning of the
>>> function, there can be more than one such location for the end of the
>>> function, so I don’t think this is generally possible.
>>>
>>
>> Seems to me like it would be - declare a variable with a non-trivial dtor
>> at the start of the function. Whichever line the dtor call is attributed
>> to, that's the end of the function. (I think we use the } for this, or
>> perhaps the final return statement if there is one and only one - I forget
>> the specifics)
>>
>>
>> Ah yes, I guess we could be using the cleanup location of the function
>> for this.
>>
>>
>>
>>> The artificial location unambiguously marks the function call as
>>> something that does not appear in source code. For a (terrible) example
>>> (given the nature of these function calls :-p) if you look at a profile you
>>> wouldn’t want these function calls to be misattributed to any line in the
>>> source code.
>>>
>>
>> I'm not quite sure what the ramifications of that would be/why that would
>> be bad (or good) - could you explain further?
>>
>>
>> If the compiler generates code that does not have any meaningful source
>> location (in this case one could argue that ‘{‘ and ‘}’ might be meaningful
>> source locations?) then I wouldn’t want that code to be attributed to a
>> source location just because the instructions immediately follow some
>> completely unrelated instructions that happen to have a source location.
>>
>
> Sorry, I meant specifically what would be the impact of giving it the
> non-artificial location (the same as the location of the cleanup code, as
> you noted), not the impact of not giving it a location at all.
>
>
>> - Profiling: It shouldn't show up in a profile counted towards the source
>> location of the instructions before it.
>> - Debugging: Since there is no source code for it a source-based debugger
>> (you can still switch to disassembly) should treat the function call as
>> transparent and skip over it as if it didn’t exist.
>>
>
> Much like the non-trivial dtor, just because the user didn't explicitly
> write the function call doesn't seem to me to mean it should be invisible.
>
>
> The user may not have written the call to the dtor, but the user did at
> least write the dtor itself; and there exists source code for it.
>

The user may not have written the dtor - it could be non-trivial but
implicit (eg: write a struct that contains a std::string member (yes, the
std::string's dtor is user-defined, but the struct's dtor is not)).


>
> The profiling argument sort of makes sense to me - but it's going to be
> attributed to /something/, right? (& wait - aren't these functions the
> profiling mechanisms themselves for counter based (rather than sample
> based) profiling?
>
>
> Yes they are, that’s why I said at the beginning that this example was a
> terrible one :-)
>
> Do people sample /and/ counter profile the same binary?)
>
>
> Hopefully not. This was really just meant as an example why someone would
> choose an artificial location over a concrete one in similar situations. In
> the end, I’m not particularly attached to using the artificial location
> here, but these were the reasons that made me opt for an artificial
> location here.
>
> -- adrian
>
>
> - Dave
>
>
>>
>> -- adrian
>>
>>
>> - Dave
>>
>>
>>>
>>> -- adrian
>>>
>>>
>>> On Thu, Apr 28, 2016 at 10:21 AM, Adrian Prantl via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: adrian
 Date: Thu Apr 28 12:21:56 2016
 New Revision: 267904

 URL: http://llvm.org/viewvc/llvm-project?rev=267904&view=rev
 Log:
 Debug info: Apply an artificial debug location to __cyg_profile_func.*
 calls.
 The LLVM Verifier expects all inlinable calls in debuggable functions to
 have a location.

 rdar://problem/25818489

 Modified:
 cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 cfe/trunk/test/CodeGen/instrument-functions.c

 Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=267904&r1=267903&r2=267904&view=diff

 ==
 --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Apr 28 12:21:56 2016
 @@ -401,

Re: [PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

2016-04-29 Thread Filipe Cabecinhas via cfe-commits
filcab updated this revision to Diff 55605.
filcab marked 2 inline comments as done.
filcab added a comment.

Addressed Richard's comments.
Waiting on http://reviews.llvm.org/D19724 (operator- on Path's 
reverse_iterator) before landing this.


http://reviews.llvm.org/D19666

Files:
  docs/UndefinedBehaviorSanitizer.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGExpr.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ubsan-strip-path-components.cpp
  test/Driver/fubsan-strip-path-components.cpp

Index: test/Driver/fubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/Driver/fubsan-strip-path-components.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang %s -### -o %t.o -fsanitize-undefined-strip-path-components=42 2>&1 | FileCheck %s
+// CHECK: "-fsanitize-undefined-strip-path-components=42"
Index: test/CodeGen/ubsan-strip-path-components.cpp
===
--- /dev/null
+++ test/CodeGen/ubsan-strip-path-components.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=0 | FileCheck %s -check-prefix=REGULAR -check-prefix=CHECK
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=2 | FileCheck %s -check-prefix=REMOVE-FIRST-TWO -check-prefix=CHECK
+// We can't easily check stripping one or two levels.
+
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-9 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=9 | FileCheck %s -check-prefix=LAST-ONLY
+
+// Check stripping from the file name
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-2 | FileCheck %s -check-prefix=LAST-TWO
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-1 | FileCheck %s -check-prefix=LAST-ONLY
+
+// REGULAR: @[[SRC:[0-9.a-zA-Z_]+]] =  private unnamed_addr constant [{{.*}} x i8] c"{{.*test.CodeGen.ubsan-strip-path-components\.cpp}}\00", align 1
+
+// We have an optional space in the regex in the next line because the }} eagerly closes the regex
+// REMOVE-FIRST-TWO: @[[STR:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"{{([^\\/]*)?(.[^\\/]+).}}[[REST:.*ubsan-strip-path-components\.cpp]]\00", align 1
+// REMOVE-FIRST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"[[REST]]\00", align 1
+
+// LAST-TWO: @[[SRC:[0-9.a-zA-Z_]+]] = private unnamed_addr constant [{{.*}} x i8] c"CodeGen{{.}}ubsan-strip-path-components.cpp\00", align 1
+// LAST-ONLY: @[[SRC:[0-9.a-zA-Z_]+]] =private unnamed_addr constant [{{.*}} x i8] c"ubsan-strip-path-components.cpp\00", align 1
+
+// CHECK: @[[STATIC_DATA:[0-9.a-zA-Z_]+]] = private unnamed_addr global { { [{{.*}} x i8]*, i32, i32 } } { { [{{.*}} x i8]*, i32, i32 } { [{{.*}} x i8]* @[[SRC]], i32 [[@LINE+6]], i32 3 } }
+void g(const char *);
+void f() {
+  // CHECK-LABEL: @_Z1fv(
+  g(__FILE__);
+  // CHECK: call void @__ubsan_handle_builtin_unreachable(i8* bitcast ({ { [{{.*}} x i8]*, i32, i32 } }* @[[STATIC_DATA]] to i8*)) {{.*}}, !nosanitize
+  __builtin_unreachable();
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,9 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.EmitCheckPathComponentsToStrip = getLastArgIntValue(
+  Args, OPT_fsanitize_undefined_strip_path_components_EQ, 0, Diags);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5595,6 +5595,10 @@
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(
+  options::OPT_fsanitize_undefined_strip_path_components_EQ))
+A->render(Args, CmdArgs);
+
   // -fdollars-in-identifiers default varies depending on platform and
   // language; only pass if specified.
   if (Arg *A = Args.getLastArg(options::OPT_fdollars_in_identifiers,
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -32,6 +32,7 @@
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Transforms/Utils/San

[PATCH] D19725: [Coverage] Fix an issue where a coverage region might not be created for a macro containing for or while statements.

2016-04-29 Thread Igor Kudrin via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: bogner, davidxl, vsk.
ikudrin added a subscriber: cfe-commits.

The situation happened when a macro contained a full loop statement,
which body ended at the end of the macro.

http://reviews.llvm.org/D19725

Files:
  lib/CodeGen/CoverageMappingGen.cpp
  test/CoverageMapping/macroscopes.cpp

Index: test/CoverageMapping/macroscopes.cpp
===
--- test/CoverageMapping/macroscopes.cpp
+++ test/CoverageMapping/macroscopes.cpp
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
+// CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
+// CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
+// CHECK-NEXT: File 15, 32:17 -> 34:4 = #11
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -443,15 +443,30 @@
 return ExitCount;
   }
 
+  /// \brief Check whether a region with bounds \c StartLoc and \c EndLoc
+  /// is already added to \c SourceRegions.
+  bool isRegionAlreadyAdded(SourceLocation StartLoc, SourceLocation EndLoc) {
+return SourceRegions.rend() !=
+   std::find_if(SourceRegions.rbegin(), SourceRegions.rend(),
+[=](const SourceMappingRegion &Region) {
+  assert(Region.hasStartLoc() && "incomplete region");
+  assert(Region.hasEndLoc() && "incomplete region");
+  return Region.getStartLoc() == StartLoc &&
+ Region.getEndLoc() == EndLoc;
+});
+  }
+
   /// \brief Adjust the most recently visited location to \c EndLoc.
   ///
   /// This should be used after visiting any statements in non-source order.
   void adjustForOutOfOrderTraversal(SourceLocation EndLoc) {
 MostRecentLocation = EndLoc;
 // Avoid adding duplicate regions if we have a completed region on the top
-// of the stack and are adjusting to the end of a virtual file.
+// of the stack.
 if (getRegion().hasEndLoc() &&
-MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation))
+MostRecentLocation == getEndOfFileOrMacro(MostRecentLocation) &&
+isRegionAlreadyAdded(getStartOfFileOrMacro(MostRecentLocation),
+ MostRecentLocation))
   MostRecentLocation = getIncludeOrExpansionLoc(MostRecentLocation);
   }
 


Index: test/CoverageMapping/macroscopes.cpp
===
--- test/CoverageMapping/macroscopes.cpp
+++ test/CoverageMapping/macroscopes.cpp
@@ -22,6 +22,17 @@
 #define starts_a_while while (x < 5)
 #define simple_stmt ++x
 
+#define macro_with_for  \
+  x = 3;\
+  for (int i = 0; i < x; ++i) { \
+  }
+
+#define macro_with_while \
+  x = 4; \
+  while (x < 5) {\
+++x; \
+  }
+
 // CHECK: main
 // CHECK-NEXT: File 0, [[@LINE+1]]:12 -> {{[0-9]+}}:2 = #0
 int main() {
@@ -64,6 +75,11 @@
 simple_stmt;
   ends_a_scope
 
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:17 = #0
+  macro_with_for
+  // CHECK-NEXT: Expansion,File 0, [[@LINE+1]]:3 -> [[@LINE+1]]:19 = #0
+  macro_with_while
+
   return 0;
 }
 
@@ -103,3 +119,10 @@
 // CHECK-NEXT: File 11, 22:31 -> 22:36 = (#0 + #9)
 // CHECK-NEXT: File 12, 23:21 -> 23:24 = #9
 // CHECK-NEXT: File 13, 6:3 -> 7:4 = #9
+// CHECK-NEXT: File 14, 26:3 -> 28:4 = #0
+// CHECK-NEXT: File 14, 27:19 -> 27:24 = (#0 + #10)
+// CHECK-NEXT: File 14, 27:26 -> 27:29 = #10
+// CHECK-NEXT: File 14, 27:31 -> 28:4 = #10
+// CHECK-NEXT: File 15, 31:3 -> 34:4 = #0
+// CHECK-NEXT: File 15, 32:10 -> 32:15 = (#0 + #11)
+// CHECK-NEXT: File 15, 32:17 -> 34:4 = #11
Index: lib/CodeGen/CoverageMappingGen.cpp
===
--- lib/CodeGen/CoverageMappingGen.cpp
+++ lib/CodeGen/CoverageMappingGen.cpp
@@ -443,15 +443,30 @@

[PATCH] D19727: [MS] Improved implementation #pragma pack (MS pragmas, part 2)

2016-04-29 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla created this revision.
d.zobnin.bugzilla added a reviewer: rnk.
d.zobnin.bugzilla added subscribers: thakis, cfe-commits.

An attempt to make implementation of #pragma pack consistent with other "stack" 
pragmas. Also modifies #pragma options align, since it shares the stack with 
#pragma pack.
It is the first item from todo list in http://reviews.llvm.org/D19361

The patch doesn't change compiler's behavior, so the tests are not modified.
I'm planning to rework the pragmas' diagnostics in next patch -- it should be a 
common feature of all "stack" pragmas.

http://reviews.llvm.org/D19727

Files:
  include/clang/Sema/Sema.h
  lib/Parse/ParsePragma.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaAttr.cpp

Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -337,11 +337,9 @@
 
 namespace {
 struct PragmaPackInfo {
-  Sema::PragmaPackKind Kind;
-  IdentifierInfo *Name;
+  Sema::PragmaMsStackAction Action;
+  StringRef SlotLabel;
   Token Alignment;
-  SourceLocation LParenLoc;
-  SourceLocation RParenLoc;
 };
 } // end anonymous namespace
 
@@ -356,8 +354,8 @@
 if (Alignment.isInvalid())
   return;
   }
-  Actions.ActOnPragmaPack(Info->Kind, Info->Name, Alignment.get(), PragmaLoc,
-  Info->LParenLoc, Info->RParenLoc);
+  Actions.ActOnPragmaPack(PragmaLoc, Info->Action, Info->SlotLabel,
+  Alignment.get());
 }
 
 void Parser::HandlePragmaMSStruct() {
@@ -962,11 +960,10 @@
 return;
   }
 
-  Sema::PragmaPackKind Kind = Sema::PPK_Default;
-  IdentifierInfo *Name = nullptr;
+  Sema::PragmaMsStackAction Action = Sema::PSK_Reset;
+  StringRef SlotLabel;
   Token Alignment;
   Alignment.startToken();
-  SourceLocation LParenLoc = Tok.getLocation();
   PP.Lex(Tok);
   if (Tok.is(tok::numeric_constant)) {
 Alignment = Tok;
@@ -976,18 +973,18 @@
 // In MSVC/gcc, #pragma pack(4) sets the alignment without affecting
 // the push/pop stack.
 // In Apple gcc, #pragma pack(4) is equivalent to #pragma pack(push, 4)
-if (PP.getLangOpts().ApplePragmaPack)
-  Kind = Sema::PPK_Push;
+Action =
+PP.getLangOpts().ApplePragmaPack ? Sema::PSK_Push_Set : Sema::PSK_Set;
   } else if (Tok.is(tok::identifier)) {
 const IdentifierInfo *II = Tok.getIdentifierInfo();
 if (II->isStr("show")) {
-  Kind = Sema::PPK_Show;
+  Action = Sema::PSK_Show;
   PP.Lex(Tok);
 } else {
   if (II->isStr("push")) {
-Kind = Sema::PPK_Push;
+Action = Sema::PSK_Push;
   } else if (II->isStr("pop")) {
-Kind = Sema::PPK_Pop;
+Action = Sema::PSK_Pop;
   } else {
 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_action) << "pack";
 return;
@@ -998,11 +995,12 @@
 PP.Lex(Tok);
 
 if (Tok.is(tok::numeric_constant)) {
+  Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
   Alignment = Tok;
 
   PP.Lex(Tok);
 } else if (Tok.is(tok::identifier)) {
-  Name = Tok.getIdentifierInfo();
+  SlotLabel = Tok.getIdentifierInfo()->getName();
   PP.Lex(Tok);
 
   if (Tok.is(tok::comma)) {
@@ -1013,6 +1011,7 @@
   return;
 }
 
+Action = (Sema::PragmaMsStackAction)(Action | Sema::PSK_Set);
 Alignment = Tok;
 
 PP.Lex(Tok);
@@ -1027,7 +1026,7 @@
 // In MSVC/gcc, #pragma pack() resets the alignment without affecting
 // the push/pop stack.
 // In Apple gcc #pragma pack() is equivalent to #pragma pack(pop).
-Kind = Sema::PPK_Pop;
+Action = Sema::PSK_Pop;
   }
 
   if (Tok.isNot(tok::r_paren)) {
@@ -1044,11 +1043,9 @@
 
   PragmaPackInfo *Info =
   PP.getPreprocessorAllocator().Allocate(1);
-  Info->Kind = Kind;
-  Info->Name = Name;
+  Info->Action = Action;
+  Info->SlotLabel = SlotLabel;
   Info->Alignment = Alignment;
-  Info->LParenLoc = LParenLoc;
-  Info->RParenLoc = RParenLoc;
 
   MutableArrayRef Toks(PP.getPreprocessorAllocator().Allocate(1),
   1);
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -79,12 +79,13 @@
 Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
 CollectStats(false), CodeCompleter(CodeCompleter),
 CurContext(nullptr), OriginalLexicalContext(nullptr),
-PackContext(nullptr), MSStructPragmaOn(false),
+MSStructPragmaOn(false),
 MSPointerToMemberRepresentationMethod(
 LangOpts.getMSPointerToMemberRepresentationMethod()),
 VtorDispStack(MSVtorDispAttr::Mode(LangOpts.VtorDispMode)),
-DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
-CodeSegStack(nullptr), CurInitSeg(nullptr), VisContext(nullptr),
+PackStack(0), DataSegStack(nullptr), BSSSegStack(nullptr),
+ConstSegStack(nullptr), CodeSegStack(n

Re: [PATCH] D19727: [MS] Improved implementation #pragma pack (MS pragmas, part 2)

2016-04-29 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla added inline comments.


Comment at: lib/Sema/SemaAttr.cpp:277-278
@@ -276,4 @@
-  // empty.
-  Diag(PragmaLoc, diag::warn_pragma_pop_failed)
-  << "pack" << (Name ? "no record matching name" : "stack empty");
-

Here I removed the "no record matching name" diagnostics, which wasn't covered 
by any test.
I'm going to rework and restore it in future patch.


http://reviews.llvm.org/D19727



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


Re: [PATCH] D19679: Method pool in modules: sync up out of date selectors before writing the module

2016-04-29 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.


Comment at: test/Modules/method_pool_write.m:3
@@ +2,3 @@
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs %s -verify
+// expected-no-diagnostics
+

manmanren wrote:
> aprantl wrote:
> > Is there anything meaningful that could be CHECKed in the output?
> This commit makes sure that we don't emit an error message for not being able 
> to find the method. That is why it checks for no diagnostics. Maybe I should 
> use -fsyntax-only?
Using -fsyntax-only and expected-no-diagnostics is fine, too. I was just 
wondering whether it might make sense (or is possible at all) to check that the 
method was indeed found in the emitted IR on top of that.


http://reviews.llvm.org/D19679



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


r268055 - Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM debug info."

2016-04-29 Thread Amjad Aboud via cfe-commits
Author: aaboud
Date: Fri Apr 29 11:08:08 2016
New Revision: 268055

URL: http://llvm.org/viewvc/llvm-project?rev=268055&view=rev
Log:
Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM 
debug info."
After fixing PR26942 in r267004.

Added:
cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268055&r1=268054&r2=268055&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 29 11:08:08 2016
@@ -814,15 +814,18 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
   llvm::DIFile *Unit) {
+  TypedefNameDecl *TD = Ty->getDecl();
   // We don't set size information, but do specify where the typedef was
   // declared.
-  SourceLocation Loc = Ty->getDecl()->getLocation();
+  SourceLocation Loc = TD->getLocation();
+
+  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));
 
   // Typedefs are derived from some other type.
   return DBuilder.createTypedef(
   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(Ty->getDecl()));
+  TDContext);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1457,6 +1460,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
   return T;
 }
 
+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
+  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
+ "D is already mapped to lexical block scope");
+  if (!LexicalBlockStack.empty())
+LexicalBlockMap[&D] = LexicalBlockStack.back();
+}
+
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
+   QualType Ty) {
+  auto I = LexicalBlockMap.find(&D);
+  if (I != LexicalBlockMap.end()) {
+RetainedTypes.push_back(Ty.getAsOpaquePtr());
+return I->second;
+  }
+  return getDeclContextDescriptor(cast(&D));
+}
+
 void CGDebugInfo::completeType(const EnumDecl *ED) {
   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
 return;
@@ -2060,7 +2080,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
 // entered into the ReplaceMap: finalize() will replace the first
 // FwdDecl with the second and then replace the second with
 // complete type.
-llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
+llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
 llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
 llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
 llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@@ -2104,7 +2124,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
 
   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
   unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
+  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
   llvm::DIType *ClassTy =
   ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@@ -2365,7 +2385,7 @@ llvm::DICompositeType *CGDebugInfo::Crea
   unsigned Line = getLineNumber(RD->getLocation());
   StringRef RDName = getClassName(RD);
 
-  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
+  llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));
 
   // If we ended up creating the type during the context chain construction,
   // just return that.
@@ -2536,8 +2556,15 @@ void CGDebugInfo::collectVarDeclProps(co
   if (DC->isRecord())
 DC = CGM.getContext().getTranslationUnitDecl();
 
- llvm::DIScope *Mod = getParentModuleOrNull(VD);
- VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
+  if (VD->isStaticLocal()) {
+// Get context for static locals (that are technically globals) the same 
way
+// we do for "local" locals -- by using current lexical block.
+assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack 
empty!");
+VDContext = LexicalBlockStack.back();
+  } else {
+llvm::DIScope *Mod = getParentModuleOrNull(VD);
+VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
+  }
 }
 
 llvm::DISubprogram *

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=268055&r1=268054&r2=268055&view=diff
=

Re: [PATCH] D19547: [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.

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


Comment at: clang-tidy/misc/StringConstructorCheck.cpp:110
@@ -106,2 +109,3 @@
   if (Result.Nodes.getNodeAs("swapped-parameter")) {
-diag(Loc, "constructor parameters are probably swapped");
+auto D = diag(Loc, "constructor parameters are probably swapped");
+

We could make the message slightly more specific by saying it's 
std::(basic_)?string constructor.


Comment at: clang-tidy/misc/StringConstructorCheck.cpp:115
@@ +114,3 @@
+StringRef Param1String =
+utils::create_fix_it::getSourceRangeAsString(Ctx, Param1);
+StringRef Param2String =

You should be able to use `Lexer::getSourceText` instead.


http://reviews.llvm.org/D19547



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


Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-04-29 Thread Hal Finkel via cfe-commits
hfinkel updated this revision to Diff 55610.
hfinkel added a comment.

Use David's suggested approach: Modify the preferred expression location for 
member calls. If the callee has a valid location (not all do), then use that. 
Otherwise, fall back to the starting location. This seems to cleanly fix the 
debug-info problem.


http://reviews.llvm.org/D19708

Files:
  include/clang/AST/ExprCXX.h
  test/CodeGenCXX/debug-info-member-call.cpp

Index: test/CodeGenCXX/debug-info-member-call.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-member-call.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm 
-debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -145,6 +145,14 @@
   /// FIXME: Returns 0 for member pointer call exprs.
   CXXRecordDecl *getRecordDecl() const;
 
+  SourceLocation getExprLoc() const LLVM_READONLY {
+SourceLocation CLoc = getCallee()->getExprLoc();
+if (CLoc.isValid())
+  return CLoc;
+
+return getLocStart();
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXMemberCallExprClass;
   }


Index: test/CodeGenCXX/debug-info-member-call.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-member-call.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
+void ext();
+
+struct Bar {
+  void bar() { ext(); }
+};
+
+struct Foo {
+  Bar *b;
+
+  Bar *foo() { return b; }
+};
+
+void test(Foo *f) {
+  f->foo()->bar();
+}
+
+// CHECK-LABEL: @_Z4testP3Foo
+// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
+// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
+
+// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
+// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
+
Index: include/clang/AST/ExprCXX.h
===
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -145,6 +145,14 @@
   /// FIXME: Returns 0 for member pointer call exprs.
   CXXRecordDecl *getRecordDecl() const;
 
+  SourceLocation getExprLoc() const LLVM_READONLY {
+SourceLocation CLoc = getCallee()->getExprLoc();
+if (CLoc.isValid())
+  return CLoc;
+
+return getLocStart();
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXMemberCallExprClass;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-29 Thread Paul Robinson via cfe-commits
probinson added a comment.

I'll proceed from here without doing anything about the inconsistencies, 
because this particular one should go away and you're already doing something 
about the rest of it.



Comment at: include/clang/Basic/Attr.td:977
@@ -976,1 +976,3 @@
+  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
+  "ExpectedFunctionGlobalVarMethodOrProperty">;
   let Documentation = [NoDebugDocs];

aaron.ballman wrote:
> It's really strange that the diagnostic kind is 
> `ExpectedFunctionGlobalVarMethodOrProperty` but the subject list does not 
> have objective-c properties. It's even more strange that this diagnostic kind 
> corresponds to the diagnostic text "functions and global variables" without 
> mention of objective-c methods or properties. I see that the Alias attribute 
> suffers from this same discombobulation.
I agree, but I didn't want to do anything about it because my next step is to 
replace GlobalVar with Var in the SubjectList, and therefore change the 
diagnostic enum to something else, making the inconsistency moot (at least for 
this attribute).



http://reviews.llvm.org/D19689



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


Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-29 Thread Aaron Ballman via cfe-commits
On Fri, Apr 29, 2016 at 12:24 PM, Paul Robinson  wrote:
> probinson added a comment.
>
> I'll proceed from here without doing anything about the inconsistencies, 
> because this particular one should go away and you're already doing something 
> about the rest of it.

I think that's a good idea. :-)

~Aaron

>
>
> 
> Comment at: include/clang/Basic/Attr.td:977
> @@ -976,1 +976,3 @@
> +  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
> +  "ExpectedFunctionGlobalVarMethodOrProperty">;
>let Documentation = [NoDebugDocs];
> 
> aaron.ballman wrote:
>> It's really strange that the diagnostic kind is 
>> `ExpectedFunctionGlobalVarMethodOrProperty` but the subject list does not 
>> have objective-c properties. It's even more strange that this diagnostic 
>> kind corresponds to the diagnostic text "functions and global variables" 
>> without mention of objective-c methods or properties. I see that the Alias 
>> attribute suffers from this same discombobulation.
> I agree, but I didn't want to do anything about it because my next step is to 
> replace GlobalVar with Var in the SubjectList, and therefore change the 
> diagnostic enum to something else, making the inconsistency moot (at least 
> for this attribute).
>
>
>
> http://reviews.llvm.org/D19689
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-04-29 Thread Eric Christopher via cfe-commits
Seems a much more principled solution yes.

On Fri, Apr 29, 2016, 9:19 AM Hal Finkel  wrote:

> hfinkel updated this revision to Diff 55610.
> hfinkel added a comment.
>
> Use David's suggested approach: Modify the preferred expression location
> for member calls. If the callee has a valid location (not all do), then use
> that. Otherwise, fall back to the starting location. This seems to cleanly
> fix the debug-info problem.
>
>
> http://reviews.llvm.org/D19708
>
> Files:
>   include/clang/AST/ExprCXX.h
>   test/CodeGenCXX/debug-info-member-call.cpp
>
> Index: test/CodeGenCXX/debug-info-member-call.cpp
> ===
> --- /dev/null
> +++ test/CodeGenCXX/debug-info-member-call.cpp
> @@ -0,0 +1,24 @@
> +// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm
> -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s
> +void ext();
> +
> +struct Bar {
> +  void bar() { ext(); }
> +};
> +
> +struct Foo {
> +  Bar *b;
> +
> +  Bar *foo() { return b; }
> +};
> +
> +void test(Foo *f) {
> +  f->foo()->bar();
> +}
> +
> +// CHECK-LABEL: @_Z4testP3Foo
> +// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]]
> +// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]]
> +
> +// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6,
> +// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13,
> +
> Index: include/clang/AST/ExprCXX.h
> ===
> --- include/clang/AST/ExprCXX.h
> +++ include/clang/AST/ExprCXX.h
> @@ -145,6 +145,14 @@
>/// FIXME: Returns 0 for member pointer call exprs.
>CXXRecordDecl *getRecordDecl() const;
>
> +  SourceLocation getExprLoc() const LLVM_READONLY {
> +SourceLocation CLoc = getCallee()->getExprLoc();
> +if (CLoc.isValid())
> +  return CLoc;
> +
> +return getLocStart();
> +  }
> +
>static bool classof(const Stmt *T) {
>  return T->getStmtClass() == CXXMemberCallExprClass;
>}
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

2016-04-29 Thread Eric Christopher via cfe-commits
echristo added a subscriber: echristo.
echristo added a comment.

Seems a much more principled solution yes.


http://reviews.llvm.org/D19708



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


Re: [PATCH] D19721: Fix crash in BuildCXXDefaultInitExpr.

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

lgtm



Comment at: test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp:6
@@ +5,3 @@
+template 
+struct B {
+

More reduced:
  template  struct A { int A = 0; };
  A a;



http://reviews.llvm.org/D19721



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


Re: [PATCH] D19590: Check for CERT ERR34-C. Detect errors when converting a string to a number

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

Looks good with a few nits.



Comment at: clang-tidy/cert/StrToNumCheck.cpp:182
@@ +181,3 @@
+void StrToNumCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *CE = Result.Nodes.getNodeAs("expr");
+  const FunctionDecl *FD = nullptr;

Too many abbreviations for my taste. How about CE -> Call, FD -> Function or 
FuncDecl, CK -> Conversion, CFD -> ConverterFunc?


Comment at: clang-tidy/cert/StrToNumCheck.cpp:224
@@ +223,3 @@
+
+  std::string ConversionPerformed = ClassifyConversionType(CK),
+  AlternateFunction = ClassifyReplacement(CK);

1. s/std::string/StringRef/
2. I'd make the functions return `StringRef` instead of a `const char *`
3. One variable per declaration, please.
4. I'm not sure the variables help making the code easier to read.


Comment at: docs/clang-tidy/checks/cert-err34-c.rst:9
@@ +8,3 @@
+does not flag calls to ``strtol()``, or other, related conversion functions 
that
+do perform better error checking.
+

Maybe add a couple of examples?


http://reviews.llvm.org/D19590



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


Re: r268055 - Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM debug info."

2016-04-29 Thread Pete Cooper via cfe-commits
Hi Amjad

Either this change, or r268054, appears to have broken the bots.  Can you 
please take a look?

The error at: 
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/22409/consoleFull#8333002949ba4694-19c4-4d7e-bec5-911270d8a58c
 


Thanks,
Pete
> On Apr 29, 2016, at 9:08 AM, Amjad Aboud via cfe-commits 
>  wrote:
> 
> Author: aaboud
> Date: Fri Apr 29 11:08:08 2016
> New Revision: 268055
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=268055&view=rev
> Log:
> Recommitted r264281 "Supporting all entities declared in lexical scope in 
> LLVM debug info."
> After fixing PR26942 in r267004.
> 
> Added:
>cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
> Modified:
>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>cfe/trunk/lib/CodeGen/CGDebugInfo.h
>cfe/trunk/lib/CodeGen/CGDecl.cpp
>cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268055&r1=268054&r2=268055&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 29 11:08:08 2016
> @@ -814,15 +814,18 @@ llvm::DIType *CGDebugInfo::CreateType(co
> 
> llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
>   llvm::DIFile *Unit) {
> +  TypedefNameDecl *TD = Ty->getDecl();
>   // We don't set size information, but do specify where the typedef was
>   // declared.
> -  SourceLocation Loc = Ty->getDecl()->getLocation();
> +  SourceLocation Loc = TD->getLocation();
> +
> +  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 
> 0));
> 
>   // Typedefs are derived from some other type.
>   return DBuilder.createTypedef(
>   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
>   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
> -  getDeclContextDescriptor(Ty->getDecl()));
> +  TDContext);
> }
> 
> llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
> @@ -1457,6 +1460,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
>   return T;
> }
> 
> +void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
> +  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
> + "D is already mapped to lexical block scope");
> +  if (!LexicalBlockStack.empty())
> +LexicalBlockMap[&D] = LexicalBlockStack.back();
> +}
> +
> +llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
> +   QualType Ty) {
> +  auto I = LexicalBlockMap.find(&D);
> +  if (I != LexicalBlockMap.end()) {
> +RetainedTypes.push_back(Ty.getAsOpaquePtr());
> +return I->second;
> +  }
> +  return getDeclContextDescriptor(cast(&D));
> +}
> +
> void CGDebugInfo::completeType(const EnumDecl *ED) {
>   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
> return;
> @@ -2060,7 +2080,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
> // entered into the ReplaceMap: finalize() will replace the first
> // FwdDecl with the second and then replace the second with
> // complete type.
> -llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
> +llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
> 0));
> llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
> llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
> llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
> @@ -2104,7 +2124,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
> 
>   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
>   unsigned Line = getLineNumber(ED->getLocation());
> -  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
> +  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
> 0));
>   llvm::DIType *ClassTy =
>   ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : 
> nullptr;
>   return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
> @@ -2365,7 +2385,7 @@ llvm::DICompositeType *CGDebugInfo::Crea
>   unsigned Line = getLineNumber(RD->getLocation());
>   StringRef RDName = getClassName(RD);
> 
> -  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
> +  llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 
> 0));
> 
>   // If we ended up creating the type during the context chain construction,
>   // just return that.
> @@ -2536,8 +2556,15 @@ void CGDebugInfo::collectVarDeclProps(co
>   if (DC->isRecord())
> DC = CGM.getContext().getTranslationUnitDecl();
> 
> - llvm::DIScope *Mod = getParentModuleOrNull(VD);
> - VDContext = getContextDescriptor(cast(DC), Mod ? Mod : TheCU);
> +  if (VD->isStaticLo

Re: [PATCH] D19727: [MS] Improved implementation #pragma pack (MS pragmas, part 2)

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

lgtm



Comment at: include/clang/Sema/Sema.h:354-357
@@ -356,6 +353,6 @@
 };
 void Act(SourceLocation PragmaLocation,
  PragmaMsStackAction Action,
  llvm::StringRef StackSlotLabel,
  ValueType Value);
 

Defining a template member function outside of its header is asking for 
trouble. This is a pre-existing issue that probably shouldn't be dealt with as 
part of this change, but eventually this needs to move back to the header.


Comment at: lib/Sema/SemaAttr.cpp:277-278
@@ -276,4 @@
-  // empty.
-  Diag(PragmaLoc, diag::warn_pragma_pop_failed)
-  << "pack" << (Name ? "no record matching name" : "stack empty");
-

d.zobnin.bugzilla wrote:
> Here I removed the "no record matching name" diagnostics, which wasn't 
> covered by any test.
> I'm going to rework and restore it in future patch.
Sure, once the pragma stack has support for popping by name.


http://reviews.llvm.org/D19727



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


Re: [PATCH] D19689: Add Subjects to NoDebugAttr [NFC]

2016-04-29 Thread Paul Robinson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268065: Add a Subjects line to NoDebugAttr [NFC]. (authored 
by probinson).

Changed prior to commit:
  http://reviews.llvm.org/D19689?vs=55482&id=55618#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19689

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/attr-nodebug.c
  cfe/trunk/test/SemaObjC/attr-nodebug.m

Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3572,18 +3572,6 @@
 }
 
 static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (const VarDecl *VD = dyn_cast(D)) {
-if (!VD->hasGlobalStorage())
-  S.Diag(Attr.getLoc(),
- diag::warn_attribute_requires_functions_or_static_globals)
-<< Attr.getName();
-  } else if (!isFunctionOrMethod(D)) {
-S.Diag(Attr.getLoc(),
-   diag::warn_attribute_requires_functions_or_static_globals)
-  << Attr.getName();
-return;
-  }
-
   D->addAttr(::new (S.Context)
  NoDebugAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -973,6 +973,8 @@
 
 def NoDebug : InheritableAttr {
   let Spellings = [GCC<"nodebug">];
+  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
+  "ExpectedFunctionGlobalVarMethodOrProperty">;
   let Documentation = [NoDebugDocs];
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2512,9 +2512,6 @@
 def warn_incomplete_encoded_type : Warning<
   "encoding of %0 type is incomplete because %1 component has unknown 
encoding">,
   InGroup>;
-def warn_attribute_requires_functions_or_static_globals : Warning<
-  "%0 only applies to variables with static storage duration and functions">,
-  InGroup;
 def warn_gnu_inline_attribute_requires_inline : Warning<
   "'gnu_inline' attribute requires function to be marked 'inline',"
   " attribute ignored">,
Index: cfe/trunk/test/Sema/attr-nodebug.c
===
--- cfe/trunk/test/Sema/attr-nodebug.c
+++ cfe/trunk/test/Sema/attr-nodebug.c
@@ -3,7 +3,7 @@
 int a __attribute__((nodebug));
 
 void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies 
to variables with static storage duration and functions}}
+  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute 
only applies to functions and global variables}}
 }
 
 void t1() __attribute__((nodebug));
Index: cfe/trunk/test/SemaObjC/attr-nodebug.m
===
--- cfe/trunk/test/SemaObjC/attr-nodebug.m
+++ cfe/trunk/test/SemaObjC/attr-nodebug.m
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+@interface NSObject
+- (void)doSomething __attribute__((nodebug));
+@end


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -3572,18 +3572,6 @@
 }
 
 static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (const VarDecl *VD = dyn_cast(D)) {
-if (!VD->hasGlobalStorage())
-  S.Diag(Attr.getLoc(),
- diag::warn_attribute_requires_functions_or_static_globals)
-<< Attr.getName();
-  } else if (!isFunctionOrMethod(D)) {
-S.Diag(Attr.getLoc(),
-   diag::warn_attribute_requires_functions_or_static_globals)
-  << Attr.getName();
-return;
-  }
-
   D->addAttr(::new (S.Context)
  NoDebugAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -973,6 +973,8 @@
 
 def NoDebug : InheritableAttr {
   let Spellings = [GCC<"nodebug">];
+  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
+  "ExpectedFunctionGlobalVarMethodOrProperty">;
   let Documentation = [NoDebugDocs];
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKi

r268065 - Add a Subjects line to NoDebugAttr [NFC].

2016-04-29 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Apr 29 12:03:34 2016
New Revision: 268065

URL: http://llvm.org/viewvc/llvm-project?rev=268065&view=rev
Log:
Add a Subjects line to NoDebugAttr [NFC].

The 'nodebug' attribute had hand-coded constraints; replace those with
a Subjects line in Attr.td.
Also add a missing test to verify the attribute is okay on an
Objective-C method.

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

Added:
cfe/trunk/test/SemaObjC/attr-nodebug.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-nodebug.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=268065&r1=268064&r2=268065&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Fri Apr 29 12:03:34 2016
@@ -973,6 +973,8 @@ def NoCommon : InheritableAttr {
 
 def NoDebug : InheritableAttr {
   let Spellings = [GCC<"nodebug">];
+  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
+  "ExpectedFunctionGlobalVarMethodOrProperty">;
   let Documentation = [NoDebugDocs];
 }
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=268065&r1=268064&r2=268065&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 29 12:03:34 
2016
@@ -2512,9 +2512,6 @@ def warn_type_attribute_wrong_type : War
 def warn_incomplete_encoded_type : Warning<
   "encoding of %0 type is incomplete because %1 component has unknown 
encoding">,
   InGroup>;
-def warn_attribute_requires_functions_or_static_globals : Warning<
-  "%0 only applies to variables with static storage duration and functions">,
-  InGroup;
 def warn_gnu_inline_attribute_requires_inline : Warning<
   "'gnu_inline' attribute requires function to be marked 'inline',"
   " attribute ignored">,

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=268065&r1=268064&r2=268065&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Apr 29 12:03:34 2016
@@ -3572,18 +3572,6 @@ void Sema::AddModeAttr(SourceRange AttrR
 }
 
 static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (const VarDecl *VD = dyn_cast(D)) {
-if (!VD->hasGlobalStorage())
-  S.Diag(Attr.getLoc(),
- diag::warn_attribute_requires_functions_or_static_globals)
-<< Attr.getName();
-  } else if (!isFunctionOrMethod(D)) {
-S.Diag(Attr.getLoc(),
-   diag::warn_attribute_requires_functions_or_static_globals)
-  << Attr.getName();
-return;
-  }
-
   D->addAttr(::new (S.Context)
  NoDebugAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));

Modified: cfe/trunk/test/Sema/attr-nodebug.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-nodebug.c?rev=268065&r1=268064&r2=268065&view=diff
==
--- cfe/trunk/test/Sema/attr-nodebug.c (original)
+++ cfe/trunk/test/Sema/attr-nodebug.c Fri Apr 29 12:03:34 2016
@@ -3,7 +3,7 @@
 int a __attribute__((nodebug));
 
 void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies 
to variables with static storage duration and functions}}
+  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute 
only applies to functions and global variables}}
 }
 
 void t1() __attribute__((nodebug));

Added: cfe/trunk/test/SemaObjC/attr-nodebug.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-nodebug.m?rev=268065&view=auto
==
--- cfe/trunk/test/SemaObjC/attr-nodebug.m (added)
+++ cfe/trunk/test/SemaObjC/attr-nodebug.m Fri Apr 29 12:03:34 2016
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+@interface NSObject
+- (void)doSomething __attribute__((nodebug));
+@end


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


RE: r268055 - Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM debug info."

2016-04-29 Thread Aboud, Amjad via cfe-commits
Sorry for that, I broke a LIT test that I added few days ago.
The LIT test need to be fixed and I already fixed it in r268063.

Let's wait till r268063 run bots and see that everything will pass.

Thanks,
Amjad
From: peter_coo...@apple.com [mailto:peter_coo...@apple.com]
Sent: Friday, April 29, 2016 19:53
To: Aboud, Amjad 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r268055 - Recommitted r264281 "Supporting all entities declared in 
lexical scope in LLVM debug info."

Hi Amjad

Either this change, or r268054, appears to have broken the bots.  Can you 
please take a look?

The error at: 
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/22409/consoleFull#8333002949ba4694-19c4-4d7e-bec5-911270d8a58c

Thanks,
Pete
On Apr 29, 2016, at 9:08 AM, Amjad Aboud via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: aaboud
Date: Fri Apr 29 11:08:08 2016
New Revision: 268055

URL: http://llvm.org/viewvc/llvm-project?rev=268055&view=rev
Log:
Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM 
debug info."
After fixing PR26942 in r267004.

Added:
   cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
Modified:
   cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
   cfe/trunk/lib/CodeGen/CGDebugInfo.h
   cfe/trunk/lib/CodeGen/CGDecl.cpp
   cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268055&r1=268054&r2=268055&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 29 11:08:08 2016
@@ -814,15 +814,18 @@ llvm::DIType *CGDebugInfo::CreateType(co

llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
  llvm::DIFile *Unit) {
+  TypedefNameDecl *TD = Ty->getDecl();
  // We don't set size information, but do specify where the typedef was
  // declared.
-  SourceLocation Loc = Ty->getDecl()->getLocation();
+  SourceLocation Loc = TD->getLocation();
+
+  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));

  // Typedefs are derived from some other type.
  return DBuilder.createTypedef(
  getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
  Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(Ty->getDecl()));
+  TDContext);
}

llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1457,6 +1460,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
  return T;
}

+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
+  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
+ "D is already mapped to lexical block scope");
+  if (!LexicalBlockStack.empty())
+LexicalBlockMap[&D] = LexicalBlockStack.back();
+}
+
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
+   QualType Ty) {
+  auto I = LexicalBlockMap.find(&D);
+  if (I != LexicalBlockMap.end()) {
+RetainedTypes.push_back(Ty.getAsOpaquePtr());
+return I->second;
+  }
+  return getDeclContextDescriptor(cast(&D));
+}
+
void CGDebugInfo::completeType(const EnumDecl *ED) {
  if (DebugKind <= codegenoptions::DebugLineTablesOnly)
return;
@@ -2060,7 +2080,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
// entered into the ReplaceMap: finalize() will replace the first
// FwdDecl with the second and then replace the second with
// complete type.
-llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
+llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
@@ -2104,7 +2124,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef

  llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
  unsigned Line = getLineNumber(ED->getLocation());
-  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
+  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
0));
  llvm::DIType *ClassTy =
  ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
  return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@@ -2365,7 +2385,7 @@ llvm::DICompositeType *CGDebugInfo::Crea
  unsigned Line = getLineNumber(RD->getLocation());
  StringRef RDName = getClassName(RD);

-  llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
+  llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));

  // If we ended up creating the type during the context chain construction,
  // just return that.
@@ -2536,8 +2556,15 @@ void CGDebugInfo::collectVarDeclProps(co
  if (DC->isRecord())
DC = CGM.getContext().getTranslationUnitDecl

Re: [PATCH] D19586: Misleading Indentation check

2016-04-29 Thread Etienne Bergeron via cfe-commits
etienneb requested changes to this revision.
etienneb added a comment.
This revision now requires changes to proceed.

Could you lift some logics to the matcher instead of the check.



Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:22
@@ +21,3 @@
+const MatchFinder::MatchResult &Result) {
+  auto *If = Result.Nodes.getNodeAs("if");
+  if (!If->getElse())

nit: const


Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:40
@@ +39,3 @@
+const MatchFinder::MatchResult &Result) {
+  auto *CStmt = Result.Nodes.getNodeAs("stmt");
+  for (unsigned int i = 0; i < CStmt->size() - 1; i++) {

nit: const


Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:67
@@ +66,3 @@
+  diag(NextLoc, "Wrong Indentation - statement is indented as a member "
+"of if statement");
+  }

of if statement  -> previous if statement


Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:72
@@ +71,3 @@
+void MisleadingIndentationCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(ifStmt().bind("if"), this);
+  Finder->addMatcher(compoundStmt(has(ifStmt())).bind("stmt"), this);

instead of doing check at line 23:
```
   if (!If->getElse())
```

you should use 'hasElse' matcher here.

As I get it, you want to match something like:

```
anyOf(
  ifStatement(hasThen(stmt().bind("last")),
 hasElse(unless(compoundStmt())),
  ifStatement(hasThen(unless(compoundStmt())),
 unless(hasElse(stmt().bind("last")))
)
```

Then, by getting node named "last" you can retrieve the indentation of the last 
statement.




Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:77
@@ +76,3 @@
+void MisleadingIndentationCheck::check(const MatchFinder::MatchResult &Result) 
{
+
+  if (Result.Nodes.getNodeAs("if"))

nit: remove empty line


Comment at: clang-tidy/readability/MisleadingIndentationCheck.h:30
@@ +29,3 @@
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void danglingElseCheck(const ast_matchers::MatchFinder::MatchResult &Result);
+  void missingBracesCheck(const ast_matchers::MatchFinder::MatchResult 
&Result);

nit: private


Comment at: docs/clang-tidy/checks/readability-misleading-indentation.rst:8
@@ +7,3 @@
+
+Correct indentation helps to understand code. Mismatch of the syntactical 
structure and the indentation of the code may reveal serious pr
+

could you fix these long lines.


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:62
@@ +61,2 @@
+   return 0;
+}

I would like to see more tests with { }

```
if (xxx) {
} else {
}
```

```
if (xxx) {
}
else {
}
```

```
if (xxx)
{
}
else
{
}
```

```
if (xxx)
  {
  }
else
  {
  }
```


Comment at: test/clang-tidy/readability-misleading-indentation.cpp:62
@@ +61,2 @@
+   return 0;
+}

etienneb wrote:
> I would like to see more tests with { }
> 
> ```
> if (xxx) {
> } else {
> }
> ```
> 
> ```
> if (xxx) {
> }
> else {
> }
> ```
> 
> ```
> if (xxx)
> {
> }
> else
> {
> }
> ```
> 
> ```
> if (xxx)
>   {
>   }
> else
>   {
>   }
> ```
could you add test with macro:

```
#define BLOCK
  if (xxx)\
stm1();  \
stm2();
```


http://reviews.llvm.org/D19586



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


Re: r268055 - Recommitted r264281 "Supporting all entities declared in lexical scope in LLVM debug info."

2016-04-29 Thread Pete Cooper via cfe-commits

> On Apr 29, 2016, at 10:27 AM, Aboud, Amjad  wrote:
> 
> Sorry for that, I broke a LIT test that I added few days ago.
> The LIT test need to be fixed and I already fixed it in r268063.
No problem.  Thanks for the quick reply.
>  
> Let’s wait till r268063 run bots and see that everything will pass.
Sounds good, thanks.  I’ll keep an eye on the bots.

Thanks,
Pete
>   <>
> Thanks,
> Amjad
>  <>From: peter_coo...@apple.com [mailto:peter_coo...@apple.com] 
> Sent: Friday, April 29, 2016 19:53
> To: Aboud, Amjad 
> Cc: cfe-commits@lists.llvm.org
> Subject: Re: r268055 - Recommitted r264281 "Supporting all entities declared 
> in lexical scope in LLVM debug info."
>  
> Hi Amjad
>  
> Either this change, or r268054, appears to have broken the bots.  Can you 
> please take a look?
>  
> The error at: 
> http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/22409/consoleFull#8333002949ba4694-19c4-4d7e-bec5-911270d8a58c
>  
> 
>  
> Thanks,
> Pete
> On Apr 29, 2016, at 9:08 AM, Amjad Aboud via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
>  
> Author: aaboud
> Date: Fri Apr 29 11:08:08 2016
> New Revision: 268055
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=268055&view=rev 
> 
> Log:
> Recommitted r264281 "Supporting all entities declared in lexical scope in 
> LLVM debug info."
> After fixing PR26942 in r267004.
> 
> Added:
>cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp
> Modified:
>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>cfe/trunk/lib/CodeGen/CGDebugInfo.h
>cfe/trunk/lib/CodeGen/CGDecl.cpp
>cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268055&r1=268054&r2=268055&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 29 11:08:08 2016
> @@ -814,15 +814,18 @@ llvm::DIType *CGDebugInfo::CreateType(co
> 
> llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
>   llvm::DIFile *Unit) {
> +  TypedefNameDecl *TD = Ty->getDecl();
>   // We don't set size information, but do specify where the typedef was
>   // declared.
> -  SourceLocation Loc = Ty->getDecl()->getLocation();
> +  SourceLocation Loc = TD->getLocation();
> +
> +  llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 
> 0));
> 
>   // Typedefs are derived from some other type.
>   return DBuilder.createTypedef(
>   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
>   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
> -  getDeclContextDescriptor(Ty->getDecl()));
> +  TDContext);
> }
> 
> llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
> @@ -1457,6 +1460,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt
>   return T;
> }
> 
> +void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
> +  assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
> + "D is already mapped to lexical block scope");
> +  if (!LexicalBlockStack.empty())
> +LexicalBlockMap[&D] = LexicalBlockStack.back();
> +}
> +
> +llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
> +   QualType Ty) {
> +  auto I = LexicalBlockMap.find(&D);
> +  if (I != LexicalBlockMap.end()) {
> +RetainedTypes.push_back(Ty.getAsOpaquePtr());
> +return I->second;
> +  }
> +  return getDeclContextDescriptor(cast(&D));
> +}
> +
> void CGDebugInfo::completeType(const EnumDecl *ED) {
>   if (DebugKind <= codegenoptions::DebugLineTablesOnly)
> return;
> @@ -2060,7 +2080,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
> // entered into the ReplaceMap: finalize() will replace the first
> // FwdDecl with the second and then replace the second with
> // complete type.
> -llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
> +llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 
> 0));
> llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
> llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
> llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
> @@ -2104,7 +2124,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
> 
>   llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
>   unsigned Line = getLineNumber(ED->getLocation());
> -  llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
> +  llvm::DIScope *EnumContext = getDeclarationLexicalScope(*E

Re: [PATCH] D19586: Misleading Indentation check

2016-04-29 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

You should not limit the checker to "if".
The for-statement and while-statement are also wrong for the same reasons:

  while (x)
statement1();
statement2();



  for (...)
statement1();
statement2();

You should test your code over large code base.
You should catch these cases:
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/frame/FrameView.cpp&q=setMediaType&sq=package:chromium&type=cs&l=1253

You will also find strange cases like:
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/icu/source/i18n/usearch.cpp&q=initializepattern&sq=package:chromium&type=cs&l=438

The rule also apply for statements in a same compound:

  {
statement1();
statement2();
  statement3();

see: 
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/icu/source/common/ushape.cpp&q=third_party/icu/source/common/ushape.cpp&sq=package:chromium&type=cs&l=784

But this can be a further improvement.


http://reviews.llvm.org/D19586



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


Re: [PATCH] D16298: Improve test coverage of -Wdouble-promotion

2016-04-29 Thread Robert Lougher via cfe-commits
rob.lougher added a comment.

No problem.  Thanks for the code review.


http://reviews.llvm.org/D16298



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


Re: [PATCH] D19586: Misleading Indentation check

2016-04-29 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D19586#417053, @etienneb wrote:

> The rule also apply for statements in a same compound:
>
>   {
> statement1();
> statement2();
>   statement3();
>
>
> But this can be a further improvement.


I believe this might be an intentional omission, since this can not imply 
semantic problems. But I agree that, this addition makes sense.


http://reviews.llvm.org/D19586



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


r268075 - Improve test coverage of -Wdouble-promotion

2016-04-29 Thread Robert Lougher via cfe-commits
Author: rlougher
Date: Fri Apr 29 12:44:29 2016
New Revision: 268075

URL: http://llvm.org/viewvc/llvm-project?rev=268075&view=rev
Log:
Improve test coverage of -Wdouble-promotion

This patch adds coverage for additional cases where implicit conversion can
occur (assignment and return).  It also adds tests for some cases where a
warning should occur but none is produced.  These are marked as FIXME.

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

Modified:
cfe/trunk/test/Sema/warn-double-promotion.c

Modified: cfe/trunk/test/Sema/warn-double-promotion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-double-promotion.c?rev=268075&r1=268074&r2=268075&view=diff
==
--- cfe/trunk/test/Sema/warn-double-promotion.c (original)
+++ cfe/trunk/test/Sema/warn-double-promotion.c Fri Apr 29 12:44:29 2016
@@ -24,7 +24,7 @@ long double ReturnLongDoubleFromDouble(d
   return d;  //expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
 }
 
-void Convert(float f, double d, long double ld) {
+void Assignment(float f, double d, long double ld) {
   d = f;  //expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
   ld = f; //expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'long double'}}
   ld = d; //expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
@@ -32,3 +32,43 @@ void Convert(float f, double d, long dou
   f = ld;
   d = ld;
 }
+
+extern void DoubleParameter(double);
+extern void LongDoubleParameter(long double);
+
+void ArgumentPassing(float f, double d) {
+  DoubleParameter(f); // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'double'}}
+  LongDoubleParameter(f); // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  LongDoubleParameter(d); // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+}
+
+void BinaryOperator(float f, double d, long double ld) {
+  f = f * d; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  f = d * f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  f = f * ld; // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  f = ld * f; // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  d = d * ld; // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+  d = ld * d; // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+}
+
+void MultiplicationAssignment(float f, double d, long double ld) {
+  d *= f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  ld *= f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'long double'}}
+  ld *= d; // expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
+
+  // FIXME: These cases should produce warnings as above.
+  f *= d;
+  f *= ld;
+  d *= ld;
+}
+
+// FIXME: As with a binary operator, the operands to the conditional operator 
are
+// converted to a common type and should produce a warning.
+void ConditionalOperator(float f, double d, long double ld, int i) {
+  f = i ? f : d;
+  f = i ? d : f;
+  f = i ? f : ld;
+  f = i ? ld : f;
+  d = i ? d : ld;
+  d = i ? ld : d;
+}


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


Re: [PATCH] D16298: Improve test coverage of -Wdouble-promotion

2016-04-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268075: Improve test coverage of -Wdouble-promotion 
(authored by rlougher).

Changed prior to commit:
  http://reviews.llvm.org/D16298?vs=45195&id=55625#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16298

Files:
  cfe/trunk/test/Sema/warn-double-promotion.c

Index: cfe/trunk/test/Sema/warn-double-promotion.c
===
--- cfe/trunk/test/Sema/warn-double-promotion.c
+++ cfe/trunk/test/Sema/warn-double-promotion.c
@@ -24,11 +24,51 @@
   return d;  //expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
 }
 
-void Convert(float f, double d, long double ld) {
+void Assignment(float f, double d, long double ld) {
   d = f;  //expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
   ld = f; //expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'long double'}}
   ld = d; //expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
   f = d;
   f = ld;
   d = ld;
 }
+
+extern void DoubleParameter(double);
+extern void LongDoubleParameter(long double);
+
+void ArgumentPassing(float f, double d) {
+  DoubleParameter(f); // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'double'}}
+  LongDoubleParameter(f); // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  LongDoubleParameter(d); // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+}
+
+void BinaryOperator(float f, double d, long double ld) {
+  f = f * d; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  f = d * f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  f = f * ld; // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  f = ld * f; // expected-warning{{implicit conversion increases 
floating-point precision: 'float' to 'long double'}}
+  d = d * ld; // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+  d = ld * d; // expected-warning{{implicit conversion increases 
floating-point precision: 'double' to 'long double'}}
+}
+
+void MultiplicationAssignment(float f, double d, long double ld) {
+  d *= f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'double'}}
+  ld *= f; // expected-warning{{implicit conversion increases floating-point 
precision: 'float' to 'long double'}}
+  ld *= d; // expected-warning{{implicit conversion increases floating-point 
precision: 'double' to 'long double'}}
+
+  // FIXME: These cases should produce warnings as above.
+  f *= d;
+  f *= ld;
+  d *= ld;
+}
+
+// FIXME: As with a binary operator, the operands to the conditional operator 
are
+// converted to a common type and should produce a warning.
+void ConditionalOperator(float f, double d, long double ld, int i) {
+  f = i ? f : d;
+  f = i ? d : f;
+  f = i ? f : ld;
+  f = i ? ld : f;
+  d = i ? d : ld;
+  d = i ? ld : d;
+}


Index: cfe/trunk/test/Sema/warn-double-promotion.c
===
--- cfe/trunk/test/Sema/warn-double-promotion.c
+++ cfe/trunk/test/Sema/warn-double-promotion.c
@@ -24,11 +24,51 @@
   return d;  //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
 }
 
-void Convert(float f, double d, long double ld) {
+void Assignment(float f, double d, long double ld) {
   d = f;  //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
   ld = f; //expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
   ld = d; //expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
   f = d;
   f = ld;
   d = ld;
 }
+
+extern void DoubleParameter(double);
+extern void LongDoubleParameter(long double);
+
+void ArgumentPassing(float f, double d) {
+  DoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
+  LongDoubleParameter(f); // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'long double'}}
+  LongDoubleParameter(d); // expected-warning{{implicit conversion increases floating-point precision: 'double' to 'long double'}}
+}
+
+void BinaryOperator(float f, double d, long double ld) {
+  f = f * d; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
+  f = d * f; // expected-warning{{implicit conversion increases floating-point precision: 'float' to 'double'}}
+  f = f * 

[clang-tools-extra] r268076 - small reformat to test access

2016-04-29 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Fri Apr 29 12:45:20 2016
New Revision: 268076

URL: http://llvm.org/viewvc/llvm-project?rev=268076&view=rev
Log:
small reformat to test access

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=268076&r1=268075&r2=268076&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Fri Apr 
29 12:45:20 2016
@@ -128,33 +128,33 @@ void PassByValueCheck::storeOptions(Clan
 void PassByValueCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++; the functionality currently does not
   // provide any benefit to other languages, despite being benign.
-  if (getLangOpts().CPlusPlus) {
-Finder->addMatcher(
-cxxConstructorDecl(
-forEachConstructorInitializer(
-cxxCtorInitializer(
-// Clang builds a CXXConstructExpr only whin it knows which
-// constructor will be called. In dependent contexts a
-// ParenListExpr is generated instead of a 
CXXConstructExpr,
-// filtering out templates automatically for us.
-withInitializer(cxxConstructExpr(
-has(declRefExpr(to(
-parmVarDecl(
-hasType(qualType(
-// Match only const-ref or a non-const 
value
-// parameters. Rvalues and const-values
-// shouldn't be modified.
-anyOf(constRefType(),
-  nonConstValueType()
-.bind("Param",
-hasDeclaration(cxxConstructorDecl(
-isCopyConstructor(), unless(isDeleted()),
-hasDeclContext(
-cxxRecordDecl(isMoveConstructible(
-.bind("Initializer")))
-.bind("Ctor"),
-this);
-  }
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(
+  cxxConstructorDecl(
+  forEachConstructorInitializer(
+  cxxCtorInitializer(
+  // Clang builds a CXXConstructExpr only whin it knows which
+  // constructor will be called. In dependent contexts a
+  // ParenListExpr is generated instead of a CXXConstructExpr,
+  // filtering out templates automatically for us.
+  withInitializer(cxxConstructExpr(
+  has(declRefExpr(to(
+  parmVarDecl(
+  hasType(qualType(
+  // Match only const-ref or a non-const value
+  // parameters. Rvalues and const-values
+  // shouldn't be modified.
+  anyOf(constRefType(), nonConstValueType()
+  .bind("Param",
+  hasDeclaration(cxxConstructorDecl(
+  isCopyConstructor(), unless(isDeleted()),
+  hasDeclContext(
+  cxxRecordDecl(isMoveConstructible(
+  .bind("Initializer")))
+  .bind("Ctor"),
+  this);
 }
 
 void PassByValueCheck::registerPPCallbacks(CompilerInstance &Compiler) {


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


Re: [PATCH] D19586: Misleading Indentation check

2016-04-29 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D19586#417063, @xazax.hun wrote:

> In http://reviews.llvm.org/D19586#417053, @etienneb wrote:
>
> > The rule also apply for statements in a same compound:
> >
> >   {
> > statement1();
> > statement2();
> >   statement3();
> >
> >
> > But this can be a further improvement.
>
>
> I believe this might be an intentional omission, since this can not imply 
> semantic problems. But I agree that, this addition makes sense.


Fair enough. This checker is in 'readbility', so I don't see why not. 
But, feel free to postpone. Or let someone else take it.


http://reviews.llvm.org/D19586



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


Re: [PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-29 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 55626.
beanz added a comment.

Adding a test case, and properly rebasing on trunk.


http://reviews.llvm.org/D19693

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/arm-target-features.c

Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -217,6 +217,7 @@
 // ARMV7K:#define __ARM_ARCH 7
 // ARMV7K:#define __ARM_ARCH_EXT_IDIV__ 1
 // ARMV7K:#define __ARM_ARCH_PROFILE 'A'
+// ARMV7K:#define __ARM_DWARF_EH__ 1
 // ARMV7K:#define __ARM_FEATURE_DSP 1
 // ARMV7K:#define __ARM_FP 0xE
 // ARMV7K:#define __ARM_PCS_VFP 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -208,6 +208,10 @@
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 


Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -217,6 +217,7 @@
 // ARMV7K:#define __ARM_ARCH 7
 // ARMV7K:#define __ARM_ARCH_EXT_IDIV__ 1
 // ARMV7K:#define __ARM_ARCH_PROFILE 'A'
+// ARMV7K:#define __ARM_DWARF_EH__ 1
 // ARMV7K:#define __ARM_FEATURE_DSP 1
 // ARMV7K:#define __ARM_FP 0xE
 // ARMV7K:#define __ARM_PCS_VFP 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -208,6 +208,10 @@
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-29 Thread Tim Northover via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks Chris!


http://reviews.llvm.org/D19693



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


r268078 - [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-29 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Apr 29 12:53:00 2016
New Revision: 268078

URL: http://llvm.org/viewvc/llvm-project?rev=268078&view=rev
Log:
[Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

Summary: The Darwin armv7k ABI uses Dwarf EH, so we need to set the OS define 
correctly. Without this the gcc_personality fails to build.

Reviewers: t.p.northover

Subscribers: aemerson, cfe-commits, rengolin

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

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=268078&r1=268077&r2=268078&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Apr 29 12:53:00 2016
@@ -208,6 +208,10 @@ static void getDarwinDefines(MacroBuilde
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 

Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=268078&r1=268077&r2=268078&view=diff
==
--- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/arm-target-features.c Fri Apr 29 12:53:00 2016
@@ -217,6 +217,7 @@
 // ARMV7K:#define __ARM_ARCH 7
 // ARMV7K:#define __ARM_ARCH_EXT_IDIV__ 1
 // ARMV7K:#define __ARM_ARCH_PROFILE 'A'
+// ARMV7K:#define __ARM_DWARF_EH__ 1
 // ARMV7K:#define __ARM_FEATURE_DSP 1
 // ARMV7K:#define __ARM_FP 0xE
 // ARMV7K:#define __ARM_PCS_VFP 1


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


Re: [PATCH] D19693: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI

2016-04-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268078: [Clang][Darwin] Define __ARM_DWARF_EH__ for WatchABI 
(authored by cbieneman).

Changed prior to commit:
  http://reviews.llvm.org/D19693?vs=55626&id=55627#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19693

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/test/Preprocessor/arm-target-features.c

Index: cfe/trunk/test/Preprocessor/arm-target-features.c
===
--- cfe/trunk/test/Preprocessor/arm-target-features.c
+++ cfe/trunk/test/Preprocessor/arm-target-features.c
@@ -217,6 +217,7 @@
 // ARMV7K:#define __ARM_ARCH 7
 // ARMV7K:#define __ARM_ARCH_EXT_IDIV__ 1
 // ARMV7K:#define __ARM_ARCH_PROFILE 'A'
+// ARMV7K:#define __ARM_DWARF_EH__ 1
 // ARMV7K:#define __ARM_FEATURE_DSP 1
 // ARMV7K:#define __ARM_FP 0xE
 // ARMV7K:#define __ARM_PCS_VFP 1
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -208,6 +208,10 @@
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 


Index: cfe/trunk/test/Preprocessor/arm-target-features.c
===
--- cfe/trunk/test/Preprocessor/arm-target-features.c
+++ cfe/trunk/test/Preprocessor/arm-target-features.c
@@ -217,6 +217,7 @@
 // ARMV7K:#define __ARM_ARCH 7
 // ARMV7K:#define __ARM_ARCH_EXT_IDIV__ 1
 // ARMV7K:#define __ARM_ARCH_PROFILE 'A'
+// ARMV7K:#define __ARM_DWARF_EH__ 1
 // ARMV7K:#define __ARM_FEATURE_DSP 1
 // ARMV7K:#define __ARM_FP 0xE
 // ARMV7K:#define __ARM_PCS_VFP 1
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -208,6 +208,10 @@
   if (Triple.isOSDarwin())
 Builder.defineMacro("__MACH__");
 
+  // The Watch ABI uses Dwarf EH.
+  if(Triple.isWatchABI())
+Builder.defineMacro("__ARM_DWARF_EH__");
+
   PlatformMinVersion = VersionTuple(Maj, Min, Rev);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r268079 - Add boost-use-to-string

2016-04-29 Thread Piotr Padlewski via cfe-commits
Author: prazek
Date: Fri Apr 29 12:58:29 2016
New Revision: 268079

URL: http://llvm.org/viewvc/llvm-project?rev=268079&view=rev
Log:
Add boost-use-to-string

http://reviews.llvm.org/D18136

Added:
clang-tools-extra/trunk/clang-tidy/boost/
clang-tools-extra/trunk/clang-tidy/boost/BoostTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/boost/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp
clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/boost-use-to-string.rst
clang-tools-extra/trunk/test/clang-tidy/boost-use-to-string.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/docs/clang-tidy/index.rst

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=268079&r1=268078&r2=268079&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Fri Apr 29 12:58:29 2016
@@ -27,6 +27,7 @@ add_clang_library(clangTidy
 
 add_subdirectory(tool)
 add_subdirectory(plugin)
+add_subdirectory(boost)
 add_subdirectory(cert)
 add_subdirectory(llvm)
 add_subdirectory(cppcoreguidelines)

Added: clang-tools-extra/trunk/clang-tidy/boost/BoostTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/boost/BoostTidyModule.cpp?rev=268079&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/boost/BoostTidyModule.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/boost/BoostTidyModule.cpp Fri Apr 29 
12:58:29 2016
@@ -0,0 +1,38 @@
+//===--- BoostTidyModule.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 "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+#include "UseToStringCheck.h"
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace boost {
+
+class BoostModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("boost-use-to-string");
+  }
+};
+
+// Register the BoostModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add X("boost-module",
+   "Add boost checks.");
+
+} // namespace boost
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the BoostModule.
+volatile int BoostModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/boost/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/boost/CMakeLists.txt?rev=268079&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/boost/CMakeLists.txt (added)
+++ clang-tools-extra/trunk/clang-tidy/boost/CMakeLists.txt Fri Apr 29 12:58:29 
2016
@@ -0,0 +1,14 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangTidyBoostModule
+  BoostTidyModule.cpp
+  UseToStringCheck.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangTidy
+  clangTidyUtils
+  )

Added: clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp?rev=268079&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/boost/UseToStringCheck.cpp Fri Apr 29 
12:58:29 2016
@@ -0,0 +1,73 @@
+//===--- UseToStringCheck.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 "UseToStringCheck.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace boost {
+
+AST_MATCHER(Type, isStrictlyInteger) {
+  

RE: [PATCH] D19622: [libc++] Implement the member functions of a local struct.

2016-04-29 Thread Stephan T. Lavavej via cfe-commits
[Sebastian Redl]
> I rail against this warning here:
> http://stackoverflow.com/questions/18979503/why-locally-defined-struct-in-function-need-assignment-operator-copy-construct/18979812#18979812
> It's not just that the warning is silly, it's also a level 1 warning, which 
> is extra-silly. (MSVC's silly warnings are usually level 4.)

Agreed. I've filed VSO#217735 "warning C4822 "local class member function does 
not have a body" is annoying and pointless, especially at level 1" in our 
internal database, recommending that the warning should be removed outright.

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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-29 Thread Akira Hatanaka via cfe-commits
If I add an assert to check (F != Flags) in setFlags, 2700+ out of 5000+ clang 
regression tests fail. I haven’t figured out which parts of clang are passing 
the same value to setFlags.

> On Apr 28, 2016, at 7:38 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> On Thu, Apr 28, 2016 at 7:34 PM, Akira Hatanaka via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> ahatanak added a comment.
> 
> Thanks for the review. I committed the patch in r267956 and r267975.
> 
> Do you think I should make setFlags(unsigned F) return early if F == Flags?
> 
> I don't think that should happen in practice, so it doesn't seem worth 
> checking.
> 
> Repository:
>   rL LLVM
> 
> http://reviews.llvm.org/D19175 
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org 
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


Re: [PATCH] D19220: [Concepts] Pass requires-clause to ActOnTemplateParameterList; NFC

2016-04-29 Thread Hubert Tong via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268081: [Concepts] Pass requires-clause to 
ActOnTemplateParameterList; NFC (authored by hubert.reinterpretcast).

Changed prior to commit:
  http://reviews.llvm.org/D19220?vs=54050&id=55629#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19220

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Parse/ParseTemplate.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -5647,7 +5647,8 @@
  SourceLocation TemplateLoc,
  SourceLocation LAngleLoc,
  ArrayRef Params,
- SourceLocation RAngleLoc);
+ SourceLocation RAngleLoc,
+ Expr *RequiresClause);
 
   /// \brief The context in which we are checking a template parameter list.
   enum TemplateParamListContext {
Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -817,18 +817,21 @@
   return Param;
 }
 
-/// ActOnTemplateParameterList - Builds a TemplateParameterList that
-/// contains the template parameters in Params/NumParams.
+/// ActOnTemplateParameterList - Builds a TemplateParameterList, optionally
+/// constrained by RequiresClause, that contains the template parameters in
+/// Params.
 TemplateParameterList *
 Sema::ActOnTemplateParameterList(unsigned Depth,
  SourceLocation ExportLoc,
  SourceLocation TemplateLoc,
  SourceLocation LAngleLoc,
  ArrayRef Params,
- SourceLocation RAngleLoc) {
+ SourceLocation RAngleLoc,
+ Expr *RequiresClause) {
   if (ExportLoc.isValid())
 Diag(ExportLoc, diag::warn_template_export_unsupported);
 
+  // FIXME: store RequiresClause
   return TemplateParameterList::Create(
   Context, TemplateLoc, LAngleLoc,
   llvm::makeArrayRef((NamedDecl *const *)Params.data(), Params.size()),
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -1670,7 +1670,7 @@
   // template specialization.
   FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
   0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
-  LAngleLoc));
+  LAngleLoc, nullptr));
   TemplateParams = &FakedParamLists;
 }
   }
Index: cfe/trunk/lib/Parse/ParseTemplate.cpp
===
--- cfe/trunk/lib/Parse/ParseTemplate.cpp
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp
@@ -122,20 +122,15 @@
   return nullptr;
 }
 
-ParamLists.push_back(
-  Actions.ActOnTemplateParameterList(CurTemplateDepthTracker.getDepth(), 
- ExportLoc,
- TemplateLoc, LAngleLoc,
- TemplateParams, RAngleLoc));
-
+ExprResult OptionalRequiresClauseConstraintER;
 if (!TemplateParams.empty()) {
   isSpecialization = false;
   ++CurTemplateDepthTracker;
 
   if (TryConsumeToken(tok::kw_requires)) {
-ExprResult ER =
+OptionalRequiresClauseConstraintER =
 Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression());
-if (!ER.isUsable()) {
+if (!OptionalRequiresClauseConstraintER.isUsable()) {
   // Skip until the semi-colon or a '}'.
   SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
   TryConsumeToken(tok::semi);
@@ -145,6 +140,10 @@
 } else {
   LastParamListWasEmpty = true;
 }
+
+ParamLists.push_back(Actions.ActOnTemplateParameterList(
+CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
+TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.get()));
   } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
 
   unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
@@ -287,7 +286,7 @@
 TemplateParameterLists FakedParamLists;
 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
-LAngleLoc));
+LAngleLoc, nullptr));
 
 return ParseFunctionDefinition(
 DeclaratorInfo, ParsedTemplateI

r268081 - [Concepts] Pass requires-clause to ActOnTemplateParameterList; NFC

2016-04-29 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Fri Apr 29 13:05:37 2016
New Revision: 268081

URL: http://llvm.org/viewvc/llvm-project?rev=268081&view=rev
Log:
[Concepts] Pass requires-clause to ActOnTemplateParameterList; NFC

Summary:
Prepare to store requires-clause expression for access via
TemplateParameterList.

Reviewers: aaron.ballman, faisalv, rsmith

Subscribers: cfe-commits, nwilson

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268081&r1=268080&r2=268081&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Apr 29 13:05:37 2016
@@ -5647,7 +5647,8 @@ public:
  SourceLocation TemplateLoc,
  SourceLocation LAngleLoc,
  ArrayRef Params,
- SourceLocation RAngleLoc);
+ SourceLocation RAngleLoc,
+ Expr *RequiresClause);
 
   /// \brief The context in which we are checking a template parameter list.
   enum TemplateParamListContext {

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=268081&r1=268080&r2=268081&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Fri Apr 29 13:05:37 2016
@@ -2004,7 +2004,7 @@ Decl *Parser::ParseDeclarationAfterDecla
 TemplateParameterLists FakedParamLists;
 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
-LAngleLoc));
+LAngleLoc, nullptr));
 
 ThisDecl =
 Actions.ActOnTemplateDeclarator(getCurScope(), FakedParamLists, D);

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=268081&r1=268080&r2=268081&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Apr 29 13:05:37 2016
@@ -1670,7 +1670,7 @@ void Parser::ParseClassSpecifier(tok::To
   // template specialization.
   FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
   0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, None,
-  LAngleLoc));
+  LAngleLoc, nullptr));
   TemplateParams = &FakedParamLists;
 }
   }

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=268081&r1=268080&r2=268081&view=diff
==
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Fri Apr 29 13:05:37 2016
@@ -122,20 +122,15 @@ Parser::ParseTemplateDeclarationOrSpecia
   return nullptr;
 }
 
-ParamLists.push_back(
-  Actions.ActOnTemplateParameterList(CurTemplateDepthTracker.getDepth(), 
- ExportLoc,
- TemplateLoc, LAngleLoc,
- TemplateParams, RAngleLoc));
-
+ExprResult OptionalRequiresClauseConstraintER;
 if (!TemplateParams.empty()) {
   isSpecialization = false;
   ++CurTemplateDepthTracker;
 
   if (TryConsumeToken(tok::kw_requires)) {
-ExprResult ER =
+OptionalRequiresClauseConstraintER =
 Actions.CorrectDelayedTyposInExpr(ParseConstraintExpression());
-if (!ER.isUsable()) {
+if (!OptionalRequiresClauseConstraintER.isUsable()) {
   // Skip until the semi-colon or a '}'.
   SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
   TryConsumeToken(tok::semi);
@@ -145,6 +140,10 @@ Parser::ParseTemplateDeclarationOrSpecia
 } else {
   LastParamListWasEmpty = true;
 }
+
+ParamLists.push_back(Actions.ActOnTemplateParameterList(
+CurTemplateDepthTracker.getDepth(), ExportLoc, TemplateLoc, LAngleLoc,
+TemplateParams, RAngleLoc, OptionalRequiresClauseConstraintER.get()));
   } while (Tok.isOneOf(tok::kw_export, tok::kw_template));
 
   unsigned NewFlags = getCurScope()->getFlags() & ~Scope::TemplateParamScope;
@@ -287,7 +286,7 @@ Parser::ParseSingleDeclarationAfterTempl
 TemplateParameterLists FakedParamLists;
 FakedParamLists.p

r268082 - Fix crash in BuildCXXDefaultInitExpr.

2016-04-29 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Apr 29 13:06:53 2016
New Revision: 268082

URL: http://llvm.org/viewvc/llvm-project?rev=268082&view=rev
Log:
Fix crash in BuildCXXDefaultInitExpr.

Fix crash in BuildCXXDefaultInitExpr when member of template class has
same name as the class itself.

Based on patch by Raphael "Teemperor" Isemann!

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

Added:
cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=268082&r1=268081&r2=268082&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Apr 29 13:06:53 2016
@@ -11412,8 +11412,19 @@ ExprResult Sema::BuildCXXDefaultInitExpr
 CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern();
 DeclContext::lookup_result Lookup =
 ClassPattern->lookup(Field->getDeclName());
-assert(Lookup.size() == 1);
-FieldDecl *Pattern = cast(Lookup[0]);
+
+// Lookup can return at most two results: the pattern for the field, or the
+// injected class name of the parent record. No other member can have the
+// same name as the field.
+assert(!Lookup.empty() && Lookup.size() <= 2 &&
+   "more than two lookup results for field name");
+FieldDecl *Pattern = dyn_cast(Lookup[0]);
+if (!Pattern) {
+  assert(isa(Lookup[0]) &&
+ "cannot have other non-field member with same name");
+  Pattern = cast(Lookup[1]);
+}
+
 if (InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field)))
   return ExprError();

Added: cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp?rev=268082&view=auto
==
--- cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp (added)
+++ cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp Fri Apr 
29 13:06:53 2016
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+template 
+struct A {
+  // Used to crash when field was named after class.
+  int A = 0;
+};
+A a;


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


Re: [PATCH] D19721: Fix crash in BuildCXXDefaultInitExpr.

2016-04-29 Thread Reid Kleckner via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268082: Fix crash in BuildCXXDefaultInitExpr. (authored by 
rnk).

Changed prior to commit:
  http://reviews.llvm.org/D19721?vs=55580&id=55631#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19721

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp

Index: cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
===
--- cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
+++ cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+template 
+struct A {
+  // Used to crash when field was named after class.
+  int A = 0;
+};
+A a;
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -11412,8 +11412,19 @@
 CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern();
 DeclContext::lookup_result Lookup =
 ClassPattern->lookup(Field->getDeclName());
-assert(Lookup.size() == 1);
-FieldDecl *Pattern = cast(Lookup[0]);
+
+// Lookup can return at most two results: the pattern for the field, or the
+// injected class name of the parent record. No other member can have the
+// same name as the field.
+assert(!Lookup.empty() && Lookup.size() <= 2 &&
+   "more than two lookup results for field name");
+FieldDecl *Pattern = dyn_cast(Lookup[0]);
+if (!Pattern) {
+  assert(isa(Lookup[0]) &&
+ "cannot have other non-field member with same name");
+  Pattern = cast(Lookup[1]);
+}
+
 if (InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field)))
   return ExprError();


Index: cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
===
--- cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
+++ cfe/trunk/test/SemaCXX/pr27047-default-init-expr-name-conflict.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+
+template 
+struct A {
+  // Used to crash when field was named after class.
+  int A = 0;
+};
+A a;
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -11412,8 +11412,19 @@
 CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern();
 DeclContext::lookup_result Lookup =
 ClassPattern->lookup(Field->getDeclName());
-assert(Lookup.size() == 1);
-FieldDecl *Pattern = cast(Lookup[0]);
+
+// Lookup can return at most two results: the pattern for the field, or the
+// injected class name of the parent record. No other member can have the
+// same name as the field.
+assert(!Lookup.empty() && Lookup.size() <= 2 &&
+   "more than two lookup results for field name");
+FieldDecl *Pattern = dyn_cast(Lookup[0]);
+if (!Pattern) {
+  assert(isa(Lookup[0]) &&
+ "cannot have other non-field member with same name");
+  Pattern = cast(Lookup[1]);
+}
+
 if (InstantiateInClassInitializer(Loc, Field, Pattern,
   getTemplateInstantiationArgs(Field)))
   return ExprError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19679: Method pool in modules: sync up out of date selectors before writing the module

2016-04-29 Thread Doug Gregor via cfe-commits
doug.gregor added a comment.

Mostly looks good, but see my comment about MapVector invalidation.



Comment at: lib/Serialization/ASTWriter.cpp:4394
@@ +4393,3 @@
+  // date, so we need to pull in the new content here.
+  for (auto &SelectorAndID : SelectorIDs)
+SemaRef.updateOutOfDateSelector(SelectorAndID.first);

Are we certain that SelectorIDs cannot get updated during this iteration under 
any circumstances? If the underlying vector were to get reallocated, we'd end 
up with a horrible-to-reproduce use-after-free here. It might be worth copying 
SelectorIDs or indexing by an integer value rather than using the for-each loop.


http://reviews.llvm.org/D19679



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


Re: [PATCH] D19725: [Coverage] Fix an issue where a coverage region might not be created for a macro containing for or while statements.

2016-04-29 Thread Vedant Kumar via cfe-commits
vsk added a comment.

Thanks, lgtm with a nit.



Comment at: lib/CodeGen/CoverageMappingGen.cpp:452
@@ +451,3 @@
+[=](const SourceMappingRegion &Region) {
+  assert(Region.hasStartLoc() && "incomplete region");
+  assert(Region.hasEndLoc() && "incomplete region");

These asserts replicate checks inside of get{Start,End}Loc, so I think it's 
cleaner to drop them.


http://reviews.llvm.org/D19725



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


r268085 - [MS] Make #pragma pack use PragmaStack<> class.

2016-04-29 Thread Denis Zobnin via cfe-commits
Author: dzobnin
Date: Fri Apr 29 13:17:40 2016
New Revision: 268085

URL: http://llvm.org/viewvc/llvm-project?rev=268085&view=rev
Log:
[MS] Make #pragma pack use PragmaStack<> class.

Make implementation of #pragma pack consistent with other "stack" pragmas.
Use PragmaStack<> class instead of old representation of internal stack.
Don't change compiler's behavior.

TODO:
  1. Introduce diagnostics on popping named slots from pragma stacks.

Reviewer: rnk

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=268085&r1=268084&r2=268085&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Apr 29 13:17:40 2016
@@ -317,10 +317,6 @@ public:
   /// This is used as part of a hack to omit that class from ADL results.
   DeclarationName VAListTagName;
 
-  /// PackContext - Manages the stack for \#pragma pack. An alignment
-  /// of 0 indicates default alignment.
-  void *PackContext; // Really a "PragmaPackStack*"
-
   bool MSStructPragmaOn; // True when \#pragma ms_struct on
 
   /// \brief Controls member pointer representation format under the MS ABI.
@@ -338,6 +334,7 @@ public:
 PSK_Set   = 0x1,// #pragma (value)
 PSK_Push  = 0x2,// #pragma (push[, id])
 PSK_Pop   = 0x4,// #pragma (pop[, id])
+PSK_Show  = 0x8,// #pragma (show) -- only for "pack"!
 PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
 PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
   };
@@ -400,11 +397,15 @@ public:
   /// 2: Always insert vtordisps to support RTTI on partially constructed
   ///objects
   PragmaStack VtorDispStack;
+  // #pragma pack.
+  // Sentinel to represent when the stack is set to mac68k alignment.
+  static const unsigned kMac68kAlignmentSentinel = ~0U;
+  PragmaStack PackStack;
+  // Segment #pragmas.
   PragmaStack DataSegStack;
   PragmaStack BSSSegStack;
   PragmaStack ConstSegStack;
   PragmaStack CodeSegStack;
-  // TODO: Change implementation of #pragma pack to use PragmaStack<> approach.
 
   // RAII object to push / pop sentinel slots for all MS #pragma stacks.
   // Actions should be performed only if we enter / exit a C++ method body.
@@ -7658,20 +7659,9 @@ public:
   void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
SourceLocation PragmaLoc);
 
-  enum PragmaPackKind {
-PPK_Default, // #pragma pack([n])
-PPK_Show,// #pragma pack(show), only supported by MSVC.
-PPK_Push,// #pragma pack(push, [identifier], [n])
-PPK_Pop  // #pragma pack(pop, [identifier], [n])
-  };
-
   /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
-  void ActOnPragmaPack(PragmaPackKind Kind,
-   IdentifierInfo *Name,
-   Expr *Alignment,
-   SourceLocation PragmaLoc,
-   SourceLocation LParenLoc,
-   SourceLocation RParenLoc);
+  void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
+   StringRef SlotLabel, Expr *Alignment);
 
   /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
   void ActOnPragmaMSStruct(PragmaMSStructKind Kind);

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=268085&r1=268084&r2=268085&view=diff
==
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Fri Apr 29 13:17:40 2016
@@ -337,11 +337,9 @@ void Parser::HandlePragmaVisibility() {
 
 namespace {
 struct PragmaPackInfo {
-  Sema::PragmaPackKind Kind;
-  IdentifierInfo *Name;
+  Sema::PragmaMsStackAction Action;
+  StringRef SlotLabel;
   Token Alignment;
-  SourceLocation LParenLoc;
-  SourceLocation RParenLoc;
 };
 } // end anonymous namespace
 
@@ -356,8 +354,8 @@ void Parser::HandlePragmaPack() {
 if (Alignment.isInvalid())
   return;
   }
-  Actions.ActOnPragmaPack(Info->Kind, Info->Name, Alignment.get(), PragmaLoc,
-  Info->LParenLoc, Info->RParenLoc);
+  Actions.ActOnPragmaPack(PragmaLoc, Info->Action, Info->SlotLabel,
+  Alignment.get());
 }
 
 void Parser::HandlePragmaMSStruct() {
@@ -962,11 +960,10 @@ void PragmaPackHandler::HandlePragma(Pre
 return;
   }
 
-  Sema::PragmaPackKind Kind = Sema::PPK_Default;
-  IdentifierInfo *Name = nullptr;
+  Sema::PragmaMsStackAction Action = Sema::PSK_Reset;
+  StringRef SlotL

Re: [PATCH] D19727: [MS] Improved implementation #pragma pack (MS pragmas, part 2)

2016-04-29 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268085: [MS] Make #pragma pack use PragmaStack<> class. 
(authored by dzobnin).

Changed prior to commit:
  http://reviews.llvm.org/D19727?vs=55598&id=55634#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19727

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaAttr.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -317,10 +317,6 @@
   /// This is used as part of a hack to omit that class from ADL results.
   DeclarationName VAListTagName;
 
-  /// PackContext - Manages the stack for \#pragma pack. An alignment
-  /// of 0 indicates default alignment.
-  void *PackContext; // Really a "PragmaPackStack*"
-
   bool MSStructPragmaOn; // True when \#pragma ms_struct on
 
   /// \brief Controls member pointer representation format under the MS ABI.
@@ -338,6 +334,7 @@
 PSK_Set   = 0x1,// #pragma (value)
 PSK_Push  = 0x2,// #pragma (push[, id])
 PSK_Pop   = 0x4,// #pragma (pop[, id])
+PSK_Show  = 0x8,// #pragma (show) -- only for "pack"!
 PSK_Push_Set  = PSK_Push | PSK_Set, // #pragma (push[, id], value)
 PSK_Pop_Set   = PSK_Pop | PSK_Set,  // #pragma (pop[, id], value)
   };
@@ -400,11 +397,15 @@
   /// 2: Always insert vtordisps to support RTTI on partially constructed
   ///objects
   PragmaStack VtorDispStack;
+  // #pragma pack.
+  // Sentinel to represent when the stack is set to mac68k alignment.
+  static const unsigned kMac68kAlignmentSentinel = ~0U;
+  PragmaStack PackStack;
+  // Segment #pragmas.
   PragmaStack DataSegStack;
   PragmaStack BSSSegStack;
   PragmaStack ConstSegStack;
   PragmaStack CodeSegStack;
-  // TODO: Change implementation of #pragma pack to use PragmaStack<> approach.
 
   // RAII object to push / pop sentinel slots for all MS #pragma stacks.
   // Actions should be performed only if we enter / exit a C++ method body.
@@ -7658,20 +7659,9 @@
   void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
SourceLocation PragmaLoc);
 
-  enum PragmaPackKind {
-PPK_Default, // #pragma pack([n])
-PPK_Show,// #pragma pack(show), only supported by MSVC.
-PPK_Push,// #pragma pack(push, [identifier], [n])
-PPK_Pop  // #pragma pack(pop, [identifier], [n])
-  };
-
   /// ActOnPragmaPack - Called on well formed \#pragma pack(...).
-  void ActOnPragmaPack(PragmaPackKind Kind,
-   IdentifierInfo *Name,
-   Expr *Alignment,
-   SourceLocation PragmaLoc,
-   SourceLocation LParenLoc,
-   SourceLocation RParenLoc);
+  void ActOnPragmaPack(SourceLocation PragmaLoc, PragmaMsStackAction Action,
+   StringRef SlotLabel, Expr *Alignment);
 
   /// ActOnPragmaMSStruct - Called on well formed \#pragma ms_struct [on|off].
   void ActOnPragmaMSStruct(PragmaMSStructKind Kind);
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -79,12 +79,13 @@
 Diags(PP.getDiagnostics()), SourceMgr(PP.getSourceManager()),
 CollectStats(false), CodeCompleter(CodeCompleter),
 CurContext(nullptr), OriginalLexicalContext(nullptr),
-PackContext(nullptr), MSStructPragmaOn(false),
+MSStructPragmaOn(false),
 MSPointerToMemberRepresentationMethod(
 LangOpts.getMSPointerToMemberRepresentationMethod()),
 VtorDispStack(MSVtorDispAttr::Mode(LangOpts.VtorDispMode)),
-DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
-CodeSegStack(nullptr), CurInitSeg(nullptr), VisContext(nullptr),
+PackStack(0), DataSegStack(nullptr), BSSSegStack(nullptr),
+ConstSegStack(nullptr), CodeSegStack(nullptr), CurInitSeg(nullptr),
+VisContext(nullptr),
 IsBuildingRecoveryCallExpr(false),
 ExprNeedsCleanups(false), LateTemplateParser(nullptr),
 LateTemplateParserCleanup(nullptr),
@@ -252,7 +253,6 @@
 
 Sema::~Sema() {
   llvm::DeleteContainerSeconds(LateParsedTemplateMap);
-  if (PackContext) FreePackedContext();
   if (VisContext) FreeVisContext();
   // Kill all the active scopes.
   for (unsigned I = 1, E = FunctionScopes.size(); I != E; ++I)
Index: cfe/trunk/lib/Sema/SemaAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaAttr.cpp
+++ cfe/trunk/lib/Sema/SemaAttr.cpp
@@ -25,86 +25,6 @@
 // Pragma 'pack' and 'options align'
 //===--===//
 
-namespace {
-  struct PackStackEntry {
-// We just use a sentinel to represent when the

Re: [PATCH] D19687: Set PIELevel module flag

2016-04-29 Thread Sriraman Tallam via cfe-commits
tmsriram closed this revision.
tmsriram added a comment.

267948


http://reviews.llvm.org/D19687



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


Re: [PATCH] D19175: Fix for PR27015 (variable template initialized with a generic lambda expression)

2016-04-29 Thread Richard Smith via cfe-commits
On Fri, Apr 29, 2016 at 11:07 AM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> If I add an assert to check (F != Flags) in setFlags, 2700+ out of 5000+
> clang regression tests fail. I haven’t figured out which parts of clang are
> passing the same value to setFlags.
>

What are you initializing Flags to in the constructor?

> On Apr 28, 2016, at 7:38 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> On Thu, Apr 28, 2016 at 7:34 PM, Akira Hatanaka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> ahatanak added a comment.
>>
>> Thanks for the review. I committed the patch in r267956 and r267975.
>>
>> Do you think I should make setFlags(unsigned F) return early if F ==
>> Flags?
>
>
> I don't think that should happen in practice, so it doesn't seem worth
> checking.
>
> Repository:
>>   rL LLVM
>>
>> http://reviews.llvm.org/D19175
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >